@gusto/embedded-react-sdk 0.56.2 → 0.56.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 (183) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/components/Common/FieldCaption/FieldCaption.js +18 -24
  3. package/dist/components/Common/FieldCaption/FieldCaption.js.map +1 -1
  4. package/dist/components/Common/FieldCaption/FieldCaption.module.scss.js +3 -5
  5. package/dist/components/Common/FieldCaption/FieldCaption.module.scss.js.map +1 -1
  6. package/dist/components/Common/PaginationControl/PaginationControl.js +66 -62
  7. package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
  8. package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
  9. package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
  10. package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
  11. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +6 -3
  12. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  13. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +6 -3
  14. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  15. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +8 -5
  16. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  17. package/dist/components/Company/BankAccount/BankAccountForm/context.js +6 -3
  18. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  19. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +6 -3
  20. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  21. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +11 -8
  22. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  23. package/dist/components/Company/Industry/Context.js +9 -6
  24. package/dist/components/Company/Industry/Context.js.map +1 -1
  25. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +6 -3
  26. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  27. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +6 -3
  28. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  29. package/dist/components/Company/OnboardingOverview/context.js +6 -3
  30. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  31. package/dist/components/Company/PaySchedule/management/PaySchedule.js +60 -0
  32. package/dist/components/Company/PaySchedule/management/PaySchedule.js.map +1 -0
  33. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.js +67 -0
  34. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.js.map +1 -0
  35. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +59 -0
  36. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -0
  37. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +57 -0
  38. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -0
  39. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +46 -0
  40. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -0
  41. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +101 -0
  42. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -0
  43. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +81 -0
  44. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -0
  45. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.js +18 -0
  46. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.js.map +1 -0
  47. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js +56 -0
  48. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -0
  49. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +34 -0
  50. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -0
  51. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js +77 -0
  52. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -0
  53. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.module.scss.js +10 -0
  54. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.module.scss.js.map +1 -0
  55. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js +66 -0
  56. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -0
  57. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +75 -57
  58. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  59. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +6 -3
  60. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  61. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +6 -3
  62. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  63. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +6 -3
  64. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
  65. package/dist/components/Company/StateTaxes/shared/requirementSetError.js +15 -0
  66. package/dist/components/Company/StateTaxes/shared/requirementSetError.js.map +1 -0
  67. package/dist/components/Company/exports/companyManagement.js +7 -0
  68. package/dist/components/Company/exports/companyManagement.js.map +1 -0
  69. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +6 -3
  70. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  71. package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +1 -1
  72. package/dist/components/Employee/PaymentMethod/management/PaymentMethodBankForm.js +4 -4
  73. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +4 -4
  74. package/dist/components/Flow/Flow.js +1 -1
  75. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +28 -27
  76. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  77. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +51 -58
  78. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
  79. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js +12 -7
  80. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js.map +1 -1
  81. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +87 -85
  82. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  83. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +1 -1
  84. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  85. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +55 -54
  86. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
  87. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +66 -62
  88. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
  89. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +129 -125
  90. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  91. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +30 -27
  92. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
  93. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js +41 -30
  94. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js.map +1 -1
  95. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js.map +1 -1
  96. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +159 -152
  97. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
  98. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +61 -59
  99. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
  100. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +32 -31
  101. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
  102. package/dist/components/Payroll/PayrollList/PayrollList.js +16 -16
  103. package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
  104. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
  105. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +61 -61
  106. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
  107. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +192 -193
  108. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  109. package/dist/components/Payroll/Transition/TransitionFlow.js +27 -22
  110. package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -1
  111. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js +55 -53
  112. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js.map +1 -1
  113. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +44 -41
  114. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
  115. package/dist/components/Payroll/helpers.js +72 -67
  116. package/dist/components/Payroll/helpers.js.map +1 -1
  117. package/dist/components/Payroll/usePreparedPayrollData.js +37 -25
  118. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  119. package/dist/contexts/ApiProvider/ApiProvider.js +23 -22
  120. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  121. package/dist/contexts/ApiProvider/informationRequestEnumHook.js +30 -0
  122. package/dist/contexts/ApiProvider/informationRequestEnumHook.js.map +1 -0
  123. package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js.map +1 -1
  124. package/dist/helpers/dateFormatting.js.map +1 -1
  125. package/dist/helpers/formattedStrings.js +9 -8
  126. package/dist/helpers/formattedStrings.js.map +1 -1
  127. package/dist/i18n/I18n.js +2 -0
  128. package/dist/i18n/I18n.js.map +1 -1
  129. package/dist/i18n/en/Company.Management.PaySchedule.json.js +24 -0
  130. package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -0
  131. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +18 -0
  132. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -0
  133. package/dist/i18n/en/Company.StateTaxes.json.js +1 -1
  134. package/dist/i18n/en/Payroll.GrossUpModal.json.js +12 -14
  135. package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -1
  136. package/dist/i18n/en/Payroll.PayrollOverview.json.js +1 -1
  137. package/dist/i18n/en/common.json.js +36 -38
  138. package/dist/i18n/en/common.json.js.map +1 -1
  139. package/dist/index.js +137 -135
  140. package/dist/index.js.map +1 -1
  141. package/dist/package.json.js +1 -1
  142. package/dist/shared/constants.js +39 -31
  143. package/dist/shared/constants.js.map +1 -1
  144. package/dist/src/components/Company/PaySchedule/management/PaySchedule.d.ts +24 -0
  145. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.d.ts +10 -0
  146. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +11 -0
  147. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +9 -0
  148. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +35 -0
  149. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +29 -0
  150. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/index.d.ts +1 -0
  151. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.d.ts +7 -0
  152. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.d.ts +12 -0
  153. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +9 -0
  154. package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +20 -0
  155. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverview.d.ts +11 -0
  156. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +18 -0
  157. package/dist/src/components/Company/PaySchedule/management/index.d.ts +1 -0
  158. package/dist/src/components/Company/PaySchedule/management/payScheduleManagementStateMachine.d.ts +12 -0
  159. package/dist/src/components/Company/StateTaxes/shared/requirementSetError.d.ts +18 -0
  160. package/dist/src/components/Company/StateTaxes/shared/requirementSetError.test.d.ts +1 -0
  161. package/dist/src/components/Company/exports/companyManagement.d.ts +2 -0
  162. package/dist/src/components/Payroll/PayrollBlocker/payrollHelpers.d.ts +12 -0
  163. package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +6 -1
  164. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.d.ts +2 -2
  165. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.d.ts +6 -1
  166. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.d.ts +7 -1
  167. package/dist/src/components/Payroll/helpers.d.ts +34 -0
  168. package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +6 -1
  169. package/dist/src/components/index.d.ts +12 -0
  170. package/dist/src/contexts/ApiProvider/informationRequestEnumHook.d.ts +14 -0
  171. package/dist/src/contexts/ApiProvider/informationRequestEnumHook.test.d.ts +1 -0
  172. package/dist/src/contexts/UnstableFeaturesProvider/useUnstableFeature.d.ts +2 -0
  173. package/dist/src/helpers/dateFormatting.d.ts +2 -2
  174. package/dist/src/helpers/formattedStrings.d.ts +15 -0
  175. package/dist/src/i18n/en/common.json.d.ts +0 -1
  176. package/dist/src/i18n/types.d.ts +96 -6
  177. package/dist/src/models/external.d.ts +12 -0
  178. package/dist/src/shared/constants.d.ts +16 -0
  179. package/dist/style.css +1 -1
  180. package/dist/types/sdkError.js +32 -21
  181. package/dist/types/sdkError.js.map +1 -1
  182. package/docs/guides/endpoint-inventory.json +59 -10
  183. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"usePayrollEditEmployeeForm.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { useFieldArray, useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { useEarningTypesListSuspense } from '@gusto/embedded-api/react-query/earningTypesList'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport {\n createPayrollEditEmployeeSchema,\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n PayrollEditEmployeeErrorCodes,\n reimbursementDraftSchema,\n type PayrollEditEmployeeFormData,\n type PayrollEditEmployeeFormOutputs,\n} from './payrollEditEmployeeSchema'\nimport {\n buildPayrollUpdateEmployeeCompensation,\n collectOvertimeEarningNames,\n derivePayrollEditEmployeeDefaults,\n hasBreakdownsMatchingWorkweeks,\n hasExistingOvertimeHours,\n normalizeWorkweeks,\n resolveEditableFixedCompensations,\n zeroFillClearedWorkweekCells,\n type NormalizedWorkweek,\n} from './payrollEditEmployeeHelpers'\nimport {\n computeTimeOffRemaining,\n createPayrollEditEmployeeFields,\n createReimbursementDraftFields,\n type PayrollEditEmployeeErrorMessages,\n type PayrollEditEmployeeFields,\n type ReimbursementDraftFields,\n type ReimbursementRow,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { derivePayrollCategory, isOffCyclePayroll } from '@/components/Payroll/payrollTypes'\nimport { PREPARE_QUERY_KEY } from '@/components/Payroll/PayrollConfiguration/usePayrollConfigurationData'\nimport { isOvertimeEligibleFlsaStatus } from '@/components/Payroll/helpers'\nimport { retryAsync } from '@/helpers/retryAsync'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport {\n composeErrorHandler,\n type QueryWithRefetch,\n} from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldMetadataWithOptions,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean =>\n error instanceof UnprocessableEntityError &&\n error.errors.some(issue => issue.category === 'invalid_operation')\n\n/**\n * Options accepted by {@link usePayrollEditEmployeeForm}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormProps {\n /** The associated employee identifier. */\n employeeId: string\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /**\n * Whether to expose reimbursement controls (`form.Fields.reimbursements`,\n * `actions.addReimbursement`/`removeReimbursement`, `form.reimbursements`).\n * Defaults to `true`. Controls are omitted for off-cycle payrolls regardless,\n * since those write reimbursements via the legacy fixed-compensation path.\n */\n withReimbursements?: boolean\n /** When validation runs. Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Defaults to `true`. Set to `false` when composing with other forms. */\n shouldFocusError?: boolean\n /**\n * Display copy for each validation error code, baked into every bound field so\n * it resolves and renders its own message. Supply it once, keyed by\n * {@link PayrollEditEmployeeErrorCodes}; a missing code falls back to the raw\n * code. Omit it to render raw codes.\n */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * Field metadata for {@link usePayrollEditEmployeeForm}, keyed by full form path.\n *\n * @remarks\n * Keys are minted from the prepared payroll's compensations at runtime\n * (`hours.${jobUuid}.${name}.${workweekStart}` and similar), so neither the key\n * set nor which entries carry options is known ahead of time.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldsMetadata = Record<\n string,\n FieldMetadata | FieldMetadataWithOptions\n>\n\n/**\n * Ready-state return value of {@link usePayrollEditEmployeeForm} — the\n * `isLoading: false` branch of {@link UsePayrollEditEmployeeFormResult}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormReady extends BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n> {\n /** Loaded entities backing the editor. */\n data: {\n /** The employee being edited. */\n employee: Employee\n /** The employee's prepared compensation for this payroll, if present. */\n employeeCompensation?: PayrollEmployeeCompensationsType\n /** The prepared payroll (server-calculated totals and workweeks). */\n preparedPayroll: PayrollPrepared\n /** The pay schedule for the payroll, if loaded. */\n paySchedule?: PayScheduleShow\n /** Whether the pay period spans more than one workweek. Raw workweeks are on `preparedPayroll.workweeks`. */\n isMultipleWorkweeks: boolean\n /**\n * The pay period's normalized workweeks (`{ startDate, endDate }` strings),\n * in order — one entry, spanning the pay period, when it's a single\n * workweek. The per-workweek split fields are keyed by start date only, so\n * this is the source for each column's date range.\n */\n workweeks: NormalizedWorkweek[]\n /** Whether the employee is overtime-eligible (nonexempt family). Drives whether hours split by workweek. */\n isOvertimeEligible: boolean\n /**\n * The single, form-wide overtime-mode flag. `false` renders one flat\n * column per line with Overtime/Double-overtime rows hidden; `true`\n * splits hours and overtime-affecting earnings into per-workweek columns\n * (for overtime-eligible employees on a multi-workweek payroll) and\n * un-hides those rows. Starts `true` when the employee already has real\n * overtime hours or matching per-workweek breakdowns (see\n * `hasExistingOvertimeHours`, `hasBreakdownsMatchingWorkweeks`), or after\n * `actions.addOvertime` is called; otherwise starts `false`.\n */\n withOvertime: boolean\n /** Whether the employee has a direct-deposit bank account set up. */\n hasDirectDepositSetup: boolean\n /**\n * Committed reimbursement rows to render in a table, present only when\n * reimbursement controls are exposed. Seeded from the employee's existing\n * reimbursements and appended to as drafts are saved. Remove a row via\n * `actions.removeReimbursement(row.index)`.\n */\n reimbursements?: ReimbursementRow[]\n }\n /** Submission status. `mode` is always `'update'` since the payroll already exists. */\n status: { isPending: boolean; mode: 'update' }\n /** Form actions. */\n actions: {\n /** Validates and submits the form, resolving to the updated prepared payroll on success or `undefined` when validation blocked the submit. */\n onSubmit: () => Promise<HookSubmitResult<PayrollPrepared> | undefined>\n /**\n * Sets `data.withOvertime` to `true`, switching the whole form to the\n * workweek split: un-hides Overtime/Double-overtime rows and splits hours\n * and overtime-affecting earnings into per-workweek columns. Populates\n * only the first workweek cell of each line with that line's current\n * total, leaving every other cell blank — no auto distribution — so the\n * per-row validation then requires the user to fill in the rest. One\n * affordance for the whole employee, not one per job. One-directional —\n * there's no corresponding \"remove overtime\" action.\n */\n addOvertime: () => void\n /** Reveals the draft reimbursement row. Present only when reimbursement controls are exposed. */\n beginAddReimbursement?: () => void\n /** Validates the draft and commits it to the reimbursement list, or flags the draft amount if invalid. Present only when reimbursement controls are exposed. */\n saveReimbursement?: () => void\n /** Discards the draft reimbursement row. Present only when reimbursement controls are exposed. */\n cancelReimbursement?: () => void\n /** Removes the committed reimbursement row at `index` (zeroing existing rows so the update clears them). Present only when reimbursement controls are exposed. */\n removeReimbursement?: (index: number) => void\n }\n /** Form internals plus the reimbursement draft state. */\n form: BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n >['form'] & {\n /** Draft reimbursement state, present only when reimbursement controls are exposed. */\n reimbursementDraft?: { isAdding: boolean }\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayrollEditEmployeeForm}. Loading\n * branch carries only `errorHandling`; ready branch carries form data, fields,\n * status, and actions.\n *\n * @public\n */\nexport type UsePayrollEditEmployeeFormResult = HookLoadingResult | UsePayrollEditEmployeeFormReady\n\n/**\n * Headless form hook for editing a single employee's compensation within a\n * payroll run, built for regular-rate-of-pay (RRoP) support.\n *\n * @remarks\n * Prepares the payroll for the target employee, then exposes a workweek-keyed\n * form whose submit builds a `PayrollUpdate`. Single-workweek pay periods send\n * totals without `breakdowns`; multi-workweek pay periods send `breakdowns` per\n * line once that line's every workweek cell is filled. Overtime-eligible\n * (nonexempt) employees split hours and overtime-affecting earnings per\n * workweek while the single `data.withOvertime` flag is on (see\n * `actions.addOvertime`); everyone else, and every line while `withOvertime` is\n * off, edits flat totals.\n *\n * @param props - Hook options.\n * @returns A loading result while data is fetching, or a ready result with data,\n * fields, status, actions, and error handling.\n * @public\n */\nexport function usePayrollEditEmployeeForm({\n employeeId,\n companyId,\n payrollId,\n withReimbursements = true,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n errorMessages,\n}: UsePayrollEditEmployeeFormProps): UsePayrollEditEmployeeFormResult {\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const { data: earningTypesData } = useEarningTypesListSuspense({ companyId })\n\n const queryClient = useQueryClient()\n const { mutateAsync: preparePayroll } = usePayrollsPrepareMutation()\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const [prepareError, setPrepareError] = useState<Error | null>(null)\n const hasFiredRef = useRef(false)\n\n const executePrepare = useCallback(async () => {\n setPrepareError(null)\n try {\n const result = await retryAsync(\n () =>\n preparePayroll({\n request: { companyId, payrollId, requestBody: { employeeUuids: [employeeId] } },\n }),\n {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n },\n )\n setPreparedPayroll(result.payrollPrepared)\n } catch (error) {\n setPrepareError(error as Error)\n }\n }, [companyId, payrollId, employeeId, preparePayroll])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void executePrepare()\n }, [executePrepare])\n\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid ?? '' },\n { enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid },\n )\n\n const employee = employeeData.employee\n const employeeCompensation = preparedPayroll?.employeeCompensations?.at(0)\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const hasDirectDepositSetup = (bankAccountsList.employeeBankAccounts?.length ?? 0) > 0\n\n // Only normalize once the payroll is prepared: normalizeWorkweeks throws on a\n // payroll with neither workweeks nor a pay period, and before prepare resolves\n // both are legitimately absent (still loading, not malformed).\n const workweeks = useMemo(\n () =>\n preparedPayroll\n ? normalizeWorkweeks(preparedPayroll.workweeks, preparedPayroll.payPeriod)\n : [],\n [preparedPayroll],\n )\n\n const overtimeEarningNames = useMemo(\n () => collectOvertimeEarningNames(earningTypesData.earningTypeList),\n [earningTypesData.earningTypeList],\n )\n\n // Source of truth for the employee's FLSA status: prefer the prepared\n // compensation's hourly lines (the same data the fields are built from, so the\n // gate and the rendered lines always agree), falling back to the employee's\n // primary-job compensation. Unknown status is treated as not overtime-eligible.\n const flsaStatus = useMemo(() => {\n const fromCompensation = employeeCompensation?.hourlyCompensations?.find(\n compensation => compensation.flsaStatus,\n )?.flsaStatus\n if (fromCompensation) return fromCompensation\n const primaryJob = employee?.jobs?.find(job => job.primary)\n return primaryJob?.compensations?.[0]?.flsaStatus\n }, [employeeCompensation, employee])\n const isOvertimeEligible = isOvertimeEligibleFlsaStatus(flsaStatus)\n\n // Starts on when the employee already has real overtime hours, or already has\n // per-workweek breakdowns matching the current pay period's workweeks (nothing\n // to hide either way), otherwise starts off until the user opts in via\n // `actions.addOvertime`. One-directional: there's no \"remove overtime\" action.\n const [withOvertimeSetByUser, setWithOvertimeSetByUser] = useState(false)\n const withOvertime =\n withOvertimeSetByUser ||\n hasExistingOvertimeHours(employeeCompensation?.hourlyCompensations) ||\n hasBreakdownsMatchingWorkweeks(employeeCompensation?.hourlyCompensations, workweeks)\n\n const primaryJobUuid = useMemo(() => employee?.jobs?.find(job => job.primary)?.uuid, [employee])\n\n // Seed a blank input for every payroll fixed-compensation type (like the stable\n // editor), then let the field/defaults builders split them into additional\n // earnings vs `overtimeExcludedEarnings` by overtime inclusion. Without this, an employee whose\n // prepared payroll carries no fixed compensations shows no earnings inputs.\n const resolvedFixedCompensations = useMemo(\n () =>\n resolveEditableFixedCompensations(\n employeeCompensation?.fixedCompensations,\n preparedPayroll?.fixedCompensationTypes,\n primaryJobUuid,\n flsaStatus,\n ),\n [employeeCompensation, preparedPayroll?.fixedCompensationTypes, primaryJobUuid, flsaStatus],\n )\n\n const jobTitlesByUuid = useMemo(() => {\n const titles = new Map<string, string>()\n for (const job of employee?.jobs ?? []) {\n if (job.uuid && job.title) titles.set(job.uuid, job.title)\n }\n return titles\n }, [employee])\n\n // Accrual balance per time-off policy, owned by the hook (rather than looked\n // up in the consumer) so the time-off field can render its own live remaining\n // balance.\n const timeOffAccrualByName = useMemo(() => {\n const balances = new Map<string, string>()\n for (const policy of employee?.eligiblePaidTimeOff ?? []) {\n if (policy.name && policy.accrualBalance != null) {\n balances.set(policy.name, policy.accrualBalance)\n }\n }\n return balances\n }, [employee])\n\n const schema = useMemo(() => createPayrollEditEmployeeSchema(), [])\n\n const resolvedDefaults = useMemo(\n () =>\n derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ),\n [\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ],\n )\n\n const formMethods = useForm<PayrollEditEmployeeFormData, unknown, PayrollEditEmployeeFormOutputs>(\n {\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n },\n )\n\n // Watched so each `Fields.timeOff[i].remaining` stays live as the user edits\n // hours. The whole form re-renders on keystroke regardless of who owns this\n // watch, so there's no cost to owning it here rather than in a per-row\n // subcomponent.\n const watchedTimeOff = useWatch({ control: formMethods.control, name: 'timeOff' })\n\n // Off-cycle payrolls write reimbursements via the legacy fixed-compensation path\n // (the itemized array is rejected server-side), so itemized reimbursement controls\n // are exposed only for regular payrolls and only when the partner opts in.\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n const showReimbursements = withReimbursements && usesItemizedReimbursements\n\n const {\n fields: reimbursementArrayFields,\n append: appendReimbursement,\n remove: removeReimbursementRow,\n update: updateReimbursementRow,\n } = useFieldArray({\n control: formMethods.control,\n name: 'reimbursements',\n })\n\n const [isAddingReimbursement, setIsAddingReimbursement] = useState(false)\n\n const reimbursementDraftFields = useMemo<ReimbursementDraftFields>(\n () => createReimbursementDraftFields(errorMessages),\n [errorMessages],\n )\n\n // Committed rows for the consumer's table. A removed existing row (one with a\n // uuid) is zeroed rather than dropped so the update still clears it server-side;\n // those zero-amount rows are filtered out of the visible list but remain in the\n // form array for submit.\n const reimbursementRows = useMemo<ReimbursementRow[]>(\n () =>\n reimbursementArrayFields\n .map((field, index) => ({\n key: field.id,\n index,\n uuid: field.uuid ?? undefined,\n description: field.description,\n amount: field.amount,\n recurring: field.recurring ?? false,\n }))\n .filter(row => parseFloat(row.amount || '0') !== 0),\n [reimbursementArrayFields],\n )\n\n const beginAddReimbursement = useCallback(() => {\n setIsAddingReimbursement(true)\n }, [])\n\n const cancelReimbursement = useCallback(() => {\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [formMethods])\n\n const saveReimbursement = useCallback(() => {\n const draft = formMethods.getValues('reimbursementDraft')\n const result = reimbursementDraftSchema.safeParse(draft)\n if (!result.success) {\n // The error code is a fallback; the field renders the consumer-supplied\n // `errorMessage` prop when present (see useField), so the copy is theirs to set.\n formMethods.setError('reimbursementDraft.amount', {\n message: PayrollEditEmployeeErrorCodes.REIMBURSEMENT_AMOUNT,\n })\n return\n }\n appendReimbursement({\n uuid: null,\n description: result.data.description.trim(),\n amount: parseFloat(result.data.amount).toFixed(2),\n recurring: false,\n })\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [appendReimbursement, formMethods])\n\n const removeReimbursement = useCallback(\n (index: number) => {\n const field = reimbursementArrayFields[index]\n if (!field) return\n if (field.uuid) {\n updateReimbursementRow(index, { ...field, amount: '0' })\n } else {\n removeReimbursementRow(index)\n }\n },\n [reimbursementArrayFields, removeReimbursementRow, updateReimbursementRow],\n )\n\n const fields = useMemo(\n () =>\n createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations: resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n }),\n [\n employeeCompensation,\n resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n ],\n )\n\n // Overlay the live remaining balance onto each time-off entry every render, so\n // it tracks the watched entered values without rebuilding (and remounting) the\n // bound field components the `fields` memo owns.\n const timeOffFields = useMemo(\n () =>\n fields.timeOff.map(entry => ({\n ...entry,\n remaining: computeTimeOffRemaining(\n timeOffAccrualByName.get(entry.name),\n watchedTimeOff[entry.name],\n ),\n })),\n [fields.timeOff, timeOffAccrualByName, watchedTimeOff],\n )\n\n // Re-derives with `withOvertime` forced `true` and pushes the result straight\n // into the form: every line's first workweek cell gets that line's current\n // total, every other cell is left blank (never auto-distributed — see\n // `derivePayrollEditEmployeeDefaults`/`buildWeekMap`). The per-row validation\n // then requires the user to fill in the rest before they can submit.\n // `setValue` (not `resetField`) is used so this overwrites even a value the\n // user already typed into the collapsed input. Plain function (not memoized):\n // it only runs on a user click, and its inputs are recomputed each render, so\n // a `useCallback` here would never actually hold a stable reference.\n const addOvertime = () => {\n setWithOvertimeSetByUser(true)\n const revealedDefaults = derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n true,\n resolvedFixedCompensations,\n )\n // Keep the user's edited collapsed value on the first workweek cell rather\n // than the seeded API total.\n const firstWeekStart = workweeks[0]?.startDate ?? ''\n const currentValues = formMethods.getValues()\n const overlayLiveFirstWeek = (\n revealed: PayrollEditEmployeeFormData['hours'],\n live: PayrollEditEmployeeFormData['hours'] | undefined,\n ) => {\n for (const [jobUuid, names] of Object.entries(revealed)) {\n for (const [name, weekMap] of Object.entries(names)) {\n const liveValue = live?.[jobUuid]?.[name]?.[firstWeekStart]\n if (liveValue !== undefined) weekMap[firstWeekStart] = liveValue\n }\n }\n return revealed\n }\n // `shouldDirty` so the form's `values`-prop reset (triggered by flipping\n // `withOvertimeSetByUser`) keeps these via `keepDirtyValues`.\n formMethods.setValue(\n 'hours',\n overlayLiveFirstWeek(revealedDefaults.hours, currentValues.hours),\n { shouldDirty: true },\n )\n formMethods.setValue(\n 'overtimeIncludedEarnings',\n overlayLiveFirstWeek(\n revealedDefaults.overtimeIncludedEarnings,\n currentValues.overtimeIncludedEarnings,\n ),\n { shouldDirty: true },\n )\n }\n const fieldsMetadata = useMemo<PayrollEditEmployeeFieldsMetadata>(\n () => ({\n paymentMethod: withOptions(\n { name: 'paymentMethod' },\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n ),\n }),\n [],\n )\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayrollEditEmployeeForm')\n\n const prepareQuerySource: QueryWithRefetch = {\n error: prepareError,\n refetch: (() => executePrepare()) as unknown as QueryWithRefetch['refetch'],\n }\n\n const errorHandling = composeErrorHandler([prepareQuerySource, payScheduleQuery], {\n submitError,\n setSubmitError,\n })\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const onSubmit = async (): Promise<HookSubmitResult<PayrollPrepared> | undefined> => {\n let submitResult: HookSubmitResult<PayrollPrepared> | undefined\n\n // A workweek input that loaded with a value and was cleared by the user\n // submits an explicit `0` for that cell. Writing the `0` into form state\n // before validation lets the existing per-row check and submit builder run\n // unchanged: the cell is now filled rather than blank. Cells that were blank\n // at load stay blank (and keep validating as required in a touched row).\n const cleared = zeroFillClearedWorkweekCells(formMethods.getValues(), resolvedDefaults)\n if (cleared.hours) {\n formMethods.setValue('hours', cleared.hours, { shouldDirty: true })\n }\n if (cleared.overtimeIncludedEarnings) {\n formMethods.setValue('overtimeIncludedEarnings', cleared.overtimeIncludedEarnings, {\n shouldDirty: true,\n })\n }\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async data => {\n await baseSubmitHandler(data, async payload => {\n const compensation = buildPayrollUpdateEmployeeCompensation(\n payload,\n employeeCompensation,\n workweeks,\n payrollCategory,\n isOvertimeEligible,\n withOvertime,\n )\n\n const response = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: { employeeCompensations: [compensation] },\n },\n })\n\n const updated = response.payrollPrepared\n if (!updated) {\n throw new SDKInternalError('Payroll update did not return a prepared payroll')\n }\n\n setPreparedPayroll(updated)\n\n // The payroll configuration surface caches its prepared payroll under a hand-written\n // key, which the global SDK auto-invalidation (namespaced to @gusto/embedded-api\n // queries only) does not touch. Invalidate it explicitly so configuration reflects\n // this edit without a manual refresh.\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n submitResult = { mode: 'update', data: updated }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n if (!preparedPayroll || !employee) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n employee,\n employeeCompensation,\n preparedPayroll,\n paySchedule: payScheduleQuery.data?.payScheduleShow,\n isMultipleWorkweeks: workweeks.length > 1,\n workweeks,\n isOvertimeEligible,\n withOvertime,\n hasDirectDepositSetup,\n ...(showReimbursements ? { reimbursements: reimbursementRows } : {}),\n },\n status: { isPending, mode: 'update' as const },\n actions: {\n onSubmit,\n addOvertime,\n ...(showReimbursements\n ? {\n beginAddReimbursement,\n saveReimbursement,\n cancelReimbursement,\n removeReimbursement,\n }\n : {}),\n },\n errorHandling,\n form: {\n Fields: {\n ...fields,\n timeOff: timeOffFields,\n reimbursementDraft: showReimbursements ? reimbursementDraftFields : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n ...(showReimbursements ? { reimbursementDraft: { isAdding: isAddingReimbursement } } : {}),\n },\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","issue","usePayrollEditEmployeeForm","employeeId","companyId","payrollId","withReimbursements","validationMode","shouldFocusError","errorMessages","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","earningTypesData","useEarningTypesListSuspense","queryClient","useQueryClient","preparePayroll","usePayrollsPrepareMutation","updatePayroll","isPending","usePayrollsUpdateMutation","preparedPayroll","setPreparedPayroll","useState","prepareError","setPrepareError","hasFiredRef","useRef","executePrepare","useCallback","result","retryAsync","useEffect","payScheduleQuery","usePaySchedulesGet","employee","employeeCompensation","payrollCategory","derivePayrollCategory","hasDirectDepositSetup","workweeks","useMemo","normalizeWorkweeks","overtimeEarningNames","collectOvertimeEarningNames","flsaStatus","fromCompensation","compensation","job","isOvertimeEligible","isOvertimeEligibleFlsaStatus","withOvertimeSetByUser","setWithOvertimeSetByUser","withOvertime","hasExistingOvertimeHours","hasBreakdownsMatchingWorkweeks","primaryJobUuid","resolvedFixedCompensations","resolveEditableFixedCompensations","jobTitlesByUuid","titles","timeOffAccrualByName","balances","policy","schema","createPayrollEditEmployeeSchema","resolvedDefaults","derivePayrollEditEmployeeDefaults","formMethods","useForm","zodResolver","watchedTimeOff","useWatch","usesItemizedReimbursements","isOffCyclePayroll","showReimbursements","reimbursementArrayFields","appendReimbursement","removeReimbursementRow","updateReimbursementRow","useFieldArray","isAddingReimbursement","setIsAddingReimbursement","reimbursementDraftFields","createReimbursementDraftFields","reimbursementRows","field","index","row","beginAddReimbursement","cancelReimbursement","saveReimbursement","draft","reimbursementDraftSchema","PayrollEditEmployeeErrorCodes","removeReimbursement","fields","createPayrollEditEmployeeFields","timeOffFields","entry","computeTimeOffRemaining","addOvertime","revealedDefaults","firstWeekStart","currentValues","overlayLiveFirstWeek","revealed","live","jobUuid","names","name","weekMap","liveValue","fieldsMetadata","withOptions","PAYMENT_METHOD_OPTIONS","PAYMENT_METHOD_VALUES","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","hookFormInternals","useHookFormInternals","onSubmit","submitResult","cleared","zeroFillClearedWorkweekCells","resolve","data","payload","buildPayrollUpdateEmployeeCompensation","updated","SDKInternalError","PREPARE_QUERY_KEY","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAMA,KAAuB,GACvBC,KAAyB,MAEzBC,KAA+B,CAACC,MACpCA,aAAiBC,MACjBD,EAAM,OAAO,KAAK,CAAAE,MAASA,EAAM,aAAa,mBAAmB;AAuK5D,SAASC,GAA2B;AAAA,EACzC,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AAAA,EACnB,eAAAC;AACF,GAAsE;AACpE,QAAM,EAAE,MAAMC,EAAA,IAAiBC,GAAwB,EAAE,YAAAR,GAAY,GAC/D,EAAE,MAAMS,GAAA,IAAqBC,GAAiD;AAAA,IAClF,YAAAV;AAAA,EAAA,CACD,GACK,EAAE,MAAMW,EAAA,IAAqBC,GAA4B,EAAE,WAAAX,GAAW,GAEtEY,KAAcC,GAAA,GACd,EAAE,aAAaC,EAAA,IAAmBC,GAAA,GAClC,EAAE,aAAaC,IAAe,WAAAC,GAAA,IAAcC,GAAA,GAE5C,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxC,CAACC,IAAc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Ba,GAA8BpE,GAAaJ,CAAM;AAAA,MAC1E,GAAIW,IAAqB,EAAE,oBAAoB,EAAE,UAAUM,GAAA,EAAsB,IAAM,CAAA;AAAA,IAAC;AAAA,EAC1F;AAEJ;"}
