Skip to content

Commit

Permalink
Update saved-grants page and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed Feb 26, 2025
1 parent af304b8 commit 419c549
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
19 changes: 19 additions & 0 deletions documentation/frontend/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ It's recommended that developers configure their code editor to auto run these t
- `npm run format-check`: Check files for prettier formatting violations without fixing them
- `npm run all-checks`: Runs linting, typescript check, unit testing, and creates a build - simulating locally tests that are run on PRs in Github Actions, other than e2e tests

#### Frontend coding conventions

Some common uses and conventions are not covered in formatting and linting tools or widely agreed upon across the industry.

##### Naming resolved and unresolved promises

Constants that represent unresolved promises should be named `varNamePromise(s)`.

Constants that represent resolved promises should be named `resolvedVarName(s)`

For example:

```javascript

const bunnyPromises = getBunnyPromises();
const resolvedBunnies = Promise.all(bunnyPromies);
```


### 🖼️ Storybook

Storybook is a [frontend workshop](https://bradfrost.com/blog/post/a-frontend-workshop-environment/) for developing and documenting pages and components in isolation. It allows you to render the same React components and files in the `src/` directory in a browser, without the need for a server or database. This allows you to develop and manually test components without having to run the entire Next.js application.
Expand Down
26 changes: 16 additions & 10 deletions frontend/src/app/[locale]/saved-grants/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ const SavedOpportunitiesList = ({
return (
<ul className="usa-prose usa-list--unstyled">
{opportunities.map((opportunity) => (
<li key={opportunity?.opportunity_id}>
<SearchResultsListItem opportunity={opportunity} saved={true} />
</li>
<>
{opportunity && (
<li key={opportunity.opportunity_id}>
<SearchResultsListItem opportunity={opportunity} saved={true} />
</li>
)}
</>
))}
</ul>
);
Expand Down Expand Up @@ -65,13 +69,15 @@ export default async function SavedGrants({ params }: LocalizedPageProps) {
const { locale } = await params;
const t = await getTranslations({ locale });
const savedOpportunities = await fetchSavedOpportunities();
const opportunities = savedOpportunities.map(async (savedOpportunity) => {
const { data: opportunityData } = await getOpportunityDetails(
String(savedOpportunity.opportunity_id),
);
return opportunityData;
});
const resolvedOpportunities = await Promise.all(opportunities);
const opportunityPromises = savedOpportunities.map(
async (savedOpportunity) => {
const { data: opportunityData } = await getOpportunityDetails(
String(savedOpportunity.opportunity_id),
);
return opportunityData;
},
);
const resolvedOpportunities = await Promise.all(opportunityPromises);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"server-only";

import { getSession } from "src/services/auth/session";
import { userSavedOpportunity } from "src/services/fetch/fetchers/fetchers";
import { SavedOpportunity } from "src/types/saved-opportunity/savedOpportunityResponseTypes";
Expand Down

0 comments on commit 419c549

Please sign in to comment.