@gusto/embedded-react-sdk 0.34.0 → 0.35.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 +38 -0
- package/dist/components/Base/Base.d.ts +6 -2
- package/dist/components/Base/Base.js +105 -59
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/useBase.d.ts +1 -0
- package/dist/components/Base/useBase.js.map +1 -1
- package/dist/components/Base/useBaseSubmit.d.ts +1 -1
- package/dist/components/Base/useBaseSubmit.js +60 -33
- package/dist/components/Base/useBaseSubmit.js.map +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.js +15 -13
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.js.map +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenuTypes.d.ts +1 -0
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +1 -1
- package/dist/components/Common/UI/Menu/Menu.js +26 -25
- package/dist/components/Common/UI/Menu/Menu.js.map +1 -1
- package/dist/components/Common/UI/Menu/Menu.module.scss.js +7 -7
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +5 -0
- package/dist/components/Common/UI/Menu/MenuTypes.js +4 -3
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/Table/Table.module.scss.js +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +12 -12
- 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/InviteSignatoryForm.js +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/Form.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +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/Form.js +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/Form.js +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/_parts/Edit.js +15 -15
- 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/Contractor/Address/Form.js +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/PaymentMethod/BankAccountForm.js +2 -2
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +119 -113
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +10 -10
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
- package/dist/components/Employee/Compensation/Edit.js +70 -70
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +9 -10
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +10 -11
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +10 -11
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
- 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/EmploymentEligibility/EmploymentEligibilityPresentation.js +18 -18
- package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.js +7 -7
- package/dist/components/Employee/DocumentSigner/SignatureForm/Form.js +5 -5
- package/dist/components/Employee/DocumentSigner/SignatureForm/Form.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/Preview.js +8 -8
- package/dist/components/Employee/DocumentSigner/SignatureForm/Preview.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.js +7 -7
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +3 -4
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +2 -2
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +8 -8
- 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.js +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +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/StateTaxes.js +69 -61
- package/dist/components/Employee/StateTaxes/StateTaxes.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.js +7 -7
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js +10 -10
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +9 -9
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.d.ts +2 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +101 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js +16 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js.map +1 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModalTypes.d.ts +7 -0
- package/dist/components/Payroll/GrossUpModal/index.d.ts +3 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +86 -67
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +83 -49
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +6 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +102 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.module.scss.js +14 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js +52 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js +16 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.d.ts +12 -2
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js +15 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/index.d.ts +2 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +212 -120
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +3 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +76 -64
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.d.ts +2 -0
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js +11 -0
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js.map +1 -0
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +67 -57
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +36 -36
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +6 -6
- package/dist/components/Payroll/usePreparedPayrollData.js +44 -44
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +2 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +58 -39
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.js +6 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.d.ts +7 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.js +11 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/index.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js +45 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/sanitization.d.ts +19 -0
- package/dist/contexts/ObservabilityProvider/sanitization.js +95 -0
- package/dist/contexts/ObservabilityProvider/sanitization.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/sanitization.test.d.ts +1 -0
- package/dist/contexts/ObservabilityProvider/useObservability.d.ts +2 -0
- package/dist/contexts/ObservabilityProvider/useObservability.js +11 -0
- package/dist/contexts/ObservabilityProvider/useObservability.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.d.ts +8 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js +28 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js.map +1 -0
- package/dist/contexts/index.d.ts +2 -0
- package/dist/helpers/formattedStrings.js +12 -13
- package/dist/helpers/formattedStrings.js.map +1 -1
- package/dist/helpers/rem.d.ts +7 -3
- package/dist/helpers/rem.js +14 -10
- package/dist/helpers/rem.js.map +1 -1
- package/dist/helpers/rem.test.d.ts +1 -0
- package/dist/helpers/retryAsync.d.ts +7 -0
- package/dist/helpers/retryAsync.js +18 -0
- package/dist/helpers/retryAsync.js.map +1 -0
- package/dist/i18n/I18n.js +15 -15
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.PaySchedule.json.js +1 -1
- package/dist/i18n/en/Payroll.GrossUpModal.json.js +24 -0
- package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -0
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js +13 -11
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -13
- package/dist/index.js.map +1 -1
- package/dist/shared/constants.d.ts +5 -0
- package/dist/shared/constants.js +11 -8
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +26 -1
- package/dist/types/observability.d.ts +145 -0
- package/docs/reference/endpoint-inventory.json +10 -1
- package/package.json +21 -21
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useFormContext as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { useCompensation as
|
|
6
|
-
import { FlsaStatus as a, PAY_PERIODS as r, FLSA_OVERTIME_SALARY_LIMIT as N } from "../../../shared/constants.js";
|
|
7
|
-
import
|
|
1
|
+
import { jsxs as O, Fragment as b, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as P, useEffect as U } from "react";
|
|
3
|
+
import { useFormContext as k, useWatch as E } from "react-hook-form";
|
|
4
|
+
import { useTranslation as R, Trans as S } from "react-i18next";
|
|
5
|
+
import { useCompensation as Y, rateMinimumError as j, rateExemptThresholdError as w } from "./useCompensation.js";
|
|
6
|
+
import { FlsaStatus as a, PAY_PERIODS as r, TIP_CREDITS_UNSUPPORTED_STATES as x, FLSA_OVERTIME_SALARY_LIMIT as N } from "../../../shared/constants.js";
|
|
7
|
+
import X from "../../../hooks/useNumberFormatter.js";
|
|
8
8
|
import "classnames";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { ComboBoxField as
|
|
18
|
-
const
|
|
19
|
-
const { t: e } =
|
|
20
|
-
() =>
|
|
9
|
+
import { useComponentContext as B } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
|
+
import { WA_RISK_CLASS_CODES as J } from "../../../models/WA_RISK_CODES.js";
|
|
11
|
+
import { TextInputField as $ } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
12
|
+
import { SelectField as f } from "../../Common/Fields/SelectField/SelectField.js";
|
|
13
|
+
import { NumberInputField as K } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
14
|
+
import { SwitchField as q } from "../../Common/Fields/SwitchField/SwitchField.js";
|
|
15
|
+
import { CheckboxField as H } from "../../Common/Fields/CheckboxField/CheckboxField.js";
|
|
16
|
+
import { RadioGroupField as V } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
17
|
+
import { ComboBoxField as G } from "../../Common/Fields/ComboBoxField/ComboBoxField.js";
|
|
18
|
+
const Oe = () => {
|
|
19
|
+
const { t: e } = R("Employee.Compensation"), l = X("currency"), C = B(), _ = P(
|
|
20
|
+
() => J.map(({ code: o, description: F }) => ({
|
|
21
21
|
value: o,
|
|
22
|
-
label: `${o}: ${
|
|
22
|
+
label: `${o}: ${F}`
|
|
23
23
|
})),
|
|
24
24
|
[]
|
|
25
25
|
), {
|
|
26
|
-
control:
|
|
27
|
-
register:
|
|
26
|
+
control: m,
|
|
27
|
+
register: T,
|
|
28
28
|
setValue: s,
|
|
29
|
-
formState: { errors:
|
|
30
|
-
} =
|
|
31
|
-
if (
|
|
32
|
-
i === a.OWNER ? s("paymentUnit", "Paycheck") : i === a.COMMISSION_ONLY_NONEXEMPT || i === a.COMMISSION_ONLY_EXEMPT ? (s("paymentUnit", "Year"), s("rate", 0)) :
|
|
33
|
-
}, [i, s,
|
|
29
|
+
formState: { errors: M, defaultValues: p }
|
|
30
|
+
} = k(), i = E({ control: m, name: "flsaStatus" }), h = E({ control: m, name: "stateWcCovered" }), W = E({ control: m, name: "adjustForMinimumWage" }), { currentJob: y, mode: n, minimumWages: I, handleFlsaChange: v, state: c, showTwoPercentStakeholder: L } = Y();
|
|
31
|
+
if (U(() => {
|
|
32
|
+
i === a.OWNER ? s("paymentUnit", "Paycheck") : i === a.COMMISSION_ONLY_NONEXEMPT || i === a.COMMISSION_ONLY_EXEMPT ? (s("paymentUnit", "Year"), s("rate", 0)) : p?.paymentUnit && s("paymentUnit", p.paymentUnit);
|
|
33
|
+
}, [i, s, p?.paymentUnit]), !(n === "ADD_INITIAL_JOB" || n === "ADD_ADDITIONAL_JOB" || n === "EDIT_INITIAL_JOB" || n === "EDIT_ADDITIONAL_JOB"))
|
|
34
34
|
return;
|
|
35
|
-
const
|
|
35
|
+
const g = Object.keys(a).map(
|
|
36
36
|
(o) => ({
|
|
37
37
|
value: a[o],
|
|
38
38
|
label: e(`flsaStatusLabels.${a[o]}`)
|
|
39
39
|
})
|
|
40
|
-
),
|
|
40
|
+
), D = [
|
|
41
41
|
{ value: r.HOUR, label: e("paymentUnitOptions.Hour") },
|
|
42
42
|
{ value: r.WEEK, label: e("paymentUnitOptions.Week") },
|
|
43
43
|
{ value: r.MONTH, label: e("paymentUnitOptions.Month") },
|
|
44
44
|
{ value: r.YEAR, label: e("paymentUnitOptions.Year") },
|
|
45
45
|
{ value: r.PAYCHECK, label: e("paymentUnitOptions.Paycheck") }
|
|
46
|
-
],
|
|
47
|
-
let
|
|
48
|
-
return
|
|
46
|
+
], u = i !== a.NONEXEMPT || y?.primary || n === "ADD_INITIAL_JOB", A = i === a.NONEXEMPT && I.length > 0 && c !== void 0 && !x.includes(c);
|
|
47
|
+
let d = e("validations.rate");
|
|
48
|
+
return M.rate?.message === j ? d = e("validations.nonZeroRate") : M.rate?.message === w && (d = e("validations.rateExemptThreshold", {
|
|
49
49
|
limit: l(N)
|
|
50
|
-
})), /* @__PURE__ */
|
|
50
|
+
})), /* @__PURE__ */ O(b, { children: [
|
|
51
51
|
/* @__PURE__ */ t(
|
|
52
|
-
|
|
52
|
+
$,
|
|
53
53
|
{
|
|
54
54
|
name: "jobTitle",
|
|
55
55
|
label: e("jobTitle"),
|
|
@@ -57,59 +57,71 @@ const ue = () => {
|
|
|
57
57
|
errorMessage: e("validations.title")
|
|
58
58
|
}
|
|
59
59
|
),
|
|
60
|
-
!
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
!u && /* @__PURE__ */ t("input", { type: "hidden", ...T("flsaStatus") }),
|
|
61
|
+
u && /* @__PURE__ */ t(
|
|
62
|
+
f,
|
|
63
63
|
{
|
|
64
64
|
name: "flsaStatus",
|
|
65
65
|
label: e("employeeClassification"),
|
|
66
66
|
description: /* @__PURE__ */ t(
|
|
67
|
-
|
|
67
|
+
S,
|
|
68
68
|
{
|
|
69
69
|
t: e,
|
|
70
70
|
i18nKey: "classificationLink",
|
|
71
71
|
components: {
|
|
72
|
-
ClassificationLink: /* @__PURE__ */ t(
|
|
72
|
+
ClassificationLink: /* @__PURE__ */ t(C.Link, {})
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
76
|
errorMessage: e("validations.exemptThreshold", {
|
|
77
77
|
limit: l(N)
|
|
78
78
|
}),
|
|
79
|
-
options:
|
|
79
|
+
options: g,
|
|
80
80
|
isRequired: !0,
|
|
81
|
-
isDisabled: !
|
|
82
|
-
onChange:
|
|
81
|
+
isDisabled: !u,
|
|
82
|
+
onChange: v
|
|
83
83
|
}
|
|
84
84
|
),
|
|
85
85
|
/* @__PURE__ */ t(
|
|
86
|
-
|
|
86
|
+
K,
|
|
87
87
|
{
|
|
88
88
|
name: "rate",
|
|
89
89
|
label: e("amount"),
|
|
90
90
|
format: "currency",
|
|
91
91
|
min: 0,
|
|
92
|
-
errorMessage:
|
|
92
|
+
errorMessage: d,
|
|
93
93
|
isRequired: !0,
|
|
94
94
|
isDisabled: i === a.COMMISSION_ONLY_NONEXEMPT || i === a.COMMISSION_ONLY_EXEMPT
|
|
95
95
|
}
|
|
96
96
|
),
|
|
97
|
-
|
|
97
|
+
/* @__PURE__ */ t(
|
|
98
|
+
f,
|
|
99
|
+
{
|
|
100
|
+
name: "paymentUnit",
|
|
101
|
+
label: e("paymentUnitLabel"),
|
|
102
|
+
description: e("paymentUnitDescription"),
|
|
103
|
+
options: D,
|
|
104
|
+
errorMessage: e("validations.paymentUnit"),
|
|
105
|
+
isRequired: !0,
|
|
106
|
+
isDisabled: i === a.OWNER || i === a.COMMISSION_ONLY_NONEXEMPT || i === a.COMMISSION_ONLY_EXEMPT
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
A && /* @__PURE__ */ O(b, { children: [
|
|
98
110
|
/* @__PURE__ */ t(
|
|
99
|
-
|
|
111
|
+
q,
|
|
100
112
|
{
|
|
101
113
|
name: "adjustForMinimumWage",
|
|
102
114
|
label: e("adjustForMinimumWage"),
|
|
103
115
|
description: e("adjustForMinimumWageDescription")
|
|
104
116
|
}
|
|
105
117
|
),
|
|
106
|
-
/* @__PURE__ */ t(
|
|
107
|
-
|
|
118
|
+
W && /* @__PURE__ */ t(
|
|
119
|
+
f,
|
|
108
120
|
{
|
|
109
121
|
name: "minimumWageId",
|
|
110
122
|
label: e("minimumWageLabel"),
|
|
111
123
|
description: e("minimumWageDescription"),
|
|
112
|
-
options:
|
|
124
|
+
options: I.map((o) => ({
|
|
113
125
|
value: o.uuid,
|
|
114
126
|
label: `${l(Number(o.wage))} - ${o.authority}: ${o.notes ?? ""}`
|
|
115
127
|
})),
|
|
@@ -117,33 +129,21 @@ const ue = () => {
|
|
|
117
129
|
}
|
|
118
130
|
)
|
|
119
131
|
] }),
|
|
120
|
-
/* @__PURE__ */ t(
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
name: "paymentUnit",
|
|
124
|
-
label: e("paymentUnitLabel"),
|
|
125
|
-
description: e("paymentUnitDescription"),
|
|
126
|
-
options: g,
|
|
127
|
-
errorMessage: e("validations.paymentUnit"),
|
|
128
|
-
isRequired: !0,
|
|
129
|
-
isDisabled: i === a.OWNER || i === a.COMMISSION_ONLY_NONEXEMPT || i === a.COMMISSION_ONLY_EXEMPT
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
T && /* @__PURE__ */ t(q, { label: e("twoPercentStakeholderLabel"), name: "twoPercentShareholder" }),
|
|
133
|
-
L === "WA" && /* @__PURE__ */ u(d, { children: [
|
|
132
|
+
L && /* @__PURE__ */ t(H, { label: e("twoPercentStakeholderLabel"), name: "twoPercentShareholder" }),
|
|
133
|
+
c === "WA" && /* @__PURE__ */ O(b, { children: [
|
|
134
134
|
/* @__PURE__ */ t(
|
|
135
|
-
|
|
135
|
+
V,
|
|
136
136
|
{
|
|
137
137
|
name: "stateWcCovered",
|
|
138
138
|
label: e("stateWcCoveredLabel"),
|
|
139
139
|
description: /* @__PURE__ */ t(
|
|
140
|
-
|
|
140
|
+
S,
|
|
141
141
|
{
|
|
142
142
|
t: e,
|
|
143
143
|
i18nKey: "stateWcCoveredDescription",
|
|
144
144
|
components: {
|
|
145
145
|
wcLink: /* @__PURE__ */ t(
|
|
146
|
-
|
|
146
|
+
C.Link,
|
|
147
147
|
{
|
|
148
148
|
href: "https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/",
|
|
149
149
|
target: "_blank",
|
|
@@ -159,12 +159,12 @@ const ue = () => {
|
|
|
159
159
|
]
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
h && /* @__PURE__ */ t(
|
|
163
|
+
G,
|
|
164
164
|
{
|
|
165
165
|
name: "stateWcClassCode",
|
|
166
166
|
label: e("stateWcClassCodeLabel"),
|
|
167
|
-
options:
|
|
167
|
+
options: _,
|
|
168
168
|
errorMessage: e("validations.stateWcClassCode"),
|
|
169
169
|
placeholder: e("stateWcClassCodeLabel"),
|
|
170
170
|
description: e("stateWcClassCodeDescription")
|
|
@@ -174,6 +174,6 @@ const ue = () => {
|
|
|
174
174
|
] });
|
|
175
175
|
};
|
|
176
176
|
export {
|
|
177
|
-
|
|
177
|
+
Oe as Edit
|
|
178
178
|
};
|
|
179
179
|
//# sourceMappingURL=Edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Edit.js","sources":["../../../../src/components/Employee/Compensation/Edit.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react'\nimport { useFormContext, useWatch } from 'react-hook-form'\nimport { Trans, useTranslation } from 'react-i18next'\nimport {\n type CompensationInputs,\n useCompensation,\n rateMinimumError,\n rateExemptThresholdError,\n} from './useCompensation'\nimport { FLSA_OVERTIME_SALARY_LIMIT, FlsaStatus, PAY_PERIODS } from '@/shared/constants'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\nimport {\n NumberInputField,\n SelectField,\n TextInputField,\n SwitchField,\n RadioGroupField,\n ComboBoxField,\n CheckboxField,\n} from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { WA_RISK_CLASS_CODES } from '@/models/WA_RISK_CODES'\n\nexport interface SelectCategory {\n id: string\n name: string\n}\n\nexport const Edit = () => {\n const { t } = useTranslation('Employee.Compensation')\n const format = useNumberFormatter('currency')\n const Components = useComponentContext()\n\n const stateWcRiskOptions = useMemo(\n () =>\n WA_RISK_CLASS_CODES.map(({ code, description }) => ({\n value: code,\n label: `${code}: ${description}`,\n })),\n [],\n )\n\n const {\n control,\n register,\n setValue,\n formState: { errors, defaultValues },\n } = useFormContext<CompensationInputs>()\n\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedStateWcCovered = useWatch({ control, name: 'stateWcCovered' })\n const { currentJob, mode, minimumWages, handleFlsaChange, state, showTwoPercentStakeholder } =\n useCompensation()\n\n /**Correctly set payment unit selected option and rate based on flsa status, falling back to default */\n useEffect(() => {\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', 'Paycheck')\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', 'Year')\n setValue('rate', 0)\n } else if (defaultValues?.paymentUnit) {\n setValue('paymentUnit', defaultValues.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, defaultValues?.paymentUnit])\n\n if (\n !(\n mode === 'ADD_INITIAL_JOB' ||\n mode === 'ADD_ADDITIONAL_JOB' ||\n mode === 'EDIT_INITIAL_JOB' ||\n mode === 'EDIT_ADDITIONAL_JOB'\n )\n )\n return\n\n const classificationOptions = (Object.keys(FlsaStatus) as Array<keyof typeof FlsaStatus>).map(\n key => ({\n value: FlsaStatus[key],\n label: t(`flsaStatusLabels.${FlsaStatus[key]}`),\n }),\n )\n\n const paymentUnitOptions = [\n { value: PAY_PERIODS.HOUR, label: t('paymentUnitOptions.Hour') },\n { value: PAY_PERIODS.WEEK, label: t('paymentUnitOptions.Week') },\n { value: PAY_PERIODS.MONTH, label: t('paymentUnitOptions.Month') },\n { value: PAY_PERIODS.YEAR, label: t('paymentUnitOptions.Year') },\n { value: PAY_PERIODS.PAYCHECK, label: t('paymentUnitOptions.Paycheck') },\n ]\n\n const isFlsaSelectionEnabled =\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary || mode === 'ADD_INITIAL_JOB'\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT && minimumWages.length > 0\n\n let rateErrorMessage = t('validations.rate')\n if (errors.rate?.message === rateMinimumError) {\n rateErrorMessage = t('validations.nonZeroRate')\n } else if (errors.rate?.message === rateExemptThresholdError) {\n rateErrorMessage = t('validations.rateExemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n })\n }\n\n return (\n <>\n <TextInputField\n name=\"jobTitle\"\n label={t('jobTitle')}\n isRequired\n errorMessage={t('validations.title')}\n />\n {/* hiding flsa selection for secondary jobs */}\n {!isFlsaSelectionEnabled && <input type=\"hidden\" {...register('flsaStatus')} />}\n {isFlsaSelectionEnabled && (\n <SelectField\n name=\"flsaStatus\"\n label={t('employeeClassification')}\n description={\n <Trans\n t={t}\n i18nKey=\"classificationLink\"\n components={{\n ClassificationLink: <Components.Link />,\n }}\n />\n }\n errorMessage={t('validations.exemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n })}\n options={classificationOptions}\n isRequired\n isDisabled={!isFlsaSelectionEnabled}\n onChange={handleFlsaChange}\n />\n )}\n <NumberInputField\n name=\"rate\"\n label={t('amount')}\n format=\"currency\"\n min={0}\n errorMessage={rateErrorMessage}\n isRequired\n isDisabled={\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n }\n />\n {isAdjustMinimumWageEnabled && (\n <>\n <SwitchField\n name=\"adjustForMinimumWage\"\n label={t('adjustForMinimumWage')}\n description={t('adjustForMinimumWageDescription')}\n />\n <SelectField\n name=\"minimumWageId\"\n label={t('minimumWageLabel')}\n description={t('minimumWageDescription')}\n options={minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${format(Number(wage.wage))} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))}\n errorMessage={t('validations.minimumWage')}\n />\n </>\n )}\n <SelectField\n name=\"paymentUnit\"\n label={t('paymentUnitLabel')}\n description={t('paymentUnitDescription')}\n options={paymentUnitOptions}\n errorMessage={t('validations.paymentUnit')}\n isRequired\n isDisabled={\n watchedFlsaStatus === FlsaStatus.OWNER ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n }\n />\n {showTwoPercentStakeholder && (\n <CheckboxField label={t('twoPercentStakeholderLabel')} name=\"twoPercentShareholder\" />\n )}\n {state === 'WA' && (\n <>\n <RadioGroupField\n name=\"stateWcCovered\"\n label={t('stateWcCoveredLabel')}\n description={\n <Trans\n t={t}\n i18nKey=\"stateWcCoveredDescription\"\n components={{\n wcLink: (\n <Components.Link\n href=\"https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n />\n }\n options={[\n { label: t('stateWcCoveredOptions.yes'), value: true },\n { label: t('stateWcCoveredOptions.no'), value: false },\n ]}\n />\n {watchedStateWcCovered && (\n <ComboBoxField\n name=\"stateWcClassCode\"\n label={t('stateWcClassCodeLabel')}\n options={stateWcRiskOptions}\n errorMessage={t('validations.stateWcClassCode')}\n placeholder={t('stateWcClassCodeLabel')}\n description={t('stateWcClassCodeDescription')}\n />\n )}\n </>\n )}\n </>\n )\n}\n"],"names":["Edit","t","useTranslation","format","useNumberFormatter","Components","useComponentContext","stateWcRiskOptions","useMemo","WA_RISK_CLASS_CODES","code","description","control","register","setValue","errors","defaultValues","useFormContext","watchedFlsaStatus","useWatch","watchedStateWcCovered","currentJob","mode","minimumWages","handleFlsaChange","state","showTwoPercentStakeholder","useCompensation","useEffect","FlsaStatus","classificationOptions","key","paymentUnitOptions","PAY_PERIODS","isFlsaSelectionEnabled","isAdjustMinimumWageEnabled","rateErrorMessage","rateMinimumError","rateExemptThresholdError","FLSA_OVERTIME_SALARY_LIMIT","jsxs","Fragment","jsx","TextInputField","SelectField","Trans","NumberInputField","SwitchField","wage","CheckboxField","RadioGroupField","ComboBoxField"],"mappings":";;;;;;;;;;;;;;;;;AA4BO,MAAMA,KAAO,MAAM;AACxB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,uBAAuB,GAC9CC,IAASC,EAAmB,UAAU,GACtCC,IAAaC,EAAA,GAEbC,IAAqBC;AAAA,IACzB,MACEC,EAAoB,IAAI,CAAC,EAAE,MAAAC,GAAM,aAAAC,SAAmB;AAAA,MAClD,OAAOD;AAAA,MACP,OAAO,GAAGA,CAAI,KAAKC,CAAW;AAAA,IAAA,EAC9B;AAAA,IACJ,CAAA;AAAA,EAAC,GAGG;AAAA,IACJ,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAW,EAAE,QAAAC,GAAQ,eAAAC,EAAA;AAAA,EAAc,IACjCC,EAAA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AA,cACC,GAAA5C;AAAA,cACA,SAAQ;AAAA,cACR,YAAY;AAAA,gBACV,QACE,gBAAAyC;AAAA,kBAACrC,EAAW;AAAA,kBAAX;AAAA,oBACC,MAAK;AAAA,oBACL,QAAO;AAAA,oBACP,KAAI;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACN;AAAA,YAEJ;AAAA,UAAA;AAAA,UAGJ,SAAS;AAAA,YACP,EAAE,OAAOJ,EAAE,2BAA2B,GAAG,OAAO,GAAA;AAAA,YAChD,EAAE,OAAOA,EAAE,0BAA0B,GAAG,OAAO,GAAA;AAAA,UAAM;AAAA,QACvD;AAAA,MAAA;AAAA,MAEDmB,KACC,gBAAAsB;AAAA,QAACS;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,OAAOlD,EAAE,uBAAuB;AAAA,UAChC,SAASM;AAAA,UACT,cAAcN,EAAE,8BAA8B;AAAA,UAC9C,aAAaA,EAAE,uBAAuB;AAAA,UACtC,aAAaA,EAAE,6BAA6B;AAAA,QAAA;AAAA,MAAA;AAAA,IAC9C,EAAA,CAEJ;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Edit.js","sources":["../../../../src/components/Employee/Compensation/Edit.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react'\nimport { useFormContext, useWatch } from 'react-hook-form'\nimport { Trans, useTranslation } from 'react-i18next'\nimport {\n type CompensationInputs,\n useCompensation,\n rateMinimumError,\n rateExemptThresholdError,\n} from './useCompensation'\nimport {\n FLSA_OVERTIME_SALARY_LIMIT,\n FlsaStatus,\n PAY_PERIODS,\n TIP_CREDITS_UNSUPPORTED_STATES,\n} from '@/shared/constants'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\nimport {\n NumberInputField,\n SelectField,\n TextInputField,\n SwitchField,\n RadioGroupField,\n ComboBoxField,\n CheckboxField,\n} from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { WA_RISK_CLASS_CODES } from '@/models/WA_RISK_CODES'\n\nexport interface SelectCategory {\n id: string\n name: string\n}\n\nexport const Edit = () => {\n const { t } = useTranslation('Employee.Compensation')\n const format = useNumberFormatter('currency')\n const Components = useComponentContext()\n\n const stateWcRiskOptions = useMemo(\n () =>\n WA_RISK_CLASS_CODES.map(({ code, description }) => ({\n value: code,\n label: `${code}: ${description}`,\n })),\n [],\n )\n\n const {\n control,\n register,\n setValue,\n formState: { errors, defaultValues },\n } = useFormContext<CompensationInputs>()\n\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedStateWcCovered = useWatch({ control, name: 'stateWcCovered' })\n const isAdjustingMinimumWage = useWatch({ control, name: 'adjustForMinimumWage' })\n const { currentJob, mode, minimumWages, handleFlsaChange, state, showTwoPercentStakeholder } =\n useCompensation()\n\n /**Correctly set payment unit selected option and rate based on flsa status, falling back to default */\n useEffect(() => {\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', 'Paycheck')\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', 'Year')\n setValue('rate', 0)\n } else if (defaultValues?.paymentUnit) {\n setValue('paymentUnit', defaultValues.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, defaultValues?.paymentUnit])\n\n if (\n !(\n mode === 'ADD_INITIAL_JOB' ||\n mode === 'ADD_ADDITIONAL_JOB' ||\n mode === 'EDIT_INITIAL_JOB' ||\n mode === 'EDIT_ADDITIONAL_JOB'\n )\n )\n return\n\n const classificationOptions = (Object.keys(FlsaStatus) as Array<keyof typeof FlsaStatus>).map(\n key => ({\n value: FlsaStatus[key],\n label: t(`flsaStatusLabels.${FlsaStatus[key]}`),\n }),\n )\n\n const paymentUnitOptions = [\n { value: PAY_PERIODS.HOUR, label: t('paymentUnitOptions.Hour') },\n { value: PAY_PERIODS.WEEK, label: t('paymentUnitOptions.Week') },\n { value: PAY_PERIODS.MONTH, label: t('paymentUnitOptions.Month') },\n { value: PAY_PERIODS.YEAR, label: t('paymentUnitOptions.Year') },\n { value: PAY_PERIODS.PAYCHECK, label: t('paymentUnitOptions.Paycheck') },\n ]\n\n const isFlsaSelectionEnabled =\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary || mode === 'ADD_INITIAL_JOB'\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n let rateErrorMessage = t('validations.rate')\n if (errors.rate?.message === rateMinimumError) {\n rateErrorMessage = t('validations.nonZeroRate')\n } else if (errors.rate?.message === rateExemptThresholdError) {\n rateErrorMessage = t('validations.rateExemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n })\n }\n\n return (\n <>\n <TextInputField\n name=\"jobTitle\"\n label={t('jobTitle')}\n isRequired\n errorMessage={t('validations.title')}\n />\n {/* hiding flsa selection for secondary jobs */}\n {!isFlsaSelectionEnabled && <input type=\"hidden\" {...register('flsaStatus')} />}\n {isFlsaSelectionEnabled && (\n <SelectField\n name=\"flsaStatus\"\n label={t('employeeClassification')}\n description={\n <Trans\n t={t}\n i18nKey=\"classificationLink\"\n components={{\n ClassificationLink: <Components.Link />,\n }}\n />\n }\n errorMessage={t('validations.exemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n })}\n options={classificationOptions}\n isRequired\n isDisabled={!isFlsaSelectionEnabled}\n onChange={handleFlsaChange}\n />\n )}\n <NumberInputField\n name=\"rate\"\n label={t('amount')}\n format=\"currency\"\n min={0}\n errorMessage={rateErrorMessage}\n isRequired\n isDisabled={\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n }\n />\n <SelectField\n name=\"paymentUnit\"\n label={t('paymentUnitLabel')}\n description={t('paymentUnitDescription')}\n options={paymentUnitOptions}\n errorMessage={t('validations.paymentUnit')}\n isRequired\n isDisabled={\n watchedFlsaStatus === FlsaStatus.OWNER ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n }\n />\n {isAdjustMinimumWageEnabled && (\n <>\n <SwitchField\n name=\"adjustForMinimumWage\"\n label={t('adjustForMinimumWage')}\n description={t('adjustForMinimumWageDescription')}\n />\n {isAdjustingMinimumWage && (\n <SelectField\n name=\"minimumWageId\"\n label={t('minimumWageLabel')}\n description={t('minimumWageDescription')}\n options={minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${format(Number(wage.wage))} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))}\n errorMessage={t('validations.minimumWage')}\n />\n )}\n </>\n )}\n\n {showTwoPercentStakeholder && (\n <CheckboxField label={t('twoPercentStakeholderLabel')} name=\"twoPercentShareholder\" />\n )}\n {state === 'WA' && (\n <>\n <RadioGroupField\n name=\"stateWcCovered\"\n label={t('stateWcCoveredLabel')}\n description={\n <Trans\n t={t}\n i18nKey=\"stateWcCoveredDescription\"\n components={{\n wcLink: (\n <Components.Link\n href=\"https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n />\n }\n options={[\n { label: t('stateWcCoveredOptions.yes'), value: true },\n { label: t('stateWcCoveredOptions.no'), value: false },\n ]}\n />\n {watchedStateWcCovered && (\n <ComboBoxField\n name=\"stateWcClassCode\"\n label={t('stateWcClassCodeLabel')}\n options={stateWcRiskOptions}\n errorMessage={t('validations.stateWcClassCode')}\n placeholder={t('stateWcClassCodeLabel')}\n description={t('stateWcClassCodeDescription')}\n />\n )}\n </>\n )}\n </>\n )\n}\n"],"names":["Edit","t","useTranslation","format","useNumberFormatter","Components","useComponentContext","stateWcRiskOptions","useMemo","WA_RISK_CLASS_CODES","code","description","control","register","setValue","errors","defaultValues","useFormContext","watchedFlsaStatus","useWatch","watchedStateWcCovered","isAdjustingMinimumWage","currentJob","mode","minimumWages","handleFlsaChange","state","showTwoPercentStakeholder","useCompensation","useEffect","FlsaStatus","classificationOptions","key","paymentUnitOptions","PAY_PERIODS","isFlsaSelectionEnabled","isAdjustMinimumWageEnabled","TIP_CREDITS_UNSUPPORTED_STATES","rateErrorMessage","rateMinimumError","rateExemptThresholdError","FLSA_OVERTIME_SALARY_LIMIT","jsxs","Fragment","jsx","TextInputField","SelectField","Trans","NumberInputField","SwitchField","wage","CheckboxField","RadioGroupField","ComboBoxField"],"mappings":";;;;;;;;;;;;;;;;;AAiCO,MAAMA,KAAO,MAAM;AACxB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,uBAAuB,GAC9CC,IAASC,EAAmB,UAAU,GACtCC,IAAaC,EAAA,GAEbC,IAAqBC;AAAA,IACzB,MACEC,EAAoB,IAAI,CAAC,EAAE,MAAAC,GAAM,aAAAC,SAAmB;AAAA,MAClD,OAAOD;AAAA,MACP,OAAO,GAAGA,CAAI,KAAKC,CAAW;AAAA,IAAA,EAC9B;AAAA,IACJ,CAAA;AAAA,EAAC,GAGG;AAAA,IACJ,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAW,EAAE,QAAAC,GAAQ,eAAAC,EAAA;AAAA,EAAc,IACjCC,EAAA,GAEEC,IAAoBC,EAAS,EAAE,SAAAP,GAAS,MAAM,cAAc,GAC5DQ,IAAwBD,EAAS,EAAE,SAAAP,GAAS,MAAM,kBAAkB,GACpES,IAAyBF,EAAS,EAAE,SAAAP,GAAS,MAAM,wBAAwB,GAC3E,EAAE,YAAAU,GAAY,MAAAC,GAAM,cAAAC,GAAc,kBAAAC,GAAkB,OAAAC,GAAO,2BAAAC,EAAA,IAC/DC,EAAA;AAi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AA,kBAAA;AAAA,gBAAA;AAAA,cACN;AAAA,YAEJ;AAAA,UAAA;AAAA,UAGJ,SAAS;AAAA,YACP,EAAE,OAAOJ,EAAE,2BAA2B,GAAG,OAAO,GAAA;AAAA,YAChD,EAAE,OAAOA,EAAE,0BAA0B,GAAG,OAAO,GAAA;AAAA,UAAM;AAAA,QACvD;AAAA,MAAA;AAAA,MAEDmB,KACC,gBAAAwB;AAAA,QAACS;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,OAAOpD,EAAE,uBAAuB;AAAA,UAChC,SAASM;AAAA,UACT,cAAcN,EAAE,8BAA8B;AAAA,UAC9C,aAAaA,EAAE,uBAAuB;AAAA,UACtC,aAAaA,EAAE,6BAA6B;AAAA,QAAA;AAAA,MAAA;AAAA,IAC9C,EAAA,CAEJ;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -12,18 +12,17 @@ import { Form as Z } from "../../../Common/Form/Form.js";
|
|
|
12
12
|
import { Flex as P } from "../../../Common/Flex/Flex.js";
|
|
13
13
|
import "classnames";
|
|
14
14
|
import { componentEvents as M } from "../../../../shared/constants.js";
|
|
15
|
-
import {
|
|
16
|
-
import { ActionsLayout as re } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
17
|
-
import { NumberInputField as D } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
15
|
+
import { ActionsLayout as ee } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
18
16
|
import "react-error-boundary";
|
|
19
17
|
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
20
18
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
21
19
|
import "@tanstack/react-query";
|
|
22
|
-
import { useBase as
|
|
20
|
+
import { useBase as re } from "../../../Base/useBase.js";
|
|
23
21
|
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
24
22
|
import "dompurify";
|
|
25
|
-
import "../../../../contexts/LocaleProvider/useLocale.js";
|
|
26
23
|
import { SelectField as N } from "../../../Common/Fields/SelectField/SelectField.js";
|
|
24
|
+
import { TextInputField as te } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
25
|
+
import { NumberInputField as D } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
27
26
|
const ne = 0, oe = 0, ie = 100, _ = "Number must be greater than or equal to 0", me = o.enum(X), ae = o.object({
|
|
28
27
|
state: o.string(),
|
|
29
28
|
fipsCode: o.string(),
|
|
@@ -34,7 +33,7 @@ const ne = 0, oe = 0, ie = 100, _ = "Number must be greater than or equal to 0",
|
|
|
34
33
|
payPeriodMaximum: o.number().min(0, { error: _ }).transform((r) => r > 0 ? r.toString() : null).nullable(),
|
|
35
34
|
paymentPeriod: me
|
|
36
35
|
});
|
|
37
|
-
function
|
|
36
|
+
function Ie({
|
|
38
37
|
deduction: r,
|
|
39
38
|
handleStateAgencySelect: R,
|
|
40
39
|
stateAgencies: A,
|
|
@@ -44,7 +43,7 @@ function Oe({
|
|
|
44
43
|
selectedAgency: f,
|
|
45
44
|
onCancel: T
|
|
46
45
|
}) {
|
|
47
|
-
const { onEvent: E, baseSubmitHandler: v } =
|
|
46
|
+
const { onEvent: E, baseSubmitHandler: v } = re(), { t: e } = W("Employee.Deductions"), a = Q(), g = {
|
|
48
47
|
case_number: {
|
|
49
48
|
name: "caseNumber",
|
|
50
49
|
description: e("caseNumberDescription")
|
|
@@ -156,7 +155,7 @@ function Oe({
|
|
|
156
155
|
}
|
|
157
156
|
),
|
|
158
157
|
q.map(({ name: t, label: u, description: s }) => /* @__PURE__ */ n(
|
|
159
|
-
|
|
158
|
+
te,
|
|
160
159
|
{
|
|
161
160
|
name: t,
|
|
162
161
|
label: u,
|
|
@@ -217,13 +216,13 @@ function Oe({
|
|
|
217
216
|
)
|
|
218
217
|
] })
|
|
219
218
|
] }),
|
|
220
|
-
/* @__PURE__ */ p(
|
|
219
|
+
/* @__PURE__ */ p(ee, { children: [
|
|
221
220
|
/* @__PURE__ */ n(a.Button, { variant: "secondary", onClick: B, children: e("cancelCta") }),
|
|
222
221
|
b && /* @__PURE__ */ n(a.Button, { type: "submit", isLoading: U, children: e("saveCta") })
|
|
223
222
|
] })
|
|
224
223
|
] }) }) });
|
|
225
224
|
}
|
|
226
225
|
export {
|
|
227
|
-
|
|
226
|
+
Ie as default
|
|
228
227
|
};
|
|
229
228
|
//# sourceMappingURL=ChildSupportForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChildSupportForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/ChildSupportForm.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 { PaymentPeriod } from '@gusto/embedded-api/models/components/garnishmentchildsupport'\nimport type { GarnishmentType } from '@gusto/embedded-api/models/operations/postv1employeesemployeeidgarnishments'\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 { type Agencies } from '@gusto/embedded-api/models/components/childsupportdata'\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, SelectField } from '@/components/Common'\nimport { type CommonComponentInterface, useBase } from '@/components/Base'\nimport { componentEvents } from '@/shared/constants'\n\nconst MINIMUM_PAY_PERIOD_AMOUNT = 0\nconst MINIMUM_PAYCHECK_PERCENTAGE = 0\nconst MAXIMUM_PAYCHECK_PERCENTAGE = 100\n\nconst NON_NEGATIVE_ERROR = 'Number must be greater than or equal to 0'\n\nconst ChildSupportPaymentPeriodSchema = z.enum(PaymentPeriod)\n\nconst ChildSupportSchema = z.object({\n state: z.string(),\n fipsCode: z.string(),\n caseNumber: z.string().nullable(),\n orderNumber: z.string().nullable(),\n remittanceNumber: z.string().nullable(),\n amount: z.number().min(0, { error: NON_NEGATIVE_ERROR }).transform(String),\n payPeriodMaximum: z\n .number()\n .min(0, { error: NON_NEGATIVE_ERROR })\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n paymentPeriod: ChildSupportPaymentPeriodSchema,\n})\n\nexport type ChildSupportInputs = z.input<typeof ChildSupportSchema>\nexport type ChildSupportPayload = z.output<typeof ChildSupportSchema>\n\ninterface ChildSupportFormProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n deduction?: Garnishment | null\n handleStateAgencySelect: (stateAgency: string) => void\n stateAgencies: { label: string; value: string }[]\n counties: { label: string; value: string }[]\n singleAllCountiesFipsCode: string | null | undefined\n selectedAgency?: Agencies\n onCancel: () => void\n}\n\nfunction ChildSupportForm({\n deduction,\n handleStateAgencySelect,\n stateAgencies,\n counties,\n singleAllCountiesFipsCode,\n employeeId,\n selectedAgency,\n onCancel,\n}: ChildSupportFormProps) {\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n const ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER = {\n case_number: {\n name: 'caseNumber',\n description: t('caseNumberDescription'),\n },\n order_number: {\n name: 'orderNumber',\n description: t('orderNumberDescription'),\n },\n remittance_number: {\n name: 'remittanceNumber',\n description: t('remittanceNumberDescription'),\n },\n }\n const requiredSelectedAgencyAttributes =\n selectedAgency?.requiredAttributes?.map(attr => {\n return {\n name: ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER[attr.key!].name,\n label: attr.label as string,\n description: ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER[attr.key!].description,\n }\n }) || []\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 defaultChildSupportValues: ChildSupportInputs = useMemo(() => {\n return {\n amount: deduction?.amount ? Number(deduction.amount) : 0,\n payPeriodMaximum: deduction?.payPeriodMaximum ? Number(deduction.payPeriodMaximum) : null,\n state: deduction?.childSupport?.state || '',\n fipsCode: deduction?.childSupport?.fipsCode || '',\n caseNumber: deduction?.childSupport?.caseNumber || null,\n orderNumber: deduction?.childSupport?.orderNumber || null,\n remittanceNumber: deduction?.childSupport?.remittanceNumber || null,\n paymentPeriod: deduction?.childSupport?.paymentPeriod as PaymentPeriod,\n }\n }, [deduction])\n\n const childSupportFormMethods = useForm<ChildSupportInputs, unknown, ChildSupportPayload>({\n resolver: zodResolver(ChildSupportSchema),\n defaultValues: defaultChildSupportValues,\n })\n const { reset: resetChildSupportForm, setValue, control } = childSupportFormMethods\n const watchedStateAgency = useWatch({ control, name: 'state' })\n\n useEffect(() => {\n resetChildSupportForm(defaultChildSupportValues)\n }, [deduction, defaultChildSupportValues, resetChildSupportForm])\n\n // if in edit mode and user elects to change state agency, reset the required attribute values\n // as new selected agency might require different payload inputs, e.g. OH requires case number + order number\n useEffect(() => {\n setValue('caseNumber', null)\n setValue('orderNumber', null)\n setValue('remittanceNumber', null)\n }, [watchedStateAgency, setValue])\n\n useEffect(() => {\n if (typeof singleAllCountiesFipsCode === 'string') {\n setValue('fipsCode', singleAllCountiesFipsCode)\n }\n }, [singleAllCountiesFipsCode, setValue])\n\n const onChildSupportSubmit: SubmitHandler<ChildSupportPayload> = async data => {\n const childSupport = {\n state: data.state,\n paymentPeriod: data.paymentPeriod,\n fipsCode: data.fipsCode,\n caseNumber: data.caseNumber,\n orderNumber: data.orderNumber,\n remittanceNumber: data.remittanceNumber,\n }\n\n await baseSubmitHandler(data, async payload => {\n const requestBody = {\n active: true,\n amount: payload.amount,\n description: `Child Support - ${childSupport.caseNumber}`, // child support description follows prefix type + case number convention\n courtOrdered: true,\n garnishmentType: 'child_support' as GarnishmentType,\n times: null,\n deductAsPercentage: true, // child support must always deduct as percentage up to a pay period maximum limit and is recurring until cancelled\n payPeriodMaximum: payload.payPeriodMaximum,\n recurring: true,\n childSupport,\n }\n\n if (!deduction) {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId,\n requestBody,\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 ...requestBody,\n version: deduction.version as string,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n }\n })\n }\n\n const handleCancel = () => {\n onCancel()\n }\n\n const isManualPaymentRequired = selectedAgency?.manualPaymentRequired\n const hasSelectableCounties =\n counties.length > 1 || (counties.length === 1 && singleAllCountiesFipsCode == null)\n\n return (\n <FormProvider {...childSupportFormMethods}>\n <Form onSubmit={childSupportFormMethods.handleSubmit(onChildSupportSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h3\">{t('childSupportTitle')}</Components.Heading>\n <Flex flexDirection=\"column\" gap={20}>\n <SelectField\n name=\"state\"\n label={t('agency')}\n description={t('agencyDescription')}\n options={stateAgencies}\n onChange={handleStateAgencySelect}\n isRequired\n />\n\n {isManualPaymentRequired && (\n <Components.Alert status=\"warning\" label={t('manualPaymentRequired')} />\n )}\n\n {watchedStateAgency && (\n <Flex flexDirection=\"column\" gap={20}>\n {hasSelectableCounties && (\n <SelectField\n name=\"fipsCode\"\n label={t('county')}\n description={t('countyDescription')}\n options={counties}\n isRequired\n />\n )}\n {/* render required inputs for respective agency, e.g. OH requires case number + order number */}\n {requiredSelectedAgencyAttributes.map(({ name, label, description }) => (\n <TextInputField\n key={name}\n name={name}\n label={label}\n description={description}\n isRequired\n />\n ))}\n <NumberInputField\n name=\"payPeriodMaximum\"\n label={t('totalAmountWithheld')}\n description={t('totalAmountWithheldDescription')}\n min={MINIMUM_PAY_PERIOD_AMOUNT}\n adornmentStart=\"$\"\n isRequired\n />\n <NumberInputField\n name=\"amount\"\n label={t('maxPaycheckPercentage')}\n description={t('maxPaycheckPercentageDescription')}\n isRequired\n min={MINIMUM_PAYCHECK_PERCENTAGE}\n max={MAXIMUM_PAYCHECK_PERCENTAGE}\n adornmentEnd=\"%\"\n />\n <SelectField\n name=\"paymentPeriod\"\n label={t('per')}\n description={t('perDescription')}\n options={[\n {\n label: t('everyWeek'),\n value: 'Every week',\n },\n {\n label: t('everyOtherWeek'),\n value: 'Every other week',\n },\n {\n label: t('twicePerMonth'),\n value: 'Twice per month',\n },\n {\n label: t('monthly'),\n value: 'Monthly',\n },\n ]}\n isRequired\n />\n </Flex>\n )}\n </Flex>\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n {watchedStateAgency && (\n <Components.Button type=\"submit\" isLoading={isPending}>\n {t('saveCta')}\n </Components.Button>\n )}\n </ActionsLayout>\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nexport default ChildSupportForm\n"],"names":["MINIMUM_PAY_PERIOD_AMOUNT","MINIMUM_PAYCHECK_PERCENTAGE","MAXIMUM_PAYCHECK_PERCENTAGE","NON_NEGATIVE_ERROR","ChildSupportPaymentPeriodSchema","z","PaymentPeriod","ChildSupportSchema","val","ChildSupportForm","deduction","handleStateAgencySelect","stateAgencies","counties","singleAllCountiesFipsCode","employeeId","selectedAgency","onCancel","onEvent","baseSubmitHandler","useBase","t","useTranslation","Components","useComponentContext","ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER","requiredSelectedAgencyAttributes","attr","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","isPending","defaultChildSupportValues","useMemo","childSupportFormMethods","useForm","zodResolver","resetChildSupportForm","setValue","control","watchedStateAgency","useWatch","useEffect","onChildSupportSubmit","data","childSupport","payload","requestBody","updateDeductionResponse","componentEvents","createDeductionResponse","handleCancel","isManualPaymentRequired","hasSelectableCounties","FormProvider","jsx","Form","jsxs","Flex","SelectField","name","label","description","TextInputField","NumberInputField","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,KAA4B,GAC5BC,KAA8B,GAC9BC,KAA8B,KAE9BC,IAAqB,6CAErBC,KAAkCC,EAAE,KAAKC,CAAa,GAEtDC,KAAqBF,EAAE,OAAO;AAAA,EAClC,OAAOA,EAAE,OAAA;AAAA,EACT,UAAUA,EAAE,OAAA;AAAA,EACZ,YAAYA,EAAE,OAAA,EAAS,SAAA;AAAA,EACvB,aAAaA,EAAE,OAAA,EAAS,SAAA;AAAA,EACxB,kBAAkBA,EAAE,OAAA,EAAS,SAAA;AAAA,EAC7B,QAAQA,EAAE,OAAA,EAAS,IAAI,GAAG,EAAE,OAAOF,EAAA,CAAoB,EAAE,UAAU,MAAM;AAAA,EACzE,kBAAkBE,EACf,SACA,IAAI,GAAG,EAAE,OAAOF,GAAoB,EACpC,UAAU,CAAAK,MAAQA,IAAM,IAAIA,EAAI,aAAa,IAAK,EAClD,SAAA;AAAA,EACH,eAAeJ;AACjB,CAAC;AAgBD,SAASK,GAAiB;AAAA,EACxB,WAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,YAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AACF,GAA0B;AACxB,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,GAAA,GACjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA,GAEbC,IAAqC;AAAA,IACzC,aAAa;AAAA,MACX,MAAM;AAAA,MACN,aAAaJ,EAAE,uBAAuB;AAAA,IAAA;AAAA,IAExC,cA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AAe,EAACnC,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWW,GACzC,UAAAb,EAAE,SAAS,EAAA,CACd;AAAA,IAAA,EAAA,CAEJ;AAAA,EAAA,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ChildSupportForm.js","sources":["../../../../../src/components/Employee/Deductions/DeductionsForm/ChildSupportForm.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 { PaymentPeriod } from '@gusto/embedded-api/models/components/garnishmentchildsupport'\nimport type { GarnishmentType } from '@gusto/embedded-api/models/operations/postv1employeesemployeeidgarnishments'\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 { type Agencies } from '@gusto/embedded-api/models/components/childsupportdata'\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, SelectField } from '@/components/Common'\nimport { type CommonComponentInterface, useBase } from '@/components/Base'\nimport { componentEvents } from '@/shared/constants'\n\nconst MINIMUM_PAY_PERIOD_AMOUNT = 0\nconst MINIMUM_PAYCHECK_PERCENTAGE = 0\nconst MAXIMUM_PAYCHECK_PERCENTAGE = 100\n\nconst NON_NEGATIVE_ERROR = 'Number must be greater than or equal to 0'\n\nconst ChildSupportPaymentPeriodSchema = z.enum(PaymentPeriod)\n\nconst ChildSupportSchema = z.object({\n state: z.string(),\n fipsCode: z.string(),\n caseNumber: z.string().nullable(),\n orderNumber: z.string().nullable(),\n remittanceNumber: z.string().nullable(),\n amount: z.number().min(0, { error: NON_NEGATIVE_ERROR }).transform(String),\n payPeriodMaximum: z\n .number()\n .min(0, { error: NON_NEGATIVE_ERROR })\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n paymentPeriod: ChildSupportPaymentPeriodSchema,\n})\n\nexport type ChildSupportInputs = z.input<typeof ChildSupportSchema>\nexport type ChildSupportPayload = z.output<typeof ChildSupportSchema>\n\ninterface ChildSupportFormProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n deduction?: Garnishment | null\n handleStateAgencySelect: (stateAgency: string) => void\n stateAgencies: { label: string; value: string }[]\n counties: { label: string; value: string }[]\n singleAllCountiesFipsCode: string | null | undefined\n selectedAgency?: Agencies\n onCancel: () => void\n}\n\nfunction ChildSupportForm({\n deduction,\n handleStateAgencySelect,\n stateAgencies,\n counties,\n singleAllCountiesFipsCode,\n employeeId,\n selectedAgency,\n onCancel,\n}: ChildSupportFormProps) {\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Employee.Deductions')\n const Components = useComponentContext()\n\n const ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER = {\n case_number: {\n name: 'caseNumber',\n description: t('caseNumberDescription'),\n },\n order_number: {\n name: 'orderNumber',\n description: t('orderNumberDescription'),\n },\n remittance_number: {\n name: 'remittanceNumber',\n description: t('remittanceNumberDescription'),\n },\n }\n const requiredSelectedAgencyAttributes =\n selectedAgency?.requiredAttributes?.map(attr => {\n return {\n name: ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER[attr.key!].name,\n label: attr.label as string,\n description: ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER[attr.key!].description,\n }\n }) || []\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 defaultChildSupportValues: ChildSupportInputs = useMemo(() => {\n return {\n amount: deduction?.amount ? Number(deduction.amount) : 0,\n payPeriodMaximum: deduction?.payPeriodMaximum ? Number(deduction.payPeriodMaximum) : null,\n state: deduction?.childSupport?.state || '',\n fipsCode: deduction?.childSupport?.fipsCode || '',\n caseNumber: deduction?.childSupport?.caseNumber || null,\n orderNumber: deduction?.childSupport?.orderNumber || null,\n remittanceNumber: deduction?.childSupport?.remittanceNumber || null,\n paymentPeriod: deduction?.childSupport?.paymentPeriod as PaymentPeriod,\n }\n }, [deduction])\n\n const childSupportFormMethods = useForm<ChildSupportInputs, unknown, ChildSupportPayload>({\n resolver: zodResolver(ChildSupportSchema),\n defaultValues: defaultChildSupportValues,\n })\n const { reset: resetChildSupportForm, setValue, control } = childSupportFormMethods\n const watchedStateAgency = useWatch({ control, name: 'state' })\n\n useEffect(() => {\n resetChildSupportForm(defaultChildSupportValues)\n }, [deduction, defaultChildSupportValues, resetChildSupportForm])\n\n // if in edit mode and user elects to change state agency, reset the required attribute values\n // as new selected agency might require different payload inputs, e.g. OH requires case number + order number\n useEffect(() => {\n setValue('caseNumber', null)\n setValue('orderNumber', null)\n setValue('remittanceNumber', null)\n }, [watchedStateAgency, setValue])\n\n useEffect(() => {\n if (typeof singleAllCountiesFipsCode === 'string') {\n setValue('fipsCode', singleAllCountiesFipsCode)\n }\n }, [singleAllCountiesFipsCode, setValue])\n\n const onChildSupportSubmit: SubmitHandler<ChildSupportPayload> = async data => {\n const childSupport = {\n state: data.state,\n paymentPeriod: data.paymentPeriod,\n fipsCode: data.fipsCode,\n caseNumber: data.caseNumber,\n orderNumber: data.orderNumber,\n remittanceNumber: data.remittanceNumber,\n }\n\n await baseSubmitHandler(data, async payload => {\n const requestBody = {\n active: true,\n amount: payload.amount,\n description: `Child Support - ${childSupport.caseNumber}`, // child support description follows prefix type + case number convention\n courtOrdered: true,\n garnishmentType: 'child_support' as GarnishmentType,\n times: null,\n deductAsPercentage: true, // child support must always deduct as percentage up to a pay period maximum limit and is recurring until cancelled\n payPeriodMaximum: payload.payPeriodMaximum,\n recurring: true,\n childSupport,\n }\n\n if (!deduction) {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId,\n requestBody,\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 ...requestBody,\n version: deduction.version as string,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n }\n })\n }\n\n const handleCancel = () => {\n onCancel()\n }\n\n const isManualPaymentRequired = selectedAgency?.manualPaymentRequired\n const hasSelectableCounties =\n counties.length > 1 || (counties.length === 1 && singleAllCountiesFipsCode == null)\n\n return (\n <FormProvider {...childSupportFormMethods}>\n <Form onSubmit={childSupportFormMethods.handleSubmit(onChildSupportSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h3\">{t('childSupportTitle')}</Components.Heading>\n <Flex flexDirection=\"column\" gap={20}>\n <SelectField\n name=\"state\"\n label={t('agency')}\n description={t('agencyDescription')}\n options={stateAgencies}\n onChange={handleStateAgencySelect}\n isRequired\n />\n\n {isManualPaymentRequired && (\n <Components.Alert status=\"warning\" label={t('manualPaymentRequired')} />\n )}\n\n {watchedStateAgency && (\n <Flex flexDirection=\"column\" gap={20}>\n {hasSelectableCounties && (\n <SelectField\n name=\"fipsCode\"\n label={t('county')}\n description={t('countyDescription')}\n options={counties}\n isRequired\n />\n )}\n {/* render required inputs for respective agency, e.g. OH requires case number + order number */}\n {requiredSelectedAgencyAttributes.map(({ name, label, description }) => (\n <TextInputField\n key={name}\n name={name}\n label={label}\n description={description}\n isRequired\n />\n ))}\n <NumberInputField\n name=\"payPeriodMaximum\"\n label={t('totalAmountWithheld')}\n description={t('totalAmountWithheldDescription')}\n min={MINIMUM_PAY_PERIOD_AMOUNT}\n adornmentStart=\"$\"\n isRequired\n />\n <NumberInputField\n name=\"amount\"\n label={t('maxPaycheckPercentage')}\n description={t('maxPaycheckPercentageDescription')}\n isRequired\n min={MINIMUM_PAYCHECK_PERCENTAGE}\n max={MAXIMUM_PAYCHECK_PERCENTAGE}\n adornmentEnd=\"%\"\n />\n <SelectField\n name=\"paymentPeriod\"\n label={t('per')}\n description={t('perDescription')}\n options={[\n {\n label: t('everyWeek'),\n value: 'Every week',\n },\n {\n label: t('everyOtherWeek'),\n value: 'Every other week',\n },\n {\n label: t('twicePerMonth'),\n value: 'Twice per month',\n },\n {\n label: t('monthly'),\n value: 'Monthly',\n },\n ]}\n isRequired\n />\n </Flex>\n )}\n </Flex>\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n {watchedStateAgency && (\n <Components.Button type=\"submit\" isLoading={isPending}>\n {t('saveCta')}\n </Components.Button>\n )}\n </ActionsLayout>\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nexport default ChildSupportForm\n"],"names":["MINIMUM_PAY_PERIOD_AMOUNT","MINIMUM_PAYCHECK_PERCENTAGE","MAXIMUM_PAYCHECK_PERCENTAGE","NON_NEGATIVE_ERROR","ChildSupportPaymentPeriodSchema","z","PaymentPeriod","ChildSupportSchema","val","ChildSupportForm","deduction","handleStateAgencySelect","stateAgencies","counties","singleAllCountiesFipsCode","employeeId","selectedAgency","onCancel","onEvent","baseSubmitHandler","useBase","t","useTranslation","Components","useComponentContext","ATTR_KEY_TO_TEXT_FIELD_NAME_MAPPER","requiredSelectedAgencyAttributes","attr","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","isPending","defaultChildSupportValues","useMemo","childSupportFormMethods","useForm","zodResolver","resetChildSupportForm","setValue","control","watchedStateAgency","useWatch","useEffect","onChildSupportSubmit","data","childSupport","payload","requestBody","updateDeductionResponse","componentEvents","createDeductionResponse","handleCancel","isManualPaymentRequired","hasSelectableCounties","FormProvider","jsx","Form","jsxs","Flex","SelectField","name","label","description","TextInputField","NumberInputField","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,KAA4B,GAC5BC,KAA8B,GAC9BC,KAA8B,KAE9BC,IAAqB,6CAErBC,KAAkCC,EAAE,KAAKC,CAAa,GAEtDC,KAAqBF,EAAE,OAAO;AAAA,EAClC,OAAOA,EAAE,OAAA;AAAA,EACT,UAAUA,EAAE,OAAA;AAAA,EACZ,YAAYA,EAAE,OAAA,EAAS,SAAA;AAAA,EACvB,aAAaA,EAAE,OAAA,EAAS,SAAA;AAAA,EACxB,kBAAkBA,EAAE,OAAA,EAAS,SAAA;AAAA,EAC7B,QAAQA,EAAE,OAAA,EAAS,IAAI,GAAG,EAAE,OAAOF,EAAA,CAAoB,EAAE,UAAU,MAAM;AAAA,EACzE,kBAAkBE,EACf,SACA,IAAI,GAAG,EAAE,OAAOF,GAAoB,EACpC,UAAU,CAAAK,MAAQA,IAAM,IAAIA,EAAI,aAAa,IAAK,EAClD,SAAA;AAAA,EACH,eAAeJ;AACjB,CAAC;AAgBD,SAASK,GAAiB;AAAA,EACxB,WAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,YAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AACF,GAA0B;AACxB,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,GAAA,GACjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAA,GAEbC,IAAqC;AAAA,IACzC,aAAa;AAAA,MACX,MAAM;AAAA,MACN,aAAaJ,EAAE,uBAAuB;AAAA,IAAA;AAAA,IAExC,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,aAAaA,EAAE,wBAAwB;AAAA,IAAA;AAAA,IAEzC,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,aA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AAA,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
@@ -11,18 +11,17 @@ import { Form as U } from "../../../Common/Form/Form.js";
|
|
|
11
11
|
import { Flex as m } from "../../../Common/Flex/Flex.js";
|
|
12
12
|
import "classnames";
|
|
13
13
|
import { componentEvents as g } from "../../../../shared/constants.js";
|
|
14
|
-
import {
|
|
15
|
-
import { TextInputField as G } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
16
|
-
import { ActionsLayout as j } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
17
|
-
import { NumberInputField as c } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
14
|
+
import { ActionsLayout as G } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
18
15
|
import "react-error-boundary";
|
|
19
16
|
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
20
17
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
21
18
|
import "@tanstack/react-query";
|
|
22
|
-
import { useBase as
|
|
19
|
+
import { useBase as j } from "../../../Base/useBase.js";
|
|
23
20
|
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
24
21
|
import "dompurify";
|
|
25
|
-
import "
|
|
22
|
+
import { TextInputField as $ } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
23
|
+
import { RadioGroupField as h } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
24
|
+
import { NumberInputField as c } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
26
25
|
const d = "Number must be greater than or equal to 0", z = r.object({
|
|
27
26
|
active: r.boolean(),
|
|
28
27
|
amount: r.number().min(0, { error: d }).transform(String),
|
|
@@ -33,8 +32,8 @@ const d = "Number must be greater than or equal to 0", z = r.object({
|
|
|
33
32
|
totalAmount: r.number().min(0, { error: d }).transform((e) => e > 0 ? e.toString() : null).nullable(),
|
|
34
33
|
deductAsPercentage: r.boolean()
|
|
35
34
|
});
|
|
36
|
-
function
|
|
37
|
-
const { onEvent: p, baseSubmitHandler: x } =
|
|
35
|
+
function fe({ deduction: e, employeeId: A, onCancel: D }) {
|
|
36
|
+
const { onEvent: p, baseSubmitHandler: x } = j(), { t: n } = S("Employee.Deductions"), u = B(), { mutateAsync: E, isPending: P } = _(), { mutateAsync: y, isPending: R } = w(), v = P || R, C = V(() => ({
|
|
38
37
|
amount: e?.amount ? Number(e.amount) : 0,
|
|
39
38
|
description: e?.description ?? "",
|
|
40
39
|
times: e?.times ?? null,
|
|
@@ -78,7 +77,7 @@ function ge({ deduction: e, employeeId: A, onCancel: D }) {
|
|
|
78
77
|
/* @__PURE__ */ t(u.Heading, { as: "h3", children: n("customDeductionTitle") }),
|
|
79
78
|
/* @__PURE__ */ o(m, { flexDirection: "column", gap: 20, children: [
|
|
80
79
|
/* @__PURE__ */ o(m, { flexDirection: "column", gap: 20, children: [
|
|
81
|
-
/* @__PURE__ */ t(
|
|
80
|
+
/* @__PURE__ */ t($, { name: "description", label: n("descriptionLabelV2"), isRequired: !0 }),
|
|
82
81
|
/* @__PURE__ */ t(
|
|
83
82
|
h,
|
|
84
83
|
{
|
|
@@ -142,7 +141,7 @@ function ge({ deduction: e, employeeId: A, onCancel: D }) {
|
|
|
142
141
|
)
|
|
143
142
|
] })
|
|
144
143
|
] }),
|
|
145
|
-
/* @__PURE__ */ o(
|
|
144
|
+
/* @__PURE__ */ o(G, { children: [
|
|
146
145
|
/* @__PURE__ */ t(u.Button, { variant: "secondary", onClick: O, children: n("cancelCta") }),
|
|
147
146
|
/* @__PURE__ */ t(u.Button, { type: "submit", isLoading: v, children: n("saveCta") })
|
|
148
147
|
] })
|
|
@@ -150,6 +149,6 @@ function ge({ deduction: e, employeeId: A, onCancel: D }) {
|
|
|
150
149
|
}
|
|
151
150
|
export {
|
|
152
151
|
z as DeductionSchema,
|
|
153
|
-
|
|
152
|
+
fe as default
|
|
154
153
|
};
|
|
155
154
|
//# 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 { 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\nconst NON_NEGATIVE_ERROR = 'Number must be greater than or equal to 0'\n\nexport const DeductionSchema = z.object({\n active: z.boolean(),\n amount: z.number().min(0, { error: NON_NEGATIVE_ERROR }).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, { error: NON_NEGATIVE_ERROR })\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n totalAmount: z\n .number()\n .min(0, { error: NON_NEGATIVE_ERROR })\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 onCancel: () => void\n}\n\nfunction CustomDeductionForm({ deduction, employeeId, onCancel }: 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 onCancel()\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 <Flex flexDirection=\"column\" gap={20}>\n <Flex flexDirection=\"column\" gap={20}>\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 </Flex>\n {watchedRecurring && (\n <Flex flexDirection=\"column\" gap={20}>\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 </Flex>\n )}\n </Flex>\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n </>\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nexport default CustomDeductionForm\n"],"names":["NON_NEGATIVE_ERROR","DeductionSchema","z","val","CustomDeductionForm","deduction","employeeId","onCancel","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":";;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,IAAqB,6CAEdC,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,QAAA;AAAA,EACV,QAAQA,EAAE,OAAA,EAAS,IAAI,GAAG,EAAE,OAAOF,EAAA,CAAoB,EAAE,UAAU,MAAM;AAAA,EACzE,aAAaE,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,OAAOA,EAAE,OAAA,EAAS,SAAA;AAAA,EAClB,WAAWA,EAAE,QAAA;AAAA,EACb,eAAeA,EACZ,SACA,IAAI,GAAG,EAAE,OAAOF,GAAoB,EACpC,UAAU,CAAAG,MAAQA,IAAM,IAAIA,EAAI,aAAa,IAAK,EAClD,SAAA;AAAA,EACH,aAAaD,EACV,SACA,IAAI,GAAG,EAAE,OAAOF,GAAoB,EACpC,UAAU,CAAAG,MAAQA,IAAM,IAAIA,EAAI,aAAa,IAAK,EAClD,SAAA;AAAA,EACH,oBAAoBD,EAAE,QAAA;AACxB,CAAC;AAWD,SAASE,GAAoB,EAAE,WAAAC,GAAW,YAAAC,GAAY,UAAAC,KAAmC;AACvF,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjC,EAAE,GAAAC,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/B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A,UAACO;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,gBAAgB,CAAChB,KAA2B;AAAA,YAC5C,cAAcA,KAA2B;AAAA,YACzC,OAAOnB,EAAE,sBAAsB;AAAA,YAC/B,YAAU;AAAA,YACV,KAAK;AAAA,YACL,QAAQmB,IAA0B,YAAY;AAAA,YAC9C,aAEMnB,EADJmB,IACM,yCACA,iCADsC;AAAA,UACL;AAAA,QAAA;AAAA,MAE3C,GACF;AAAA,MACCF,KACC,gBAAAc,EAACD,GAAA,EAAK,eAAc,UAAS,KAAK,IAChC,UAAA;AAAA,QAAA,gBAAAF;AAAA,UAACO;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,gBAAe;AAAA,YACf,QAAO;AAAA,YACP,OAAOnC,EAAE,kBAAkB;AAAA,YAC3B,aAAaA,EAAE,wBAAwB;AAAA,YACvC,KAAK;AAAA,UAAA;AAAA,QAAA;AAAA,QAEP,gBAAA4B;AAAA,UAACO;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,gBAAe;AAAA,YACf,QAAO;AAAA,YACP,OAAOnC,EAAE,gBAAgB;AAAA,YACzB,KAAK;AAAA,YACL,aAAaA,EAAE,sBAAsB;AAAA,UAAA;AAAA,QAAA;AAAA,MACvC,EAAA,CACF;AAAA,IAAA,GAEJ;AAAA,sBACCoC,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,UAAAV,EAAE,SAAS,EAAA,CACd;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\nconst NON_NEGATIVE_ERROR = 'Number must be greater than or equal to 0'\n\nexport const DeductionSchema = z.object({\n active: z.boolean(),\n amount: z.number().min(0, { error: NON_NEGATIVE_ERROR }).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, { error: NON_NEGATIVE_ERROR })\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n totalAmount: z\n .number()\n .min(0, { error: NON_NEGATIVE_ERROR })\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 onCancel: () => void\n}\n\nfunction CustomDeductionForm({ deduction, employeeId, onCancel }: 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 onCancel()\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 <Flex flexDirection=\"column\" gap={20}>\n <Flex flexDirection=\"column\" gap={20}>\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 </Flex>\n {watchedRecurring && (\n <Flex flexDirection=\"column\" gap={20}>\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 </Flex>\n )}\n </Flex>\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button type=\"submit\" isLoading={isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n </>\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nexport default CustomDeductionForm\n"],"names":["NON_NEGATIVE_ERROR","DeductionSchema","z","val","CustomDeductionForm","deduction","employeeId","onCancel","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":";;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,IAAqB,6CAEdC,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,QAAA;AAAA,EACV,QAAQA,EAAE,OAAA,EAAS,IAAI,GAAG,EAAE,OAAOF,EAAA,CAAoB,EAAE,UAAU,MAAM;AAAA,EACzE,aAAaE,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,OAAOA,EAAE,OAAA,EAAS,SAAA;AAAA,EAClB,WAAWA,EAAE,QAAA;AAAA,EACb,eAAeA,EACZ,SACA,IAAI,GAAG,EAAE,OAAOF,GAAoB,EACpC,UAAU,CAAAG,MAAQA,IAAM,IAAIA,EAAI,aAAa,IAAK,EAClD,SAAA;AAAA,EACH,aAAaD,EACV,SACA,IAAI,GAAG,EAAE,OAAOF,GAAoB,EACpC,UAAU,CAAAG,MAAQA,IAAM,IAAIA,EAAI,aAAa,IAAK,EAClD,SAAA;AAAA,EACH,oBAAoBD,EAAE,QAAA;AACxB,CAAC;AAWD,SAASE,GAAoB,EAAE,WAAAC,GAAW,YAAAC,GAAY,UAAAC,KAAmC;AACvF,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjC,EAAE,GAAAC,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,QAAQlB,GAAW,SAAS,OAAOA,EAAU,MAAM,IAAI;AAAA,IACvD,aAAaA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