1
+ {"version":3,"file":"usePayrollEditEmployeeForm.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { useFieldArray, useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { useEarningTypesListSuspense } from '@gusto/embedded-api/react-query/earningTypesList'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport {\n createPayrollEditEmployeeSchema,\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n PayrollEditEmployeeErrorCodes,\n reimbursementDraftSchema,\n type PayrollEditEmployeeFormData,\n type PayrollEditEmployeeFormOutputs,\n} from './payrollEditEmployeeSchema'\nimport {\n buildPayrollUpdateEmployeeCompensation,\n collectOvertimeEarningNames,\n derivePayrollEditEmployeeDefaults,\n hasBreakdownsMatchingWorkweeks,\n hasExistingOvertimeHours,\n normalizeWorkweeks,\n resolveEditableFixedCompensations,\n zeroFillClearedWorkweekCells,\n type NormalizedWorkweek,\n} from './payrollEditEmployeeHelpers'\nimport {\n computeTimeOffRemaining,\n createPayrollEditEmployeeFields,\n createReimbursementDraftFields,\n type PayrollEditEmployeeErrorMessages,\n type PayrollEditEmployeeFields,\n type ReimbursementDraftFields,\n type ReimbursementRow,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport {\n derivePayrollCategory,\n isOffCyclePayroll,\n PayrollCategory,\n} from '@/components/Payroll/payrollTypes'\nimport { PREPARE_QUERY_KEY } from '@/components/Payroll/PayrollConfiguration/usePayrollConfigurationData'\nimport { isOvertimeEligibleFlsaStatus } from '@/components/Payroll/helpers'\nimport { retryAsync } from '@/helpers/retryAsync'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport {\n composeErrorHandler,\n type QueryWithRefetch,\n} from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldMetadataWithOptions,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean =>\n error instanceof UnprocessableEntityError &&\n error.errors.some(issue => issue.category === 'invalid_operation')\n\n/**\n * Options accepted by {@link usePayrollEditEmployeeForm}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormProps {\n /** The associated employee identifier. */\n employeeId: string\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /**\n * Whether to expose reimbursement controls (`form.Fields.reimbursements`,\n * `actions.addReimbursement`/`removeReimbursement`, `form.reimbursements`).\n * Defaults to `true`. Controls are omitted for off-cycle payrolls regardless,\n * since those write reimbursements via the legacy fixed-compensation path.\n */\n withReimbursements?: boolean\n /** When validation runs. Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Defaults to `true`. Set to `false` when composing with other forms. */\n shouldFocusError?: boolean\n /**\n * Display copy for each validation error code, baked into every bound field so\n * it resolves and renders its own message. Supply it once, keyed by\n * {@link PayrollEditEmployeeErrorCodes}; a missing code falls back to the raw\n * code. Omit it to render raw codes.\n */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * Field metadata for {@link usePayrollEditEmployeeForm}, keyed by full form path.\n *\n * @remarks\n * Keys are minted from the prepared payroll's compensations at runtime\n * (`hours.${jobUuid}.${name}.${workweekStart}` and similar), so neither the key\n * set nor which entries carry options is known ahead of time.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldsMetadata = Record<\n string,\n FieldMetadata | FieldMetadataWithOptions\n>\n\n/**\n * Ready-state return value of {@link usePayrollEditEmployeeForm} — the\n * `isLoading: false` branch of {@link UsePayrollEditEmployeeFormResult}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormReady extends BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n> {\n /** Loaded entities backing the editor. */\n data: {\n /** The employee being edited. */\n employee: Employee\n /** The employee's prepared compensation for this payroll, if present. */\n employeeCompensation?: PayrollEmployeeCompensationsType\n /** The prepared payroll (server-calculated totals and workweeks). */\n preparedPayroll: PayrollPrepared\n /** The pay schedule for the payroll, if loaded. */\n paySchedule?: PayScheduleShow\n /** Whether the pay period spans more than one workweek. Raw workweeks are on `preparedPayroll.workweeks`. */\n isMultipleWorkweeks: boolean\n /**\n * The pay period's normalized workweeks (`{ startDate, endDate }` strings),\n * in order — one entry, spanning the pay period, when it's a single\n * workweek. The per-workweek split fields are keyed by start date only, so\n * this is the source for each column's date range.\n */\n workweeks: NormalizedWorkweek[]\n /** Whether the employee is overtime-eligible (nonexempt family). Drives whether hours split by workweek. */\n isOvertimeEligible: boolean\n /**\n * The single, form-wide overtime-mode flag. `false` renders one flat\n * column per line with Overtime/Double-overtime rows hidden; `true`\n * splits hours and overtime-affecting earnings into per-workweek columns\n * (for overtime-eligible employees on a multi-workweek payroll) and\n * un-hides those rows. Starts `true` when the employee already has real\n * overtime hours or matching per-workweek breakdowns (see\n * `hasExistingOvertimeHours`, `hasBreakdownsMatchingWorkweeks`), or after\n * `actions.addOvertime` is called; otherwise starts `false`.\n */\n withOvertime: boolean\n /** Whether the employee has a direct-deposit bank account set up. */\n hasDirectDepositSetup: boolean\n /**\n * Committed reimbursement rows to render in a table, present only when\n * reimbursement controls are exposed. Seeded from the employee's existing\n * reimbursements and appended to as drafts are saved. Remove a row via\n * `actions.removeReimbursement(row.index)`.\n */\n reimbursements?: ReimbursementRow[]\n }\n /** Submission status. `mode` is always `'update'` since the payroll already exists. */\n status: { isPending: boolean; mode: 'update' }\n /** Form actions. */\n actions: {\n /** Validates and submits the form, resolving to the updated prepared payroll on success or `undefined` when validation blocked the submit. */\n onSubmit: () => Promise<HookSubmitResult<PayrollPrepared> | undefined>\n /**\n * Sets `data.withOvertime` to `true`, switching the whole form to the\n * workweek split: un-hides Overtime/Double-overtime rows and splits hours\n * and overtime-affecting earnings into per-workweek columns. Populates\n * only the first workweek cell of each line with that line's current\n * total, leaving every other cell blank — no auto distribution — so the\n * per-row validation then requires the user to fill in the rest. One\n * affordance for the whole employee, not one per job. One-directional —\n * there's no corresponding \"remove overtime\" action.\n */\n addOvertime: () => void\n /** Reveals the draft reimbursement row. Present only when reimbursement controls are exposed. */\n beginAddReimbursement?: () => void\n /** Validates the draft and commits it to the reimbursement list, or flags the draft amount if invalid. Present only when reimbursement controls are exposed. */\n saveReimbursement?: () => void\n /** Discards the draft reimbursement row. Present only when reimbursement controls are exposed. */\n cancelReimbursement?: () => void\n /** Removes the committed reimbursement row at `index` (zeroing existing rows so the update clears them). Present only when reimbursement controls are exposed. */\n removeReimbursement?: (index: number) => void\n }\n /** Form internals plus the reimbursement draft state. */\n form: BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n >['form'] & {\n /** Draft reimbursement state, present only when reimbursement controls are exposed. */\n reimbursementDraft?: { isAdding: boolean }\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayrollEditEmployeeForm}. Loading\n * branch carries only `errorHandling`; ready branch carries form data, fields,\n * status, and actions.\n *\n * @public\n */\nexport type UsePayrollEditEmployeeFormResult = HookLoadingResult | UsePayrollEditEmployeeFormReady\n\n/**\n * Headless form hook for editing a single employee's compensation within a\n * payroll run, built for regular-rate-of-pay (RRoP) support.\n *\n * @remarks\n * Prepares the payroll for the target employee, then exposes a workweek-keyed\n * form whose submit builds a `PayrollUpdate`. Single-workweek pay periods send\n * totals without `breakdowns`; multi-workweek pay periods send `breakdowns` per\n * line once that line's every workweek cell is filled. Overtime-eligible\n * (nonexempt) employees split hours and overtime-affecting earnings per\n * workweek while the single `data.withOvertime` flag is on (see\n * `actions.addOvertime`); everyone else, and every line while `withOvertime` is\n * off, edits flat totals.\n *\n * @param props - Hook options.\n * @returns A loading result while data is fetching, or a ready result with data,\n * fields, status, actions, and error handling.\n * @public\n */\nexport function usePayrollEditEmployeeForm({\n employeeId,\n companyId,\n payrollId,\n withReimbursements = true,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n errorMessages,\n}: UsePayrollEditEmployeeFormProps): UsePayrollEditEmployeeFormResult {\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const { data: earningTypesData } = useEarningTypesListSuspense({ companyId })\n const { data: payrollData } = usePayrollsGetSuspense({ companyId, payrollId })\n const isTransitionPayroll =\n derivePayrollCategory(payrollData.payrollShow ?? {}) === PayrollCategory.Transition\n\n const queryClient = useQueryClient()\n const { mutateAsync: preparePayroll } = usePayrollsPrepareMutation()\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const [prepareError, setPrepareError] = useState<Error | null>(null)\n const hasFiredRef = useRef(false)\n\n const executePrepare = useCallback(async () => {\n setPrepareError(null)\n try {\n const result = await retryAsync(\n () =>\n preparePayroll({\n request: {\n companyId,\n payrollId,\n requestBody: { employeeUuids: isTransitionPayroll ? undefined : [employeeId] },\n },\n }),\n {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n },\n )\n setPreparedPayroll(result.payrollPrepared)\n } catch (error) {\n setPrepareError(error as Error)\n }\n }, [companyId, payrollId, employeeId, preparePayroll, isTransitionPayroll])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void executePrepare()\n }, [executePrepare])\n\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid ?? '' },\n { enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid },\n )\n\n const employee = employeeData.employee\n const employeeCompensation = preparedPayroll?.employeeCompensations?.find(\n comp => comp.employeeUuid === employeeId,\n )\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const hasDirectDepositSetup = (bankAccountsList.employeeBankAccounts?.length ?? 0) > 0\n\n // Only normalize once the payroll is prepared: normalizeWorkweeks throws on a\n // payroll with neither workweeks nor a pay period, and before prepare resolves\n // both are legitimately absent (still loading, not malformed).\n const workweeks = useMemo(\n () =>\n preparedPayroll\n ? normalizeWorkweeks(preparedPayroll.workweeks, preparedPayroll.payPeriod)\n : [],\n [preparedPayroll],\n )\n\n const overtimeEarningNames = useMemo(\n () => collectOvertimeEarningNames(earningTypesData.earningTypeList),\n [earningTypesData.earningTypeList],\n )\n\n // Source of truth for the employee's FLSA status: prefer the prepared\n // compensation's hourly lines (the same data the fields are built from, so the\n // gate and the rendered lines always agree), falling back to the employee's\n // primary-job compensation. Unknown status is treated as not overtime-eligible.\n const flsaStatus = useMemo(() => {\n const fromCompensation = employeeCompensation?.hourlyCompensations?.find(\n compensation => compensation.flsaStatus,\n )?.flsaStatus\n if (fromCompensation) return fromCompensation\n const primaryJob = employee?.jobs?.find(job => job.primary)\n return primaryJob?.compensations?.[0]?.flsaStatus\n }, [employeeCompensation, employee])\n const isOvertimeEligible = isOvertimeEligibleFlsaStatus(flsaStatus)\n\n // Starts on when the employee already has real overtime hours, or already has\n // per-workweek breakdowns matching the current pay period's workweeks (nothing\n // to hide either way), otherwise starts off until the user opts in via\n // `actions.addOvertime`. One-directional: there's no \"remove overtime\" action.\n const [withOvertimeSetByUser, setWithOvertimeSetByUser] = useState(false)\n const withOvertime =\n withOvertimeSetByUser ||\n hasExistingOvertimeHours(employeeCompensation?.hourlyCompensations) ||\n hasBreakdownsMatchingWorkweeks(employeeCompensation?.hourlyCompensations, workweeks)\n\n const primaryJobUuid = useMemo(() => employee?.jobs?.find(job => job.primary)?.uuid, [employee])\n\n // Seed a blank input for every payroll fixed-compensation type (like the stable\n // editor), then let the field/defaults builders split them into additional\n // earnings vs `overtimeExcludedEarnings` by overtime inclusion. Without this, an employee whose\n // prepared payroll carries no fixed compensations shows no earnings inputs.\n const resolvedFixedCompensations = useMemo(\n () =>\n resolveEditableFixedCompensations(\n employeeCompensation?.fixedCompensations,\n preparedPayroll?.fixedCompensationTypes,\n primaryJobUuid,\n flsaStatus,\n ),\n [employeeCompensation, preparedPayroll?.fixedCompensationTypes, primaryJobUuid, flsaStatus],\n )\n\n const jobTitlesByUuid = useMemo(() => {\n const titles = new Map<string, string>()\n for (const job of employee?.jobs ?? []) {\n if (job.uuid && job.title) titles.set(job.uuid, job.title)\n }\n return titles\n }, [employee])\n\n // Accrual balance per time-off policy, owned by the hook (rather than looked\n // up in the consumer) so the time-off field can render its own live remaining\n // balance.\n const timeOffAccrualByName = useMemo(() => {\n const balances = new Map<string, string>()\n for (const policy of employee?.eligiblePaidTimeOff ?? []) {\n if (policy.name && policy.accrualBalance != null) {\n balances.set(policy.name, policy.accrualBalance)\n }\n }\n return balances\n }, [employee])\n\n const schema = useMemo(() => createPayrollEditEmployeeSchema(), [])\n\n const resolvedDefaults = useMemo(\n () =>\n derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ),\n [\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ],\n )\n\n const formMethods = useForm<PayrollEditEmployeeFormData, unknown, PayrollEditEmployeeFormOutputs>(\n {\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n },\n )\n\n // Watched so each `Fields.timeOff[i].remaining` stays live as the user edits\n // hours. The whole form re-renders on keystroke regardless of who owns this\n // watch, so there's no cost to owning it here rather than in a per-row\n // subcomponent.\n const watchedTimeOff = useWatch({ control: formMethods.control, name: 'timeOff' })\n\n // Off-cycle payrolls write reimbursements via the legacy fixed-compensation path\n // (the itemized array is rejected server-side), so itemized reimbursement controls\n // are exposed only for regular payrolls and only when the partner opts in.\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n const showReimbursements = withReimbursements && usesItemizedReimbursements\n\n const {\n fields: reimbursementArrayFields,\n append: appendReimbursement,\n remove: removeReimbursementRow,\n update: updateReimbursementRow,\n } = useFieldArray({\n control: formMethods.control,\n name: 'reimbursements',\n })\n\n const [isAddingReimbursement, setIsAddingReimbursement] = useState(false)\n\n const reimbursementDraftFields = useMemo<ReimbursementDraftFields>(\n () => createReimbursementDraftFields(errorMessages),\n [errorMessages],\n )\n\n // Committed rows for the consumer's table. A removed existing row (one with a\n // uuid) is zeroed rather than dropped so the update still clears it server-side;\n // those zero-amount rows are filtered out of the visible list but remain in the\n // form array for submit.\n const reimbursementRows = useMemo<ReimbursementRow[]>(\n () =>\n reimbursementArrayFields\n .map((field, index) => ({\n key: field.id,\n index,\n uuid: field.uuid ?? undefined,\n description: field.description,\n amount: field.amount,\n recurring: field.recurring ?? false,\n }))\n .filter(row => parseFloat(row.amount || '0') !== 0),\n [reimbursementArrayFields],\n )\n\n const beginAddReimbursement = useCallback(() => {\n setIsAddingReimbursement(true)\n }, [])\n\n const cancelReimbursement = useCallback(() => {\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [formMethods])\n\n const saveReimbursement = useCallback(() => {\n const draft = formMethods.getValues('reimbursementDraft')\n const result = reimbursementDraftSchema.safeParse(draft)\n if (!result.success) {\n // The error code is a fallback; the field renders the consumer-supplied\n // `errorMessage` prop when present (see useField), so the copy is theirs to set.\n formMethods.setError('reimbursementDraft.amount', {\n message: PayrollEditEmployeeErrorCodes.REIMBURSEMENT_AMOUNT,\n })\n return\n }\n appendReimbursement({\n uuid: null,\n description: result.data.description.trim(),\n amount: parseFloat(result.data.amount).toFixed(2),\n recurring: false,\n })\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [appendReimbursement, formMethods])\n\n const removeReimbursement = useCallback(\n (index: number) => {\n const field = reimbursementArrayFields[index]\n if (!field) return\n if (field.uuid) {\n updateReimbursementRow(index, { ...field, amount: '0' })\n } else {\n removeReimbursementRow(index)\n }\n },\n [reimbursementArrayFields, removeReimbursementRow, updateReimbursementRow],\n )\n\n const fields = useMemo(\n () =>\n createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations: resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n }),\n [\n employeeCompensation,\n resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n ],\n )\n\n // Overlay the live remaining balance onto each time-off entry every render, so\n // it tracks the watched entered values without rebuilding (and remounting) the\n // bound field components the `fields` memo owns.\n const timeOffFields = useMemo(\n () =>\n fields.timeOff.map(entry => ({\n ...entry,\n remaining: computeTimeOffRemaining(\n timeOffAccrualByName.get(entry.name),\n watchedTimeOff[entry.name],\n ),\n })),\n [fields.timeOff, timeOffAccrualByName, watchedTimeOff],\n )\n\n // Re-derives with `withOvertime` forced `true` and pushes the result straight\n // into the form: every line's first workweek cell gets that line's current\n // total, every other cell is left blank (never auto-distributed — see\n // `derivePayrollEditEmployeeDefaults`/`buildWeekMap`). The per-row validation\n // then requires the user to fill in the rest before they can submit.\n // `setValue` (not `resetField`) is used so this overwrites even a value the\n // user already typed into the collapsed input. Plain function (not memoized):\n // it only runs on a user click, and its inputs are recomputed each render, so\n // a `useCallback` here would never actually hold a stable reference.\n const addOvertime = () => {\n setWithOvertimeSetByUser(true)\n const revealedDefaults = derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n true,\n resolvedFixedCompensations,\n )\n // Keep the user's edited collapsed value on the first workweek cell rather\n // than the seeded API total.\n const firstWeekStart = workweeks[0]?.startDate ?? ''\n const currentValues = formMethods.getValues()\n const overlayLiveFirstWeek = (\n revealed: PayrollEditEmployeeFormData['hours'],\n live: PayrollEditEmployeeFormData['hours'] | undefined,\n ) => {\n for (const [jobUuid, names] of Object.entries(revealed)) {\n for (const [name, weekMap] of Object.entries(names)) {\n const liveValue = live?.[jobUuid]?.[name]?.[firstWeekStart]\n if (liveValue !== undefined) weekMap[firstWeekStart] = liveValue\n }\n }\n return revealed\n }\n // `shouldDirty` so the form's `values`-prop reset (triggered by flipping\n // `withOvertimeSetByUser`) keeps these via `keepDirtyValues`.\n formMethods.setValue(\n 'hours',\n overlayLiveFirstWeek(revealedDefaults.hours, currentValues.hours),\n { shouldDirty: true },\n )\n formMethods.setValue(\n 'overtimeIncludedEarnings',\n overlayLiveFirstWeek(\n revealedDefaults.overtimeIncludedEarnings,\n currentValues.overtimeIncludedEarnings,\n ),\n { shouldDirty: true },\n )\n }\n const fieldsMetadata = useMemo<PayrollEditEmployeeFieldsMetadata>(\n () => ({\n paymentMethod: withOptions(\n { name: 'paymentMethod' },\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n ),\n }),\n [],\n )\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayrollEditEmployeeForm')\n\n const prepareQuerySource: QueryWithRefetch = {\n error: prepareError,\n refetch: (() => executePrepare()) as unknown as QueryWithRefetch['refetch'],\n }\n\n const errorHandling = composeErrorHandler([prepareQuerySource, payScheduleQuery], {\n submitError,\n setSubmitError,\n })\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const onSubmit = async (): Promise<HookSubmitResult<PayrollPrepared> | undefined> => {\n let submitResult: HookSubmitResult<PayrollPrepared> | undefined\n\n // A workweek input that loaded with a value and was cleared by the user\n // submits an explicit `0` for that cell. Writing the `0` into form state\n // before validation lets the existing per-row check and submit builder run\n // unchanged: the cell is now filled rather than blank. Cells that were blank\n // at load stay blank (and keep validating as required in a touched row).\n const cleared = zeroFillClearedWorkweekCells(formMethods.getValues(), resolvedDefaults)\n if (cleared.hours) {\n formMethods.setValue('hours', cleared.hours, { shouldDirty: true })\n }\n if (cleared.overtimeIncludedEarnings) {\n formMethods.setValue('overtimeIncludedEarnings', cleared.overtimeIncludedEarnings, {\n shouldDirty: true,\n })\n }\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async data => {\n await baseSubmitHandler(data, async payload => {\n const compensation = buildPayrollUpdateEmployeeCompensation(\n payload,\n employeeCompensation,\n workweeks,\n payrollCategory,\n isOvertimeEligible,\n withOvertime,\n )\n\n const response = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: { employeeCompensations: [compensation] },\n },\n })\n\n const updated = response.payrollPrepared\n if (!updated) {\n throw new SDKInternalError('Payroll update did not return a prepared payroll')\n }\n\n setPreparedPayroll(updated)\n\n // The payroll configuration surface caches its prepared payroll under a hand-written\n // key, which the global SDK auto-invalidation (namespaced to @gusto/embedded-api\n // queries only) does not touch. Invalidate it explicitly so configuration reflects\n // this edit without a manual refresh.\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n submitResult = { mode: 'update', data: updated }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n if (!preparedPayroll || !employee) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n employee,\n employeeCompensation,\n preparedPayroll,\n paySchedule: payScheduleQuery.data?.payScheduleShow,\n isMultipleWorkweeks: workweeks.length > 1,\n workweeks,\n isOvertimeEligible,\n withOvertime,\n hasDirectDepositSetup,\n ...(showReimbursements ? { reimbursements: reimbursementRows } : {}),\n },\n status: { isPending, mode: 'update' as const },\n actions: {\n onSubmit,\n addOvertime,\n ...(showReimbursements\n ? {\n beginAddReimbursement,\n saveReimbursement,\n cancelReimbursement,\n removeReimbursement,\n }\n : {}),\n },\n errorHandling,\n form: {\n Fields: {\n ...fields,\n timeOff: timeOffFields,\n reimbursementDraft: showReimbursements ? reimbursementDraftFields : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n ...(showReimbursements ? { reimbursementDraft: { isAdding: isAddingReimbursement } } : {}),\n },\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","issue","usePayrollEditEmployeeForm","employeeId","companyId","payrollId","withReimbursements","validationMode","shouldFocusError","errorMessages","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","earningTypesData","useEarningTypesListSuspense","payrollData","usePayrollsGetSuspense","isTransitionPayroll","derivePayrollCategory","PayrollCategory","queryClient","useQueryClient","preparePayroll","usePayrollsPrepareMutation","updatePayroll","isPending","usePayrollsUpdateMutation","preparedPayroll","setPreparedPayroll","useState","prepareError","setPrepareError","hasFiredRef","useRef","executePrepare","useCallback","result","retryAsync","useEffect","payScheduleQuery","usePaySchedulesGet","employee","employeeCompensation","comp","payrollCategory","hasDirectDepositSetup","workweeks","useMemo","normalizeWorkweeks","overtimeEarningNames","collectOvertimeEarningNames","flsaStatus","fromCompensation","compensation","job","isOvertimeEligible","isOvertimeEligibleFlsaStatus","withOvertimeSetByUser","setWithOvertimeSetByUser","withOvertime","hasExistingOvertimeHours","hasBreakdownsMatchingWorkweeks","primaryJobUuid","resolvedFixedCompensations","resolveEditableFixedCompensations","jobTitlesByUuid","titles","timeOffAccrualByName","balances","policy","schema","createPayrollEditEmployeeSchema","resolvedDefaults","derivePayrollEditEmployeeDefaults","formMethods","useForm","zodResolver","watchedTimeOff","useWatch","usesItemizedReimbursements","isOffCyclePayroll","showReimbursements","reimbursementArrayFields","appendReimbursement","removeReimbursementRow","updateReimbursementRow","useFieldArray","isAddingReimbursement","setIsAddingReimbursement","reimbursementDraftFields","createReimbursementDraftFields","reimbursementRows","field","index","row","beginAddReimbursement","cancelReimbursement","saveReimbursement","draft","reimbursementDraftSchema","PayrollEditEmployeeErrorCodes","removeReimbursement","fields","createPayrollEditEmployeeFields","timeOffFields","entry","computeTimeOffRemaining","addOvertime","revealedDefaults","firstWeekStart","currentValues","overlayLiveFirstWeek","revealed","live","jobUuid","names","name","weekMap","liveValue","fieldsMetadata","withOptions","PAYMENT_METHOD_OPTIONS","PAYMENT_METHOD_VALUES","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","hookFormInternals","useHookFormInternals","onSubmit","submitResult","cleared","zeroFillClearedWorkweekCells","resolve","data","payload","buildPayrollUpdateEmployeeCompensation","updated","SDKInternalError","PREPARE_QUERY_KEY","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAMA,KAAuB,GACvBC,KAAyB,MAEzBC,KAA+B,CAACC,MACpCA,aAAiBC,MACjBD,EAAM,OAAO,KAAK,CAAAE,MAASA,EAAM,aAAa,mBAAmB;AAuK5D,SAASC,GAA2B;AAAA,EACzC,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,KAAmB;AAAA,EACnB,eAAAC;AACF,GAAsE;AACpE,QAAM,EAAE,MAAMC,GAAA,IAAiBC,GAAwB,EAAE,YAAAR,GAAY,GAC/D,EAAE,MAAMS,GAAA,IAAqBC,GAAiD;AAAA,IAClF,YAAAV;AAAA,EAAA,CACD,GACK,EAAE,MAAMW,EAAA,IAAqBC,GAA4B,EAAE,WAAAX,GAAW,GACtE,EAAE,MAAMY,GAAA,IAAgBC,GAAuB,EAAE,WAAAb,GAAW,WAAAC,GAAW,GACvEa,IACJC,EAAsBH,GAAY,eAAe,CAAA,CAAE,MAAMI,GAAgB,YAErEC,KAAcC,GAAA,GACd,EAAE,aAAaC,EAAA,IAAmBC,GAAA,GAClC,EAAE,aAAaC,IAAe,WAAAC,GAAA,IAAcC,GAAA,GAE5C,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxC,C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oBAAoBvB,IAAqBQ,KAA2B;AAAA,MAAA;AAAA,MAEtE,gBAAA8B;AAAA,MACA,mBAAAU;AAAA,MACA,yBAAyBa,GAA8BpE,GAAaJ,CAAM;AAAA,MAC1E,GAAIW,IAAqB,EAAE,oBAAoB,EAAE,UAAUM,GAAA,EAAsB,IAAM,CAAA;AAAA,IAAC;AAAA,EAC1F;AAEJ;"}
@@ -1,85 +1,93 @@
1
1
  import { jsxs as d, jsx as r } from "react/jsx-runtime";
