@gusto/embedded-react-sdk 0.21.0 → 0.23.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +32 -17
- package/dist/assets/icons/eye.svg.js +10 -0
- package/dist/assets/icons/eye.svg.js.map +1 -0
- package/dist/assets/icons/icon-file-outline.svg.js +10 -0
- package/dist/assets/icons/icon-file-outline.svg.js.map +1 -0
- package/dist/assets/icons/icon-receipt-outline.svg.js +10 -0
- package/dist/assets/icons/icon-receipt-outline.svg.js.map +1 -0
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/index.d.ts +1 -1
- package/dist/components/Common/Fields/CheckboxField/CheckboxField.js.map +1 -1
- package/dist/components/Common/Fields/CheckboxGroupField/CheckboxGroupField.js.map +1 -1
- package/dist/components/Common/Fields/ComboBoxField/ComboBoxField.js.map +1 -1
- package/dist/components/Common/Fields/DatePickerField/DatePickerField.js.map +1 -1
- package/dist/components/Common/Fields/NumberInputField/NumberInputField.js.map +1 -1
- package/dist/components/Common/Fields/RadioGroupField/RadioGroupField.js.map +1 -1
- package/dist/components/Common/Fields/SelectField/SelectField.js.map +1 -1
- package/dist/components/Common/Fields/SwitchField/SwitchField.js.map +1 -1
- package/dist/components/Common/Fields/TextAreaField/TextAreaField.js.map +1 -1
- package/dist/components/Common/Fields/TextInputField/TextInputField.js.map +1 -1
- package/dist/components/Common/Fieldset/Fieldset.js.map +1 -1
- package/dist/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers.d.ts +1 -0
- package/dist/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers.js +14 -0
- package/dist/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers.js.map +1 -0
- package/dist/components/Common/FlowBreadcrumbs/index.d.ts +1 -0
- package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +1 -1
- package/dist/components/Common/ReorderableList/ReorderableItem.d.ts +1 -1
- package/dist/components/Common/ReorderableList/ReorderableItem.js.map +1 -1
- package/dist/components/Common/ReorderableList/ReorderableList.js +7 -7
- package/dist/components/Common/ReorderableList/ReorderableList.js.map +1 -1
- package/dist/components/Common/UI/Badge/BadgeTypes.js.map +1 -1
- package/dist/components/Common/UI/Banner/BannerTypes.js.map +1 -1
- package/dist/components/Common/UI/Button/ButtonIcon.d.ts +1 -1
- package/dist/components/Common/UI/Button/ButtonIcon.js +10 -7
- package/dist/components/Common/UI/Button/ButtonIcon.js.map +1 -1
- package/dist/components/Common/UI/Button/ButtonTypes.js.map +1 -1
- package/dist/components/Common/UI/Checkbox/CheckboxTypes.js.map +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBox.module.scss.js +1 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.module.scss.js +7 -7
- package/dist/components/Common/UI/Input/InputTypes.js.map +1 -1
- package/dist/components/Common/UI/LoadingSpinner/LoadingSpinnerTypes.js.map +1 -1
- package/dist/components/Common/UI/Radio/RadioTypes.js.map +1 -1
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.js.map +1 -1
- package/dist/components/Common/UI/Select/Select.module.scss.js +6 -6
- package/dist/components/Common/UI/Switch/SwitchTypes.js.map +1 -1
- package/dist/components/Common/UI/Table/Table.module.scss.js +1 -1
- package/dist/components/Common/UI/Table/TableTypes.js.map +1 -1
- package/dist/components/Common/UI/Tabs/Tabs.module.scss.js +5 -5
- package/dist/components/Common/UI/TextArea/TextAreaTypes.js.map +1 -1
- package/dist/components/Common/UI/TextInput/TextInputTypes.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/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- 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/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +5 -6
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- 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/Company/index.d.ts +2 -0
- package/dist/components/Company/index.js +20 -16
- package/dist/components/Company/index.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/Payments/CreatePayment/CreatePayment.d.ts +7 -0
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +204 -0
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -0
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.d.ts +15 -9
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js +140 -0
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js.map +1 -0
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.d.ts +39 -0
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +131 -0
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js.map +1 -0
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.d.ts +11 -0
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js +139 -0
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js.map +1 -0
- package/dist/components/Contractor/Payments/CreatePayment/helpers.d.ts +2 -0
- package/dist/components/Contractor/Payments/CreatePayment/helpers.js +6 -0
- package/dist/components/Contractor/Payments/CreatePayment/helpers.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.d.ts +2 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.js +26 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.d.ts +16 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js +31 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentFlow/index.d.ts +3 -0
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.d.ts +7 -0
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js +122 -0
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.d.ts +8 -0
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +26 -0
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.d.ts +17 -15
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js +114 -0
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.d.ts +9 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js +49 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.d.ts +12 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js +116 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js.map +1 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.module.scss.js +10 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.module.scss.js.map +1 -0
- package/dist/components/Contractor/Payments/types.d.ts +8 -0
- package/dist/components/Contractor/Profile/useContractorProfile.d.ts +26 -26
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Contractor/index.d.ts +1 -0
- package/dist/components/Contractor/index.js +4 -2
- package/dist/components/Contractor/index.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +2 -3
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.d.ts +0 -3
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +62 -77
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/DeductionsForm.js +83 -50
- package/dist/components/Employee/Deductions/DeductionsForm/DeductionsForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.d.ts +56 -0
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +159 -0
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -0
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +3 -4
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalForm.d.ts +22 -7
- package/dist/components/Employee/FederalTaxes/FederalForm.js +86 -32
- package/dist/components/Employee/FederalTaxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalTaxes.js +62 -46
- package/dist/components/Employee/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +3 -4
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +25 -23
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js +116 -106
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +5 -6
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.d.ts +6 -6
- package/dist/components/Employee/Profile/PersonalDetailsInputs.d.ts +2 -2
- package/dist/components/Employee/Profile/useProfile.js +3 -4
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +3 -4
- package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.d.ts +22 -7
- package/dist/components/Employee/Taxes/FederalForm.js +86 -32
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +97 -81
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Flow/Flow.d.ts +3 -3
- package/dist/components/Flow/Flow.js +35 -31
- package/dist/components/Flow/Flow.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js +46 -39
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.module.scss.js +8 -0
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.module.scss.js.map +1 -0
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsBanner/ConfirmWireDetailsBanner.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsComponents.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +71 -72
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.js +21 -22
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.d.ts +2 -2
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.js +19 -19
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +1 -0
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js +75 -68
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +66 -65
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +127 -103
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +254 -185
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/{FastAchThresholdExceeded.d.ts → FastAchSubmissionBlockerBanner.d.ts} +2 -2
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchSubmissionBlockerBanner.js +55 -0
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchSubmissionBlockerBanner.js.map +1 -0
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/index.d.ts +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.module.scss.js +1 -1
- package/dist/components/Payroll/PayrollStatusBadges/payrollStatusConfig.js +1 -1
- package/dist/components/Payroll/PayrollStatusBadges/payrollStatusConfig.js.map +1 -1
- package/dist/components/Payroll/index.d.ts +1 -1
- package/dist/components/Payroll/index.js +8 -6
- package/dist/components/Payroll/index.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +6 -7
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ComponentAdapter/componentAdapterTypes.d.ts +4 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +9 -11
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/LocaleProvider/useLocale.d.ts +6 -3
- package/dist/contexts/LocaleProvider/useLocale.js +12 -9
- package/dist/contexts/LocaleProvider/useLocale.js.map +1 -1
- package/dist/helpers/currencyHelpers.d.ts +2 -0
- package/dist/helpers/currencyHelpers.js +6 -0
- package/dist/helpers/currencyHelpers.js.map +1 -0
- package/dist/helpers/formattedStrings.js +11 -12
- package/dist/helpers/formattedStrings.js.map +1 -1
- package/dist/i18n/I18n.js +10 -10
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Contractor.Payments.CreatePayment.json.js +40 -0
- package/dist/i18n/en/Contractor.Payments.CreatePayment.json.js.map +1 -0
- package/dist/i18n/en/Contractor.Payments.PaymentHistory.json.js +24 -0
- package/dist/i18n/en/Contractor.Payments.PaymentHistory.json.js.map +1 -0
- package/dist/i18n/en/Contractor.Payments.PaymentsList.json.js +36 -0
- package/dist/i18n/en/Contractor.Payments.PaymentsList.json.js.map +1 -0
- package/dist/i18n/en/Employee.Deductions.json.js +58 -46
- package/dist/i18n/en/Employee.Deductions.json.js.map +1 -1
- package/dist/i18n/en/Employee.FederalTaxes.json.js +49 -41
- package/dist/i18n/en/Employee.FederalTaxes.json.js.map +1 -1
- package/dist/i18n/en/Employee.Taxes.json.js +53 -45
- package/dist/i18n/en/Employee.Taxes.json.js.map +1 -1
- package/dist/i18n/en/Payroll.ConfirmWireDetailsForm.json.js +5 -5
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +35 -31
- package/dist/i18n/en/Payroll.PayrollOverview.json.js.map +1 -1
- package/dist/shared/constants.d.ts +18 -0
- package/dist/shared/constants.js +73 -59
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +182 -125
- package/package.json +18 -18
- package/dist/components/Contractor/Payments/Detail/DetailPresentation.d.ts +0 -19
- package/dist/components/Contractor/Payments/Overview/OverviewPresentation.d.ts +0 -18
- package/dist/components/Contractor/Payments/PaymentEdit/PaymentEditPresentation.d.ts +0 -6
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchThresholdExceeded.js +0 -52
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchThresholdExceeded.js.map +0 -1
- package/dist/i18n/en/ContractorPayment.ContractorPaymentCreatePayment.json.js +0 -32
- package/dist/i18n/en/ContractorPayment.ContractorPaymentCreatePayment.json.js.map +0 -1
- package/dist/i18n/en/ContractorPayment.ContractorPaymentDetail.json.js +0 -24
- package/dist/i18n/en/ContractorPayment.ContractorPaymentDetail.json.js.map +0 -1
- package/dist/i18n/en/ContractorPayment.ContractorPaymentOverview.json.js +0 -32
- package/dist/i18n/en/ContractorPayment.ContractorPaymentOverview.json.js.map +0 -1
- package/dist/i18n/en/ContractorPayment.ContractorPaymentPaymentHistory.json.js +0 -32
- package/dist/i18n/en/ContractorPayment.ContractorPaymentPaymentHistory.json.js.map +0 -1
|
@@ -1,42 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as b } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as T } from "react-i18next";
|
|
3
|
-
import { useForm as q, useWatch as
|
|
4
|
-
import { useMemo as
|
|
3
|
+
import { useForm as q, useWatch as f, FormProvider as F } from "react-hook-form";
|
|
4
|
+
import { useMemo as R } from "react";
|
|
5
5
|
import { z as r } from "zod";
|
|
6
|
-
import { zodResolver as
|
|
7
|
-
import { useGarnishmentsCreateMutation as
|
|
8
|
-
import { useGarnishmentsUpdateMutation as
|
|
9
|
-
import { useComponentContext as
|
|
10
|
-
import { Form as
|
|
11
|
-
import { Flex as
|
|
6
|
+
import { zodResolver as S } from "@hookform/resolvers/zod";
|
|
7
|
+
import { useGarnishmentsCreateMutation as N } from "@gusto/embedded-api/react-query/garnishmentsCreate";
|
|
8
|
+
import { useGarnishmentsUpdateMutation as I } from "@gusto/embedded-api/react-query/garnishmentsUpdate";
|
|
9
|
+
import { useComponentContext as U } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
|
+
import { Form as V } from "../../../Common/Form/Form.js";
|
|
11
|
+
import { Flex as _ } from "../../../Common/Flex/Flex.js";
|
|
12
12
|
import "classnames";
|
|
13
|
-
import { componentEvents as
|
|
14
|
-
import { RadioGroupField as
|
|
15
|
-
import { TextInputField as
|
|
16
|
-
import { ActionsLayout as
|
|
17
|
-
import { NumberInputField as
|
|
13
|
+
import { componentEvents as c } from "../../../../shared/constants.js";
|
|
14
|
+
import { RadioGroupField as g } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
15
|
+
import { TextInputField as w } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
16
|
+
import { ActionsLayout as B } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
17
|
+
import { NumberInputField as d } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
18
18
|
import "react-error-boundary";
|
|
19
19
|
import "@gusto/embedded-api/models/errors/apierror";
|
|
20
20
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
21
21
|
import "@tanstack/react-query";
|
|
22
|
-
import { useBase as
|
|
22
|
+
import { useBase as j } from "../../../Base/useBase.js";
|
|
23
23
|
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
24
24
|
import "dompurify";
|
|
25
|
-
|
|
26
|
-
import { CheckboxField as $ } from "../../../Common/Fields/CheckboxField/CheckboxField.js";
|
|
27
|
-
const k = r.object({
|
|
25
|
+
const G = r.object({
|
|
28
26
|
active: r.boolean(),
|
|
29
27
|
amount: r.number().min(0).transform(String),
|
|
30
28
|
description: r.string().min(1),
|
|
31
|
-
courtOrdered: r.boolean(),
|
|
32
29
|
times: r.number().nullable(),
|
|
33
30
|
recurring: r.boolean(),
|
|
34
31
|
annualMaximum: r.number().min(0).transform((e) => e > 0 ? e.toString() : null).nullable(),
|
|
35
32
|
totalAmount: r.number().min(0).transform((e) => e > 0 ? e.toString() : null).nullable(),
|
|
36
33
|
deductAsPercentage: r.boolean()
|
|
37
34
|
});
|
|
38
|
-
function
|
|
39
|
-
const { onEvent: a, baseSubmitHandler:
|
|
35
|
+
function pe({ deduction: e, employeeId: A }) {
|
|
36
|
+
const { onEvent: a, baseSubmitHandler: D } = j(), { t: n } = T("Employee.Deductions"), m = U(), { mutateAsync: h, isPending: E } = N(), { mutateAsync: P, isPending: C } = I(), x = E || C, y = R(() => ({
|
|
40
37
|
amount: e?.amount ? Number(e.amount) : 0,
|
|
41
38
|
description: e?.description ?? "",
|
|
42
39
|
times: e?.times ?? null,
|
|
@@ -44,19 +41,14 @@ function he({ deduction: e, employeeId: A }) {
|
|
|
44
41
|
annualMaximum: e?.annualMaximum ? Number(e.annualMaximum) : null,
|
|
45
42
|
totalAmount: e?.totalAmount ? Number(e.totalAmount) : null,
|
|
46
43
|
deductAsPercentage: e?.deductAsPercentage ?? !0,
|
|
47
|
-
active: !0
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
N(() => {
|
|
54
|
-
b(u);
|
|
55
|
-
}, [e, u, b]);
|
|
56
|
-
const M = D({ control: f, name: "recurring" }), o = D({ control: f, name: "deductAsPercentage" }), F = async (v) => {
|
|
57
|
-
await E(v, async (i) => {
|
|
44
|
+
active: !0
|
|
45
|
+
}), [e]), u = q({
|
|
46
|
+
resolver: S(G),
|
|
47
|
+
defaultValues: y
|
|
48
|
+
}), { control: p } = u, M = f({ control: p, name: "recurring" }), o = f({ control: p, name: "deductAsPercentage" }), v = async (O) => {
|
|
49
|
+
await D(O, async (i) => {
|
|
58
50
|
if (e) {
|
|
59
|
-
const { garnishment:
|
|
51
|
+
const { garnishment: s } = await P({
|
|
60
52
|
request: {
|
|
61
53
|
garnishmentId: e.uuid,
|
|
62
54
|
requestBody: {
|
|
@@ -66,100 +58,93 @@ function he({ deduction: e, employeeId: A }) {
|
|
|
66
58
|
}
|
|
67
59
|
}
|
|
68
60
|
});
|
|
69
|
-
a(
|
|
61
|
+
a(c.EMPLOYEE_DEDUCTION_UPDATED, s);
|
|
70
62
|
} else {
|
|
71
|
-
const { garnishment:
|
|
63
|
+
const { garnishment: s } = await h({
|
|
72
64
|
request: {
|
|
73
65
|
employeeId: A,
|
|
74
|
-
requestBody: { ...i, times: i.recurring ? null : 1 }
|
|
66
|
+
requestBody: { ...i, courtOrdered: !1, times: i.recurring ? null : 1 }
|
|
67
|
+
// custom deductions cannot be court ordered/garnishment
|
|
75
68
|
}
|
|
76
69
|
});
|
|
77
|
-
a(
|
|
70
|
+
a(c.EMPLOYEE_DEDUCTION_CREATED, s);
|
|
78
71
|
}
|
|
79
72
|
});
|
|
80
73
|
}, L = () => {
|
|
81
|
-
a(
|
|
74
|
+
a(c.EMPLOYEE_DEDUCTION_CANCEL);
|
|
82
75
|
};
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
|
|
76
|
+
return /* @__PURE__ */ t(F, { ...u, children: /* @__PURE__ */ t(V, { onSubmit: u.handleSubmit(v), children: /* @__PURE__ */ t(_, { flexDirection: "column", gap: 32, children: /* @__PURE__ */ l(b, { children: [
|
|
77
|
+
/* @__PURE__ */ t(m.Heading, { as: "h3", children: n("customDeductionTitle") }),
|
|
78
|
+
/* @__PURE__ */ t(w, { name: "description", label: n("descriptionLabelV2"), isRequired: !0 }),
|
|
79
|
+
/* @__PURE__ */ t(
|
|
80
|
+
g,
|
|
88
81
|
{
|
|
89
82
|
name: "recurring",
|
|
90
|
-
label:
|
|
83
|
+
label: n("frequencyLabel"),
|
|
91
84
|
isRequired: !0,
|
|
92
85
|
options: [
|
|
93
|
-
{ value: !0, label:
|
|
94
|
-
{ value: !1, label:
|
|
86
|
+
{ value: !0, label: n("frequencyRecurringOptionV2") },
|
|
87
|
+
{ value: !1, label: n("frequencyOneTimeOptionV2") }
|
|
95
88
|
]
|
|
96
89
|
}
|
|
97
90
|
),
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
|
|
91
|
+
/* @__PURE__ */ t(
|
|
92
|
+
g,
|
|
100
93
|
{
|
|
101
94
|
name: "deductAsPercentage",
|
|
102
|
-
label:
|
|
95
|
+
label: n("deductionTypeLabelV2"),
|
|
103
96
|
isRequired: !0,
|
|
104
97
|
options: [
|
|
105
|
-
{ value: !0, label:
|
|
106
|
-
{ value: !1, label:
|
|
98
|
+
{ value: !0, label: n("deductionTypePercentageOptionV2") },
|
|
99
|
+
{ value: !1, label: n("deductionTypeFixedAmountOption") }
|
|
107
100
|
]
|
|
108
101
|
}
|
|
109
102
|
),
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
|
|
103
|
+
/* @__PURE__ */ t(
|
|
104
|
+
d,
|
|
112
105
|
{
|
|
113
106
|
name: "amount",
|
|
114
107
|
adornmentStart: !o && "$",
|
|
115
108
|
adornmentEnd: o && "%",
|
|
116
|
-
label:
|
|
109
|
+
label: n("deductionAmountLabel"),
|
|
117
110
|
isRequired: !0,
|
|
118
111
|
min: 0,
|
|
119
112
|
format: o ? "percent" : "currency",
|
|
120
|
-
description:
|
|
113
|
+
description: n(o ? "deductionAmountDescriptionPercentage" : "deductionAmountDescriptionFixed")
|
|
121
114
|
}
|
|
122
115
|
),
|
|
123
|
-
M && /* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
|
|
116
|
+
M && /* @__PURE__ */ l(b, { children: [
|
|
117
|
+
/* @__PURE__ */ t(
|
|
118
|
+
d,
|
|
126
119
|
{
|
|
127
120
|
name: "totalAmount",
|
|
128
121
|
adornmentStart: "$",
|
|
129
122
|
format: "currency",
|
|
130
|
-
label:
|
|
131
|
-
description:
|
|
123
|
+
label: n("totalAmountLabel"),
|
|
124
|
+
description: n("totalAmountDescription"),
|
|
132
125
|
min: 0
|
|
133
126
|
}
|
|
134
127
|
),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
|
|
128
|
+
/* @__PURE__ */ t(
|
|
129
|
+
d,
|
|
137
130
|
{
|
|
138
131
|
name: "annualMaximum",
|
|
139
132
|
adornmentStart: "$",
|
|
140
133
|
format: "currency",
|
|
141
|
-
label:
|
|
134
|
+
label: n("annualMaxLabel"),
|
|
142
135
|
min: 0,
|
|
143
|
-
description:
|
|
136
|
+
description: n("annualMaxDescription")
|
|
144
137
|
}
|
|
145
138
|
)
|
|
146
139
|
] }),
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
|
|
149
|
-
{
|
|
150
|
-
name: "courtOrdered",
|
|
151
|
-
label: t("courtOrderedLabel"),
|
|
152
|
-
isDisabled: !!e
|
|
153
|
-
}
|
|
154
|
-
),
|
|
155
|
-
/* @__PURE__ */ c(G, { children: [
|
|
156
|
-
/* @__PURE__ */ n(m.Button, { variant: "secondary", onClick: L, children: t("cancelCta") }),
|
|
157
|
-
/* @__PURE__ */ n(m.Button, { type: "submit", isLoading: O, children: t(e ? "continueCta" : "addDeductionCta") })
|
|
140
|
+
/* @__PURE__ */ l(B, { children: [
|
|
141
|
+
/* @__PURE__ */ t(m.Button, { variant: "secondary", onClick: L, children: n("cancelCta") }),
|
|
142
|
+
/* @__PURE__ */ t(m.Button, { type: "submit", isLoading: x, children: n(e ? "continueCta" : "addDeductionCta") })
|
|
158
143
|
] })
|
|
159
144
|
] }) }) }) });
|
|
160
145
|
}
|
|
161
146
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
147
|
+
G as DeductionSchema,
|
|
148
|
+
pe as default
|
|
164
149
|
};
|
|
165
150
|
//# sourceMappingURL=CustomDeductionForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDeductionForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { FormProvider, useForm, useWatch, type SubmitHandler } from 'react-hook-form'\nimport { useEffect, useMemo } from 'react'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { type Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api/react-query/garnishmentsUpdate'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { Form } from '@/components/Common/Form'\nimport { ActionsLayout } from '@/components/Common'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport {\n NumberInputField,\n TextInputField,\n RadioGroupField,\n CheckboxField,\n} from '@/components/Common'\nimport { type CommonComponentInterface, useBase } from '@/components/Base'\nimport { componentEvents } from '@/shared/constants'\n\nexport const DeductionSchema = z.object({\n active: z.boolean(),\n amount: z.number().min(0).transform(String),\n description: z.string().min(1),\n courtOrdered: z.boolean(),\n times: z.number().nullable(),\n recurring: z.boolean(),\n annualMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n totalAmount: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n deductAsPercentage: z.boolean(),\n})\n\nexport type DeductionInputs = z.input<typeof DeductionSchema>\nexport type DeductionPayload = z.output<typeof DeductionSchema>\n\ninterface ChildSupportFormProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n deduction?: Garnishment | null\n}\n\nfunction CustomDeductionForm({ deduction, employeeId }: ChildSupportFormProps) {\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n const { mutateAsync: createDeduction, isPending: isPendingCreate } =\n useGarnishmentsCreateMutation()\n const { mutateAsync: updateDeduction, isPending: isPendingUpdate } =\n useGarnishmentsUpdateMutation()\n const isPending = isPendingCreate || isPendingUpdate\n\n const defaultValues: DeductionInputs = useMemo(() => {\n return {\n amount: deduction?.amount ? Number(deduction.amount) : 0,\n description: deduction?.description ?? '',\n times: deduction?.times ?? null,\n recurring: deduction?.recurring ?? true,\n annualMaximum: deduction?.annualMaximum ? Number(deduction.annualMaximum) : null,\n totalAmount: deduction?.totalAmount ? Number(deduction.totalAmount) : null,\n deductAsPercentage: deduction?.deductAsPercentage ?? true,\n active: true,\n courtOrdered: deduction?.courtOrdered ?? false,\n } as DeductionInputs\n }, [deduction])\n\n const formMethods = useForm<DeductionInputs, unknown, DeductionPayload>({\n resolver: zodResolver(DeductionSchema),\n defaultValues,\n })\n const { reset: resetForm, control } = formMethods\n\n useEffect(() => {\n resetForm(defaultValues)\n }, [deduction, defaultValues, resetForm])\n\n const watchedRecurring = useWatch({ control, name: 'recurring' })\n const watchedAmountPercentage = useWatch({ control, name: 'deductAsPercentage' })\n\n const onSubmit: SubmitHandler<DeductionPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n if (!deduction) {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId: employeeId,\n requestBody: { ...payload, times: payload.recurring ? null : 1 },\n },\n })\n\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CREATED, createDeductionResponse)\n } else {\n const { garnishment: updateDeductionResponse } = await updateDeduction({\n request: {\n garnishmentId: deduction.uuid,\n requestBody: {\n ...payload,\n version: deduction.version as string,\n times: payload.recurring ? null : 1,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n }\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CANCEL)\n }\n\n return (\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n <>\n <Components.Heading as=\"h3\">{t('customDeductionTitle')}</Components.Heading>\n <TextInputField name=\"description\" label={t('descriptionLabelV2')} isRequired />\n <RadioGroupField\n name=\"recurring\"\n label={t('frequencyLabel')}\n isRequired\n options={[\n { value: true, label: t('frequencyRecurringOptionV2') },\n { value: false, label: t('frequencyOneTimeOptionV2') },\n ]}\n />\n <RadioGroupField\n name=\"deductAsPercentage\"\n label={t('deductionTypeLabelV2')}\n isRequired\n options={[\n { value: true, label: t('deductionTypePercentageOptionV2') },\n { value: false, label: t('deductionTypeFixedAmountOption') },\n ]}\n />\n <NumberInputField\n name=\"amount\"\n adornmentStart={!watchedAmountPercentage && '$'}\n adornmentEnd={watchedAmountPercentage && '%'}\n label={t('deductionAmountLabel')}\n isRequired\n min={0}\n format={watchedAmountPercentage ? 'percent' : 'currency'}\n description={\n watchedAmountPercentage\n ? t('deductionAmountDescriptionPercentage')\n : t('deductionAmountDescriptionFixed')\n }\n />\n {watchedRecurring && (\n <>\n <NumberInputField\n name=\"totalAmount\"\n adornmentStart=\"$\"\n format=\"currency\"\n label={t('totalAmountLabel')}\n description={t('totalAmountDescription')}\n min={0}\n />\n <NumberInputField\n name=\"annualMaximum\"\n adornmentStart=\"$\"\n format=\"currency\"\n label={t('annualMaxLabel')}\n min={0}\n description={t('annualMaxDescription')}\n />\n </>\n )}\n <CheckboxField\n name=\"courtOrdered\"\n label={t('courtOrderedLabel')}\n isDisabled={!!deduction}\n />\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={isPending}>\n {!deduction ? t('addDeductionCta') : t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n </>\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nexport default CustomDeductionForm\n"],"names":["DeductionSchema","z","val","CustomDeductionForm","deduction","employeeId","onEvent","baseSubmitHandler","useBase","useTranslation","Components","useComponentContext","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","isPending","defaultValues","useMemo","formMethods","useForm","zodResolver","resetForm","control","useEffect","watchedRecurring","useWatch","watchedAmountPercentage","onSubmit","data","payload","updateDeductionResponse","componentEvents","createDeductionResponse","handleCancel","FormProvider","jsx","Form","Flex","jsxs","Fragment","TextInputField","RadioGroupField","NumberInputField","CheckboxField","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAMA,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,QAAA;AAAA,EACV,QAAQA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,UAAU,MAAM;AAAA,EAC1C,aAAaA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,cAAcA,EAAE,QAAA;AAAA,EAChB,OAAOA,EAAE,OAAA,EAAS,SAAA;AAAA,EAClB,WAAWA,EAAE,QAAA;AAAA,EACb,eAAeA,EACZ,OAAA,EACA,IAAI,CAAC,EACL,UAAU,CAAAC,MAAQA,IAAM,IAAIA,EAAI,SAAA,IAAa,IAAK,EAClD,SAAA;AAAA,EACH,aAAaD,EACV,OAAA,EACA,IAAI,CAAC,EACL,UAAU,CAAAC,MAAQA,IAAM,IAAIA,EAAI,SAAA,IAAa,IAAK,EAClD,SAAA;AAAA,EACH,oBAAoBD,EAAE,QAAA;AACxB,CAAC;AAUD,SAASE,GAAoB,EAAE,WAAAC,GAAW,YAAAC,KAAqC;AAC7E,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjC,EAAE,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA,GAEb,EAAE,aAAaC,GAAiB,WAAWC,EAAA,IAC/CC,EAAA,GACI,EAAE,aAAaC,GAAiB,WAAWC,EAAA,IAC/CC,EAAA,GACIC,IAAYL,KAAmBG,GAE/BG,IAAiCC,EAAQ,OACtC;AAAA,IACL,QAAQhB,GAAW,SAAS,OAAOA,EAAU,MAAM,IAAI;AAAA,IACvD,aAAaA,GAAW,eAAe;AAAA,IACvC,OAAOA,GAAW,SAAS;AAAA,IAC3B,WAAWA,GAAW,aAAa;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AAAA,QACL,QAAQA,IAA0B,YAAY;AAAA,QAC9C,aAEM,EADJA,IACM,yCACA,iCADsC;AAAA,MACL;AAAA,IAAA;AAAA,IAG1CF,KACC,gBAAAc,EAAAC,GAAA,EACE,UAAA;AAAA,MAAA,gBAAAJ;AAAA,QAACO;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,gBAAe;AAAA,UACf,QAAO;AAAA,UACP,OAAO,EAAE,kBAAkB;AAAA,UAC3B,aAAa,EAAE,wBAAwB;AAAA,UACvC,KAAK;AAAA,QAAA;AAAA,MAAA;AAAA,MAEP,gBAAAP;AAAA,QAACO;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,gBAAe;AAAA,UACf,QAAO;AAAA,UACP,OAAO,EAAE,gBAAgB;AAAA,UACzB,KAAK;AAAA,UACL,aAAa,EAAE,sBAAsB;AAAA,QAAA;AAAA,MAAA;AAAA,IACvC,GACF;AAAA,IAEF,gBAAAP;AAAA,MAACQ;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAO,EAAE,mBAAmB;AAAA,QAC5B,YAAY,CAAC,CAAC1C;AAAA,MAAA;AAAA,IAAA;AAAA,sBAEf2C,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAT,EAAC5B,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAAS0B,GAC7C,UAAA,EAAE,WAAW,EAAA,CAChB;AAAA,MACA,gBAAAE,EAAC5B,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWQ,GACzC,UAAoC,EAAnCd,IAAqC,gBAAvB,iBAAoC,EAAA,CACtD;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"CustomDeductionForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { FormProvider, useForm, useWatch, type SubmitHandler } from 'react-hook-form'\nimport { useMemo } from 'react'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { type Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api/react-query/garnishmentsUpdate'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { Form } from '@/components/Common/Form'\nimport { ActionsLayout } from '@/components/Common'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { NumberInputField, TextInputField, RadioGroupField } from '@/components/Common'\nimport { type CommonComponentInterface, useBase } from '@/components/Base'\nimport { componentEvents } from '@/shared/constants'\n\nexport const DeductionSchema = z.object({\n active: z.boolean(),\n amount: z.number().min(0).transform(String),\n description: z.string().min(1),\n times: z.number().nullable(),\n recurring: z.boolean(),\n annualMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n totalAmount: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n deductAsPercentage: z.boolean(),\n})\n\nexport type DeductionInputs = z.input<typeof DeductionSchema>\nexport type DeductionPayload = z.output<typeof DeductionSchema>\n\ninterface ChildSupportFormProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n deduction?: Garnishment | null\n}\n\nfunction CustomDeductionForm({ deduction, employeeId }: ChildSupportFormProps) {\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n const { mutateAsync: createDeduction, isPending: isPendingCreate } =\n useGarnishmentsCreateMutation()\n const { mutateAsync: updateDeduction, isPending: isPendingUpdate } =\n useGarnishmentsUpdateMutation()\n const isPending = isPendingCreate || isPendingUpdate\n\n const defaultValues: DeductionInputs = useMemo(() => {\n return {\n amount: deduction?.amount ? Number(deduction.amount) : 0,\n description: deduction?.description ?? '',\n times: deduction?.times ?? null,\n recurring: deduction?.recurring ?? true,\n annualMaximum: deduction?.annualMaximum ? Number(deduction.annualMaximum) : null,\n totalAmount: deduction?.totalAmount ? Number(deduction.totalAmount) : null,\n deductAsPercentage: deduction?.deductAsPercentage ?? true,\n active: true,\n } as DeductionInputs\n }, [deduction])\n\n const formMethods = useForm<DeductionInputs, unknown, DeductionPayload>({\n resolver: zodResolver(DeductionSchema),\n defaultValues,\n })\n const { control } = formMethods\n const watchedRecurring = useWatch({ control, name: 'recurring' })\n const watchedAmountPercentage = useWatch({ control, name: 'deductAsPercentage' })\n\n const onSubmit: SubmitHandler<DeductionPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n if (!deduction) {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId: employeeId,\n requestBody: { ...payload, courtOrdered: false, times: payload.recurring ? null : 1 }, // custom deductions cannot be court ordered/garnishment\n },\n })\n\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CREATED, createDeductionResponse)\n } else {\n const { garnishment: updateDeductionResponse } = await updateDeduction({\n request: {\n garnishmentId: deduction.uuid,\n requestBody: {\n ...payload,\n version: deduction.version as string,\n times: payload.recurring ? null : 1,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n }\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CANCEL)\n }\n\n return (\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n <>\n <Components.Heading as=\"h3\">{t('customDeductionTitle')}</Components.Heading>\n <TextInputField name=\"description\" label={t('descriptionLabelV2')} isRequired />\n <RadioGroupField\n name=\"recurring\"\n label={t('frequencyLabel')}\n isRequired\n options={[\n { value: true, label: t('frequencyRecurringOptionV2') },\n { value: false, label: t('frequencyOneTimeOptionV2') },\n ]}\n />\n <RadioGroupField\n name=\"deductAsPercentage\"\n label={t('deductionTypeLabelV2')}\n isRequired\n options={[\n { value: true, label: t('deductionTypePercentageOptionV2') },\n { value: false, label: t('deductionTypeFixedAmountOption') },\n ]}\n />\n <NumberInputField\n name=\"amount\"\n adornmentStart={!watchedAmountPercentage && '$'}\n adornmentEnd={watchedAmountPercentage && '%'}\n label={t('deductionAmountLabel')}\n isRequired\n min={0}\n format={watchedAmountPercentage ? 'percent' : 'currency'}\n description={\n watchedAmountPercentage\n ? t('deductionAmountDescriptionPercentage')\n : t('deductionAmountDescriptionFixed')\n }\n />\n {watchedRecurring && (\n <>\n <NumberInputField\n name=\"totalAmount\"\n adornmentStart=\"$\"\n format=\"currency\"\n label={t('totalAmountLabel')}\n description={t('totalAmountDescription')}\n min={0}\n />\n <NumberInputField\n name=\"annualMaximum\"\n adornmentStart=\"$\"\n format=\"currency\"\n label={t('annualMaxLabel')}\n min={0}\n description={t('annualMaxDescription')}\n />\n </>\n )}\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={isPending}>\n {!deduction ? t('addDeductionCta') : t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n </>\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nexport default CustomDeductionForm\n"],"names":["DeductionSchema","z","val","CustomDeductionForm","deduction","employeeId","onEvent","baseSubmitHandler","useBase","t","useTranslation","Components","useComponentContext","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","isPending","defaultValues","useMemo","formMethods","useForm","zodResolver","control","watchedRecurring","useWatch","watchedAmountPercentage","onSubmit","data","payload","updateDeductionResponse","componentEvents","createDeductionResponse","handleCancel","FormProvider","jsx","Form","Flex","jsxs","Fragment","TextInputField","RadioGroupField","NumberInputField","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgBO,MAAMA,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,QAAA;AAAA,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,QAAA;AAAA,UACC,MAAK;AAAA,UACL,gBAAe;AAAA,UACf,QAAO;AAAA,UACP,OAAOnC,EAAE,gBAAgB;AAAA,UACzB,KAAK;AAAA,UACL,aAAaA,EAAE,sBAAsB;AAAA,QAAA;AAAA,MAAA;AAAA,IACvC,GACF;AAAA,sBAEDoC,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAR,EAAC1B,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAASwB,GAC7C,UAAA1B,EAAE,WAAW,EAAA,CAChB;AAAA,MACA,gBAAA4B,EAAC1B,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWQ,GACzC,UAAoCV,EAAnCL,IAAqC,gBAAvB,iBAAoC,EAAA,CACtD;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
@@ -1,49 +1,71 @@
|
|
|
1
|
-
import { jsx as n, jsxs as a } from "react/jsx-runtime";
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useGarnishmentsListSuspense as
|
|
5
|
-
import { useGarnishmentsGetChildSupportDataSuspense as
|
|
1
|
+
import { jsx as n, jsxs as a, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as M } from "react-i18next";
|
|
3
|
+
import { useState as u } from "react";
|
|
4
|
+
import { useGarnishmentsListSuspense as Y } from "@gusto/embedded-api/react-query/garnishmentsList";
|
|
5
|
+
import { useGarnishmentsGetChildSupportDataSuspense as B } from "@gusto/embedded-api/react-query/garnishmentsGetChildSupportData";
|
|
6
6
|
import c from "./DeductionsForm.module.scss.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
import U from "./ChildSupportForm.js";
|
|
8
|
+
import j from "./GarnishmentForm.js";
|
|
9
|
+
import k from "./CustomDeductionForm.js";
|
|
10
|
+
import { BaseComponent as I } from "../../../Base/Base.js";
|
|
11
|
+
import { useBase as V } from "../../../Base/useBase.js";
|
|
12
|
+
import { Grid as q } from "../../../Common/Grid/Grid.js";
|
|
13
|
+
import { useComponentDictionary as w, useI18n as z } from "../../../../i18n/I18n.js";
|
|
14
|
+
import { componentEvents as C } from "../../../../shared/constants.js";
|
|
15
|
+
import { useComponentContext as J } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
16
|
+
import K from "../../../../assets/icons/caret-left.svg.js";
|
|
17
|
+
function ue(s) {
|
|
18
|
+
return /* @__PURE__ */ n(I, { ...s, children: /* @__PURE__ */ n(Q, { ...s, children: s.children }) });
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const S = [
|
|
21
|
+
"child_support",
|
|
22
|
+
"federal_tax_lien",
|
|
23
|
+
"state_tax_lien",
|
|
24
|
+
"student_loan",
|
|
25
|
+
"creditor_garnishment",
|
|
26
|
+
"federal_loan",
|
|
27
|
+
"other_garnishment"
|
|
28
|
+
];
|
|
29
|
+
function Q({ className: s, employeeId: r, deductionId: p, dictionary: y }) {
|
|
30
|
+
const { onEvent: h } = V(), { t } = M("Employee.Deductions"), i = J();
|
|
31
|
+
w("Employee.Deductions", y), z("Employee.Deductions");
|
|
32
|
+
const { data: g } = Y({ employeeId: r }), { data: d } = B({}), o = p ? g.garnishmentList?.find((e) => e.uuid === p) ?? null : null, E = t(o ? "editDeductionTitle" : "addDeductionTitle"), l = o?.garnishmentType, L = d.childSupportData?.agencies?.map((e) => ({
|
|
24
33
|
label: e.name,
|
|
25
34
|
value: e.state
|
|
26
|
-
})) || [], [
|
|
27
|
-
|
|
28
|
-
),
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
})) || [], [f, b] = u(
|
|
36
|
+
l && S.includes(l) || !o
|
|
37
|
+
), [m, x] = u(
|
|
38
|
+
l || "child_support"
|
|
39
|
+
), T = {
|
|
40
|
+
child_support: t("childSupportTitle"),
|
|
41
|
+
federal_tax_lien: t("federalTaxLien"),
|
|
42
|
+
state_tax_lien: t("stateTaxLien"),
|
|
43
|
+
student_loan: t("studentLoan"),
|
|
44
|
+
creditor_garnishment: t("creditorGarnishment"),
|
|
45
|
+
federal_loan: t("federalLoan"),
|
|
46
|
+
other_garnishment: t("otherGarnishment")
|
|
47
|
+
}, D = T[m], G = S.map((e) => ({
|
|
48
|
+
value: e,
|
|
49
|
+
label: T[e]
|
|
50
|
+
})), v = o ? l ? "garnishment" : "custom" : "garnishment", [_, N] = u(o?.childSupport?.state || ""), P = (e) => {
|
|
51
|
+
N(e);
|
|
52
|
+
}, A = d.childSupportData?.agencies?.find((e) => e.state === _)?.fipsCodes?.map((e) => ({
|
|
31
53
|
label: e.county?.length ? e.county : t("allCounties"),
|
|
32
54
|
value: e.code
|
|
33
|
-
})) || [],
|
|
34
|
-
(e) => e.state ===
|
|
35
|
-
),
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
55
|
+
})) || [], O = d.childSupportData?.agencies?.find(
|
|
56
|
+
(e) => e.state === _
|
|
57
|
+
), R = () => {
|
|
58
|
+
g.garnishmentList?.some((e) => e.active) ? h(C.EMPLOYEE_DEDUCTION_CANCEL) : h(C.EMPLOYEE_DEDUCTION_CANCEL_EMPTY);
|
|
59
|
+
}, F = (e) => {
|
|
60
|
+
b(e === "garnishment");
|
|
39
61
|
};
|
|
40
62
|
return /* @__PURE__ */ a("section", { className: s, children: [
|
|
41
|
-
/* @__PURE__ */ a(i.Button, { variant: "secondary", onClick:
|
|
42
|
-
/* @__PURE__ */ n(
|
|
63
|
+
/* @__PURE__ */ a(i.Button, { variant: "secondary", onClick: R, children: [
|
|
64
|
+
/* @__PURE__ */ n(K, { className: c.leftCaretIcon }),
|
|
43
65
|
t("backToDeductionsCta")
|
|
44
66
|
] }),
|
|
45
|
-
/* @__PURE__ */ a(
|
|
46
|
-
/* @__PURE__ */ n(i.Heading, { as: "h2", children:
|
|
67
|
+
/* @__PURE__ */ a(q, { gap: 16, className: c.formHeadingContainer, children: [
|
|
68
|
+
/* @__PURE__ */ n(i.Heading, { as: "h2", children: E }),
|
|
47
69
|
/* @__PURE__ */ a("section", { children: [
|
|
48
70
|
/* @__PURE__ */ n(i.Heading, { as: "h3", children: t("externalPostTaxDeductions") }),
|
|
49
71
|
/* @__PURE__ */ n(i.Text, { variant: "supporting", children: t("externalPostTaxDeductionsDescription") })
|
|
@@ -57,42 +79,53 @@ function k({ className: s, employeeId: r, deductionId: u, dictionary: T }) {
|
|
|
57
79
|
{ value: "garnishment", label: t("garnishmentOption") },
|
|
58
80
|
{ value: "custom", label: t("customDeductionOption") }
|
|
59
81
|
],
|
|
60
|
-
defaultValue:
|
|
61
|
-
onChange:
|
|
82
|
+
defaultValue: v,
|
|
83
|
+
onChange: F,
|
|
62
84
|
isRequired: !0,
|
|
63
85
|
isDisabled: !!o,
|
|
64
86
|
className: c.deductionTypeRadioGroup
|
|
65
87
|
}
|
|
66
88
|
),
|
|
67
|
-
|
|
89
|
+
f && /* @__PURE__ */ a("section", { children: [
|
|
68
90
|
/* @__PURE__ */ n(i.Text, { weight: "bold", className: c.garnishmentTypeLabel, children: t("garnishmentType") }),
|
|
69
91
|
/* @__PURE__ */ n(
|
|
70
92
|
i.Select,
|
|
71
93
|
{
|
|
72
94
|
label: t("garnishmentType"),
|
|
73
|
-
options:
|
|
74
|
-
placeholder:
|
|
95
|
+
options: G,
|
|
96
|
+
placeholder: D,
|
|
75
97
|
shouldVisuallyHideLabel: !0,
|
|
76
|
-
|
|
98
|
+
onChange: (e) => {
|
|
99
|
+
x(e);
|
|
100
|
+
},
|
|
101
|
+
isDisabled: !!o
|
|
77
102
|
}
|
|
78
103
|
)
|
|
79
104
|
] }),
|
|
80
105
|
/* @__PURE__ */ n("hr", {})
|
|
81
106
|
] }),
|
|
82
|
-
|
|
83
|
-
|
|
107
|
+
f ? /* @__PURE__ */ n(H, { children: m === "child_support" ? /* @__PURE__ */ n(
|
|
108
|
+
U,
|
|
84
109
|
{
|
|
85
110
|
deduction: o,
|
|
86
111
|
employeeId: r,
|
|
87
|
-
handleStateAgencySelect:
|
|
88
|
-
stateAgencies:
|
|
89
|
-
counties:
|
|
90
|
-
selectedAgency:
|
|
112
|
+
handleStateAgencySelect: P,
|
|
113
|
+
stateAgencies: L,
|
|
114
|
+
counties: A,
|
|
115
|
+
selectedAgency: O
|
|
91
116
|
}
|
|
92
|
-
) : /* @__PURE__ */ n(
|
|
117
|
+
) : /* @__PURE__ */ n(
|
|
118
|
+
j,
|
|
119
|
+
{
|
|
120
|
+
deduction: o,
|
|
121
|
+
employeeId: r,
|
|
122
|
+
selectedGarnishmentType: m,
|
|
123
|
+
selectedGarnishmentTitle: D
|
|
124
|
+
}
|
|
125
|
+
) }) : /* @__PURE__ */ n(k, { deduction: o, employeeId: r })
|
|
93
126
|
] });
|
|
94
127
|
}
|
|
95
128
|
export {
|
|
96
|
-
|
|
129
|
+
ue as DeductionsForm
|
|
97
130
|
};
|
|
98
131
|
//# sourceMappingURL=DeductionsForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeductionsForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/DeductionsForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useState } from 'react'\nimport { useGarnishmentsListSuspense } from '@gusto/embedded-api/react-query/garnishmentsList'\nimport { useGarnishmentsGetChildSupportDataSuspense } from '@gusto/embedded-api/react-query/garnishmentsGetChildSupportData'\nimport styles from './DeductionsForm.module.scss'\nimport ChildSupportForm from './ChildSupportForm'\nimport CustomDeductionForm from './CustomDeductionForm'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n useBase,\n} from '@/components/Base'\nimport { Grid } from '@/components/Common/Grid/Grid'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport CaretLeft from '@/assets/icons/caret-left.svg?react'\ninterface DeductionsFormProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n deductionId?: string | null\n}\n\nexport function DeductionsForm(props: DeductionsFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\n// deductions can be either custom or a garnishment\n// we currently only support child support garnishment type\nconst SUPPORTED_GARNISHMENT_TYPES = ['child_support']\n\nfunction Root({ className, employeeId, deductionId, dictionary }: DeductionsFormProps) {\n const { onEvent } = useBase()\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n useComponentDictionary('Employee.Deductions', dictionary)\n useI18n('Employee.Deductions')\n\n // Fetch all garnishments to find the specific one by ID\n const { data } = useGarnishmentsListSuspense({ employeeId })\n\n // Fetch child support garnishment metadata\n const { data: childSupportData } = useGarnishmentsGetChildSupportDataSuspense({})\n\n // find existing deduction to determine if in ADD or EDIT mode\n // if deduction exists we are editing, else we are adding\n // edit deductions cannot change the record type, it can only update the existing entries of the record\n const deduction = deductionId\n ? (data.garnishmentList?.find(g => g.uuid === deductionId) ?? null)\n : null\n const title = !deduction ? t('addDeductionTitle') : t('editDeductionTitle')\n const deductionType = deduction?.garnishmentType\n const stateAgencies =\n childSupportData.childSupportData?.agencies?.map(a => ({\n label: a.name as string,\n value: a.state as string,\n })) || []\n\n // if deduction exists check if it has a type, else if does not exist default to garnishment\n const [isGarnishment, setIsGarnishment] = useState<boolean>(\n (deductionType && SUPPORTED_GARNISHMENT_TYPES.includes(deductionType)) || !deduction,\n )\n const defaultDeductionTypeSelection = deduction\n ? deductionType\n ? 'garnishment'\n : 'custom'\n : 'garnishment'\n\n // filter out specific fipsCodes/counties as mapped to selected state agency\n // some states only have 1 fips code/county to cover the entire state,\n // but the API will return a null label so we need to provide a default label\n const [stateAgency, setStateAgency] = useState<string>(deduction?.childSupport?.state || '')\n const handleStateAgencySelect = (stateAgency: string) => {\n setStateAgency(stateAgency)\n }\n const counties =\n childSupportData.childSupportData?.agencies\n ?.find(agency => agency.state === stateAgency)\n ?.fipsCodes?.map(fipsCode => ({\n label: fipsCode.county?.length ? fipsCode.county : t('allCounties'),\n value: fipsCode.code as string,\n })) || []\n\n // get a reference to the currently selected agency to determine which required fields to display/include in submission\n const selectedAgency = childSupportData.childSupportData?.agencies?.find(\n agency => agency.state === stateAgency,\n )\n\n const handleCancel = () => {\n // if any active garnishments return to list view, else return to empty state view\n if (data.garnishmentList?.some(g => g.active)) {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CANCEL)\n } else {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CANCEL_EMPTY)\n }\n }\n\n const handleSelectDeductionType = (selection: string) => {\n setIsGarnishment(selection === 'garnishment')\n }\n\n return (\n <section className={className}>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n <CaretLeft className={styles.leftCaretIcon} />\n {t('backToDeductionsCta')}\n </Components.Button>\n <Grid gap={16} className={styles.formHeadingContainer}>\n <Components.Heading as=\"h2\">{title}</Components.Heading>\n <section>\n <Components.Heading as=\"h3\">{t('externalPostTaxDeductions')}</Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('externalPostTaxDeductionsDescription')}\n </Components.Text>\n </section>\n <Components.RadioGroup\n label={t('deductionTypeLabel')}\n description={t('deductionTypeRadioLabel')}\n options={[\n { value: 'garnishment', label: t('garnishmentOption') },\n { value: 'custom', label: t('customDeductionOption') },\n ]}\n defaultValue={defaultDeductionTypeSelection}\n onChange={handleSelectDeductionType}\n isRequired\n isDisabled={!!deduction}\n className={styles.deductionTypeRadioGroup}\n />\n {isGarnishment && (\n <section>\n <Components.Text weight=\"bold\" className={styles.garnishmentTypeLabel}>\n {t('garnishmentType')}\n </Components.Text>\n {/* we currently only support child support garnishment type */}\n <Components.Select\n label={t('garnishmentType')}\n options={[]}\n placeholder={t('childSupport')}\n shouldVisuallyHideLabel\n isDisabled\n />\n </section>\n )}\n <hr />\n </Grid>\n\n {isGarnishment ? (\n <ChildSupportForm\n deduction={deduction}\n employeeId={employeeId}\n handleStateAgencySelect={handleStateAgencySelect}\n stateAgencies={stateAgencies}\n counties={counties}\n selectedAgency={selectedAgency}\n />\n ) : (\n <CustomDeductionForm deduction={deduction} employeeId={employeeId} />\n )}\n </section>\n )\n}\n"],"names":["DeductionsForm","props","jsx","BaseComponent","Root","SUPPORTED_GARNISHMENT_TYPES","className","employeeId","deductionId","dictionary","onEvent","useBase","useTranslation","Components","useComponentContext","useComponentDictionary","useI18n","data","useGarnishmentsListSuspense","childSupportData","useGarnishmentsGetChildSupportDataSuspense","deduction","g","title","deductionType","stateAgencies","a","isGarnishment","setIsGarnishment","useState","defaultDeductionTypeSelection","stateAgency","setStateAgency","handleStateAgencySelect","counties","agency","fipsCode","selectedAgency","handleCancel","componentEvents","handleSelectDeductionType","selection","jsxs","CaretLeft","styles","Grid","ChildSupportForm","CustomDeductionForm"],"mappings":";;;;;;;;;;;;;;;AAwBO,SAASA,GAAeC,GAAqD;AAClF,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAIA,MAAMI,IAA8B,CAAC,eAAe;AAEpD,SAASD,EAAK,EAAE,WAAAE,GAAW,YAAAC,GAAY,aAAAC,GAAa,YAAAC,KAAmC;AACrF,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA,GACd,EAAE,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA;AAEnB,EAAAC,EAAuB,uBAAuBN,CAAU,GACxDO,EAAQ,qBAAqB;AAG7B,QAAM,EAAE,MAAAC,EAAA,IAASC,EAA4B,EAAE,YAAAX,GAAY,GAGrD,EAAE,MAAMY,MAA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AU;AAAA,UAAA;AAAA,QAAA;AAAA,MACZ,GACF;AAAA,wBAED,MAAA,CAAA,CAAG;AAAA,IAAA,GACN;AAAA,IAECc,IACC,gBAAAzB;AAAA,MAAC4C;AAAA,MAAA;AAAA,QACC,WAAAzB;AAAA,QACA,YAAAd;AAAA,QACA,yBAAA0B;AAAA,QACA,eAAAR;AAAA,QACA,UAAAS;AAAA,QACA,gBAAAG;AAAA,MAAA;AAAA,IAAA,IAGF,gBAAAnC,EAAC6C,GAAA,EAAoB,WAAA1B,GAAsB,YAAAd,EAAA,CAAwB;AAAA,EAAA,GAEvE;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"DeductionsForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/DeductionsForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useState } from 'react'\nimport { useGarnishmentsListSuspense } from '@gusto/embedded-api/react-query/garnishmentsList'\nimport { useGarnishmentsGetChildSupportDataSuspense } from '@gusto/embedded-api/react-query/garnishmentsGetChildSupportData'\nimport type { GarnishmentType } from '@gusto/embedded-api/models/operations/postv1employeesemployeeidgarnishments'\nimport styles from './DeductionsForm.module.scss'\nimport ChildSupportForm from './ChildSupportForm'\nimport GarnishmentForm from './GarnishmentForm'\nimport CustomDeductionForm from './CustomDeductionForm'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n useBase,\n} from '@/components/Base'\nimport { Grid } from '@/components/Common/Grid/Grid'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport CaretLeft from '@/assets/icons/caret-left.svg?react'\n\ninterface DeductionsFormProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n deductionId?: string | null\n}\n\nexport function DeductionsForm(props: DeductionsFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\n// deductions can be either garnishment (court-ordered) or a custom deduction\nconst SUPPORTED_GARNISHMENT_TYPES: 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]\n\nfunction Root({ className, employeeId, deductionId, dictionary }: DeductionsFormProps) {\n const { onEvent } = useBase()\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n useComponentDictionary('Employee.Deductions', dictionary)\n useI18n('Employee.Deductions')\n\n // Fetch all garnishments to find the specific one by ID\n const { data } = useGarnishmentsListSuspense({ employeeId })\n\n // Fetch child support garnishment metadata\n const { data: childSupportData } = useGarnishmentsGetChildSupportDataSuspense({})\n\n // find existing deduction to determine if in ADD or EDIT mode\n // if deduction exists we are editing, else we are adding\n const deduction = deductionId\n ? (data.garnishmentList?.find(g => g.uuid === deductionId) ?? null)\n : null\n const title = !deduction ? t('addDeductionTitle') : t('editDeductionTitle')\n const deductionType = deduction?.garnishmentType\n const stateAgencies =\n childSupportData.childSupportData?.agencies?.map(a => ({\n label: a.name as string,\n value: a.state as string,\n })) || []\n\n // if deduction exists check if it has a type, else if does not exist default to garnishment\n const [isGarnishment, setIsGarnishment] = useState<boolean>(\n (deductionType && SUPPORTED_GARNISHMENT_TYPES.includes(deductionType)) || !deduction,\n )\n const [selectedGarnishment, setSelectedGarnishment] = useState<GarnishmentType>(\n deductionType || 'child_support',\n )\n const garnishmentLabels: Record<string, string> = {\n child_support: t('childSupportTitle'),\n federal_tax_lien: t('federalTaxLien'),\n state_tax_lien: t('stateTaxLien'),\n student_loan: t('studentLoan'),\n creditor_garnishment: t('creditorGarnishment'),\n federal_loan: t('federalLoan'),\n other_garnishment: t('otherGarnishment'),\n }\n const garnishmentPlaceholder = garnishmentLabels[selectedGarnishment]\n const garnishmentOptions = SUPPORTED_GARNISHMENT_TYPES.map(garnishment => ({\n value: garnishment,\n label: garnishmentLabels[garnishment] as string,\n }))\n\n const defaultDeductionTypeSelection = deduction\n ? deductionType\n ? 'garnishment'\n : 'custom'\n : 'garnishment'\n\n // filter out specific fipsCodes/counties as mapped to selected state agency\n // some states only have 1 fips code/county to cover the entire state,\n // but the API will return a null label so we need to provide a default label\n const [stateAgency, setStateAgency] = useState<string>(deduction?.childSupport?.state || '')\n const handleStateAgencySelect = (stateAgency: string) => {\n setStateAgency(stateAgency)\n }\n const counties =\n childSupportData.childSupportData?.agencies\n ?.find(agency => agency.state === stateAgency)\n ?.fipsCodes?.map(fipsCode => ({\n label: fipsCode.county?.length ? fipsCode.county : t('allCounties'),\n value: fipsCode.code as string,\n })) || []\n\n // get a reference to the currently selected agency to determine which required fields to display/include in submission\n const selectedAgency = childSupportData.childSupportData?.agencies?.find(\n agency => agency.state === stateAgency,\n )\n\n const handleCancel = () => {\n // if any active garnishments return to list view, else return to empty state view\n if (data.garnishmentList?.some(g => g.active)) {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CANCEL)\n } else {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CANCEL_EMPTY)\n }\n }\n\n const handleSelectDeductionType = (selection: string) => {\n setIsGarnishment(selection === 'garnishment')\n }\n\n return (\n <section className={className}>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n <CaretLeft className={styles.leftCaretIcon} />\n {t('backToDeductionsCta')}\n </Components.Button>\n <Grid gap={16} className={styles.formHeadingContainer}>\n <Components.Heading as=\"h2\">{title}</Components.Heading>\n <section>\n <Components.Heading as=\"h3\">{t('externalPostTaxDeductions')}</Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('externalPostTaxDeductionsDescription')}\n </Components.Text>\n </section>\n <Components.RadioGroup\n label={t('deductionTypeLabel')}\n description={t('deductionTypeRadioLabel')}\n options={[\n { value: 'garnishment', label: t('garnishmentOption') },\n { value: 'custom', label: t('customDeductionOption') },\n ]}\n defaultValue={defaultDeductionTypeSelection}\n onChange={handleSelectDeductionType}\n isRequired\n isDisabled={!!deduction}\n className={styles.deductionTypeRadioGroup}\n />\n {isGarnishment && (\n <section>\n <Components.Text weight=\"bold\" className={styles.garnishmentTypeLabel}>\n {t('garnishmentType')}\n </Components.Text>\n <Components.Select\n label={t('garnishmentType')}\n options={garnishmentOptions}\n placeholder={garnishmentPlaceholder}\n shouldVisuallyHideLabel\n onChange={value => {\n setSelectedGarnishment(value as GarnishmentType)\n }}\n isDisabled={!!deduction} // API does not allow to change/edit an existing deduction type\n />\n </section>\n )}\n <hr />\n </Grid>\n\n {isGarnishment ? (\n <>\n {selectedGarnishment === 'child_support' ? (\n <ChildSupportForm\n deduction={deduction}\n employeeId={employeeId}\n handleStateAgencySelect={handleStateAgencySelect}\n stateAgencies={stateAgencies}\n counties={counties}\n selectedAgency={selectedAgency}\n />\n ) : (\n <GarnishmentForm\n deduction={deduction}\n employeeId={employeeId}\n selectedGarnishmentType={selectedGarnishment}\n selectedGarnishmentTitle={garnishmentPlaceholder!}\n />\n )}\n </>\n ) : (\n <CustomDeductionForm deduction={deduction} employeeId={employeeId} />\n )}\n </section>\n )\n}\n"],"names":["DeductionsForm","props","jsx","BaseComponent","Root","SUPPORTED_GARNISHMENT_TYPES","className","employeeId","deductionId","dictionary","onEvent","useBase","useTranslation","Components","useComponentContext","useComponentDictionary","useI18n","data","useGarnishmentsListSuspense","childSupportData","useGarnishmentsGetChildSupportDataSuspense","deduction","g","title","deductionType","stateAgencies","a","isGarnishment","setIsGarnishment","useState","selectedGarnishment","setSelectedGarnishment","garnishmentLabels","garnishmentPlaceholder","garnishmentOptions","garnishment","defaultDeductionTypeSelection","stateAgency","setStateAgency","handleStateAgencySelect","counties","agency","fipsCode","selectedAgency","handleCancel","componentEvents","handleSelectDeductionType","selection","jsxs","CaretLeft","styles","Grid","value","Fragment","ChildSupportForm","GarnishmentForm","CustomDeductionForm"],"mappings":";;;;;;;;;;;;;;;;AA2BO,SAASA,GAAeC,GAAqD;AAClF,SACE,gBAAAC,EAACC,GAAA,E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AAvB,MAAwB,kBACvB,gBAAA5B;AAAA,MAACoD;AAAA,MAAA;AAAA,QACC,WAAAjC;AAAA,QACA,YAAAd;AAAA,QACA,yBAAAgC;AAAA,QACA,eAAAd;AAAA,QACA,UAAAe;AAAA,QACA,gBAAAG;AAAA,MAAA;AAAA,IAAA,IAGF,gBAAAzC;AAAA,MAACqD;AAAA,MAAA;AAAA,QACC,WAAAlC;AAAA,QACA,YAAAd;AAAA,QACA,yBAAyBuB;AAAA,QACzB,0BAA0BG;AAAA,MAAA;AAAA,IAAA,EAC5B,CAEJ,IAEA,gBAAA/B,EAACsD,GAAA,EAAoB,WAAAnC,GAAsB,YAAAd,EAAA,CAAwB;AAAA,EAAA,GAEvE;AAEJ;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Garnishment } from '@gusto/embedded-api/models/components/garnishment';
|
|
3
|
+
import { GarnishmentType } from '@gusto/embedded-api/models/operations/postv1employeesemployeeidgarnishments';
|
|
4
|
+
import { CommonComponentInterface } from '../../../Base';
|
|
5
|
+
export declare const DeductionSchema: z.ZodObject<{
|
|
6
|
+
active: z.ZodBoolean;
|
|
7
|
+
amount: z.ZodEffects<z.ZodNumber, string, number>;
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
courtOrdered: z.ZodBoolean;
|
|
10
|
+
times: z.ZodNullable<z.ZodNumber>;
|
|
11
|
+
recurring: z.ZodBoolean;
|
|
12
|
+
annualMaximum: z.ZodNullable<z.ZodEffects<z.ZodNumber, string | null, number>>;
|
|
13
|
+
totalAmount: z.ZodNullable<z.ZodEffects<z.ZodNumber, string | null, number>>;
|
|
14
|
+
deductAsPercentage: z.ZodBoolean;
|
|
15
|
+
garnishmentType: z.ZodNativeEnum<{
|
|
16
|
+
readonly ChildSupport: "child_support";
|
|
17
|
+
readonly FederalTaxLien: "federal_tax_lien";
|
|
18
|
+
readonly StateTaxLien: "state_tax_lien";
|
|
19
|
+
readonly StudentLoan: "student_loan";
|
|
20
|
+
readonly CreditorGarnishment: "creditor_garnishment";
|
|
21
|
+
readonly FederalLoan: "federal_loan";
|
|
22
|
+
readonly OtherGarnishment: "other_garnishment";
|
|
23
|
+
}>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
description: string;
|
|
26
|
+
active: boolean;
|
|
27
|
+
totalAmount: string | null;
|
|
28
|
+
amount: string;
|
|
29
|
+
garnishmentType: "child_support" | "federal_tax_lien" | "state_tax_lien" | "student_loan" | "creditor_garnishment" | "federal_loan" | "other_garnishment";
|
|
30
|
+
recurring: boolean;
|
|
31
|
+
courtOrdered: boolean;
|
|
32
|
+
times: number | null;
|
|
33
|
+
annualMaximum: string | null;
|
|
34
|
+
deductAsPercentage: boolean;
|
|
35
|
+
}, {
|
|
36
|
+
description: string;
|
|
37
|
+
active: boolean;
|
|
38
|
+
totalAmount: number | null;
|
|
39
|
+
amount: number;
|
|
40
|
+
garnishmentType: "child_support" | "federal_tax_lien" | "state_tax_lien" | "student_loan" | "creditor_garnishment" | "federal_loan" | "other_garnishment";
|
|
41
|
+
recurring: boolean;
|
|
42
|
+
courtOrdered: boolean;
|
|
43
|
+
times: number | null;
|
|
44
|
+
annualMaximum: number | null;
|
|
45
|
+
deductAsPercentage: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
export type DeductionInputs = z.input<typeof DeductionSchema>;
|
|
48
|
+
export type DeductionPayload = z.output<typeof DeductionSchema>;
|
|
49
|
+
interface GarnishmentFormProps extends CommonComponentInterface<'Employee.Deductions'> {
|
|
50
|
+
employeeId: string;
|
|
51
|
+
deduction?: Garnishment | null;
|
|
52
|
+
selectedGarnishmentType: GarnishmentType;
|
|
53
|
+
selectedGarnishmentTitle: string;
|
|
54
|
+
}
|
|
55
|
+
declare function GarnishmentForm({ deduction, employeeId, selectedGarnishmentType, selectedGarnishmentTitle, }: GarnishmentFormProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export default GarnishmentForm;
|