@gusto/embedded-react-sdk 0.8.0 → 0.8.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 +9 -0
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +5 -3
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js.map +1 -1
- package/dist/components/Common/FadeIn/FadeIn.module.scss.js +4 -4
- package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.js +1 -1
- package/dist/components/Common/FieldCaption/FieldCaption.js.map +1 -0
- package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.js +1 -1
- package/dist/components/Common/FieldDescription/FieldDescription.js.map +1 -0
- package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.js +1 -1
- package/dist/components/Common/FieldErrorMessage/FieldErrorMessage.js.map +1 -0
- package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.js +1 -1
- package/dist/components/Common/FieldLayout/FieldLayout.js.map +1 -0
- package/dist/components/Common/FieldLayout/FieldLayoutTypes.d.ts +52 -0
- package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.js +1 -1
- package/dist/components/Common/Fieldset/Fieldset.js.map +1 -0
- package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.js +2 -2
- package/dist/components/Common/HorizontalFieldLayout/HorizontalFieldLayout.js.map +1 -0
- package/dist/components/Common/SignatureForm/SignatureForm.d.ts +12 -6
- package/dist/components/Common/SignatureForm/SignatureForm.js +10 -10
- package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Common/UI/Alert/Alert.d.ts +1 -1
- package/dist/components/Common/UI/Alert/Alert.js +13 -12
- package/dist/components/Common/UI/Alert/Alert.js.map +1 -1
- package/dist/components/Common/UI/Alert/AlertTypes.d.ts +16 -4
- package/dist/components/Common/UI/Badge/BadgeTypes.d.ts +6 -0
- package/dist/components/Common/UI/Button/Button.js +28 -27
- package/dist/components/Common/UI/Button/Button.js.map +1 -1
- package/dist/components/Common/UI/Button/Button.module.scss.js +1 -1
- package/dist/components/Common/UI/Button/ButtonTypes.d.ts +29 -4
- package/dist/components/Common/UI/CalendarPreview/CalendarPreviewTypes.d.ts +24 -0
- package/dist/components/Common/UI/Card/Card.module.scss.js +1 -1
- package/dist/components/Common/UI/Card/CardTypes.d.ts +12 -4
- package/dist/components/Common/UI/Checkbox/Checkbox.js +4 -4
- package/dist/components/Common/UI/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Common/UI/Checkbox/CheckboxTypes.d.ts +16 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.js +4 -4
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.d.ts +33 -3
- package/dist/components/Common/UI/ComboBox/ComboBox.js +8 -8
- package/dist/components/Common/UI/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +31 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.js +13 -13
- package/dist/components/Common/UI/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/Common/UI/DatePicker/DatePickerTypes.d.ts +25 -1
- package/dist/components/Common/UI/Heading/HeadingTypes.d.ts +12 -0
- package/dist/components/Common/UI/Link/LinkTypes.d.ts +53 -1
- package/dist/components/Common/UI/List/ListTypes.d.ts +3 -5
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +30 -0
- package/dist/components/Common/UI/NumberInput/NumberInput.js +4 -4
- package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInputTypes.d.ts +34 -1
- package/dist/components/Common/UI/ProgressBar/ProgressBarTypes.d.ts +12 -0
- package/dist/components/Common/UI/Radio/Radio.js +1 -1
- package/dist/components/Common/UI/Radio/Radio.js.map +1 -1
- package/dist/components/Common/UI/Radio/RadioTypes.d.ts +16 -1
- package/dist/components/Common/UI/RadioGroup/RadioGroup.js +4 -4
- package/dist/components/Common/UI/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.d.ts +33 -3
- package/dist/components/Common/UI/Select/Select.js +8 -8
- package/dist/components/Common/UI/Select/Select.js.map +1 -1
- package/dist/components/Common/UI/Select/SelectTypes.d.ts +34 -1
- package/dist/components/Common/UI/Switch/Switch.js +1 -1
- package/dist/components/Common/UI/Switch/Switch.js.map +1 -1
- package/dist/components/Common/UI/Switch/SwitchTypes.d.ts +25 -1
- package/dist/components/Common/UI/Table/TableTypes.d.ts +21 -0
- package/dist/components/Common/UI/Text/TextTypes.d.ts +18 -0
- package/dist/components/Common/UI/TextInput/TextInput.js +1 -1
- package/dist/components/Common/UI/TextInput/TextInput.js.map +1 -1
- package/dist/components/Common/UI/TextInput/TextInputTypes.d.ts +22 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.js +12 -12
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +7 -7
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.d.ts +2 -2
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.d.ts +41 -15
- package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.js +17 -20
- package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +10 -10
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.d.ts +17 -11
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +42 -45
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js +6 -6
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.d.ts +12 -6
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +2 -2
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js +10 -10
- package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.d.ts +12 -6
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +17 -17
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
- package/dist/components/Company/DocumentSignerFlow/SignatureForm/SignatureForm.js +1 -1
- package/dist/components/Company/DocumentSignerFlow/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.js +5 -5
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.d.ts +18 -8
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +12 -16
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Industry.js +1 -1
- package/dist/components/Company/Industry/Industry.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.d.ts +27 -11
- package/dist/components/Company/Locations/LocationForm/Form.js +24 -24
- package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.js +24 -24
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +7 -7
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.js +28 -31
- package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.module.scss.js +8 -0
- package/dist/components/Company/PaySchedule/_parts/List.module.scss.js.map +1 -0
- package/dist/components/Company/PaySchedule/usePaySchedule.d.ts +31 -13
- package/dist/components/Company/PaySchedule/usePaySchedule.js +15 -20
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.d.ts +3 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +3 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +66 -77
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Employee/Compensation/Compensation.js +5 -5
- package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
- package/dist/components/Employee/Compensation/List.js +10 -10
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Compensation/useCompensation.d.ts +90 -42
- package/dist/components/Employee/Compensation/useCompensation.js +45 -69
- package/dist/components/Employee/Compensation/useCompensation.js.map +1 -1
- package/dist/components/Employee/Deductions/Deductions.d.ts +9 -5
- package/dist/components/Employee/Deductions/Deductions.js +13 -13
- package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
- package/dist/components/Employee/Deductions/useDeductions.d.ts +34 -14
- package/dist/components/Employee/Deductions/useDeductions.js +14 -32
- package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccount.d.ts +22 -10
- package/dist/components/Employee/PaymentMethod/BankAccount.js +9 -9
- package/dist/components/Employee/PaymentMethod/BankAccount.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js +13 -13
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.d.ts +10 -6
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +8 -8
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.d.ts +92 -37
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +35 -42
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.d.ts +68 -31
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +33 -46
- package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Profile/HomeAddress.d.ts +33 -13
- package/dist/components/Employee/Profile/HomeAddress.js +39 -38
- package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.d.ts +81 -32
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +60 -74
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/Profile.js +51 -55
- package/dist/components/Employee/Profile/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/SelfPersonalDetails.d.ts +44 -15
- package/dist/components/Employee/Profile/SelfPersonalDetails.js +18 -21
- package/dist/components/Employee/Profile/SelfPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.d.ts +28 -12
- package/dist/components/Employee/Taxes/FederalForm.js +28 -28
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/StateForm.d.ts +9 -5
- package/dist/components/Employee/Taxes/StateForm.js +5 -5
- package/dist/components/Employee/Taxes/StateForm.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +31 -34
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/contexts/ApiProvider/ApiProvider.d.ts +5 -0
- package/dist/contexts/ApiProvider/ApiProvider.js +34 -0
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +16 -16
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/helpers/validations.d.ts +6 -5
- package/dist/helpers/validations.js +10 -17
- package/dist/helpers/validations.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +7 -4
- package/dist/components/Common/UI/FieldCaption/FieldCaption.js.map +0 -1
- package/dist/components/Common/UI/FieldDescription/FieldDescription.js.map +0 -1
- package/dist/components/Common/UI/FieldErrorMessage/FieldErrorMessage.js.map +0 -1
- package/dist/components/Common/UI/FieldLayout/FieldLayout.js.map +0 -1
- package/dist/components/Common/UI/FieldLayout/FieldLayoutTypes.d.ts +0 -19
- package/dist/components/Common/UI/Fieldset/Fieldset.js.map +0 -1
- package/dist/components/Common/UI/HorizontalFieldLayout/HorizontalFieldLayout.js.map +0 -1
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.d.ts +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.module.scss.js +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.d.ts +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.module.scss.js +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayoutTypes.d.ts +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/index.d.ts +0 -0
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import { Garnishment } from '@gusto/embedded-api/models/components/garnishment';
|
|
2
|
-
import
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
export type MODE = 'ADD' | 'LIST' | 'INITIAL' | 'EDIT';
|
|
4
|
-
export declare const DeductionSchema:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
export declare const DeductionSchema: z.ZodObject<{
|
|
5
|
+
active: z.ZodBoolean;
|
|
6
|
+
amount: z.ZodEffects<z.ZodNumber, string, number>;
|
|
7
|
+
description: z.ZodString;
|
|
8
|
+
courtOrdered: z.ZodBoolean;
|
|
9
|
+
times: z.ZodNullable<z.ZodNumber>;
|
|
10
|
+
recurring: z.ZodEffects<z.ZodString, boolean, string>;
|
|
11
|
+
annualMaximum: z.ZodNullable<z.ZodEffects<z.ZodNumber, string | null, number>>;
|
|
12
|
+
payPeriodMaximum: z.ZodNullable<z.ZodEffects<z.ZodNumber, string | null, number>>;
|
|
13
|
+
deductAsPercentage: z.ZodEffects<z.ZodString, boolean, string>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
description: string;
|
|
16
|
+
active: boolean;
|
|
17
|
+
amount: string;
|
|
18
|
+
courtOrdered: boolean;
|
|
19
|
+
times: number | null;
|
|
20
|
+
recurring: boolean;
|
|
21
|
+
annualMaximum: string | null;
|
|
22
|
+
payPeriodMaximum: string | null;
|
|
23
|
+
deductAsPercentage: boolean;
|
|
24
|
+
}, {
|
|
25
|
+
description: string;
|
|
26
|
+
active: boolean;
|
|
27
|
+
amount: number;
|
|
28
|
+
courtOrdered: boolean;
|
|
29
|
+
times: number | null;
|
|
30
|
+
recurring: string;
|
|
31
|
+
annualMaximum: number | null;
|
|
32
|
+
payPeriodMaximum: number | null;
|
|
33
|
+
deductAsPercentage: string;
|
|
34
|
+
}>;
|
|
35
|
+
export type DeductionInputs = z.input<typeof DeductionSchema>;
|
|
36
|
+
export type DeductionPayload = z.output<typeof DeductionSchema>;
|
|
17
37
|
type DeductionsContextType = {
|
|
18
38
|
isPending: boolean;
|
|
19
39
|
deductions: Garnishment[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z as r } from "zod";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
4
|
import "react-error-boundary";
|
|
@@ -9,40 +9,22 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
9
9
|
import "../../Base/useBase.js";
|
|
10
10
|
import "dompurify";
|
|
11
11
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
12
|
-
import { createCompoundContext as
|
|
13
|
-
const
|
|
12
|
+
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
13
|
+
const g = r.object({
|
|
14
14
|
active: r.boolean(),
|
|
15
|
-
amount: r.
|
|
16
|
-
description: r.
|
|
15
|
+
amount: r.number().min(0).transform(String),
|
|
16
|
+
description: r.string().min(1),
|
|
17
17
|
courtOrdered: r.boolean(),
|
|
18
|
-
times: r.
|
|
18
|
+
times: r.number().nullable(),
|
|
19
19
|
//The number of times to apply the garnishment. Ignored if recurring is true.
|
|
20
|
-
recurring: r.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
r.pipe(
|
|
26
|
-
r.number(),
|
|
27
|
-
r.minValue(0),
|
|
28
|
-
r.transform((t) => t > 0 ? t.toString() : null)
|
|
29
|
-
)
|
|
30
|
-
),
|
|
31
|
-
payPeriodMaximum: r.nullable(
|
|
32
|
-
r.pipe(
|
|
33
|
-
r.number(),
|
|
34
|
-
r.minValue(0),
|
|
35
|
-
r.transform((t) => t > 0 ? t.toString() : null)
|
|
36
|
-
)
|
|
37
|
-
),
|
|
38
|
-
deductAsPercentage: r.pipe(
|
|
39
|
-
r.string(),
|
|
40
|
-
r.transform((t) => t === "true")
|
|
41
|
-
)
|
|
42
|
-
}), [g, f] = e("DeductionsContext");
|
|
20
|
+
recurring: r.string().transform((t) => t === "true"),
|
|
21
|
+
annualMaximum: r.number().min(0).transform((t) => t > 0 ? t.toString() : null).nullable(),
|
|
22
|
+
payPeriodMaximum: r.number().min(0).transform((t) => t > 0 ? t.toString() : null).nullable(),
|
|
23
|
+
deductAsPercentage: r.string().transform((t) => t === "true")
|
|
24
|
+
}), [f, x] = o("DeductionsContext");
|
|
43
25
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
g as DeductionSchema,
|
|
27
|
+
x as DeductionsProvider,
|
|
28
|
+
f as useDeductions
|
|
47
29
|
};
|
|
48
30
|
//# sourceMappingURL=useDeductions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeductions.js","sources":["../../../../src/components/Employee/Deductions/useDeductions.ts"],"sourcesContent":["import type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport
|
|
1
|
+
{"version":3,"file":"useDeductions.js","sources":["../../../../src/components/Employee/Deductions/useDeductions.ts"],"sourcesContent":["import type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\n\nexport type MODE = 'ADD' | 'LIST' | 'INITIAL' | 'EDIT'\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(), //The number of times to apply the garnishment. Ignored if recurring is true.\n recurring: z.string().transform(val => val === 'true'),\n annualMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n payPeriodMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n deductAsPercentage: z.string().transform(val => val === 'true'),\n})\n\nexport type DeductionInputs = z.input<typeof DeductionSchema>\nexport type DeductionPayload = z.output<typeof DeductionSchema>\n\ntype DeductionsContextType = {\n isPending: boolean\n deductions: Garnishment[]\n employeeId: string\n mode: MODE\n handleAdd: () => void\n handleCancel: () => void\n handleEdit: (deduction: Garnishment) => void\n handleDelete: (deduction: Garnishment) => void\n handlePassthrough: () => void\n}\nconst [useDeductions, DeductionsProvider] =\n createCompoundContext<DeductionsContextType>('DeductionsContext')\nexport { useDeductions, DeductionsProvider }\n"],"names":["DeductionSchema","z","val","useDeductions","DeductionsProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;AAMa,MAAAA,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,QAAQ;AAAA,EAClB,QAAQA,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,MAAM;AAAA,EAC1C,aAAaA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,cAAcA,EAAE,QAAQ;AAAA,EACxB,OAAOA,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAC3B,WAAWA,EAAE,SAAS,UAAU,CAAAC,MAAOA,MAAQ,MAAM;AAAA,EACrD,eAAeD,EACZ,OAAA,EACA,IAAI,CAAC,EACL,UAAU,CAAQC,MAAAA,IAAM,IAAIA,EAAI,SAAA,IAAa,IAAK,EAClD,SAAS;AAAA,EACZ,kBAAkBD,EACf,OAAA,EACA,IAAI,CAAC,EACL,UAAU,CAAQC,MAAAA,IAAM,IAAIA,EAAI,SAAA,IAAa,IAAK,EAClD,SAAS;AAAA,EACZ,oBAAoBD,EAAE,SAAS,UAAU,CAAAC,MAAOA,MAAQ,MAAM;AAChE,CAAC,GAgBK,CAACC,GAAeC,CAAkB,IACtCC,EAA6C,mBAAmB;"}
|
|
@@ -3,7 +3,7 @@ import { invalidateEmployeeFormsList as w } from "@gusto/embedded-api/react-quer
|
|
|
3
3
|
import { useEmployeeFormsGetPdfSuspense as B } from "@gusto/embedded-api/react-query/employeeFormsGetPdf";
|
|
4
4
|
import { useEmployeeFormsSignMutation as C } from "@gusto/embedded-api/react-query/employeeFormsSign";
|
|
5
5
|
import { useEmployeeFormsGetSuspense as A } from "@gusto/embedded-api/react-query/employeeFormsGet";
|
|
6
|
-
import { useQueryClient as q } from "@
|
|
6
|
+
import { useQueryClient as q } from "@tanstack/react-query";
|
|
7
7
|
import { Form as u } from "./Form.js";
|
|
8
8
|
import { Head as a } from "./Head.js";
|
|
9
9
|
import { Actions as c } from "./Actions.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureForm.js","sources":["../../../../../src/components/Employee/DocumentSigner/SignatureForm/SignatureForm.tsx"],"sourcesContent":["import { invalidateEmployeeFormsList } from '@gusto/embedded-api/react-query/employeeFormsList'\nimport { useEmployeeFormsGetPdfSuspense } from '@gusto/embedded-api/react-query/employeeFormsGetPdf'\nimport { useEmployeeFormsSignMutation } from '@gusto/embedded-api/react-query/employeeFormsSign'\nimport { useEmployeeFormsGetSuspense } from '@gusto/embedded-api/react-query/employeeFormsGet'\nimport { useQueryClient } from '@
|
|
1
|
+
{"version":3,"file":"SignatureForm.js","sources":["../../../../../src/components/Employee/DocumentSigner/SignatureForm/SignatureForm.tsx"],"sourcesContent":["import { invalidateEmployeeFormsList } from '@gusto/embedded-api/react-query/employeeFormsList'\nimport { useEmployeeFormsGetPdfSuspense } from '@gusto/embedded-api/react-query/employeeFormsGetPdf'\nimport { useEmployeeFormsSignMutation } from '@gusto/embedded-api/react-query/employeeFormsSign'\nimport { useEmployeeFormsGetSuspense } from '@gusto/embedded-api/react-query/employeeFormsGet'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { Form as FormComponent } from './Form'\nimport { Head } from './Head'\nimport { Actions } from './Actions'\nimport { Preview } from './Preview'\nimport { SignatureFormProvider } from './useSignatureForm'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Flex } from '@/components/Common'\nimport type { SignatureFormInputs } from '@/components/Common/SignatureForm'\nimport { SignatureForm as SharedSignatureForm } from '@/components/Common/SignatureForm'\n\ninterface SignatureFormProps extends CommonComponentInterface {\n employeeId: string\n formId: string\n}\n\nexport function SignatureForm(props: SignatureFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, formId, className, children }: SignatureFormProps) {\n useI18n('Employee.DocumentSigner')\n const { onEvent, baseSubmitHandler } = useBase()\n const queryClient = useQueryClient()\n\n const { data } = useEmployeeFormsGetSuspense({ employeeId, formId })\n const form = data.form!\n\n const {\n data: { formPdf },\n } = useEmployeeFormsGetPdfSuspense({ employeeId, formId: form.uuid })\n const pdfUrl = formPdf!.documentUrl\n\n const { mutateAsync: signForm, isPending: isSignFormPending } = useEmployeeFormsSignMutation({\n onSettled: async () => {\n await invalidateEmployeeFormsList(queryClient, [employeeId])\n },\n })\n\n const handleBack = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n const handleSubmit = async (data: SignatureFormInputs) => {\n await baseSubmitHandler(data, async payload => {\n if (form.uuid) {\n const { form: signFormResult } = await signForm({\n request: {\n employeeId,\n formId: form.uuid,\n requestBody: {\n signatureText: payload.signature,\n agree: payload.confirmSignature,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_SIGN_FORM, signFormResult)\n }\n })\n }\n\n return (\n <section className={className}>\n <SignatureFormProvider\n value={{\n pdfUrl,\n handleBack,\n form,\n isPending: isSignFormPending,\n }}\n >\n <SharedSignatureForm onSubmit={handleSubmit}>\n <Flex flexDirection=\"column\">\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Preview />\n <FormComponent />\n <Actions />\n </>\n )}\n </Flex>\n </SharedSignatureForm>\n </SignatureFormProvider>\n </section>\n )\n}\n\nSignatureForm.Head = Head\nSignatureForm.Preview = Preview\nSignatureForm.Form = FormComponent\nSignatureForm.Actions = Actions\n"],"names":["SignatureForm","props","jsx","BaseComponent","Root","employeeId","formId","className","children","useI18n","onEvent","baseSubmitHandler","useBase","queryClient","useQueryClient","data","useEmployeeFormsGetSuspense","form","formPdf","useEmployeeFormsGetPdfSuspense","pdfUrl","signForm","isSignFormPending","useEmployeeFormsSignMutation","invalidateEmployeeFormsList","SignatureFormProvider","componentEvents","SharedSignatureForm","payload","signFormResult","Flex","jsxs","Fragment","Head","Preview","FormComponent","Actions"],"mappings":";;;;;;;;;;;;;;;;;AA2BO,SAASA,EAAcC,GAAoD;AAE9E,SAAA,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAM,EAAA,GAAGH,GAAO,EACnB,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,YAAAC,GAAY,QAAAC,GAAQ,WAAAC,GAAW,UAAAC,KAAgC;AAC7E,EAAAC,EAAQ,yBAAyB;AACjC,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzCC,IAAcC,EAAe,GAE7B,EAAE,MAAAC,EAAK,IAAIC,EAA4B,EAAE,YAAAX,GAAY,QAAAC,GAAQ,GAC7DW,IAAOF,EAAK,MAEZ;AAAA,IACJ,MAAM,EAAE,SAAAG,EAAQ;AAAA,EAAA,IACdC,EAA+B,EAAE,YAAAd,GAAY,QAAQY,EAAK,MAAM,GAC9DG,IAASF,EAAS,aAElB,EAAE,aAAaG,GAAU,WAAWC,EAAA,IAAsBC,EAA6B;AAAA,IAC3F,WAAW,YAAY;AACrB,YAAMC,EAA4BX,GAAa,CAACR,CAAU,CAAC;AAAA,IAAA;AAAA,EAC7D,CACD;AAyBC,SAAA,gBAAAH,EAAC,aAAQ,WAAAK,GACP,UAAA,gBAAAL;AAAA,IAACuB;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAAL;AAAA,QACA,YA3BW,MAAM;AACvB,UAAAV,EAAQgB,EAAgB,MAAM;AAAA,QAChC;AAAA,QA0BQ,MAAAT;AAAA,QACA,WAAWK;AAAA,MACb;AAAA,MAEA,UAAA,gBAAApB,EAACyB,GAAoB,EAAA,UA5BN,OAAOZ,MAA8B;AAClD,cAAAJ,EAAkBI,GAAM,OAAMa,MAAW;AAC7C,cAAIX,EAAK,MAAM;AACb,kBAAM,EAAE,MAAMY,EAAe,IAAI,MAAMR,EAAS;AAAA,cAC9C,SAAS;AAAA,gBACP,YAAAhB;AAAA,gBACA,QAAQY,EAAK;AAAA,gBACb,aAAa;AAAA,kBACX,eAAeW,EAAQ;AAAA,kBACvB,OAAOA,EAAQ;AAAA,gBAAA;AAAA,cACjB;AAAA,YACF,CACD;AACO,YAAAlB,EAAAgB,EAAgB,oBAAoBG,CAAc;AAAA,UAAA;AAAA,QAC5D,CACD;AAAA,MACH,GAaQ,UAAA,gBAAA3B,EAAC4B,KAAK,eAAc,UACjB,UACCtB,KAGE,gBAAAuB,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAA9B,EAAC+B,GAAK,EAAA;AAAA,0BACLC,GAAQ,EAAA;AAAA,0BACRC,GAAc,EAAA;AAAA,0BACdC,GAAQ,CAAA,CAAA;AAAA,MAAA,EACX,CAAA,EAEJ,CAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEApC,EAAc,OAAOiC;AACrBjC,EAAc,UAAUkC;AACxBlC,EAAc,OAAOmC;AACrBnC,EAAc,UAAUoC;"}
|
|
@@ -3,7 +3,7 @@ import { useState as y } from "react";
|
|
|
3
3
|
import { useEmployeesListSuspense as F, invalidateEmployeesList as U } from "@gusto/embedded-api/react-query/employeesList";
|
|
4
4
|
import { useEmployeesDeleteMutation as q } from "@gusto/embedded-api/react-query/employeesDelete";
|
|
5
5
|
import { useEmployeesUpdateOnboardingStatusMutation as W } from "@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus";
|
|
6
|
-
import { useQueryClient as H } from "@
|
|
6
|
+
import { useQueryClient as H } from "@tanstack/react-query";
|
|
7
7
|
import { EmployeeListProvider as j } from "./useEmployeeList.js";
|
|
8
8
|
import { Actions as P } from "./Actions.js";
|
|
9
9
|
import { BaseComponent as k } from "../../Base/Base.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmployeeList.js","sources":["../../../../src/components/Employee/EmployeeList/EmployeeList.tsx"],"sourcesContent":["import { useState } from 'react'\nimport {\n useEmployeesListSuspense,\n invalidateEmployeesList,\n} from '@gusto/embedded-api/react-query/employeesList'\nimport { useEmployeesDeleteMutation } from '@gusto/embedded-api/react-query/employeesDelete'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { useQueryClient } from '@
|
|
1
|
+
{"version":3,"file":"EmployeeList.js","sources":["../../../../src/components/Employee/EmployeeList/EmployeeList.tsx"],"sourcesContent":["import { useState } from 'react'\nimport {\n useEmployeesListSuspense,\n invalidateEmployeesList,\n} from '@gusto/embedded-api/react-query/employeesList'\nimport { useEmployeesDeleteMutation } from '@gusto/embedded-api/react-query/employeesDelete'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { EmployeeListProvider } from './useEmployeeList'\nimport { Actions } from './Actions'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents, EmployeeOnboardingStatus } from '@/shared/constants'\nimport { Head } from '@/components/Employee/EmployeeList/Head'\nimport { List } from '@/components/Employee/EmployeeList/List'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\n//Interface for component specific props\ninterface EmployeeListProps extends CommonComponentInterface {\n companyId: string\n}\n\nexport function EmployeeList(props: EmployeeListProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nfunction Root({ companyId, className, children }: EmployeeListProps) {\n //Using i18n hook to directly load necessary namespace\n useI18n('Employee.EmployeeList')\n //Getting props from base context\n const { onEvent, baseSubmitHandler } = useBase()\n const [currentPage, setCurrentPage] = useState(1)\n const [itemsPerPage, setItemsPerPage] = useState(5)\n const queryClient = useQueryClient()\n\n const { data } = useEmployeesListSuspense({ companyId, page: currentPage, per: itemsPerPage })\n const { httpMeta, employeeList } = data\n const employees = employeeList!\n\n const { mutateAsync: deleteEmployeeMutation } = useEmployeesDeleteMutation()\n const { mutateAsync: updateEmployeeOnboardingStatusMutation } =\n useEmployeesUpdateOnboardingStatusMutation()\n\n const totalPages = Number(httpMeta.response.headers.get('x-total-pages') ?? 1)\n\n const handleItemsPerPageChange = (newCount: number) => {\n setItemsPerPage(newCount)\n }\n const handleFirstPage = () => {\n setCurrentPage(1)\n }\n const handlePreviousPage = () => {\n setCurrentPage(prevPage => Math.max(prevPage - 1, 1))\n }\n const handleNextPage = () => {\n setCurrentPage(prevPage => Math.min(prevPage + 1, totalPages))\n }\n const handleLastPage = () => {\n setCurrentPage(totalPages)\n }\n const handleDelete = async (uuid: string) => {\n await baseSubmitHandler(uuid, async payload => {\n await deleteEmployeeMutation({\n request: { employeeId: payload },\n })\n\n await invalidateEmployeesList(queryClient, [companyId])\n onEvent(componentEvents.EMPLOYEE_DELETED, { employeeId: payload })\n })\n }\n /**Set onboarding status to self_onboarding_awaiting_admin_review and proceed to edit */\n const handleReview = async (data: string) => {\n await baseSubmitHandler(data, async employeeId => {\n await updateOnboardingStatus({\n employeeId,\n status: EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n })\n onEvent(componentEvents.EMPLOYEE_UPDATE, {\n employeeId,\n onboardingStatus: EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n })\n })\n }\n /**Update employee onboarding status reverting it back to admin_onboarding_incomplete */\n const handleCancelSelfOnboarding = async (data: string) => {\n await baseSubmitHandler(data, async employeeId => {\n await updateOnboardingStatus({\n employeeId,\n status: EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n })\n })\n }\n const updateOnboardingStatus = async (data: { employeeId: string; status: string }) => {\n await baseSubmitHandler(data, async ({ employeeId, status }) => {\n const { employeeOnboardingStatus: responseData } =\n await updateEmployeeOnboardingStatusMutation({\n request: { employeeId, requestBody: { onboardingStatus: status } },\n })\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, responseData)\n })\n }\n const handleNew = () => {\n onEvent(componentEvents.EMPLOYEE_CREATE)\n }\n const handleSkip = () => {\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_DONE)\n }\n\n const handleEdit = (uuid: string, onboardingStatus?: string) => {\n onEvent(componentEvents.EMPLOYEE_UPDATE, { employeeId: uuid, onboardingStatus })\n }\n return (\n <section className={className}>\n <EmployeeListProvider\n value={{\n handleEdit,\n handleNew,\n handleReview,\n handleDelete,\n employees,\n currentPage,\n totalPages,\n handleFirstPage,\n handlePreviousPage,\n handleNextPage,\n handleLastPage,\n handleCancelSelfOnboarding,\n handleItemsPerPageChange,\n handleSkip,\n }}\n >\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Actions />\n </Flex>\n )}\n </EmployeeListProvider>\n </section>\n )\n}\n\nEmployeeList.Head = Head\nEmployeeList.List = List\nEmployeeList.Actions = Actions\n\n/**\n * Wrapper used inside Flows -> exposes flow context for required parameters\n */\nexport const EmployeeListContextual = () => {\n const { companyId, onEvent } = useFlow<EmployeeOnboardingContextInterface>()\n return <EmployeeList companyId={companyId} onEvent={onEvent} />\n}\n"],"names":["EmployeeList","props","jsx","BaseComponent","Root","companyId","className","children","useI18n","onEvent","baseSubmitHandler","useBase","currentPage","setCurrentPage","useState","itemsPerPage","setItemsPerPage","queryClient","useQueryClient","data","useEmployeesListSuspense","httpMeta","employeeList","employees","deleteEmployeeMutation","useEmployeesDeleteMutation","updateEmployeeOnboardingStatusMutation","useEmployeesUpdateOnboardingStatusMutation","totalPages","handleItemsPerPageChange","newCount","handleFirstPage","handlePreviousPage","prevPage","handleNextPage","handleLastPage","handleDelete","uuid","payload","invalidateEmployeesList","componentEvents","handleReview","employeeId","updateOnboardingStatus","EmployeeOnboardingStatus","handleCancelSelfOnboarding","status","responseData","EmployeeListProvider","onboardingStatus","jsxs","Flex","Head","List","Actions","EmployeeListContextual","useFlow"],"mappings":";;;;;;;;;;;;;;;;AA6BO,SAASA,EAAaC,GAAmD;AAE5E,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AACA,SAASG,EAAK,EAAE,WAAAC,GAAW,WAAAC,GAAW,UAAAC,KAA+B;AAEnE,EAAAC,EAAQ,uBAAuB;AAE/B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,CAACC,GAAaC,CAAc,IAAIC,EAAS,CAAC,GAC1C,CAACC,GAAcC,CAAe,IAAIF,EAAS,CAAC,GAC5CG,IAAcC,EAAe,GAE7B,EAAE,MAAAC,MAASC,EAAyB,EAAE,WAAAf,GAAW,MAAMO,GAAa,KAAKG,GAAc,GACvF,EAAE,UAAAM,GAAU,cAAAC,EAAA,IAAiBH,GAC7BI,IAAYD,GAEZ,EAAE,aAAaE,EAAuB,IAAIC,EAA2B,GACrE,EAAE,aAAaC,EAAuC,IAC1DC,EAA2C,GAEvCC,IAAa,OAAOP,EAAS,SAAS,QAAQ,IAAI,eAAe,KAAK,CAAC,GAEvEQ,IAA2B,CAACC,MAAqB;AACrD,IAAAd,EAAgBc,CAAQ;AAAA,EAC1B,GACMC,IAAkB,MAAM;AAC5B,IAAAlB,EAAe,CAAC;AAAA,EAClB,GACMmB,IAAqB,MAAM;AAC/B,IAAAnB,EAAe,OAAY,KAAK,IAAIoB,IAAW,GAAG,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
-
},
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const BankAccountSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
routingNumber: z.ZodString;
|
|
5
|
+
accountNumber: z.ZodString;
|
|
6
|
+
accountType: z.ZodEnum<["Checking", "Savings"]>;
|
|
7
|
+
hasBankPayload: z.ZodLiteral<true>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
name: string;
|
|
10
|
+
routingNumber: string;
|
|
11
|
+
accountNumber: string;
|
|
12
|
+
accountType: "Checking" | "Savings";
|
|
13
|
+
hasBankPayload: true;
|
|
14
|
+
}, {
|
|
15
|
+
name: string;
|
|
16
|
+
routingNumber: string;
|
|
17
|
+
accountNumber: string;
|
|
18
|
+
accountType: "Checking" | "Savings";
|
|
19
|
+
hasBankPayload: true;
|
|
20
|
+
}>;
|
|
21
|
+
export type BankAccountInputs = z.input<typeof BankAccountSchema>;
|
|
22
|
+
export type BankAccountDefaults = z.input<typeof BankAccountSchema>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { accountNumberValidation as
|
|
3
|
-
const
|
|
4
|
-
name:
|
|
5
|
-
routingNumber:
|
|
6
|
-
accountNumber:
|
|
7
|
-
accountType:
|
|
8
|
-
hasBankPayload: n(!0)
|
|
1
|
+
import { z as n } from "zod";
|
|
2
|
+
import { accountNumberValidation as a, routingNumberValidation as o } from "../../../helpers/validations.js";
|
|
3
|
+
const e = n.object({
|
|
4
|
+
name: n.string().min(1),
|
|
5
|
+
routingNumber: o,
|
|
6
|
+
accountNumber: a,
|
|
7
|
+
accountType: n.enum(["Checking", "Savings"]),
|
|
8
|
+
hasBankPayload: n.literal(!0)
|
|
9
9
|
});
|
|
10
10
|
export {
|
|
11
|
-
|
|
11
|
+
e as BankAccountSchema
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=BankAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BankAccount.js","sources":["../../../../src/components/Employee/PaymentMethod/BankAccount.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"BankAccount.js","sources":["../../../../src/components/Employee/PaymentMethod/BankAccount.ts"],"sourcesContent":["import { z } from 'zod'\nimport { accountNumberValidation, routingNumberValidation } from '@/helpers/validations'\n\nexport const BankAccountSchema = z.object({\n name: z.string().min(1),\n routingNumber: routingNumberValidation,\n accountNumber: accountNumberValidation,\n accountType: z.enum(['Checking', 'Savings']),\n hasBankPayload: z.literal(true),\n})\n\nexport type BankAccountInputs = z.input<typeof BankAccountSchema>\nexport type BankAccountDefaults = z.input<typeof BankAccountSchema>\n"],"names":["BankAccountSchema","z","routingNumberValidation","accountNumberValidation"],"mappings":";;AAGa,MAAAA,IAAoBC,EAAE,OAAO;AAAA,EACxC,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,eAAeC;AAAA,EACf,eAAeC;AAAA,EACf,aAAaF,EAAE,KAAK,CAAC,YAAY,SAAS,CAAC;AAAA,EAC3C,gBAAgBA,EAAE,QAAQ,EAAI;AAChC,CAAC;"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as n, jsxs as U } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { zodResolver as x } from "@hookform/resolvers/zod";
|
|
3
3
|
import { useEmployeePaymentMethodCreateMutation as H } from "@gusto/embedded-api/react-query/employeePaymentMethodCreate";
|
|
4
4
|
import { useEmployeePaymentMethodDeleteBankAccountMutation as R } from "@gusto/embedded-api/react-query/employeePaymentMethodDeleteBankAccount";
|
|
5
5
|
import { useEmployeePaymentMethodsGetBankAccountsSuspense as G, invalidateAllEmployeePaymentMethodsGetBankAccounts as V } from "@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts";
|
|
6
6
|
import { useEmployeePaymentMethodGetSuspense as j, invalidateAllEmployeePaymentMethodGet as K } from "@gusto/embedded-api/react-query/employeePaymentMethodGet";
|
|
7
|
-
import { useEmployeePaymentMethodUpdateBankAccountMutation as
|
|
8
|
-
import { useEmployeePaymentMethodUpdateMutation as
|
|
9
|
-
import { useQueryClient as J } from "@
|
|
10
|
-
import { useCallback as W, useState as X, useMemo as
|
|
7
|
+
import { useEmployeePaymentMethodUpdateBankAccountMutation as z } from "@gusto/embedded-api/react-query/employeePaymentMethodUpdateBankAccount";
|
|
8
|
+
import { useEmployeePaymentMethodUpdateMutation as Q } from "@gusto/embedded-api/react-query/employeePaymentMethodUpdate";
|
|
9
|
+
import { useQueryClient as J } from "@tanstack/react-query";
|
|
10
|
+
import { useCallback as W, useState as X, useMemo as k, useEffect as S } from "react";
|
|
11
11
|
import { useForm as Z, FormProvider as $ } from "react-hook-form";
|
|
12
12
|
import { useTranslation as tt } from "react-i18next";
|
|
13
13
|
import { CombinedSchema as et, PaymentMethodProvider as ot } from "./usePaymentMethod.js";
|
|
14
|
-
import { SPLIT_BY as
|
|
14
|
+
import { SPLIT_BY as b, PAYMENT_METHODS as N } from "./Constants.js";
|
|
15
15
|
import { BaseComponent as nt } from "../../Base/Base.js";
|
|
16
16
|
import { useBase as it } from "../../Base/useBase.js";
|
|
17
17
|
import { Form as st } from "../../Common/Form/Form.js";
|
|
@@ -33,11 +33,11 @@ const At = ({ employeeId: o, className: f }) => {
|
|
|
33
33
|
data: { employeePaymentMethod: L }
|
|
34
34
|
} = j({ employeeId: o }), t = L, { data: w } = G({
|
|
35
35
|
employeeId: o
|
|
36
|
-
}), y = w.employeeBankAccountList, M =
|
|
36
|
+
}), y = w.employeeBankAccountList, M = Q(), B = R(), D = H(), g = z(), a = W(async () => {
|
|
37
37
|
await K(d), await V(d);
|
|
38
38
|
}, [d]), [m, c] = X(y.length < 1 ? "INITIAL" : "LIST");
|
|
39
39
|
m !== "INITIAL" && y.length < 1 && c("INITIAL");
|
|
40
|
-
const T =
|
|
40
|
+
const T = k(() => ({
|
|
41
41
|
type: "Direct Deposit",
|
|
42
42
|
isSplit: !1,
|
|
43
43
|
hasBankPayload: !1,
|
|
@@ -48,7 +48,7 @@ const At = ({ employeeId: o, className: f }) => {
|
|
|
48
48
|
splitBy: void 0,
|
|
49
49
|
splitAmount: {},
|
|
50
50
|
priority: {}
|
|
51
|
-
}), []), u =
|
|
51
|
+
}), []), u = k(() => ({
|
|
52
52
|
...T,
|
|
53
53
|
type: t.type ?? "Direct Deposit",
|
|
54
54
|
splitBy: t.splitBy ?? void 0,
|
|
@@ -67,12 +67,12 @@ const At = ({ employeeId: o, className: f }) => {
|
|
|
67
67
|
resolver: x(et),
|
|
68
68
|
defaultValues: u
|
|
69
69
|
}), C = s.watch("type"), { reset: A } = s, { mutateAsync: v } = M;
|
|
70
|
-
|
|
70
|
+
S(() => {
|
|
71
71
|
(async () => t.splits?.length === 1 && t.type === "Direct Deposit" && (await v({
|
|
72
72
|
request: {
|
|
73
73
|
employeeId: o,
|
|
74
74
|
requestBody: {
|
|
75
|
-
splitBy:
|
|
75
|
+
splitBy: b.percentage,
|
|
76
76
|
splits: t.splits.map((i) => ({
|
|
77
77
|
...i,
|
|
78
78
|
splitAmount: 100,
|
|
@@ -83,7 +83,7 @@ const At = ({ employeeId: o, className: f }) => {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}), await a()))();
|
|
86
|
-
}, [o, a, t, d, v]),
|
|
86
|
+
}, [o, a, t, d, v]), S(() => {
|
|
87
87
|
A(u);
|
|
88
88
|
}, [y.length, t, u, A]);
|
|
89
89
|
const I = async (i) => {
|
|
@@ -106,7 +106,7 @@ const At = ({ employeeId: o, className: f }) => {
|
|
|
106
106
|
const p = r === N.check ? { version: t.version } : {
|
|
107
107
|
...t,
|
|
108
108
|
version: t.version,
|
|
109
|
-
splitBy: e.isSplit ? e.splitBy : t.splitBy ??
|
|
109
|
+
splitBy: e.isSplit ? e.splitBy : t.splitBy ?? b.percentage,
|
|
110
110
|
splits: e.isSplit && t.splits ? t.splits.map((P) => ({
|
|
111
111
|
...P,
|
|
112
112
|
splitAmount: e.splitAmount[P.uuid],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentMethod.js","sources":["../../../../src/components/Employee/PaymentMethod/PaymentMethod.tsx"],"sourcesContent":["import { valibotResolver } from '@hookform/resolvers/valibot'\nimport { useEmployeePaymentMethodCreateMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodCreate'\nimport { useEmployeePaymentMethodDeleteBankAccountMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodDeleteBankAccount'\nimport {\n useEmployeePaymentMethodsGetBankAccountsSuspense,\n invalidateAllEmployeePaymentMethodsGetBankAccounts,\n} from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport {\n useEmployeePaymentMethodGetSuspense,\n invalidateAllEmployeePaymentMethodGet,\n} from '@gusto/embedded-api/react-query/employeePaymentMethodGet'\nimport { useEmployeePaymentMethodUpdateBankAccountMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodUpdateBankAccount'\nimport { useEmployeePaymentMethodUpdateMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodUpdate'\nimport { useQueryClient } from '@gusto/embedded-api/ReactSDKProvider'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { FormProvider, useForm, type DefaultValues, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport {\n CombinedSchema,\n type CombinedSchemaInputs,\n type CombinedSchemaOutputs,\n type MODE,\n PaymentMethodProvider,\n} from './usePaymentMethod'\nimport { PAYMENT_METHODS, SPLIT_BY } from './Constants'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { Form } from '@/components/Common/Form'\nimport { Actions } from '@/components/Employee/PaymentMethod/Actions'\nimport { BankAccountForm } from '@/components/Employee/PaymentMethod/BankAccountEdit'\nimport { BankAccountsList } from '@/components/Employee/PaymentMethod/BankAccountsList'\nimport { Head } from '@/components/Employee/PaymentMethod/Head'\nimport { PaymentTypeForm } from '@/components/Employee/PaymentMethod/PaymentTypeForm'\nimport { Split } from '@/components/Employee/PaymentMethod/Split'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\ninterface PaymentMethodProps extends CommonComponentInterface {\n employeeId: string\n defaultValues?: never\n}\n\nexport function PaymentMethod(props: PaymentMethodProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, className }: PaymentMethodProps) => {\n useI18n('Employee.PaymentMethod')\n const { baseSubmitHandler, onEvent } = useBase()\n const queryClient = useQueryClient()\n\n const {\n data: { employeePaymentMethod },\n } = useEmployeePaymentMethodGetSuspense({ employeeId })\n const paymentMethod = employeePaymentMethod!\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const bankAccounts = bankAccountsList.employeeBankAccountList!\n const paymentMethodMutation = useEmployeePaymentMethodUpdateMutation()\n const deleteBankAccountMutation = useEmployeePaymentMethodDeleteBankAccountMutation()\n const addBankAccountMutation = useEmployeePaymentMethodCreateMutation()\n const updateBankAccountMutation = useEmployeePaymentMethodUpdateBankAccountMutation()\n\n const invalidateAll = useCallback(async () => {\n await invalidateAllEmployeePaymentMethodGet(queryClient)\n await invalidateAllEmployeePaymentMethodsGetBankAccounts(queryClient)\n }, [queryClient])\n\n const [mode, setMode] = useState<MODE>(bankAccounts.length < 1 ? 'INITIAL' : 'LIST')\n if (mode !== 'INITIAL' && bankAccounts.length < 1) {\n setMode('INITIAL')\n }\n\n const baseDefaultValues: Partial<CombinedSchemaOutputs> = useMemo(() => {\n return {\n type: 'Direct Deposit',\n isSplit: false,\n hasBankPayload: false,\n name: '',\n routingNumber: '',\n accountNumber: '',\n accountType: 'Checking',\n splitBy: undefined,\n splitAmount: {},\n priority: {},\n } as Partial<CombinedSchemaOutputs>\n }, [])\n\n const defaultValues: CombinedSchemaOutputs = useMemo(() => {\n return {\n ...baseDefaultValues,\n type: paymentMethod.type ?? 'Direct Deposit',\n splitBy: paymentMethod.splitBy ?? undefined,\n ...paymentMethod.splits?.reduce(\n (acc, { uuid, splitAmount, priority }) => ({\n splitAmount: { ...acc.splitAmount, [uuid]: splitAmount ?? null },\n priority: { ...acc.priority, [uuid]: Number(priority) },\n }),\n { splitAmount: {}, priority: {} },\n ),\n remainder:\n paymentMethod.type === 'Direct Deposit' && paymentMethod.splits\n ? paymentMethod.splits.reduce(\n (acc, curr) =>\n curr.splitAmount === null ? curr.uuid : (paymentMethod.splits?.at(-1)?.uuid ?? acc),\n '',\n )\n : undefined,\n } as CombinedSchemaOutputs\n }, [baseDefaultValues, paymentMethod.type, paymentMethod.splitBy, paymentMethod.splits])\n\n const formMethods = useForm<CombinedSchemaInputs>({\n resolver: valibotResolver(CombinedSchema),\n defaultValues: defaultValues as DefaultValues<CombinedSchemaInputs>,\n })\n\n const watchedType = formMethods.watch('type')\n\n const { reset: resetForm } = formMethods\n const { mutateAsync: mutatePaymentMethod } = paymentMethodMutation\n\n useEffect(() => {\n void (async () => {\n if (paymentMethod.splits?.length === 1 && paymentMethod.type === 'Direct Deposit') {\n await mutatePaymentMethod({\n request: {\n employeeId,\n requestBody: {\n splitBy: SPLIT_BY.percentage,\n splits: paymentMethod.splits.map(split => ({\n ...split,\n splitAmount: 100,\n priority: 1,\n })),\n version: paymentMethod.version as string,\n type: 'Direct Deposit',\n },\n },\n })\n await invalidateAll()\n }\n })()\n }, [employeeId, invalidateAll, paymentMethod, queryClient, mutatePaymentMethod])\n\n useEffect(() => {\n resetForm(defaultValues)\n }, [bankAccounts.length, paymentMethod, defaultValues, resetForm])\n\n const onSubmit: SubmitHandler<CombinedSchemaInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { type } = payload\n if (\n type === 'Direct Deposit' &&\n payload.hasBankPayload &&\n (mode === 'ADD' || mode === 'INITIAL')\n ) {\n const bankAccountResponse = await addBankAccountMutation.mutateAsync({\n request: {\n employeeId,\n requestBody: {\n name: payload.name,\n routingNumber: payload.routingNumber,\n accountNumber: payload.accountNumber,\n accountType: payload.accountType,\n },\n },\n })\n await invalidateAll()\n\n onEvent(componentEvents.EMPLOYEE_BANK_ACCOUNT_CREATED, bankAccountResponse)\n } else {\n //Adding bank account updates payment method\n const body =\n type === PAYMENT_METHODS.check\n ? { version: paymentMethod.version as string }\n : {\n ...paymentMethod,\n version: paymentMethod.version as string,\n splitBy: payload.isSplit\n ? payload.splitBy\n : (paymentMethod.splitBy ?? SPLIT_BY.percentage),\n splits:\n payload.isSplit && paymentMethod.splits\n ? paymentMethod.splits.map(split => ({\n ...split,\n splitAmount: payload.splitAmount[split.uuid],\n priority: payload.priority[split.uuid],\n }))\n : (paymentMethod.splits ?? []),\n }\n const paymentMethodResponse = await paymentMethodMutation.mutateAsync({\n request: { employeeId, requestBody: { ...body, type } },\n })\n await invalidateAll()\n onEvent(componentEvents.EMPLOYEE_PAYMENT_METHOD_UPDATED, paymentMethodResponse)\n }\n //Cleanup after submission bank/split submission\n formMethods.setValue('isSplit', false)\n formMethods.setValue('hasBankPayload', false)\n //Notify that this component is ready to proceed\n if (mode === 'LIST' || type === PAYMENT_METHODS.check) {\n onEvent(componentEvents.EMPLOYEE_PAYMENT_METHOD_DONE)\n } else {\n setMode('LIST')\n }\n })\n }\n\n const handleDelete = async (uuid: string) => {\n const data = await deleteBankAccountMutation.mutateAsync({\n request: { employeeId, bankAccountUuid: uuid },\n })\n await invalidateAll()\n onEvent(componentEvents.EMPLOYEE_BANK_ACCOUNT_DELETED, data)\n }\n const handleAdd = () => {\n setMode('ADD')\n resetForm(defaultValues)\n }\n const handleCancel = () => {\n setMode('LIST')\n resetForm(defaultValues)\n }\n const handleSplit = () => {\n setMode('SPLIT')\n }\n\n return (\n <section className={className}>\n <PaymentMethodProvider\n value={{\n bankAccounts,\n isPending:\n deleteBankAccountMutation.isPending ||\n paymentMethodMutation.isPending ||\n addBankAccountMutation.isPending ||\n updateBankAccountMutation.isPending,\n watchedType,\n mode,\n paymentMethod,\n handleCancel,\n handleAdd,\n handleDelete,\n handleSplit,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Head />\n <PaymentTypeForm />\n <BankAccountsList />\n <BankAccountForm />\n <Split />\n <Actions />\n </Form>\n </FormProvider>\n </PaymentMethodProvider>\n </section>\n )\n}\n\nexport const PaymentMethodContextual = () => {\n const { employeeId, onEvent } = useFlow<EmployeeOnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'PaymentMethod',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <PaymentMethod employeeId={employeeId} onEvent={onEvent} />\n}\n"],"names":["PaymentMethod","props","jsx","BaseComponent","Root","employeeId","className","useI18n","baseSubmitHandler","onEvent","useBase","queryClient","useQueryClient","employeePaymentMethod","useEmployeePaymentMethodGetSuspense","paymentMethod","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","bankAccounts","paymentMethodMutation","useEmployeePaymentMethodUpdateMutation","deleteBankAccountMutation","useEmployeePaymentMethodDeleteBankAccountMutation","addBankAccountMutation","useEmployeePaymentMethodCreateMutation","updateBankAccountMutation","useEmployeePaymentMethodUpdateBankAccountMutation","invalidateAll","useCallback","invalidateAllEmployeePaymentMethodGet","invalidateAllEmployeePaymentMethodsGetBankAccounts","mode","setMode","useState","baseDefaultValues","useMemo","defaultValues","acc","uuid","splitAmount","priority","curr","formMethods","useForm","valibotResolver","CombinedSchema","watchedType","resetForm","mutatePaymentMethod","useEffect","SPLIT_BY","split","onSubmit","data","payload","type","bankAccountResponse","componentEvents","body","PAYMENT_METHODS","paymentMethodResponse","handleDelete","handleAdd","handleCancel","handleSplit","PaymentMethodProvider","FormProvider","jsxs","Form","Head","PaymentTypeForm","BankAccountsList","BankAccountForm","Split","Actions","PaymentMethodContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgDO,SAASA,GAAcC,GAAoD;AAE9E,SAAA,gBAAAC,EAACC,IAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,MAAMG,KAAO,CAAC,EAAE,YAAAC,GAAY,WAAAC,QAAoC;AAC9D,EAAAC,GAAQ,wBAAwB;AAChC,QAAM,EAAE,mBAAAC,GAAmB,SAAAC,EAAQ,IAAIC,GAAQ,GACzCC,IAAcC,EAAe,GAE7B;AAAA,IACJ,MAAM,EAAE,uBAAAC,EAAsB;AAAA,EAAA,IAC5BC,EAAoC,EAAE,YAAAT,GAAY,GAChDU,IAAgBF,GAChB,EAAE,MAAMG,EAAiB,IAAIC,EAAiD;AAAA,IAClF,YAAAZ;AAAA,EAAA,CACD,GACKa,IAAeF,EAAiB,yBAChCG,IAAwBC,EAAuC,GAC/DC,IAA4BC,EAAkD,GAC9EC,IAAyBC,EAAuC,GAChEC,IAA4BC,EAAkD,GAE9EC,IAAgBC,EAAY,YAAY;AAC5C,UAAMC,EAAsClB,CAAW,GACvD,MAAMmB,EAAmDnB,CAAW;AAAA,EAAA,GACnE,CAACA,CAAW,CAAC,GAEV,CAACoB,GAAMC,CAAO,IAAIC,EAAef,EAAa,SAAS,IAAI,YAAY,MAAM;AACnF,EAAIa,MAAS,aAAab,EAAa,SAAS,KAC9Cc,EAAQ,SAAS;AAGb,QAAAE,IAAoDC,EAAQ,OACzD;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,eAAe;AAAA,IACf,eAAe;AAAA,IACf,aAAa;AAAA,IACb,SAAS;AAAA,IACT,aAAa,CAAC;AAAA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,UAAA,gBAAAyB,EAACC,MAAK,UAAU1B,EAAY,aAAaU,CAAQ,GAC/C,UAAA;AAAA,QAAA,gBAAAlD,EAACmE,IAAK,EAAA;AAAA,0BACLC,IAAgB,EAAA;AAAA,0BAChBC,IAAiB,EAAA;AAAA,0BACjBC,IAAgB,EAAA;AAAA,0BAChBC,IAAM,EAAA;AAAA,0BACNC,IAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ,GAEaC,KAA0B,MAAM;AAC3C,QAAM,EAAE,YAAAtE,GAAY,SAAAI,EAAQ,IAAImE,GAA4C,GACtE,EAAE,GAAAC,EAAA,IAAMC,GAAe,QAAQ;AAErC,MAAI,CAACzE;AACH,UAAM,IAAI;AAAA,MACRwE,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAO;AAAA,QACP,UAAU;AAAA,MACX,CAAA;AAAA,IACH;AAEK,SAAA,gBAAA3E,EAACF,IAAc,EAAA,YAAAK,GAAwB,SAAAI,EAAkB,CAAA;AAClE;"}
|
|
1
|
+
{"version":3,"file":"PaymentMethod.js","sources":["../../../../src/components/Employee/PaymentMethod/PaymentMethod.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useEmployeePaymentMethodCreateMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodCreate'\nimport { useEmployeePaymentMethodDeleteBankAccountMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodDeleteBankAccount'\nimport {\n useEmployeePaymentMethodsGetBankAccountsSuspense,\n invalidateAllEmployeePaymentMethodsGetBankAccounts,\n} from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport {\n useEmployeePaymentMethodGetSuspense,\n invalidateAllEmployeePaymentMethodGet,\n} from '@gusto/embedded-api/react-query/employeePaymentMethodGet'\nimport { useEmployeePaymentMethodUpdateBankAccountMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodUpdateBankAccount'\nimport { useEmployeePaymentMethodUpdateMutation } from '@gusto/embedded-api/react-query/employeePaymentMethodUpdate'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { FormProvider, useForm, type DefaultValues, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport {\n CombinedSchema,\n type CombinedSchemaInputs,\n type CombinedSchemaOutputs,\n type MODE,\n PaymentMethodProvider,\n} from './usePaymentMethod'\nimport { PAYMENT_METHODS, SPLIT_BY } from './Constants'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { Form } from '@/components/Common/Form'\nimport { Actions } from '@/components/Employee/PaymentMethod/Actions'\nimport { BankAccountForm } from '@/components/Employee/PaymentMethod/BankAccountEdit'\nimport { BankAccountsList } from '@/components/Employee/PaymentMethod/BankAccountsList'\nimport { Head } from '@/components/Employee/PaymentMethod/Head'\nimport { PaymentTypeForm } from '@/components/Employee/PaymentMethod/PaymentTypeForm'\nimport { Split } from '@/components/Employee/PaymentMethod/Split'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\ninterface PaymentMethodProps extends CommonComponentInterface {\n employeeId: string\n defaultValues?: never\n}\n\nexport function PaymentMethod(props: PaymentMethodProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, className }: PaymentMethodProps) => {\n useI18n('Employee.PaymentMethod')\n const { baseSubmitHandler, onEvent } = useBase()\n const queryClient = useQueryClient()\n\n const {\n data: { employeePaymentMethod },\n } = useEmployeePaymentMethodGetSuspense({ employeeId })\n const paymentMethod = employeePaymentMethod!\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const bankAccounts = bankAccountsList.employeeBankAccountList!\n const paymentMethodMutation = useEmployeePaymentMethodUpdateMutation()\n const deleteBankAccountMutation = useEmployeePaymentMethodDeleteBankAccountMutation()\n const addBankAccountMutation = useEmployeePaymentMethodCreateMutation()\n const updateBankAccountMutation = useEmployeePaymentMethodUpdateBankAccountMutation()\n\n const invalidateAll = useCallback(async () => {\n await invalidateAllEmployeePaymentMethodGet(queryClient)\n await invalidateAllEmployeePaymentMethodsGetBankAccounts(queryClient)\n }, [queryClient])\n\n const [mode, setMode] = useState<MODE>(bankAccounts.length < 1 ? 'INITIAL' : 'LIST')\n if (mode !== 'INITIAL' && bankAccounts.length < 1) {\n setMode('INITIAL')\n }\n\n const baseDefaultValues: Partial<CombinedSchemaOutputs> = useMemo(() => {\n return {\n type: 'Direct Deposit',\n isSplit: false,\n hasBankPayload: false,\n name: '',\n routingNumber: '',\n accountNumber: '',\n accountType: 'Checking',\n splitBy: undefined,\n splitAmount: {},\n priority: {},\n } as Partial<CombinedSchemaOutputs>\n }, [])\n\n const defaultValues: CombinedSchemaOutputs = useMemo(() => {\n return {\n ...baseDefaultValues,\n type: paymentMethod.type ?? 'Direct Deposit',\n splitBy: paymentMethod.splitBy ?? undefined,\n ...paymentMethod.splits?.reduce(\n (acc, { uuid, splitAmount, priority }) => ({\n splitAmount: { ...acc.splitAmount, [uuid]: splitAmount ?? null },\n priority: { ...acc.priority, [uuid]: Number(priority) },\n }),\n { splitAmount: {}, priority: {} },\n ),\n remainder:\n paymentMethod.type === 'Direct Deposit' && paymentMethod.splits\n ? paymentMethod.splits.reduce(\n (acc, curr) =>\n curr.splitAmount === null ? curr.uuid : (paymentMethod.splits?.at(-1)?.uuid ?? acc),\n '',\n )\n : undefined,\n } as CombinedSchemaOutputs\n }, [baseDefaultValues, paymentMethod.type, paymentMethod.splitBy, paymentMethod.splits])\n\n const formMethods = useForm<CombinedSchemaInputs>({\n resolver: zodResolver(CombinedSchema),\n defaultValues: defaultValues as DefaultValues<CombinedSchemaInputs>,\n })\n\n const watchedType = formMethods.watch('type')\n\n const { reset: resetForm } = formMethods\n const { mutateAsync: mutatePaymentMethod } = paymentMethodMutation\n\n useEffect(() => {\n void (async () => {\n if (paymentMethod.splits?.length === 1 && paymentMethod.type === 'Direct Deposit') {\n await mutatePaymentMethod({\n request: {\n employeeId,\n requestBody: {\n splitBy: SPLIT_BY.percentage,\n splits: paymentMethod.splits.map(split => ({\n ...split,\n splitAmount: 100,\n priority: 1,\n })),\n version: paymentMethod.version as string,\n type: 'Direct Deposit',\n },\n },\n })\n await invalidateAll()\n }\n })()\n }, [employeeId, invalidateAll, paymentMethod, queryClient, mutatePaymentMethod])\n\n useEffect(() => {\n resetForm(defaultValues)\n }, [bankAccounts.length, paymentMethod, defaultValues, resetForm])\n\n const onSubmit: SubmitHandler<CombinedSchemaInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { type } = payload\n if (\n type === 'Direct Deposit' &&\n payload.hasBankPayload &&\n (mode === 'ADD' || mode === 'INITIAL')\n ) {\n const bankAccountResponse = await addBankAccountMutation.mutateAsync({\n request: {\n employeeId,\n requestBody: {\n name: payload.name,\n routingNumber: payload.routingNumber,\n accountNumber: payload.accountNumber,\n accountType: payload.accountType,\n },\n },\n })\n await invalidateAll()\n\n onEvent(componentEvents.EMPLOYEE_BANK_ACCOUNT_CREATED, bankAccountResponse)\n } else {\n //Adding bank account updates payment method\n const body =\n type === PAYMENT_METHODS.check\n ? { version: paymentMethod.version as string }\n : {\n ...paymentMethod,\n version: paymentMethod.version as string,\n splitBy: payload.isSplit\n ? payload.splitBy\n : (paymentMethod.splitBy ?? SPLIT_BY.percentage),\n splits:\n payload.isSplit && paymentMethod.splits\n ? paymentMethod.splits.map(split => ({\n ...split,\n splitAmount: payload.splitAmount[split.uuid],\n priority: payload.priority[split.uuid],\n }))\n : (paymentMethod.splits ?? []),\n }\n const paymentMethodResponse = await paymentMethodMutation.mutateAsync({\n request: { employeeId, requestBody: { ...body, type } },\n })\n await invalidateAll()\n onEvent(componentEvents.EMPLOYEE_PAYMENT_METHOD_UPDATED, paymentMethodResponse)\n }\n //Cleanup after submission bank/split submission\n formMethods.setValue('isSplit', false)\n formMethods.setValue('hasBankPayload', false)\n //Notify that this component is ready to proceed\n if (mode === 'LIST' || type === PAYMENT_METHODS.check) {\n onEvent(componentEvents.EMPLOYEE_PAYMENT_METHOD_DONE)\n } else {\n setMode('LIST')\n }\n })\n }\n\n const handleDelete = async (uuid: string) => {\n const data = await deleteBankAccountMutation.mutateAsync({\n request: { employeeId, bankAccountUuid: uuid },\n })\n await invalidateAll()\n onEvent(componentEvents.EMPLOYEE_BANK_ACCOUNT_DELETED, data)\n }\n const handleAdd = () => {\n setMode('ADD')\n resetForm(defaultValues)\n }\n const handleCancel = () => {\n setMode('LIST')\n resetForm(defaultValues)\n }\n const handleSplit = () => {\n setMode('SPLIT')\n }\n\n return (\n <section className={className}>\n <PaymentMethodProvider\n value={{\n bankAccounts,\n isPending:\n deleteBankAccountMutation.isPending ||\n paymentMethodMutation.isPending ||\n addBankAccountMutation.isPending ||\n updateBankAccountMutation.isPending,\n watchedType,\n mode,\n paymentMethod,\n handleCancel,\n handleAdd,\n handleDelete,\n handleSplit,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Head />\n <PaymentTypeForm />\n <BankAccountsList />\n <BankAccountForm />\n <Split />\n <Actions />\n </Form>\n </FormProvider>\n </PaymentMethodProvider>\n </section>\n )\n}\n\nexport const PaymentMethodContextual = () => {\n const { employeeId, onEvent } = useFlow<EmployeeOnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'PaymentMethod',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <PaymentMethod employeeId={employeeId} onEvent={onEvent} />\n}\n"],"names":["PaymentMethod","props","jsx","BaseComponent","Root","employeeId","className","useI18n","baseSubmitHandler","onEvent","useBase","queryClient","useQueryClient","employeePaymentMethod","useEmployeePaymentMethodGetSuspense","paymentMethod","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","bankAccounts","paymentMethodMutation","useEmployeePaymentMethodUpdateMutation","deleteBankAccountMutation","useEmployeePaymentMethodDeleteBankAccountMutation","addBankAccountMutation","useEmployeePaymentMethodCreateMutation","updateBankAccountMutation","useEmployeePaymentMethodUpdateBankAccountMutation","invalidateAll","useCallback","invalidateAllEmployeePaymentMethodGet","invalidateAllEmployeePaymentMethodsGetBankAccounts","mode","setMode","useState","baseDefaultValues","useMemo","defaultValues","acc","uuid","splitAmount","priority","curr","formMethods","useForm","zodResolver","CombinedSchema","watchedType","resetForm","mutatePaymentMethod","useEffect","SPLIT_BY","split","onSubmit","data","payload","type","bankAccountResponse","componentEvents","body","PAYMENT_METHODS","paymentMethodResponse","handleDelete","handleAdd","handleCancel","handleSplit","PaymentMethodProvider","FormProvider","jsxs","Form","Head","PaymentTypeForm","BankAccountsList","BankAccountForm","Split","Actions","PaymentMethodContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgDO,SAASA,GAAcC,GAAoD;AAE9E,SAAA,gBAAAC,EAACC,IAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,MAAMG,KAAO,CAAC,EAAE,YAAAC,GAAY,WAAAC,QAAoC;AAC9D,EAAAC,GAAQ,wBAAwB;AAChC,QAAM,EAAE,mBAAAC,GAAmB,SAAAC,EAAQ,IAAIC,GAAQ,GACzCC,IAAcC,EAAe,GAE7B;AAAA,IACJ,MAAM,EAAE,uBAAAC,EAAsB;AAAA,EAAA,IAC5BC,EAAoC,EAAE,YAAAT,GAAY,GAChDU,IAAgBF,GAChB,EAAE,MAAMG,EAAiB,IAAIC,EAAiD;AAAA,IAClF,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AAAK,GAAwB,SAAAI,EAAkB,CAAA;AAClE;"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const PaymentTypeSchema:
|
|
3
|
-
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PaymentTypeSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodEnum<["Check", "Direct Deposit"]>;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
type: "Check" | "Direct Deposit";
|
|
6
|
+
}, {
|
|
7
|
+
type: "Check" | "Direct Deposit";
|
|
8
|
+
}>;
|
|
9
|
+
export type PaymentTypeInputs = z.input<typeof PaymentTypeSchema>;
|
|
10
|
+
export type PaymentTypePayload = z.output<typeof PaymentTypeSchema>;
|
|
7
11
|
export declare function PaymentTypeForm(): import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as p } from "react-i18next";
|
|
3
|
-
import
|
|
4
|
-
import { usePaymentMethod as
|
|
3
|
+
import { z as o } from "zod";
|
|
4
|
+
import { usePaymentMethod as m } from "./usePaymentMethod.js";
|
|
5
5
|
import { PAYMENT_METHODS as i } from "./Constants.js";
|
|
6
|
-
import { RadioGroupField as
|
|
6
|
+
import { RadioGroupField as n } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
7
7
|
o.object({
|
|
8
|
-
type: o.
|
|
8
|
+
type: o.enum(["Check", "Direct Deposit"])
|
|
9
9
|
});
|
|
10
|
-
function
|
|
11
|
-
const { mode: t } =
|
|
10
|
+
function y() {
|
|
11
|
+
const { mode: t } = m(), { t: e } = p("Employee.PaymentMethod");
|
|
12
12
|
if (!(t !== "INITIAL" && t !== "LIST"))
|
|
13
13
|
return /* @__PURE__ */ r(
|
|
14
|
-
|
|
14
|
+
n,
|
|
15
15
|
{
|
|
16
16
|
name: "type",
|
|
17
17
|
label: e("paymentFieldsetLegend"),
|
|
@@ -32,6 +32,6 @@ function u() {
|
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
export {
|
|
35
|
-
|
|
35
|
+
y as PaymentTypeForm
|
|
36
36
|
};
|
|
37
37
|
//# sourceMappingURL=PaymentTypeForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentTypeForm.js","sources":["../../../../src/components/Employee/PaymentMethod/PaymentTypeForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport
|
|
1
|
+
{"version":3,"file":"PaymentTypeForm.js","sources":["../../../../src/components/Employee/PaymentMethod/PaymentTypeForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { usePaymentMethod } from './usePaymentMethod'\nimport { PAYMENT_METHODS } from './Constants'\nimport { RadioGroupField } from '@/components/Common'\n\nexport const PaymentTypeSchema = z.object({\n type: z.enum(['Check', 'Direct Deposit']),\n})\nexport type PaymentTypeInputs = z.input<typeof PaymentTypeSchema>\nexport type PaymentTypePayload = z.output<typeof PaymentTypeSchema>\n\nexport function PaymentTypeForm() {\n const { mode } = usePaymentMethod()\n const { t } = useTranslation('Employee.PaymentMethod')\n if (mode !== 'INITIAL' && mode !== 'LIST') return\n return (\n <RadioGroupField\n name=\"type\"\n label={t('paymentFieldsetLegend')}\n shouldVisuallyHideLabel\n options={[\n {\n value: PAYMENT_METHODS.directDeposit,\n label: t('directDepositLabel'),\n description: t('directDepositDescription'),\n },\n {\n value: PAYMENT_METHODS.check,\n label: t('checkLabel'),\n description: t('checkDescription'),\n },\n ]}\n />\n )\n}\n"],"names":["z","PaymentTypeForm","mode","usePaymentMethod","t","useTranslation","jsx","RadioGroupField","PAYMENT_METHODS"],"mappings":";;;;;;AAMiCA,EAAE,OAAO;AAAA,EACxC,MAAMA,EAAE,KAAK,CAAC,SAAS,gBAAgB,CAAC;AAC1C,CAAC;AAIM,SAASC,IAAkB;AAC1B,QAAA,EAAE,MAAAC,EAAK,IAAIC,EAAiB,GAC5B,EAAE,GAAAC,EAAA,IAAMC,EAAe,wBAAwB;AACjD,MAAA,EAAAH,MAAS,aAAaA,MAAS;AAEjC,WAAA,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOH,EAAE,uBAAuB;AAAA,QAChC,yBAAuB;AAAA,QACvB,SAAS;AAAA,UACP;AAAA,YACE,OAAOI,EAAgB;AAAA,YACvB,OAAOJ,EAAE,oBAAoB;AAAA,YAC7B,aAAaA,EAAE,0BAA0B;AAAA,UAC3C;AAAA,UACA;AAAA,YACE,OAAOI,EAAgB;AAAA,YACvB,OAAOJ,EAAE,YAAY;AAAA,YACrB,aAAaA,EAAE,kBAAkB;AAAA,UAAA;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAEJ;"}
|