-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#3306] Add save button #3677
base: main
Are you sure you want to change the base?
[#3306] Add save button #3677
Conversation
44bf30a
to
8b68b3a
Compare
@@ -67,7 +67,7 @@ export default function SearchError({ error, reset }: ErrorProps) { | |||
) { | |||
reset(); | |||
} | |||
}, [searchParams, reset]); | |||
}, [searchParams, reset, previousSearchParams]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came up from ts:check
locally.
{ message: `Error logging out: ${error.message}` }, | ||
{ status: 500 }, | ||
{ message: `Error logging out: ${(cause as string) ?? message}` }, | ||
{ status }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This passes on the status from our own errors.
"usa-alert__heading margin-bottom-0 margin-top-05 font-weight-100", | ||
{ | ||
"margin-left-2 font-sans-xs": !error, | ||
"margin-left-5 font-sans-sm": error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -55,11 +53,7 @@ const OpportunityIntro = ({ opportunityData }: Props) => { | |||
}; | |||
|
|||
return ( | |||
<ContentLayout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opp title is moved to the page as part of the update
} | ||
} catch (error) { | ||
setSavedError(true); | ||
console.error(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would want to add new relic here in the future.
}); | ||
super(serializedData); | ||
}; | ||
super(message, { cause }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds the details to the cause property which serializes it.
ca60c29
to
840bb78
Compare
840bb78
to
fd15fcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to make a follow up for e2e tests around this functionality?
one note on the error front - noticed a case where a request failed with a string message, and since parseErrorStatus
is relying on the error message being a valid json string, it errors, and we end up with a 500 response. We should probably take a pass through the code to make sure we've got that right - in any case assuming that the error message will be a json string seems presumptuous.
try { | ||
const session = await getSession(); | ||
if (!session || !session.token) { | ||
throw new Error("No active session to get saved opportunity"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a 401?
try { | ||
const session = await getSession(); | ||
if (!session || !session.token) { | ||
throw new Error("No active session to save opportunity"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same note as above - should a situation with no session or token be a 401?
}; | ||
|
||
export const DELETE = async (request: Request) => { | ||
return await handleRequest(request, "DELETE"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't need a second argument here - request.method
should give you the string you need, and then we can simplify this a little.
(savedOpportunity: { opportunity_id: number }) => | ||
savedOpportunity.opportunity_id === opportunity_id, | ||
); | ||
return savedOpportunity ?? []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is expected to return an array, maybe annotate that since getSavedOpportunity
suggests to me that it would return a single opportunity rather than a list
@@ -238,6 +238,35 @@ i.e. | |||
padding: units(1) units(2); | |||
} | |||
|
|||
.simpler-save-button { | |||
padding: units(0.5) units(2) units(0.5) units(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do this with existing classes?
|
||
describe("GET request", () => { | ||
afterEach(() => jest.clearAllMocks()); | ||
it("gets a saved opportunity", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test for the unauthorized and no saved opps error cases?
} as unknown as NextRequest; | ||
}; | ||
|
||
describe("POST and DELETE request", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to the other test, can you add a couple of error tests?
Summary
One part of #3306
Time to review: 45 mins
This adds the save button to the opportunity page.
To Review
Run the API:
cd api && make remake-backed
Start the site:
cd frontend && npm run dev
Login and save an opportunity.
The button matches pretty well with PixelPerfect