2
- import { useTranslation as E } from "react-i18next";
3
- import { getPayrollTypeLabel as H, calculateTotalPayroll as U, canCancelPayroll as j } from "../helpers.js";
4
- import { Flex as s } from "../../Common/Flex/Flex.js";
2
+ import { useTranslation as H } from "react-i18next";
3
+ import { getPayPeriodOrCheckDateLabel as u, getPayrollTypeLabel as U, calculateTotalPayroll as j, canCancelPayroll as O } from "../helpers.js";
4
+ import { Flex as c } from "../../Common/Flex/Flex.js";
5
5
  import { EmptyData as y } from "../../Common/EmptyData/EmptyData.js";
6
6
  import { HamburgerMenu as N } from "../../Common/HamburgerMenu/HamburgerMenu.js";
7
- import { DateRangeFilter as O } from "../../Common/DateRangeFilter/DateRangeFilter.js";
7
+ import { DateRangeFilter as I } from "../../Common/DateRangeFilter/DateRangeFilter.js";
8
8
  import { useComponentContext as V } from "../../../contexts/ComponentAdapter/useComponentContext.js";
9
9
  import { formatNumberAsCurrency as Y } from "../../../helpers/formattedStrings.js";
10
10
  import { useI18n as Z } from "../../../i18n/I18n.js";
