@gusto/embedded-react-sdk 0.48.3 → 0.49.0
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 +45 -0
- package/README.md +8 -8
- package/dist/components/Base/Base.d.ts +11 -3
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/index.d.ts +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.js +21 -21
- package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
- package/dist/components/Common/Fields/NumberInputField/NumberInputField.js +16 -15
- package/dist/components/Common/Fields/NumberInputField/NumberInputField.js.map +1 -1
- package/dist/components/Common/FlowBreadcrumbs/FlowBreadcrumbs.d.ts +1 -0
- package/dist/components/Common/FlowBreadcrumbs/FlowBreadcrumbs.js.map +1 -1
- package/dist/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers.js.map +1 -1
- package/dist/components/Common/PaginationControl/PaginationControl.js +9 -8
- package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
- package/dist/components/Common/TaxInputs/TaxInputs.js +104 -102
- package/dist/components/Common/TaxInputs/TaxInputs.js.map +1 -1
- package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/Modal/Modal.module.scss.js +12 -12
- package/dist/components/Common/UI/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInput.js +87 -80
- package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInputTypes.d.ts +4 -0
- package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
- package/dist/components/Common/UI/Select/Select.js +28 -28
- package/dist/components/Common/UI/Select/Select.js.map +1 -1
- package/dist/components/Common/UI/Select/SelectTypes.d.ts +3 -2
- package/dist/components/Common/UI/Tabs/Tabs.js +9 -8
- package/dist/components/Common/UI/Tabs/Tabs.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.d.ts +1 -0
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.d.ts +4 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.d.ts +4 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/TitleSelect.js +9 -8
- package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccount.d.ts +3 -2
- package/dist/components/Company/BankAccount/BankAccount.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.d.ts +3 -3
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/BankAccountList.d.ts +3 -3
- package/dist/components/Company/BankAccount/BankAccountList/BankAccountList.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.d.ts +3 -3
- package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.d.ts +13 -2
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/index.d.ts +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentSigner.d.ts +6 -5
- package/dist/components/Company/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.d.ts +1 -0
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/DocumentSigner/assignSignatoryState.js +4 -6
- package/dist/components/Company/DocumentSigner/assignSignatoryState.js.map +1 -1
- package/dist/components/Company/DocumentSigner/index.d.ts +1 -1
- package/dist/components/Company/DocumentSigner/stateMachine.js +12 -18
- package/dist/components/Company/DocumentSigner/stateMachine.js.map +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.d.ts +15 -6
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +23 -21
- package/dist/components/Company/FederalTaxes/Form.js.map +1 -1
- package/dist/components/Company/FederalTaxes/index.d.ts +2 -0
- package/dist/components/Company/FederalTaxes/useFederalTaxes.d.ts +10 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/Industry.d.ts +5 -7
- package/dist/components/Company/Industry/Industry.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.d.ts +11 -4
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/index.d.ts +1 -0
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/Locations.d.ts +1 -0
- package/dist/components/Company/Locations/Locations.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +20 -20
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.module.scss.js +1 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.d.ts +2 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/Locations/stateMachine.js +4 -6
- package/dist/components/Company/Locations/stateMachine.js.map +1 -1
- package/dist/components/Company/OnboardingFlow/OnboardingFlow.d.ts +38 -1
- package/dist/components/Company/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Company/OnboardingFlow/OnboardingFlowComponents.d.ts +14 -3
- package/dist/components/Company/OnboardingFlow/OnboardingFlowComponents.js +30 -23
- package/dist/components/Company/OnboardingFlow/OnboardingFlowComponents.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.d.ts +10 -4
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.d.ts +4 -3
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/PayScheduleForm.js +6 -4
- package/dist/components/Company/PaySchedule/PayScheduleForm.js.map +1 -1
- package/dist/components/Company/PaySchedule/payScheduleStateMachine.js +10 -14
- package/dist/components/Company/PaySchedule/payScheduleStateMachine.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxes.d.ts +1 -0
- package/dist/components/Company/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +29 -25
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.d.ts +11 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +55 -54
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/applicableIf.d.ts +10 -0
- package/dist/components/Company/StateTaxes/StateTaxesForm/applicableIf.js +11 -0
- package/dist/components/Company/StateTaxes/StateTaxesForm/applicableIf.js.map +1 -0
- package/dist/components/Company/StateTaxes/StateTaxesForm/applicableIf.test.d.ts +1 -0
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/index.d.ts +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/rhfKey.js +2 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/rhfKey.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/StateTaxesList.d.ts +7 -2
- package/dist/components/Company/StateTaxes/StateTaxesList/StateTaxesList.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/index.d.ts +1 -1
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js +5 -7
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js.map +1 -1
- package/dist/components/Company/exports/companyOnboarding.d.ts +11 -11
- package/dist/components/Contractor/Address/Address.d.ts +14 -8
- package/dist/components/Contractor/Address/Address.js +83 -64
- package/dist/components/Contractor/Address/Address.js.map +1 -1
- package/dist/components/Contractor/Address/Address.module.scss.js +8 -0
- package/dist/components/Contractor/Address/Address.module.scss.js.map +1 -0
- package/dist/components/Contractor/Address/index.d.ts +1 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/contractorAddressSchema.d.ts +59 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/contractorAddressSchema.js +32 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/contractorAddressSchema.js.map +1 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/fields.d.ts +111 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/fields.js +26 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/fields.js.map +1 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/index.d.ts +6 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.d.ts +112 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js +133 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -0
- package/dist/components/Contractor/Address/types.d.ts +8 -0
- package/dist/components/Contractor/ContractorList/index.d.ts +4 -4
- package/dist/components/Contractor/ContractorList/index.js.map +1 -1
- package/dist/components/Contractor/Documents/DocumentsList/DocumentsList.d.ts +29 -0
- package/dist/components/Contractor/Documents/DocumentsList/DocumentsList.js +71 -0
- package/dist/components/Contractor/Documents/DocumentsList/DocumentsList.js.map +1 -0
- package/dist/components/Contractor/Documents/DocumentsList/index.d.ts +3 -0
- package/dist/components/Contractor/Documents/DocumentsList/useContractorDocumentsList/index.d.ts +2 -0
- package/dist/components/Contractor/Documents/DocumentsList/useContractorDocumentsList/useContractorDocumentsList.d.ts +59 -0
- package/dist/components/Contractor/Documents/DocumentsList/useContractorDocumentsList/useContractorDocumentsList.js +20 -0
- package/dist/components/Contractor/Documents/DocumentsList/useContractorDocumentsList/useContractorDocumentsList.js.map +1 -0
- package/dist/components/Contractor/Landing/Landing.d.ts +19 -0
- package/dist/components/Contractor/Landing/Landing.js +73 -0
- package/dist/components/Contractor/Landing/Landing.js.map +1 -0
- package/dist/components/Contractor/Landing/index.d.ts +2 -0
- package/dist/components/Contractor/NewHireReport/NewHireReport.d.ts +1 -0
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +7 -7
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.d.ts +20 -8
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.d.ts +4 -4
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.js.map +1 -1
- package/dist/components/Contractor/OnboardingSummary/OnboardingSummary.d.ts +23 -0
- package/dist/components/Contractor/OnboardingSummary/OnboardingSummary.js +36 -0
- package/dist/components/Contractor/OnboardingSummary/OnboardingSummary.js.map +1 -0
- package/dist/components/Contractor/OnboardingSummary/index.d.ts +2 -0
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.d.ts +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.d.ts +11 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js +59 -53
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +70 -91
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js +62 -56
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.d.ts +11 -2
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.d.ts +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.d.ts +7 -0
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js +54 -51
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatementPresentation.js +20 -22
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatementPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.d.ts +8 -0
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js +109 -102
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.d.ts +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js +86 -65
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js.map +1 -1
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.d.ts +8 -0
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js +79 -0
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js.map +1 -0
- package/dist/components/Contractor/Profile/ContractorProfile.d.ts +52 -10
- package/dist/components/Contractor/Profile/ContractorProfile.js +205 -31
- package/dist/components/Contractor/Profile/ContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/ContractorProfile.module.scss.js +8 -0
- package/dist/components/Contractor/Profile/ContractorProfile.module.scss.js.map +1 -0
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.d.ts +8 -0
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js +96 -0
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js.map +1 -0
- package/dist/components/Contractor/Profile/SelfOnboardingContractorProfile.d.ts +22 -0
- package/dist/components/Contractor/Profile/SelfOnboardingContractorProfile.js +40 -0
- package/dist/components/Contractor/Profile/SelfOnboardingContractorProfile.js.map +1 -0
- package/dist/components/Contractor/Profile/index.d.ts +1 -1
- package/dist/components/Contractor/Profile/shared/index.d.ts +2 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.d.ts +125 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.js +73 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.js.map +1 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.test.d.ts +1 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.d.ts +312 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.js +87 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.js.map +1 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/index.d.ts +6 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.d.ts +151 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +188 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -0
- package/dist/components/Contractor/Submit/Submit.d.ts +4 -4
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Contractor/exports/contractorOnboarding.d.ts +6 -3
- package/dist/components/Contractor/exports/contractorOnboarding.js +14 -8
- package/dist/components/Contractor/exports/contractorOnboarding.js.map +1 -1
- package/dist/components/Employee/Compensation/management/Compensation.d.ts +4 -7
- package/dist/components/Employee/Compensation/management/Compensation.js +1 -5
- package/dist/components/Employee/Compensation/management/Compensation.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationAddAnotherJobForm/CompensationAddAnotherJobForm.d.ts +1 -0
- package/dist/components/Employee/Compensation/management/CompensationAddAnotherJobForm/CompensationAddAnotherJobForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationAddJobForm/CompensationAddJobForm.d.ts +1 -0
- package/dist/components/Employee/Compensation/management/CompensationAddJobForm/CompensationAddJobForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationCard/CompensationCard.d.ts +1 -0
- package/dist/components/Employee/Compensation/management/CompensationCard/CompensationCard.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationEditForm/CompensationEditForm.d.ts +1 -0
- package/dist/components/Employee/Compensation/management/CompensationEditForm/CompensationEditForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +13 -10
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -1
- package/dist/components/Employee/Compensation/management/compensationStateMachine.js +23 -31
- package/dist/components/Employee/Compensation/management/compensationStateMachine.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/Compensation.d.ts +1 -0
- package/dist/components/Employee/Compensation/onboarding/Compensation.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.d.ts +1 -0
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/JobsList/JobsList.d.ts +3 -3
- package/dist/components/Employee/Compensation/onboarding/JobsList/JobsList.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/compensationStateMachine.js +20 -28
- package/dist/components/Employee/Compensation/onboarding/compensationStateMachine.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js +13 -10
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.d.ts +29 -4
- package/dist/components/Employee/Dashboard/Dashboard.js +1 -4
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Dashboard/DashboardFlow.d.ts +20 -14
- package/dist/components/Employee/Dashboard/DashboardFlow.js.map +1 -1
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js +78 -108
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
- package/dist/components/Employee/Deductions/management/Deductions.d.ts +4 -7
- package/dist/components/Employee/Deductions/management/Deductions.js +1 -5
- package/dist/components/Employee/Deductions/management/Deductions.js.map +1 -1
- package/dist/components/Employee/Deductions/management/DeductionsCard/DeductionsCard.d.ts +1 -0
- package/dist/components/Employee/Deductions/management/DeductionsCard/DeductionsCard.js.map +1 -1
- package/dist/components/Employee/Deductions/management/DeductionsEditForm/DeductionsEditForm.d.ts +4 -3
- package/dist/components/Employee/Deductions/management/DeductionsEditForm/DeductionsEditForm.js +1 -4
- package/dist/components/Employee/Deductions/management/DeductionsEditForm/DeductionsEditForm.js.map +1 -1
- package/dist/components/Employee/Deductions/management/deductionsStateMachine.js +17 -23
- package/dist/components/Employee/Deductions/management/deductionsStateMachine.js.map +1 -1
- package/dist/components/Employee/Deductions/onboarding/Deductions.d.ts +1 -0
- package/dist/components/Employee/Deductions/onboarding/Deductions.js.map +1 -1
- package/dist/components/Employee/Deductions/onboarding/stateMachine.js +25 -35
- package/dist/components/Employee/Deductions/onboarding/stateMachine.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/DeductionsForm/ChildSupportFormView.js +40 -37
- package/dist/components/Employee/Deductions/shared/DeductionsForm/ChildSupportFormView.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/DeductionsForm/DeductionsForm.js +1 -0
- package/dist/components/Employee/Deductions/shared/DeductionsForm/DeductionsForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.js.map +1 -1
- package/dist/components/Employee/Documents/management/DocumentManager.d.ts +19 -4
- package/dist/components/Employee/Documents/management/DocumentManager.js +4 -1
- package/dist/components/Employee/Documents/management/DocumentManager.js.map +1 -1
- package/dist/components/Employee/Documents/management/Documents.d.ts +4 -7
- package/dist/components/Employee/Documents/management/Documents.js +1 -5
- package/dist/components/Employee/Documents/management/Documents.js.map +1 -1
- package/dist/components/Employee/Documents/management/documentsStateMachine.js +5 -7
- package/dist/components/Employee/Documents/management/documentsStateMachine.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.d.ts +2 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.d.ts +8 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/EmploymentEligibility/EmploymentEligibility.d.ts +1 -0
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/EmploymentEligibility/EmploymentEligibility.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/I9SignatureForm/I9SignatureForm.d.ts +3 -2
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/I9SignatureForm/I9SignatureForm.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.d.ts +1 -4
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map +1 -1
- package/dist/components/Employee/Documents/shared/SignatureForm/SignatureForm.d.ts +3 -2
- package/dist/components/Employee/Documents/shared/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.d.ts +5 -8
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeList.d.ts +18 -3
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeList.js +21 -18
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeListView.d.ts +2 -1
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeListView.js +47 -46
- package/dist/components/Employee/EmployeeList/onboarding/EmployeeListView.js.map +1 -1
- package/dist/components/Employee/EmployeeList/shared/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +8 -2
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.d.ts +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js +5 -7
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/management/FederalTaxes.d.ts +4 -7
- package/dist/components/Employee/FederalTaxes/management/FederalTaxes.js +1 -5
- package/dist/components/Employee/FederalTaxes/management/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.d.ts +4 -5
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.js +1 -4
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/management/federalTaxesStateMachine.js +14 -20
- package/dist/components/Employee/FederalTaxes/management/federalTaxesStateMachine.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.d.ts +4 -3
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.js +1 -4
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddress.d.ts +7 -11
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js +1 -5
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressCard/HomeAddressCard.d.ts +1 -0
- package/dist/components/Employee/HomeAddress/management/HomeAddressCard/HomeAddressCard.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressEditForm.d.ts +7 -9
- package/dist/components/Employee/HomeAddress/management/HomeAddressEditForm.js +1 -4
- package/dist/components/Employee/HomeAddress/management/HomeAddressEditForm.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +2 -0
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/homeAddressStateMachine.js +8 -12
- package/dist/components/Employee/HomeAddress/management/homeAddressStateMachine.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
- package/dist/components/Employee/Landing/Landing.d.ts +10 -4
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/OnboardingExecutionFlow/OnboardingExecutionFlow.d.ts +19 -5
- package/dist/components/Employee/OnboardingExecutionFlow/OnboardingExecutionFlow.js.map +1 -1
- package/dist/components/Employee/OnboardingExecutionFlow/OnboardingExecutionFlowComponents.d.ts +1 -0
- package/dist/components/Employee/OnboardingExecutionFlow/OnboardingExecutionFlowComponents.js.map +1 -1
- package/dist/components/Employee/OnboardingExecutionFlow/onboardingExecutionStateMachine.js.map +1 -1
- package/dist/components/Employee/OnboardingFlow/OnboardingFlow.d.ts +32 -12
- package/dist/components/Employee/OnboardingFlow/OnboardingFlow.js +19 -17
- package/dist/components/Employee/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Employee/OnboardingFlow/OnboardingFlowComponents.js +23 -16
- package/dist/components/Employee/OnboardingFlow/OnboardingFlowComponents.js.map +1 -1
- package/dist/components/Employee/OnboardingFlow/onboardingStateMachine.js +11 -15
- package/dist/components/Employee/OnboardingFlow/onboardingStateMachine.js.map +1 -1
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.d.ts +10 -4
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/PaymentMethod.d.ts +3 -7
- package/dist/components/Employee/PaymentMethod/management/PaymentMethod.js +1 -5
- package/dist/components/Employee/PaymentMethod/management/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodBankForm.d.ts +1 -0
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodBankForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodCard.d.ts +1 -0
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodCard.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodComponents.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodSplitForm.d.ts +1 -0
- package/dist/components/Employee/PaymentMethod/management/PaymentMethodSplitForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/paymentMethodStateMachine.js +15 -21
- package/dist/components/Employee/PaymentMethod/management/paymentMethodStateMachine.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/onboarding/PaymentMethod.d.ts +4 -7
- package/dist/components/Employee/PaymentMethod/onboarding/PaymentMethod.js +1 -5
- package/dist/components/Employee/PaymentMethod/onboarding/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/onboarding/paymentMethodStateMachine.js +24 -36
- package/dist/components/Employee/PaymentMethod/onboarding/paymentMethodStateMachine.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js.map +1 -1
- package/dist/components/Employee/Profile/management/Profile.d.ts +5 -8
- package/dist/components/Employee/Profile/management/Profile.js +1 -5
- package/dist/components/Employee/Profile/management/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/management/ProfileCard/ProfileCard.d.ts +1 -0
- package/dist/components/Employee/Profile/management/ProfileCard/ProfileCard.js.map +1 -1
- package/dist/components/Employee/Profile/management/ProfileEditForm.d.ts +5 -6
- package/dist/components/Employee/Profile/management/ProfileEditForm.js +1 -4
- package/dist/components/Employee/Profile/management/ProfileEditForm.js.map +1 -1
- package/dist/components/Employee/Profile/management/profileStateMachine.js +14 -20
- package/dist/components/Employee/Profile/management/profileStateMachine.js.map +1 -1
- package/dist/components/Employee/Profile/onboarding/AdminProfile.js +55 -54
- package/dist/components/Employee/Profile/onboarding/AdminProfile.js.map +1 -1
- package/dist/components/Employee/Profile/onboarding/AdminProfile.module.scss.js +3 -5
- package/dist/components/Employee/Profile/onboarding/AdminProfile.module.scss.js.map +1 -1
- package/dist/components/Employee/Profile/onboarding/Profile.d.ts +11 -12
- package/dist/components/Employee/Profile/onboarding/Profile.js +1 -5
- package/dist/components/Employee/Profile/onboarding/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.d.ts +2 -2
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.d.ts +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.d.ts +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingFlow.d.ts +19 -5
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingFlow.js.map +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/selfOnboardingMachine.js +12 -18
- package/dist/components/Employee/SelfOnboardingFlow/selfOnboardingMachine.js.map +1 -1
- package/dist/components/Employee/StateTaxes/management/StateTaxes.d.ts +4 -9
- package/dist/components/Employee/StateTaxes/management/StateTaxes.js +1 -5
- package/dist/components/Employee/StateTaxes/management/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/management/StateTaxesCard/StateTaxesCard.d.ts +1 -0
- package/dist/components/Employee/StateTaxes/management/StateTaxesCard/StateTaxesCard.js.map +1 -1
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.d.ts +5 -8
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.js +1 -4
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.js.map +1 -1
- package/dist/components/Employee/StateTaxes/management/stateTaxesStateMachine.js +14 -20
- package/dist/components/Employee/StateTaxes/management/stateTaxesStateMachine.js.map +1 -1
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.d.ts +5 -8
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.js +1 -4
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +29 -29
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldProps.d.ts +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/useEmployeeStateTaxesForm.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.d.ts +1 -0
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlow.d.ts +16 -5
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlow.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlowComponents.d.ts +1 -1
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlowComponents.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationFlow/terminationStateMachine.js +5 -7
- package/dist/components/Employee/Terminations/TerminationFlow/terminationStateMachine.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.d.ts +1 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddress.d.ts +7 -11
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js +1 -5
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressCard/WorkAddressCard.d.ts +1 -0
- package/dist/components/Employee/WorkAddress/management/WorkAddressCard/WorkAddressCard.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressEditForm.d.ts +7 -9
- package/dist/components/Employee/WorkAddress/management/WorkAddressEditForm.js +1 -4
- package/dist/components/Employee/WorkAddress/management/WorkAddressEditForm.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +97 -95
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/workAddressStateMachine.js +8 -12
- package/dist/components/Employee/WorkAddress/management/workAddressStateMachine.js.map +1 -1
- package/dist/components/Employee/WorkAddress/shared/useEmployeeWorkAddressSummary/useEmployeeWorkAddressSummary.js.map +1 -1
- package/dist/components/Employee/exports/employeeOnboarding.d.ts +3 -3
- package/dist/components/Flow/Flow.js +1 -1
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.d.ts +1 -0
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.d.ts +1 -0
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequests.d.ts +26 -1
- package/dist/components/InformationRequests/InformationRequests.js.map +1 -1
- package/dist/components/InformationRequests/informationRequestsStateMachine.js +10 -14
- package/dist/components/InformationRequests/informationRequestsStateMachine.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.d.ts +3 -4
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js +2 -11
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.d.ts +0 -1
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.js +1 -0
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.js +11 -17
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/types.d.ts +1 -3
- package/dist/components/Payroll/Dismissal/DismissalFlow.d.ts +25 -1
- package/dist/components/Payroll/Dismissal/DismissalFlow.js.map +1 -1
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.d.ts +1 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/OffCycle/OffCycleFlow.d.ts +18 -4
- package/dist/components/Payroll/OffCycle/OffCycleFlow.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.d.ts +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.d.ts +1 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.js.map +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelection.d.ts +1 -0
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelection.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +21 -20
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.d.ts +2 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.d.ts +2 -2
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +28 -3
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +38 -46
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollExecutionFlowContextual.js +25 -24
- package/dist/components/Payroll/PayrollFlow/PayrollExecutionFlowContextual.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.d.ts +13 -3
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +2 -2
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js +34 -44
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.d.ts +1 -0
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
- package/dist/components/Payroll/PayrollLanding/PayrollLanding.d.ts +12 -2
- package/dist/components/Payroll/PayrollLanding/PayrollLanding.js.map +1 -1
- package/dist/components/Payroll/PayrollLanding/payrollLandingStateMachine.js +8 -10
- package/dist/components/Payroll/PayrollLanding/payrollLandingStateMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.d.ts +2 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.d.ts +1 -0
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +112 -112
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js +4 -6
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCases.d.ts +2 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCases.js +5 -9
- package/dist/components/Payroll/RecoveryCases/RecoveryCases.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesList/RecoveryCasesList.d.ts +0 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesList/RecoveryCasesList.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesResubmit/RecoveryCasesResubmit.d.ts +0 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesResubmit/RecoveryCasesResubmit.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/recoveryCasesStateMachine.js +10 -14
- package/dist/components/Payroll/RecoveryCases/recoveryCasesStateMachine.js.map +1 -1
- package/dist/components/Payroll/Transition/TransitionFlow.d.ts +27 -1
- package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.d.ts +1 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +8 -9
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/TimeOff/AddEmployeesHoliday/AddEmployeesHoliday.d.ts +2 -2
- package/dist/components/TimeOff/AddEmployeesHoliday/AddEmployeesHoliday.js.map +1 -1
- package/dist/components/TimeOff/AddEmployeesToPolicy/AddEmployeesToPolicy.d.ts +2 -1
- package/dist/components/TimeOff/AddEmployeesToPolicy/AddEmployeesToPolicy.js.map +1 -1
- package/dist/components/TimeOff/HolidayPolicyDetail/HolidayPolicyDetail.d.ts +1 -1
- package/dist/components/TimeOff/HolidayPolicyDetail/HolidayPolicyDetail.js.map +1 -1
- package/dist/components/TimeOff/HolidaySelectionForm/HolidaySelectionForm.d.ts +2 -2
- package/dist/components/TimeOff/HolidaySelectionForm/HolidaySelectionForm.js.map +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyList.d.ts +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyList.js.map +1 -1
- package/dist/components/TimeOff/PolicySettings/PolicySettings.d.ts +2 -1
- package/dist/components/TimeOff/PolicySettings/PolicySettings.js.map +1 -1
- package/dist/components/TimeOff/PolicyTypeSelector/PolicyTypeSelector.d.ts +1 -0
- package/dist/components/TimeOff/PolicyTypeSelector/PolicyTypeSelector.js.map +1 -1
- package/dist/components/TimeOff/TimeOffFlow/TimeOffFlow.d.ts +28 -1
- package/dist/components/TimeOff/TimeOffFlow/TimeOffFlow.js.map +1 -1
- package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.d.ts +1 -1
- package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.js.map +1 -1
- package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js +128 -174
- package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.d.ts +1 -0
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js +9 -7
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.d.ts +2 -1
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js.map +1 -1
- package/dist/components/TimeOff/ViewHolidayEmployees/ViewHolidayEmployees.d.ts +2 -1
- package/dist/components/TimeOff/ViewHolidayEmployees/ViewHolidayEmployees.js.map +1 -1
- package/dist/components/TimeOff/ViewHolidayPolicyDetails/ViewHolidayPolicyDetails.d.ts +2 -2
- package/dist/components/TimeOff/ViewHolidayPolicyDetails/ViewHolidayPolicyDetails.js.map +1 -1
- package/dist/components/TimeOff/ViewHolidaySchedule/ViewHolidaySchedule.d.ts +2 -2
- package/dist/components/TimeOff/ViewHolidaySchedule/ViewHolidaySchedule.js.map +1 -1
- package/dist/components/index.d.ts +9 -0
- package/dist/contexts/ThemeProvider/types.d.ts +19 -0
- package/dist/i18n/I18n.js +5 -2
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.AssignSignatory.json.js +1 -1
- package/dist/i18n/en/Company.FederalTaxes.json.js +27 -23
- package/dist/i18n/en/Company.FederalTaxes.json.js.map +1 -1
- package/dist/i18n/en/Company.PaySchedule.json.js +1 -1
- package/dist/i18n/en/Contractor.Address.json.js +13 -13
- package/dist/i18n/en/Contractor.DocumentsList.json.js +28 -0
- package/dist/i18n/en/Contractor.DocumentsList.json.js.map +1 -0
- package/dist/i18n/en/Contractor.Landing.json.js +18 -0
- package/dist/i18n/en/Contractor.Landing.json.js.map +1 -0
- package/dist/i18n/en/Contractor.NewHireReport.json.js +12 -10
- package/dist/i18n/en/Contractor.NewHireReport.json.js.map +1 -1
- package/dist/i18n/en/Contractor.OnboardingSummary.json.js +12 -0
- package/dist/i18n/en/Contractor.OnboardingSummary.json.js.map +1 -0
- package/dist/i18n/en/Contractor.Payments.CreatePayment.json.js +13 -13
- package/dist/i18n/en/Contractor.Payments.PaymentHistory.json.js +10 -6
- package/dist/i18n/en/Contractor.Payments.PaymentHistory.json.js.map +1 -1
- package/dist/i18n/en/Contractor.Profile.json.js +8 -6
- package/dist/i18n/en/Contractor.Profile.json.js.map +1 -1
- package/dist/i18n/en/Employee.Compensation.json.js +56 -50
- package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
- package/dist/i18n/en/Employee.DeductionsForm.json.js +8 -8
- package/dist/i18n/en/Employee.EmploymentEligibility.json.js +1 -1
- package/dist/i18n/en/Employee.Management.Compensation.json.js +48 -42
- package/dist/i18n/en/Employee.Management.Compensation.json.js.map +1 -1
- package/dist/i18n/en/Employee.Management.HomeAddress.json.js +1 -1
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +40 -38
- package/dist/i18n/en/Payroll.PayrollOverview.json.js.map +1 -1
- package/dist/i18n/en/common.json.d.ts +1 -0
- package/dist/i18n/en/common.json.js +34 -32
- package/dist/i18n/en/common.json.js.map +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +239 -205
- package/dist/index.js.map +1 -1
- package/dist/models/external.d.ts +293 -0
- package/dist/partner-hook-utils/form/FormFieldsMetadataContext.js +3 -3
- package/dist/partner-hook-utils/form/buildFormSchema.d.ts +14 -1
- package/dist/partner-hook-utils/form/buildFormSchema.js +41 -40
- package/dist/partner-hook-utils/form/buildFormSchema.js.map +1 -1
- package/dist/partner-hook-utils/form/composeSubmitHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SelectHookField.d.ts +5 -2
- package/dist/partner-hook-utils/form/fields/SelectHookField.js.map +1 -1
- package/dist/shared/constants.d.ts +10 -1
- package/dist/shared/constants.js +9 -5
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/Helpers.d.ts +19 -2
- package/dist/types/i18next.d.ts +66 -5
- package/docs/{reference → appendix}/endpoint-inventory.json +27 -0
- package/package.json +21 -22
- package/dist/components/Contractor/Address/Actions.d.ts +0 -2
- package/dist/components/Contractor/Address/Actions.js +0 -13
- package/dist/components/Contractor/Address/Actions.js.map +0 -1
- package/dist/components/Contractor/Address/Form.d.ts +0 -2
- package/dist/components/Contractor/Address/Form.js +0 -51
- package/dist/components/Contractor/Address/Form.js.map +0 -1
- package/dist/components/Contractor/Address/Head.d.ts +0 -2
- package/dist/components/Contractor/Address/Head.js +0 -17
- package/dist/components/Contractor/Address/Head.js.map +0 -1
- package/dist/components/Contractor/Address/useAddress.d.ts +0 -28
- package/dist/components/Contractor/Address/useAddress.js +0 -31
- package/dist/components/Contractor/Address/useAddress.js.map +0 -1
- package/dist/components/Contractor/Profile/ContractorProfileForm.d.ts +0 -9
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +0 -143
- package/dist/components/Contractor/Profile/ContractorProfileForm.js.map +0 -1
- package/dist/components/Contractor/Profile/useContractorProfile.d.ts +0 -205
- package/dist/components/Contractor/Profile/useContractorProfile.js +0 -237
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeductionsForm.js","sources":["../../../../../../src/components/Employee/Deductions/shared/DeductionsForm/DeductionsForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useMemo, useState } from 'react'\nimport type {\n Garnishment,\n GarnishmentType,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport { StandardDeductionForm } from './StandardDeductionForm'\nimport { ChildSupportFormView } from './ChildSupportFormView'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { Grid } from '@/components/Common/Grid/Grid'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport type { ResourceDictionary } from '@/types/Helpers'\n\n/** @internal */\nexport type DeductionsFormDictionary = ResourceDictionary<'Employee.DeductionsForm'>\n\n// Garnishment types the form supports (mirrors the legacy SUPPORTED_GARNISHMENT_TYPES).\nconst SUPPORTED_GARNISHMENT_TYPES: readonly GarnishmentType[] = [\n 'child_support',\n 'federal_tax_lien',\n 'state_tax_lien',\n 'student_loan',\n 'creditor_garnishment',\n 'federal_loan',\n 'other_garnishment',\n] as const\n\ntype Variant = { kind: 'custom' } | { kind: 'garnishment'; type: GarnishmentType }\n\nfunction deductionToVariant(deduction: Garnishment): Variant {\n const type = deduction.garnishmentType\n if (!deduction.courtOrdered) return { kind: 'custom' }\n return {\n kind: 'garnishment',\n type: type && SUPPORTED_GARNISHMENT_TYPES.includes(type) ? type : 'child_support',\n }\n}\n\n/** @internal */\nexport interface DeductionsFormProps {\n /** Optional CSS class for the root section. */\n className?: string\n /** The associated employee identifier. */\n employeeId: string\n /** When provided, the form is in edit mode and the deduction's existing\n * garnishment type selects the inline form variant. Omit for add mode. */\n deduction?: Garnishment | null\n /**\n * Translation overrides for the form's strings. Each consuming block\n * passes the dictionary it resolved from its own namespace so partner\n * overrides on that namespace flow into the form text.\n */\n dictionary?: DeductionsFormDictionary\n /** Called after a successful save with the saved row and whether it was a create or update. */\n onSaved: (deduction: Garnishment, mode: 'create' | 'update') => void\n /** Called when the user cancels the form. */\n onCancel: () => void\n}\n\n/** @internal */\nexport function DeductionsForm({\n className,\n employeeId,\n deduction,\n dictionary,\n onSaved,\n onCancel,\n}: DeductionsFormProps) {\n useI18n('Employee.DeductionsForm')\n useComponentDictionary('Employee.DeductionsForm', dictionary)\n const { t } = useTranslation('Employee.DeductionsForm')\n const Components = useComponentContext()\n\n const isEdit = !!deduction\n const title = isEdit ? t('editTitle') : t('addTitle')\n\n // Pre-select the variant in edit mode; let the user pick in add mode.\n const initialVariant = useMemo<Variant | null>(\n () => (deduction ? deductionToVariant(deduction) : null),\n [deduction],\n )\n const [variant, setVariant] = useState<Variant | null>(initialVariant)\n\n const garnishmentTypeOptions = useMemo(\n () =>\n SUPPORTED_GARNISHMENT_TYPES.map(value => ({\n value,\n label: garnishmentTypeLabel(t, value),\n })),\n [t],\n )\n\n const handleSelectDeductionType = (selection: string) => {\n if (selection === 'custom') {\n setVariant({ kind: 'custom' })\n } else {\n setVariant({ kind: 'garnishment', type: 'child_support' })\n }\n }\n\n const handleSelectGarnishmentType = (value: string) => {\n setVariant({ kind: 'garnishment', type: value as GarnishmentType })\n }\n\n return (\n <section className={className}>\n <Grid gap={32}>\n <Flex flexDirection=\"column\" gap={2}>\n <Components.Heading as=\"h2\">{title}</Components.Heading>\n <Components.Text variant=\"supporting\">{t('description')}</Components.Text>\n </Flex>\n\n {!isEdit && (\n <>\n <Flex flexDirection=\"column\" gap={20}>\n <Components.RadioGroup\n label={t('variantLabel')}\n description={t('variantDescription')}\n options={[\n { value: 'garnishment', label: t('garnishmentOption') },\n { value: 'custom', label: t('customOption') },\n ]}\n defaultValue={variant?.kind === 'custom' ? 'custom' : undefined}\n onChange={handleSelectDeductionType}\n isRequired\n />\n\n {variant?.kind === 'garnishment' && (\n <Components.Select\n label={t('garnishmentTypeLabel')}\n options={garnishmentTypeOptions}\n value={variant.type}\n onChange={handleSelectGarnishmentType}\n isRequired\n />\n )}\n </Flex>\n\n {variant !== null && <hr />}\n\n {variant === null && (\n <ActionsLayout>\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onCancel}>\n {t('actions.cancel')}\n </Components.Button>\n </ActionsLayout>\n )}\n </>\n )}\n\n {variant?.kind === 'custom' && (\n <StandardDeductionForm\n employeeId={employeeId}\n deduction={deduction ?? null}\n courtOrdered={false}\n title={t('types.custom')}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )}\n {variant?.kind === 'garnishment' && variant.type === 'child_support' && (\n <ChildSupportFormView\n employeeId={employeeId}\n deduction={deduction ?? null}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )}\n {variant?.kind === 'garnishment' && variant.type !== 'child_support' && (\n <StandardDeductionForm\n employeeId={employeeId}\n deduction={deduction ?? null}\n courtOrdered={true}\n garnishmentType={variant.type}\n title={garnishmentTypeLabel(t, variant.type)}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )}\n </Grid>\n </section>\n )\n}\n\nfunction garnishmentTypeLabel(\n t: ReturnType<typeof useTranslation<'Employee.DeductionsForm'>>['t'],\n value: GarnishmentType,\n): string {\n switch (value) {\n case 'child_support':\n return t('types.childSupport')\n case 'federal_tax_lien':\n return t('types.federalTaxLien')\n case 'state_tax_lien':\n return t('types.stateTaxLien')\n case 'student_loan':\n return t('types.studentLoan')\n case 'creditor_garnishment':\n return t('types.creditorGarnishment')\n case 'federal_loan':\n return t('types.federalLoan')\n case 'other_garnishment':\n return t('types.otherGarnishment')\n }\n}\n"],"names":["SUPPORTED_GARNISHMENT_TYPES","deductionToVariant","deduction","type","DeductionsForm","className","employeeId","dictionary","onSaved","onCancel","useI18n","useComponentDictionary","t","useTranslation","Components","useComponentContext","isEdit","title","initialVariant","useMemo","variant","setVariant","useState","garnishmentTypeOptions","value","garnishmentTypeLabel","handleSelectDeductionType","selection","handleSelectGarnishmentType","jsxs","Grid","Flex","jsx","Fragment","ActionsLayout","StandardDeductionForm","ChildSupportFormView"],"mappings":";;;;;;;;;;AAmBA,MAAMA,IAA0D;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,SAASC,EAAmBC,GAAiC;AAC3D,QAAMC,IAAOD,EAAU;AACvB,SAAKA,EAAU,eACR;AAAA,IACL,MAAM;AAAA,IACN,MAAMC,KAAQH,EAA4B,SAASG,CAAI,IAAIA,IAAO;AAAA,EAAA,IAHhC,EAAE,MAAM,SAAA;AAK9C;AAwBO,SAASC,EAAe;AAAA,EAC7B,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAJ;AAAA,EACA,YAAAK;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AACF,GAAwB;AACtB,EAAAC,EAAQ,yBAAyB,GACjCC,EAAuB,2BAA2BJ,CAAU;AAC5D,QAAM,EAAE,GAAAK,EAAA,IAAMC,EAAe,yBAAyB,GAChDC,IAAaC,EAAA,GAEbC,IAAS,CAAC,CAACd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iBkB,EAAQ;AAAA,QACzB,OAAOK,EAAqBb,GAAGQ,EAAQ,IAAI;AAAA,QAC3C,SAAAZ;AAAA,QACA,UAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,EAAA,CAEJ,EAAA,CACF;AAEJ;AAEA,SAASgB,EACP,GACAD,GACQ;AACR,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO,EAAE,oBAAoB;AAAA,IAC/B,KAAK;AACH,aAAO,EAAE,sBAAsB;AAAA,IACjC,KAAK;AACH,aAAO,EAAE,oBAAoB;AAAA,IAC/B,KAAK;AACH,aAAO,EAAE,mBAAmB;AAAA,IAC9B,KAAK;AACH,aAAO,EAAE,2BAA2B;AAAA,IACtC,KAAK;AACH,aAAO,EAAE,mBAAmB;AAAA,IAC9B,KAAK;AACH,aAAO,EAAE,wBAAwB;AAAA,EAAA;AAEvC;"}
|
|
1
|
+
{"version":3,"file":"DeductionsForm.js","sources":["../../../../../../src/components/Employee/Deductions/shared/DeductionsForm/DeductionsForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useMemo, useState } from 'react'\nimport type {\n Garnishment,\n GarnishmentType,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport { StandardDeductionForm } from './StandardDeductionForm'\nimport { ChildSupportFormView } from './ChildSupportFormView'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { Grid } from '@/components/Common/Grid/Grid'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport type { ResourceDictionary } from '@/types/Helpers'\n\n/** @internal */\nexport type DeductionsFormDictionary = ResourceDictionary<'Employee.DeductionsForm'>\n\n// Garnishment types the form supports (mirrors the legacy SUPPORTED_GARNISHMENT_TYPES).\nconst SUPPORTED_GARNISHMENT_TYPES: readonly GarnishmentType[] = [\n 'child_support',\n 'federal_tax_lien',\n 'state_tax_lien',\n 'student_loan',\n 'creditor_garnishment',\n 'federal_loan',\n 'other_garnishment',\n] as const\n\ntype Variant = { kind: 'custom' } | { kind: 'garnishment'; type: GarnishmentType }\n\nfunction deductionToVariant(deduction: Garnishment): Variant {\n const type = deduction.garnishmentType\n if (!deduction.courtOrdered) return { kind: 'custom' }\n return {\n kind: 'garnishment',\n type: type && SUPPORTED_GARNISHMENT_TYPES.includes(type) ? type : 'child_support',\n }\n}\n\n/** @internal */\nexport interface DeductionsFormProps {\n /** Optional CSS class for the root section. */\n className?: string\n /** The associated employee identifier. */\n employeeId: string\n /** When provided, the form is in edit mode and the deduction's existing\n * garnishment type selects the inline form variant. Omit for add mode. */\n deduction?: Garnishment | null\n /**\n * Translation overrides for the form's strings. Each consuming block\n * passes the dictionary it resolved from its own namespace so partner\n * overrides on that namespace flow into the form text.\n */\n dictionary?: DeductionsFormDictionary\n /** Called after a successful save with the saved row and whether it was a create or update. */\n onSaved: (deduction: Garnishment, mode: 'create' | 'update') => void\n /** Called when the user cancels the form. */\n onCancel: () => void\n}\n\n/** @internal */\nexport function DeductionsForm({\n className,\n employeeId,\n deduction,\n dictionary,\n onSaved,\n onCancel,\n}: DeductionsFormProps) {\n useI18n('Employee.DeductionsForm')\n useComponentDictionary('Employee.DeductionsForm', dictionary)\n const { t } = useTranslation('Employee.DeductionsForm')\n const Components = useComponentContext()\n\n const isEdit = !!deduction\n const title = isEdit ? t('editTitle') : t('addTitle')\n\n // Pre-select the variant in edit mode; let the user pick in add mode.\n const initialVariant = useMemo<Variant | null>(\n () => (deduction ? deductionToVariant(deduction) : null),\n [deduction],\n )\n const [variant, setVariant] = useState<Variant | null>(initialVariant)\n\n const garnishmentTypeOptions = useMemo(\n () =>\n SUPPORTED_GARNISHMENT_TYPES.map(value => ({\n value,\n label: garnishmentTypeLabel(t, value),\n })),\n [t],\n )\n\n const handleSelectDeductionType = (selection: string) => {\n if (selection === 'custom') {\n setVariant({ kind: 'custom' })\n } else {\n setVariant({ kind: 'garnishment', type: 'child_support' })\n }\n }\n\n const handleSelectGarnishmentType = (value: string) => {\n setVariant({ kind: 'garnishment', type: value as GarnishmentType })\n }\n\n return (\n <section className={className}>\n <Grid gap={32}>\n <Flex flexDirection=\"column\" gap={2}>\n <Components.Heading as=\"h2\">{title}</Components.Heading>\n <Components.Text variant=\"supporting\">{t('description')}</Components.Text>\n </Flex>\n\n {!isEdit && (\n <>\n <Flex flexDirection=\"column\" gap={20}>\n <Components.RadioGroup\n label={t('variantLabel')}\n description={t('variantDescription')}\n options={[\n { value: 'garnishment', label: t('garnishmentOption') },\n { value: 'custom', label: t('customOption') },\n ]}\n defaultValue={variant?.kind === 'custom' ? 'custom' : undefined}\n onChange={handleSelectDeductionType}\n isRequired\n />\n\n {variant?.kind === 'garnishment' && (\n <Components.Select\n label={t('garnishmentTypeLabel')}\n placeholder=\"\"\n options={garnishmentTypeOptions}\n value={variant.type}\n onChange={handleSelectGarnishmentType}\n isRequired\n />\n )}\n </Flex>\n\n {variant !== null && <hr />}\n\n {variant === null && (\n <ActionsLayout>\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onCancel}>\n {t('actions.cancel')}\n </Components.Button>\n </ActionsLayout>\n )}\n </>\n )}\n\n {variant?.kind === 'custom' && (\n <StandardDeductionForm\n employeeId={employeeId}\n deduction={deduction ?? null}\n courtOrdered={false}\n title={t('types.custom')}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )}\n {variant?.kind === 'garnishment' && variant.type === 'child_support' && (\n <ChildSupportFormView\n employeeId={employeeId}\n deduction={deduction ?? null}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )}\n {variant?.kind === 'garnishment' && variant.type !== 'child_support' && (\n <StandardDeductionForm\n employeeId={employeeId}\n deduction={deduction ?? null}\n courtOrdered={true}\n garnishmentType={variant.type}\n title={garnishmentTypeLabel(t, variant.type)}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )}\n </Grid>\n </section>\n )\n}\n\nfunction garnishmentTypeLabel(\n t: ReturnType<typeof useTranslation<'Employee.DeductionsForm'>>['t'],\n value: GarnishmentType,\n): string {\n switch (value) {\n case 'child_support':\n return t('types.childSupport')\n case 'federal_tax_lien':\n return t('types.federalTaxLien')\n case 'state_tax_lien':\n return t('types.stateTaxLien')\n case 'student_loan':\n return t('types.studentLoan')\n case 'creditor_garnishment':\n return t('types.creditorGarnishment')\n case 'federal_loan':\n return t('types.federalLoan')\n case 'other_garnishment':\n return t('types.otherGarnishment')\n }\n}\n"],"names":["SUPPORTED_GARNISHMENT_TYPES","deductionToVariant","deduction","type","DeductionsForm","className","employeeId","dictionary","onSaved","onCancel","useI18n","useComponentDictionary","t","useTranslation","Components","useComponentContext","isEdit","title","initialVariant","useMemo","variant","setVariant","useState","garnishmentTypeOptions","value","garnishmentTypeLabel","handleSelectDeductionType","selection","handleSelectGarnishmentType","jsxs","Grid","Flex","jsx","Fragment","ActionsLayout","StandardDeductionForm","ChildSupportFormView"],"mappings":";;;;;;;;;;AAmBA,MAAMA,IAA0D;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,SAASC,EAAmBC,GAAiC;AAC3D,QAAMC,IAAOD,EAAU;AACvB,SAAKA,EAAU,eACR;AAAA,IACL,MAAM;AAAA,IACN,MAAMC,KAAQH,EAA4B,SAASG,CAAI,IAAIA,IAAO;AAAA,EAAA,IAHhC,EAAE,MAAM,SAAA;AAK9C;AAwBO,SAASC,EAAe;AAAA,EAC7B,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAJ;AAAA,EACA,YAAAK;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AACF,GAAwB;AACtB,EAAAC,EAAQ,yBAAyB,GACjCC,EAAuB,2BAA2BJ,CAAU;AAC5D,QAAM,EAAE,GAAAK,EAAA,IAAMC,EAAe,yBAAyB,GAChDC,IAAaC,EAAA,GAEbC,IAAS,CAAC,CAACd,GACXe,IAAiBL,EAATI,IAAW,cAAi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AAA,QACzB,OAAOK,EAAqBb,GAAGQ,EAAQ,IAAI;AAAA,QAC3C,SAAAZ;AAAA,QACA,UAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,EAAA,CAEJ,EAAA,CACF;AAEJ;AAEA,SAASgB,EACP,GACAD,GACQ;AACR,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO,EAAE,oBAAoB;AAAA,IAC/B,KAAK;AACH,aAAO,EAAE,sBAAsB;AAAA,IACjC,KAAK;AACH,aAAO,EAAE,oBAAoB;AAAA,IAC/B,KAAK;AACH,aAAO,EAAE,mBAAmB;AAAA,IAC9B,KAAK;AACH,aAAO,EAAE,2BAA2B;AAAA,IACtC,KAAK;AACH,aAAO,EAAE,mBAAmB;AAAA,IAC9B,KAAK;AACH,aAAO,EAAE,wBAAwB;AAAA,EAAA;AAEvC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChildSupportGarnishmentForm.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport {\n type Garnishment,\n type GarnishmentType,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport type { Agencies } from '@gusto/embedded-api-v-2025-11-15/models/components/childsupportdata'\nimport { PaymentPeriod } from '@gusto/embedded-api-v-2025-11-15/models/components/garnishmentchildsupport'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsUpdate'\nimport { useGarnishmentsList } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsList'\nimport { useGarnishmentsGetChildSupportData } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsGetChildSupportData'\nimport {\n createChildSupportGarnishmentFormSchema,\n getRequiredAttrKeys,\n type ChildSupportGarnishmentFormData,\n type ChildSupportGarnishmentFormOutputs,\n type SupportedRequiredAttrKey,\n} from './childSupportGarnishmentFormSchema'\nimport {\n StateField,\n FipsCodeField,\n CaseNumberField,\n OrderNumberField,\n RemittanceNumberField,\n PayPeriodMaximumField,\n AmountField,\n PaymentPeriodField,\n type CountyEntry,\n type StateFieldEntry,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nconst PAYMENT_PERIOD_OPTIONS = [\n { value: PaymentPeriod.EveryWeek, label: PaymentPeriod.EveryWeek },\n { value: PaymentPeriod.EveryOtherWeek, label: PaymentPeriod.EveryOtherWeek },\n { value: PaymentPeriod.TwicePerMonth, label: PaymentPeriod.TwicePerMonth },\n { value: PaymentPeriod.Monthly, label: PaymentPeriod.Monthly },\n] as const\n\nconst PAYMENT_PERIOD_ENTRIES = [\n PaymentPeriod.EveryWeek,\n PaymentPeriod.EveryOtherWeek,\n PaymentPeriod.TwicePerMonth,\n PaymentPeriod.Monthly,\n] as const\n\n/**\n * Configuration options for {@link useChildSupportGarnishmentForm}.\n *\n * @remarks\n * Presence or absence of `garnishmentId` selects the API verb — see the\n * `garnishmentId` field description.\n *\n * @public\n */\nexport interface UseChildSupportGarnishmentFormProps {\n /** UUID of the employee whose child-support garnishment is being created or edited. */\n employeeId: string\n /**\n * When set, loads that garnishment and updates it (PUT). When omitted, the\n * form is in create mode (POST).\n */\n garnishmentId?: string\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<ChildSupportGarnishmentFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useChildSupportGarnishmentForm().form.Fields`.\n *\n * @remarks\n * Each property is either the field component or `undefined`. A field is\n * `undefined` when conditions for rendering it aren't met — see each member\n * for its visibility rule. Always null-check conditional fields (e.g.\n * `{Fields.FipsCode && <Fields.FipsCode ... />}`) before rendering.\n *\n * @public\n */\nexport interface ChildSupportGarnishmentFormFields {\n /** Agency (state) select. Always available. */\n State: typeof StateField\n /** Only available when the selected agency has more than one fips code, or the\n * sole code is county-scoped (not an \"all counties\" auto-pick). */\n FipsCode: typeof FipsCodeField | undefined\n /** Only available when the selected agency requires `case_number`. */\n CaseNumber: typeof CaseNumberField | undefined\n /** Only available when the selected agency requires `order_number`. */\n OrderNumber: typeof OrderNumberField | undefined\n /** Only available when the selected agency requires `remittance_number`. */\n RemittanceNumber: typeof RemittanceNumberField | undefined\n /** Per-pay-period currency cap input. Always available. */\n PayPeriodMaximum: typeof PayPeriodMaximumField\n /** Percent-of-paycheck input (0–100). Always available. */\n Amount: typeof AmountField\n /** Payment period select. Always available. */\n PaymentPeriod: typeof PaymentPeriodField\n}\n\n/**\n * Ready-state shape returned by {@link useChildSupportGarnishmentForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the child-support-specific `data`, `status`, `actions`, and `form.Fields`\n * shape. Static, entity-derived values live under `data.*`; reactive values\n * that flip with form input live under `status.*`.\n *\n * @public\n */\nexport interface UseChildSupportGarnishmentFormReady extends BaseFormHookReady<\n FieldsMetadata,\n ChildSupportGarnishmentFormData,\n ChildSupportGarnishmentFormFields\n> {\n /** Child-support-specific data payload: the available agencies, counties for the selected state, and the loaded garnishment for update mode. */\n data: {\n /** Agencies offered as `State` options; raw entries the consumer can use\n * with `getOptionLabel` for translated names. */\n agencies: StateFieldEntry[]\n /** Counties for the currently selected state. Empty array when no state\n * is selected. */\n counties: CountyEntry[]\n /** The garnishment loaded for update; `null` in create mode. */\n deduction: Garnishment | null\n }\n /** Submission state and reactive flags derived from current form input. */\n status: {\n /** `true` while a create or update mutation is in flight. */\n isPending: boolean\n /** Reflects whether the next submit will POST a new garnishment or PUT an existing one. */\n mode: 'create' | 'update'\n /** The agency record matching the currently selected `state`. */\n selectedAgency: Agencies | null\n /** Mirrors `selectedAgency.manualPaymentRequired`; convenient for showing\n * a warning alert. */\n isManualPaymentRequired: boolean\n /** Which `required_attributes` keys the selected agency declares. */\n requiredAttrKeys: ReadonlySet<SupportedRequiredAttrKey>\n }\n /** Submission action. */\n actions: {\n /** Submits the form. Returns the saved garnishment + mode on success, or `undefined` when validation fails or the request errored. */\n onSubmit: () => Promise<HookSubmitResult<Garnishment> | undefined>\n }\n}\n\n/**\n * Return value of {@link useChildSupportGarnishmentForm}.\n *\n * @remarks\n * Discriminated union: {@link HookLoadingResult} while the agency catalog (and,\n * in update mode, the existing garnishment) is loading;\n * {@link UseChildSupportGarnishmentFormReady} once data is ready.\n *\n * @public\n */\nexport type UseChildSupportGarnishmentFormResult =\n | HookLoadingResult\n | UseChildSupportGarnishmentFormReady\n\n/**\n * Headless hook for creating or updating a child-support garnishment.\n *\n * @remarks\n * Unlike standard garnishments, child support requires agency-specific\n * attributes (case number, order number, remittance number) that vary by\n * state, plus an optional county selection when the state has multiple\n * counties. The hook loads the agency catalog from the Gusto API, derives\n * which attributes the selected state requires, and exposes the right Fields\n * conditionally.\n *\n * Presence or absence of `garnishmentId` selects the API verb: omit it to\n * POST a new garnishment, supply it to PUT updates against the existing row.\n * For non-child-support deductions (court-ordered garnishments and post-tax\n * custom), use {@link useDeductionForm} instead.\n *\n * @param input - See {@link UseChildSupportGarnishmentFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseChildSupportGarnishmentFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useChildSupportGarnishmentForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function ChildSupportPage({ employeeId, garnishmentId }: { employeeId: string; garnishmentId?: string }) {\n * const form = useChildSupportGarnishmentForm({ employeeId, garnishmentId })\n *\n * if (form.isLoading) return <p>Loading…</p>\n *\n * const { Fields } = form.form\n *\n * return (\n * <SDKFormProvider formHookResult={form}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void form.actions.onSubmit()\n * }}\n * >\n * <Fields.State\n * label=\"Agency\"\n * getOptionLabel={entry => entry.name}\n * validationMessages={{ REQUIRED: 'Required' }}\n * />\n * {Fields.CaseNumber && (\n * <Fields.CaseNumber label=\"Case number\" validationMessages={{ REQUIRED: 'Required' }} />\n * )}\n * <Fields.Amount\n * label=\"Percentage of paycheck\"\n * validationMessages={{\n * REQUIRED: 'Required',\n * PERCENT_OUT_OF_RANGE: 'Must be between 0 and 100',\n * }}\n * />\n * <button type=\"submit\">Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useChildSupportGarnishmentForm({\n employeeId,\n garnishmentId,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseChildSupportGarnishmentFormProps): UseChildSupportGarnishmentFormResult {\n const isCreateMode = !garnishmentId\n const schemaMode = isCreateMode ? 'create' : 'update'\n\n // Agencies + their required-attributes / fips codes come from a single GET.\n const agencyDataQuery = useGarnishmentsGetChildSupportData({})\n const agencyList = useMemo(\n () => agencyDataQuery.data?.childSupportData?.agencies ?? [],\n [agencyDataQuery.data],\n )\n\n // Update mode reads the row from the list endpoint (the garnishments API\n // has no single-row GET).\n const garnishmentsListQuery = useGarnishmentsList({ employeeId }, { enabled: !isCreateMode })\n const fetchedDeduction = useMemo(() => {\n if (isCreateMode) return null\n return garnishmentsListQuery.data?.garnishments?.find(g => g.uuid === garnishmentId) ?? null\n }, [isCreateMode, garnishmentId, garnishmentsListQuery.data])\n\n const resolvedDefaults: ChildSupportGarnishmentFormData = useMemo(\n () => ({\n state: fetchedDeduction?.childSupport?.state ?? partnerDefaults?.state ?? '',\n fipsCode: fetchedDeduction?.childSupport?.fipsCode ?? partnerDefaults?.fipsCode ?? '',\n caseNumber: fetchedDeduction?.childSupport?.caseNumber ?? partnerDefaults?.caseNumber ?? '',\n orderNumber:\n fetchedDeduction?.childSupport?.orderNumber ?? partnerDefaults?.orderNumber ?? '',\n remittanceNumber:\n fetchedDeduction?.childSupport?.remittanceNumber ?? partnerDefaults?.remittanceNumber ?? '',\n amount: fetchedDeduction?.amount\n ? Number(fetchedDeduction.amount)\n : (partnerDefaults?.amount ?? 0),\n payPeriodMaximum: fetchedDeduction?.payPeriodMaximum\n ? Number(fetchedDeduction.payPeriodMaximum)\n : (partnerDefaults?.payPeriodMaximum ?? 0),\n paymentPeriod:\n (fetchedDeduction?.childSupport?.paymentPeriod as PaymentPeriod | undefined) ??\n partnerDefaults?.paymentPeriod ??\n PaymentPeriod.Monthly,\n }),\n [fetchedDeduction, partnerDefaults],\n )\n\n // Pass the full agency list so requiredness for the agency-attribute fields\n // (`caseNumber`, `orderNumber`, `remittanceNumber`) is derived dynamically\n // from the form's `state` value. The schema doesn't need to rebuild when the\n // user changes states — the predicate runs at validation time and via\n // `useDeriveFieldsMetadata` for the (optional) label.\n const [schema, metadataConfig] = useMemo(\n () => createChildSupportGarnishmentFormSchema({ mode: schemaMode, agencyList }),\n [schemaMode, agencyList],\n )\n\n const formMethods = useForm<\n ChildSupportGarnishmentFormData,\n unknown,\n ChildSupportGarnishmentFormOutputs\n >({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const liveWatchedState = useWatch({ control: formMethods.control, name: 'state' })\n const liveSelectedAgency = useMemo(\n () => agencyList.find(a => a.state === liveWatchedState) ?? null,\n [agencyList, liveWatchedState],\n )\n\n // The agency-attribute fields stay in sync with the chosen state: when the\n // user switches states, the previous attribute values would otherwise carry\n // over and potentially submit alongside the wrong agency. The ref tracks\n // the previous value so the wipe only fires on user-driven transitions —\n // NOT on the initial sync when an existing garnishment loads (state moves\n // from '' to e.g. 'AK' as a side effect of `values` updating, which would\n // otherwise clobber the loaded case/order/remittance values).\n const previousWatchedStateRef = useRef<string | null>(null)\n useEffect(() => {\n const previous = previousWatchedStateRef.current\n previousWatchedStateRef.current = liveWatchedState\n // First render (no previous value) → skip the wipe.\n if (previous === null) return\n // Server-side load: previous was '' (initial defaults before the row\n // arrived), now it's the loaded state. That's a sync, not a user toggle.\n if (previous === '') return\n if (previous === liveWatchedState) return\n formMethods.setValue('caseNumber', '')\n formMethods.setValue('orderNumber', '')\n formMethods.setValue('remittanceNumber', '')\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [liveWatchedState])\n\n // When the selected agency has a single \"all counties\" fips code, auto-fill\n // the field so the consumer doesn't have to render the county select.\n const fipsCodes = liveSelectedAgency?.fipsCodes ?? []\n const singleAllCountiesFipsCode =\n fipsCodes.length === 1 && !fipsCodes[0]?.county?.length ? (fipsCodes[0]?.code ?? null) : null\n useEffect(() => {\n if (singleAllCountiesFipsCode) {\n formMethods.setValue('fipsCode', singleAllCountiesFipsCode)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [singleAllCountiesFipsCode])\n\n const createGarnishmentMutation = useGarnishmentsCreateMutation()\n const updateGarnishmentMutation = useGarnishmentsUpdateMutation()\n const isPending = createGarnishmentMutation.isPending || updateGarnishmentMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('ChildSupportGarnishmentForm')\n\n const errorHandling = composeErrorHandler(\n isCreateMode ? [agencyDataQuery] : [agencyDataQuery, garnishmentsListQuery],\n { submitError, setSubmitError },\n )\n\n // ── Derived data exposed on the ready branch ─────────────────────────\n\n const agencies: StateFieldEntry[] = useMemo(\n () =>\n agencyList.map(a => ({\n state: a.state ?? '',\n name: a.name ?? a.state ?? '',\n manualPaymentRequired: a.manualPaymentRequired ?? false,\n })),\n [agencyList],\n )\n\n const counties: CountyEntry[] = useMemo(\n () =>\n (liveSelectedAgency?.fipsCodes ?? [])\n .filter(f => typeof f.code === 'string')\n .map(f => ({ fipsCode: f.code as string, county: f.county ?? null })),\n [liveSelectedAgency],\n )\n\n const requiredAttrKeys = useMemo(\n () => getRequiredAttrKeys(liveSelectedAgency),\n [liveSelectedAgency],\n )\n\n const hasSelectableCounties =\n counties.length > 1 || (counties.length === 1 && singleAllCountiesFipsCode == null)\n\n // ── Metadata + field-options wiring ─────────────────────────────────\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const stateOptions = agencies.map(a => ({ value: a.state, label: a.name }))\n const countyOptions = counties.map(c => ({\n value: c.fipsCode,\n label: c.county ?? c.fipsCode,\n }))\n\n const fieldsMetadata = {\n state: withOptions(baseMetadata.state, stateOptions, agencies),\n fipsCode: withOptions(baseMetadata.fipsCode, countyOptions, counties),\n caseNumber: baseMetadata.caseNumber,\n orderNumber: baseMetadata.orderNumber,\n remittanceNumber: baseMetadata.remittanceNumber,\n payPeriodMaximum: baseMetadata.payPeriodMaximum,\n amount: baseMetadata.amount,\n paymentPeriod: withOptions(\n baseMetadata.paymentPeriod,\n [...PAYMENT_PERIOD_OPTIONS],\n [...PAYMENT_PERIOD_ENTRIES],\n ),\n }\n\n // ── Submit ───────────────────────────────────────────────────────────\n\n const onSubmit = async (): Promise<HookSubmitResult<Garnishment> | undefined> => {\n let submitResult: HookSubmitResult<Garnishment> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: ChildSupportGarnishmentFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const childSupport = {\n state: payload.state,\n paymentPeriod: payload.paymentPeriod,\n fipsCode: payload.fipsCode,\n // Empty strings collapse to null so the API persists \"no value\n // declared\" rather than an empty case number.\n caseNumber: payload.caseNumber || null,\n orderNumber: payload.orderNumber || null,\n remittanceNumber: payload.remittanceNumber || null,\n }\n\n const description = `Child Support - ${childSupport.caseNumber ?? ''}`\n const amountStr = String(payload.amount)\n const payPeriodMaximumStr =\n payload.payPeriodMaximum > 0 ? String(payload.payPeriodMaximum) : null\n\n const requestBody = {\n active: true,\n amount: amountStr,\n description,\n courtOrdered: true,\n garnishmentType: 'child_support' as GarnishmentType,\n times: null,\n deductAsPercentage: true,\n payPeriodMaximum: payPeriodMaximumStr,\n recurring: true,\n childSupport,\n }\n\n let updated: Garnishment | undefined\n\n if (isCreateMode) {\n const result = await createGarnishmentMutation.mutateAsync({\n request: { employeeId, garnishmentRequest: requestBody },\n })\n updated = result.garnishment\n } else {\n if (!fetchedDeduction) {\n throw new SDKInternalError(\n 'Cannot update child-support deduction: no matching garnishment on file',\n )\n }\n const result = await updateGarnishmentMutation.mutateAsync({\n request: {\n garnishmentId: fetchedDeduction.uuid,\n updateGarnishmentRequest: {\n ...requestBody,\n version: fetchedDeduction.version as string,\n },\n },\n })\n updated = result.garnishment\n }\n\n if (!updated) {\n throw new SDKInternalError(\n isCreateMode\n ? 'Child-support deduction creation failed'\n : 'Child-support deduction update failed',\n )\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updated,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (agencyDataQuery.isLoading) {\n return { isLoading: true as const, errorHandling }\n }\n if (!isCreateMode && garnishmentsListQuery.isLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n agencies,\n counties,\n deduction: fetchedDeduction,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n selectedAgency: liveSelectedAgency,\n isManualPaymentRequired: liveSelectedAgency?.manualPaymentRequired ?? false,\n requiredAttrKeys,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n State: StateField,\n FipsCode: hasSelectableCounties ? FipsCodeField : undefined,\n CaseNumber: requiredAttrKeys.has('case_number') ? CaseNumberField : undefined,\n OrderNumber: requiredAttrKeys.has('order_number') ? OrderNumberField : undefined,\n RemittanceNumber: requiredAttrKeys.has('remittance_number')\n ? RemittanceNumberField\n : undefined,\n PayPeriodMaximum: PayPeriodMaximumField,\n Amount: AmountField,\n PaymentPeriod: PaymentPeriodField,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Per-field metadata returned by {@link useChildSupportGarnishmentForm} as `form.fieldsMetadata`.\n *\n * @remarks\n * Carries per-field `isRequired`, `isDisabled`, label, description, and option\n * entries derived from the schema and form state. Use these to drive UI such\n * as disabled state or option lists when not relying on the pre-bound\n * {@link ChildSupportGarnishmentFormFields} components.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormFieldsMetadata =\n UseChildSupportGarnishmentFormReady['form']['fieldsMetadata']\n"],"names":["PAYMENT_PERIOD_OPTIONS","PaymentPeriod","PAYMENT_PERIOD_ENTRIES","useChildSupportGarnishmentForm","employeeId","garnishmentId","partnerDefaults","validationMode","shouldFocusError","isCreateMode","schemaMode","agencyDataQuery","useGarnishmentsGetChildSupportData","agencyList","useMemo","garnishmentsListQuery","useGarnishmentsList","fetchedDeduction","g","resolvedDefaults","schema","metadataConfig","createChildSupportGarnishmentFormSchema","formMethods","useForm","zodResolver","liveWatchedState","useWatch","liveSelectedAgency","a","previousWatchedStateRef","useRef","useEffect","previous","fipsCodes","singleAllCountiesFipsCode","createGarnishmentMutation","useGarnishmentsCreateMutation","updateGarnishmentMutation","useGarnishmentsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","agencies","counties","f","requiredAttrKeys","getRequiredAttrKeys","hasSelectableCounties","baseMetadata","useDeriveFieldsMetadata","stateOptions","countyOptions","c","fieldsMetadata","withOptions","onSubmit","submitResult","resolve","data","payload","childSupport","description","amountStr","payPeriodMaximumStr","requestBody","updated","SDKInternalError","hookFormInternals","useHookFormInternals","StateField","FipsCodeField","CaseNumberField","OrderNumberField","RemittanceNumberField","PayPeriodMaximumField","AmountField","PaymentPeriodField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,MAAMA,KAAyB;AAAA,EAC7B,EAAE,OAAOC,EAAc,WAAW,OAAOA,EAAc,UAAA;AAAA,EACvD,EAAE,OAAOA,EAAc,gBAAgB,OAAOA,EAAc,eAAA;AAAA,EAC5D,EAAE,OAAOA,EAAc,eAAe,OAAOA,EAAc,cAAA;AAAA,EAC3D,EAAE,OAAOA,EAAc,SAAS,OAAOA,EAAc,QAAA;AACvD,GAEMC,KAAyB;AAAA,EAC7BD,EAAc;AAAA,EACdA,EAAc;AAAA,EACdA,EAAc;AAAA,EACdA,EAAc;AAChB;AAqLO,SAASE,GAA+B;AAAA,EAC7C,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAA8E;AAC5E,QAAMC,IAAe,CAACJ,GAChBK,IAAaD,IAAe,WAAW,UAGvCE,IAAkBC,GAAmC,EAAE,GACvDC,IAAaC;AAAA,IACjB,MAAMH,EAAgB,MAAM,kBAAkB,YAAY,CAAA;AAAA,IAC1D,CAACA,EAAgB,IAAI;AAAA,EAAA,GAKjBI,IAAwBC,GAAoB,EAAE,YAAAZ,EAAA,GAAc,EAAE,SAAS,CAACK,GAAc,GACtFQ,IAAmBH,EAAQ,MAC3BL,IAAqB,OAClBM,EAAsB,MAAM,cAAc,KAAK,OAAKG,EAAE,SAASb,CAAa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AA8B,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,UAAAE;AAAA,MACA,UAAAC;AAAA,MACA,WAAW/B;AAAA,IAAA;AAAA,IAEb,QAAQ;AAAA,MACN,WAAAuB;AAAA,MACA,MAAM/B,IAAe,WAAW;AAAA,MAChC,gBAAgBmB;AAAA,MAChB,yBAAyBA,GAAoB,yBAAyB;AAAA,MACtE,kBAAAsB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAAU,EAAA;AAAA,IACX,eAAAf;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAO6B;AAAA,QACP,UAAUtB,IAAwBuB,KAAgB;AAAA,QAClD,YAAYzB,EAAiB,IAAI,aAAa,IAAI0B,KAAkB;AAAA,QACpE,aAAa1B,EAAiB,IAAI,cAAc,IAAI2B,KAAmB;AAAA,QACvE,kBAAkB3B,EAAiB,IAAI,mBAAmB,IACtD4B,KACA;AAAA,QACJ,kBAAkBC;AAAA,QAClB,QAAQC;AAAA,QACR,eAAeC;AAAA,MAAA;AAAA,MAEjB,gBAAAvB;AAAA,MACA,mBAAAc;AAAA,MACA,yBAAyBU,GAA8B3D,GAAaH,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useChildSupportGarnishmentForm.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport {\n type Garnishment,\n type GarnishmentType,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport type { Agencies } from '@gusto/embedded-api-v-2025-11-15/models/components/childsupportdata'\nimport { PaymentPeriod } from '@gusto/embedded-api-v-2025-11-15/models/components/garnishmentchildsupport'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsUpdate'\nimport { useGarnishmentsList } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsList'\nimport { useGarnishmentsGetChildSupportData } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsGetChildSupportData'\nimport {\n createChildSupportGarnishmentFormSchema,\n getRequiredAttrKeys,\n type ChildSupportGarnishmentFormData,\n type ChildSupportGarnishmentFormOutputs,\n type SupportedRequiredAttrKey,\n} from './childSupportGarnishmentFormSchema'\nimport {\n StateField,\n FipsCodeField,\n CaseNumberField,\n OrderNumberField,\n RemittanceNumberField,\n PayPeriodMaximumField,\n AmountField,\n PaymentPeriodField,\n type CountyEntry,\n type StateFieldEntry,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nconst PAYMENT_PERIOD_OPTIONS = [\n { value: PaymentPeriod.EveryWeek, label: PaymentPeriod.EveryWeek },\n { value: PaymentPeriod.EveryOtherWeek, label: PaymentPeriod.EveryOtherWeek },\n { value: PaymentPeriod.TwicePerMonth, label: PaymentPeriod.TwicePerMonth },\n { value: PaymentPeriod.Monthly, label: PaymentPeriod.Monthly },\n] as const\n\nconst PAYMENT_PERIOD_ENTRIES = [\n PaymentPeriod.EveryWeek,\n PaymentPeriod.EveryOtherWeek,\n PaymentPeriod.TwicePerMonth,\n PaymentPeriod.Monthly,\n] as const\n\n/**\n * Configuration options for {@link useChildSupportGarnishmentForm}.\n *\n * @remarks\n * Presence or absence of `garnishmentId` selects the API verb — see the\n * `garnishmentId` field description.\n *\n * @public\n */\nexport interface UseChildSupportGarnishmentFormProps {\n /** UUID of the employee whose child-support garnishment is being created or edited. */\n employeeId: string\n /**\n * When set, loads that garnishment and updates it (PUT). When omitted, the\n * form is in create mode (POST).\n */\n garnishmentId?: string\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<ChildSupportGarnishmentFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useChildSupportGarnishmentForm().form.Fields`.\n *\n * @remarks\n * Each property is either the field component or `undefined`. A field is\n * `undefined` when conditions for rendering it aren't met — see each member\n * for its visibility rule. Always null-check conditional fields (e.g.\n * `{Fields.FipsCode && <Fields.FipsCode ... />}`) before rendering.\n *\n * @public\n */\nexport interface ChildSupportGarnishmentFormFields {\n /** Agency (state) select. Always available. */\n State: typeof StateField\n /** Only available when the selected agency has more than one fips code, or the\n * sole code is county-scoped (not an \"all counties\" auto-pick). */\n FipsCode: typeof FipsCodeField | undefined\n /** Only available when the selected agency requires `case_number`. */\n CaseNumber: typeof CaseNumberField | undefined\n /** Only available when the selected agency requires `order_number`. */\n OrderNumber: typeof OrderNumberField | undefined\n /** Only available when the selected agency requires `remittance_number`. */\n RemittanceNumber: typeof RemittanceNumberField | undefined\n /** Per-pay-period currency cap input. Always available. */\n PayPeriodMaximum: typeof PayPeriodMaximumField\n /** Percent-of-paycheck input (0–100). Always available. */\n Amount: typeof AmountField\n /** Payment period select. Always available. */\n PaymentPeriod: typeof PaymentPeriodField\n}\n\n/**\n * Ready-state shape returned by {@link useChildSupportGarnishmentForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the child-support-specific `data`, `status`, `actions`, and `form.Fields`\n * shape. Static, entity-derived values live under `data.*`; reactive values\n * that flip with form input live under `status.*`.\n *\n * @public\n */\nexport interface UseChildSupportGarnishmentFormReady extends BaseFormHookReady<\n FieldsMetadata,\n ChildSupportGarnishmentFormData,\n ChildSupportGarnishmentFormFields\n> {\n /** Child-support-specific data payload: the available agencies, counties for the selected state, and the loaded garnishment for update mode. */\n data: {\n /** Agencies offered as `State` options; raw entries the consumer can use\n * with `getOptionLabel` for translated names. */\n agencies: StateFieldEntry[]\n /** Counties for the currently selected state. Empty array when no state\n * is selected. */\n counties: CountyEntry[]\n /** The garnishment loaded for update; `null` in create mode. */\n deduction: Garnishment | null\n }\n /** Submission state and reactive flags derived from current form input. */\n status: {\n /** `true` while a create or update mutation is in flight. */\n isPending: boolean\n /** Reflects whether the next submit will POST a new garnishment or PUT an existing one. */\n mode: 'create' | 'update'\n /** The agency record matching the currently selected `state`. */\n selectedAgency: Agencies | null\n /** Mirrors `selectedAgency.manualPaymentRequired`; convenient for showing\n * a warning alert. */\n isManualPaymentRequired: boolean\n /** Which `required_attributes` keys the selected agency declares. */\n requiredAttrKeys: ReadonlySet<SupportedRequiredAttrKey>\n }\n /** Submission action. */\n actions: {\n /** Submits the form. Returns the saved garnishment + mode on success, or `undefined` when validation fails or the request errored. */\n onSubmit: () => Promise<HookSubmitResult<Garnishment> | undefined>\n }\n}\n\n/**\n * Return value of {@link useChildSupportGarnishmentForm}.\n *\n * @remarks\n * Discriminated union: {@link HookLoadingResult} while the agency catalog (and,\n * in update mode, the existing garnishment) is loading;\n * {@link UseChildSupportGarnishmentFormReady} once data is ready.\n *\n * @public\n */\nexport type UseChildSupportGarnishmentFormResult =\n HookLoadingResult | UseChildSupportGarnishmentFormReady\n\n/**\n * Headless hook for creating or updating a child-support garnishment.\n *\n * @remarks\n * Unlike standard garnishments, child support requires agency-specific\n * attributes (case number, order number, remittance number) that vary by\n * state, plus an optional county selection when the state has multiple\n * counties. The hook loads the agency catalog from the Gusto API, derives\n * which attributes the selected state requires, and exposes the right Fields\n * conditionally.\n *\n * Presence or absence of `garnishmentId` selects the API verb: omit it to\n * POST a new garnishment, supply it to PUT updates against the existing row.\n * For non-child-support deductions (court-ordered garnishments and post-tax\n * custom), use {@link useDeductionForm} instead.\n *\n * @param input - See {@link UseChildSupportGarnishmentFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseChildSupportGarnishmentFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useChildSupportGarnishmentForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function ChildSupportPage({ employeeId, garnishmentId }: { employeeId: string; garnishmentId?: string }) {\n * const form = useChildSupportGarnishmentForm({ employeeId, garnishmentId })\n *\n * if (form.isLoading) return <p>Loading…</p>\n *\n * const { Fields } = form.form\n *\n * return (\n * <SDKFormProvider formHookResult={form}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void form.actions.onSubmit()\n * }}\n * >\n * <Fields.State\n * label=\"Agency\"\n * getOptionLabel={entry => entry.name}\n * validationMessages={{ REQUIRED: 'Required' }}\n * />\n * {Fields.CaseNumber && (\n * <Fields.CaseNumber label=\"Case number\" validationMessages={{ REQUIRED: 'Required' }} />\n * )}\n * <Fields.Amount\n * label=\"Percentage of paycheck\"\n * validationMessages={{\n * REQUIRED: 'Required',\n * PERCENT_OUT_OF_RANGE: 'Must be between 0 and 100',\n * }}\n * />\n * <button type=\"submit\">Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useChildSupportGarnishmentForm({\n employeeId,\n garnishmentId,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseChildSupportGarnishmentFormProps): UseChildSupportGarnishmentFormResult {\n const isCreateMode = !garnishmentId\n const schemaMode = isCreateMode ? 'create' : 'update'\n\n // Agencies + their required-attributes / fips codes come from a single GET.\n const agencyDataQuery = useGarnishmentsGetChildSupportData({})\n const agencyList = useMemo(\n () => agencyDataQuery.data?.childSupportData?.agencies ?? [],\n [agencyDataQuery.data],\n )\n\n // Update mode reads the row from the list endpoint (the garnishments API\n // has no single-row GET).\n const garnishmentsListQuery = useGarnishmentsList({ employeeId }, { enabled: !isCreateMode })\n const fetchedDeduction = useMemo(() => {\n if (isCreateMode) return null\n return garnishmentsListQuery.data?.garnishments?.find(g => g.uuid === garnishmentId) ?? null\n }, [isCreateMode, garnishmentId, garnishmentsListQuery.data])\n\n const resolvedDefaults: ChildSupportGarnishmentFormData = useMemo(\n () => ({\n state: fetchedDeduction?.childSupport?.state ?? partnerDefaults?.state ?? '',\n fipsCode: fetchedDeduction?.childSupport?.fipsCode ?? partnerDefaults?.fipsCode ?? '',\n caseNumber: fetchedDeduction?.childSupport?.caseNumber ?? partnerDefaults?.caseNumber ?? '',\n orderNumber:\n fetchedDeduction?.childSupport?.orderNumber ?? partnerDefaults?.orderNumber ?? '',\n remittanceNumber:\n fetchedDeduction?.childSupport?.remittanceNumber ?? partnerDefaults?.remittanceNumber ?? '',\n amount: fetchedDeduction?.amount\n ? Number(fetchedDeduction.amount)\n : (partnerDefaults?.amount ?? 0),\n payPeriodMaximum: fetchedDeduction?.payPeriodMaximum\n ? Number(fetchedDeduction.payPeriodMaximum)\n : (partnerDefaults?.payPeriodMaximum ?? 0),\n paymentPeriod:\n (fetchedDeduction?.childSupport?.paymentPeriod as PaymentPeriod | undefined) ??\n partnerDefaults?.paymentPeriod ??\n PaymentPeriod.Monthly,\n }),\n [fetchedDeduction, partnerDefaults],\n )\n\n // Pass the full agency list so requiredness for the agency-attribute fields\n // (`caseNumber`, `orderNumber`, `remittanceNumber`) is derived dynamically\n // from the form's `state` value. The schema doesn't need to rebuild when the\n // user changes states — the predicate runs at validation time and via\n // `useDeriveFieldsMetadata` for the (optional) label.\n const [schema, metadataConfig] = useMemo(\n () => createChildSupportGarnishmentFormSchema({ mode: schemaMode, agencyList }),\n [schemaMode, agencyList],\n )\n\n const formMethods = useForm<\n ChildSupportGarnishmentFormData,\n unknown,\n ChildSupportGarnishmentFormOutputs\n >({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const liveWatchedState = useWatch({ control: formMethods.control, name: 'state' })\n const liveSelectedAgency = useMemo(\n () => agencyList.find(a => a.state === liveWatchedState) ?? null,\n [agencyList, liveWatchedState],\n )\n\n // The agency-attribute fields stay in sync with the chosen state: when the\n // user switches states, the previous attribute values would otherwise carry\n // over and potentially submit alongside the wrong agency. The ref tracks\n // the previous value so the wipe only fires on user-driven transitions —\n // NOT on the initial sync when an existing garnishment loads (state moves\n // from '' to e.g. 'AK' as a side effect of `values` updating, which would\n // otherwise clobber the loaded case/order/remittance values).\n const previousWatchedStateRef = useRef<string | null>(null)\n useEffect(() => {\n const previous = previousWatchedStateRef.current\n previousWatchedStateRef.current = liveWatchedState\n // First render (no previous value) → skip the wipe.\n if (previous === null) return\n // Server-side load: previous was '' (initial defaults before the row\n // arrived), now it's the loaded state. That's a sync, not a user toggle.\n if (previous === '') return\n if (previous === liveWatchedState) return\n formMethods.setValue('caseNumber', '')\n formMethods.setValue('orderNumber', '')\n formMethods.setValue('remittanceNumber', '')\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [liveWatchedState])\n\n // When the selected agency has a single \"all counties\" fips code, auto-fill\n // the field so the consumer doesn't have to render the county select.\n const fipsCodes = liveSelectedAgency?.fipsCodes ?? []\n const singleAllCountiesFipsCode =\n fipsCodes.length === 1 && !fipsCodes[0]?.county?.length ? (fipsCodes[0]?.code ?? null) : null\n useEffect(() => {\n if (singleAllCountiesFipsCode) {\n formMethods.setValue('fipsCode', singleAllCountiesFipsCode)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [singleAllCountiesFipsCode])\n\n const createGarnishmentMutation = useGarnishmentsCreateMutation()\n const updateGarnishmentMutation = useGarnishmentsUpdateMutation()\n const isPending = createGarnishmentMutation.isPending || updateGarnishmentMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('ChildSupportGarnishmentForm')\n\n const errorHandling = composeErrorHandler(\n isCreateMode ? [agencyDataQuery] : [agencyDataQuery, garnishmentsListQuery],\n { submitError, setSubmitError },\n )\n\n // ── Derived data exposed on the ready branch ─────────────────────────\n\n const agencies: StateFieldEntry[] = useMemo(\n () =>\n agencyList.map(a => ({\n state: a.state ?? '',\n name: a.name ?? a.state ?? '',\n manualPaymentRequired: a.manualPaymentRequired ?? false,\n })),\n [agencyList],\n )\n\n const counties: CountyEntry[] = useMemo(\n () =>\n (liveSelectedAgency?.fipsCodes ?? [])\n .filter(f => typeof f.code === 'string')\n .map(f => ({ fipsCode: f.code as string, county: f.county ?? null })),\n [liveSelectedAgency],\n )\n\n const requiredAttrKeys = useMemo(\n () => getRequiredAttrKeys(liveSelectedAgency),\n [liveSelectedAgency],\n )\n\n const hasSelectableCounties =\n counties.length > 1 || (counties.length === 1 && singleAllCountiesFipsCode == null)\n\n // ── Metadata + field-options wiring ─────────────────────────────────\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const stateOptions = agencies.map(a => ({ value: a.state, label: a.name }))\n const countyOptions = counties.map(c => ({\n value: c.fipsCode,\n label: c.county ?? c.fipsCode,\n }))\n\n const fieldsMetadata = {\n state: withOptions(baseMetadata.state, stateOptions, agencies),\n fipsCode: withOptions(baseMetadata.fipsCode, countyOptions, counties),\n caseNumber: baseMetadata.caseNumber,\n orderNumber: baseMetadata.orderNumber,\n remittanceNumber: baseMetadata.remittanceNumber,\n payPeriodMaximum: baseMetadata.payPeriodMaximum,\n amount: baseMetadata.amount,\n paymentPeriod: withOptions(\n baseMetadata.paymentPeriod,\n [...PAYMENT_PERIOD_OPTIONS],\n [...PAYMENT_PERIOD_ENTRIES],\n ),\n }\n\n // ── Submit ───────────────────────────────────────────────────────────\n\n const onSubmit = async (): Promise<HookSubmitResult<Garnishment> | undefined> => {\n let submitResult: HookSubmitResult<Garnishment> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: ChildSupportGarnishmentFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const childSupport = {\n state: payload.state,\n paymentPeriod: payload.paymentPeriod,\n fipsCode: payload.fipsCode,\n // Empty strings collapse to null so the API persists \"no value\n // declared\" rather than an empty case number.\n caseNumber: payload.caseNumber || null,\n orderNumber: payload.orderNumber || null,\n remittanceNumber: payload.remittanceNumber || null,\n }\n\n const description = `Child Support - ${childSupport.caseNumber ?? ''}`\n const amountStr = String(payload.amount)\n const payPeriodMaximumStr =\n payload.payPeriodMaximum > 0 ? String(payload.payPeriodMaximum) : null\n\n const requestBody = {\n active: true,\n amount: amountStr,\n description,\n courtOrdered: true,\n garnishmentType: 'child_support' as GarnishmentType,\n times: null,\n deductAsPercentage: true,\n payPeriodMaximum: payPeriodMaximumStr,\n recurring: true,\n childSupport,\n }\n\n let updated: Garnishment | undefined\n\n if (isCreateMode) {\n const result = await createGarnishmentMutation.mutateAsync({\n request: { employeeId, garnishmentRequest: requestBody },\n })\n updated = result.garnishment\n } else {\n if (!fetchedDeduction) {\n throw new SDKInternalError(\n 'Cannot update child-support deduction: no matching garnishment on file',\n )\n }\n const result = await updateGarnishmentMutation.mutateAsync({\n request: {\n garnishmentId: fetchedDeduction.uuid,\n updateGarnishmentRequest: {\n ...requestBody,\n version: fetchedDeduction.version as string,\n },\n },\n })\n updated = result.garnishment\n }\n\n if (!updated) {\n throw new SDKInternalError(\n isCreateMode\n ? 'Child-support deduction creation failed'\n : 'Child-support deduction update failed',\n )\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updated,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (agencyDataQuery.isLoading) {\n return { isLoading: true as const, errorHandling }\n }\n if (!isCreateMode && garnishmentsListQuery.isLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n agencies,\n counties,\n deduction: fetchedDeduction,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n selectedAgency: liveSelectedAgency,\n isManualPaymentRequired: liveSelectedAgency?.manualPaymentRequired ?? false,\n requiredAttrKeys,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n State: StateField,\n FipsCode: hasSelectableCounties ? FipsCodeField : undefined,\n CaseNumber: requiredAttrKeys.has('case_number') ? CaseNumberField : undefined,\n OrderNumber: requiredAttrKeys.has('order_number') ? OrderNumberField : undefined,\n RemittanceNumber: requiredAttrKeys.has('remittance_number')\n ? RemittanceNumberField\n : undefined,\n PayPeriodMaximum: PayPeriodMaximumField,\n Amount: AmountField,\n PaymentPeriod: PaymentPeriodField,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Per-field metadata returned by {@link useChildSupportGarnishmentForm} as `form.fieldsMetadata`.\n *\n * @remarks\n * Carries per-field `isRequired`, `isDisabled`, label, description, and option\n * entries derived from the schema and form state. Use these to drive UI such\n * as disabled state or option lists when not relying on the pre-bound\n * {@link ChildSupportGarnishmentFormFields} components.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormFieldsMetadata =\n UseChildSupportGarnishmentFormReady['form']['fieldsMetadata']\n"],"names":["PAYMENT_PERIOD_OPTIONS","PaymentPeriod","PAYMENT_PERIOD_ENTRIES","useChildSupportGarnishmentForm","employeeId","garnishmentId","partnerDefaults","validationMode","shouldFocusError","isCreateMode","schemaMode","agencyDataQuery","useGarnishmentsGetChildSupportData","agencyList","useMemo","garnishmentsListQuery","useGarnishmentsList","fetchedDeduction","g","resolvedDefaults","schema","metadataConfig","createChildSupportGarnishmentFormSchema","formMethods","useForm","zodResolver","liveWatchedState","useWatch","liveSelectedAgency","a","previousWatchedStateRef","useRef","useEffect","previous","fipsCodes","singleAllCountiesFipsCode","createGarnishmentMutation","useGarnishmentsCreateMutation","updateGarnishmentMutation","useGarnishmentsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","agencies","counties","f","requiredAttrKeys","getRequiredAttrKeys","hasSelectableCounties","baseMetadata","useDeriveFieldsMetadata","stateOptions","countyOptions","c","fieldsMetadata","withOptions","onSubmit","submitResult","resolve","data","payload","childSupport","description","amountStr","payPeriodMaximumStr","requestBody","updated","SDKInternalError","hookFormInternals","useHookFormInternals","StateField","FipsCodeField","CaseNumberField","OrderNumberField","RemittanceNumberField","PayPeriodMaximumField","AmountField","PaymentPeriodField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,MAAMA,KAAyB;AAAA,EAC7B,EAAE,OAAOC,EAAc,WAAW,OAAOA,EAAc,UAAA;AAAA,EACvD,EAAE,OAAOA,EAAc,gBAAgB,OAAOA,EAAc,eAAA;AAAA,EAC5D,EAAE,OAAOA,EAAc,eAAe,OAAOA,EAAc,cAAA;AAAA,EAC3D,EAAE,OAAOA,EAAc,SAAS,OAAOA,EAAc,QAAA;AACvD,GAEMC,KAAyB;AAAA,EAC7BD,EAAc;AAAA,EACdA,EAAc;AAAA,EACdA,EAAc;AAAA,EACdA,EAAc;AAChB;AAoLO,SAASE,GAA+B;AAAA,EAC7C,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAA8E;AAC5E,QAAMC,IAAe,CAACJ,GAChBK,IAAaD,IAAe,WAAW,UAGvCE,IAAkBC,GAAmC,EAAE,GACvDC,IAAaC;AAAA,IACjB,MAAMH,EAAgB,MAAM,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MAAM;AACJ,UAAAA,EAAA;AAAA,QACF;AAAA,MAAA,EACF;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMW,IAAoBC,GAAqBlD,CAAW;AAE1D,SAAIZ,EAAgB,YACX,EAAE,WAAW,IAAe,eAAAkC,EAAA,IAEjC,CAACpC,KAAgBM,EAAsB,YAClC,EAAE,WAAW,IAAe,eAAA8B,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,UAAAE;AAAA,MACA,UAAAC;AAAA,MACA,WAAW/B;AAAA,IAAA;AAAA,IAEb,QAAQ;AAAA,MACN,WAAAuB;AAAA,MACA,MAAM/B,IAAe,WAAW;AAAA,MAChC,gBAAgBmB;AAAA,MAChB,yBAAyBA,GAAoB,yBAAyB;AAAA,MACtE,kBAAAsB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAAU,EAAA;AAAA,IACX,eAAAf;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAO6B;AAAA,QACP,UAAUtB,IAAwBuB,KAAgB;AAAA,QAClD,YAAYzB,EAAiB,IAAI,aAAa,IAAI0B,KAAkB;AAAA,QACpE,aAAa1B,EAAiB,IAAI,cAAc,IAAI2B,KAAmB;AAAA,QACvE,kBAAkB3B,EAAiB,IAAI,mBAAmB,IACtD4B,KACA;AAAA,QACJ,kBAAkBC;AAAA,QAClB,QAAQC;AAAA,QACR,eAAeC;AAAA,MAAA;AAAA,MAEjB,gBAAAvB;AAAA,MACA,mBAAAc;AAAA,MACA,yBAAyBU,GAA8B3D,GAAaH,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeductionForm.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport {\n type Garnishment,\n type GarnishmentType,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsUpdate'\nimport { useGarnishmentsList } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsList'\nimport {\n createDeductionFormSchema,\n type DeductionFormData,\n type DeductionFormOutputs,\n type DeductionFormOptionalFieldsToRequire,\n} from './deductionFormSchema'\nimport {\n DescriptionField,\n RecurringField,\n DeductAsPercentageField,\n AmountField,\n TotalAmountField,\n AnnualMaximumField,\n GarnishmentTypeField,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nexport type { DeductionFormOptionalFieldsToRequire } from './deductionFormSchema'\n\n// GarnishmentType is a runtime enum; the schema gates which values are valid.\n// The hook's `withOptions` entries below carry the raw enum values so the\n// consumer can supply translated labels via `getOptionLabel` on the field.\n//\n// `'child_support'` is intentionally omitted — child-support garnishments\n// require agency-keyed required attributes (case number, order number,\n// remittance number, county) that this hook doesn't model. Use\n// `useChildSupportGarnishmentForm` for those.\nconst GARNISHMENT_TYPES: readonly GarnishmentType[] = [\n 'federal_tax_lien',\n 'state_tax_lien',\n 'student_loan',\n 'creditor_garnishment',\n 'federal_loan',\n 'other_garnishment',\n] as const\n\n/**\n * Configuration options for {@link useDeductionForm}.\n *\n * @remarks\n * Presence or absence of `garnishmentId` selects the API verb — see the\n * `garnishmentId` field description. `courtOrdered` selects between the\n * post-tax custom variant and the court-ordered garnishment variant.\n *\n * @public\n */\nexport interface UseDeductionFormProps {\n /** UUID of the employee whose deduction is being created or edited. */\n employeeId: string\n /**\n * When set, loads that garnishment and updates it (PUT). When omitted, the\n * form is in create mode (POST).\n */\n garnishmentId?: string\n /**\n * Court-ordered deductions are stored as garnishments with `courtOrdered: true`\n * and require a `garnishmentType` (Federal Tax Lien, Student Loan, etc.).\n * When `false`, the form is for a \"custom\" post-tax deduction —\n * `garnishmentType` is excluded from the schema and submit payload.\n *\n * Note: this hook does NOT handle `garnishmentType: 'child_support'`. Use\n * {@link useChildSupportGarnishmentForm} for child-support agency-keyed payloads.\n */\n courtOrdered: boolean\n /** Override fields that are optional on a given mode to be required. See {@link DeductionFormOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: DeductionFormOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<DeductionFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useDeductionForm().form.Fields`.\n *\n * @remarks\n * Each property is either the field component or `undefined`. A field is\n * `undefined` when conditions for rendering it aren't met — see each member\n * for its visibility rule. Always null-check conditional fields (e.g.\n * `{Fields.TotalAmount && <Fields.TotalAmount ... />}`) before rendering.\n *\n * @public\n */\nexport interface DeductionFormFields {\n /** Description text input. Always available. */\n Description: typeof DescriptionField\n /** Recurring vs one-time radio group. Always available. */\n Recurring: typeof RecurringField\n /** Fixed-amount vs percentage radio group. Always available. */\n DeductAsPercentage: typeof DeductAsPercentageField\n /** Deduction amount input. Always available. */\n Amount: typeof AmountField\n /** Only available when `status.isRecurring` is true. */\n TotalAmount: typeof TotalAmountField | undefined\n /** Only available when `status.isRecurring` is true. */\n AnnualMaximum: typeof AnnualMaximumField | undefined\n /** Only available when `courtOrdered: true`. */\n GarnishmentType: typeof GarnishmentTypeField | undefined\n}\n\n/**\n * Ready-state shape returned by {@link useDeductionForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the deduction-specific `data`, `status`, `actions`, and `form.Fields` shape.\n * Static, entity-derived values live under `data.*`; reactive values that\n * flip with form input live under `status.*`.\n *\n * @public\n */\nexport interface UseDeductionFormReady extends BaseFormHookReady<\n FieldsMetadata,\n DeductionFormData,\n DeductionFormFields\n> {\n /** Deduction-specific data payload: the loaded garnishment for update mode, or `null` in create mode. */\n data: {\n /** The garnishment loaded for update; `null` in create mode. */\n deduction: Garnishment | null\n }\n /** Submission state and reactive flags derived from current form input. */\n status: {\n /** `true` while a create or update mutation is in flight. */\n isPending: boolean\n /** Reflects whether the next submit will POST a new deduction or PUT an existing one. */\n mode: 'create' | 'update'\n /**\n * Mirrors the watched `recurring` value. Cap fields (`TotalAmount`,\n * `AnnualMaximum`) are only included on `Fields` when this is true — the\n * consumer can render them unconditionally and the gating happens in the\n * hook.\n */\n isRecurring: boolean\n }\n /** Submission action. */\n actions: {\n /** Submits the form. Returns the saved garnishment + mode on success, or `undefined` when validation fails or the request errored. */\n onSubmit: () => Promise<HookSubmitResult<Garnishment> | undefined>\n }\n}\n\n/**\n * Return value of {@link useDeductionForm}.\n *\n * @remarks\n * Discriminated union: {@link HookLoadingResult} while the existing garnishment\n * is loading (update mode only); {@link UseDeductionFormReady} once data is\n * ready. In create mode the hook returns the ready branch immediately.\n *\n * @public\n */\nexport type UseDeductionFormResult = HookLoadingResult | UseDeductionFormReady\n\n/**\n * Headless hook for creating or updating a non-child-support deduction.\n *\n * @remarks\n * Both variants — post-tax custom deductions and court-ordered garnishments —\n * share the same field set (description, frequency, deduct-as-percentage,\n * amount, optional caps) and differ only in whether the deduction is\n * court-ordered and carries a `garnishmentType`. Set `courtOrdered: true` to\n * surface the garnishment-type select; set it to `false` for a custom post-tax\n * deduction.\n *\n * Presence or absence of `garnishmentId` selects the API verb: omit it to POST\n * a new deduction, supply it to PUT updates against the existing row. For\n * child-support garnishments, use {@link useChildSupportGarnishmentForm}\n * instead — those require agency-keyed required attributes (case number,\n * order number, remittance number, county) that this hook doesn't model.\n *\n * @param input - See {@link UseDeductionFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseDeductionFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useDeductionForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function CustomDeductionPage({ employeeId, garnishmentId }: { employeeId: string; garnishmentId?: string }) {\n * const form = useDeductionForm({ employeeId, garnishmentId, courtOrdered: false })\n *\n * if (form.isLoading) return <p>Loading…</p>\n *\n * const { Fields } = form.form\n *\n * return (\n * <SDKFormProvider formHookResult={form}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void form.actions.onSubmit()\n * }}\n * >\n * <Fields.Description label=\"Description\" validationMessages={{ REQUIRED: 'Required' }} />\n * <Fields.Recurring\n * label=\"Frequency\"\n * getOptionLabel={v => (v ? 'Recurring' : 'One-time')}\n * validationMessages={{ REQUIRED: 'Required' }}\n * />\n * <Fields.Amount\n * label=\"Amount\"\n * validationMessages={{ REQUIRED: 'Required', NEGATIVE_AMOUNT: 'Must be ≥ 0' }}\n * />\n * {Fields.TotalAmount && (\n * <Fields.TotalAmount label=\"Total cap\" validationMessages={{ NEGATIVE_AMOUNT: 'Must be ≥ 0' }} />\n * )}\n * <button type=\"submit\">Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useDeductionForm({\n employeeId,\n garnishmentId,\n courtOrdered,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseDeductionFormProps): UseDeductionFormResult {\n const isCreateMode = !garnishmentId\n const schemaMode = isCreateMode ? 'create' : 'update'\n\n // The garnishments API has no single-row GET — the list endpoint is the only\n // way to retrieve an existing garnishment. We use the (non-suspense) list\n // query and pick the matching row by uuid.\n const garnishmentsListQuery = useGarnishmentsListMutationLikeLoader({\n employeeId,\n enabled: !isCreateMode,\n })\n\n const fetchedDeduction = useMemo(() => {\n if (isCreateMode) return null\n return garnishmentsListQuery.data?.find(g => g.uuid === garnishmentId) ?? null\n }, [isCreateMode, garnishmentId, garnishmentsListQuery.data])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createDeductionFormSchema({\n mode: schemaMode,\n courtOrdered,\n optionalFieldsToRequire,\n }),\n [schemaMode, courtOrdered, optionalFieldsToRequire],\n )\n\n const resolvedDefaults: DeductionFormData = useMemo(\n () => ({\n description: fetchedDeduction?.description ?? partnerDefaults?.description ?? '',\n recurring: fetchedDeduction?.recurring ?? partnerDefaults?.recurring ?? true,\n deductAsPercentage:\n fetchedDeduction?.deductAsPercentage ?? partnerDefaults?.deductAsPercentage ?? true,\n amount: fetchedDeduction?.amount\n ? Number(fetchedDeduction.amount)\n : (partnerDefaults?.amount ?? 0),\n // Caps stay as numbers in the form (0 means \"no cap\"); the hook drops\n // them to null on the wire in onSubmit.\n totalAmount: fetchedDeduction?.totalAmount\n ? Number(fetchedDeduction.totalAmount)\n : (partnerDefaults?.totalAmount ?? 0),\n annualMaximum: fetchedDeduction?.annualMaximum\n ? Number(fetchedDeduction.annualMaximum)\n : (partnerDefaults?.annualMaximum ?? 0),\n garnishmentType:\n fetchedDeduction?.garnishmentType ??\n partnerDefaults?.garnishmentType ??\n // First non-child-support type — partners typically pick via the\n // GarnishmentType select before saving.\n 'federal_tax_lien',\n }),\n [fetchedDeduction, partnerDefaults],\n )\n\n const formMethods = useForm<DeductionFormData, unknown, DeductionFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n // The cap fields only appear when the deduction is recurring. Watching here\n // (inside the hook) keeps the consumer from having to reach into\n // hookFormInternals — the conditional Fields below flip to `undefined`.\n // The `recurring` RadioGroup round-trips its value as the strings `'true'`/\n // `'false'` (only the zod preprocessor coerces to a real boolean at\n // validation time). The string `'false'` is truthy, so reading the raw\n // watched value here would leave the cap fields visible for one-time\n // deductions after a frequency toggle. Compare against both shapes — mirrors\n // the `deductAsPercentage` handling in StandardDeductionForm.\n const watchedRecurring = useWatch({ control: formMethods.control, name: 'recurring' }) as\n | boolean\n | 'true'\n | 'false'\n | undefined\n const isRecurring = watchedRecurring === true || watchedRecurring === 'true'\n\n const createGarnishmentMutation = useGarnishmentsCreateMutation()\n const updateGarnishmentMutation = useGarnishmentsUpdateMutation()\n const isPending = createGarnishmentMutation.isPending || updateGarnishmentMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('DeductionForm')\n\n const queriesForErrors = !isCreateMode ? [garnishmentsListQuery] : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const garnishmentTypeOptions = GARNISHMENT_TYPES.map(value => ({ value, label: value }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = {\n description: baseMetadata.description,\n recurring: withOptions<boolean>(\n baseMetadata.recurring,\n [\n { value: 'true', label: 'true' },\n { value: 'false', label: 'false' },\n ],\n [true, false],\n ),\n deductAsPercentage: withOptions<boolean>(\n baseMetadata.deductAsPercentage,\n [\n { value: 'true', label: 'true' },\n { value: 'false', label: 'false' },\n ],\n [true, false],\n ),\n amount: baseMetadata.amount,\n totalAmount: baseMetadata.totalAmount,\n annualMaximum: baseMetadata.annualMaximum,\n garnishmentType: courtOrdered\n ? withOptions(baseMetadata.garnishmentType, garnishmentTypeOptions, GARNISHMENT_TYPES)\n : baseMetadata.garnishmentType,\n }\n\n const onSubmit = async (): Promise<HookSubmitResult<Garnishment> | undefined> => {\n let submitResult: HookSubmitResult<Garnishment> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: DeductionFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n // The API's `times` column is \"number of remaining occurrences\" —\n // for one-time deductions we set it to 1, for recurring we null it\n // out. Matches the legacy GarnishmentForm/CustomDeductionForm.\n const times = payload.recurring ? null : 1\n // Wire conversions: amount is always a string; the optional caps\n // collapse to undefined when the partner left them at zero.\n const amountStr = String(payload.amount)\n const totalAmountStr = payload.totalAmount > 0 ? String(payload.totalAmount) : undefined\n const annualMaximumStr =\n payload.annualMaximum > 0 ? String(payload.annualMaximum) : undefined\n\n let updated: Garnishment | undefined\n\n if (isCreateMode) {\n const result = await createGarnishmentMutation.mutateAsync({\n request: {\n employeeId,\n garnishmentRequest: {\n active: true,\n description: payload.description,\n recurring: payload.recurring,\n deductAsPercentage: payload.deductAsPercentage,\n amount: amountStr,\n totalAmount: totalAmountStr,\n annualMaximum: annualMaximumStr,\n courtOrdered,\n garnishmentType: courtOrdered ? payload.garnishmentType : undefined,\n times,\n },\n },\n })\n updated = result.garnishment\n } else {\n if (!fetchedDeduction) {\n throw new SDKInternalError(\n 'Cannot update deduction: no matching garnishment on file',\n )\n }\n const result = await updateGarnishmentMutation.mutateAsync({\n request: {\n garnishmentId: fetchedDeduction.uuid,\n updateGarnishmentRequest: {\n version: fetchedDeduction.version as string,\n active: true,\n description: payload.description,\n recurring: payload.recurring,\n deductAsPercentage: payload.deductAsPercentage,\n amount: amountStr,\n totalAmount: totalAmountStr,\n annualMaximum: annualMaximumStr,\n courtOrdered,\n // The API rejects garnishment_type changes on update — only\n // include when court-ordered AND when matching the loaded\n // row's type (no-op pass-through).\n garnishmentType: courtOrdered ? payload.garnishmentType : undefined,\n times,\n },\n },\n })\n updated = result.garnishment\n }\n\n if (!updated) {\n throw new SDKInternalError(\n isCreateMode ? 'Deduction creation failed' : 'Deduction update failed',\n )\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updated,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (!isCreateMode && garnishmentsListQuery.isLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n deduction: fetchedDeduction,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n isRecurring,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Description: DescriptionField,\n Recurring: RecurringField,\n DeductAsPercentage: DeductAsPercentageField,\n Amount: AmountField,\n TotalAmount: isRecurring ? TotalAmountField : undefined,\n AnnualMaximum: isRecurring ? AnnualMaximumField : undefined,\n GarnishmentType: courtOrdered ? GarnishmentTypeField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Per-field metadata returned by {@link useDeductionForm} as `form.fieldsMetadata`.\n *\n * @remarks\n * Carries per-field `isRequired`, `isDisabled`, label, description, and option\n * entries derived from the schema and form state. Use these to drive UI such\n * as disabled state or option lists when not relying on the pre-bound\n * {@link DeductionFormFields} components.\n *\n * @public\n */\nexport type DeductionFormFieldsMetadata = UseDeductionFormReady['form']['fieldsMetadata']\n\n// ── Internal loader ─────────────────────────────────────────────────────\n//\n// `useGarnishmentsList` is the only way to retrieve an existing garnishment\n// row — the API has no single-row GET. We expose a tiny wrapper that returns\n// the array directly so the hook above can `.find()` by uuid. Skips the fetch\n// entirely in create mode via `enabled: false`.\n\nfunction useGarnishmentsListMutationLikeLoader({\n employeeId,\n enabled,\n}: {\n employeeId: string\n enabled: boolean\n}) {\n const query = useGarnishmentsList({ employeeId }, { enabled })\n return {\n data: query.data?.garnishments,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n }\n}\n"],"names":["GARNISHMENT_TYPES","useDeductionForm","employeeId","garnishmentId","courtOrdered","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","isCreateMode","schemaMode","garnishmentsListQuery","useGarnishmentsListMutationLikeLoader","fetchedDeduction","useMemo","g","schema","metadataConfig","createDeductionFormSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedRecurring","useWatch","isRecurring","createGarnishmentMutation","useGarnishmentsCreateMutation","updateGarnishmentMutation","useGarnishmentsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","garnishmentTypeOptions","value","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","withOptions","onSubmit","submitResult","resolve","data","payload","times","amountStr","totalAmountStr","annualMaximumStr","updated","SDKInternalError","hookFormInternals","useHookFormInternals","DescriptionField","RecurringField","DeductAsPercentageField","AmountField","TotalAmountField","AnnualMaximumField","GarnishmentTypeField","createGetFormSubmissionValues","enabled","query","useGarnishmentsList"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAMA,IAAgD;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsLO,SAASC,GAAiB;AAAA,EAC/B,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAAkD;AAChD,QAAMC,IAAe,CAACN,GAChBO,IAAaD,IAAe,WAAW,UAKvCE,IAAwBC,GAAsC;AAAA,IAClE,YAAAV;AAAA,IACA,SAAS,CAACO;AAAA,EAAA,CACX,GAEKI,IAAmBC,EAAQ,MAC3BL,IAAqB,OAClBE,EAAsB,MAAM,KAAK,OAAKI,EAAE,SAASZ,CAAa,KAAK,MACzE,CAACM,GAAcN,GAAeQ,EAAsB,IAAI,CAAC,GAEtD,CAACK,GAAQC,CAAc,IA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AAsB,YAClC,EAAE,WAAW,IAAe,eAAAwB,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,WAAWtB;AAAA,IAAA;AAAA,IAEb,QAAQ;AAAA,MACN,WAAAiB;AAAA,MACA,MAAMrB,IAAe,WAAW;AAAA,MAChC,aAAAgB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAAkB,EAAA;AAAA,IACX,eAAAR;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,aAAaqB;AAAA,QACb,WAAWC;AAAA,QACX,oBAAoBC;AAAA,QACpB,QAAQC;AAAA,QACR,aAAalC,IAAcmC,IAAmB;AAAA,QAC9C,eAAenC,IAAcoC,IAAqB;AAAA,QAClD,iBAAiBzD,IAAe0D,IAAuB;AAAA,MAAA;AAAA,MAEzD,gBAAArB;AAAA,MACA,mBAAAa;AAAA,MACA,yBAAyBS,GAA8B3C,GAAaJ,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;AAsBA,SAASJ,GAAsC;AAAA,EAC7C,YAAAV;AAAA,EACA,SAAA8D;AACF,GAGG;AACD,QAAMC,IAAQC,EAAoB,EAAE,YAAAhE,KAAc,EAAE,SAAA8D,GAAS;AAC7D,SAAO;AAAA,IACL,MAAMC,EAAM,MAAM;AAAA,IAClB,WAAWA,EAAM;AAAA,IACjB,OAAOA,EAAM;AAAA,IACb,SAASA,EAAM;AAAA,EAAA;AAEnB;"}
|
|
1
|
+
{"version":3,"file":"useDeductionForm.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport {\n type Garnishment,\n type GarnishmentType,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsUpdate'\nimport { useGarnishmentsList } from '@gusto/embedded-api-v-2025-11-15/react-query/garnishmentsList'\nimport {\n createDeductionFormSchema,\n type DeductionFormData,\n type DeductionFormOutputs,\n type DeductionFormOptionalFieldsToRequire,\n} from './deductionFormSchema'\nimport {\n DescriptionField,\n RecurringField,\n DeductAsPercentageField,\n AmountField,\n TotalAmountField,\n AnnualMaximumField,\n GarnishmentTypeField,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nexport type { DeductionFormOptionalFieldsToRequire } from './deductionFormSchema'\n\n// GarnishmentType is a runtime enum; the schema gates which values are valid.\n// The hook's `withOptions` entries below carry the raw enum values so the\n// consumer can supply translated labels via `getOptionLabel` on the field.\n//\n// `'child_support'` is intentionally omitted — child-support garnishments\n// require agency-keyed required attributes (case number, order number,\n// remittance number, county) that this hook doesn't model. Use\n// `useChildSupportGarnishmentForm` for those.\nconst GARNISHMENT_TYPES: readonly GarnishmentType[] = [\n 'federal_tax_lien',\n 'state_tax_lien',\n 'student_loan',\n 'creditor_garnishment',\n 'federal_loan',\n 'other_garnishment',\n] as const\n\n/**\n * Configuration options for {@link useDeductionForm}.\n *\n * @remarks\n * Presence or absence of `garnishmentId` selects the API verb — see the\n * `garnishmentId` field description. `courtOrdered` selects between the\n * post-tax custom variant and the court-ordered garnishment variant.\n *\n * @public\n */\nexport interface UseDeductionFormProps {\n /** UUID of the employee whose deduction is being created or edited. */\n employeeId: string\n /**\n * When set, loads that garnishment and updates it (PUT). When omitted, the\n * form is in create mode (POST).\n */\n garnishmentId?: string\n /**\n * Court-ordered deductions are stored as garnishments with `courtOrdered: true`\n * and require a `garnishmentType` (Federal Tax Lien, Student Loan, etc.).\n * When `false`, the form is for a \"custom\" post-tax deduction —\n * `garnishmentType` is excluded from the schema and submit payload.\n *\n * Note: this hook does NOT handle `garnishmentType: 'child_support'`. Use\n * {@link useChildSupportGarnishmentForm} for child-support agency-keyed payloads.\n */\n courtOrdered: boolean\n /** Override fields that are optional on a given mode to be required. See {@link DeductionFormOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: DeductionFormOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<DeductionFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useDeductionForm().form.Fields`.\n *\n * @remarks\n * Each property is either the field component or `undefined`. A field is\n * `undefined` when conditions for rendering it aren't met — see each member\n * for its visibility rule. Always null-check conditional fields (e.g.\n * `{Fields.TotalAmount && <Fields.TotalAmount ... />}`) before rendering.\n *\n * @public\n */\nexport interface DeductionFormFields {\n /** Description text input. Always available. */\n Description: typeof DescriptionField\n /** Recurring vs one-time radio group. Always available. */\n Recurring: typeof RecurringField\n /** Fixed-amount vs percentage radio group. Always available. */\n DeductAsPercentage: typeof DeductAsPercentageField\n /** Deduction amount input. Always available. */\n Amount: typeof AmountField\n /** Only available when `status.isRecurring` is true. */\n TotalAmount: typeof TotalAmountField | undefined\n /** Only available when `status.isRecurring` is true. */\n AnnualMaximum: typeof AnnualMaximumField | undefined\n /** Only available when `courtOrdered: true`. */\n GarnishmentType: typeof GarnishmentTypeField | undefined\n}\n\n/**\n * Ready-state shape returned by {@link useDeductionForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the deduction-specific `data`, `status`, `actions`, and `form.Fields` shape.\n * Static, entity-derived values live under `data.*`; reactive values that\n * flip with form input live under `status.*`.\n *\n * @public\n */\nexport interface UseDeductionFormReady extends BaseFormHookReady<\n FieldsMetadata,\n DeductionFormData,\n DeductionFormFields\n> {\n /** Deduction-specific data payload: the loaded garnishment for update mode, or `null` in create mode. */\n data: {\n /** The garnishment loaded for update; `null` in create mode. */\n deduction: Garnishment | null\n }\n /** Submission state and reactive flags derived from current form input. */\n status: {\n /** `true` while a create or update mutation is in flight. */\n isPending: boolean\n /** Reflects whether the next submit will POST a new deduction or PUT an existing one. */\n mode: 'create' | 'update'\n /**\n * Mirrors the watched `recurring` value. Cap fields (`TotalAmount`,\n * `AnnualMaximum`) are only included on `Fields` when this is true — the\n * consumer can render them unconditionally and the gating happens in the\n * hook.\n */\n isRecurring: boolean\n }\n /** Submission action. */\n actions: {\n /** Submits the form. Returns the saved garnishment + mode on success, or `undefined` when validation fails or the request errored. */\n onSubmit: () => Promise<HookSubmitResult<Garnishment> | undefined>\n }\n}\n\n/**\n * Return value of {@link useDeductionForm}.\n *\n * @remarks\n * Discriminated union: {@link HookLoadingResult} while the existing garnishment\n * is loading (update mode only); {@link UseDeductionFormReady} once data is\n * ready. In create mode the hook returns the ready branch immediately.\n *\n * @public\n */\nexport type UseDeductionFormResult = HookLoadingResult | UseDeductionFormReady\n\n/**\n * Headless hook for creating or updating a non-child-support deduction.\n *\n * @remarks\n * Both variants — post-tax custom deductions and court-ordered garnishments —\n * share the same field set (description, frequency, deduct-as-percentage,\n * amount, optional caps) and differ only in whether the deduction is\n * court-ordered and carries a `garnishmentType`. Set `courtOrdered: true` to\n * surface the garnishment-type select; set it to `false` for a custom post-tax\n * deduction.\n *\n * Presence or absence of `garnishmentId` selects the API verb: omit it to POST\n * a new deduction, supply it to PUT updates against the existing row. For\n * child-support garnishments, use {@link useChildSupportGarnishmentForm}\n * instead — those require agency-keyed required attributes (case number,\n * order number, remittance number, county) that this hook doesn't model.\n *\n * @param input - See {@link UseDeductionFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseDeductionFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useDeductionForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function CustomDeductionPage({ employeeId, garnishmentId }: { employeeId: string; garnishmentId?: string }) {\n * const form = useDeductionForm({ employeeId, garnishmentId, courtOrdered: false })\n *\n * if (form.isLoading) return <p>Loading…</p>\n *\n * const { Fields } = form.form\n *\n * return (\n * <SDKFormProvider formHookResult={form}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void form.actions.onSubmit()\n * }}\n * >\n * <Fields.Description label=\"Description\" validationMessages={{ REQUIRED: 'Required' }} />\n * <Fields.Recurring\n * label=\"Frequency\"\n * getOptionLabel={v => (v ? 'Recurring' : 'One-time')}\n * validationMessages={{ REQUIRED: 'Required' }}\n * />\n * <Fields.Amount\n * label=\"Amount\"\n * validationMessages={{ REQUIRED: 'Required', NEGATIVE_AMOUNT: 'Must be ≥ 0' }}\n * />\n * {Fields.TotalAmount && (\n * <Fields.TotalAmount label=\"Total cap\" validationMessages={{ NEGATIVE_AMOUNT: 'Must be ≥ 0' }} />\n * )}\n * <button type=\"submit\">Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useDeductionForm({\n employeeId,\n garnishmentId,\n courtOrdered,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseDeductionFormProps): UseDeductionFormResult {\n const isCreateMode = !garnishmentId\n const schemaMode = isCreateMode ? 'create' : 'update'\n\n // The garnishments API has no single-row GET — the list endpoint is the only\n // way to retrieve an existing garnishment. We use the (non-suspense) list\n // query and pick the matching row by uuid.\n const garnishmentsListQuery = useGarnishmentsListMutationLikeLoader({\n employeeId,\n enabled: !isCreateMode,\n })\n\n const fetchedDeduction = useMemo(() => {\n if (isCreateMode) return null\n return garnishmentsListQuery.data?.find(g => g.uuid === garnishmentId) ?? null\n }, [isCreateMode, garnishmentId, garnishmentsListQuery.data])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createDeductionFormSchema({\n mode: schemaMode,\n courtOrdered,\n optionalFieldsToRequire,\n }),\n [schemaMode, courtOrdered, optionalFieldsToRequire],\n )\n\n const resolvedDefaults: DeductionFormData = useMemo(\n () => ({\n description: fetchedDeduction?.description ?? partnerDefaults?.description ?? '',\n recurring: fetchedDeduction?.recurring ?? partnerDefaults?.recurring ?? true,\n deductAsPercentage:\n fetchedDeduction?.deductAsPercentage ?? partnerDefaults?.deductAsPercentage ?? true,\n amount: fetchedDeduction?.amount\n ? Number(fetchedDeduction.amount)\n : (partnerDefaults?.amount ?? 0),\n // Caps stay as numbers in the form (0 means \"no cap\"); the hook drops\n // them to null on the wire in onSubmit.\n totalAmount: fetchedDeduction?.totalAmount\n ? Number(fetchedDeduction.totalAmount)\n : (partnerDefaults?.totalAmount ?? 0),\n annualMaximum: fetchedDeduction?.annualMaximum\n ? Number(fetchedDeduction.annualMaximum)\n : (partnerDefaults?.annualMaximum ?? 0),\n garnishmentType:\n fetchedDeduction?.garnishmentType ??\n partnerDefaults?.garnishmentType ??\n // First non-child-support type — partners typically pick via the\n // GarnishmentType select before saving.\n 'federal_tax_lien',\n }),\n [fetchedDeduction, partnerDefaults],\n )\n\n const formMethods = useForm<DeductionFormData, unknown, DeductionFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n // The cap fields only appear when the deduction is recurring. Watching here\n // (inside the hook) keeps the consumer from having to reach into\n // hookFormInternals — the conditional Fields below flip to `undefined`.\n // The `recurring` RadioGroup round-trips its value as the strings `'true'`/\n // `'false'` (only the zod preprocessor coerces to a real boolean at\n // validation time). The string `'false'` is truthy, so reading the raw\n // watched value here would leave the cap fields visible for one-time\n // deductions after a frequency toggle. Compare against both shapes — mirrors\n // the `deductAsPercentage` handling in StandardDeductionForm.\n const watchedRecurring = useWatch({ control: formMethods.control, name: 'recurring' }) as\n boolean | 'true' | 'false' | undefined\n const isRecurring = watchedRecurring === true || watchedRecurring === 'true'\n\n const createGarnishmentMutation = useGarnishmentsCreateMutation()\n const updateGarnishmentMutation = useGarnishmentsUpdateMutation()\n const isPending = createGarnishmentMutation.isPending || updateGarnishmentMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('DeductionForm')\n\n const queriesForErrors = !isCreateMode ? [garnishmentsListQuery] : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const garnishmentTypeOptions = GARNISHMENT_TYPES.map(value => ({ value, label: value }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = {\n description: baseMetadata.description,\n recurring: withOptions<boolean>(\n baseMetadata.recurring,\n [\n { value: 'true', label: 'true' },\n { value: 'false', label: 'false' },\n ],\n [true, false],\n ),\n deductAsPercentage: withOptions<boolean>(\n baseMetadata.deductAsPercentage,\n [\n { value: 'true', label: 'true' },\n { value: 'false', label: 'false' },\n ],\n [true, false],\n ),\n amount: baseMetadata.amount,\n totalAmount: baseMetadata.totalAmount,\n annualMaximum: baseMetadata.annualMaximum,\n garnishmentType: courtOrdered\n ? withOptions(baseMetadata.garnishmentType, garnishmentTypeOptions, GARNISHMENT_TYPES)\n : baseMetadata.garnishmentType,\n }\n\n const onSubmit = async (): Promise<HookSubmitResult<Garnishment> | undefined> => {\n let submitResult: HookSubmitResult<Garnishment> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: DeductionFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n // The API's `times` column is \"number of remaining occurrences\" —\n // for one-time deductions we set it to 1, for recurring we null it\n // out. Matches the legacy GarnishmentForm/CustomDeductionForm.\n const times = payload.recurring ? null : 1\n // Wire conversions: amount is always a string; the optional caps\n // collapse to undefined when the partner left them at zero.\n const amountStr = String(payload.amount)\n const totalAmountStr = payload.totalAmount > 0 ? String(payload.totalAmount) : undefined\n const annualMaximumStr =\n payload.annualMaximum > 0 ? String(payload.annualMaximum) : undefined\n\n let updated: Garnishment | undefined\n\n if (isCreateMode) {\n const result = await createGarnishmentMutation.mutateAsync({\n request: {\n employeeId,\n garnishmentRequest: {\n active: true,\n description: payload.description,\n recurring: payload.recurring,\n deductAsPercentage: payload.deductAsPercentage,\n amount: amountStr,\n totalAmount: totalAmountStr,\n annualMaximum: annualMaximumStr,\n courtOrdered,\n garnishmentType: courtOrdered ? payload.garnishmentType : undefined,\n times,\n },\n },\n })\n updated = result.garnishment\n } else {\n if (!fetchedDeduction) {\n throw new SDKInternalError(\n 'Cannot update deduction: no matching garnishment on file',\n )\n }\n const result = await updateGarnishmentMutation.mutateAsync({\n request: {\n garnishmentId: fetchedDeduction.uuid,\n updateGarnishmentRequest: {\n version: fetchedDeduction.version as string,\n active: true,\n description: payload.description,\n recurring: payload.recurring,\n deductAsPercentage: payload.deductAsPercentage,\n amount: amountStr,\n totalAmount: totalAmountStr,\n annualMaximum: annualMaximumStr,\n courtOrdered,\n // The API rejects garnishment_type changes on update — only\n // include when court-ordered AND when matching the loaded\n // row's type (no-op pass-through).\n garnishmentType: courtOrdered ? payload.garnishmentType : undefined,\n times,\n },\n },\n })\n updated = result.garnishment\n }\n\n if (!updated) {\n throw new SDKInternalError(\n isCreateMode ? 'Deduction creation failed' : 'Deduction update failed',\n )\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updated,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (!isCreateMode && garnishmentsListQuery.isLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n deduction: fetchedDeduction,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n isRecurring,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Description: DescriptionField,\n Recurring: RecurringField,\n DeductAsPercentage: DeductAsPercentageField,\n Amount: AmountField,\n TotalAmount: isRecurring ? TotalAmountField : undefined,\n AnnualMaximum: isRecurring ? AnnualMaximumField : undefined,\n GarnishmentType: courtOrdered ? GarnishmentTypeField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Per-field metadata returned by {@link useDeductionForm} as `form.fieldsMetadata`.\n *\n * @remarks\n * Carries per-field `isRequired`, `isDisabled`, label, description, and option\n * entries derived from the schema and form state. Use these to drive UI such\n * as disabled state or option lists when not relying on the pre-bound\n * {@link DeductionFormFields} components.\n *\n * @public\n */\nexport type DeductionFormFieldsMetadata = UseDeductionFormReady['form']['fieldsMetadata']\n\n// ── Internal loader ─────────────────────────────────────────────────────\n//\n// `useGarnishmentsList` is the only way to retrieve an existing garnishment\n// row — the API has no single-row GET. We expose a tiny wrapper that returns\n// the array directly so the hook above can `.find()` by uuid. Skips the fetch\n// entirely in create mode via `enabled: false`.\n\nfunction useGarnishmentsListMutationLikeLoader({\n employeeId,\n enabled,\n}: {\n employeeId: string\n enabled: boolean\n}) {\n const query = useGarnishmentsList({ employeeId }, { enabled })\n return {\n data: query.data?.garnishments,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n }\n}\n"],"names":["GARNISHMENT_TYPES","useDeductionForm","employeeId","garnishmentId","courtOrdered","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","isCreateMode","schemaMode","garnishmentsListQuery","useGarnishmentsListMutationLikeLoader","fetchedDeduction","useMemo","g","schema","metadataConfig","createDeductionFormSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedRecurring","useWatch","isRecurring","createGarnishmentMutation","useGarnishmentsCreateMutation","updateGarnishmentMutation","useGarnishmentsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","garnishmentTypeOptions","value","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","withOptions","onSubmit","submitResult","resolve","data","payload","times","amountStr","totalAmountStr","annualMaximumStr","updated","SDKInternalError","hookFormInternals","useHookFormInternals","DescriptionField","RecurringField","DeductAsPercentageField","AmountField","TotalAmountField","AnnualMaximumField","GarnishmentTypeField","createGetFormSubmissionValues","enabled","query","useGarnishmentsList"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAMA,IAAgD;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsLO,SAASC,GAAiB;AAAA,EAC/B,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAAkD;AAChD,QAAMC,IAAe,CAACN,GAChBO,IAAaD,IAAe,WAAW,UAKvCE,IAAwBC,GAAsC;AAAA,IAClE,YAAAV;AAAA,IACA,SAAS,CAACO;AAAA,EAAA,CACX,GAEKI,IAAmBC,EAAQ,MAC3BL,IAAqB,OAClBE,EAAsB,MAAM,KAAK,OAAKI,EAAE,SAASZ,CAAa,KAAK,MACzE,CAACM,GAAcN,GAAeQ,EAAsB,IAAI,CAAC,GAEtD,CAACK,GAAQC,CAAc,IAAIH;AAAA,IAC/B,MACEI,EAA0B;AAAA,MACxB,MAAMR;AAAA,MACN,cAAAN;AAAA,MACA,yBAAAC;AAAA,IAAA,CACD;AAAA,IACH,CAACK,GAAYN,GAAcC,CAAuB;AAAA,EA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AiB;AAAA,MACA,MAAMrB,IAAe,WAAW;AAAA,MAChC,aAAAgB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAAkB,EAAA;AAAA,IACX,eAAAR;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,aAAaqB;AAAA,QACb,WAAWC;AAAA,QACX,oBAAoBC;AAAA,QACpB,QAAQC;AAAA,QACR,aAAalC,IAAcmC,IAAmB;AAAA,QAC9C,eAAenC,IAAcoC,IAAqB;AAAA,QAClD,iBAAiBzD,IAAe0D,IAAuB;AAAA,MAAA;AAAA,MAEzD,gBAAArB;AAAA,MACA,mBAAAa;AAAA,MACA,yBAAyBS,GAA8B3C,GAAaJ,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;AAsBA,SAASJ,GAAsC;AAAA,EAC7C,YAAAV;AAAA,EACA,SAAA8D;AACF,GAGG;AACD,QAAMC,IAAQC,EAAoB,EAAE,YAAAhE,KAAc,EAAE,SAAA8D,GAAS;AAC7D,SAAO;AAAA,IACL,MAAMC,EAAM,MAAM;AAAA,IAClB,WAAWA,EAAM;AAAA,IACjB,OAAOA,EAAM;AAAA,IACb,SAASA,EAAM;AAAA,EAAA;AAEnB;"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { BaseComponentInterface } from '../../../Base';
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link DocumentManager}.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface DocumentManagerProps extends BaseComponentInterface<'Employee.DocumentManager'> {
|
|
8
|
+
/** The associated employee identifier. */
|
|
4
9
|
employeeId: string;
|
|
10
|
+
/** The identifier of the form to display. */
|
|
5
11
|
formId: string;
|
|
6
12
|
}
|
|
7
13
|
/**
|
|
@@ -10,6 +16,15 @@ export interface DocumentManagerProps {
|
|
|
10
16
|
* Signing is intentionally not offered here; forms are signed by the employee
|
|
11
17
|
* during onboarding, not by an admin viewing the dashboard.
|
|
12
18
|
*
|
|
13
|
-
* @
|
|
19
|
+
* @remarks
|
|
20
|
+
* Emits the following events:
|
|
21
|
+
*
|
|
22
|
+
* @events
|
|
23
|
+
* | Event | Description | Data |
|
|
24
|
+
* | ----- | ----------- | ---- |
|
|
25
|
+
* | `CANCEL` | The back button is selected | — |
|
|
26
|
+
*
|
|
27
|
+
* @param props - See {@link DocumentManagerProps}.
|
|
28
|
+
* @public
|
|
14
29
|
*/
|
|
15
|
-
export declare function DocumentManager(props: DocumentManagerProps
|
|
30
|
+
export declare function DocumentManager(props: DocumentManagerProps): import("react").JSX.Element;
|
|
@@ -14,7 +14,10 @@ import { DocumentViewer as x } from "../../../Common/DocumentViewer/DocumentView
|
|
|
14
14
|
function P(o) {
|
|
15
15
|
return h("Employee.DocumentManager"), /* @__PURE__ */ e(d, { ...o, componentName: "Employee.DocumentManager", children: /* @__PURE__ */ e(w, { employeeId: o.employeeId, formId: o.formId }) });
|
|
16
16
|
}
|
|
17
|
-
function w({
|
|
17
|
+
function w({
|
|
18
|
+
employeeId: o,
|
|
19
|
+
formId: i
|
|
20
|
+
}) {
|
|
18
21
|
const { t: r } = s("Employee.DocumentManager"), t = g(), { onEvent: a } = C(), {
|
|
19
22
|
data: { form: n }
|
|
20
23
|
} = u({ employeeId: o, formId: i }), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentManager.js","sources":["../../../../../src/components/Employee/Documents/management/DocumentManager.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { useEmployeeFormsGetSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/employeeFormsGet'\nimport { useEmployeeFormsGetPdfSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/employeeFormsGetPdf'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { ActionsLayout, Flex } from '@/components/Common'\nimport { DocumentViewer } from '@/components/Common/DocumentViewer'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\n\n
|
|
1
|
+
{"version":3,"file":"DocumentManager.js","sources":["../../../../../src/components/Employee/Documents/management/DocumentManager.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { useEmployeeFormsGetSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/employeeFormsGet'\nimport { useEmployeeFormsGetPdfSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/employeeFormsGetPdf'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { BaseComponentKeys } from '@/components/Base/Base'\nimport { ActionsLayout, Flex } from '@/components/Common'\nimport { DocumentViewer } from '@/components/Common/DocumentViewer'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\n\n/**\n * Props for {@link DocumentManager}.\n *\n * @public\n */\nexport interface DocumentManagerProps extends BaseComponentInterface<'Employee.DocumentManager'> {\n /** The associated employee identifier. */\n employeeId: string\n /** The identifier of the form to display. */\n formId: string\n}\n\n/**\n * Read-only document viewer for the admin-facing employee dashboard. Renders the\n * selected form's PDF — including unsigned forms, which are shown as-is.\n * Signing is intentionally not offered here; forms are signed by the employee\n * during onboarding, not by an admin viewing the dashboard.\n *\n * @remarks\n * Emits the following events:\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `CANCEL` | The back button is selected | — |\n *\n * @param props - See {@link DocumentManagerProps}.\n * @public\n */\nexport function DocumentManager(props: DocumentManagerProps) {\n useI18n('Employee.DocumentManager')\n return (\n <BaseComponent {...props} componentName=\"Employee.DocumentManager\">\n <DocumentManagerRoot employeeId={props.employeeId} formId={props.formId} />\n </BaseComponent>\n )\n}\n\nfunction DocumentManagerRoot({\n employeeId,\n formId,\n}: Omit<DocumentManagerProps, BaseComponentKeys>) {\n const { t } = useTranslation('Employee.DocumentManager')\n const Components = useComponentContext()\n const { onEvent } = useBase()\n\n const {\n data: { form },\n } = useEmployeeFormsGetSuspense({ employeeId, formId })\n const {\n data: { formPdf },\n } = useEmployeeFormsGetPdfSuspense({ employeeId, formId })\n\n const pdfUrl = formPdf?.documentUrl\n\n if (!form) return null\n\n return (\n <Flex flexDirection=\"column\" gap={16}>\n {form.title && <Components.Heading as=\"h2\">{form.title}</Components.Heading>}\n {pdfUrl && (\n <Components.Text>\n <Trans\n t={t}\n i18nKey=\"downloadDocumentCta\"\n components={{\n downloadLink: (\n <Components.Link\n href={pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n download={`${form.title || 'form'}.pdf`}\n />\n ),\n }}\n />\n </Components.Text>\n )}\n <DocumentViewer url={pdfUrl} title={form.title} viewDocumentLabel={t('viewDocumentCta')} />\n\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.CANCEL)\n }}\n >\n {t('backCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n )\n}\n"],"names":["DocumentManager","props","useI18n","jsx","BaseComponent","DocumentManagerRoot","employeeId","formId","t","useTranslation","Components","useComponentContext","onEvent","useBase","form","useEmployeeFormsGetSuspense","formPdf","useEmployeeFormsGetPdfSuspense","pdfUrl","jsxs","Flex","Trans","DocumentViewer","ActionsLayout","componentEvents"],"mappings":";;;;;;;;;;;;;AAwCO,SAASA,EAAgBC,GAA6B;AAC3D,SAAAC,EAAQ,0BAA0B,GAEhC,gBAAAC,EAACC,GAAA,EAAe,GAAGH,GAAO,eAAc,4BACtC,UAAA,gBAAAE,EAACE,GAAA,EAAoB,YAAYJ,EAAM,YAAY,QAAQA,EAAM,QAAQ,GAC3E;AAEJ;AAEA,SAASI,EAAoB;AAAA,EAC3B,YAAAC;AAAA,EACA,QAAAC;AACF,GAAkD;AAChD,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,0BAA0B,GACjDC,IAAaC,EAAA,GACb,EAAE,SAA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OnEventType } from '../../../Base/useBase';
|
|
1
|
+
import { BaseComponentInterface } from '../../../Base';
|
|
4
2
|
/**
|
|
5
3
|
* Props for {@link Documents}.
|
|
6
4
|
*
|
|
7
5
|
* @public
|
|
8
6
|
*/
|
|
9
|
-
export interface DocumentsProps extends
|
|
7
|
+
export interface DocumentsProps extends BaseComponentInterface<'Employee.Management.Documents'> {
|
|
10
8
|
/** The associated employee identifier. */
|
|
11
9
|
employeeId: string;
|
|
12
|
-
/** Event handler fired on flow state changes. */
|
|
13
|
-
onEvent: OnEventType<EventType, unknown>;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
16
12
|
* Standalone employee documents management flow.
|
|
@@ -21,6 +17,7 @@ export interface DocumentsProps extends CommonComponentInterface<'Employee.Manag
|
|
|
21
17
|
* View CTA is selected; cancelling from the document manager returns to the
|
|
22
18
|
* card.
|
|
23
19
|
*
|
|
20
|
+
* @events
|
|
24
21
|
* | Event | Description | Data |
|
|
25
22
|
* | ----- | ----------- | ---- |
|
|
26
23
|
* | `employee/management/documents/card/viewRequested` | Fired when a row's View CTA is clicked on the documents card | `{ employeeId: string; formId: string }` |
|
|
@@ -29,4 +26,4 @@ export interface DocumentsProps extends CommonComponentInterface<'Employee.Manag
|
|
|
29
26
|
* @returns The documents management flow.
|
|
30
27
|
* @public
|
|
31
28
|
*/
|
|
32
|
-
export declare function Documents({ dictionary, FallbackComponent, ...props }: DocumentsProps
|
|
29
|
+
export declare function Documents({ dictionary, FallbackComponent, ...props }: DocumentsProps): import("react").JSX.Element;
|
|
@@ -19,11 +19,7 @@ function D({ employeeId: o, onEvent: e }) {
|
|
|
19
19
|
);
|
|
20
20
|
return /* @__PURE__ */ n(u, { machine: m, onEvent: e });
|
|
21
21
|
}
|
|
22
|
-
function w({
|
|
23
|
-
dictionary: o,
|
|
24
|
-
FallbackComponent: e,
|
|
25
|
-
...m
|
|
26
|
-
}) {
|
|
22
|
+
function w({ dictionary: o, FallbackComponent: e, ...m }) {
|
|
27
23
|
return s("Employee.Management.Documents", o), /* @__PURE__ */ n(
|
|
28
24
|
p,
|
|
29
25
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Documents.js","sources":["../../../../../src/components/Employee/Documents/management/Documents.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { DocumentsCardContextual, type DocumentsContextInterface } from './DocumentsComponents'\nimport { documentsStateMachine } from './documentsStateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport {
|
|
1
|
+
{"version":3,"file":"Documents.js","sources":["../../../../../src/components/Employee/Documents/management/Documents.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { DocumentsCardContextual, type DocumentsContextInterface } from './DocumentsComponents'\nimport { documentsStateMachine } from './documentsStateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseBoundaries, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { useI18n } from '@/i18n'\n\n/**\n * Props for {@link Documents}.\n *\n * @public\n */\nexport interface DocumentsProps extends BaseComponentInterface<'Employee.Management.Documents'> {\n /** The associated employee identifier. */\n employeeId: string\n}\n\nfunction DocumentsFlow({ employeeId, onEvent }: DocumentsProps) {\n useI18n('Employee.Management.Documents')\n\n const machine = useMemo(\n () =>\n createMachine('card', documentsStateMachine, (ctx: DocumentsContextInterface) => ({\n ...ctx,\n component: DocumentsCardContextual,\n employeeId,\n })),\n [employeeId],\n )\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n\n/**\n * Standalone employee documents management flow.\n *\n * @remarks\n * Orchestrates the documents card and the per-form document manager. The flow\n * starts on the documents card and routes to the document manager when a row's\n * View CTA is selected; cancelling from the document manager returns to the\n * card.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/documents/card/viewRequested` | Fired when a row's View CTA is clicked on the documents card | `{ employeeId: string; formId: string }` |\n *\n * @param props - See {@link DocumentsProps}.\n * @returns The documents management flow.\n * @public\n */\nexport function Documents({ dictionary, FallbackComponent, ...props }: DocumentsProps) {\n useComponentDictionary('Employee.Management.Documents', dictionary)\n return (\n <BaseBoundaries\n componentName=\"Employee.Management.Documents\"\n FallbackComponent={FallbackComponent}\n >\n <DocumentsFlow {...props} />\n </BaseBoundaries>\n )\n}\n"],"names":["DocumentsFlow","employeeId","onEvent","useI18n","machine","useMemo","createMachine","documentsStateMachine","ctx","DocumentsCardContextual","jsx","Flow","Documents","dictionary","FallbackComponent","props","useComponentDictionary","BaseBoundaries"],"mappings":";;;;;;;;;AAmBA,SAASA,EAAc,EAAE,YAAAC,GAAY,SAAAC,KAA2B;AAC9D,EAAAC,EAAQ,+BAA+B;AAEvC,QAAMC,IAAUC;AAAA,IACd,MACEC,EAAc,QAAQC,GAAuB,CAACC,OAAoC;AAAA,MAChF,GAAGA;AAAA,MACH,WAAWC;AAAA,MACX,YAAAR;AAAA,IAAA,EACA;AAAA,IACJ,CAACA,CAAU;AAAA,EAAA;AAGb,SAAO,gBAAAS,EAACC,GAAA,EAAK,SAAAP,GAAkB,SAAAF,EAAA,CAAkB;AACnD;AAoBO,SAASU,EAAU,EAAE,YAAAC,GAAY,mBAAAC,GAAmB,GAAGC,KAAyB;AACrF,SAAAC,EAAuB,iCAAiCH,CAAU,GAEhE,gBAAAH;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,mBAAAH;AAAA,MAEA,UAAA,gBAAAJ,EAACV,GAAA,EAAe,GAAGe,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGhC;"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { state as t, transition as r, reduce as n } from "robot3";
|
|
2
2
|
import { DocumentManagerContextual as a, DocumentsCardContextual as c } from "./DocumentsComponents.js";
|
|
3
3
|
import { componentEvents as e } from "../../../../shared/constants.js";
|
|
4
|
-
const E = n(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})
|
|
10
|
-
), C = {
|
|
4
|
+
const E = n((o) => ({
|
|
5
|
+
...o,
|
|
6
|
+
component: c,
|
|
7
|
+
formId: void 0
|
|
8
|
+
})), C = {
|
|
11
9
|
card: t(
|
|
12
10
|
r(
|
|
13
11
|
e.EMPLOYEE_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentsStateMachine.js","sources":["../../../../../src/components/Employee/Documents/management/documentsStateMachine.ts"],"sourcesContent":["import { reduce, state, transition } from 'robot3'\nimport type { ComponentType } from 'react'\nimport type { DocumentsContextInterface } from './DocumentsComponents'\nimport { DocumentsCardContextual, DocumentManagerContextual } from './DocumentsComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\n\ntype EventPayloads = {\n [componentEvents.EMPLOYEE_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED]: {\n employeeId: string\n formId: string\n }\n}\n\nconst returnToCard = reduce(
|
|
1
|
+
{"version":3,"file":"documentsStateMachine.js","sources":["../../../../../src/components/Employee/Documents/management/documentsStateMachine.ts"],"sourcesContent":["import { reduce, state, transition } from 'robot3'\nimport type { ComponentType } from 'react'\nimport type { DocumentsContextInterface } from './DocumentsComponents'\nimport { DocumentsCardContextual, DocumentManagerContextual } from './DocumentsComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\n\ntype EventPayloads = {\n [componentEvents.EMPLOYEE_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED]: {\n employeeId: string\n formId: string\n }\n}\n\nconst returnToCard = reduce((ctx: DocumentsContextInterface): DocumentsContextInterface => ({\n ...ctx,\n component: DocumentsCardContextual as ComponentType,\n formId: undefined,\n}))\n\n/** @internal */\nexport const documentsStateMachine = {\n card: state<MachineTransition>(\n transition(\n componentEvents.EMPLOYEE_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED,\n 'viewForm',\n reduce(\n (\n ctx: DocumentsContextInterface,\n ev: MachineEventType<\n EventPayloads,\n typeof componentEvents.EMPLOYEE_MANAGEMENT_DOCUMENTS_CARD_VIEW_REQUESTED\n >,\n ): DocumentsContextInterface => ({\n ...ctx,\n component: DocumentManagerContextual as ComponentType,\n formId: ev.payload.formId,\n }),\n ),\n ),\n ),\n viewForm: state<MachineTransition>(transition(componentEvents.CANCEL, 'card', returnToCard)),\n}\n"],"names":["returnToCard","reduce","ctx","DocumentsCardContextual","documentsStateMachine","state","transition","componentEvents","ev","DocumentManagerContextual"],"mappings":";;;AAcA,MAAMA,IAAeC,EAAO,CAACC,OAA+D;AAAA,EAC1F,GAAGA;AAAA,EACH,WAAWC;AAAA,EACX,QAAQ;AACV,EAAE,GAGWC,IAAwB;AAAA,EACnC,MAAMC;AAAA,IACJC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAN;AAAA,QACE,CACEC,GACAM,OAI+B;AAAA,UAC/B,GAAGN;AAAA,UACH,WAAWO;AAAA,UACX,QAAQD,EAAG,QAAQ;AAAA,QAAA;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAAA,EAEF,UAAUH,EAAyBC,EAAWC,EAAgB,QAAQ,QAAQP,CAAY,CAAC;AAC7F;"}
|
package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { BaseComponentInterface } from '../../../../../Base/Base';
|
|
|
4
4
|
*
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export interface DocumentListProps extends BaseComponentInterface {
|
|
7
|
+
export interface DocumentListProps extends BaseComponentInterface<'Employee.DocumentSigner'> {
|
|
8
8
|
/** The associated employee identifier. */
|
|
9
9
|
employeeId: string;
|
|
10
10
|
}
|
|
@@ -15,6 +15,7 @@ export interface DocumentListProps extends BaseComponentInterface {
|
|
|
15
15
|
* Fetches the employee's forms and renders the list of documents that still
|
|
16
16
|
* require signing along with a continue action once everything is signed.
|
|
17
17
|
*
|
|
18
|
+
* @events
|
|
18
19
|
* | Event | Description | Data |
|
|
19
20
|
* | ----- | ----------- | ---- |
|
|
20
21
|
* | `employee/forms/view` | Fired when a form's "Sign" action is selected | `{ uuid: string; name?: string }` |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentList.js","sources":["../../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.tsx"],"sourcesContent":["import { useEmployeeFormsListSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/employeeFormsList'\nimport { type Form } from '@gusto/embedded-api-v-2025-11-15/models/components/form'\nimport { Head } from './Head'\nimport { List } from './List'\nimport { Actions } from './Actions'\nimport { DocumentListProvider } from './useDocumentList'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Flex } from '@/components/Common'\n\n/**\n * Props for {@link DocumentList}.\n *\n * @public\n */\nexport interface DocumentListProps extends BaseComponentInterface {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Lists the employee's documents pending signature.\n *\n * @remarks\n * Fetches the employee's forms and renders the list of documents that still\n * require signing along with a continue action once everything is signed.\n *\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/forms/view` | Fired when a form's \"Sign\" action is selected | `{ uuid: string; name?: string }` |\n * | `employee/forms/done` | Fired when all required forms have been signed and the parent flow can advance | — |\n *\n * @param props - See {@link DocumentListProps}.\n * @returns The employee document list.\n * @public\n */\nexport function DocumentList(props: DocumentListProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, className, children }: DocumentListProps) {\n useI18n('Employee.DocumentSigner')\n const { onEvent } = useBase()\n\n const { data, error: documentListError } = useEmployeeFormsListSuspense({ employeeId })\n const employeeForms = data.forms!\n\n const hasSignedAllForms = employeeForms.every(employeeForm => !employeeForm.requiresSigning)\n\n const handleRequestFormToSign = (data: Form) => {\n const fullForm = employeeForms.find(f => f.uuid === data.uuid)\n onEvent(componentEvents.EMPLOYEE_VIEW_FORM_TO_SIGN, { uuid: data.uuid, name: fullForm?.name })\n }\n\n const handleContinue = () => {\n onEvent(componentEvents.EMPLOYEE_FORMS_DONE)\n }\n\n return (\n <section className={className}>\n <DocumentListProvider\n value={{\n employeeForms,\n hasSignedAllForms,\n handleContinue,\n handleRequestFormToSign,\n documentListError,\n }}\n >\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Actions />\n </Flex>\n )}\n </DocumentListProvider>\n </section>\n )\n}\n"],"names":["DocumentList","props","jsx","BaseComponent","Root","employeeId","className","children","useI18n","onEvent","useBase","data","documentListError","useEmployeeFormsListSuspense","employeeForms","hasSignedAllForms","employeeForm","DocumentListProvider","componentEvents","fullForm","jsxs","Flex","Head","List","Actions"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DocumentList.js","sources":["../../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.tsx"],"sourcesContent":["import { useEmployeeFormsListSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/employeeFormsList'\nimport { type Form } from '@gusto/embedded-api-v-2025-11-15/models/components/form'\nimport { Head } from './Head'\nimport { List } from './List'\nimport { Actions } from './Actions'\nimport { DocumentListProvider } from './useDocumentList'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Flex } from '@/components/Common'\n\n/**\n * Props for {@link DocumentList}.\n *\n * @public\n */\nexport interface DocumentListProps extends BaseComponentInterface<'Employee.DocumentSigner'> {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Lists the employee's documents pending signature.\n *\n * @remarks\n * Fetches the employee's forms and renders the list of documents that still\n * require signing along with a continue action once everything is signed.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/forms/view` | Fired when a form's \"Sign\" action is selected | `{ uuid: string; name?: string }` |\n * | `employee/forms/done` | Fired when all required forms have been signed and the parent flow can advance | — |\n *\n * @param props - See {@link DocumentListProps}.\n * @returns The employee document list.\n * @public\n */\nexport function DocumentList(props: DocumentListProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, className, children }: DocumentListProps) {\n useI18n('Employee.DocumentSigner')\n const { onEvent } = useBase()\n\n const { data, error: documentListError } = useEmployeeFormsListSuspense({ employeeId })\n const employeeForms = data.forms!\n\n const hasSignedAllForms = employeeForms.every(employeeForm => !employeeForm.requiresSigning)\n\n const handleRequestFormToSign = (data: Form) => {\n const fullForm = employeeForms.find(f => f.uuid === data.uuid)\n onEvent(componentEvents.EMPLOYEE_VIEW_FORM_TO_SIGN, { uuid: data.uuid, name: fullForm?.name })\n }\n\n const handleContinue = () => {\n onEvent(componentEvents.EMPLOYEE_FORMS_DONE)\n }\n\n return (\n <section className={className}>\n <DocumentListProvider\n value={{\n employeeForms,\n hasSignedAllForms,\n handleContinue,\n handleRequestFormToSign,\n documentListError,\n }}\n >\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Actions />\n </Flex>\n )}\n </DocumentListProvider>\n </section>\n )\n}\n"],"names":["DocumentList","props","jsx","BaseComponent","Root","employeeId","className","children","useI18n","onEvent","useBase","data","documentListError","useEmployeeFormsListSuspense","employeeForms","hasSignedAllForms","employeeForm","DocumentListProvider","componentEvents","fullForm","jsxs","Flex","Head","List","Actions"],"mappings":";;;;;;;;;;;;;;AAuCO,SAASA,EAAaC,GAA0B;AACrD,SACE,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAEA,SAASG,EAAK,EAAE,YAAAC,GAAY,WAAAC,GAAW,UAAAC,KAA+B;AACpE,EAAAC,EAAQ,yBAAyB;AACjC,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA,GAEd,EAAE,MAAAC,GAAM,OAAOC,EAAA,IAAsBC,EAA6B,EAAE,YAAAR,GAAY,GAChFS,IAAgBH,EAAK,OAErBI,IAAoBD,EAAc,MAAM,CAAAE,MAAgB,CAACA,EAAa,eAAe;AAW3F,SACE,gBAAAd,EAAC,aAAQ,WAAAI,GACP,UAAA,gBAAAJ;AAAA,IAACe;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,eAAAH;AAAA,QACA,mBAAAC;AAAA,QACA,gBAVe,MAAM;AAC3B,UAAAN,EAAQS,EAAgB,mBAAmB;AAAA,QAC7C;AAAA,QASQ,yBAhBwB,CAACP,MAAe;AAC9C,gBAAMQ,IAAWL,EAAc,KAAK,OAAK,EAAE,SAASH,EAAK,IAAI;AAC7D,UAAAF,EAAQS,EAAgB,4BAA4B,EAAE,MAAMP,EAAK,MAAM,MAAMQ,GAAU,MAAM;AAAA,QAC/F;AAAA,QAcQ,mBAAAP;AAAA,MAAA;AAAA,MAGD,UAAAL,KAGC,gBAAAa,EAACC,GAAA,EAAK,eAAc,UAClB,UAAA;AAAA,QAAA,gBAAAnB,EAACoB,GAAA,EAAK;AAAA,0BACLC,GAAA,EAAK;AAAA,0BACLC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ;"}
|
package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js
CHANGED
|
@@ -11,11 +11,10 @@ import "@gusto/embedded-api-v-2025-11-15/models/errors/unprocessableentityerror"
|
|
|
11
11
|
import "@gusto/embedded-api-v-2025-11-15/models/errors/httpclienterrors";
|
|
12
12
|
import "../../../../../../shared/constants.js";
|
|
13
13
|
import "../../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
|
-
import "../../../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
14
|
import { createCompoundContext as t } from "../../../../../Base/createCompoundContext.js";
|
|
16
|
-
const [
|
|
15
|
+
const [d, a] = t("DocumentListContext");
|
|
17
16
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
a as DocumentListProvider,
|
|
18
|
+
d as useDocumentList
|
|
20
19
|
};
|
|
21
20
|
//# sourceMappingURL=useDocumentList.js.map
|