feat(preonboardings-requirements) - make employment readonly when shouldFreezeEmploymentData is true - #1213
feat(preonboardings-requirements) - make employment readonly when shouldFreezeEmploymentData is true #1213gabrielseco wants to merge 13 commits into
Conversation
…ployment readonly
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (402 total)
✅ Bundle size check passed |
📊 Coverage Report✅ Coverage increased! 🎉
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 110942d. Configure here.
| }); | ||
|
|
||
| it('should keep button disabled during requirements loading to prevent race condition', async () => { | ||
| let resolveRequirements: (value: unknown) => void; |
There was a problem hiding this comment.
simplified the test
| isLoadingEmploymentAgreementPreview || | ||
| isLoadingContractDetailsFormV1; | ||
| isLoadingContractDetailsFormV1 || | ||
| isLoadingPreOnboardingRequirements || |
There was a problem hiding this comment.
we were missing some loadings here
| employmentStatus && | ||
| !disabledInviteButtonEmploymentStatus.includes(employmentStatus) && | ||
| arePreOnboardingRequirementsFulfilled && | ||
| !isLoadingOnboardingReservesStatus; |
There was a problem hiding this comment.
loading not needed here as we put it in the initialLoading
| isDepositRequired && | ||
| onboardingBag.employmentId && | ||
| onboardingBag.employment?.status && | ||
| !onboardingBag.isEmploymentReadOnly |
There was a problem hiding this comment.
we cannot rely anymore on the employment being readonly because that would mean that you cannot create a reserve if a preonboarding requirement has shouldFreezeEmploymentData

When a user ack a requirement or signs one, the shouldFreezeEmploymentData that comes from the preonboarding-requirements endpoint changes and it should not make able to edit the employment anymore
This code presented here makes that happen but there were needed some more changes to not break create reserves as it was coupled with isEmploymentReadOnly
Note
Medium Risk
Changes invite/reserve branching and when employment is read-only during onboarding, which can affect who can edit data or click invite before async requirements load.
Overview
Pre-onboarding requirements with
freeze_employment_datanow lock employment editing and auto-route users to Review, same as late-stage employment statuses.useOnboardingderivesshouldFreezeEmploymentDatafrom requirements, folds it intoisEmploymentReadOnly, and keeps the flow in a loading state until pre-onboarding requirements (and onboarding reserves status) finish loading.canInviteno longer blocks on reserves loading; unfinished requirements still block invite viaarePreOnboardingRequirementsFulfilled.OnboardingInviteuses sharedstatusesWithReserveAlreadyHandledinstead of readonly employment to decide reserve vs invite, and only creates a reserve invoice whencanInviteis true. Tests cover freeze navigation and updated invite loading behavior.Reviewed by Cursor Bugbot for commit baa0df5. Bugbot is set up for automated code reviews on this repo. Configure here.