@gusto/embedded-react-sdk 0.46.0 → 0.46.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +117 -0
- package/dist/components/Common/DataView/DataCards/DataCards.d.ts +2 -1
- package/dist/components/Common/DataView/DataCards/DataCards.js +14 -13
- package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.d.ts +2 -1
- package/dist/components/Common/DataView/DataTable/DataTable.js +85 -80
- package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js +8 -0
- package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js.map +1 -0
- package/dist/components/Common/DataView/DataView.d.ts +1 -0
- package/dist/components/Common/DataView/DataView.js.map +1 -1
- package/dist/components/Common/DataView/useDataView.d.ts +10 -1
- package/dist/components/Common/DataView/useDataView.js +20 -17
- package/dist/components/Common/DataView/useDataView.js.map +1 -1
- package/dist/components/Common/DocumentViewer/DocumentViewer.js +10 -10
- package/dist/components/Common/DocumentViewer/DocumentViewer.js.map +1 -1
- package/dist/components/Common/DocumentViewer/DocumentViewer.module.scss.js +9 -9
- package/dist/components/Common/PaginationControl/PaginationControl.js +11 -10
- package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
- package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionList.js +11 -10
- package/dist/components/Common/UI/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionList.module.scss.js +4 -4
- package/dist/components/Common/UI/Input/InputTypes.d.ts +1 -1
- package/dist/components/Common/UI/Input/InputTypes.js.map +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInput.js +51 -48
- package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/Common/VisuallyHidden/VisuallyHidden.d.ts +1 -1
- package/dist/components/Common/VisuallyHidden/VisuallyHidden.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/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.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/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +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/shared/useSignCompanyForm/fields.js +4 -4
- 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/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.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/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
- 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/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +5 -6
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/Profile/useContractorProfile.js +33 -34
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.d.ts +9 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js +76 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js.map +1 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js +8 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js.map +1 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +60 -202
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.d.ts +25 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +79 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js +8 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js.map +1 -0
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.d.ts +18 -0
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +171 -0
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -0
- package/dist/components/Employee/Compensation/management/index.d.ts +3 -0
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.d.ts +6 -1
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +67 -209
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js +36 -36
- package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.d.ts +18 -0
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js +169 -0
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js.map +1 -0
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.d.ts +16 -0
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js +36 -30
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.d.ts +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +213 -191
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +6 -5
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +162 -131
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/BasicDetailsView.js +74 -88
- package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.js +86 -72
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Dashboard/DashboardComponents.d.ts +3 -3
- package/dist/components/Employee/Dashboard/DashboardComponents.js +138 -101
- package/dist/components/Employee/Dashboard/DashboardComponents.js.map +1 -1
- package/dist/components/Employee/Dashboard/DocumentsView.js +17 -10
- package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.js +359 -313
- package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js +5 -3
- package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js.map +1 -1
- package/dist/components/Employee/Dashboard/TaxesView.js +114 -101
- package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js +147 -148
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.d.ts +6 -0
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +37 -36
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.d.ts +2 -2
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js +34 -35
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js +57 -57
- package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.d.ts +14 -5
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js +55 -36
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js +18 -18
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
- package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.d.ts +3 -3
- package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.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/shared/useSignEmployeeForm/fields.js +1 -1
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js +37 -40
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.d.ts +1 -2
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js +64 -71
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +2 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js +25 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.d.ts +13 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js +37 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js.map +1 -0
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.d.ts +6 -0
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js +69 -0
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js.map +1 -0
- package/dist/components/Employee/EmployeeListFlow/index.d.ts +3 -0
- package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js +15 -12
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.d.ts +2 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +170 -157
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +56 -55
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +20 -20
- package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.d.ts +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.d.ts +0 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js +11 -12
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.test.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.d.ts +6 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js +95 -94
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.d.ts +6 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js +87 -86
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js +18 -18
- package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js +14 -11
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.d.ts +2 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +96 -89
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +61 -60
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
- package/dist/components/Employee/exports/employeeManagement.d.ts +2 -0
- package/dist/components/Employee/exports/employeeManagement.js +18 -16
- package/dist/components/Employee/exports/employeeManagement.js.map +1 -1
- package/dist/components/Employee/index.d.ts +2 -0
- package/dist/components/Employee/index.js +32 -30
- package/dist/components/Employee/index.js.map +1 -1
- package/dist/components/Flow/FlowHeader.js +34 -31
- package/dist/components/Flow/FlowHeader.js.map +1 -1
- package/dist/components/Flow/useFlow.d.ts +12 -0
- package/dist/components/Flow/useFlow.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/usePreparedPayrollData.js +2 -3
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyList.js +92 -69
- package/dist/components/TimeOff/PolicyList/PolicyList.js.map +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js +23 -23
- package/dist/components/TimeOff/PolicyList/PolicyListPresentation.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 +73 -56
- package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js +58 -58
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.d.ts +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js +91 -87
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormTypes.d.ts +2 -0
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +91 -125
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.d.ts +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js +60 -91
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.module.scss.js +4 -4
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +0 -16
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +139 -225
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.d.ts +7 -3
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +78 -54
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.test.d.ts +1 -0
- package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js +12 -11
- package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js.map +1 -1
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js +177 -147
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js.map +1 -1
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js +34 -34
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js.map +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.d.ts +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js +38 -36
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js.map +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTableTypes.d.ts +2 -0
- package/dist/helpers/breadcrumbHelpers.d.ts +1 -1
- package/dist/helpers/breadcrumbHelpers.js.map +1 -1
- package/dist/helpers/federalEin.d.ts +1 -0
- package/dist/helpers/federalEin.js.map +1 -1
- package/dist/helpers/mask.d.ts +8 -4
- package/dist/helpers/mask.js.map +1 -1
- package/dist/helpers/rem.d.ts +2 -1
- package/dist/helpers/rem.js.map +1 -1
- package/dist/hooks/useAsyncError.d.ts +1 -0
- package/dist/hooks/useAsyncError.js.map +1 -1
- package/dist/hooks/useForkRef/useForkRef.d.ts +1 -0
- package/dist/hooks/useForkRef/useForkRef.js.map +1 -1
- package/dist/i18n/I18n.d.ts +9 -1
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.TimeOff.EmployeeTable.json.js +14 -14
- package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +16 -22
- package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js.map +1 -1
- package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js +17 -15
- package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js.map +1 -1
- package/dist/i18n/en/Company.TimeOff.TimeOffPolicyDetails.json.js +9 -9
- package/dist/i18n/en/Employee.Compensation.json.js +66 -58
- package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
- package/dist/i18n/en/Employee.Dashboard.json.js +28 -24
- package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
- package/dist/i18n/en/Employee.HomeAddress.Management.json.js +12 -10
- package/dist/i18n/en/Employee.HomeAddress.Management.json.js.map +1 -1
- package/dist/i18n/en/Employee.ManagementEmployeeList.json.js +32 -30
- package/dist/i18n/en/Employee.ManagementEmployeeList.json.js.map +1 -1
- package/dist/i18n/en/Employee.PaymentMethod.json.js +25 -25
- package/dist/i18n/en/Employee.StateTaxes.json.js +12 -10
- package/dist/i18n/en/Employee.StateTaxes.json.js.map +1 -1
- package/dist/i18n/en/Employee.WorkAddress.Management.json.js +16 -14
- package/dist/i18n/en/Employee.WorkAddress.Management.json.js.map +1 -1
- package/dist/i18n/en/common.json.d.ts +14 -0
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js +33 -32
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
- package/dist/partner-hook-utils/types.d.ts +4 -0
- package/dist/shared/constants.d.ts +2 -0
- package/dist/shared/constants.js +13 -12
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/i18next.d.ts +30 -29
- package/dist/types/observability.d.ts +1 -1
- package/docs/reference/endpoint-inventory.json +24 -8
- package/package.json +30 -27
- package/dist/components/Employee/Dashboard/CompensationCard.d.ts +0 -13
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import { normalizeToDate as
|
|
2
|
-
const
|
|
1
|
+
import { normalizeToDate as h } from "../../../helpers/dateFormatting.js";
|
|
2
|
+
const g = (t) => new Date(t.getFullYear(), t.getMonth(), t.getDate()), w = (t, e) => {
|
|
3
3
|
if (!t) return !1;
|
|
4
|
-
const n =
|
|
5
|
-
return n ?
|
|
6
|
-
},
|
|
4
|
+
const n = h(t);
|
|
5
|
+
return n ? g(n) > e : !1;
|
|
6
|
+
}, b = (t, e) => {
|
|
7
7
|
if (!t) return !1;
|
|
8
|
-
const n =
|
|
9
|
-
return n ?
|
|
10
|
-
},
|
|
8
|
+
const n = h(t);
|
|
9
|
+
return n ? g(n) <= e : !1;
|
|
10
|
+
}, p = (t) => {
|
|
11
11
|
if (t === void 0 || t === "") return null;
|
|
12
12
|
const e = Number(t);
|
|
13
13
|
return Number.isFinite(e) ? e : null;
|
|
14
14
|
};
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
(
|
|
20
|
-
const
|
|
21
|
-
return !
|
|
15
|
+
function y(t, e) {
|
|
16
|
+
const n = [], d = t.title ?? null, u = e.title ?? null;
|
|
17
|
+
u && d !== u && n.push({ kind: "titleChange", title: u });
|
|
18
|
+
const o = p(t.rate), a = p(e.rate), r = t.paymentUnit, l = e.paymentUnit;
|
|
19
|
+
(a !== null && a !== o || l !== void 0 && l !== r) && a !== null && l && n.push({ kind: "payChange", rate: a, paymentUnit: l }), e.flsaStatus && e.flsaStatus !== t.flsaStatus && n.push({ kind: "flsaChange", flsaStatus: e.flsaStatus });
|
|
20
|
+
const i = t.adjustForMinimumWage ?? !1, s = e.adjustForMinimumWage ?? !1, f = t.minimumWages?.[0], c = e.minimumWages?.[0];
|
|
21
|
+
return !i && s ? n.push({ kind: "minWageEnabled", wage: c?.wage ?? null }) : i && !s ? n.push({ kind: "minWageDisabled" }) : i && s && (f?.uuid !== c?.uuid || f?.wage !== c?.wage) && n.push({ kind: "minWageChanged", wage: c?.wage ?? null }), n;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const
|
|
23
|
+
function C(t) {
|
|
24
|
+
const e = p(t.rate);
|
|
25
25
|
return [
|
|
26
26
|
{
|
|
27
27
|
kind: "newJob",
|
|
28
|
-
title: t.title ??
|
|
29
|
-
rate:
|
|
30
|
-
paymentUnit:
|
|
28
|
+
title: t.title ?? null,
|
|
29
|
+
rate: e,
|
|
30
|
+
paymentUnit: e !== null && t.paymentUnit ? t.paymentUnit : null
|
|
31
31
|
}
|
|
32
32
|
];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function v(t, e = {}) {
|
|
35
35
|
if (!t?.length) return [];
|
|
36
|
-
const n = e.today ?? /* @__PURE__ */ new Date(),
|
|
37
|
-
for (const
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
for (let
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
compensationUuid:
|
|
45
|
-
jobUuid:
|
|
46
|
-
effectiveDate:
|
|
47
|
-
jobTitle:
|
|
48
|
-
details:
|
|
36
|
+
const n = e.today ?? /* @__PURE__ */ new Date(), d = g(n), u = [];
|
|
37
|
+
for (const o of t) {
|
|
38
|
+
const a = o.compensations ?? [], r = a.filter((i) => w(i.effectiveDate, d)).slice().sort((i, s) => (i.effectiveDate ?? "").localeCompare(s.effectiveDate ?? ""));
|
|
39
|
+
if (r.length === 0) continue;
|
|
40
|
+
const l = o.currentCompensationUuid ? a.find((i) => i.uuid === o.currentCompensationUuid) : void 0, m = l && b(l.effectiveDate, d) ? l : null, D = m?.title ?? r[0]?.title ?? null;
|
|
41
|
+
for (let i = 0; i < r.length; i++) {
|
|
42
|
+
const s = r[i], f = i === 0 ? m : r[i - 1], c = f ? y(f, s) : C(s);
|
|
43
|
+
u.push({
|
|
44
|
+
compensationUuid: s.uuid,
|
|
45
|
+
jobUuid: o.uuid,
|
|
46
|
+
effectiveDate: s.effectiveDate,
|
|
47
|
+
jobTitle: D,
|
|
48
|
+
details: c,
|
|
49
|
+
isNewJob: f === null
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
return
|
|
53
|
+
return u.sort((o, a) => o.effectiveDate.localeCompare(a.effectiveDate)), u;
|
|
53
54
|
}
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
+
v as getPendingCompensationChanges
|
|
56
57
|
};
|
|
57
58
|
//# sourceMappingURL=getPendingCompensationChanges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPendingCompensationChanges.js","sources":["../../../../src/components/Employee/Dashboard/getPendingCompensationChanges.ts"],"sourcesContent":["import type { Compensation } from '@gusto/embedded-api/models/components/compensation'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport { normalizeToDate } from '@/helpers/dateFormatting'\n\nexport type PendingChangeDetail =\n | { kind: 'titleChange'; title: string }\n | { kind: 'payChange'; rate: number; paymentUnit: string }\n | { kind: 'flsaChange'; flsaStatus: FlsaStatusType }\n | { kind: 'minWageEnabled'; wage: string | null }\n | { kind: 'minWageDisabled' }\n | { kind: 'minWageChanged'; wage: string | null }\n | {\n kind: 'newJob'\n title: string | null\n rate: number | null\n paymentUnit: string | null\n }\n\nexport interface PendingCompensationChange {\n compensationUuid: string\n jobUuid: string\n effectiveDate: string\n jobTitle: string | null\n details: PendingChangeDetail[]\n}\n\nconst startOfLocalDay = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate())\n\nconst isAfterToday = (effectiveDate: string | undefined, todayStart: Date): boolean => {\n if (!effectiveDate) return false\n const parsed = normalizeToDate(effectiveDate)\n if (!parsed) return false\n return startOfLocalDay(parsed) > todayStart\n}\n\nconst isOnOrBeforeToday = (effectiveDate: string | undefined, todayStart: Date): boolean => {\n if (!effectiveDate) return false\n const parsed = normalizeToDate(effectiveDate)\n if (!parsed) return false\n return startOfLocalDay(parsed) <= todayStart\n}\n\nconst numericRate = (rate: string | undefined): number | null => {\n if (rate === undefined || rate === '') return null\n const n = Number(rate)\n return Number.isFinite(n) ? n : null\n}\n\nfunction buildExistingJobDetails(\n baseline: Compensation,\n future: Compensation,\n jobTitle: string | null,\n): PendingChangeDetail[] {\n const details: PendingChangeDetail[] = []\n\n const baseTitle = baseline.title ?? jobTitle\n const futureTitle = future.title ?? jobTitle\n if (futureTitle && baseTitle !== futureTitle) {\n details.push({ kind: 'titleChange', title: futureTitle })\n }\n\n const baseRate = numericRate(baseline.rate)\n const futureRate = numericRate(future.rate)\n const baseUnit = baseline.paymentUnit\n const futureUnit = future.paymentUnit\n const rateDiffers = futureRate !== null && futureRate !== baseRate\n const unitDiffers = futureUnit !== undefined && futureUnit !== baseUnit\n if ((rateDiffers || unitDiffers) && futureRate !== null && futureUnit) {\n details.push({ kind: 'payChange', rate: futureRate, paymentUnit: futureUnit })\n }\n\n if (future.flsaStatus && future.flsaStatus !== baseline.flsaStatus) {\n details.push({ kind: 'flsaChange', flsaStatus: future.flsaStatus })\n }\n\n const baseAdj = baseline.adjustForMinimumWage ?? false\n const futureAdj = future.adjustForMinimumWage ?? false\n const baseMw = baseline.minimumWages?.[0]\n const futureMw = future.minimumWages?.[0]\n\n if (!baseAdj && futureAdj) {\n details.push({ kind: 'minWageEnabled', wage: futureMw?.wage ?? null })\n } else if (baseAdj && !futureAdj) {\n details.push({ kind: 'minWageDisabled' })\n } else if (baseAdj && futureAdj) {\n if (baseMw?.uuid !== futureMw?.uuid || baseMw?.wage !== futureMw?.wage) {\n details.push({ kind: 'minWageChanged', wage: futureMw?.wage ?? null })\n }\n }\n\n return details\n}\n\nfunction buildNewJobDetails(future: Compensation, jobTitle: string | null): PendingChangeDetail[] {\n const rate = numericRate(future.rate)\n return [\n {\n kind: 'newJob',\n title: future.title ?? jobTitle,\n rate,\n paymentUnit: rate !== null && future.paymentUnit ? future.paymentUnit : null,\n },\n ]\n}\n\n/**\n * Returns the pending compensation changes for an employee, flattened across\n * all jobs and sorted globally by `effectiveDate` ascending.\n *\n * A pending change is any `Compensation` whose `effectiveDate` is strictly\n * after today (local midnight). When a single job has multiple future-dated\n * compensations stacked, each is returned in chronological order and the diff\n * details for the N+1th comp are computed against the Nth (rather than the\n * job's current compensation) so the bullets remain meaningful end-to-end.\n *\n * The helper returns structured deltas (a discriminated union per detail) so\n * the consuming UI is responsible for formatting them via i18n / pay-rate\n * helpers. This keeps the helper pure and trivially unit-testable.\n */\nexport function getPendingCompensationChanges(\n jobs: Job[] | undefined,\n options: { today?: Date } = {},\n): PendingCompensationChange[] {\n if (!jobs?.length) return []\n\n const now = options.today ?? new Date()\n const todayStart = startOfLocalDay(now)\n const results: PendingCompensationChange[] = []\n\n for (const job of jobs) {\n const comps = job.compensations ?? []\n\n const futureComps = comps\n .filter(c => isAfterToday(c.effectiveDate, todayStart))\n .slice()\n .sort((a, b) => (a.effectiveDate ?? '').localeCompare(b.effectiveDate ?? ''))\n\n if (futureComps.length === 0) continue\n\n const referencedCurrent = job.currentCompensationUuid\n ? comps.find(c => c.uuid === job.currentCompensationUuid)\n : undefined\n const currentComp =\n referencedCurrent && isOnOrBeforeToday(referencedCurrent.effectiveDate, todayStart)\n ? referencedCurrent\n : null\n\n for (let i = 0; i < futureComps.length; i++) {\n const future = futureComps[i]!\n const baseline = i === 0 ? currentComp : futureComps[i - 1]!\n\n const details = baseline\n ? buildExistingJobDetails(baseline, future, job.title)\n : buildNewJobDetails(future, job.title)\n\n results.push({\n compensationUuid: future.uuid,\n jobUuid: job.uuid,\n effectiveDate: future.effectiveDate!,\n jobTitle: job.title,\n details,\n })\n }\n }\n\n results.sort((a, b) => a.effectiveDate.localeCompare(b.effectiveDate))\n\n return results\n}\n"],"names":["startOfLocalDay","d","isAfterToday","effectiveDate","todayStart","parsed","normalizeToDate","isOnOrBeforeToday","numericRate","rate","n","buildExistingJobDetails","baseline","future","jobTitle","details","baseTitle","futureTitle","baseRate","futureRate","baseUnit","futureUnit","baseAdj","futureAdj","baseMw","futureMw","buildNewJobDetails","getPendingCompensationChanges","jobs","options","now","results","job","comps","futureComps","c","a","b","referencedCurrent","currentComp","i"],"mappings":";AA2BA,MAAMA,IAAkB,CAACC,MAAY,IAAI,KAAKA,EAAE,eAAeA,E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5B,IAAW4B,MAAM,IAAID,IAAcL,EAAYM,IAAI,CAAC,GAEpDzB,IAAUH,IACZD,EAAwBC,GAAUC,GAAQmB,EAAI,KAAK,IACnDN,EAAmBb,GAAQmB,EAAI,KAAK;AAExC,MAAAD,EAAQ,KAAK;AAAA,QACX,kBAAkBlB,EAAO;AAAA,QACzB,SAASmB,EAAI;AAAA,QACb,eAAenB,EAAO;AAAA,QACtB,UAAUmB,EAAI;AAAA,QACd,SAAAjB;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EACF;AAEA,SAAAgB,EAAQ,KAAK,CAACK,GAAGC,MAAMD,EAAE,cAAc,cAAcC,EAAE,aAAa,CAAC,GAE9DN;AACT;"}
|
|
1
|
+
{"version":3,"file":"getPendingCompensationChanges.js","sources":["../../../../src/components/Employee/Dashboard/getPendingCompensationChanges.ts"],"sourcesContent":["import type { Compensation } from '@gusto/embedded-api/models/components/compensation'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport { normalizeToDate } from '@/helpers/dateFormatting'\n\nexport type PendingChangeDetail =\n | { kind: 'titleChange'; title: string }\n | { kind: 'payChange'; rate: number; paymentUnit: string }\n | { kind: 'flsaChange'; flsaStatus: FlsaStatusType }\n | { kind: 'minWageEnabled'; wage: string | null }\n | { kind: 'minWageDisabled' }\n | { kind: 'minWageChanged'; wage: string | null }\n | {\n kind: 'newJob'\n title: string | null\n rate: number | null\n paymentUnit: string | null\n }\n\nexport interface PendingCompensationChange {\n compensationUuid: string\n jobUuid: string\n effectiveDate: string\n jobTitle: string | null\n details: PendingChangeDetail[]\n /**\n * True when the job has no current (on-or-before-today) compensation —\n * i.e., the job itself hasn't started yet. The UI renders a \"Pending\"\n * badge rather than a change alert in this case.\n */\n isNewJob: boolean\n}\n\nconst startOfLocalDay = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate())\n\nconst isAfterToday = (effectiveDate: string | undefined, todayStart: Date): boolean => {\n if (!effectiveDate) return false\n const parsed = normalizeToDate(effectiveDate)\n if (!parsed) return false\n return startOfLocalDay(parsed) > todayStart\n}\n\nconst isOnOrBeforeToday = (effectiveDate: string | undefined, todayStart: Date): boolean => {\n if (!effectiveDate) return false\n const parsed = normalizeToDate(effectiveDate)\n if (!parsed) return false\n return startOfLocalDay(parsed) <= todayStart\n}\n\nconst numericRate = (rate: string | undefined): number | null => {\n if (rate === undefined || rate === '') return null\n const n = Number(rate)\n return Number.isFinite(n) ? n : null\n}\n\nfunction buildExistingJobDetails(\n baseline: Compensation,\n future: Compensation,\n): PendingChangeDetail[] {\n const details: PendingChangeDetail[] = []\n\n // Title diffs come straight from `compensation.title` — that's where the\n // value lives in the API. A future comp that doesn't carry a title (e.g.\n // a pay-only change) leaves `future.title` undefined; the `futureTitle &&`\n // guard prevents that case from emitting a spurious title change.\n const baseTitle = baseline.title ?? null\n const futureTitle = future.title ?? null\n if (futureTitle && baseTitle !== futureTitle) {\n details.push({ kind: 'titleChange', title: futureTitle })\n }\n\n const baseRate = numericRate(baseline.rate)\n const futureRate = numericRate(future.rate)\n const baseUnit = baseline.paymentUnit\n const futureUnit = future.paymentUnit\n const rateDiffers = futureRate !== null && futureRate !== baseRate\n const unitDiffers = futureUnit !== undefined && futureUnit !== baseUnit\n if ((rateDiffers || unitDiffers) && futureRate !== null && futureUnit) {\n details.push({ kind: 'payChange', rate: futureRate, paymentUnit: futureUnit })\n }\n\n if (future.flsaStatus && future.flsaStatus !== baseline.flsaStatus) {\n details.push({ kind: 'flsaChange', flsaStatus: future.flsaStatus })\n }\n\n const baseAdj = baseline.adjustForMinimumWage ?? false\n const futureAdj = future.adjustForMinimumWage ?? false\n const baseMw = baseline.minimumWages?.[0]\n const futureMw = future.minimumWages?.[0]\n\n if (!baseAdj && futureAdj) {\n details.push({ kind: 'minWageEnabled', wage: futureMw?.wage ?? null })\n } else if (baseAdj && !futureAdj) {\n details.push({ kind: 'minWageDisabled' })\n } else if (baseAdj && futureAdj) {\n if (baseMw?.uuid !== futureMw?.uuid || baseMw?.wage !== futureMw?.wage) {\n details.push({ kind: 'minWageChanged', wage: futureMw?.wage ?? null })\n }\n }\n\n return details\n}\n\nfunction buildNewJobDetails(future: Compensation): PendingChangeDetail[] {\n const rate = numericRate(future.rate)\n return [\n {\n kind: 'newJob',\n title: future.title ?? null,\n rate,\n paymentUnit: rate !== null && future.paymentUnit ? future.paymentUnit : null,\n },\n ]\n}\n\n/**\n * Returns the pending compensation changes for an employee, flattened across\n * all jobs and sorted globally by `effectiveDate` ascending.\n *\n * A pending change is any `Compensation` whose `effectiveDate` is strictly\n * after today (local midnight). When a single job has multiple future-dated\n * compensations stacked, each is returned in chronological order and the diff\n * details for the N+1th comp are computed against the Nth (rather than the\n * job's current compensation) so the bullets remain meaningful end-to-end.\n *\n * The helper returns structured deltas (a discriminated union per detail) so\n * the consuming UI is responsible for formatting them via i18n / pay-rate\n * helpers. This keeps the helper pure and trivially unit-testable.\n */\nexport function getPendingCompensationChanges(\n jobs: Job[] | undefined,\n options: { today?: Date } = {},\n): PendingCompensationChange[] {\n if (!jobs?.length) return []\n\n const now = options.today ?? new Date()\n const todayStart = startOfLocalDay(now)\n const results: PendingCompensationChange[] = []\n\n for (const job of jobs) {\n const comps = job.compensations ?? []\n\n const futureComps = comps\n .filter(c => isAfterToday(c.effectiveDate, todayStart))\n .slice()\n .sort((a, b) => (a.effectiveDate ?? '').localeCompare(b.effectiveDate ?? ''))\n\n if (futureComps.length === 0) continue\n\n const referencedCurrent = job.currentCompensationUuid\n ? comps.find(c => c.uuid === job.currentCompensationUuid)\n : undefined\n const currentComp =\n referencedCurrent && isOnOrBeforeToday(referencedCurrent.effectiveDate, todayStart)\n ? referencedCurrent\n : null\n\n // Title lives on compensation; `job.title` is a denormalized snapshot of\n // the primary comp's title and can lag behind comp-level edits on\n // secondaries (and on primaries until the server resyncs). For UI strings\n // that contextualize a change (\"Compensation for X will change on...\"),\n // use the title from the currently-in-effect comp; for a job that hasn't\n // started yet (`currentComp === null`), fall back to the first future\n // comp's title — that's the title the job is starting with.\n const displayTitle = currentComp?.title ?? futureComps[0]?.title ?? null\n\n for (let i = 0; i < futureComps.length; i++) {\n const future = futureComps[i]!\n const baseline = i === 0 ? currentComp : futureComps[i - 1]!\n\n const details = baseline\n ? buildExistingJobDetails(baseline, future)\n : buildNewJobDetails(future)\n\n results.push({\n compensationUuid: future.uuid,\n jobUuid: job.uuid,\n effectiveDate: future.effectiveDate!,\n jobTitle: displayTitle,\n details,\n isNewJob: baseline === null,\n })\n }\n }\n\n results.sort((a, b) => a.effectiveDate.localeCompare(b.effectiveDate))\n\n return results\n}\n"],"names":["startOfLocalDay","d","isAfterToday","effectiveDate","todayStart","parsed","normalizeToDate","isOnOrBeforeToday","numericRate","rate","n","buildExistingJobDetails","baseline","future","details","baseTitle","futureTitle","baseRate","futureRate","baseUnit","futureUnit","baseAdj","futureAdj","baseMw","futureMw","buildNewJobDetails","getPendingCompensationChanges","jobs","options","now","results","job","comps","futureComps","c","a","b","referencedCurrent","currentComp","displayTitle"],"mappings":";AAiCA,MAAMA,IAAkB,CAACC,MAAY,IAAI,KAAKA,EAAE,eAAeA,EAAE,SAAA,GAAYA,EAAE,SAAS,GAElFC,IAAe,CAACC,GAAmCC,MAA8B;AACrF,MAAI,CAACD,EAAe,QAAO;AAC3B,QAAME,IAASC,EAAgBH,CAAa;AAC5C,SAAKE,IACEL,EAAgBK,CAAM,IAAID,IADb;AAEtB,GAEMG,IAAoB,CAACJ,GAAmCC,MAA8B;AAC1F,MAAI,CAACD,EAAe,QAAO;AAC3B,QAAME,IAASC,EAAgBH,CAAa;AAC5C,SAAKE,IACEL,EAAgBK,CAAM,KAAKD,IADd;AAEtB,GAEMI,IAAc,CAACC,MAA4C;AAC/D,MAAIA,MAAS,UAAaA,MAAS,GAAI,QAAO;AAC9C,QAAMC,IAAI,OAAOD,CAAI;AACrB,SAAO,OAAO,SAASC,CAAC,IAAIA,IAAI;AAClC;AAEA,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eeCompensationResult extends BaseHookReady<{
|
|
|
21
21
|
}, {
|
|
22
22
|
isPending: boolean;
|
|
23
23
|
cancellingCompensationUuid: string | null;
|
|
24
|
-
/** Compensation card depends on the
|
|
24
|
+
/** Compensation card depends on the jobs fetch (jobs, pending
|
|
25
25
|
* changes, FLSA status). */
|
|
26
|
-
|
|
26
|
+
isCompensationLoading: boolean;
|
|
27
27
|
/** Paystubs card depends on a separate paginated endpoint. */
|
|
28
28
|
isPayStubsLoading: boolean;
|
|
29
29
|
}> {
|
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import { useMemo as a, useCallback as
|
|
2
|
-
import { useEmployeesGet as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { useMemo as a, useCallback as M } from "react";
|
|
2
|
+
import { useEmployeesGet as A } from "@gusto/embedded-api/react-query/employeesGet";
|
|
3
|
+
import { useJobsAndCompensationsGetJobs as j } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
|
|
4
|
+
import { GetV1EmployeesEmployeeIdJobsQueryParamInclude as v } from "@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs";
|
|
5
|
+
import { useJobsAndCompensationsDeleteCompensationMutation as G } from "@gusto/embedded-api/react-query/jobsAndCompensationsDeleteCompensation";
|
|
6
|
+
import { usePayrollsGetPayStubs as Q } from "@gusto/embedded-api/react-query/payrollsGetPayStubs";
|
|
7
|
+
import { getPendingCompensationChanges as H } from "../getPendingCompensationChanges.js";
|
|
8
|
+
import { derivePrimaryFlsaStatus as T } from "../../Compensation/shared/derivePrimaryFlsaStatus.js";
|
|
7
9
|
import { useBaseSubmit as q } from "../../../Base/useBaseSubmit.js";
|
|
8
10
|
import { composeErrorHandler as w } from "../../../../partner-hook-utils/composeErrorHandler.js";
|
|
9
11
|
import { usePagination as D } from "../../../../hooks/usePagination/usePagination.js";
|
|
10
|
-
function
|
|
11
|
-
employeeId:
|
|
12
|
+
function Y({
|
|
13
|
+
employeeId: i
|
|
12
14
|
}) {
|
|
13
15
|
const { currentPage: c, itemsPerPage: d, getPaginationProps: m } = D({
|
|
14
16
|
defaultItemsPerPage: 10
|
|
15
|
-
}),
|
|
16
|
-
{ employeeId:
|
|
17
|
+
}), o = j(
|
|
18
|
+
{ employeeId: i, include: v.AllCompensations },
|
|
17
19
|
{ staleTime: 1 / 0 }
|
|
18
|
-
), e =
|
|
19
|
-
{ employeeId:
|
|
20
|
+
), r = A({ employeeId: i }, { staleTime: 1 / 0 }), e = Q(
|
|
21
|
+
{ employeeId: i, page: c, per: d },
|
|
20
22
|
{ staleTime: 1 / 0 }
|
|
21
|
-
),
|
|
23
|
+
), n = G(), {
|
|
22
24
|
baseSubmitHandler: p,
|
|
23
25
|
error: l,
|
|
24
26
|
setError: g
|
|
25
|
-
} = q("Employee.Dashboard.JobAndPay.Compensation"),
|
|
26
|
-
() => A(n?.jobs),
|
|
27
|
-
[n?.jobs]
|
|
28
|
-
), h = e.data?.employeePayStubsList ?? [], S = a(() => {
|
|
27
|
+
} = q("Employee.Dashboard.JobAndPay.Compensation"), y = r.data?.employee, t = a(() => o.data?.jobs ?? [], [o.data?.jobs]), b = a(() => t.find((s) => s.primary === !0), [t]), P = a(() => T(t), [t]), f = t.length > 1, h = a(() => H(t), [t]), C = e.data?.employeePayStubsList ?? [], S = a(() => {
|
|
29
28
|
const s = e.data?.httpMeta.response.headers;
|
|
30
29
|
if (s)
|
|
31
30
|
return m(s, e.isFetching);
|
|
32
|
-
}, [e.data?.httpMeta.response.headers, e.isFetching, m]),
|
|
31
|
+
}, [e.data?.httpMeta.response.headers, e.isFetching, m]), E = n.isPending ? n.variables.request.compensationId : null, F = M(
|
|
33
32
|
async (s) => {
|
|
34
33
|
let u;
|
|
35
|
-
return await p(s, async ({ compensationUuid:
|
|
36
|
-
u = { mode: "update", data: await
|
|
37
|
-
request: { compensationId:
|
|
34
|
+
return await p(s, async ({ compensationUuid: L }) => {
|
|
35
|
+
u = { mode: "update", data: await n.mutateAsync({
|
|
36
|
+
request: { compensationId: L }
|
|
38
37
|
}) };
|
|
39
38
|
}), u;
|
|
40
39
|
},
|
|
41
|
-
[p,
|
|
42
|
-
),
|
|
40
|
+
[p, n]
|
|
41
|
+
), J = o.isFetching || r.isFetching || e.isFetching || n.isPending, I = w([o, r, e], {
|
|
43
42
|
submitError: l,
|
|
44
43
|
setSubmitError: g
|
|
45
44
|
});
|
|
@@ -47,29 +46,29 @@ function z({
|
|
|
47
46
|
isLoading: !1,
|
|
48
47
|
data: {
|
|
49
48
|
jobs: t,
|
|
50
|
-
primaryJob:
|
|
51
|
-
primaryFlsaStatus:
|
|
52
|
-
hasMultipleJobs:
|
|
53
|
-
pendingChanges:
|
|
54
|
-
payStubs:
|
|
55
|
-
employeeFirstName:
|
|
49
|
+
primaryJob: b,
|
|
50
|
+
primaryFlsaStatus: P,
|
|
51
|
+
hasMultipleJobs: f,
|
|
52
|
+
pendingChanges: h,
|
|
53
|
+
payStubs: C,
|
|
54
|
+
employeeFirstName: y?.firstName ?? void 0
|
|
56
55
|
},
|
|
57
56
|
status: {
|
|
58
|
-
isPending:
|
|
59
|
-
cancellingCompensationUuid:
|
|
60
|
-
|
|
57
|
+
isPending: J,
|
|
58
|
+
cancellingCompensationUuid: E,
|
|
59
|
+
isCompensationLoading: o.isLoading,
|
|
61
60
|
isPayStubsLoading: e.isLoading
|
|
62
61
|
},
|
|
63
62
|
pagination: {
|
|
64
63
|
payStubs: S
|
|
65
64
|
},
|
|
66
65
|
actions: {
|
|
67
|
-
cancelPendingChange:
|
|
66
|
+
cancelPendingChange: F
|
|
68
67
|
},
|
|
69
|
-
errorHandling:
|
|
68
|
+
errorHandling: I
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
export {
|
|
73
|
-
|
|
72
|
+
Y as useEmployeeCompensation
|
|
74
73
|
};
|
|
75
74
|
//# sourceMappingURL=useEmployeeCompensation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmployeeCompensation.js","sources":["../../../../../src/components/Employee/Dashboard/hooks/useEmployeeCompensation.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useJobsAndCompensationsDeleteCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDeleteCompensation'\nimport { usePayrollsGetPayStubs } from '@gusto/embedded-api/react-query/payrollsGetPayStubs'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { GetV1EmployeesEmployeeUuidPayStubsResponse } from '@gusto/embedded-api/models/operations/getv1employeesemployeeuuidpaystubs'\nimport {\n getPendingCompensationChanges,\n type PendingCompensationChange,\n} from '../getPendingCompensationChanges'\nimport { derivePrimaryFlsaStatus } from '@/components/Employee/Compensation/shared/derivePrimaryFlsaStatus'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\nimport type { BaseHookReady, HookSubmitResult } from '@/partner-hook-utils/types'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\n\ntype EmployeePayStub = NonNullable<\n GetV1EmployeesEmployeeUuidPayStubsResponse['employeePayStubsList']\n>[number]\n\nexport interface UseEmployeeCompensationProps {\n employeeId: string\n}\n\nexport interface UseEmployeeCompensationResult extends BaseHookReady<\n {\n jobs: Job[]\n primaryJob?: Job\n primaryFlsaStatus?: string\n hasMultipleJobs: boolean\n pendingChanges: PendingCompensationChange[]\n payStubs: EmployeePayStub[]\n /** First name from the shared employee fetch; useful for cosmetic copy\n * in alerts (e.g. \"Heads up, Jane has pending changes\"). Optional\n * because the employee record can omit it. */\n employeeFirstName?: string\n },\n {\n isPending: boolean\n cancellingCompensationUuid: string | null\n /** Compensation card depends on the
|
|
1
|
+
{"version":3,"file":"useEmployeeCompensation.js","sources":["../../../../../src/components/Employee/Dashboard/hooks/useEmployeeCompensation.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsDeleteCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDeleteCompensation'\nimport { usePayrollsGetPayStubs } from '@gusto/embedded-api/react-query/payrollsGetPayStubs'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { GetV1EmployeesEmployeeUuidPayStubsResponse } from '@gusto/embedded-api/models/operations/getv1employeesemployeeuuidpaystubs'\nimport {\n getPendingCompensationChanges,\n type PendingCompensationChange,\n} from '../getPendingCompensationChanges'\nimport { derivePrimaryFlsaStatus } from '@/components/Employee/Compensation/shared/derivePrimaryFlsaStatus'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\nimport type { BaseHookReady, HookSubmitResult } from '@/partner-hook-utils/types'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\n\ntype EmployeePayStub = NonNullable<\n GetV1EmployeesEmployeeUuidPayStubsResponse['employeePayStubsList']\n>[number]\n\nexport interface UseEmployeeCompensationProps {\n employeeId: string\n}\n\nexport interface UseEmployeeCompensationResult extends BaseHookReady<\n {\n jobs: Job[]\n primaryJob?: Job\n primaryFlsaStatus?: string\n hasMultipleJobs: boolean\n pendingChanges: PendingCompensationChange[]\n payStubs: EmployeePayStub[]\n /** First name from the shared employee fetch; useful for cosmetic copy\n * in alerts (e.g. \"Heads up, Jane has pending changes\"). Optional\n * because the employee record can omit it. */\n employeeFirstName?: string\n },\n {\n isPending: boolean\n cancellingCompensationUuid: string | null\n /** Compensation card depends on the jobs fetch (jobs, pending\n * changes, FLSA status). */\n isCompensationLoading: boolean\n /** Paystubs card depends on a separate paginated endpoint. */\n isPayStubsLoading: boolean\n }\n> {\n pagination: {\n payStubs?: PaginationControlProps\n }\n actions: {\n cancelPendingChange: (\n pendingChange: PendingCompensationChange,\n ) => Promise<HookSubmitResult<unknown> | undefined>\n }\n}\n\n/**\n * Phase B: non-Suspense queries so the Compensation and Paystubs cards\n * can paint independently within the Job and pay tab. JobAndPayView\n * already gets the Payment and Deductions cards as separate non-Suspense\n * hooks, so this completes the four-section incremental render.\n */\nexport function useEmployeeCompensation({\n employeeId,\n}: UseEmployeeCompensationProps): UseEmployeeCompensationResult {\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 10,\n })\n\n // staleTime: Infinity on dashboard reads — the SDK QueryClient already\n // invalidates all queries on any mutation success, so post-write\n // freshness is preserved. Without this, every subscriber re-mount\n // (e.g. tab navigation) would fire a redundant background refetch.\n //\n // GET /v1/employees/:id/jobs?include=all_compensations returns all effective-\n // dated compensations (current + future) with compensation.title on each,\n // which is required for pending-change detection. Without the include param,\n // only the current compensation is returned.\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId, include: GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations },\n { staleTime: Infinity },\n )\n // Employee query is a lightweight secondary fetch for cosmetic data only\n // (first name used in alert copy). Jobs / compensation data comes from jobsQuery.\n const employeeQuery = useEmployeesGet({ employeeId }, { staleTime: Infinity })\n const payStubsQuery = usePayrollsGetPayStubs(\n { employeeId, page: currentPage, per: itemsPerPage },\n { staleTime: Infinity },\n )\n const cancelCompensationMutation = useJobsAndCompensationsDeleteCompensationMutation()\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('Employee.Dashboard.JobAndPay.Compensation')\n\n const employee = employeeQuery.data?.employee\n\n const jobs = useMemo(() => jobsQuery.data?.jobs ?? [], [jobsQuery.data?.jobs])\n const primaryJob = useMemo(() => jobs.find(job => job.primary === true), [jobs])\n const primaryFlsaStatus = useMemo(() => derivePrimaryFlsaStatus(jobs), [jobs])\n const hasMultipleJobs = jobs.length > 1\n\n const pendingChanges = useMemo(() => getPendingCompensationChanges(jobs), [jobs])\n\n const payStubs = payStubsQuery.data?.employeePayStubsList ?? []\n\n const payStubsPagination = useMemo(() => {\n const headers = payStubsQuery.data?.httpMeta.response.headers\n if (!headers) return undefined\n return getPaginationProps(headers, payStubsQuery.isFetching)\n }, [payStubsQuery.data?.httpMeta.response.headers, payStubsQuery.isFetching, getPaginationProps])\n\n const cancellingCompensationUuid = cancelCompensationMutation.isPending\n ? cancelCompensationMutation.variables.request.compensationId\n : null\n\n const cancelPendingChange = useCallback(\n async (\n pendingChange: PendingCompensationChange,\n ): Promise<HookSubmitResult<unknown> | undefined> => {\n let submitResult: HookSubmitResult<unknown> | undefined\n await baseSubmitHandler(pendingChange, async ({ compensationUuid }) => {\n const data = await cancelCompensationMutation.mutateAsync({\n request: { compensationId: compensationUuid },\n })\n submitResult = { mode: 'update', data }\n })\n return submitResult\n },\n [baseSubmitHandler, cancelCompensationMutation],\n )\n\n const isPending =\n jobsQuery.isFetching ||\n employeeQuery.isFetching ||\n payStubsQuery.isFetching ||\n cancelCompensationMutation.isPending\n\n const errorHandling = composeErrorHandler([jobsQuery, employeeQuery, payStubsQuery], {\n submitError,\n setSubmitError,\n })\n\n return {\n isLoading: false,\n data: {\n jobs,\n primaryJob,\n primaryFlsaStatus,\n hasMultipleJobs,\n pendingChanges,\n payStubs,\n employeeFirstName: employee?.firstName ?? undefined,\n },\n status: {\n isPending,\n cancellingCompensationUuid,\n isCompensationLoading: jobsQuery.isLoading,\n isPayStubsLoading: payStubsQuery.isLoading,\n },\n pagination: {\n payStubs: payStubsPagination,\n },\n actions: {\n cancelPendingChange,\n },\n errorHandling,\n }\n}\n"],"names":["useEmployeeCompensation","employeeId","currentPage","itemsPerPage","getPaginationProps","usePagination","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","employeeQuery","useEmployeesGet","payStubsQuery","usePayrollsGetPayStubs","cancelCompensationMutation","useJobsAndCompensationsDeleteCompensationMutation","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","employee","jobs","useMemo","primaryJob","job","primaryFlsaStatus","derivePrimaryFlsaStatus","hasMultipleJobs","pendingChanges","getPendingCompensationChanges","payStubs","payStubsPagination","headers","cancellingCompensationUuid","cancelPendingChange","useCallback","pendingChange","submitResult","compensationUuid","isPending","errorHandling","composeErrorHandler"],"mappings":";;;;;;;;;;;AAkEO,SAASA,EAAwB;AAAA,EACtC,YAAAC;AACF,GAAgE;AAC9D,QAAM,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,EAAc;AAAA,IACtE,qBAAqB;AAAA,EAAA,CACtB,GAWKC,IAAYC;AAAA,IAChB,EAAE,YAAAN,GAAY,SAASO,EAA8C,iBAAA;AAAA,IACrE,EAAE,WAAW,MAAA;AAAA,EAAS,GAIlBC,IAAgBC,EAAgB,EAAE,YAAAT,EAAA,GAAc,EAAE,WAAW,OAAU,GACvEU,IAAgBC;AAAA,IACpB,EAAE,YAAAX,GAAY,MAAMC,GAAa,KAAKC,EAAA;AAAA,IACtC,EAAE,WAAW,MAAA;AAAA,EAAS,GAElBU,IAA6BC,EAAA,GAC7B;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,2CAA2C,GAEvDC,IAAWV,EAAc,MAAM,UAE/BW,IAAOC,EAAQ,MAAMf,EAAU,MAAM,QAAQ,CAAA,GAAI,CAACA,EAAU,MAAM,IAAI,CAAC,GACvEgB,IAAaD,EAAQ,MAAMD,EAAK,KAAK,CAAAG,MAAOA,EAAI,YAAY,EAAI,GAAG,CAACH,CAAI,CAAC,GACzEI,IAAoBH,EAAQ,MAAMI,EAAwBL,CAAI,GAAG,CA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A,MACjC,mBAAmBK,EAAc;AAAA,IAAA;AAAA,IAEnC,YAAY;AAAA,MACV,UAAUmB;AAAA,IAAA;AAAA,IAEZ,SAAS;AAAA,MACP,qBAAAG;AAAA,IAAA;AAAA,IAEF,eAAAM;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
1
|
+
import { jsx as n, jsxs as c } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as f } from "react-i18next";
|
|
3
3
|
import { useWatch as A } from "react-hook-form";
|
|
4
|
-
import { useDeductionForm as
|
|
5
|
-
import { Form as
|
|
6
|
-
import { Flex as
|
|
4
|
+
import { useDeductionForm as D } from "../shared/useDeductionForm/useDeductionForm.js";
|
|
5
|
+
import { Form as b } from "../../../Common/Form/Form.js";
|
|
6
|
+
import { Flex as m } from "../../../Common/Flex/Flex.js";
|
|
7
7
|
import "classnames";
|
|
8
8
|
import "../../../../shared/constants.js";
|
|
9
|
-
import { ActionsLayout as
|
|
10
|
-
import { BaseLayout as
|
|
11
|
-
import { SDKFormProvider as
|
|
9
|
+
import { ActionsLayout as h } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
10
|
+
import { BaseLayout as g } from "../../../Base/Base.js";
|
|
11
|
+
import { SDKFormProvider as y } from "../../../../partner-hook-utils/form/SDKFormProvider.js";
|
|
12
12
|
import { useComponentContext as R } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
13
|
function S({
|
|
14
|
-
employeeId:
|
|
15
|
-
deduction:
|
|
16
|
-
courtOrdered:
|
|
14
|
+
employeeId: t,
|
|
15
|
+
deduction: o,
|
|
16
|
+
courtOrdered: r,
|
|
17
17
|
garnishmentType: e,
|
|
18
|
-
title:
|
|
19
|
-
onSaved:
|
|
20
|
-
onCancel:
|
|
18
|
+
title: s,
|
|
19
|
+
onSaved: l,
|
|
20
|
+
onCancel: p
|
|
21
21
|
}) {
|
|
22
|
-
const { t:
|
|
23
|
-
employeeId:
|
|
24
|
-
garnishmentId:
|
|
25
|
-
courtOrdered:
|
|
26
|
-
defaultValues:
|
|
22
|
+
const { t: u } = f("Employee.Deductions"), d = R(), a = D({
|
|
23
|
+
employeeId: t,
|
|
24
|
+
garnishmentId: o?.uuid,
|
|
25
|
+
courtOrdered: r,
|
|
26
|
+
defaultValues: r && e ? { garnishmentType: e } : void 0
|
|
27
27
|
});
|
|
28
|
-
if (
|
|
29
|
-
return /* @__PURE__ */ n(
|
|
30
|
-
const { Fields:
|
|
28
|
+
if (a.isLoading)
|
|
29
|
+
return /* @__PURE__ */ n(g, { isLoading: !0, error: a.errorHandling.errors });
|
|
30
|
+
const { Fields: i } = a.form;
|
|
31
31
|
return /* @__PURE__ */ n(
|
|
32
32
|
x,
|
|
33
33
|
{
|
|
34
|
-
form:
|
|
35
|
-
Fields:
|
|
36
|
-
Components:
|
|
37
|
-
t:
|
|
38
|
-
title:
|
|
39
|
-
onSaved:
|
|
40
|
-
onCancel:
|
|
34
|
+
form: a,
|
|
35
|
+
Fields: i,
|
|
36
|
+
Components: d,
|
|
37
|
+
t: u,
|
|
38
|
+
title: s,
|
|
39
|
+
onSaved: l,
|
|
40
|
+
onCancel: p
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
function x({
|
|
45
|
-
form:
|
|
46
|
-
Fields:
|
|
47
|
-
Components:
|
|
45
|
+
form: t,
|
|
46
|
+
Fields: o,
|
|
47
|
+
Components: r,
|
|
48
48
|
t: e,
|
|
49
|
-
title:
|
|
50
|
-
onSaved:
|
|
51
|
-
onCancel:
|
|
49
|
+
title: s,
|
|
50
|
+
onSaved: l,
|
|
51
|
+
onCancel: p
|
|
52
52
|
}) {
|
|
53
|
-
const
|
|
54
|
-
control:
|
|
53
|
+
const u = A({
|
|
54
|
+
control: t.form.hookFormInternals.formMethods.control,
|
|
55
55
|
name: "deductAsPercentage"
|
|
56
|
-
}),
|
|
57
|
-
const
|
|
58
|
-
|
|
56
|
+
}), d = u === !0 || u === "true", a = async () => {
|
|
57
|
+
const i = await t.actions.onSubmit();
|
|
58
|
+
i && l(i.data, i.mode);
|
|
59
59
|
};
|
|
60
|
-
return /* @__PURE__ */ n(
|
|
61
|
-
/* @__PURE__ */ n(
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
60
|
+
return /* @__PURE__ */ n(g, { error: t.errorHandling.errors, children: /* @__PURE__ */ n(y, { formHookResult: t, children: /* @__PURE__ */ n(b, { onSubmit: a, children: /* @__PURE__ */ c(m, { flexDirection: "column", gap: 32, children: [
|
|
61
|
+
/* @__PURE__ */ n(r.Heading, { as: "h3", children: s }),
|
|
62
|
+
/* @__PURE__ */ c(m, { flexDirection: "column", gap: 20, children: [
|
|
63
|
+
/* @__PURE__ */ c(m, { flexDirection: "column", gap: 20, children: [
|
|
64
64
|
/* @__PURE__ */ n(
|
|
65
|
-
|
|
65
|
+
o.Description,
|
|
66
66
|
{
|
|
67
67
|
label: e("descriptionLabelV2"),
|
|
68
68
|
validationMessages: { REQUIRED: e("descriptionRequired") }
|
|
69
69
|
}
|
|
70
70
|
),
|
|
71
71
|
/* @__PURE__ */ n(
|
|
72
|
-
|
|
72
|
+
o.Recurring,
|
|
73
73
|
{
|
|
74
74
|
label: e("frequencyLabel"),
|
|
75
|
-
getOptionLabel: (
|
|
75
|
+
getOptionLabel: (i) => e(i ? "frequencyRecurringOptionV2" : "frequencyOneTimeOptionV2"),
|
|
76
76
|
validationMessages: { REQUIRED: e("frequencyRequired") }
|
|
77
77
|
}
|
|
78
78
|
),
|
|
79
79
|
/* @__PURE__ */ n(
|
|
80
|
-
|
|
80
|
+
o.DeductAsPercentage,
|
|
81
81
|
{
|
|
82
82
|
label: e("deductionTypeLabelV2"),
|
|
83
|
-
getOptionLabel: (
|
|
83
|
+
getOptionLabel: (i) => e(i ? "deductionTypePercentageOptionV2" : "deductionTypeFixedAmountOption"),
|
|
84
84
|
validationMessages: { REQUIRED: e("deductionTypeRequired") }
|
|
85
85
|
}
|
|
86
86
|
),
|
|
87
87
|
/* @__PURE__ */ n(
|
|
88
|
-
|
|
88
|
+
o.Amount,
|
|
89
89
|
{
|
|
90
90
|
label: e("deductionAmountLabel"),
|
|
91
|
-
format:
|
|
92
|
-
description: e(
|
|
91
|
+
format: d ? "percent" : "currency",
|
|
92
|
+
description: e(d ? "deductionAmountDescriptionPercentage" : "deductionAmountDescriptionFixed"),
|
|
93
93
|
min: 0,
|
|
94
94
|
validationMessages: {
|
|
95
95
|
REQUIRED: e("amountRequired"),
|
|
@@ -98,9 +98,9 @@ function x({
|
|
|
98
98
|
}
|
|
99
99
|
)
|
|
100
100
|
] }),
|
|
101
|
-
|
|
101
|
+
o.TotalAmount && o.AnnualMaximum && /* @__PURE__ */ c(m, { flexDirection: "column", gap: 20, children: [
|
|
102
102
|
/* @__PURE__ */ n(
|
|
103
|
-
|
|
103
|
+
o.TotalAmount,
|
|
104
104
|
{
|
|
105
105
|
label: e("totalAmountLabel"),
|
|
106
106
|
description: e("totalAmountDescription"),
|
|
@@ -112,7 +112,7 @@ function x({
|
|
|
112
112
|
}
|
|
113
113
|
),
|
|
114
114
|
/* @__PURE__ */ n(
|
|
115
|
-
|
|
115
|
+
o.AnnualMaximum,
|
|
116
116
|
{
|
|
117
117
|
label: e("annualMaxLabel"),
|
|
118
118
|
description: e("annualMaxDescription"),
|
|
@@ -125,9 +125,9 @@ function x({
|
|
|
125
125
|
)
|
|
126
126
|
] })
|
|
127
127
|
] }),
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */ n(
|
|
130
|
-
/* @__PURE__ */ n(
|
|
128
|
+
/* @__PURE__ */ c(h, { children: [
|
|
129
|
+
/* @__PURE__ */ n(r.Button, { variant: "secondary", type: "button", onClick: p, children: e("cancelCta") }),
|
|
130
|
+
/* @__PURE__ */ n(r.Button, { type: "submit", isLoading: t.status.isPending, children: e("saveCta") })
|
|
131
131
|
] })
|
|
132
132
|
] }) }) }) });
|
|
133
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardDeductionForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useWatch } from 'react-hook-form'\nimport type {\n Garnishment,\n GarnishmentType,\n} from '@gusto/embedded-api/models/components/garnishment'\nimport type { Control } from 'react-hook-form'\nimport { useDeductionForm } from '../shared/useDeductionForm'\nimport type { DeductionFormData } from '../shared/useDeductionForm'\nimport { Form } from '@/components/Common/Form'\nimport { ActionsLayout } from '@/components/Common'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { BaseLayout } from '@/components/Base/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ninterface StandardDeductionFormProps {\n employeeId: string\n deduction: Garnishment | null\n /** Court-ordered garnishments require `garnishmentType`. Custom deductions don't. */\n courtOrdered: boolean\n /** Only meaningful when `courtOrdered: true`. Selects the garnishment type\n * on create. Ignored in edit mode (the existing type is preserved). */\n garnishmentType?: GarnishmentType\n /** Section heading shown above the form. The parent picker is responsible\n * for translating the garnishment-type label so this component doesn't\n * need to repeat the labels mapping. */\n title: string\n onSaved: (deduction: Garnishment, mode: 'create' | 'update') => void\n onCancel: () => void\n}\n\nexport function StandardDeductionForm({\n employeeId,\n deduction,\n courtOrdered,\n garnishmentType,\n title,\n onSaved,\n onCancel,\n}: StandardDeductionFormProps) {\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n const form = useDeductionForm({\n employeeId,\n garnishmentId: deduction?.uuid,\n courtOrdered,\n defaultValues: courtOrdered && garnishmentType ? { garnishmentType } : undefined,\n })\n\n if (form.isLoading) {\n return <BaseLayout isLoading error={form.errorHandling.errors} />\n }\n\n const { Fields } = form.form\n return (\n <ReadyForm\n form={form}\n Fields={Fields}\n Components={Components}\n t={t}\n title={title}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )\n}\n\n// Split into a child component so we can call `useWatch` on the form's control\n// only once the hook is in its ready state (the control reference exists then).\nfunction ReadyForm({\n form,\n Fields,\n Components,\n t,\n title,\n onSaved,\n onCancel,\n}: {\n form: Extract<ReturnType<typeof useDeductionForm>, { isLoading: false }>\n Fields: Extract<ReturnType<typeof useDeductionForm>, { isLoading: false }>['form']['Fields']\n Components: ReturnType<typeof useComponentContext>\n t: ReturnType<typeof useTranslation<'Employee.Deductions'>>['t']\n title: string\n onSaved: (deduction: Garnishment, mode: 'create' | 'update') => void\n onCancel: () => void\n}) {\n // useWatch subscribes to changes; getValues only reads once. We need the\n // subscription because `Fields.Amount`'s `format` and `description` props\n // need to re-render when the user toggles Percentage / Fixed amount.\n const watchedDeductAsPercentage = useWatch({\n control: form.form.hookFormInternals.formMethods.control as Control<DeductionFormData>,\n name: 'deductAsPercentage',\n })\n\n const handleSubmit = async () => {\n const result = await form.actions.onSubmit()\n if (result) onSaved(result.data, result.mode)\n }\n\n return (\n <BaseLayout error={form.errorHandling.errors}>\n <SDKFormProvider formHookResult={form}>\n <Form onSubmit={handleSubmit}>\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h3\">{title}</Components.Heading>\n <Flex flexDirection=\"column\" gap={20}>\n <Flex flexDirection=\"column\" gap={20}>\n <Fields.Description\n label={t('descriptionLabelV2')}\n validationMessages={{ REQUIRED: t('descriptionRequired') }}\n />\n <Fields.Recurring\n label={t('frequencyLabel')}\n getOptionLabel={(value: boolean) =>\n value ? t('frequencyRecurringOptionV2') : t('frequencyOneTimeOptionV2')\n }\n validationMessages={{ REQUIRED: t('frequencyRequired') }}\n />\n <Fields.DeductAsPercentage\n label={t('deductionTypeLabelV2')}\n getOptionLabel={(value: boolean) =>\n value\n ? t('deductionTypePercentageOptionV2')\n : t('deductionTypeFixedAmountOption')\n }\n validationMessages={{ REQUIRED: t('deductionTypeRequired') }}\n />\n <Fields.Amount\n label={t('deductionAmountLabel')}\n format={watchedDeductAsPercentage ? 'percent' : 'currency'}\n description={\n watchedDeductAsPercentage\n ? t('deductionAmountDescriptionPercentage')\n : t('deductionAmountDescriptionFixed')\n }\n min={0}\n validationMessages={{\n REQUIRED: t('amountRequired'),\n NEGATIVE_AMOUNT: t('amountNonNegative'),\n }}\n />\n </Flex>\n {Fields.TotalAmount && Fields.AnnualMaximum && (\n <Flex flexDirection=\"column\" gap={20}>\n <Fields.TotalAmount\n label={t('totalAmountLabel')}\n description={t('totalAmountDescription')}\n format=\"currency\"\n min={0}\n validationMessages={{\n NEGATIVE_AMOUNT: t('amountNonNegative'),\n }}\n />\n <Fields.AnnualMaximum\n label={t('annualMaxLabel')}\n description={t('annualMaxDescription')}\n format=\"currency\"\n min={0}\n validationMessages={{\n NEGATIVE_AMOUNT: t('amountNonNegative'),\n }}\n />\n </Flex>\n )}\n </Flex>\n <ActionsLayout>\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={form.status.isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n )\n}\n"],"names":["StandardDeductionForm","employeeId","deduction","courtOrdered","garnishmentType","title","onSaved","onCancel","t","useTranslation","Components","useComponentContext","form","useDeductionForm","BaseLayout","Fields","jsx","ReadyForm","watchedDeductAsPercentage","useWatch","handleSubmit","result","SDKFormProvider","Form","jsxs","Flex","value","ActionsLayout"],"mappings":";;;;;;;;;;;;AAgCO,SAASA,EAAsB;AAAA,EACpC,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AACF,GAA+B;AAC7B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA,GAEbC,IAAOC,E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A,cAClB,iBAAiBA,EAAE,mBAAmB;AAAA,YAAA;AAAA,UACxC;AAAA,QAAA;AAAA,QAEF,gBAAAQ;AAAA,UAACD,EAAO;AAAA,UAAP;AAAA,YACC,OAAOP,EAAE,gBAAgB;AAAA,YACzB,aAAaA,EAAE,sBAAsB;AAAA,YACrC,QAAO;AAAA,YACP,KAAK;AAAA,YACL,oBAAoB;AAAA,cAClB,iBAAiBA,EAAE,mBAAmB;AAAA,YAAA;AAAA,UACxC;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,GAEJ;AAAA,sBACCmB,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAX,EAACN,EAAW,QAAX,EAAkB,SAAQ,aAAY,MAAK,UAAS,SAASH,GAC3D,UAAAC,EAAE,WAAW,EAAA,CAChB;AAAA,MACA,gBAAAQ,EAACN,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWE,EAAK,OAAO,WACrD,UAAAJ,EAAE,SAAS,EAAA,CACd;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"StandardDeductionForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useWatch } from 'react-hook-form'\nimport type {\n Garnishment,\n GarnishmentType,\n} from '@gusto/embedded-api/models/components/garnishment'\nimport type { Control } from 'react-hook-form'\nimport { useDeductionForm } from '../shared/useDeductionForm'\nimport type { DeductionFormData } from '../shared/useDeductionForm'\nimport { Form } from '@/components/Common/Form'\nimport { ActionsLayout } from '@/components/Common'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { BaseLayout } from '@/components/Base/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ninterface StandardDeductionFormProps {\n employeeId: string\n deduction: Garnishment | null\n /** Court-ordered garnishments require `garnishmentType`. Custom deductions don't. */\n courtOrdered: boolean\n /** Only meaningful when `courtOrdered: true`. Selects the garnishment type\n * on create. Ignored in edit mode (the existing type is preserved). */\n garnishmentType?: GarnishmentType\n /** Section heading shown above the form. The parent picker is responsible\n * for translating the garnishment-type label so this component doesn't\n * need to repeat the labels mapping. */\n title: string\n onSaved: (deduction: Garnishment, mode: 'create' | 'update') => void\n onCancel: () => void\n}\n\nexport function StandardDeductionForm({\n employeeId,\n deduction,\n courtOrdered,\n garnishmentType,\n title,\n onSaved,\n onCancel,\n}: StandardDeductionFormProps) {\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n const form = useDeductionForm({\n employeeId,\n garnishmentId: deduction?.uuid,\n courtOrdered,\n defaultValues: courtOrdered && garnishmentType ? { garnishmentType } : undefined,\n })\n\n if (form.isLoading) {\n return <BaseLayout isLoading error={form.errorHandling.errors} />\n }\n\n const { Fields } = form.form\n return (\n <ReadyForm\n form={form}\n Fields={Fields}\n Components={Components}\n t={t}\n title={title}\n onSaved={onSaved}\n onCancel={onCancel}\n />\n )\n}\n\n// Split into a child component so we can call `useWatch` on the form's control\n// only once the hook is in its ready state (the control reference exists then).\nfunction ReadyForm({\n form,\n Fields,\n Components,\n t,\n title,\n onSaved,\n onCancel,\n}: {\n form: Extract<ReturnType<typeof useDeductionForm>, { isLoading: false }>\n Fields: Extract<ReturnType<typeof useDeductionForm>, { isLoading: false }>['form']['Fields']\n Components: ReturnType<typeof useComponentContext>\n t: ReturnType<typeof useTranslation<'Employee.Deductions'>>['t']\n title: string\n onSaved: (deduction: Garnishment, mode: 'create' | 'update') => void\n onCancel: () => void\n}) {\n // useWatch subscribes to changes; getValues only reads once. We need the\n // subscription because `Fields.Amount`'s `format` and `description` props\n // need to re-render when the user toggles Percentage / Fixed amount.\n // The RadioGroup's options carry string values (`'true'`/`'false'`), which\n // round-trip into form state as strings — only `coerceStringBoolean` in the\n // zod preprocessor turns them into actual booleans at validation time. So\n // here we explicitly compare against both shapes; `Boolean('false')` would\n // be truthy and surface the wrong copy under the Amount field.\n const watchedDeductAsPercentageRaw = useWatch({\n control: form.form.hookFormInternals.formMethods.control as Control<DeductionFormData>,\n name: 'deductAsPercentage',\n }) as boolean | 'true' | 'false' | undefined\n const watchedDeductAsPercentage =\n watchedDeductAsPercentageRaw === true || watchedDeductAsPercentageRaw === 'true'\n\n const handleSubmit = async () => {\n const result = await form.actions.onSubmit()\n if (result) onSaved(result.data, result.mode)\n }\n\n return (\n <BaseLayout error={form.errorHandling.errors}>\n <SDKFormProvider formHookResult={form}>\n <Form onSubmit={handleSubmit}>\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h3\">{title}</Components.Heading>\n <Flex flexDirection=\"column\" gap={20}>\n <Flex flexDirection=\"column\" gap={20}>\n <Fields.Description\n label={t('descriptionLabelV2')}\n validationMessages={{ REQUIRED: t('descriptionRequired') }}\n />\n <Fields.Recurring\n label={t('frequencyLabel')}\n getOptionLabel={(value: boolean) =>\n value ? t('frequencyRecurringOptionV2') : t('frequencyOneTimeOptionV2')\n }\n validationMessages={{ REQUIRED: t('frequencyRequired') }}\n />\n <Fields.DeductAsPercentage\n label={t('deductionTypeLabelV2')}\n getOptionLabel={(value: boolean) =>\n value\n ? t('deductionTypePercentageOptionV2')\n : t('deductionTypeFixedAmountOption')\n }\n validationMessages={{ REQUIRED: t('deductionTypeRequired') }}\n />\n <Fields.Amount\n label={t('deductionAmountLabel')}\n format={watchedDeductAsPercentage ? 'percent' : 'currency'}\n description={\n watchedDeductAsPercentage\n ? t('deductionAmountDescriptionPercentage')\n : t('deductionAmountDescriptionFixed')\n }\n min={0}\n validationMessages={{\n REQUIRED: t('amountRequired'),\n NEGATIVE_AMOUNT: t('amountNonNegative'),\n }}\n />\n </Flex>\n {Fields.TotalAmount && Fields.AnnualMaximum && (\n <Flex flexDirection=\"column\" gap={20}>\n <Fields.TotalAmount\n label={t('totalAmountLabel')}\n description={t('totalAmountDescription')}\n format=\"currency\"\n min={0}\n validationMessages={{\n NEGATIVE_AMOUNT: t('amountNonNegative'),\n }}\n />\n <Fields.AnnualMaximum\n label={t('annualMaxLabel')}\n description={t('annualMaxDescription')}\n format=\"currency\"\n min={0}\n validationMessages={{\n NEGATIVE_AMOUNT: t('amountNonNegative'),\n }}\n />\n </Flex>\n )}\n </Flex>\n <ActionsLayout>\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={form.status.isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n )\n}\n"],"names":["StandardDeductionForm","employeeId","deduction","courtOrdered","garnishmentType","title","onSaved","onCancel","t","useTranslation","Components","useComponentContext","form","useDeductionForm","BaseLayout","Fields","jsx","ReadyForm","watchedDeductAsPercentageRaw","useWatch","watchedDeductAsPercentage","handleSubmit","result","SDKFormProvider","Form","jsxs","Flex","value","ActionsLayout"],"mappings":";;;;;;;;;;;;AAgCO,SAASA,EAAsB;AAAA,EACpC,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AACF,GAA+B;AAC7B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA,GAEbC,IAAOC,EAAiB;AAAA,IAC5B,YAAAZ;AAAA,IACA,eAAeC,GAAW;AAAA,IAC1B,cAAAC;AAAA,IACA,eAAeA,KAAgBC,IAAkB,EAAE,iBAAAA,MAAoB;AAAA,EAAA,CACxE;AAED,MAAIQ,EAAK;AACP,6BAAQE,GAAA,EAAW,WAAS,IAAC,OAAOF,EAAK,cAAc,QAAQ;AAGjE,QAAM,EAAE,QAAAG,MAAWH,EAAK;AACxB,SACE,gBAAAI;AAAA,IAACC;AAAA,IAAA;AA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AmB;AAAA,YAAA;AAAA,UACxC;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,GAEJ;AAAA,sBACCoB,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAZ,EAACN,EAAW,QAAX,EAAkB,SAAQ,aAAY,MAAK,UAAS,SAASH,GAC3D,UAAAC,EAAE,WAAW,EAAA,CAChB;AAAA,MACA,gBAAAQ,EAACN,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWE,EAAK,OAAO,WACrD,UAAAJ,EAAE,SAAS,EAAA,CACd;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
@@ -38,14 +38,23 @@ export type ChildSupportGarnishmentFormOutputs = ChildSupportGarnishmentFormData
|
|
|
38
38
|
interface ChildSupportGarnishmentFormSchemaOptions {
|
|
39
39
|
mode?: 'create' | 'update';
|
|
40
40
|
/**
|
|
41
|
-
* The agency record matching the currently selected `state`.
|
|
42
|
-
* `
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* The agency record matching the currently selected `state`. Used only when
|
|
42
|
+
* `agencyList` is not provided — `requiredAttributes` are pinned to this
|
|
43
|
+
* single agency, so the schema must be rebuilt whenever the user picks a
|
|
44
|
+
* different state. Prefer passing `agencyList` instead so requiredness
|
|
45
|
+
* tracks the form's `state` value dynamically.
|
|
45
46
|
*/
|
|
46
47
|
selectedAgency?: Agencies | null;
|
|
48
|
+
/**
|
|
49
|
+
* Full list of agencies. When provided, the schema's requiredness for
|
|
50
|
+
* `caseNumber` / `orderNumber` / `remittanceNumber` is computed at validation
|
|
51
|
+
* time by looking up the agency whose `state` matches the form's `state`
|
|
52
|
+
* value — so a single schema instance stays correct as the user changes
|
|
53
|
+
* states. Takes precedence over `selectedAgency`.
|
|
54
|
+
*/
|
|
55
|
+
agencyList?: readonly Agencies[];
|
|
47
56
|
}
|
|
48
|
-
export declare function createChildSupportGarnishmentFormSchema({ mode, selectedAgency, }?: ChildSupportGarnishmentFormSchemaOptions): import('../../../../../partner-hook-utils/form/buildFormSchema').BuildFormSchemaResult<{
|
|
57
|
+
export declare function createChildSupportGarnishmentFormSchema({ mode, selectedAgency, agencyList, }?: ChildSupportGarnishmentFormSchemaOptions): import('../../../../../partner-hook-utils/form/buildFormSchema').BuildFormSchemaResult<{
|
|
49
58
|
state: z.ZodString;
|
|
50
59
|
fipsCode: z.ZodString;
|
|
51
60
|
caseNumber: z.ZodString;
|