11
11
  import { useDateFormatter as $ } from "../../../hooks/useDateFormatter.js";
12
12
  import q from "../../../assets/icons/trashcan.svg.js";
13
13
  import B from "../../../assets/icons/icon-file-outline.svg.js";
14
- import I from "../../../assets/icons/icon-receipt-outline.svg.js";
15
- import { PayrollStatusBadges as W } from "../PayrollStatusBadges/PayrollStatusBadges.js";
16
- import { DataView as _ } from "../../Common/DataView/DataView.js";
17
- const ce = ({
18
- className: u,
19
- payrollHistory: D,
20
- wireInRequests: f,
21
- pagination: c,
22
- onViewSummary: h,
23
- onViewReceipt: P,
24
- onCancelPayroll: C,
14
+ import W from "../../../assets/icons/icon-receipt-outline.svg.js";
15
+ import { PayrollStatusBadges as _ } from "../PayrollStatusBadges/PayrollStatusBadges.js";
16
+ import { DataView as z } from "../../Common/DataView/DataView.js";
17
+ const me = ({
18
+ className: D,
19
+ payrollHistory: f,
20
+ wireInRequests: h,
21
+ pagination: s,
22
+ onViewSummary: P,
23
+ onViewReceipt: C,
24
+ onCancelPayroll: b,
25
25
  cancelDialogItem: a,
26
26
  onCancelDialogOpen: S,
27
- onCancelDialogClose: b,
28
- isLoading: g = !1,
27
+ onCancelDialogClose: g,
28
+ isLoading: F = !1,
29
29
  dateRangeFilter: o
30
30
  }) => {
31
- const { Heading: F, Text: m, Dialog: w } = V();
31
+ const { Heading: L, Text: m, Dialog: v } = V();
32
32
  Z("Payroll.PayrollHistory");
33
- const { t: e } = E("Payroll.PayrollHistory"), l = $(), L = (t) => {
34
- const n = t.payrollDeadline;
35
- if (!n) return "";
36
- const i = new Date(n), p = "America/New_York", v = new Intl.DateTimeFormat("en-US", {
33
+ const { t: e } = H("Payroll.PayrollHistory"), l = $(), w = (t) => {
34
+ const i = t.payrollDeadline;
35
+ if (!i) return "";
36
+ const n = new Date(i), p = "America/New_York", T = new Intl.DateTimeFormat("en-US", {
37
37
  weekday: "short",
38
38
  month: "short",
39
39
  day: "numeric",
40
40
  timeZone: p
41
- }), T = new Intl.DateTimeFormat("en-US", {
41
+ }), M = new Intl.DateTimeFormat("en-US", {
42
42
  hour: "numeric",
43
43
  minute: "2-digit",
44
44
  timeZoneName: "short",
45
45
  timeZone: p
46
- }), M = v.format(i);
47
- return `${T.format(i)} on ${M}`;
46
+ }), E = T.format(n);
47
+ return `${M.format(n)} on ${E}`;
48
48
  }, x = (t) => {
49
49
  S(t);
50
50
  }, k = () => {
51
- a && C(a);
51
+ a && b(a);
52
52
  }, A = (t) => {
53
- const n = t.payrollUuid || t.uuid, i = [
53
+ const i = t.payrollUuid || t.uuid, n = [
54
54
  {
55
55
  label: e("menu.viewSummary"),
56
56
  icon: /* @__PURE__ */ r(B, { "aria-hidden": !0 }),
57
57
  onClick: () => {
58
- h(n, t.payPeriod?.startDate, t.payPeriod?.endDate);
58
+ P(
59
+ i,
60
+ t.payPeriod?.startDate ?? void 0,
61
+ t.payPeriod?.endDate ?? void 0
62
+ );
59
63
  }
60
64
  },
61
65
  {
62
66
  label: e("menu.viewReceipt"),
63
- icon: /* @__PURE__ */ r(I, { "aria-hidden": !0 }),
67
+ icon: /* @__PURE__ */ r(W, { "aria-hidden": !0 }),
64
68
  onClick: () => {
65
- P(n, t.payPeriod?.startDate, t.payPeriod?.endDate);
69
+ C(
70
+ i,
71
+ t.payPeriod?.startDate ?? void 0,
72
+ t.payPeriod?.endDate ?? void 0
73
+ );
66
74
  }
67
75
  }
68
76
  ];
69
- return j(t) && i.push({
77
+ return O(t) && n.push({
70
78
  label: e("menu.cancelPayroll"),
71
79
  icon: /* @__PURE__ */ r(q, { "aria-hidden": !0 }),
72
80
  onClick: () => {
73
81
  x(t);
74
82
  },
75
83
  "data-destructive": "true"
76
- }), i;
84
+ }), n;
77
85
  };
78
- return /* @__PURE__ */ d(s, { className: u, flexDirection: "column", gap: 16, children: [
79
- /* @__PURE__ */ d(s, { justifyContent: "space-between", alignItems: "center", children: [
80
- /* @__PURE__ */ r(F, { as: "h2", children: e("title") }),
86
+ return /* @__PURE__ */ d(c, { className: D, flexDirection: "column", gap: 16, children: [
87
+ /* @__PURE__ */ d(c, { justifyContent: "space-between", alignItems: "center", children: [
88
+ /* @__PURE__ */ r(L, { as: "h2", children: e("title") }),
81
89
  /* @__PURE__ */ r(
82
- O,
90
+ I,
83
91
  {
84
92
  startDate: o.startDate,
85
93
  endDate: o.endDate,
@@ -99,11 +107,11 @@ const ce = ({
99
107
  )
100
108
  ] }),
101
109
  /* @__PURE__ */ r(
102
- _,
110
+ z,
103
111
  {
104
112
  label: e("dataView.label"),
105
- pagination: c,
106
- isFetching: c.isFetching,
113
+ pagination: s,
114
+ isFetching: s.isFetching,
107
115
  emptyState: () => o.isModified ? /* @__PURE__ */ r(
108
116
  y,
109
117
  {
@@ -120,14 +128,11 @@ const ce = ({
120
128
  columns: [
121
129
  {
122
130
  title: e("columns.payPeriod"),
123
- render: (t) => l.formatPayPeriodRange(
124
- t.payPeriod?.startDate,
125
- t.payPeriod?.endDate
126
- )
131
+ render: (t) => u(t, l)
127
132
  },
128
133
  {
129
134
  title: e("columns.type"),
130
- render: (t) => H(t)
135
+ render: (t) => U(t)
131
136
  },
132
137
  {
133
138
  title: e("columns.payDate"),
@@ -136,42 +141,39 @@ const ce = ({
136
141
  {
137
142
  title: e("columns.status"),
138
143
  render: (t) => {
139
- const n = f.find(
140
- (i) => i.paymentUuid === t.payrollUuid
144
+ const i = h.find(
145
+ (n) => n.paymentUuid === t.payrollUuid
141
146
  );
142
- return /* @__PURE__ */ r(W, { payroll: t, wireInRequest: n });
147
+ return /* @__PURE__ */ r(_, { payroll: t, wireInRequest: i });
143
148
  }
144
149
  },
145
150
  {
146
151
  title: e("columns.totalPayroll"),
147
152
  justify: "end",
148
- render: (t) => Y(U(t))
153
+ render: (t) => Y(j(t))
149
154
  }
150
155
  ],
151
- data: D,
156
+ data: f,
152
157
  itemMenu: (t) => /* @__PURE__ */ r(N, { items: A(t) })
153
158
  }
154
159
  ),
155
160
  /* @__PURE__ */ r(
156
- w,
161
+ v,
157
162
  {
158
163
  isOpen: !!a,
159
- onClose: b,
164
+ onClose: g,
160
165
  onPrimaryActionClick: k,
161
166
  isDestructive: !0,
162
- isPrimaryActionLoading: g,
167
+ isPrimaryActionLoading: F,
163
168
  primaryActionLabel: e("cancelDialog.primaryAction"),
164
169
  closeActionLabel: e("cancelDialog.secondaryAction"),
165
170
  title: a ? e("cancelDialog.title", {
166
- payPeriod: l.formatPayPeriodRange(
167
- a.payPeriod?.startDate,
168
- a.payPeriod?.endDate
169
- )
171
+ payPeriod: u(a, l)
170
172
  }) : "",
171
- children: a && /* @__PURE__ */ d(s, { flexDirection: "column", gap: 16, children: [
173
+ children: a && /* @__PURE__ */ d(c, { flexDirection: "column", gap: 16, children: [
172
174
  /* @__PURE__ */ r(m, { children: e("cancelDialog.body") }),
173
175
  a.payrollDeadline && /* @__PURE__ */ r(m, { children: e("cancelDialog.deadline", {
174
- deadline: L(a)
176
+ deadline: w(a)
175
177
  }) })
176
178
  ] })
177
179
  }
@@ -179,6 +181,6 @@ const ce = ({
179
181
  ] });
180
182
  };
181
183
  export {
182
- ce as PayrollHistoryPresentation
184
+ me as PayrollHistoryPresentation
183
185
  };
184
186
  //# sourceMappingURL=PayrollHistoryPresentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PayrollHistoryPresentation.js","sources":["../../../../src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { Payroll } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { WireInRequest } from '@gusto/embedded-api/models/components/wireinrequest'\nimport { PayrollStatusBadges } from '../PayrollStatusBadges'\nimport { getPayrollTypeLabel, calculateTotalPayroll, canCancelPayroll } from '../helpers'\nimport type { MenuItem } from '@/components/Common/UI/Menu/MenuTypes'\nimport { DataView, Flex, DateRangeFilter } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\nimport { useI18n } from '@/i18n'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport type { UseDateRangeFilterResult } from '@/hooks/useDateRangeFilter/useDateRangeFilter'\nimport TrashcanIcon from '@/assets/icons/trashcan.svg?react'\nimport FileIcon from '@/assets/icons/icon-file-outline.svg?react'\nimport ReceiptIcon from '@/assets/icons/icon-receipt-outline.svg?react'\nimport { EmptyData } from '@/components/Common/'\n\ninterface PayrollHistoryPresentationProps {\n /** CSS class name applied to the root element. */\n className?: string\n payrollHistory: Payroll[]\n wireInRequests: WireInRequest[]\n pagination: PaginationControlProps\n onViewSummary: (payrollId: string, startDate?: string, endDate?: string) => void\n onViewReceipt: (payrollId: string, startDate?: string, endDate?: string) => void\n onCancelPayroll: (item: Payroll) => void\n cancelDialogItem: Payroll | null\n onCancelDialogOpen: (item: Payroll) => void\n onCancelDialogClose: () => void\n isLoading?: boolean\n dateRangeFilter: UseDateRangeFilterResult\n}\n\n/** @internal */\nexport const PayrollHistoryPresentation = ({\n className,\n payrollHistory,\n wireInRequests,\n pagination,\n onViewSummary,\n onViewReceipt,\n onCancelPayroll,\n cancelDialogItem,\n onCancelDialogOpen,\n onCancelDialogClose,\n isLoading = false,\n dateRangeFilter,\n}: PayrollHistoryPresentationProps) => {\n const { Heading, Text, Dialog } = useComponentContext()\n useI18n('Payroll.PayrollHistory')\n const { t } = useTranslation('Payroll.PayrollHistory')\n const dateFormatter = useDateFormatter()\n\n const formatDeadlineForDialog = (item: Payroll): string => {\n const deadline = item.payrollDeadline\n if (!deadline) return ''\n\n const deadlineDate = new Date(deadline)\n const timeZone = 'America/New_York'\n\n const formatter = new Intl.DateTimeFormat('en-US', {\n weekday: 'short',\n month: 'short',\n day: 'numeric',\n timeZone,\n })\n\n const timeFormatter = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n minute: '2-digit',\n timeZoneName: 'short',\n timeZone,\n })\n\n const dateStr = formatter.format(deadlineDate)\n const timeStr = timeFormatter.format(deadlineDate)\n\n return `${timeStr} on ${dateStr}`\n }\n\n const handleCancelClick = (item: Payroll) => {\n onCancelDialogOpen(item)\n }\n\n const handleConfirmCancel = () => {\n if (cancelDialogItem) {\n onCancelPayroll(cancelDialogItem)\n }\n }\n\n const getMenuItems = (item: Payroll): MenuItem[] => {\n const payrollId = item.payrollUuid || item.uuid!\n const items: MenuItem[] = [\n {\n label: t('menu.viewSummary'),\n icon: <FileIcon aria-hidden />,\n onClick: () => {\n onViewSummary(payrollId, item.payPeriod?.startDate, item.payPeriod?.endDate)\n },\n },\n {\n label: t('menu.viewReceipt'),\n icon: <ReceiptIcon aria-hidden />,\n onClick: () => {\n onViewReceipt(payrollId, item.payPeriod?.startDate, item.payPeriod?.endDate)\n },\n },\n ]\n\n if (canCancelPayroll(item)) {\n items.push({\n label: t('menu.cancelPayroll'),\n icon: <TrashcanIcon aria-hidden />,\n onClick: () => {\n handleCancelClick(item)\n },\n 'data-destructive': 'true',\n })\n }\n\n return items\n }\n\n return (\n <Flex className={className} flexDirection=\"column\" gap={16}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\">\n <Heading as=\"h2\">{t('title')}</Heading>\n <DateRangeFilter\n startDate={dateRangeFilter.startDate}\n endDate={dateRangeFilter.endDate}\n onStartDateChange={dateRangeFilter.handleStartDateChange}\n onEndDateChange={dateRangeFilter.handleEndDateChange}\n onClear={dateRangeFilter.handleClearFilter}\n startDateLabel={t('dateFilter.startDate')}\n endDateLabel={t('dateFilter.endDate')}\n applyLabel={t('dateFilter.apply')}\n cancelLabel={t('dateFilter.cancel')}\n resetLabel={t('dateFilter.reset')}\n selectDatesLabel={t('dateFilter.selectDates')}\n triggerLabel={t('dateFilter.trigger')}\n maxEndDate={dateRangeFilter.getMaxEndDate()}\n minStartDate={dateRangeFilter.getMinStartDate()}\n />\n </Flex>\n\n <DataView\n label={t('dataView.label')}\n pagination={pagination}\n isFetching={pagination.isFetching}\n emptyState={() =>\n dateRangeFilter.isModified ? (\n <EmptyData\n title={t('emptyState.filtered.title')}\n description={t('emptyState.filtered.description')}\n />\n ) : (\n <EmptyData\n title={t('emptyState.default.title')}\n description={t('emptyState.default.description')}\n />\n )\n }\n columns={[\n {\n title: t('columns.payPeriod'),\n render: (item: Payroll) =>\n dateFormatter.formatPayPeriodRange(\n item.payPeriod?.startDate,\n item.payPeriod?.endDate,\n ),\n },\n {\n title: t('columns.type'),\n render: (item: Payroll) => getPayrollTypeLabel(item),\n },\n {\n title: t('columns.payDate'),\n render: (item: Payroll) => dateFormatter.formatShortWithYear(item.checkDate),\n },\n {\n title: t('columns.status'),\n render: (item: Payroll) => {\n const wireInRequest = wireInRequests.find(\n wire => wire.paymentUuid === item.payrollUuid,\n )\n return <PayrollStatusBadges payroll={item} wireInRequest={wireInRequest} />\n },\n },\n {\n title: t('columns.totalPayroll'),\n justify: 'end',\n render: (item: Payroll) => formatNumberAsCurrency(calculateTotalPayroll(item)),\n },\n ]}\n data={payrollHistory}\n itemMenu={(item: Payroll) => <HamburgerMenu items={getMenuItems(item)} />}\n />\n\n <Dialog\n isOpen={!!cancelDialogItem}\n onClose={onCancelDialogClose}\n onPrimaryActionClick={handleConfirmCancel}\n isDestructive\n isPrimaryActionLoading={isLoading}\n primaryActionLabel={t('cancelDialog.primaryAction')}\n closeActionLabel={t('cancelDialog.secondaryAction')}\n title={\n cancelDialogItem\n ? t('cancelDialog.title', {\n payPeriod: dateFormatter.formatPayPeriodRange(\n cancelDialogItem.payPeriod?.startDate,\n cancelDialogItem.payPeriod?.endDate,\n ),\n })\n : ''\n }\n >\n {cancelDialogItem && (\n <Flex flexDirection=\"column\" gap={16}>\n <Text>{t('cancelDialog.body')}</Text>\n {cancelDialogItem.payrollDeadline && (\n <Text>\n {t('cancelDialog.deadline', {\n deadline: formatDeadlineForDialog(cancelDialogItem),\n })}\n </Text>\n )}\n </Flex>\n )}\n </Dialog>\n </Flex>\n )\n}\n"],"names":["PayrollHistoryPresentation","className","payrollHistory","wireInRequests","pagination","onViewSummary","onViewReceipt","onCancelPayroll","cancelDialogItem","onCancelDialogOpen","onCancelDialogClose","isLoading","dateRangeFilter","Heading","Text","Dialog","useComponentContext","useI18n","t","useTranslation","dateFormatter","useDateFormatter","formatDeadlineForDialog","item","deadline","deadlineDate","timeZone","formatter","timeFormatter","dateStr","handleCancelClick","handleConfirmCancel","getMenuItems","payrollId","items","jsx","FileIcon","ReceiptIcon","canCancelPayroll","TrashcanIcon","Flex","jsxs","DateRangeFilter","DataView","EmptyData","getPayrollTypeLabel","wireInRequest","wire","PayrollStatusBadges","formatNumberAsCurrency","calculateTotalPayroll","HamburgerMenu"],"mappings":";;;;;;;;;;;;;;;;AAoCO,MAAMA,KAA6B,CAAC;AAAA,EACzC,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,iBAAAC;AACF,MAAuC;AACrC,QAAM,EAAE,SAAAC,GAAS,MAAAC,GAAM,QAAAC,EAAA,IAAWC,EAAA;AAClC,EAAAC,EAAQ,wBAAwB;AAChC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,wBAAwB,GAC/CC,IAAgBC,EAAA,GAEhBC,IAA0B,CAACC,MAA0B;AACzD,UAAMC,IAAWD,EAAK;AACtB,QAAI,CAACC,EAAU,QAAO;AAEtB,UAAMC,IAAe,IAAI,KAAKD,CAAQ,GAChCE,IAAW,oBAEXC,IAAY,IAAI,KAAK,eAAe,SAAS;AAAA,MACjD,SAAS;AAAA,MACT,OAAO;AAAA,MACP,KAAK;AAAA,MACL,UAAAD;AAAA,IAAA,CACD,GAEKE,IAAgB,IAAI,KAAK,eAAe,SAAS;AAAA,MACrD,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,UAAAF;AAAA,IAAA,CACD,GAEKG,IAAUF,EAAU,OAAOF,CAAY;AAG7C,WAAO,GAFSG,EAAc,OAAOH,CAAY,CAEhC,OAAOI,CAAO;AAAA,EACjC,GAEMC,IAAoB,CAACP,MAAkB;AAC3C,IAAAd,EAAmBc,CAAI;AAAA,EACzB,GAEMQ,IAAsB,MAAM;AAChC,IAAIvB,KACFD,EAAgBC,CAAgB;AAAA,EAEpC,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{"version":3,"file":"PayrollHistoryPresentation.js","sources":["../../../../src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { Payroll } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { WireInRequest } from '@gusto/embedded-api/models/components/wireinrequest'\nimport { PayrollStatusBadges } from '../PayrollStatusBadges'\nimport {\n getPayrollTypeLabel,\n calculateTotalPayroll,\n canCancelPayroll,\n getPayPeriodOrCheckDateLabel,\n} from '../helpers'\nimport type { MenuItem } from '@/components/Common/UI/Menu/MenuTypes'\nimport { DataView, Flex, DateRangeFilter } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\nimport { useI18n } from '@/i18n'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport type { UseDateRangeFilterResult } from '@/hooks/useDateRangeFilter/useDateRangeFilter'\nimport TrashcanIcon from '@/assets/icons/trashcan.svg?react'\nimport FileIcon from '@/assets/icons/icon-file-outline.svg?react'\nimport ReceiptIcon from '@/assets/icons/icon-receipt-outline.svg?react'\nimport { EmptyData } from '@/components/Common/'\n\ninterface PayrollHistoryPresentationProps {\n /** CSS class name applied to the root element. */\n className?: string\n payrollHistory: Payroll[]\n wireInRequests: WireInRequest[]\n pagination: PaginationControlProps\n onViewSummary: (payrollId: string, startDate?: string, endDate?: string) => void\n onViewReceipt: (payrollId: string, startDate?: string, endDate?: string) => void\n onCancelPayroll: (item: Payroll) => void\n cancelDialogItem: Payroll | null\n onCancelDialogOpen: (item: Payroll) => void\n onCancelDialogClose: () => void\n isLoading?: boolean\n dateRangeFilter: UseDateRangeFilterResult\n}\n\n/** @internal */\nexport const PayrollHistoryPresentation = ({\n className,\n payrollHistory,\n wireInRequests,\n pagination,\n onViewSummary,\n onViewReceipt,\n onCancelPayroll,\n cancelDialogItem,\n onCancelDialogOpen,\n onCancelDialogClose,\n isLoading = false,\n dateRangeFilter,\n}: PayrollHistoryPresentationProps) => {\n const { Heading, Text, Dialog } = useComponentContext()\n useI18n('Payroll.PayrollHistory')\n const { t } = useTranslation('Payroll.PayrollHistory')\n const dateFormatter = useDateFormatter()\n\n const formatDeadlineForDialog = (item: Payroll): string => {\n const deadline = item.payrollDeadline\n if (!deadline) return ''\n\n const deadlineDate = new Date(deadline)\n const timeZone = 'America/New_York'\n\n const formatter = new Intl.DateTimeFormat('en-US', {\n weekday: 'short',\n month: 'short',\n day: 'numeric',\n timeZone,\n })\n\n const timeFormatter = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n minute: '2-digit',\n timeZoneName: 'short',\n timeZone,\n })\n\n const dateStr = formatter.format(deadlineDate)\n const timeStr = timeFormatter.format(deadlineDate)\n\n return `${timeStr} on ${dateStr}`\n }\n\n const handleCancelClick = (item: Payroll) => {\n onCancelDialogOpen(item)\n }\n\n const handleConfirmCancel = () => {\n if (cancelDialogItem) {\n onCancelPayroll(cancelDialogItem)\n }\n }\n\n const getMenuItems = (item: Payroll): MenuItem[] => {\n const payrollId = item.payrollUuid || item.uuid!\n const items: MenuItem[] = [\n {\n label: t('menu.viewSummary'),\n icon: <FileIcon aria-hidden />,\n onClick: () => {\n onViewSummary(\n payrollId,\n item.payPeriod?.startDate ?? undefined,\n item.payPeriod?.endDate ?? undefined,\n )\n },\n },\n {\n label: t('menu.viewReceipt'),\n icon: <ReceiptIcon aria-hidden />,\n onClick: () => {\n onViewReceipt(\n payrollId,\n item.payPeriod?.startDate ?? undefined,\n item.payPeriod?.endDate ?? undefined,\n )\n },\n },\n ]\n\n if (canCancelPayroll(item)) {\n items.push({\n label: t('menu.cancelPayroll'),\n icon: <TrashcanIcon aria-hidden />,\n onClick: () => {\n handleCancelClick(item)\n },\n 'data-destructive': 'true',\n })\n }\n\n return items\n }\n\n return (\n <Flex className={className} flexDirection=\"column\" gap={16}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\">\n <Heading as=\"h2\">{t('title')}</Heading>\n <DateRangeFilter\n startDate={dateRangeFilter.startDate}\n endDate={dateRangeFilter.endDate}\n onStartDateChange={dateRangeFilter.handleStartDateChange}\n onEndDateChange={dateRangeFilter.handleEndDateChange}\n onClear={dateRangeFilter.handleClearFilter}\n startDateLabel={t('dateFilter.startDate')}\n endDateLabel={t('dateFilter.endDate')}\n applyLabel={t('dateFilter.apply')}\n cancelLabel={t('dateFilter.cancel')}\n resetLabel={t('dateFilter.reset')}\n selectDatesLabel={t('dateFilter.selectDates')}\n triggerLabel={t('dateFilter.trigger')}\n maxEndDate={dateRangeFilter.getMaxEndDate()}\n minStartDate={dateRangeFilter.getMinStartDate()}\n />\n </Flex>\n\n <DataView\n label={t('dataView.label')}\n pagination={pagination}\n isFetching={pagination.isFetching}\n emptyState={() =>\n dateRangeFilter.isModified ? (\n <EmptyData\n title={t('emptyState.filtered.title')}\n description={t('emptyState.filtered.description')}\n />\n ) : (\n <EmptyData\n title={t('emptyState.default.title')}\n description={t('emptyState.default.description')}\n />\n )\n }\n columns={[\n {\n title: t('columns.payPeriod'),\n render: (item: Payroll) => getPayPeriodOrCheckDateLabel(item, dateFormatter),\n },\n {\n title: t('columns.type'),\n render: (item: Payroll) => getPayrollTypeLabel(item),\n },\n {\n title: t('columns.payDate'),\n render: (item: Payroll) => dateFormatter.formatShortWithYear(item.checkDate),\n },\n {\n title: t('columns.status'),\n render: (item: Payroll) => {\n const wireInRequest = wireInRequests.find(\n wire => wire.paymentUuid === item.payrollUuid,\n )\n return <PayrollStatusBadges payroll={item} wireInRequest={wireInRequest} />\n },\n },\n {\n title: t('columns.totalPayroll'),\n justify: 'end',\n render: (item: Payroll) => formatNumberAsCurrency(calculateTotalPayroll(item)),\n },\n ]}\n data={payrollHistory}\n itemMenu={(item: Payroll) => <HamburgerMenu items={getMenuItems(item)} />}\n />\n\n <Dialog\n isOpen={!!cancelDialogItem}\n onClose={onCancelDialogClose}\n onPrimaryActionClick={handleConfirmCancel}\n isDestructive\n isPrimaryActionLoading={isLoading}\n primaryActionLabel={t('cancelDialog.primaryAction')}\n closeActionLabel={t('cancelDialog.secondaryAction')}\n title={\n cancelDialogItem\n ? t('cancelDialog.title', {\n payPeriod: getPayPeriodOrCheckDateLabel(cancelDialogItem, dateFormatter),\n })\n : ''\n }\n >\n {cancelDialogItem && (\n <Flex flexDirection=\"column\" gap={16}>\n <Text>{t('cancelDialog.body')}</Text>\n {cancelDialogItem.payrollDeadline && (\n <Text>\n {t('cancelDialog.deadline', {\n deadline: formatDeadlineForDialog(cancelDialogItem),\n })}\n </Text>\n )}\n </Flex>\n )}\n </Dialog>\n </Flex>\n )\n}\n"],"names":["PayrollHistoryPresentation","className","payrollHistory","wireInRequests","pagination","onViewSummary","onViewReceipt","onCancelPayroll","cancelDialogItem","onCancelDialogOpen","onCancelDialogClose","isLoading","dateRangeFilter","Heading","Text","Dialog","useComponentContext","useI18n","t","useTranslation","dateFormatter","useDateFormatter","formatDeadlineForDialog","item","deadline","deadlineDate","timeZone","formatter","timeFormatter","dateStr","handleCancelClick","handleConfirmCancel","getMenuItems","payrollId","items","jsx","FileIcon","ReceiptIcon","canCancelPayroll","TrashcanIcon","Flex","jsxs","DateRangeFilter","DataView","EmptyData","getPayPeriodOrCheckDateLabel","getPayrollTypeLabel","wireInRequest","wire","PayrollStatusBadges","formatNumberAsCurrency","calculateTotalPayroll","HamburgerMenu"],"mappings":";;;;;;;;;;;;;;;;AAyCO,MAAMA,KAA6B,CAAC;AAAA,EACzC,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,iBAAAC;AACF,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