@gusto/embedded-react-sdk 0.46.2 → 0.46.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/components/Common/DataView/DataTable/DataTable.js +76 -72
  3. package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
  4. package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js +8 -0
  5. package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js.map +1 -0
  6. package/dist/components/Common/DataView/useDataView.d.ts +2 -0
  7. package/dist/components/Common/DataView/useDataView.js.map +1 -1
  8. package/dist/components/Common/DocumentViewer/DocumentViewer.js +10 -10
  9. package/dist/components/Common/DocumentViewer/DocumentViewer.js.map +1 -1
  10. package/dist/components/Common/DocumentViewer/DocumentViewer.module.scss.js +9 -9
  11. package/dist/components/Common/PaginationControl/PaginationControl.js +11 -10
  12. package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
  13. package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +1 -1
  14. package/dist/components/Common/UI/DescriptionList/DescriptionList.js +11 -10
  15. package/dist/components/Common/UI/DescriptionList/DescriptionList.js.map +1 -1
  16. package/dist/components/Common/UI/DescriptionList/DescriptionList.module.scss.js +4 -4
  17. package/dist/components/Common/UI/Input/InputTypes.d.ts +1 -1
  18. package/dist/components/Common/UI/Input/InputTypes.js.map +1 -1
  19. package/dist/components/Common/UI/NumberInput/NumberInput.js +51 -48
  20. package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
  21. package/dist/components/Common/VisuallyHidden/VisuallyHidden.d.ts +1 -1
  22. package/dist/components/Common/VisuallyHidden/VisuallyHidden.js.map +1 -1
  23. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
  24. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  25. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
  26. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  27. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
  28. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  29. package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
  30. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  31. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  32. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  33. package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
  34. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
  35. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  36. package/dist/components/Company/Industry/Context.js +6 -7
  37. package/dist/components/Company/Industry/Context.js.map +1 -1
  38. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
  39. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  40. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
  41. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  42. package/dist/components/Company/OnboardingOverview/context.js +3 -4
  43. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  44. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
  45. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
  46. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  47. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
  48. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  49. package/dist/components/Contractor/Address/useAddress.js +5 -6
  50. package/dist/components/Contractor/Address/useAddress.js.map +1 -1
  51. package/dist/components/Contractor/Profile/useContractorProfile.js +33 -34
  52. package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
  53. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +14 -11
  54. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -1
  55. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +0 -2
  56. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -1
  57. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +18 -18
  58. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -1
  59. package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js +36 -36
  60. package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js.map +1 -1
  61. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
  62. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +140 -140
  63. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  64. package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
  65. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +6 -5
  66. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +162 -131
  67. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
  68. package/dist/components/Employee/Dashboard/BasicDetailsView.js +74 -88
  69. package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
  70. package/dist/components/Employee/Dashboard/Dashboard.js +53 -51
  71. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  72. package/dist/components/Employee/Dashboard/DocumentsView.js +17 -10
  73. package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
  74. package/dist/components/Employee/Dashboard/JobAndPayView.js +383 -357
  75. package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
  76. package/dist/components/Employee/Dashboard/TaxesView.js +114 -101
  77. package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
  78. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +36 -36
  79. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
  80. package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js +57 -57
  81. package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js.map +1 -1
  82. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.d.ts +14 -5
  83. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js +55 -36
  84. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js.map +1 -1
  85. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
  86. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js +18 -18
  87. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js.map +1 -1
  88. package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
  89. package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.d.ts +3 -3
  90. package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.js.map +1 -1
  91. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  92. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  93. package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
  94. package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
  95. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +157 -147
  96. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
  97. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +56 -55
  98. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
  99. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +20 -20
  100. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js.map +1 -1
  101. package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
  102. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.d.ts +1 -1
  103. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
  104. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js.map +1 -1
  105. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
  106. package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
  107. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.d.ts +0 -1
  108. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js +11 -12
  109. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js.map +1 -1
  110. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.test.d.ts +1 -0
  111. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.d.ts +6 -1
  112. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js +95 -94
  113. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js.map +1 -1
  114. package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
  115. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.d.ts +6 -1
  116. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js +87 -86
  117. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js.map +1 -1
  118. package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js +18 -18
  119. package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js.map +1 -1
  120. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
  121. package/dist/components/Employee/Taxes/useTaxes.js +3 -4
  122. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  123. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +5 -1
  124. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
  125. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +61 -60
  126. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
  127. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
  128. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  129. package/dist/components/Payroll/usePreparedPayrollData.js +2 -3
  130. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  131. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +6 -7
  132. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js.map +1 -1
  133. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.d.ts +1 -1
  134. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js +52 -68
  135. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
  136. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.module.scss.js +4 -4
  137. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +0 -11
  138. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +137 -163
  139. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
  140. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +36 -35
  141. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
  142. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js +34 -34
  143. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js.map +1 -1
  144. package/dist/helpers/breadcrumbHelpers.d.ts +1 -1
  145. package/dist/helpers/breadcrumbHelpers.js.map +1 -1
  146. package/dist/helpers/federalEin.d.ts +1 -0
  147. package/dist/helpers/federalEin.js.map +1 -1
  148. package/dist/helpers/mask.d.ts +8 -4
  149. package/dist/helpers/mask.js.map +1 -1
  150. package/dist/helpers/rem.d.ts +2 -1
  151. package/dist/helpers/rem.js.map +1 -1
  152. package/dist/hooks/useAsyncError.d.ts +1 -0
  153. package/dist/hooks/useAsyncError.js.map +1 -1
  154. package/dist/hooks/useForkRef/useForkRef.d.ts +1 -0
  155. package/dist/hooks/useForkRef/useForkRef.js.map +1 -1
  156. package/dist/i18n/I18n.d.ts +9 -1
  157. package/dist/i18n/I18n.js.map +1 -1
  158. package/dist/i18n/en/Company.TimeOff.EmployeeTable.json.js +14 -14
  159. package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +12 -18
  160. package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js.map +1 -1
  161. package/dist/i18n/en/Employee.Compensation.json.js +24 -24
  162. package/dist/i18n/en/Employee.Dashboard.json.js +22 -20
  163. package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
  164. package/dist/i18n/en/Employee.PaymentMethod.json.js +25 -25
  165. package/dist/i18n/en/Employee.StateTaxes.json.js +12 -10
  166. package/dist/i18n/en/Employee.StateTaxes.json.js.map +1 -1
  167. package/dist/style.css +1 -1
  168. package/dist/types/hooks.d.ts +1 -1
  169. package/dist/types/i18next.d.ts +4 -17
  170. package/dist/types/observability.d.ts +1 -1
  171. package/package.json +30 -27
  172. package/dist/components/Employee/Dashboard/CompensationCard.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"useCompensationForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsCreateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWages } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n createCompensationSchema,\n type CompensationOptionalFieldsToRequire,\n type CompensationFormData,\n type CompensationFormOutputs,\n} from './compensationSchema'\nimport {\n TitleField,\n FlsaStatusField,\n RateField,\n PaymentUnitField,\n AdjustForMinimumWageField,\n MinimumWageIdField,\n EffectiveDateField,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { FlsaStatus, PAY_PERIODS, TIP_CREDITS_UNSUPPORTED_STATES } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { addDays, formatDateToStringDate } from '@/helpers/dateFormatting'\n\nexport interface CompensationSubmitOptions {\n /** Override jobId — required when creating a compensation if not configured at hook construction (e.g. when the parent job was just created in the same submit chain). */\n jobId?: string\n /** Override compensationId — when present, forces update (PUT) routing regardless of hook construction. */\n compensationId?: string\n /**\n * Compensation version for optimistic locking on PUT. Required when forcing\n * update routing post-create (e.g. updating the auto-created stub returned\n * from `POST /v1/employees/:id/jobs`). When omitted, the hook reads the\n * version from its cached `currentCompensation`.\n */\n compensationVersion?: string\n /**\n * Supply `effectiveDate` at submit time. When `withEffectiveDateField`\n * is `true`, this overrides the form's value. When `withEffectiveDateField`\n * is `false`, this is the only way to put `effective_date` on the wire —\n * the form value is not read in that mode (matching the options-only\n * convention of `useWorkAddressForm` / `useHomeAddressForm` / `useJobForm`).\n */\n effectiveDate?: string\n}\n\nexport interface UseCompensationFormProps {\n employeeId?: string\n /** The parent job's UUID. Required in create mode (scopes `POST /v1/jobs/:jobId/compensations`). Optional in update mode — the parent job is derived from the loaded compensation. */\n jobId?: string\n /** Present → update mode (PUT /v1/compensations/:id). Omitted → create mode (POST /v1/jobs/:jobId/compensations). */\n compensationId?: string\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n defaultValues?: Partial<CompensationFormData>\n validationMode?: UseFormProps['mode']\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.EffectiveDate` (becomes `undefined`) and\n * removes `effectiveDate` from schema validation. In this mode the hook\n * does not read any form value at submit time — `effective_date` is\n * omitted from the request body unless explicitly supplied via\n * `CompensationSubmitOptions.effectiveDate`. This matches the\n * options-only convention of `useWorkAddressForm` /\n * `useHomeAddressForm` / `useJobForm`, and means the\n * `willDeleteSecondaryJobs` carve-out's form-state side effects do not\n * leak onto the wire (there is no field to render them in anyway).\n * Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\nexport interface CompensationFormFields {\n Title: typeof TitleField\n FlsaStatus: typeof FlsaStatusField | undefined\n Rate: typeof RateField\n PaymentUnit: typeof PaymentUnitField\n AdjustForMinimumWage: typeof AdjustForMinimumWageField | undefined\n MinimumWageId: typeof MinimumWageIdField | undefined\n EffectiveDate: typeof EffectiveDateField | undefined\n}\n\nexport interface UseCompensationFormReady extends BaseFormHookReady<\n FieldsMetadata,\n CompensationFormData,\n CompensationFormFields\n> {\n data: {\n /** The compensation row loaded for update; `null` in create mode. */\n compensation: Compensation | null\n /** The parent job. In update mode it's derived from the loaded compensation; in create mode it's looked up by `jobId`. `null` if neither resolves. */\n currentJob: Job | null\n minimumWages: MinimumWage[]\n /** Lower bound for `effectiveDate` (typically the parent job's hire date). */\n minimumEffectiveDate: string | null\n /** Upper bound for `effectiveDate` — the next scheduled future compensation's effective date, when one exists. */\n maximumEffectiveDate: string | null\n /** True when at least one future-dated compensation already exists for this job. */\n hasPendingFutureCompensation: boolean\n }\n status: {\n isPending: boolean\n mode: 'create' | 'update'\n /**\n * True when submitting the form right now would delete the employee's\n * secondary jobs server-side (the \"carve-out\" branch). Reactive:\n * derived from the current `flsaStatus` form value, the loaded\n * compensation, and the other-jobs count, so this flips as you change\n * inputs.\n *\n * Conditions: update mode, the loaded compensation is Nonexempt, the\n * form's `flsaStatus` has been changed to a non-Nonexempt value, and\n * the employee has at least one secondary job.\n *\n * While this flag is true the hook also takes the `effectiveDate`\n * field over: it forces the form value to today (so submits route\n * through a PUT that immediately deletes secondaries) and exposes\n * `fieldsMetadata.effectiveDate.isDisabled = true` so `Fields.EffectiveDate`\n * renders as disabled. On revert (FLSA back to Nonexempt) the prior\n * `effectiveDate` is restored. Render an inline warning keyed off\n * this flag — no separate confirmation step is needed.\n */\n willDeleteSecondaryJobs: boolean\n }\n actions: {\n onSubmit: (\n options?: CompensationSubmitOptions,\n ) => Promise<HookSubmitResult<Compensation> | undefined>\n }\n}\n\nfunction resolveCompAndJob(\n jobs: Job[] | undefined,\n compensationId: string | undefined,\n jobId: string | undefined,\n): { compensation: Compensation | null; job: Job | null } {\n if (!jobs) return { compensation: null, job: null }\n if (compensationId) {\n for (const job of jobs) {\n const compensation = job.compensations?.find(c => c.uuid === compensationId)\n if (compensation) return { compensation, job }\n }\n // If the comp isn't in any job's compensations list, still try to resolve\n // the job by jobId so callers can check job metadata (e.g. job.primary).\n const fallbackJob = jobId ? (jobs.find(j => j.uuid === jobId) ?? null) : null\n return { compensation: null, job: fallbackJob }\n }\n if (jobId) return { compensation: null, job: jobs.find(j => j.uuid === jobId) ?? null }\n return { compensation: null, job: null }\n}\n\nfunction findPrimaryFlsaStatus(jobs: Job[] | undefined): FlsaStatusType | null {\n if (!jobs) return null\n for (const job of jobs) {\n if (!job.primary) continue\n const compensation = job.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n if (compensation?.flsaStatus) return compensation.flsaStatus\n }\n return null\n}\n\nfunction findFutureCompensations(job: Job | null): Compensation[] {\n if (!job?.compensations) return []\n const today = todayISO()\n return job.compensations.filter(c => c.effectiveDate !== undefined && c.effectiveDate > today)\n}\n\nfunction earliestEffectiveDate(comps: Compensation[]): string | null {\n if (comps.length === 0) return null\n return comps.reduce<string | null>((min, c) => {\n const d = c.effectiveDate\n if (!d) return min\n if (!min || d < min) return d\n return min\n }, null)\n}\n\nconst flsaStatusEntries: FlsaStatusType[] = [\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n]\n\nconst flsaOptions = flsaStatusEntries.map(status => ({ value: status, label: status }))\n\nconst paymentUnitEntries: PaymentUnit[] = [\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n]\n\nconst paymentUnitOptions = paymentUnitEntries.map(unit => ({ value: unit, label: unit }))\n\nfunction todayISO(): string {\n return new Date().toISOString().split('T')[0]!\n}\n\nexport function useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withEffectiveDateField = true,\n}: UseCompensationFormProps): HookLoadingResult | UseCompensationFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n {\n employeeId: employeeId ?? '',\n // Fetch all effective-dated compensations when editing an existing one so\n // resolveCompAndJob can find the target comp (future-dated comps are\n // omitted from the default response, which only returns the current comp).\n include: compensationId\n ? GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations\n : undefined,\n },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active)\n const locationUuid = currentWorkAddress?.locationUuid\n const employee = employeeQuery.data?.employee\n\n const minWagesQuery = useLocationsGetMinimumWages(\n { locationUuid: locationUuid ?? '' },\n { enabled: !!locationUuid },\n )\n\n const minimumWages = minWagesQuery.data?.minimumWageList ?? []\n\n const { compensation: currentCompensation, job: currentJob } = resolveCompAndJob(\n employeeJobs,\n compensationId,\n jobId,\n )\n\n const otherJobsCount =\n employeeJobs && currentJob ? employeeJobs.filter(j => j.uuid !== currentJob.uuid).length : 0\n\n // Snapshot — written exactly once, on the first render where `employeeJobs`\n // is defined (i.e., the initial `getJobs` query has resolved) — capturing\n // whether the employee already had a primary job at that moment.\n //\n // Used to ignore the API-generated stub primary (FLSA Nonexempt, rate \"0.00\")\n // that briefly appears between the chained job POST and comp PUT during\n // onboarding: `getJobs` invalidates between the two mutations and\n // momentarily includes the stub, which would otherwise flip\n // `isAddingSecondaryJob` to true and hide `Fields.FlsaStatus` mid-submit.\n //\n // In steady-state flows (edit primary, edit secondary, add secondary), the\n // real primary already exists when the query first resolves, so the snapshot\n // is `true` and live `employeeJobs` continues to drive `primaryFlsaStatus`.\n // Recovery for the rare case where a partner mounts before any jobs exist\n // and a primary is created externally mid-form is to remount the hook\n // (e.g., via a `key` change).\n const hadPrimaryAtMountRef = useRef<boolean | null>(null)\n if (hadPrimaryAtMountRef.current === null && employeeJobs !== undefined) {\n hadPrimaryAtMountRef.current = employeeJobs.some(job => job.primary)\n }\n const hadPrimaryAtMount = hadPrimaryAtMountRef.current === true\n\n // FLSA status of the employee's primary job's current compensation, when one\n // exists. Used as a fallback default when adding a *secondary* job/comp so the\n // multi-job classification stays consistent with the primary by default — the\n // user can still override it (when allowed). Null when there was no primary\n // job at the moment the hook first observed `employeeJobs`, or when the\n // primary has no current compensation yet.\n const primaryFlsaStatus = hadPrimaryAtMount ? findPrimaryFlsaStatus(employeeJobs) : null\n\n const hireDate =\n currentJob?.hireDate ??\n // Secondary jobs being created (AddAnotherJob) have no hireDate until the\n // job POST completes. Fall back to the primary job's hireDate so the schema\n // can enforce EFFECTIVE_DATE_BEFORE_HIRE during that window.\n employeeJobs?.find(j => j.primary)?.hireDate ??\n null\n\n // In update mode, exclude the compensation being edited so it doesn't\n // bound `maximumEffectiveDate` to its own current date — that would prevent\n // the user from pushing the pending effective date further out.\n const futureCompensations = findFutureCompensations(currentJob).filter(\n c => c.uuid !== compensationId,\n )\n const hasPendingFutureCompensation = futureCompensations.length > 0\n const maximumEffectiveDate = earliestEffectiveDate(futureCompensations)\n\n const isCreateMode = !compensationId\n const mode = isCreateMode ? 'create' : 'update'\n // Adding a secondary job (the employee already has a primary). The Gusto API\n // only allows secondaries when the primary's current FLSA is Nonexempt, and\n // the secondary itself must match — so the FLSA field is not user-editable\n // in this branch. We force the form value to the primary's FLSA below and\n // hide `Fields.FlsaStatus`.\n // True when adding a brand-new secondary job (not when scheduling a future\n // comp for the primary). The distinction matters: for the primary's future\n // comp, FLSA should be editable; for a secondary, it must match the primary.\n const isAddingSecondaryJob =\n isCreateMode && primaryFlsaStatus === FlsaStatus.NONEXEMPT && currentJob?.primary !== true\n\n // Derive the effective-date floor internally so consumers don't need to wire\n // it up. Rules by mode and job type:\n // create (any job): tomorrow — new comp must be future-dated\n // update, primary: undefined — the carve-out (willDeleteSecondaryJobs) can\n // force effectiveDate to today on a disabled field; enforcing a floor here\n // would produce a spurious EFFECTIVE_DATE_BEFORE_MIN on submit.\n // update, secondary: tomorrow — must be in the future\n // The hire-date lower bound is handled separately in the schema via the\n // `hireDate` option (→ EFFECTIVE_DATE_BEFORE_HIRE), which fires alongside\n // this check so each violation gets its own error message.\n const internalMinEffectiveDate = useMemo(() => {\n if (!withEffectiveDateField) return undefined\n if (!isCreateMode && currentJob?.primary === true) return undefined\n\n return formatDateToStringDate(addDays(new Date(), 1)) ?? undefined\n }, [isCreateMode, currentJob?.primary, withEffectiveDateField])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createCompensationSchema({\n mode,\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate: internalMinEffectiveDate,\n withEffectiveDateField,\n }),\n [mode, optionalFieldsToRequire, hireDate, internalMinEffectiveDate, withEffectiveDateField],\n )\n\n const state = currentWorkAddress?.state\n\n // `flsaStatus` is intentionally allowed to be undefined so the field renders\n // an empty placeholder when nothing is provided — partners can choose to\n // seed it via `defaultValues.flsaStatus`. When a `compensation` is loaded we\n // seed from it; for a brand-new secondary job we inherit from the primary's\n // current compensation so multi-job classification stays consistent. The\n // schema enforces requiredness on submit in `create` mode (see\n // `requiredFieldsConfig` in compensationSchema.ts).\n //\n // `title` falls back to the parent job's title when the loaded compensation\n // row has none — a compensation only carries a non-null `title` when an\n // explicit title change has been scheduled on it. For steady-state edits\n // we want the input to show the employee's current title as the starting\n // value so the user can edit-in-place rather than re-typing.\n const resolvedDefaults: CompensationFormData = useMemo(\n () => ({\n title: currentCompensation?.title ?? currentJob?.title ?? partnerDefaults?.title ?? '',\n // When adding a secondary, the FLSA must match the primary's — force it\n // here (overriding any partner default) so the form submits the right\n // value even though `Fields.FlsaStatus` is hidden.\n flsaStatus: isAddingSecondaryJob\n ? primaryFlsaStatus\n : (currentCompensation?.flsaStatus ??\n partnerDefaults?.flsaStatus ??\n primaryFlsaStatus ??\n undefined),\n rate: Number(currentCompensation?.rate ?? partnerDefaults?.rate ?? 0),\n adjustForMinimumWage:\n currentCompensation?.adjustForMinimumWage ?? partnerDefaults?.adjustForMinimumWage ?? false,\n minimumWageId:\n currentCompensation?.minimumWages?.[0]?.uuid ?? partnerDefaults?.minimumWageId ?? '',\n paymentUnit:\n currentCompensation?.paymentUnit ?? partnerDefaults?.paymentUnit ?? PAY_PERIODS.HOUR,\n effectiveDate: currentCompensation?.effectiveDate ?? partnerDefaults?.effectiveDate ?? null,\n }),\n [currentCompensation, currentJob, partnerDefaults, primaryFlsaStatus, isAddingSecondaryJob],\n )\n\n const formMethods = useForm<CompensationFormData, unknown, CompensationFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const { control, getValues, setValue } = formMethods\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedAdjustForMinimumWage = useWatch({\n control,\n name: 'adjustForMinimumWage',\n })\n\n useEffect(() => {\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', PAY_PERIODS.PAYCHECK)\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', PAY_PERIODS.YEAR)\n setValue('rate', 0)\n } else {\n setValue('paymentUnit', resolvedDefaults.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, resolvedDefaults.paymentUnit])\n\n // The FLSA status that represents the employee's current classification.\n // In update mode this is the compensation being edited. In create mode\n // `currentCompensation` is null, so fall back to the job's active\n // compensation (identified by currentCompensationUuid) — this lets the\n // secondary-job warning fire even when scheduling a future-dated change.\n const currentJobActiveComp = currentJob\n ? currentJob.compensations?.find(c => c.uuid === currentJob.currentCompensationUuid)\n : undefined\n const effectiveBaseFlsaStatus =\n currentCompensation?.flsaStatus ?? currentJobActiveComp?.flsaStatus ?? null\n\n // True when the user is changing FLSA away from Nonexempt on a job that has\n // secondary jobs — those secondaries will be deleted by the API when the\n // new classification takes effect (immediately in update mode, at the chosen\n // effective date in create mode). Drives the warning and, in update mode\n // only, the effectiveDate-lock side effect below.\n const willDeleteSecondaryJobs =\n effectiveBaseFlsaStatus === FlsaStatus.NONEXEMPT &&\n watchedFlsaStatus !== undefined &&\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT &&\n otherJobsCount > 0\n\n // Carve-out UX — update mode only: while willDeleteSecondaryJobs is active\n // the server deletes secondaries immediately on PUT. Mirror this by forcing\n // `effectiveDate` to today and disabling the field. In create mode the\n // deletion happens at the chosen future date, so we show the warning but\n // leave the date field editable.\n const carveOutActiveRef = useRef(false)\n const priorEffectiveDateRef = useRef<string | null>(null)\n useEffect(() => {\n if (!isCreateMode && willDeleteSecondaryJobs && !carveOutActiveRef.current) {\n priorEffectiveDateRef.current = getValues('effectiveDate') ?? null\n setValue('effectiveDate', todayISO(), { shouldDirty: true, shouldValidate: false })\n carveOutActiveRef.current = true\n } else if (!isCreateMode && !willDeleteSecondaryJobs && carveOutActiveRef.current) {\n setValue('effectiveDate', priorEffectiveDateRef.current ?? null, {\n shouldDirty: true,\n shouldValidate: false,\n })\n priorEffectiveDateRef.current = null\n carveOutActiveRef.current = false\n }\n }, [isCreateMode, willDeleteSecondaryJobs, getValues, setValue])\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation()\n const createCompensationMutation = useJobsAndCompensationsCreateCompensationMutation()\n\n const isPending = updateCompensationMutation.isPending || createCompensationMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('CompensationForm')\n\n const queriesForErrors = employeeId\n ? [jobsQuery, addressesQuery, employeeQuery, minWagesQuery]\n : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const isCommissionOnly =\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n const isOwner = watchedFlsaStatus === FlsaStatus.OWNER\n\n // Hide `Fields.FlsaStatus` when the user has no meaningful choice:\n // - update mode editing a secondary whose comp is already Nonexempt\n // (must keep matching the primary), and\n // - create mode while adding a secondary (must inherit primary's FLSA).\n // The first job's create flow and primary-job edits keep the field exposed.\n const isFlsaSelectionEnabled =\n !isAddingSecondaryJob &&\n (watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary === true || isCreateMode)\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n // Min-wage adjustment is only valid for Nonexempt FLSA (and a state that\n // allows tip credit). When the gate flips off — typically because the user\n // changed FLSA away from Nonexempt — `Fields.AdjustForMinimumWage` and\n // `Fields.MinimumWageId` stop rendering, but the underlying form values\n // persist in react-hook-form state. That would leak an\n // `adjust_for_minimum_wage: true` + `minimum_wages: [...]` body on submit\n // (server rejects with \"Minimum wage adjustments only valid for\n // flsa_status: Nonexempt\"). Reset both values to safe defaults so the\n // submitted payload always matches what the user can actually see.\n useEffect(() => {\n if (isAdjustMinimumWageEnabled) return\n if (getValues('adjustForMinimumWage')) {\n setValue('adjustForMinimumWage', false, { shouldDirty: true, shouldValidate: false })\n }\n if (getValues('minimumWageId')) {\n setValue('minimumWageId', '', { shouldDirty: true, shouldValidate: false })\n }\n }, [isAdjustMinimumWageEnabled, getValues, setValue])\n\n const minimumWageOptions = minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${wage.wage} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const effectiveDateMinDate = useMemo(\n () =>\n [internalMinEffectiveDate, hireDate]\n .filter((d): d is string => !!d)\n .reduce<string | null>((max, d) => (!max || d > max ? d : max), null),\n [internalMinEffectiveDate, hireDate],\n )\n const fieldsMetadata = {\n title: baseMetadata.title,\n effectiveDate: {\n ...baseMetadata.effectiveDate,\n isDisabled: willDeleteSecondaryJobs && !isCreateMode,\n minDate: effectiveDateMinDate,\n maxDate: maximumEffectiveDate,\n },\n flsaStatus: withOptions<FlsaStatusType>(\n baseMetadata.flsaStatus,\n flsaOptions,\n flsaStatusEntries,\n ),\n rate: { ...baseMetadata.rate, isDisabled: isCommissionOnly },\n paymentUnit: withOptions<PaymentUnit>(\n { ...baseMetadata.paymentUnit, isDisabled: isOwner || isCommissionOnly },\n paymentUnitOptions,\n paymentUnitEntries,\n ),\n adjustForMinimumWage: {\n ...baseMetadata.adjustForMinimumWage,\n isDisabled: !isAdjustMinimumWageEnabled,\n },\n minimumWageId: withOptions<MinimumWage>(\n baseMetadata.minimumWageId,\n minimumWageOptions,\n minimumWages,\n ),\n }\n\n const onSubmit = async (\n options?: CompensationSubmitOptions,\n ): Promise<HookSubmitResult<Compensation> | undefined> => {\n let submitResult: HookSubmitResult<Compensation> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: CompensationFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedJobId = options?.jobId ?? jobId\n const resolvedCompensationId = options?.compensationId ?? compensationId\n const resolvedMode = resolvedCompensationId ? 'update' : 'create'\n\n // When the field is rendered, the validated payload value wins\n // unless an explicit submit-time override is supplied. When the\n // field is hidden (`withEffectiveDateField: false`) we are\n // strictly options-only — matching `useWorkAddressForm` and the\n // hidden-field behavior of `useHomeAddressForm` / `useJobForm`.\n // The carve-out's form-state side effect (force value to today)\n // is therefore inert in the hidden-field path; partners who\n // need a specific date there must supply it via\n // `CompensationSubmitOptions.effectiveDate`.\n const resolvedEffectiveDate = withEffectiveDateField\n ? (options?.effectiveDate ?? payload.effectiveDate ?? undefined)\n : (options?.effectiveDate ?? undefined)\n\n const requestBodyBase = {\n rate: String(payload.rate),\n paymentUnit: payload.paymentUnit,\n flsaStatus: payload.flsaStatus,\n effectiveDate: resolvedEffectiveDate,\n title: payload.title || undefined,\n adjustForMinimumWage: payload.adjustForMinimumWage,\n minimumWages: payload.adjustForMinimumWage ? [{ uuid: payload.minimumWageId }] : [],\n }\n\n let result: Compensation | undefined\n\n if (resolvedMode === 'create') {\n if (!resolvedJobId) {\n throw new SDKInternalError(\n 'jobId is required to create a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n // Schema's `requiredFieldsConfig` guarantees `flsaStatus` is set\n // on create-mode submit; the runtime guard appeases the API\n // request-body type (which requires a non-undefined value on\n // POST, vs. the optional PUT body).\n if (!payload.flsaStatus) {\n throw new SDKInternalError('flsaStatus is required to create a compensation.')\n }\n const createResponse = await createCompensationMutation.mutateAsync({\n request: {\n jobId: resolvedJobId,\n compensationsRequestBody: { ...requestBodyBase, flsaStatus: payload.flsaStatus },\n },\n })\n result = createResponse.compensation\n if (!result) throw new SDKInternalError('Compensation creation failed')\n } else {\n if (!resolvedCompensationId) {\n throw new SDKInternalError(\n 'compensationId is required to update a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n const resolvedVersion =\n options?.compensationVersion ?? (currentCompensation?.version as string | undefined)\n if (!resolvedVersion) {\n throw new SDKInternalError(\n 'compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded.',\n )\n }\n const updateResponse = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: resolvedCompensationId,\n compensationsUpdateRequestBody: {\n version: resolvedVersion,\n ...requestBodyBase,\n },\n },\n })\n result = updateResponse.compensation\n if (!result) throw new SDKInternalError('Compensation update failed')\n }\n\n submitResult = { mode: resolvedMode, data: result }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading ||\n addressesQuery.isLoading ||\n employeeQuery.isLoading ||\n minWagesQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n compensation: currentCompensation,\n currentJob,\n minimumWages,\n minimumEffectiveDate: effectiveDateMinDate,\n maximumEffectiveDate,\n hasPendingFutureCompensation,\n },\n status: {\n isPending,\n mode,\n willDeleteSecondaryJobs,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: TitleField,\n FlsaStatus: isFlsaSelectionEnabled ? FlsaStatusField : undefined,\n Rate: RateField,\n PaymentUnit: PaymentUnitField,\n AdjustForMinimumWage: isAdjustMinimumWageEnabled ? AdjustForMinimumWageField : undefined,\n MinimumWageId:\n isAdjustMinimumWageEnabled && watchedAdjustForMinimumWage\n ? MinimumWageIdField\n : undefined,\n EffectiveDate: withEffectiveDateField ? EffectiveDateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\nexport type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady\nexport type CompensationFieldsMetadata = UseCompensationFormReady['form']['fieldsMetadata']\n"],"names":["resolveCompAndJob","jobs","compensationId","jobId","job","compensation","c","j","findPrimaryFlsaStatus","findFutureCompensations","today","todayISO","earliestEffectiveDate","comps","min","d","flsaStatusEntries","FlsaStatus","flsaOptions","status","paymentUnitEntries","PAY_PERIODS","paymentUnitOptions","unit","useCompensationForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withEffectiveDateField","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","locationUuid","employee","minWagesQuery","useLocationsGetMinimumWages","minimumWages","currentCompensation","currentJob","otherJobsCount","hadPrimaryAtMountRef","useRef","primaryFlsaStatus","hireDate","futureCompensations","hasPendingFutureCompensation","maximumEffectiveDate","isCreateMode","mode","isAddingSecondaryJob","internalMinEffectiveDate","useMemo","formatDateToStringDate","addDays","schema","metadataConfig","createCompensationSchema","state","resolvedDefaults","formMethods","useForm","zodResolver","control","getValues","setValue","watchedFlsaStatus","useWatch","watchedAdjustForMinimumWage","useEffect","currentJobActiveComp","willDeleteSecondaryJobs","carveOutActiveRef","priorEffectiveDateRef","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","createCompensationMutation","useJobsAndCompensationsCreateCompensationMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","isCommissionOnly","isOwner","isFlsaSelectionEnabled","isAdjustMinimumWageEnabled","TIP_CREDITS_UNSUPPORTED_STATES","minimumWageOptions","wage","baseMetadata","useDeriveFieldsMetadata","effectiveDateMinDate","max","fieldsMetadata","withOptions","onSubmit","options","submitResult","resolve","data","payload","resolvedJobId","resolvedCompensationId","resolvedMode","resolvedEffectiveDate","requestBodyBase","result","SDKInternalError","resolvedVersion","isDataLoading","hookFormInternals","useHookFormInternals","TitleField","FlsaStatusField","RateField","PaymentUnitField","AdjustForMinimumWageField","MinimumWageIdField","EffectiveDateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwJA,SAASA,GACPC,GACAC,GACAC,GACwD;AACxD,MAAI,CAACF,EAAM,QAAO,EAAE,cAAc,MAAM,KAAK,KAAA;AAC7C,MAAIC,GAA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,sBAAsB9B,IAA6B+B,KAA4B;AAAA,QAC/E,eACE/B,KAA8BpB,KAC1BoD,KACA;AAAA,QACN,eAAelG,IAAyBmG,KAAqB;AAAA,MAAA;AAAA,MAE/D,gBAAAzB;AAAA,MACA,mBAAAiB;AAAA,MACA,yBAAyBS,GAA8B9D,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
1
+ {"version":3,"file":"useCompensationForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsCreateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWages } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n createCompensationSchema,\n type CompensationOptionalFieldsToRequire,\n type CompensationFormData,\n type CompensationFormOutputs,\n} from './compensationSchema'\nimport {\n TitleField,\n FlsaStatusField,\n RateField,\n PaymentUnitField,\n AdjustForMinimumWageField,\n MinimumWageIdField,\n EffectiveDateField,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { FlsaStatus, PAY_PERIODS, TIP_CREDITS_UNSUPPORTED_STATES } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { addDays, formatDateToStringDate } from '@/helpers/dateFormatting'\n\nexport interface CompensationSubmitOptions {\n /** Override jobId — required when creating a compensation if not configured at hook construction (e.g. when the parent job was just created in the same submit chain). */\n jobId?: string\n /** Override compensationId — when present, forces update (PUT) routing regardless of hook construction. */\n compensationId?: string\n /**\n * Compensation version for optimistic locking on PUT. Required when forcing\n * update routing post-create (e.g. updating the auto-created stub returned\n * from `POST /v1/employees/:id/jobs`). When omitted, the hook reads the\n * version from its cached `currentCompensation`.\n */\n compensationVersion?: string\n /**\n * Supply `effectiveDate` at submit time. When `withEffectiveDateField`\n * is `true`, this overrides the form's value. When `withEffectiveDateField`\n * is `false`, this is the only way to put `effective_date` on the wire —\n * the form value is not read in that mode (matching the options-only\n * convention of `useWorkAddressForm` / `useHomeAddressForm` / `useJobForm`).\n */\n effectiveDate?: string\n}\n\nexport interface UseCompensationFormProps {\n employeeId?: string\n /** The parent job's UUID. Required in create mode (scopes `POST /v1/jobs/:jobId/compensations`). Optional in update mode — the parent job is derived from the loaded compensation. */\n jobId?: string\n /** Present → update mode (PUT /v1/compensations/:id). Omitted → create mode (POST /v1/jobs/:jobId/compensations). */\n compensationId?: string\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n defaultValues?: Partial<CompensationFormData>\n validationMode?: UseFormProps['mode']\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.EffectiveDate` (becomes `undefined`) and\n * removes `effectiveDate` from schema validation. In this mode the hook\n * does not read any form value at submit time — `effective_date` is\n * omitted from the request body unless explicitly supplied via\n * `CompensationSubmitOptions.effectiveDate`. This matches the\n * options-only convention of `useWorkAddressForm` /\n * `useHomeAddressForm` / `useJobForm`, and means the\n * `willDeleteSecondaryJobs` carve-out's form-state side effects do not\n * leak onto the wire (there is no field to render them in anyway).\n * Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\nexport interface CompensationFormFields {\n Title: typeof TitleField\n FlsaStatus: typeof FlsaStatusField | undefined\n Rate: typeof RateField\n PaymentUnit: typeof PaymentUnitField\n AdjustForMinimumWage: typeof AdjustForMinimumWageField | undefined\n MinimumWageId: typeof MinimumWageIdField | undefined\n EffectiveDate: typeof EffectiveDateField | undefined\n}\n\nexport interface UseCompensationFormReady extends BaseFormHookReady<\n FieldsMetadata,\n CompensationFormData,\n CompensationFormFields\n> {\n data: {\n /** The compensation row loaded for update; `null` in create mode. */\n compensation: Compensation | null\n /** The parent job. In update mode it's derived from the loaded compensation; in create mode it's looked up by `jobId`. `null` if neither resolves. */\n currentJob: Job | null\n minimumWages: MinimumWage[]\n /** Lower bound for `effectiveDate` (typically the parent job's hire date). */\n minimumEffectiveDate: string | null\n /** Upper bound for `effectiveDate` — the next scheduled future compensation's effective date, when one exists. */\n maximumEffectiveDate: string | null\n /** True when at least one future-dated compensation already exists for this job. */\n hasPendingFutureCompensation: boolean\n }\n status: {\n isPending: boolean\n mode: 'create' | 'update'\n /**\n * True when submitting the form right now would delete the employee's\n * secondary jobs server-side (the \"carve-out\" branch). Reactive:\n * derived from the current `flsaStatus` form value, the loaded\n * compensation, and the other-jobs count, so this flips as you change\n * inputs.\n *\n * Conditions: update mode, the loaded compensation is Nonexempt, the\n * form's `flsaStatus` has been changed to a non-Nonexempt value, and\n * the employee has at least one secondary job.\n *\n * While this flag is true the hook also takes the `effectiveDate`\n * field over: it forces the form value to today (so submits route\n * through a PUT that immediately deletes secondaries) and exposes\n * `fieldsMetadata.effectiveDate.isDisabled = true` so `Fields.EffectiveDate`\n * renders as disabled. On revert (FLSA back to Nonexempt) the prior\n * `effectiveDate` is restored. Render an inline warning keyed off\n * this flag — no separate confirmation step is needed.\n */\n willDeleteSecondaryJobs: boolean\n }\n actions: {\n onSubmit: (\n options?: CompensationSubmitOptions,\n ) => Promise<HookSubmitResult<Compensation> | undefined>\n }\n}\n\nfunction resolveCompAndJob(\n jobs: Job[] | undefined,\n compensationId: string | undefined,\n jobId: string | undefined,\n): { compensation: Compensation | null; job: Job | null } {\n if (!jobs) return { compensation: null, job: null }\n if (compensationId) {\n for (const job of jobs) {\n const compensation = job.compensations?.find(c => c.uuid === compensationId)\n if (compensation) return { compensation, job }\n }\n // If the comp isn't in any job's compensations list, still try to resolve\n // the job by jobId so callers can check job metadata (e.g. job.primary).\n const fallbackJob = jobId ? (jobs.find(j => j.uuid === jobId) ?? null) : null\n return { compensation: null, job: fallbackJob }\n }\n if (jobId) return { compensation: null, job: jobs.find(j => j.uuid === jobId) ?? null }\n return { compensation: null, job: null }\n}\n\nfunction findPrimaryFlsaStatus(jobs: Job[] | undefined): FlsaStatusType | null {\n if (!jobs) return null\n for (const job of jobs) {\n if (!job.primary) continue\n const compensation = job.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n if (compensation?.flsaStatus) return compensation.flsaStatus\n }\n return null\n}\n\nfunction findFutureCompensations(job: Job | null): Compensation[] {\n if (!job?.compensations) return []\n const today = todayISO()\n return job.compensations.filter(c => c.effectiveDate !== undefined && c.effectiveDate > today)\n}\n\nfunction earliestEffectiveDate(comps: Compensation[]): string | null {\n if (comps.length === 0) return null\n return comps.reduce<string | null>((min, c) => {\n const d = c.effectiveDate\n if (!d) return min\n if (!min || d < min) return d\n return min\n }, null)\n}\n\nconst flsaStatusEntries: FlsaStatusType[] = [\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n]\n\nconst flsaOptions = flsaStatusEntries.map(status => ({ value: status, label: status }))\n\nconst paymentUnitEntries: PaymentUnit[] = [\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n]\n\nconst paymentUnitOptions = paymentUnitEntries.map(unit => ({ value: unit, label: unit }))\n\nfunction todayISO(): string {\n return new Date().toISOString().split('T')[0]!\n}\n\nexport function useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withEffectiveDateField = true,\n}: UseCompensationFormProps): HookLoadingResult | UseCompensationFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n {\n employeeId: employeeId ?? '',\n // Fetch all effective-dated compensations when editing an existing one so\n // resolveCompAndJob can find the target comp (future-dated comps are\n // omitted from the default response, which only returns the current comp).\n include: compensationId\n ? GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations\n : undefined,\n },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active)\n const locationUuid = currentWorkAddress?.locationUuid\n const employee = employeeQuery.data?.employee\n\n const minWagesQuery = useLocationsGetMinimumWages(\n { locationUuid: locationUuid ?? '' },\n { enabled: !!locationUuid },\n )\n\n const minimumWages = minWagesQuery.data?.minimumWageList ?? []\n\n const { compensation: currentCompensation, job: currentJob } = resolveCompAndJob(\n employeeJobs,\n compensationId,\n jobId,\n )\n\n const otherJobsCount =\n employeeJobs && currentJob ? employeeJobs.filter(j => j.uuid !== currentJob.uuid).length : 0\n\n // Snapshot — written exactly once, on the first render where `employeeJobs`\n // is defined (i.e., the initial `getJobs` query has resolved) — capturing\n // whether the employee already had a primary job at that moment.\n //\n // Used to ignore the API-generated stub primary (FLSA Nonexempt, rate \"0.00\")\n // that briefly appears between the chained job POST and comp PUT during\n // onboarding: `getJobs` invalidates between the two mutations and\n // momentarily includes the stub, which would otherwise flip\n // `isAddingSecondaryJob` to true and hide `Fields.FlsaStatus` mid-submit.\n //\n // In steady-state flows (edit primary, edit secondary, add secondary), the\n // real primary already exists when the query first resolves, so the snapshot\n // is `true` and live `employeeJobs` continues to drive `primaryFlsaStatus`.\n // Recovery for the rare case where a partner mounts before any jobs exist\n // and a primary is created externally mid-form is to remount the hook\n // (e.g., via a `key` change).\n const hadPrimaryAtMountRef = useRef<boolean | null>(null)\n if (hadPrimaryAtMountRef.current === null && employeeJobs !== undefined) {\n hadPrimaryAtMountRef.current = employeeJobs.some(job => job.primary)\n }\n const hadPrimaryAtMount = hadPrimaryAtMountRef.current === true\n\n // FLSA status of the employee's primary job's current compensation, when one\n // exists. Used as a fallback default when adding a *secondary* job/comp so the\n // multi-job classification stays consistent with the primary by default — the\n // user can still override it (when allowed). Null when there was no primary\n // job at the moment the hook first observed `employeeJobs`, or when the\n // primary has no current compensation yet.\n const primaryFlsaStatus = hadPrimaryAtMount ? findPrimaryFlsaStatus(employeeJobs) : null\n\n const hireDate =\n currentJob?.hireDate ??\n // Secondary jobs being created (AddAnotherJob) have no hireDate until the\n // job POST completes. Fall back to the primary job's hireDate so the schema\n // can enforce EFFECTIVE_DATE_BEFORE_HIRE during that window.\n employeeJobs?.find(j => j.primary)?.hireDate ??\n null\n\n // In update mode, exclude the compensation being edited so it doesn't\n // bound `maximumEffectiveDate` to its own current date — that would prevent\n // the user from pushing the pending effective date further out.\n const futureCompensations = findFutureCompensations(currentJob).filter(\n c => c.uuid !== compensationId,\n )\n const hasPendingFutureCompensation = futureCompensations.length > 0\n const maximumEffectiveDate = earliestEffectiveDate(futureCompensations)\n\n const isCreateMode = !compensationId\n const mode = isCreateMode ? 'create' : 'update'\n // Adding a secondary job (the employee already has a primary). The Gusto API\n // only allows secondaries when the primary's current FLSA is Nonexempt, and\n // the secondary itself must match — so the FLSA field is not user-editable\n // in this branch. We force the form value to the primary's FLSA below and\n // hide `Fields.FlsaStatus`.\n // True when adding a brand-new secondary job (not when scheduling a future\n // comp for the primary). The distinction matters: for the primary's future\n // comp, FLSA should be editable; for a secondary, it must match the primary.\n const isAddingSecondaryJob =\n isCreateMode && primaryFlsaStatus === FlsaStatus.NONEXEMPT && currentJob?.primary !== true\n\n // Derive the effective-date floor internally so consumers don't need to wire\n // it up. Rules by mode and job type:\n // create (any job): tomorrow — new comp must be future-dated\n // update, primary: undefined — the carve-out (willDeleteSecondaryJobs) can\n // force effectiveDate to today on a disabled field; enforcing a floor here\n // would produce a spurious EFFECTIVE_DATE_BEFORE_MIN on submit.\n // update, secondary: tomorrow — must be in the future\n // The hire-date lower bound is handled separately in the schema via the\n // `hireDate` option (→ EFFECTIVE_DATE_BEFORE_HIRE), which fires alongside\n // this check so each violation gets its own error message.\n const internalMinEffectiveDate = useMemo(() => {\n if (!withEffectiveDateField) return undefined\n if (!isCreateMode && currentJob?.primary === true) return undefined\n\n return formatDateToStringDate(addDays(new Date(), 1)) ?? undefined\n }, [isCreateMode, currentJob?.primary, withEffectiveDateField])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createCompensationSchema({\n mode,\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate: internalMinEffectiveDate,\n withEffectiveDateField,\n }),\n [mode, optionalFieldsToRequire, hireDate, internalMinEffectiveDate, withEffectiveDateField],\n )\n\n const state = currentWorkAddress?.state\n\n // `flsaStatus` is intentionally allowed to be undefined so the field renders\n // an empty placeholder when nothing is provided — partners can choose to\n // seed it via `defaultValues.flsaStatus`. When a `compensation` is loaded we\n // seed from it; for a brand-new secondary job we inherit from the primary's\n // current compensation so multi-job classification stays consistent. The\n // schema enforces requiredness on submit in `create` mode (see\n // `requiredFieldsConfig` in compensationSchema.ts).\n //\n // `title` lives on compensation in the API — `job.title` is a denormalized\n // snapshot of the primary comp's title that can lag behind comp-level edits\n // on secondaries. Seed directly from the loaded compensation so editing in\n // place can't silently re-introduce a stale title from the job record.\n const resolvedDefaults: CompensationFormData = useMemo(\n () => ({\n title: currentCompensation?.title ?? partnerDefaults?.title ?? '',\n // When adding a secondary, the FLSA must match the primary's — force it\n // here (overriding any partner default) so the form submits the right\n // value even though `Fields.FlsaStatus` is hidden.\n flsaStatus: isAddingSecondaryJob\n ? primaryFlsaStatus\n : (currentCompensation?.flsaStatus ??\n partnerDefaults?.flsaStatus ??\n primaryFlsaStatus ??\n undefined),\n rate: Number(currentCompensation?.rate ?? partnerDefaults?.rate ?? 0),\n adjustForMinimumWage:\n currentCompensation?.adjustForMinimumWage ?? partnerDefaults?.adjustForMinimumWage ?? false,\n minimumWageId:\n currentCompensation?.minimumWages?.[0]?.uuid ?? partnerDefaults?.minimumWageId ?? '',\n paymentUnit:\n currentCompensation?.paymentUnit ?? partnerDefaults?.paymentUnit ?? PAY_PERIODS.HOUR,\n effectiveDate: currentCompensation?.effectiveDate ?? partnerDefaults?.effectiveDate ?? null,\n }),\n [currentCompensation, currentJob, partnerDefaults, primaryFlsaStatus, isAddingSecondaryJob],\n )\n\n const formMethods = useForm<CompensationFormData, unknown, CompensationFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const { control, getValues, setValue, clearErrors } = formMethods\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedAdjustForMinimumWage = useWatch({\n control,\n name: 'adjustForMinimumWage',\n })\n\n // Validation rules for `paymentUnit` and `rate` are FLSA-driven, so any\n // prior error on those fields is stale once FLSA changes. RHF doesn't clear\n // them on its own (`setValue` without `shouldValidate` skips the resolver,\n // and reValidate is per-field) — clear eagerly and let the next blur/submit\n // re-establish the error if it still applies.\n useEffect(() => {\n clearErrors(['paymentUnit', 'rate'])\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', PAY_PERIODS.PAYCHECK)\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', PAY_PERIODS.YEAR)\n setValue('rate', 0)\n } else {\n setValue('paymentUnit', resolvedDefaults.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, clearErrors, resolvedDefaults.paymentUnit])\n\n // The FLSA status that represents the employee's current classification.\n // In update mode this is the compensation being edited. In create mode\n // `currentCompensation` is null, so fall back to the job's active\n // compensation (identified by currentCompensationUuid) — this lets the\n // secondary-job warning fire even when scheduling a future-dated change.\n const currentJobActiveComp = currentJob\n ? currentJob.compensations?.find(c => c.uuid === currentJob.currentCompensationUuid)\n : undefined\n const effectiveBaseFlsaStatus =\n currentCompensation?.flsaStatus ?? currentJobActiveComp?.flsaStatus ?? null\n\n // True when the user is changing FLSA away from Nonexempt on a job that has\n // secondary jobs — those secondaries will be deleted by the API when the\n // new classification takes effect (immediately in update mode, at the chosen\n // effective date in create mode). Drives the warning and, in update mode\n // only, the effectiveDate-lock side effect below.\n const willDeleteSecondaryJobs =\n effectiveBaseFlsaStatus === FlsaStatus.NONEXEMPT &&\n watchedFlsaStatus !== undefined &&\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT &&\n otherJobsCount > 0\n\n // Carve-out UX — update mode only: while willDeleteSecondaryJobs is active\n // the server deletes secondaries immediately on PUT. Mirror this by forcing\n // `effectiveDate` to today and disabling the field. In create mode the\n // deletion happens at the chosen future date, so we show the warning but\n // leave the date field editable.\n const carveOutActiveRef = useRef(false)\n const priorEffectiveDateRef = useRef<string | null>(null)\n useEffect(() => {\n if (!isCreateMode && willDeleteSecondaryJobs && !carveOutActiveRef.current) {\n priorEffectiveDateRef.current = getValues('effectiveDate') ?? null\n setValue('effectiveDate', todayISO(), { shouldDirty: true, shouldValidate: false })\n carveOutActiveRef.current = true\n } else if (!isCreateMode && !willDeleteSecondaryJobs && carveOutActiveRef.current) {\n setValue('effectiveDate', priorEffectiveDateRef.current ?? null, {\n shouldDirty: true,\n shouldValidate: false,\n })\n priorEffectiveDateRef.current = null\n carveOutActiveRef.current = false\n }\n }, [isCreateMode, willDeleteSecondaryJobs, getValues, setValue])\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation()\n const createCompensationMutation = useJobsAndCompensationsCreateCompensationMutation()\n\n const isPending = updateCompensationMutation.isPending || createCompensationMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('CompensationForm')\n\n const queriesForErrors = employeeId\n ? [jobsQuery, addressesQuery, employeeQuery, minWagesQuery]\n : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const isCommissionOnly =\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n const isOwner = watchedFlsaStatus === FlsaStatus.OWNER\n\n // Hide `Fields.FlsaStatus` when the user has no meaningful choice:\n // - update mode editing a secondary whose comp is already Nonexempt\n // (must keep matching the primary), and\n // - create mode while adding a secondary (must inherit primary's FLSA).\n // The first job's create flow and primary-job edits keep the field exposed.\n const isFlsaSelectionEnabled =\n !isAddingSecondaryJob &&\n (watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary === true || isCreateMode)\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n // Min-wage adjustment is only valid for Nonexempt FLSA (and a state that\n // allows tip credit). When the gate flips off — typically because the user\n // changed FLSA away from Nonexempt — `Fields.AdjustForMinimumWage` and\n // `Fields.MinimumWageId` stop rendering, but the underlying form values\n // persist in react-hook-form state. That would leak an\n // `adjust_for_minimum_wage: true` + `minimum_wages: [...]` body on submit\n // (server rejects with \"Minimum wage adjustments only valid for\n // flsa_status: Nonexempt\"). Reset both values to safe defaults so the\n // submitted payload always matches what the user can actually see.\n useEffect(() => {\n if (isAdjustMinimumWageEnabled) return\n if (getValues('adjustForMinimumWage')) {\n setValue('adjustForMinimumWage', false, { shouldDirty: true, shouldValidate: false })\n }\n if (getValues('minimumWageId')) {\n setValue('minimumWageId', '', { shouldDirty: true, shouldValidate: false })\n }\n // Both fields stop rendering once the gate closes — clear errors so a\n // stale one doesn't silently fail the next submit with no visible UI to fix.\n clearErrors(['adjustForMinimumWage', 'minimumWageId'])\n }, [isAdjustMinimumWageEnabled, getValues, setValue, clearErrors])\n\n const minimumWageOptions = minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${wage.wage} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const effectiveDateMinDate = useMemo(\n () =>\n [internalMinEffectiveDate, hireDate]\n .filter((d): d is string => !!d)\n .reduce<string | null>((max, d) => (!max || d > max ? d : max), null),\n [internalMinEffectiveDate, hireDate],\n )\n const fieldsMetadata = {\n title: baseMetadata.title,\n effectiveDate: {\n ...baseMetadata.effectiveDate,\n isDisabled: willDeleteSecondaryJobs && !isCreateMode,\n minDate: effectiveDateMinDate,\n maxDate: maximumEffectiveDate,\n },\n flsaStatus: withOptions<FlsaStatusType>(\n baseMetadata.flsaStatus,\n flsaOptions,\n flsaStatusEntries,\n ),\n rate: { ...baseMetadata.rate, isDisabled: isCommissionOnly },\n paymentUnit: withOptions<PaymentUnit>(\n { ...baseMetadata.paymentUnit, isDisabled: isOwner || isCommissionOnly },\n paymentUnitOptions,\n paymentUnitEntries,\n ),\n adjustForMinimumWage: {\n ...baseMetadata.adjustForMinimumWage,\n isDisabled: !isAdjustMinimumWageEnabled,\n },\n minimumWageId: withOptions<MinimumWage>(\n baseMetadata.minimumWageId,\n minimumWageOptions,\n minimumWages,\n ),\n }\n\n const onSubmit = async (\n options?: CompensationSubmitOptions,\n ): Promise<HookSubmitResult<Compensation> | undefined> => {\n let submitResult: HookSubmitResult<Compensation> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: CompensationFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedJobId = options?.jobId ?? jobId\n const resolvedCompensationId = options?.compensationId ?? compensationId\n const resolvedMode = resolvedCompensationId ? 'update' : 'create'\n\n // When the field is rendered, the validated payload value wins\n // unless an explicit submit-time override is supplied. When the\n // field is hidden (`withEffectiveDateField: false`) we are\n // strictly options-only — matching `useWorkAddressForm` and the\n // hidden-field behavior of `useHomeAddressForm` / `useJobForm`.\n // The carve-out's form-state side effect (force value to today)\n // is therefore inert in the hidden-field path; partners who\n // need a specific date there must supply it via\n // `CompensationSubmitOptions.effectiveDate`.\n const resolvedEffectiveDate = withEffectiveDateField\n ? (options?.effectiveDate ?? payload.effectiveDate ?? undefined)\n : (options?.effectiveDate ?? undefined)\n\n const requestBodyBase = {\n rate: String(payload.rate),\n paymentUnit: payload.paymentUnit,\n flsaStatus: payload.flsaStatus,\n effectiveDate: resolvedEffectiveDate,\n title: payload.title || undefined,\n adjustForMinimumWage: payload.adjustForMinimumWage,\n minimumWages: payload.adjustForMinimumWage ? [{ uuid: payload.minimumWageId }] : [],\n }\n\n let result: Compensation | undefined\n\n if (resolvedMode === 'create') {\n if (!resolvedJobId) {\n throw new SDKInternalError(\n 'jobId is required to create a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n // Schema's `requiredFieldsConfig` guarantees `flsaStatus` is set\n // on create-mode submit; the runtime guard appeases the API\n // request-body type (which requires a non-undefined value on\n // POST, vs. the optional PUT body).\n if (!payload.flsaStatus) {\n throw new SDKInternalError('flsaStatus is required to create a compensation.')\n }\n const createResponse = await createCompensationMutation.mutateAsync({\n request: {\n jobId: resolvedJobId,\n compensationsRequestBody: { ...requestBodyBase, flsaStatus: payload.flsaStatus },\n },\n })\n result = createResponse.compensation\n if (!result) throw new SDKInternalError('Compensation creation failed')\n } else {\n if (!resolvedCompensationId) {\n throw new SDKInternalError(\n 'compensationId is required to update a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n const resolvedVersion =\n options?.compensationVersion ?? (currentCompensation?.version as string | undefined)\n if (!resolvedVersion) {\n throw new SDKInternalError(\n 'compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded.',\n )\n }\n const updateResponse = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: resolvedCompensationId,\n compensationsUpdateRequestBody: {\n version: resolvedVersion,\n ...requestBodyBase,\n },\n },\n })\n result = updateResponse.compensation\n if (!result) throw new SDKInternalError('Compensation update failed')\n }\n\n submitResult = { mode: resolvedMode, data: result }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading ||\n addressesQuery.isLoading ||\n employeeQuery.isLoading ||\n minWagesQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n compensation: currentCompensation,\n currentJob,\n minimumWages,\n minimumEffectiveDate: effectiveDateMinDate,\n maximumEffectiveDate,\n hasPendingFutureCompensation,\n },\n status: {\n isPending,\n mode,\n willDeleteSecondaryJobs,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: TitleField,\n FlsaStatus: isFlsaSelectionEnabled ? FlsaStatusField : undefined,\n Rate: RateField,\n PaymentUnit: PaymentUnitField,\n AdjustForMinimumWage: isAdjustMinimumWageEnabled ? AdjustForMinimumWageField : undefined,\n MinimumWageId:\n isAdjustMinimumWageEnabled && watchedAdjustForMinimumWage\n ? MinimumWageIdField\n : undefined,\n EffectiveDate: withEffectiveDateField ? EffectiveDateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\nexport type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady\nexport type CompensationFieldsMetadata = UseCompensationFormReady['form']['fieldsMetadata']\n"],"names":["resolveCompAndJob","jobs","compensationId","jobId","job","compensation","c","j","findPrimaryFlsaStatus","findFutureCompensations","today","todayISO","earliestEffectiveDate","comps","min","d","flsaStatusEntries","FlsaStatus","flsaOptions","status","paymentUnitEntries","PAY_PERIODS","paymentUnitOptions","unit","useCompensationForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withEffectiveDateField","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","locationUuid","employee","minWagesQuery","useLocationsGetMinimumWages","minimumWages","currentCompensation","currentJob","otherJobsCount","hadPrimaryAtMountRef","useRef","primaryFlsaStatus","hireDate","futureCompensations","hasPendingFutureCompensation","maximumEffectiveDate","isCreateMode","mode","isAddingSecondaryJob","internalMinEffectiveDate","useMemo","formatDateToStringDate","addDays","schema","metadataConfig","createCompensationSchema","state","resolvedDefaults","formMethods","useForm","zodResolver","control","getValues","setValue","clearErrors","watchedFlsaStatus","useWatch","watchedAdjustForMinimumWage","useEffect","currentJobActiveComp","willDeleteSecondaryJobs","carveOutActiveRef","priorEffectiveDateRef","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","createCompensationMutation","useJobsAndCompensationsCreateCompensationMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","isCommissionOnly","isOwner","isFlsaSelectionEnabled","isAdjustMinimumWageEnabled","TIP_CREDITS_UNSUPPORTED_STATES","minimumWageOptions","wage","baseMetadata","useDeriveFieldsMetadata","effectiveDateMinDate","max","fieldsMetadata","withOptions","onSubmit","options","submitResult","resolve","data","payload","resolvedJobId","resolvedCompensationId","resolvedMode","resolvedEffectiveDate","requestBodyBase","result","SDKInternalError","resolvedVersion","isDataLoading","hookFormInternals","useHookFormInternals","TitleField","FlsaStatusField","RateField","PaymentUnitField","AdjustForMinimumWageField","MinimumWageIdField","EffectiveDateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwJA,SAASA,GACPC,GACAC,GACAC,GACwD;AACxD,MAAI,CAACF,EAAM,QAAO,EAAE,cAAc,MAAM,KAAK,KAAA;AAC7C,MAAIC,GAAgB;AAClB,eAAWE,KAAOH,GAAM;AACtB,YAAMI,IAAeD,EAAI,eAAe,KAAK,CAAAE,MAAKA,EAAE,SAASJ,CAAc;AAC3E,UAAIG,EAAc,QAAO,EAAE,cAAAA,GAAc,KAAAD,EAAA;AAAA,IAC3C;AAIA,WAAO,EAAE,cAAc,MAAM,KADTD,IAASF,EAAK,KAAK,OAAKM,EAAE,SAASJ,CAAK,KAAK,OAAQ,KACvC;AAAA,EACpC;AACA,SAAIA,IAAc,EAAE,cAAc,MAAM,KAAKF,EAAK,KAAK,CAAAM,MAAKA,EAAE,SAASJ,CAAK,KAAK,KAAA,IAC1E,EAAE,cAAc,MAAM,KAAK,KAAA;AACpC;AAEA,SAASK,GAAsBP,GAAgD;AAC7E,MAAI,CAACA,EAAM,QAAO;AAClB,aAAWG,KAAOH,GAAM;AACtB,QAAI,CAACG,EAAI,QAAS;AAClB,UAAMC,IAAeD,EAAI,eAA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ACA,MAAM;AACJ,UAAAA,GAAA;AAAA,QACF;AAAA,MAAA,EACF;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMY,KAAgBhG,IAClBM,EAAU,aACVG,EAAe,aACfE,EAAc,aACdO,EAAc,YACd,IAEE+E,KAAoBC,GAAqBvD,CAAW;AAE1D,SAAIqD,MAAkBhG,MAAe,CAACa,KAAgB,CAACI,MAC9C,EAAE,WAAW,IAAe,eAAAkD,GAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,cAAc9C;AAAA,MACd,YAAAC;AAAA,MACA,cAAAF;AAAA,MACA,sBAAsB0D;AAAA,MACtB,sBAAAhD;AAAA,MACA,8BAAAD;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAiC;AAAA,MACA,MAAA9B;AAAA,MACA,yBAAAuB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAA2B,GAAA;AAAA,IACX,eAAAf;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAOgC;AAAA,QACP,YAAY5B,KAAyB6B,KAAkB;AAAA,QACvD,MAAMC;AAAA,QACN,aAAaC;AAAA,QACb,sBAAsB9B,IAA6B+B,KAA4B;AAAA,QAC/E,eACE/B,KAA8BpB,KAC1BoD,KACA;AAAA,QACN,eAAenG,IAAyBoG,KAAqB;AAAA,MAAA;AAAA,MAE/D,gBAAAzB;AAAA,MACA,mBAAAiB;AAAA,MACA,yBAAyBS,GAA8B/D,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
@@ -1,11 +1,11 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import { TextInputHookField as t } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
3
- import { SelectHookField as r } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
2
+ import { SelectHookField as t } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
3
+ import { RadioGroupHookField as r } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
4
4
  import { CheckboxHookField as i } from "../../../../../partner-hook-utils/form/fields/CheckboxHookField.js";
5
5
  import { DatePickerHookField as n } from "../../../../../partner-hook-utils/form/fields/DatePickerHookField.js";
6
- import { RadioGroupHookField as a } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
6
+ import { TextInputHookField as a } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
7
7
  function F(e) {
8
- return /* @__PURE__ */ o(t, { ...e, name: "title" });
8
+ return /* @__PURE__ */ o(a, { ...e, name: "title" });
9
9
  }
10
10
  function p(e) {
11
11
  return /* @__PURE__ */ o(n, { ...e, name: "hireDate" });
@@ -14,10 +14,10 @@ function k(e) {
14
14
  return /* @__PURE__ */ o(i, { ...e, name: "twoPercentShareholder" });
15
15
  }
16
16
  function s(e) {
17
- return /* @__PURE__ */ o(a, { ...e, name: "stateWcCovered" });
17
+ return /* @__PURE__ */ o(r, { ...e, name: "stateWcCovered" });
18
18
  }
19
19
  function C(e) {
20
- return /* @__PURE__ */ o(r, { ...e, name: "stateWcClassCode" });
20
+ return /* @__PURE__ */ o(t, { ...e, name: "stateWcClassCode" });
21
21
  }
22
22
  export {
23
23
  p as HireDateField,
@@ -37,11 +37,12 @@ export interface UseJobFormProps {
37
37
  /**
38
38
  * When `false`, hides `Fields.Title` (becomes `undefined`), removes
39
39
  * `title` from schema validation, and skips sending `title` on PUT/POST.
40
- * Use this when another form owns the title field — e.g. steady-state
41
- * compensation edits render title via `CompFields.Title` so a title
42
- * change is effective-dated alongside the rest of the compensation
43
- * change, rather than overwriting the job's current title immediately.
44
- * Defaults to `true`.
40
+ * Use this when another form owns the title field — e.g. compensation
41
+ * edit surfaces render the title via `CompFields.Title` because title
42
+ * lives on compensation in the API (`job.title` is just a denormalized
43
+ * snapshot of the primary comp's title). Defaults to `true` so the
44
+ * standalone job-creation flow still gathers a title for the create
45
+ * body.
45
46
  */
46
47
  withTitleField?: boolean;
47
48
  }