Skip to content

Commit 9eccc04

Browse files
authored
feat(contractor-onboarding): implement employment update capability for contractors (#703)
1 parent 04b9ab7 commit 9eccc04

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/flows/ContractorOnboarding/hooks.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
useCreateEmployment,
3333
useEmployment,
3434
useJSONSchemaForm,
35+
useUpdateEmployment,
3536
} from '@/src/flows/Onboarding/api';
3637
import {
3738
disabledInviteButtonEmploymentStatus,
@@ -144,8 +145,15 @@ export const useContractorOnboarding = ({
144145
}, [employmentStatus]);
145146

146147
const createEmploymentMutation = useCreateEmployment();
148+
const updateEmploymentMutation = useUpdateEmployment(
149+
internalCountryCode as string,
150+
options,
151+
);
147152
const createContractorContractDocumentMutation =
148153
useCreateContractorContractDocument();
154+
const { mutateAsync: updateEmploymentMutationAsync } = mutationToPromise(
155+
updateEmploymentMutation,
156+
);
149157
const signContractDocumentMutation = useSignContractDocument();
150158
const manageContractorSubscriptionMutation =
151159
usePostManageContractorSubscriptions();
@@ -655,10 +663,9 @@ export const useContractorOnboarding = ({
655663
throw error;
656664
}
657665
} else if (internalEmploymentId) {
658-
// TODO: Provisional it seems you cannot update a contractor employment
659-
// TODO: we'll need to check later if the provisional start date gets updated for the statement of work
660-
return Promise.resolve({
661-
data: { employmentId: internalEmploymentId },
666+
return updateEmploymentMutationAsync({
667+
employmentId: internalEmploymentId,
668+
basic_information: parsedValues,
662669
});
663670
}
664671

src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
fillSignature,
3535
generateUniqueEmploymentId,
3636
} from '@/src/flows/ContractorOnboarding/tests/helpers';
37+
import { employmentUpdatedResponse } from '@/src/flows/Onboarding/tests/fixtures';
3738

3839
const mockOnSubmit = vi.fn();
3940
const mockOnSuccess = vi.fn();
@@ -341,6 +342,9 @@ describe('ContractorOnboardingFlow', () => {
341342
http.post('*/v1/employments/*/invite', () => {
342343
return HttpResponse.json(inviteResponse);
343344
}),
345+
http.patch('*/v1/employments/*', async () => {
346+
return HttpResponse.json(employmentUpdatedResponse);
347+
}),
344348
);
345349
});
346350

@@ -608,7 +612,7 @@ describe('ContractorOnboardingFlow', () => {
608612
await screen.findByText(/Step: Pricing Plan/i);
609613

610614
// Verify PATCH was NOT called (contractors can't be updated)
611-
expect(patchSpy).not.toHaveBeenCalled();
615+
expect(patchSpy).toHaveBeenCalled();
612616
});
613617

614618
it('should create contract document when submitting contract details', async () => {

0 commit comments

Comments
 (0)