@gusto/embedded-react-sdk 0.55.8 → 0.56.1
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.
- package/CHANGELOG.md +56 -0
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.js +43 -42
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +6 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +4 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +6 -5
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +7 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +4 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +4 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +4 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +4 -3
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js +70 -69
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js.map +1 -1
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeListView.js +2 -2
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeListView.js.map +1 -1
- package/dist/components/Employee/EmployeeList/shared/useEmployeeList.js +51 -42
- package/dist/components/Employee/EmployeeList/shared/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js +29 -26
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +2 -2
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js +11 -11
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummaryPresentation.js +3 -3
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummaryPresentation.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +76 -79
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js +2 -2
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsBanner/ConfirmWireDetailsBanner.js +2 -2
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsBanner/ConfirmWireDetailsBanner.js.map +1 -1
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelectionPresentation.js +10 -10
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelectionPresentation.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +49 -45
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/OffCycle/OffCycleFlow.js.map +1 -1
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +24 -18
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
- package/dist/components/Payroll/OffCycle/offCycleStateMachine.js +39 -21
- package/dist/components/Payroll/OffCycle/offCycleStateMachine.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +98 -88
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +64 -60
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.js +12 -12
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.js.map +1 -1
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +40 -40
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +205 -185
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/useCalculationPoll.js +48 -34
- package/dist/components/Payroll/PayrollConfiguration/useCalculationPoll.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +13 -16
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +0 -1
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js +138 -110
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +149 -146
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +4 -0
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js +22 -35
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +185 -171
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/useSubmissionPoll.js +45 -34
- package/dist/components/Payroll/PayrollOverview/useSubmissionPoll.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js +44 -44
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.module.scss.js +14 -14
- package/dist/components/Payroll/PrintChecks/PrintChecksFailure/PrintChecksFailure.js +16 -16
- package/dist/components/Payroll/PrintChecks/PrintChecksFailure/PrintChecksFailure.js.map +1 -1
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/useGenerationPoll.js +52 -37
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/useGenerationPoll.js.map +1 -1
- package/dist/components/Payroll/Transition/TransitionFlow.js +49 -36
- package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -1
- package/dist/components/Payroll/Transition/TransitionFlowComponents.js +24 -47
- package/dist/components/Payroll/Transition/TransitionFlowComponents.js.map +1 -1
- package/dist/components/Payroll/Transition/transitionStateMachine.js +35 -40
- package/dist/components/Payroll/Transition/transitionStateMachine.js.map +1 -1
- package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js +48 -0
- package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js.map +1 -0
- package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js +35 -0
- package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js.map +1 -0
- package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js +23 -0
- package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js.map +1 -0
- package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js +32 -0
- package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js.map +1 -0
- package/dist/components/Payroll/index.js +7 -5
- package/dist/components/Payroll/index.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +9 -8
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ApiProvider/ApiProvider.js +29 -28
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
- package/dist/contexts/ApiProvider/apiVersionMismatchHook.js +15 -0
- package/dist/contexts/ApiProvider/apiVersionMismatchHook.js.map +1 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ThemeProvider/ThemeProvider.js +32 -26
- package/dist/contexts/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/hooks/usePollingTask/usePollingTask.js +53 -41
- package/dist/hooks/usePollingTask/usePollingTask.js.map +1 -1
- package/dist/i18n/I18n.js +9 -4
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Employee.ManagementEmployeeList.json.js +28 -24
- package/dist/i18n/en/Employee.ManagementEmployeeList.json.js.map +1 -1
- package/dist/i18n/en/Payroll.GrossUpModal.json.js +12 -10
- package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollBlocker.json.js +10 -8
- package/dist/i18n/en/Payroll.PayrollBlocker.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +8 -8
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +15 -15
- package/dist/i18n/es_US/Company.StateTaxes.json.js +1 -1
- package/dist/i18n/es_US/Contractor.ContractorList.json.js +14 -12
- package/dist/i18n/es_US/Contractor.ContractorList.json.js.map +1 -1
- package/dist/i18n/es_US/Contractor.Management.Compensation.json.js +4 -4
- package/dist/i18n/es_US/Contractor.Management.Profile.json.js +4 -4
- package/dist/i18n/es_US/Contractor.ManagementContractorList.json.js +40 -38
- package/dist/i18n/es_US/Contractor.ManagementContractorList.json.js.map +1 -1
- package/dist/i18n/es_US/Contractor.Payments.PaymentsList.json.js +18 -16
- package/dist/i18n/es_US/Contractor.Payments.PaymentsList.json.js.map +1 -1
- package/dist/i18n/es_US/Contractor.Profile.json.js +5 -5
- package/dist/i18n/es_US/Payroll.OffCycleCreation.json.js +11 -9
- package/dist/i18n/es_US/Payroll.OffCycleCreation.json.js.map +1 -1
- package/dist/i18n/es_US/Payroll.OffCyclePayPeriodDateForm.json.js +2 -2
- package/dist/i18n/es_US/Payroll.OffCycleTaxWithholding.json.js +6 -6
- package/dist/i18n/es_US/Payroll.PayrollConfiguration.json.js +15 -15
- package/dist/i18n/es_US/Payroll.PayrollEditEmployee.json.js +28 -26
- package/dist/i18n/es_US/Payroll.PayrollEditEmployee.json.js.map +1 -1
- package/dist/i18n/es_US/Payroll.PayrollOverview.json.js +40 -38
- package/dist/i18n/es_US/Payroll.PayrollOverview.json.js.map +1 -1
- package/dist/i18n/es_US/Payroll.PrintChecksBanner.json.js +14 -0
- package/dist/i18n/es_US/Payroll.PrintChecksBanner.json.js.map +1 -0
- package/dist/i18n/es_US/Payroll.PrintChecksFailure.json.js +12 -0
- package/dist/i18n/es_US/Payroll.PrintChecksFailure.json.js.map +1 -0
- package/dist/i18n/es_US/Payroll.PrintChecksForm.json.js +26 -0
- package/dist/i18n/es_US/Payroll.PrintChecksForm.json.js.map +1 -0
- package/dist/i18n/es_US/Payroll.PrintChecksSummary.json.js +14 -0
- package/dist/i18n/es_US/Payroll.PrintChecksSummary.json.js.map +1 -0
- package/dist/i18n/es_US/Payroll.UNSTABLE_PayrollEditEmployee.json.js +78 -0
- package/dist/i18n/es_US/Payroll.UNSTABLE_PayrollEditEmployee.json.js.map +1 -0
- package/dist/i18n/es_US/common.json.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/shared/constants.js +21 -20
- package/dist/shared/constants.js.map +1 -1
- package/dist/src/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +1 -1
- package/dist/src/components/Common/UI/DatePicker/DatePickerTypes.d.ts +2 -1
- package/dist/src/components/Common/UI/Menu/MenuTypes.d.ts +1 -1
- package/dist/src/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.d.ts +1 -1
- package/dist/src/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +5 -0
- package/dist/src/components/Common/UI/Select/SelectTypes.d.ts +2 -1
- package/dist/src/components/Employee/EmployeeList/shared/useEmployeeList.d.ts +7 -2
- package/dist/src/components/Employee/EmployeeListFlow/employeeListStateMachine.test.d.ts +1 -0
- package/dist/src/components/Payroll/OffCycle/OffCycleFlow.d.ts +2 -0
- package/dist/src/components/Payroll/OffCycle/OffCycleFlowComponents.d.ts +2 -0
- package/dist/src/components/Payroll/OffCycle/offCycleStateMachine.d.ts +1 -0
- package/dist/src/components/Payroll/OffCycleCreation/OffCycleCreation.d.ts +1 -0
- package/dist/src/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +11 -0
- package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfiguration.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollConfiguration/useCalculationPoll.d.ts +6 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.d.ts +18 -0
- package/dist/src/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.d.ts +8 -0
- package/dist/src/components/Payroll/PayrollFlow/PayrollFlow.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollFlow/TransitionFlowContextual.d.ts +6 -1
- package/dist/src/components/Payroll/PayrollOverview/useSubmissionPoll.d.ts +10 -1
- package/dist/src/components/Payroll/Transition/TransitionFlow.d.ts +17 -15
- package/dist/src/components/Payroll/Transition/TransitionFlowComponents.d.ts +21 -12
- package/dist/src/components/Payroll/Transition/transitionStateMachine.d.ts +25 -4
- package/dist/src/components/Payroll/TransitionPayroll/TransitionPayroll.d.ts +55 -0
- package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollComponents.d.ts +24 -0
- package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollTypes.d.ts +23 -0
- package/dist/src/components/Payroll/TransitionPayroll/index.d.ts +2 -0
- package/dist/src/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.d.ts +15 -0
- package/dist/src/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.d.ts +28 -0
- package/dist/src/components/Payroll/index.d.ts +2 -0
- package/dist/src/contexts/ApiProvider/ApiProvider.d.ts +5 -3
- package/dist/src/contexts/ApiProvider/apiVersionMismatchHook.d.ts +3 -0
- package/dist/src/contexts/ApiProvider/apiVersionMismatchHook.test.d.ts +1 -0
- package/dist/src/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +9 -1
- package/dist/src/contexts/ThemeProvider/ThemeProvider.d.ts +8 -3
- package/dist/src/hooks/usePollingTask/usePollingTask.d.ts +55 -14
- package/dist/src/i18n/types.d.ts +20 -0
- package/dist/src/shared/constants.d.ts +2 -0
- package/dist/style.css +1 -1
- package/docs/guides/endpoint-inventory.json +19 -19
- package/package.json +8 -8
|
@@ -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 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 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","resolve","data","payload","buildPayrollUpdateEmployeeCompensation","updated","SDKInternalError","PREPARE_QUERY_KEY","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAMA,KAAuB,GACvBC,KAAyB,MAEzBC,KAA+B,CAACC,MACpCA,aAAiBC,MACjBD,EAAM,OAAO,KAAK,CAAAE,MAASA,EAAM,aAAa,mBAAmB;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,GAAI1B,IACA;AAAA,QACE,uBAAAc;AAAA,QACA,mBAAAE;AAAA,QACA,qBAAAD;AAAA,QACA,qBAAAK;AAAA,MAAA,IAEF,CAAA;AAAA,IAAC;AAAA,IAEP,eAAA0B;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,GAAGzB;AAAA,QACH,SAASE;AAAA,QACT,oBAAoBvB,IAAqBQ,KAA2B;AAAA,MAAA;AAAA,MAEtE,gBAAA8B;AAAA,MACA,mBAAAU;AAAA,MACA,yBAAyBW,GAA8BlE,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 { 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,IAAcC,CAAe,IAAIF,EAAuB,IAAI,GAC7DG,IAAcC,GAAO,EAAK,GAE1BC,IAAiBC,EA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UAAUM,GAAA,EAAsB,IAAM,CAAA;AAAA,IAAC;AAAA,EAC1F;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayrollExecutionFlow.js","sources":["../../../../src/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { createMachine } from 'robot3'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { ConfirmWireDetailsComponentType } from '../ConfirmWireDetails/ConfirmWireDetails'\nimport {\n PayrollConfigurationContextual,\n PayrollOverviewContextual,\n SaveAndExitCta,\n type PayrollFlowContextInterface,\n} from '../PayrollFlow/PayrollFlowComponents'\nimport {\n payrollExecutionMachine,\n getPayrollExecutionBreadcrumbsNodes,\n} from './payrollExecutionMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport type { FlowBreadcrumb } from '@/components/Common/FlowBreadcrumbs/FlowBreadcrumbsTypes'\nimport { buildBreadcrumbs, updateBreadcrumbs } from '@/helpers/breadcrumbHelpers'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { EventType } from '@/shared/constants'\n\nconst EMPTY_BREADCRUMBS: FlowBreadcrumb[] = []\n\n/**\n * Entry point for {@link PayrollExecutionFlow}. Determines which screen the flow renders first.\n *\n * @public\n */\nexport type PayrollExecutionInitialState = 'configuration' | 'overview'\n\n/**\n * Props for {@link PayrollExecutionFlow}.\n *\n * @public\n */\nexport interface PayrollExecutionFlowProps {\n /** The associated company identifier. */\n companyId: string\n /**\n * The identifier of the payroll to execute. The payroll must already exist (e.g. created by a\n * prior creation step or by the standard `PayrollFlow` selection).\n */\n payrollId: string\n /** Event handler that receives the `RUN_PAYROLL_*` events emitted during the flow. */\n onEvent: OnEventType<EventType, unknown>\n /** Optional pay period metadata used to seed breadcrumb labels and date context. */\n initialPayPeriod?: PayrollPayPeriodType\n /**\n * When true, surfaces dismissal-specific copy and breadcrumbs (used by `Payroll.DismissalFlow`).\n * Defaults to `false`.\n */\n isDismissalPayroll?: boolean\n /** Optional flag to show or hide reimbursement fields throughout the flow. Defaults to `true`. */\n withReimbursements?: boolean\n /** Optional custom component to replace the default wire details confirmation UI. */\n ConfirmWireDetailsComponent?: ConfirmWireDetailsComponentType\n /**\n * Where the flow starts. Use `'overview'` when you want to drop the user directly on the review\n * screen (e.g. resuming an already-calculated payroll). Defaults to `'configuration'`.\n */\n initialState?: PayrollExecutionInitialState\n}\n\n/**\n * Props for the flow-internal {@link PayrollExecutionInternalFlow}, which layers flow-injected\n * prefix breadcrumbs on top of the public {@link PayrollExecutionFlowProps}.\n *\n * @internal\n */\nexport interface PayrollExecutionInternalFlowProps extends PayrollExecutionFlowProps {\n /**\n * Breadcrumbs prepended to the flow's own breadcrumb trail. Set by a parent flow (e.g. an\n * off-cycle creation step) so the breadcrumb history remains coherent across the handoff.\n */\n prefixBreadcrumbs?: FlowBreadcrumb[]\n}\n\nconst INITIAL_COMPONENT_MAP = {\n configuration: PayrollConfigurationContextual,\n overview: PayrollOverviewContextual,\n} as const\n\nconst INITIAL_NAMESPACE_MAP = {\n configuration: 'Payroll.PayrollConfiguration' as const,\n overview: 'Payroll.PayrollOverview' as const,\n} as const\n\n/**\n * Guided flow to configure, review, and submit a single payroll.\n *\n * @remarks\n * This is the inner flow that powers the back half of `Payroll.PayrollFlow`, and it is also reused\n * by the off-cycle, dismissal, and transition flows after they have created their respective\n * payrolls. Render it directly when you have built your own payroll-creation step and want to hand\n * the user off to the standard execution experience without re-implementing it. The flow ships\n * with breadcrumb navigation and the standard wire-confirmation UX.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/edit` | Fired when user chooses to edit payroll | — |\n * | `runPayroll/calculated` | Fired when payroll calculation completes | `{ payrollUuid, payPeriod?, alert? }` |\n * | `runPayroll/alreadyProcessed` | Fired when the payroll turns out to already be processed while configuring it; the flow moves to the review screen | `{ payrollId, alert?, payPeriod? }` |\n * | `runPayroll/employee/edit` | Fired when user opens an employee row to edit | `{ employeeId, firstName, lastName }` |\n * | `runPayroll/employee/saved` | Fired when employee edits are saved | — |\n * | `runPayroll/employee/cancelled` | Fired when employee edits are cancelled | — |\n * | `runPayroll/submitting` | Fired when payroll submission begins | — |\n * | `runPayroll/submitted` | Fired when payroll is successfully submitted | Response from the Submit payroll endpoint |\n * | `runPayroll/processed` | Fired when payroll processing is completed | — |\n * | `runPayroll/processingFailed` | Fired when payroll processing fails | Error details |\n * | `runPayroll/cancelled` | Fired when a payroll is cancelled | Response from the Cancel payroll endpoint |\n * | `runPayroll/receipt/get` | Fired when user requests payroll receipt | `{ payrollId }` |\n * | `runPayroll/receipt/viewed` | Fired when the receipt screen is viewed | — |\n * | `runPayroll/pdfPaystub/viewed` | Fired when user views employee paystub PDF | `{ employeeId }` |\n * | `runPayroll/blockers/viewAll` | Fired when user opens the full blockers list | — |\n * | `payroll/saveAndExit` | Fired when user uses the save-and-exit CTA | — |\n *\n * @components\n * - {@link PayrollConfiguration}\n * - {@link PayrollOverview}\n * - {@link PayrollEditEmployee}\n * - {@link PayrollReceipts}\n * - {@link PayrollBlockerList}\n *\n * @param input - {@link PayrollExecutionFlowProps}\n * @returns The rendered execution flow.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { Payroll, type EventType } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <Payroll.PayrollExecutionFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * payrollId=\"0987fcea-7b59-4907-a301-f232b5aff508\"\n * onEvent={(eventType: EventType) => {\n * if (eventType === 'runPayroll/submitted') {\n * // Payroll submitted — navigate to your next screen\n * }\n * }}\n * />\n * )\n * }\n * ```\n */\nexport function PayrollExecutionFlow(props: PayrollExecutionFlowProps) {\n return <PayrollExecutionInternalFlow {...props} />\n}\n\n/**\n * Flow-internal entry point for {@link PayrollExecutionFlow} that additionally accepts\n * flow-injected `prefixBreadcrumbs`. Partners use {@link PayrollExecutionFlow}; our own parent\n * flows (off-cycle, dismissal, transition, and `PayrollFlow`) render this directly to prepend\n * their own breadcrumb trail.\n *\n * @internal\n */\nexport function PayrollExecutionInternalFlow({\n companyId,\n payrollId,\n onEvent,\n initialPayPeriod,\n isDismissalPayroll: isDismissal = false,\n withReimbursements = true,\n ConfirmWireDetailsComponent,\n prefixBreadcrumbs = EMPTY_BREADCRUMBS,\n initialState = 'configuration',\n}: PayrollExecutionInternalFlowProps) {\n const executionFlowMachine = useMemo(() => {\n const breadcrumbNodes = getPayrollExecutionBreadcrumbsNodes(isDismissal)\n const baseBreadcrumbs = buildBreadcrumbs(breadcrumbNodes)\n const displayOnlyPrefixes = prefixBreadcrumbs.map(({ onNavigate, ...rest }) => rest)\n const breadcrumbs = Object.fromEntries(\n Object.entries(baseBreadcrumbs).map(([stateKey, trail]) => [\n stateKey,\n [...displayOnlyPrefixes, ...trail],\n ]),\n )\n\n const initialBreadcrumbContext = updateBreadcrumbs(\n initialState,\n {\n header: {\n type: 'breadcrumbs' as const,\n breadcrumbs,\n cta: SaveAndExitCta,\n },\n },\n {\n startDate: initialPayPeriod?.startDate ?? '',\n endDate: initialPayPeriod?.endDate ?? '',\n },\n )\n\n return createMachine(\n initialState,\n payrollExecutionMachine,\n (initialContext: PayrollFlowContextInterface) => ({\n ...initialContext,\n ...initialBreadcrumbContext,\n component: INITIAL_COMPONENT_MAP[initialState],\n companyId,\n payrollUuid: payrollId,\n payPeriod: initialPayPeriod,\n withReimbursements,\n ConfirmWireDetailsComponent,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: INITIAL_NAMESPACE_MAP[initialState],\n },\n }),\n )\n }, [\n companyId,\n payrollId,\n isDismissal,\n withReimbursements,\n ConfirmWireDetailsComponent,\n prefixBreadcrumbs,\n initialState,\n ])\n\n return <Flow machine={executionFlowMachine} onEvent={onEvent} />\n}\n"],"names":["EMPTY_BREADCRUMBS","INITIAL_COMPONENT_MAP","PayrollConfigurationContextual","PayrollOverviewContextual","INITIAL_NAMESPACE_MAP","PayrollExecutionFlow","props","jsx","PayrollExecutionInternalFlow","companyId","payrollId","onEvent","initialPayPeriod","isDismissal","withReimbursements","ConfirmWireDetailsComponent","prefixBreadcrumbs","initialState","executionFlowMachine","useMemo","breadcrumbNodes","getPayrollExecutionBreadcrumbsNodes","baseBreadcrumbs","buildBreadcrumbs","displayOnlyPrefixes","onNavigate","rest","breadcrumbs","stateKey","trail","initialBreadcrumbContext","updateBreadcrumbs","SaveAndExitCta","createMachine","payrollExecutionMachine","initialContext","Flow"],"mappings":";;;;;;;AAoBA,MAAMA,IAAsC,CAAA,GAwDtCC,IAAwB;AAAA,EAC5B,eAAeC;AAAA,EACf,UAAUC;AACZ,GAEMC,IAAwB;AAAA,EAC5B,eAAe;AAAA,EACf,UAAU;AACZ;AA8DO,SAASC,EAAqBC,GAAkC;AACrE,SAAO,gBAAAC,EAACC,GAAA,EAA8B,GAAGF,EAAA,CAAO;AAClD;AAUO,SAASE,EAA6B;AAAA,EAC3C,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,oBAAoBC,IAAc;AAAA,EAClC,oBAAAC,IAAqB;AAAA,EACrB,6BAAAC;AAAA,EACA,mBAAAC,IAAoBhB;AAAA,EACpB,cAAAiB,IAAe;AACjB,GAAsC;AACpC,QAAMC,IAAuBC,EAAQ,MAAM;AACzC,UAAMC,IAAkBC,EAAoCR,CAAW,GACjES,IAAkBC,EAAiBH,CAAe,GAClDI,IAAsBR,EAAkB,IAAI,CAAC,EAAE,YAAAS,GAAY,GAAGC,EAAA,MAAWA,CAAI,GAC7EC,IAAc,OAAO;AAAA,MACzB,OAAO,QAAQL,CAAe,EAAE,IAAI,CAAC,CAACM,GAAUC,CAAK,MAAM;AAAA,QACzDD;AAAA,QACA,CAAC,GAAGJ,GAAqB,GAAGK,CAAK;AAAA,MAAA,CAClC;AAAA,IAAA,GAGGC,IAA2BC;AAAA,MAC/Bd;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,aAAAU;AAAA,UACA,KAAKK;AAAA,QAAA;AAAA,MACP;AAAA,MAEF;AAAA,QACE,WAAWpB,GAAkB,aAAa;AAAA,QAC1C,SAASA,GAAkB,WAAW;AAAA,MAAA;AAAA,IACxC;AAGF,WAAOqB;AAAA,MACLhB;AAAA,MACAiB;AAAA,MACA,CAACC,OAAiD;AAAA,QAChD,GAAGA;AAAA,QACH,GAAGL;AAAA,QACH,WAAW7B,EAAsBgB,CAAY;AAAA,QAC7C,WAAAR;AAAA,QACA,aAAaC;AAAA,QACb,WAAWE;AAAA,QACX,oBAAAE;AAAA,QACA,6BAAAC;AAAA,QACA,WAAW;AAAA,UACT,UAAU;AAAA,UACV,WAAWX,EAAsBa,CAAY;AAAA,QAAA;AAAA,MAC/C;AAAA,IACF;AAAA,EAEJ,GAAG;AAAA,IACDR;AAAA,IACAC;AAAA,IACAG;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD;AAED,SAAO,gBAAAV,EAAC6B,GAAA,EAAK,SAASlB,GAAsB,SAAAP,EAAA,CAAkB;AAChE;"}
|
|
1
|
+
{"version":3,"file":"PayrollExecutionFlow.js","sources":["../../../../src/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { createMachine } from 'robot3'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { ConfirmWireDetailsComponentType } from '../ConfirmWireDetails/ConfirmWireDetails'\nimport {\n PayrollConfigurationContextual,\n PayrollOverviewContextual,\n SaveAndExitCta,\n type PayrollFlowContextInterface,\n} from '../PayrollFlow/PayrollFlowComponents'\nimport {\n payrollExecutionMachine,\n getPayrollExecutionBreadcrumbsNodes,\n} from './payrollExecutionMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport type { FlowBreadcrumb } from '@/components/Common/FlowBreadcrumbs/FlowBreadcrumbsTypes'\nimport { buildBreadcrumbs, updateBreadcrumbs } from '@/helpers/breadcrumbHelpers'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { EventType } from '@/shared/constants'\n\nconst EMPTY_BREADCRUMBS: FlowBreadcrumb[] = []\n\n/**\n * Entry point for {@link PayrollExecutionFlow}. Determines which screen the flow renders first.\n *\n * @public\n */\nexport type PayrollExecutionInitialState = 'configuration' | 'overview'\n\n/**\n * Props for {@link PayrollExecutionFlow}.\n *\n * @public\n */\nexport interface PayrollExecutionFlowProps {\n /** The associated company identifier. */\n companyId: string\n /**\n * The identifier of the payroll to execute. The payroll must already exist (e.g. created by a\n * prior creation step or by the standard `PayrollFlow` selection).\n */\n payrollId: string\n /** Event handler that receives the `RUN_PAYROLL_*` events emitted during the flow. */\n onEvent: OnEventType<EventType, unknown>\n /** Optional pay period metadata used to seed breadcrumb labels and date context. */\n initialPayPeriod?: PayrollPayPeriodType\n /**\n * When true, surfaces dismissal-specific copy and breadcrumbs (used by `Payroll.DismissalFlow`).\n * Defaults to `false`.\n */\n isDismissalPayroll?: boolean\n /** Optional flag to show or hide reimbursement fields throughout the flow. Defaults to `true`. */\n withReimbursements?: boolean\n /** Optional custom component to replace the default wire details confirmation UI. */\n ConfirmWireDetailsComponent?: ConfirmWireDetailsComponentType\n /**\n * Where the flow starts. Use `'overview'` when you want to drop the user directly on the review\n * screen (e.g. resuming an already-calculated payroll). Defaults to `'configuration'`.\n */\n initialState?: PayrollExecutionInitialState\n}\n\n/**\n * Props for the flow-internal {@link PayrollExecutionInternalFlow}, which layers flow-injected\n * prefix breadcrumbs on top of the public {@link PayrollExecutionFlowProps}.\n *\n * @internal\n */\nexport interface PayrollExecutionInternalFlowProps extends PayrollExecutionFlowProps {\n /**\n * Breadcrumbs prepended to the flow's own breadcrumb trail. Set by a parent flow (e.g. an\n * off-cycle creation step) so the breadcrumb history remains coherent across the handoff.\n */\n prefixBreadcrumbs?: FlowBreadcrumb[]\n}\n\nconst INITIAL_COMPONENT_MAP = {\n configuration: PayrollConfigurationContextual,\n overview: PayrollOverviewContextual,\n} as const\n\nconst INITIAL_NAMESPACE_MAP = {\n configuration: 'Payroll.PayrollConfiguration' as const,\n overview: 'Payroll.PayrollOverview' as const,\n} as const\n\n/**\n * Guided flow to configure, review, and submit a single payroll.\n *\n * @remarks\n * This is the inner flow that powers the back half of `Payroll.PayrollFlow`, and it is also reused\n * by the off-cycle, dismissal, and transition flows after they have created their respective\n * payrolls. Render it directly when you have built your own payroll-creation step and want to hand\n * the user off to the standard execution experience without re-implementing it. The flow ships\n * with breadcrumb navigation and the standard wire-confirmation UX.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/edit` | Fired when user chooses to edit payroll | — |\n * | `runPayroll/calculated` | Fired when payroll calculation completes | `{ payrollUuid, payPeriod?, alert? }` |\n * | `runPayroll/alreadyProcessed` | Fired when the payroll turns out to already be processed while configuring it; the flow moves to the review screen | `{ payrollId, alert?, payPeriod? }` |\n * | `runPayroll/employee/edit` | Fired when user opens an employee row to edit | `{ payrollId, employeeId, firstName, lastName }` |\n * | `runPayroll/employee/saved` | Fired when employee edits are saved | — |\n * | `runPayroll/employee/cancelled` | Fired when employee edits are cancelled | — |\n * | `runPayroll/submitting` | Fired when payroll submission begins | — |\n * | `runPayroll/submitted` | Fired when payroll is successfully submitted | Response from the Submit payroll endpoint |\n * | `runPayroll/processed` | Fired when payroll processing is completed | — |\n * | `runPayroll/processingFailed` | Fired when payroll processing fails | Error details |\n * | `runPayroll/cancelled` | Fired when a payroll is cancelled | Response from the Cancel payroll endpoint |\n * | `runPayroll/receipt/get` | Fired when user requests payroll receipt | `{ payrollId }` |\n * | `runPayroll/receipt/viewed` | Fired when the receipt screen is viewed | — |\n * | `runPayroll/pdfPaystub/viewed` | Fired when user views employee paystub PDF | `{ employeeId }` |\n * | `runPayroll/blockers/viewAll` | Fired when user opens the full blockers list | — |\n * | `payroll/saveAndExit` | Fired when user uses the save-and-exit CTA | — |\n *\n * @components\n * - {@link PayrollConfiguration}\n * - {@link PayrollOverview}\n * - {@link PayrollEditEmployee}\n * - {@link PayrollReceipts}\n * - {@link PayrollBlockerList}\n *\n * @param input - {@link PayrollExecutionFlowProps}\n * @returns The rendered execution flow.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { Payroll, type EventType } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <Payroll.PayrollExecutionFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * payrollId=\"0987fcea-7b59-4907-a301-f232b5aff508\"\n * onEvent={(eventType: EventType) => {\n * if (eventType === 'runPayroll/submitted') {\n * // Payroll submitted — navigate to your next screen\n * }\n * }}\n * />\n * )\n * }\n * ```\n */\nexport function PayrollExecutionFlow(props: PayrollExecutionFlowProps) {\n return <PayrollExecutionInternalFlow {...props} />\n}\n\n/**\n * Flow-internal entry point for {@link PayrollExecutionFlow} that additionally accepts\n * flow-injected `prefixBreadcrumbs`. Partners use {@link PayrollExecutionFlow}; our own parent\n * flows (off-cycle, dismissal, transition, and `PayrollFlow`) render this directly to prepend\n * their own breadcrumb trail.\n *\n * @internal\n */\nexport function PayrollExecutionInternalFlow({\n companyId,\n payrollId,\n onEvent,\n initialPayPeriod,\n isDismissalPayroll: isDismissal = false,\n withReimbursements = true,\n ConfirmWireDetailsComponent,\n prefixBreadcrumbs = EMPTY_BREADCRUMBS,\n initialState = 'configuration',\n}: PayrollExecutionInternalFlowProps) {\n const executionFlowMachine = useMemo(() => {\n const breadcrumbNodes = getPayrollExecutionBreadcrumbsNodes(isDismissal)\n const baseBreadcrumbs = buildBreadcrumbs(breadcrumbNodes)\n const displayOnlyPrefixes = prefixBreadcrumbs.map(({ onNavigate, ...rest }) => rest)\n const breadcrumbs = Object.fromEntries(\n Object.entries(baseBreadcrumbs).map(([stateKey, trail]) => [\n stateKey,\n [...displayOnlyPrefixes, ...trail],\n ]),\n )\n\n const initialBreadcrumbContext = updateBreadcrumbs(\n initialState,\n {\n header: {\n type: 'breadcrumbs' as const,\n breadcrumbs,\n cta: SaveAndExitCta,\n },\n },\n {\n startDate: initialPayPeriod?.startDate ?? '',\n endDate: initialPayPeriod?.endDate ?? '',\n },\n )\n\n return createMachine(\n initialState,\n payrollExecutionMachine,\n (initialContext: PayrollFlowContextInterface) => ({\n ...initialContext,\n ...initialBreadcrumbContext,\n component: INITIAL_COMPONENT_MAP[initialState],\n companyId,\n payrollUuid: payrollId,\n payPeriod: initialPayPeriod,\n withReimbursements,\n ConfirmWireDetailsComponent,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: INITIAL_NAMESPACE_MAP[initialState],\n },\n }),\n )\n }, [\n companyId,\n payrollId,\n isDismissal,\n withReimbursements,\n ConfirmWireDetailsComponent,\n prefixBreadcrumbs,\n initialState,\n ])\n\n return <Flow machine={executionFlowMachine} onEvent={onEvent} />\n}\n"],"names":["EMPTY_BREADCRUMBS","INITIAL_COMPONENT_MAP","PayrollConfigurationContextual","PayrollOverviewContextual","INITIAL_NAMESPACE_MAP","PayrollExecutionFlow","props","jsx","PayrollExecutionInternalFlow","companyId","payrollId","onEvent","initialPayPeriod","isDismissal","withReimbursements","ConfirmWireDetailsComponent","prefixBreadcrumbs","initialState","executionFlowMachine","useMemo","breadcrumbNodes","getPayrollExecutionBreadcrumbsNodes","baseBreadcrumbs","buildBreadcrumbs","displayOnlyPrefixes","onNavigate","rest","breadcrumbs","stateKey","trail","initialBreadcrumbContext","updateBreadcrumbs","SaveAndExitCta","createMachine","payrollExecutionMachine","initialContext","Flow"],"mappings":";;;;;;;AAoBA,MAAMA,IAAsC,CAAA,GAwDtCC,IAAwB;AAAA,EAC5B,eAAeC;AAAA,EACf,UAAUC;AACZ,GAEMC,IAAwB;AAAA,EAC5B,eAAe;AAAA,EACf,UAAU;AACZ;AA8DO,SAASC,EAAqBC,GAAkC;AACrE,SAAO,gBAAAC,EAACC,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AAAA,IACDR;AAAA,IACAC;AAAA,IACAG;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD;AAED,SAAO,gBAAAV,EAAC6B,GAAA,EAAK,SAASlB,GAAsB,SAAAP,EAAA,CAAkB;AAChE;"}
|
|
@@ -219,6 +219,10 @@ const s = L(), B = (e = !1) => ({
|
|
|
219
219
|
blockers: n(s("configuration"))
|
|
220
220
|
};
|
|
221
221
|
export {
|
|
222
|
+
D as alreadyProcessedTransition,
|
|
223
|
+
C as blockersViewAllTransition,
|
|
224
|
+
v as calculatedTransition,
|
|
225
|
+
E as employeeEditTransition,
|
|
222
226
|
B as getPayrollExecutionBreadcrumbsNodes,
|
|
223
227
|
K as payrollExecutionMachine
|
|
224
228
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payrollExecutionMachine.js","sources":["../../../../src/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.ts"],"sourcesContent":["import { transition, reduce, state, guard } from 'robot3'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayrollFlowAlert } from '../PayrollFlow/PayrollFlowComponents'\nimport {\n PayrollConfigurationContextual,\n PayrollOverviewContextual,\n PayrollEditEmployeeContextual,\n PayrollReceiptsContextual,\n PayrollBlockerContextual,\n type PayrollFlowContextInterface,\n} from '../PayrollFlow/PayrollFlowComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\nimport {\n hideBreadcrumb,\n patchBreadcrumbsHeader,\n updateBreadcrumbs,\n} from '@/helpers/breadcrumbHelpers'\nimport type {\n BreadcrumbNode,\n BreadcrumbNodes,\n} from '@/components/Common/FlowBreadcrumbs/FlowBreadcrumbsTypes'\nimport { createBreadcrumbNavigateTransition } from '@/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers'\n\ntype PayrollEventPayloads = {\n [componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT]: {\n employeeId: string\n firstName: string\n lastName: string\n }\n [componentEvents.RUN_PAYROLL_CALCULATED]: {\n payrollUuid: string\n alert?: PayrollFlowAlert\n payPeriod?: PayrollPayPeriodType\n }\n [componentEvents.RUN_PAYROLL_ALREADY_PROCESSED]: {\n payrollId: string\n alert?: PayrollFlowAlert\n payPeriod?: PayrollPayPeriodType\n }\n [componentEvents.BREADCRUMB_NAVIGATE]: {\n key: string\n onNavigate: (ctx: PayrollFlowContextInterface) => PayrollFlowContextInterface\n }\n [componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL]: undefined\n [componentEvents.RUN_PAYROLL_EDIT]: undefined\n}\n\nconst breadcrumbNavigateTransition =\n createBreadcrumbNavigateTransition<PayrollFlowContextInterface>()\n\ntype BreadcrumbNodeKeys = 'configuration' | 'overview' | 'editEmployee' | 'receipts' | 'blockers'\n\n/** @internal */\nexport const getPayrollExecutionBreadcrumbsNodes = (\n isDismissal: boolean = false,\n): BreadcrumbNodes => {\n const configLabel = isDismissal ? 'breadcrumbLabelDismissal' : 'breadcrumbLabel'\n\n return {\n configuration: {\n parent: null,\n item: {\n id: 'configuration',\n label: configLabel,\n namespace: 'Payroll.PayrollConfiguration',\n onNavigate: ((ctx: PayrollFlowContextInterface) => ({\n ...updateBreadcrumbs('configuration', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollConfigurationContextual,\n alerts: undefined,\n })) as (context: unknown) => unknown,\n },\n },\n overview: {\n parent: 'configuration',\n item: {\n id: 'overview',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollOverview',\n onNavigate: ((ctx: PayrollFlowContextInterface) => ({\n ...updateBreadcrumbs('overview', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n alerts: undefined,\n })) as (context: unknown) => unknown,\n },\n },\n editEmployee: {\n parent: 'configuration',\n item: {\n id: 'editEmployee',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollEditEmployee',\n },\n },\n receipts: {\n parent: 'overview',\n item: {\n id: 'receipts',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollReceipts',\n },\n },\n blockers: {\n parent: 'configuration',\n item: {\n id: 'blockers',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollBlocker',\n },\n },\n } satisfies Record<BreadcrumbNodeKeys, BreadcrumbNode>\n}\n\nconst calculatedTransition = transition(\n componentEvents.RUN_PAYROLL_CALCULATED,\n 'overview',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollEventPayloads, typeof componentEvents.RUN_PAYROLL_CALCULATED>,\n ): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('overview', ctx, {\n startDate: ev.payload.payPeriod?.startDate ?? '',\n endDate: ev.payload.payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n payPeriod: ev.payload.payPeriod ?? ctx.payPeriod,\n alerts: ev.payload.alert\n ? [\n ...(ctx.alerts ?? []).filter(a => a.alertKey !== 'progressSaved'),\n { ...ev.payload.alert, alertKey: 'progressSaved' as const },\n ]\n : ctx.alerts,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollOverview',\n },\n }\n },\n ),\n)\n\nconst alreadyProcessedTransition = transition(\n componentEvents.RUN_PAYROLL_ALREADY_PROCESSED,\n 'overview',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<\n PayrollEventPayloads,\n typeof componentEvents.RUN_PAYROLL_ALREADY_PROCESSED\n >,\n ): PayrollFlowContextInterface => {\n const payPeriod = ev.payload.payPeriod ?? ctx.payPeriod\n return {\n ...updateBreadcrumbs('overview', ctx, {\n startDate: payPeriod?.startDate ?? '',\n endDate: payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n payPeriod,\n alerts: ev.payload.alert\n ? [\n ...(ctx.alerts ?? []).filter(a => a.alertKey !== 'alreadyProcessed'),\n { ...ev.payload.alert, alertKey: 'alreadyProcessed' as const },\n ]\n : ctx.alerts,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollOverview',\n },\n }\n },\n ),\n)\n\nconst employeeEditTransition = transition(\n componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT,\n 'editEmployee',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollEventPayloads, typeof componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT>,\n ): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('editEmployee', ctx, {\n firstName: ev.payload.firstName,\n lastName: ev.payload.lastName,\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollEditEmployeeContextual,\n employeeId: ev.payload.employeeId,\n firstName: ev.payload.firstName,\n lastName: ev.payload.lastName,\n ctaConfig: null,\n }\n },\n ),\n)\n\nconst blockersViewAllTransition = transition(\n componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL,\n 'blockers',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('blockers', ctx),\n component: PayrollBlockerContextual,\n }\n }),\n)\n\nconst notSubmitted = (ctx: PayrollFlowContextInterface) => !ctx.hasPayrollSubmissionStarted\n\nconst editPayrollTransition = transition(\n componentEvents.RUN_PAYROLL_EDIT,\n 'configuration',\n guard(notSubmitted),\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('configuration', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollConfigurationContextual,\n alerts: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollConfiguration',\n },\n }\n }),\n)\n\nconst payrollSubmittingTransition = transition(\n componentEvents.RUN_PAYROLL_SUBMITTING,\n 'overview',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...hideBreadcrumb('configuration', ctx),\n hasPayrollSubmissionStarted: true,\n })),\n)\n\nconst receiptGetTransition = transition(\n componentEvents.RUN_PAYROLL_RECEIPT_GET,\n 'receipts',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...updateBreadcrumbs('receipts', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollReceiptsContextual,\n alerts: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollReceipts',\n },\n })),\n)\n\nconst employeeSavedTransition = transition(\n componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED,\n 'configuration',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: 'configuration' }),\n component: PayrollConfigurationContextual,\n employeeId: undefined,\n firstName: undefined,\n lastName: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollConfiguration',\n },\n })),\n)\n\nconst employeeCancelledTransition = transition(\n componentEvents.RUN_PAYROLL_EMPLOYEE_CANCELLED,\n 'configuration',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: 'configuration' }),\n component: PayrollConfigurationContextual,\n employeeId: undefined,\n firstName: undefined,\n lastName: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollConfiguration',\n },\n })),\n)\n\n/** @internal */\nexport const payrollExecutionMachine = {\n configuration: state<MachineTransition>(\n breadcrumbNavigateTransition('configuration'),\n calculatedTransition,\n alreadyProcessedTransition,\n employeeEditTransition,\n blockersViewAllTransition,\n ),\n overview: state<MachineTransition>(\n breadcrumbNavigateTransition('configuration', notSubmitted),\n payrollSubmittingTransition,\n editPayrollTransition,\n receiptGetTransition,\n ),\n editEmployee: state<MachineTransition>(\n breadcrumbNavigateTransition('configuration'),\n employeeSavedTransition,\n employeeCancelledTransition,\n ),\n receipts: state<MachineTransition>(breadcrumbNavigateTransition('configuration')),\n blockers: state<MachineTransition>(breadcrumbNavigateTransition('configuration')),\n}\n"],"names":["breadcrumbNavigateTransition","createBreadcrumbNavigateTransition","getPayrollExecutionBreadcrumbsNodes","isDismissal","ctx","updateBreadcrumbs","PayrollConfigurationContextual","PayrollOverviewContextual","calculatedTransition","transition","componentEvents","reduce","ev","a","alreadyProcessedTransition","payPeriod","employeeEditTransition","PayrollEditEmployeeContextual","blockersViewAllTransition","PayrollBlockerContextual","notSubmitted","editPayrollTransition","guard","payrollSubmittingTransition","hideBreadcrumb","receiptGetTransition","PayrollReceiptsContextual","employeeSavedTransition","patchBreadcrumbsHeader","employeeCancelledTransition","payrollExecutionMachine","state"],"mappings":";;;;;AAgDA,MAAMA,IACJC,EAAA,GAKWC,IAAsC,CACjDC,IAAuB,QAIhB;AAAA,EACL,eAAe;AAAA,IACb,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAPcA,IAAc,6BAA6B;AAAA,MAQzD,WAAW;AAAA,MACX,aAAa,CAACC,OAAsC;AAAA,QAClD,GAAGC,EAAkB,iBAAiBD,GAAK;AAAA,UACzC,WAAWA,EAAI,WAAW,aAAa;AAAA,UACvC,SAASA,EAAI,WAAW,WAAW;AAAA,QAAA,CACpC;AAAA,QACD,WAAWE;AAAA,QACX,QAAQ;AAAA,MAAA;AAAA,IACV;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,MACX,aAAa,CAACF,OAAsC;AAAA,QAClD,GAAGC,EAAkB,YAAYD,GAAK;AAAA,UACpC,WAAWA,EAAI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,IACvE,WAAWE;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,IAAA;AAAA,EACb,EACA;AACJ,GAGawB,IAA0B;AAAA,EACrC,eAAeC;AAAA,IACb/B,EAA6B,eAAe;AAAA,IAC5CQ;AAAA,IACAM;AAAA,IACAE;AAAA,IACAE;AAAA,EAAA;AAAA,EAEF,UAAUa;AAAA,IACR/B,EAA6B,iBAAiBoB,CAAY;AAAA,IAC1DG;AAAA,IACAF;AAAA,IACAI;AAAA,EAAA;AAAA,EAEF,cAAcM;AAAA,IACZ/B,EAA6B,eAAe;AAAA,IAC5C2B;AAAA,IACAE;AAAA,EAAA;AAAA,EAEF,UAAUE,EAAyB/B,EAA6B,eAAe,CAAC;AAAA,EAChF,UAAU+B,EAAyB/B,EAA6B,eAAe,CAAC;AAClF;"}
|
|
1
|
+
{"version":3,"file":"payrollExecutionMachine.js","sources":["../../../../src/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.ts"],"sourcesContent":["import { transition, reduce, state, guard } from 'robot3'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayrollFlowAlert } from '../PayrollFlow/PayrollFlowComponents'\nimport {\n PayrollConfigurationContextual,\n PayrollOverviewContextual,\n PayrollEditEmployeeContextual,\n PayrollReceiptsContextual,\n PayrollBlockerContextual,\n type PayrollFlowContextInterface,\n} from '../PayrollFlow/PayrollFlowComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\nimport {\n hideBreadcrumb,\n patchBreadcrumbsHeader,\n updateBreadcrumbs,\n} from '@/helpers/breadcrumbHelpers'\nimport type {\n BreadcrumbNode,\n BreadcrumbNodes,\n} from '@/components/Common/FlowBreadcrumbs/FlowBreadcrumbsTypes'\nimport { createBreadcrumbNavigateTransition } from '@/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers'\n\ntype PayrollEventPayloads = {\n [componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT]: {\n payrollId: string\n employeeId: string\n firstName: string\n lastName: string\n }\n [componentEvents.RUN_PAYROLL_CALCULATED]: {\n payrollUuid: string\n alert?: PayrollFlowAlert\n payPeriod?: PayrollPayPeriodType\n }\n [componentEvents.RUN_PAYROLL_ALREADY_PROCESSED]: {\n payrollId: string\n alert?: PayrollFlowAlert\n payPeriod?: PayrollPayPeriodType\n }\n [componentEvents.BREADCRUMB_NAVIGATE]: {\n key: string\n onNavigate: (ctx: PayrollFlowContextInterface) => PayrollFlowContextInterface\n }\n [componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL]: undefined\n [componentEvents.RUN_PAYROLL_EDIT]: undefined\n}\n\nconst breadcrumbNavigateTransition =\n createBreadcrumbNavigateTransition<PayrollFlowContextInterface>()\n\ntype BreadcrumbNodeKeys = 'configuration' | 'overview' | 'editEmployee' | 'receipts' | 'blockers'\n\n/** @internal */\nexport const getPayrollExecutionBreadcrumbsNodes = (\n isDismissal: boolean = false,\n): BreadcrumbNodes => {\n const configLabel = isDismissal ? 'breadcrumbLabelDismissal' : 'breadcrumbLabel'\n\n return {\n configuration: {\n parent: null,\n item: {\n id: 'configuration',\n label: configLabel,\n namespace: 'Payroll.PayrollConfiguration',\n onNavigate: ((ctx: PayrollFlowContextInterface) => ({\n ...updateBreadcrumbs('configuration', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollConfigurationContextual,\n alerts: undefined,\n })) as (context: unknown) => unknown,\n },\n },\n overview: {\n parent: 'configuration',\n item: {\n id: 'overview',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollOverview',\n onNavigate: ((ctx: PayrollFlowContextInterface) => ({\n ...updateBreadcrumbs('overview', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n alerts: undefined,\n })) as (context: unknown) => unknown,\n },\n },\n editEmployee: {\n parent: 'configuration',\n item: {\n id: 'editEmployee',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollEditEmployee',\n },\n },\n receipts: {\n parent: 'overview',\n item: {\n id: 'receipts',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollReceipts',\n },\n },\n blockers: {\n parent: 'configuration',\n item: {\n id: 'blockers',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollBlocker',\n },\n },\n } satisfies Record<BreadcrumbNodeKeys, BreadcrumbNode>\n}\n\n/** @internal */\nexport const calculatedTransition = transition(\n componentEvents.RUN_PAYROLL_CALCULATED,\n 'overview',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollEventPayloads, typeof componentEvents.RUN_PAYROLL_CALCULATED>,\n ): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('overview', ctx, {\n startDate: ev.payload.payPeriod?.startDate ?? '',\n endDate: ev.payload.payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n payPeriod: ev.payload.payPeriod ?? ctx.payPeriod,\n alerts: ev.payload.alert\n ? [\n ...(ctx.alerts ?? []).filter(a => a.alertKey !== 'progressSaved'),\n { ...ev.payload.alert, alertKey: 'progressSaved' as const },\n ]\n : ctx.alerts,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollOverview',\n },\n }\n },\n ),\n)\n\n/** @internal */\nexport const alreadyProcessedTransition = transition(\n componentEvents.RUN_PAYROLL_ALREADY_PROCESSED,\n 'overview',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<\n PayrollEventPayloads,\n typeof componentEvents.RUN_PAYROLL_ALREADY_PROCESSED\n >,\n ): PayrollFlowContextInterface => {\n const payPeriod = ev.payload.payPeriod ?? ctx.payPeriod\n return {\n ...updateBreadcrumbs('overview', ctx, {\n startDate: payPeriod?.startDate ?? '',\n endDate: payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n payPeriod,\n alerts: ev.payload.alert\n ? [\n ...(ctx.alerts ?? []).filter(a => a.alertKey !== 'alreadyProcessed'),\n { ...ev.payload.alert, alertKey: 'alreadyProcessed' as const },\n ]\n : ctx.alerts,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollOverview',\n },\n }\n },\n ),\n)\n\n/** @internal */\nexport const employeeEditTransition = transition(\n componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT,\n 'editEmployee',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollEventPayloads, typeof componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT>,\n ): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('editEmployee', ctx, {\n firstName: ev.payload.firstName,\n lastName: ev.payload.lastName,\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollEditEmployeeContextual,\n employeeId: ev.payload.employeeId,\n firstName: ev.payload.firstName,\n lastName: ev.payload.lastName,\n ctaConfig: null,\n }\n },\n ),\n)\n\n/** @internal */\nexport const blockersViewAllTransition = transition(\n componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL,\n 'blockers',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('blockers', ctx),\n component: PayrollBlockerContextual,\n }\n }),\n)\n\nconst notSubmitted = (ctx: PayrollFlowContextInterface) => !ctx.hasPayrollSubmissionStarted\n\nconst editPayrollTransition = transition(\n componentEvents.RUN_PAYROLL_EDIT,\n 'configuration',\n guard(notSubmitted),\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => {\n return {\n ...updateBreadcrumbs('configuration', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollConfigurationContextual,\n alerts: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollConfiguration',\n },\n }\n }),\n)\n\nconst payrollSubmittingTransition = transition(\n componentEvents.RUN_PAYROLL_SUBMITTING,\n 'overview',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...hideBreadcrumb('configuration', ctx),\n hasPayrollSubmissionStarted: true,\n })),\n)\n\nconst receiptGetTransition = transition(\n componentEvents.RUN_PAYROLL_RECEIPT_GET,\n 'receipts',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...updateBreadcrumbs('receipts', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollReceiptsContextual,\n alerts: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollReceipts',\n },\n })),\n)\n\nconst employeeSavedTransition = transition(\n componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED,\n 'configuration',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: 'configuration' }),\n component: PayrollConfigurationContextual,\n employeeId: undefined,\n firstName: undefined,\n lastName: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollConfiguration',\n },\n })),\n)\n\nconst employeeCancelledTransition = transition(\n componentEvents.RUN_PAYROLL_EMPLOYEE_CANCELLED,\n 'configuration',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: 'configuration' }),\n component: PayrollConfigurationContextual,\n employeeId: undefined,\n firstName: undefined,\n lastName: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollConfiguration',\n },\n })),\n)\n\n/** @internal */\nexport const payrollExecutionMachine = {\n configuration: state<MachineTransition>(\n breadcrumbNavigateTransition('configuration'),\n calculatedTransition,\n alreadyProcessedTransition,\n employeeEditTransition,\n blockersViewAllTransition,\n ),\n overview: state<MachineTransition>(\n breadcrumbNavigateTransition('configuration', notSubmitted),\n payrollSubmittingTransition,\n editPayrollTransition,\n receiptGetTransition,\n ),\n editEmployee: state<MachineTransition>(\n breadcrumbNavigateTransition('configuration'),\n employeeSavedTransition,\n employeeCancelledTransition,\n ),\n receipts: state<MachineTransition>(breadcrumbNavigateTransition('configuration')),\n blockers: state<MachineTransition>(breadcrumbNavigateTransition('configuration')),\n}\n"],"names":["breadcrumbNavigateTransition","createBreadcrumbNavigateTransition","getPayrollExecutionBreadcrumbsNodes","isDismissal","ctx","updateBreadcrumbs","PayrollConfigurationContextual","PayrollOverviewContextual","calculatedTransition","transition","componentEvents","reduce","ev","a","alreadyProcessedTransition","payPeriod","employeeEditTransition","PayrollEditEmployeeContextual","blockersViewAllTransition","PayrollBlockerContextual","notSubmitted","editPayrollTransition","guard","payrollSubmittingTransition","hideBreadcrumb","receiptGetTransition","PayrollReceiptsContextual","employeeSavedTransition","patchBreadcrumbsHeader","employeeCancelledTransition","payrollExecutionMachine","state"],"mappings":";;;;;AAiDA,MAAMA,IACJC,EAAA,GAKWC,IAAsC,CACjDC,IAAuB,QAIhB;AAAA,EACL,eAAe;AAAA,IACb,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAPcA,IAAc,6BAA6B;AAAA,MAQzD,WAAW;AAAA,MACX,aAAa,CAACC,OAAsC;AAAA,QAClD,GAAGC,EAAkB,iBAAiBD,GAAK;AAAA,UACzC,WAAWA,EAAI,WAAW,aAAa;AAAA,UACvC,SAASA,EAAI,WAAW,WAAW;AAAA,QAAA,CACpC;AAAA,QACD,WAAWE;AAAA,QACX,QAAQ;AAAA,MAAA;AAAA,IACV;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MAC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CC,EAAgB;AAAA,EAChB;AAAA,EACAC,EAAO,CAACP,OAAmE;AAAA,IACzE,GAAGwB,EAAuBxB,GAAK,EAAE,qBAAqB,iBAAiB;AAAA,IACvE,WAAWE;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,IAAA;AAAA,EACb,EACA;AACJ,GAGawB,IAA0B;AAAA,EACrC,eAAeC;AAAA,IACb/B,EAA6B,eAAe;AAAA,IAC5CQ;AAAA,IACAM;AAAA,IACAE;AAAA,IACAE;AAAA,EAAA;AAAA,EAEF,UAAUa;AAAA,IACR/B,EAA6B,iBAAiBoB,CAAY;AAAA,IAC1DG;AAAA,IACAF;AAAA,IACAI;AAAA,EAAA;AAAA,EAEF,cAAcM;AAAA,IACZ/B,EAA6B,eAAe;AAAA,IAC5C2B;AAAA,IACAE;AAAA,EAAA;AAAA,EAEF,UAAUE,EAAyB/B,EAA6B,eAAe,CAAC;AAAA,EAChF,UAAU+B,EAAyB/B,EAA6B,eAAe,CAAC;AAClF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayrollFlow.js","sources":["../../../../src/components/Payroll/PayrollFlow/PayrollFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { payrollFlowBreadcrumbsNodes, payrollFlowMachine } from './payrollStateMachine'\nimport type { PayrollFlowProps } from './PayrollFlowComponents'\nimport {\n SaveAndExitCta,\n PayrollLandingContextual,\n type PayrollFlowContextInterface,\n} from './PayrollFlowComponents'\nimport { Flow } from '@/components/Flow/Flow'\nimport { buildBreadcrumbs } from '@/helpers/breadcrumbHelpers'\n\n/**\n * Hub for running and managing all payrolls across a company's pay schedules.\n *\n * @remarks\n * Renders the payroll landing page and orchestrates the full run-payroll experience: selecting a payroll, configuring earnings and reimbursements, reviewing totals, submitting, and viewing receipts. Off-cycle, transition, and edit-employee steps are reachable from the same flow.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/selected` | A payroll is selected to run | `{ payrollId: string }` |\n * | `payroll/review` | A calculated payroll is opened for review | `{ payrollId: string }` |\n * | `runPayroll/calculated` | Payroll calculations complete | — |\n * | `runPayroll/edit` | The user returns to configuration to make changes | — |\n * | `runPayroll/employee/edit` | An employee row is opened for editing | `{ employeeId: string, firstName: string, lastName: string }` |\n * | `runPayroll/employee/saved` | Employee payroll changes are saved | `{ payrollPrepared: object, employee: object }` |\n * | `runPayroll/employee/cancelled` | Employee editing is cancelled | — |\n * | `runPayroll/submitted` | Payroll is successfully submitted | Response from the submit payroll endpoint |\n * | `runPayroll/processed` | Payroll processing completes | — |\n * | `runPayroll/processingFailed` | Payroll processing fails | Error details |\n * | `runPayroll/cancelled` | A submitted payroll is cancelled | `{ payrollId: string, result: object }` |\n * | `runPayroll/summary/viewed` | The summary screen is opened | `{ payrollId: string }` |\n * | `runPayroll/receipt/viewed` | The receipt screen is opened | `{ payrollId: string }` |\n * | `runPayroll/offCycle/start` | The user starts an off-cycle payroll | — |\n * | `transition/runPayroll` | The user starts a pending transition payroll | — |\n * | `payroll/saveAndExit` | The user clicks Save and Exit | — |\n *\n * @components\n * - {@link PayrollLanding}\n * - {@link PayrollExecutionFlow}\n * - {@link OffCycleFlow}\n * - {@link TransitionFlow}\n * - {@link PayrollBlockerList}\n * - {@link PayrollOverview}\n * - {@link PayrollReceipts}\n *\n * @param props - {@link PayrollFlowProps} with the company, optional reimbursements toggle, optional wire-details override, and event handler.\n * @returns The composed payroll flow.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { Payroll } from '@gusto/embedded-react-sdk'\n *\n * function RunPayrollPage() {\n * return <Payroll.PayrollFlow companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\" onEvent={() => {}} />\n * }\n * ```\n */\nexport const PayrollFlow = ({\n companyId,\n onEvent,\n withReimbursements = true,\n withOffcyclePayroll = true,\n ConfirmWireDetailsComponent,\n}: PayrollFlowProps) => {\n const payrollFlow = useMemo(\n () =>\n createMachine(\n 'landing',\n payrollFlowMachine,\n (initialContext: PayrollFlowContextInterface) => ({\n ...initialContext,\n component: PayrollLandingContextual,\n companyId,\n header: {\n type: 'breadcrumbs' as const,\n breadcrumbs: buildBreadcrumbs(payrollFlowBreadcrumbsNodes),\n cta: SaveAndExitCta,\n },\n withReimbursements,\n withOffcyclePayroll,\n ConfirmWireDetailsComponent,\n }),\n ),\n [companyId, withReimbursements, withOffcyclePayroll, ConfirmWireDetailsComponent],\n )\n\n return <Flow machine={payrollFlow} onEvent={onEvent} />\n}\n"],"names":["PayrollFlow","companyId","onEvent","withReimbursements","withOffcyclePayroll","ConfirmWireDetailsComponent","payrollFlow","useMemo","createMachine","payrollFlowMachine","initialContext","PayrollLandingContextual","buildBreadcrumbs","payrollFlowBreadcrumbsNodes","SaveAndExitCta","jsx","Flow"],"mappings":";;;;;;;AA4DO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,qBAAAC,IAAsB;AAAA,EACtB,6BAAAC;AACF,MAAwB;AACtB,QAAMC,IAAcC;AAAA,IAClB,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAAiD;AAAA,QAChD,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAAV;AAAA,QACA,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,aAAaW,EAAiBC,CAA2B;AAAA,UACzD,KAAKC;AAAA,QAAA;AAAA,QAEP,oBAAAX;AAAA,QACA,qBAAAC;AAAA,QACA,6BAAAC;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACJ,GAAWE,GAAoBC,GAAqBC,CAA2B;AAAA,EAAA;AAGlF,SAAO,gBAAAU,EAACC,GAAA,EAAK,SAASV,GAAa,SAAAJ,EAAA,CAAkB;AACvD;"}
|
|
1
|
+
{"version":3,"file":"PayrollFlow.js","sources":["../../../../src/components/Payroll/PayrollFlow/PayrollFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { payrollFlowBreadcrumbsNodes, payrollFlowMachine } from './payrollStateMachine'\nimport type { PayrollFlowProps } from './PayrollFlowComponents'\nimport {\n SaveAndExitCta,\n PayrollLandingContextual,\n type PayrollFlowContextInterface,\n} from './PayrollFlowComponents'\nimport { Flow } from '@/components/Flow/Flow'\nimport { buildBreadcrumbs } from '@/helpers/breadcrumbHelpers'\n\n/**\n * Hub for running and managing all payrolls across a company's pay schedules.\n *\n * @remarks\n * Renders the payroll landing page and orchestrates the full run-payroll experience: selecting a payroll, configuring earnings and reimbursements, reviewing totals, submitting, and viewing receipts. Off-cycle, transition, and edit-employee steps are reachable from the same flow.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/selected` | A payroll is selected to run | `{ payrollId: string }` |\n * | `payroll/review` | A calculated payroll is opened for review | `{ payrollId: string }` |\n * | `runPayroll/calculated` | Payroll calculations complete | — |\n * | `runPayroll/edit` | The user returns to configuration to make changes | — |\n * | `runPayroll/employee/edit` | An employee row is opened for editing | `{ payrollId: string, employeeId: string, firstName: string, lastName: string }` |\n * | `runPayroll/employee/saved` | Employee payroll changes are saved | `{ payrollPrepared: object, employee: object }` |\n * | `runPayroll/employee/cancelled` | Employee editing is cancelled | — |\n * | `runPayroll/submitted` | Payroll is successfully submitted | Response from the submit payroll endpoint |\n * | `runPayroll/processed` | Payroll processing completes | — |\n * | `runPayroll/processingFailed` | Payroll processing fails | Error details |\n * | `runPayroll/cancelled` | A submitted payroll is cancelled | `{ payrollId: string, result: object }` |\n * | `runPayroll/summary/viewed` | The summary screen is opened | `{ payrollId: string }` |\n * | `runPayroll/receipt/viewed` | The receipt screen is opened | `{ payrollId: string }` |\n * | `runPayroll/offCycle/start` | The user starts an off-cycle payroll | — |\n * | `transition/runPayroll` | The user starts a pending transition payroll | — |\n * | `payroll/saveAndExit` | The user clicks Save and Exit | — |\n *\n * @components\n * - {@link PayrollLanding}\n * - {@link PayrollExecutionFlow}\n * - {@link OffCycleFlow}\n * - {@link TransitionFlow}\n * - {@link PayrollBlockerList}\n * - {@link PayrollOverview}\n * - {@link PayrollReceipts}\n *\n * @param props - {@link PayrollFlowProps} with the company, optional reimbursements toggle, optional wire-details override, and event handler.\n * @returns The composed payroll flow.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { Payroll } from '@gusto/embedded-react-sdk'\n *\n * function RunPayrollPage() {\n * return <Payroll.PayrollFlow companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\" onEvent={() => {}} />\n * }\n * ```\n */\nexport const PayrollFlow = ({\n companyId,\n onEvent,\n withReimbursements = true,\n withOffcyclePayroll = true,\n ConfirmWireDetailsComponent,\n}: PayrollFlowProps) => {\n const payrollFlow = useMemo(\n () =>\n createMachine(\n 'landing',\n payrollFlowMachine,\n (initialContext: PayrollFlowContextInterface) => ({\n ...initialContext,\n component: PayrollLandingContextual,\n companyId,\n header: {\n type: 'breadcrumbs' as const,\n breadcrumbs: buildBreadcrumbs(payrollFlowBreadcrumbsNodes),\n cta: SaveAndExitCta,\n },\n withReimbursements,\n withOffcyclePayroll,\n ConfirmWireDetailsComponent,\n }),\n ),\n [companyId, withReimbursements, withOffcyclePayroll, ConfirmWireDetailsComponent],\n )\n\n return <Flow machine={payrollFlow} onEvent={onEvent} />\n}\n"],"names":["PayrollFlow","companyId","onEvent","withReimbursements","withOffcyclePayroll","ConfirmWireDetailsComponent","payrollFlow","useMemo","createMachine","payrollFlowMachine","initialContext","PayrollLandingContextual","buildBreadcrumbs","payrollFlowBreadcrumbsNodes","SaveAndExitCta","jsx","Flow"],"mappings":";;;;;;;AA4DO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,qBAAAC,IAAsB;AAAA,EACtB,6BAAAC;AACF,MAAwB;AACtB,QAAMC,IAAcC;AAAA,IAClB,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAAiD;AAAA,QAChD,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAAV;AAAA,QACA,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,aAAaW,EAAiBC,CAA2B;AAAA,UACzD,KAAKC;AAAA,QAAA;AAAA,QAEP,oBAAAX;AAAA,QACA,qBAAAC;AAAA,QACA,6BAAAC;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACJ,GAAWE,GAAoBC,GAAqBC,CAA2B;AAAA,EAAA;AAGlF,SAAO,gBAAAU,EAACC,GAAA,EAAK,SAASV,GAAa,SAAAJ,EAAA,CAAkB;AACvD;"}
|
|
@@ -1,42 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
processingStatuses: [T.Unprocessed],
|
|
17
|
-
endDate: F(),
|
|
18
|
-
payrollTypes: [
|
|
19
|
-
c.Regular,
|
|
20
|
-
c.OffCycle,
|
|
21
|
-
c.External
|
|
22
|
-
]
|
|
23
|
-
}), s = g(() => p.payrollList?.find((y) => {
|
|
24
|
-
const l = y.payPeriod;
|
|
25
|
-
return y.offCycleReason === "Transition from old pay schedule" && l?.startDate === e && l.endDate === o && l.payScheduleUuid === r;
|
|
26
|
-
})?.payrollUuid, [p, e, o, r]), i = `${a}:${e}:${o}:${r}`, u = m(s), d = m(i);
|
|
27
|
-
return d.current !== i && (d.current = i, u.current = void 0), s && (u.current = s), /* @__PURE__ */ P(
|
|
28
|
-
h,
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { TransitionFlow as s } from "../Transition/TransitionFlow.js";
|
|
3
|
+
import { useFlow as u } from "../../Flow/useFlow.js";
|
|
4
|
+
import { ensureRequired as t } from "../../../helpers/ensureRequired.js";
|
|
5
|
+
function f() {
|
|
6
|
+
const {
|
|
7
|
+
companyId: n,
|
|
8
|
+
transitionStartDate: o,
|
|
9
|
+
transitionEndDate: e,
|
|
10
|
+
transitionPayScheduleUuid: r,
|
|
11
|
+
withReimbursements: i,
|
|
12
|
+
onEvent: a
|
|
13
|
+
} = u();
|
|
14
|
+
return /* @__PURE__ */ m(
|
|
15
|
+
s,
|
|
29
16
|
{
|
|
30
|
-
companyId:
|
|
31
|
-
startDate:
|
|
32
|
-
endDate:
|
|
33
|
-
payScheduleUuid: r,
|
|
34
|
-
|
|
35
|
-
onEvent:
|
|
17
|
+
companyId: t(n),
|
|
18
|
+
startDate: t(o),
|
|
19
|
+
endDate: t(e),
|
|
20
|
+
payScheduleUuid: t(r),
|
|
21
|
+
withReimbursements: i,
|
|
22
|
+
onEvent: a
|
|
36
23
|
}
|
|
37
24
|
);
|
|
38
25
|
}
|
|
39
26
|
export {
|
|
40
|
-
|
|
27
|
+
f as TransitionFlowContextual
|
|
41
28
|
};
|
|
42
29
|
//# sourceMappingURL=TransitionFlowContextual.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransitionFlowContextual.js","sources":["../../../../src/components/Payroll/PayrollFlow/TransitionFlowContextual.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"TransitionFlowContextual.js","sources":["../../../../src/components/Payroll/PayrollFlow/TransitionFlowContextual.tsx"],"sourcesContent":["import { TransitionFlow } from '../Transition/TransitionFlow'\nimport type { PayrollFlowContextInterface } from './PayrollFlowComponents'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\n/**\n * Adapts the `PayrollFlow` machine context to {@link TransitionFlow}'s props. The resolve/resume\n * lookup that used to live here now lives inside `TransitionPayroll`, so this is a thin bridge.\n *\n * @internal\n */\nexport function TransitionFlowContextual() {\n const {\n companyId,\n transitionStartDate,\n transitionEndDate,\n transitionPayScheduleUuid,\n withReimbursements,\n onEvent,\n } = useFlow<PayrollFlowContextInterface>()\n\n return (\n <TransitionFlow\n companyId={ensureRequired(companyId)}\n startDate={ensureRequired(transitionStartDate)}\n endDate={ensureRequired(transitionEndDate)}\n payScheduleUuid={ensureRequired(transitionPayScheduleUuid)}\n withReimbursements={withReimbursements}\n onEvent={onEvent}\n />\n )\n}\n"],"names":["TransitionFlowContextual","companyId","transitionStartDate","transitionEndDate","transitionPayScheduleUuid","withReimbursements","onEvent","useFlow","jsx","TransitionFlow","ensureRequired"],"mappings":";;;;AAWO,SAASA,IAA2B;AACzC,QAAM;AAAA,IACJ,WAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,2BAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,SAAAC;AAAA,EAAA,IACEC,EAAA;AAEJ,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAeT,CAAS;AAAA,MACnC,WAAWS,EAAeR,CAAmB;AAAA,MAC7C,SAASQ,EAAeP,CAAiB;AAAA,MACzC,iBAAiBO,EAAeN,CAAyB;AAAA,MACzD,oBAAAC;AAAA,MACA,SAAAC;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|