diff --git a/apps/web/src/components/ExperienceFormFields/WorkFields/GovFields.tsx b/apps/web/src/components/ExperienceFormFields/WorkFields/GovFields.tsx index 2192945f67f..7c6cb763abe 100644 --- a/apps/web/src/components/ExperienceFormFields/WorkFields/GovFields.tsx +++ b/apps/web/src/components/ExperienceFormFields/WorkFields/GovFields.tsx @@ -205,13 +205,8 @@ const GovFields = ({ labels }: SubExperienceFormProps) => { resetDirtyField("classificationLevel"); } - /** - * Wipe position type field if employment type changes, setting it to null rather than just reset incase the user default is bad - */ - if ( - watchGovEmploymentType !== WorkExperienceGovEmployeeType.Indeterminate - ) { - resetField("govPositionType", { keepDirty: false, defaultValue: null }); + if (watchGovEmploymentType) { + resetDirtyField("govPositionType"); } if (watchGovEmploymentType !== WorkExperienceGovEmployeeType.Contractor) { diff --git a/apps/web/src/hooks/useExperienceMutations.ts b/apps/web/src/hooks/useExperienceMutations.ts index 6296cd41b1e..a365f80f658 100644 --- a/apps/web/src/hooks/useExperienceMutations.ts +++ b/apps/web/src/hooks/useExperienceMutations.ts @@ -6,6 +6,7 @@ import { CreateEducationExperienceMutation, CreatePersonalExperienceMutation, CreateWorkExperienceMutation, + GovEmployeeType, graphql, } from "@gc-digital-talent/graphql"; @@ -158,10 +159,20 @@ export const useExperienceMutations = ( id: string, values: ExperienceDetailsSubmissionData, ): ExperienceMutationArgs => { + // users may have invalid WorkExperience state with govEmploymentType TERM and non-null govPositionType + let massagedValues = values; + if ( + experienceType === "work" && + !!massagedValues.govEmploymentType && + massagedValues.govEmploymentType !== GovEmployeeType.Indeterminate + ) { + massagedValues.govPositionType = null; + } + return { id, ...(!!experienceType && { - [args[experienceType]]: values, + [args[experienceType]]: massagedValues, }), } as ExperienceMutationArgs; };