Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[Issue #96]: Opportunity listing page (first pass) #97

Merged
merged 7 commits into from
Jun 20, 2024

Conversation

rylew1
Copy link
Collaborator

@rylew1 rylew1 commented Jun 18, 2024

Summary

Fixes #96

Time to review: 10 min

Changes proposed

  • Add new id-based opportunity page
  • Add new OpportunityListingAPI class extended from BaseAPI
  • Make searchInputs/QueryParamData in BaseAPI and errors.ts optional params (only used for search page)
  • Update sitemap to replace [id] in url with 1
  • Add test coverage

Context for reviewers

Page just shows a table with simple results:

Screen.Recording.2024-06-18.at.7.00.46.PM.mov

@rylew1 rylew1 marked this pull request as draft June 18, 2024 23:03
Copy link

github-actions bot commented Jun 19, 2024

Coverage report for ./frontend

St.
Category Percentage Covered / Total
🟢 Statements
83.87% (+0.3% 🔼)
879/1048
🟡 Branches
68.25% (-0.14% 🔻)
230/337
🟡 Functions
76.11% (+0.09% 🔼)
172/226
🟢 Lines
83.45% (+0.32% 🔼)
827/991
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / OpportunityListingAPI.ts
88.89% 100% 75% 88.89%
🟢
... / isSummary.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴 src/errors.ts 51.72%
50% (-7.14% 🔻)
50% 51.72%

Test suite run success

175 tests passing in 57 suites.

Report generated by 🧪jest coverage report action from 9a11a74

@@ -69,7 +65,7 @@ export default abstract class BaseApi {
basePath: string,
namespace: string,
subPath: string,
queryParamData: QueryParamData,
queryParamData?: QueryParamData,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all queryParamData / searchInput references need to be an optional param because they're only used for search (SearchOpportunityAPI class) and not when the derived OpportunityListingAPI class is used.

@@ -0,0 +1,24 @@
import "server-only";
Copy link
Collaborator Author

@rylew1 rylew1 Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only ever run this code on the next server

@@ -32,6 +32,7 @@ export function getNextRoutes(src: string): string[] {
.replace("/page.tsx", "")
.replace(/\[locale\]/g, "")
.replace(/\\/g, "/")
.replace(/\[id\]/g, "1") // for id-based routes like /opportunity/[id]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow pa11y to run on the opportunity listing page by just setting any [id] found to 1 - resulting in /opportunity/1

@@ -12,6 +12,7 @@ jest.mock("../../src/utils/getRoutes", () => {

const mockedListPaths = listPaths as jest.MockedFunction<typeof listPaths>;

// TODO: https://github.com/navapbc/simpler-grants-gov/issues/98
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is a little wonky rn - it's not actually mocking properly so it pulls what the sitemap actually pulls (so we have to update the test every time there's a new route - which is not really testing the functions in getRoutes in isolation) - so there's a ticket to come back to this

@rylew1 rylew1 marked this pull request as ready for review June 19, 2024 01:59
@rylew1 rylew1 requested review from btabaska and chouinar June 19, 2024 02:00
Copy link
Collaborator

@btabaska btabaska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@btabaska btabaska self-requested a review June 20, 2024 13:55
@rylew1 rylew1 changed the title [Issue #96]: Opportunity listing page [Issue #96]: Opportunity listing page (first pass) Jun 20, 2024
Comment on lines 52 to 59
{Object.entries(opportunity.data).map(([key, value]) => (
<tr key={key}>
<td className="word-wrap">{key}</td>
<td className="word-wrap">{JSON.stringify(value)}</td>
</tr>
))}
</tbody>
</table>
Copy link
Collaborator

@chouinar chouinar Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a small bit of special logic for the summary field so that it doesn't print out as the full JSON, but instead pulls out each of the fields? Just to make it look a little bit nicer / make it look like we've done a lot more and are truly just waiting on shoving it into whatever designs.

So, rather than summary with a value of { ... } (the whole object), do something like (in hacky python pseudo-code):

for key, value in obj.items():
     if key == "summary":
          for summary_key, summary_value in value.items():
                 print(summary_key)
                 print(JSON.stringify(summary_value)

    else:
         print(key)
         print(value)
 

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chouinar I added this:

image
image

return meta;
}

export default async function OpportunityListing({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still catching up on whether or not making a page async affects ability to statically render the page. The opportunity pages are the same for everyone and rarely update so should not be rebuilt for every single request. Statically rendering seems like the easiest way to achieve that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can punt this consideration for #85 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rylew1 rylew1 merged commit 4c877fa into main Jun 20, 2024
12 checks passed
@rylew1 rylew1 deleted the rylew/96-opportunity-listing-page branch June 20, 2024 20:53
acouch pushed a commit that referenced this pull request Sep 18, 2024
Fixes HHS#2068

- Add new id-based opportunity page
- Add new `OpportunityListingAPI` class extended from `BaseAPI`
- Make `searchInputs`/`QueryParamData` in `BaseAPI` and `errors.ts`
optional params (only used for search page)
- Update sitemap to replace [id] in url with 1
- Add test coverage
acouch pushed a commit that referenced this pull request Sep 18, 2024
Fixes HHS#2068

- Add new id-based opportunity page
- Add new `OpportunityListingAPI` class extended from `BaseAPI`
- Make `searchInputs`/`QueryParamData` in `BaseAPI` and `errors.ts`
optional params (only used for search page)
- Update sitemap to replace [id] in url with 1
- Add test coverage
acouch pushed a commit to HHS/simpler-grants-gov that referenced this pull request Sep 18, 2024
Fixes #2068

- Add new id-based opportunity page
- Add new `OpportunityListingAPI` class extended from `BaseAPI`
- Make `searchInputs`/`QueryParamData` in `BaseAPI` and `errors.ts`
optional params (only used for search page)
- Update sitemap to replace [id] in url with 1
- Add test coverage
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Create frontend opportunity listing page
4 participants