Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR addresses an onboarding edge case where intermediate PATCH submissions could incorrectly clear the registration cookie (breaking subsequent steps), and adds a clearer UX path when the onboarding cookie/record is missing by redirecting users back to /join with an explanatory modal.
Changes:
- Update
/api/registration/updateto clear the registration cookie only when the client explicitly sendsfinalize: true. - Redirect onboarding users to
/join?registrationError=trueon 401/404 and show an error modal on the join page. - Add an E2E test covering “fill last step → go back → change earlier answers → complete registration” to prevent regressions.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pages/join/index.tsx |
Opens a modal when redirected back with registrationError query param. |
pages/api/registration/update.ts |
Switches cookie-clearing logic to a finalize flag and adjusts 404 behavior. |
components/Forms/UpdateProfileForm/UpdateProfileForm.tsx |
Adds redirect-on-401/404 and sends finalize: true on final submit. |
common/constants/api.ts |
Broadens updateUser typing and adds finalize support in the client API call signature. |
components/Forms/UpdateProfileForm/steps/MilitaryDetails.tsx |
Exports a step form-shape type for API typing. |
e2e/join.spec.ts |
Adds coverage for the back-navigation + resubmit edge case. |
Comments suppressed due to low confidence (2)
components/Forms/UpdateProfileForm/UpdateProfileForm.tsx:101
goToProfilecatches all errors fromupdateUserand doesn't rethrow or redirect on 401/404. BecauseMultiStepFormtreats a resolvedonFinalSubmitas success, this can lead to the form being reset (and the user not being navigated to/join/success) even though the final PATCH failed. Handle 401/404 consistently (redirect to/join?registrationError=true) and rethrow for other errors soMultiStepFormcan show an error instead of resetting.
const goToProfile = async (values: UpdateProfileFormShape) => {
try {
await updateUser({ ...values, finalize: true });
push('/join/success');
} catch (error) {
LogRocket.captureException(error as Error);
}
pages/api/registration/update.ts:94
- The cookie is cleared before the Airtable
updatecall. If the Airtable update throws (network issue / validation), the cookie will already be gone and the user can’t retry the final submit. Consider only clearing the cookie after the Airtable update succeeds (i.e., set theSet-Cookieheader right before returning 200).
if (req.body.finalize) {
res.setHeader('Set-Cookie', [
`opCodeApplicantEmail=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`,
]);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await base(AIR_TABLE_TABLE_NAME).update(relevantRecord.id, parsedPayload); | ||
|
|
||
| return res.status(200).json({ message: 'Success' }); | ||
| } else { |
There was a problem hiding this comment.
On the 404 path (No record found), the API no longer clears the stale opCodeApplicantEmail cookie. This can leave users stuck with a cookie that allows /join/form to load on a server refresh, but every subsequent PATCH will keep 404’ing and redirecting them back to /join. Consider clearing the cookie on this 404 response (as was done previously) so the server-side guard can reliably redirect users out of the onboarding flow.
| } else { | |
| } else { | |
| // Clear stale registration cookie when no record is found so users | |
| // are redirected out of the onboarding flow on subsequent requests. | |
| res.setHeader('Set-Cookie', [ | |
| `opCodeApplicantEmail=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`, | |
| ]); |
📝 Changed routes:
And 1 other route: Commit 4b86b66 (https://operation-code-q347kjqfm-operation-code.vercel.app). |

Description of changes
Resolves issue where user would fill out all form steps, but not submit the final step. Also resolves UX if necessary cookie missing.