@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
|
@@ -2,8 +2,8 @@ import { PayScheduleCreateUpdate } from '@gusto/embedded-api/models/components/p
|
|
|
2
2
|
import { PayScheduleList } from '@gusto/embedded-api/models/components/payschedulelist';
|
|
3
3
|
import { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject';
|
|
4
4
|
import { PayPeriods } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayschedulespreview';
|
|
5
|
+
import { z } from 'zod';
|
|
5
6
|
import { RequireAtLeastOne } from '../../../types/Helpers';
|
|
6
|
-
import * as v from 'valibot';
|
|
7
7
|
export type MODE = 'LIST_PAY_SCHEDULES' | 'ADD_PAY_SCHEDULE' | 'EDIT_PAY_SCHEDULE' | 'PREVIEW_PAY_SCHEDULE';
|
|
8
8
|
type PayScheduleContextType = {
|
|
9
9
|
companyId: string;
|
|
@@ -17,18 +17,36 @@ type PayScheduleContextType = {
|
|
|
17
17
|
payPeriodPreview?: PayPeriods[];
|
|
18
18
|
payPreviewLoading?: boolean;
|
|
19
19
|
};
|
|
20
|
-
export declare const PayScheduleSchema:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
export declare const PayScheduleSchema: z.ZodObject<{
|
|
21
|
+
frequency: z.ZodEnum<["Every week", "Every other week", "Twice per month", "Monthly"]>;
|
|
22
|
+
anchorPayDate: z.ZodOptional<z.ZodDate>;
|
|
23
|
+
anchorEndOfPayPeriod: z.ZodOptional<z.ZodDate>;
|
|
24
|
+
day1: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
day2: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
customName: z.ZodOptional<z.ZodString>;
|
|
27
|
+
customTwicePerMonth: z.ZodOptional<z.ZodString>;
|
|
28
|
+
payPeriodPreviewRange: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
frequency: "Every week" | "Every other week" | "Twice per month" | "Monthly";
|
|
31
|
+
anchorPayDate?: Date | undefined;
|
|
32
|
+
anchorEndOfPayPeriod?: Date | undefined;
|
|
33
|
+
day1?: number | undefined;
|
|
34
|
+
day2?: number | undefined;
|
|
35
|
+
customName?: string | undefined;
|
|
36
|
+
customTwicePerMonth?: string | undefined;
|
|
37
|
+
payPeriodPreviewRange?: number | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
frequency: "Every week" | "Every other week" | "Twice per month" | "Monthly";
|
|
40
|
+
anchorPayDate?: Date | undefined;
|
|
41
|
+
anchorEndOfPayPeriod?: Date | undefined;
|
|
42
|
+
day1?: number | undefined;
|
|
43
|
+
day2?: number | undefined;
|
|
44
|
+
customName?: string | undefined;
|
|
45
|
+
customTwicePerMonth?: string | undefined;
|
|
46
|
+
payPeriodPreviewRange?: number | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
export type PayScheduleInputs = z.input<typeof PayScheduleSchema>;
|
|
49
|
+
export type PayScheduleOutputs = z.output<typeof PayScheduleSchema>;
|
|
32
50
|
export type PayScheduleDefaultValues = RequireAtLeastOne<Partial<Pick<PayScheduleCreateUpdate, 'anchorPayDate' | 'anchorEndOfPayPeriod' | 'day1' | 'day2' | 'customName' | 'frequency'>>>;
|
|
33
51
|
declare const usePaySchedule: () => PayScheduleContextType, PayScheduleProvider: import('react').Provider<PayScheduleContextType | null>;
|
|
34
52
|
export { usePaySchedule, PayScheduleProvider };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z as o } from "zod";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
4
|
import "react-error-boundary";
|
|
@@ -9,25 +9,20 @@ 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
|
|
14
|
-
frequency:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
day2: e.optional(e.pipe(e.number(), e.minValue(1), e.maxValue(31))),
|
|
24
|
-
customName: e.optional(e.string()),
|
|
25
|
-
customTwicePerMonth: e.optional(e.string()),
|
|
26
|
-
payPeriodPreviewRange: e.optional(e.number())
|
|
27
|
-
}), [h, P] = o("PayScheduleContext");
|
|
12
|
+
import { createCompoundContext as e } from "../../Base/createCompoundContext.js";
|
|
13
|
+
const h = o.object({
|
|
14
|
+
frequency: o.enum(["Every week", "Every other week", "Twice per month", "Monthly"]),
|
|
15
|
+
anchorPayDate: o.date().optional(),
|
|
16
|
+
anchorEndOfPayPeriod: o.date().optional(),
|
|
17
|
+
day1: o.number().min(1).max(31).optional(),
|
|
18
|
+
day2: o.number().min(1).max(31).optional(),
|
|
19
|
+
customName: o.string().optional(),
|
|
20
|
+
customTwicePerMonth: o.string().optional(),
|
|
21
|
+
payPeriodPreviewRange: o.number().optional()
|
|
22
|
+
}), [P, s] = e("PayScheduleContext");
|
|
28
23
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
s as PayScheduleProvider,
|
|
25
|
+
h as PayScheduleSchema,
|
|
26
|
+
P as usePaySchedule
|
|
32
27
|
};
|
|
33
28
|
//# sourceMappingURL=usePaySchedule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/usePaySchedule.ts"],"sourcesContent":["import type { PayScheduleCreateUpdate } from '@gusto/embedded-api/models/components/payschedulecreateupdate'\nimport type { PayScheduleList } from '@gusto/embedded-api/models/components/payschedulelist'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { PayPeriods } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayschedulespreview'\nimport
|
|
1
|
+
{"version":3,"file":"usePaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/usePaySchedule.ts"],"sourcesContent":["import type { PayScheduleCreateUpdate } from '@gusto/embedded-api/models/components/payschedulecreateupdate'\nimport type { PayScheduleList } from '@gusto/embedded-api/models/components/payschedulelist'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { PayPeriods } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayschedulespreview'\nimport { z } from 'zod'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport { createCompoundContext } from '@/components/Base'\n\nexport type MODE =\n | 'LIST_PAY_SCHEDULES'\n | 'ADD_PAY_SCHEDULE'\n | 'EDIT_PAY_SCHEDULE'\n | 'PREVIEW_PAY_SCHEDULE'\n\ntype PayScheduleContextType = {\n companyId: string\n handleAdd: () => void\n handleEdit: (schedule: PayScheduleType) => void\n handleCancel: () => void\n handleContinue: () => void\n mode: MODE\n paySchedules: PayScheduleList[] | undefined | null\n currentPaySchedule: PayScheduleType | undefined | null\n payPeriodPreview?: PayPeriods[]\n payPreviewLoading?: boolean\n}\n\nexport const PayScheduleSchema = z.object({\n frequency: z.enum(['Every week', 'Every other week', 'Twice per month', 'Monthly']),\n anchorPayDate: z.date().optional(),\n anchorEndOfPayPeriod: z.date().optional(),\n day1: z.number().min(1).max(31).optional(),\n day2: z.number().min(1).max(31).optional(),\n customName: z.string().optional(),\n customTwicePerMonth: z.string().optional(),\n payPeriodPreviewRange: z.number().optional(),\n})\n\nexport type PayScheduleInputs = z.input<typeof PayScheduleSchema>\nexport type PayScheduleOutputs = z.output<typeof PayScheduleSchema>\n\nexport type PayScheduleDefaultValues = RequireAtLeastOne<\n Partial<\n Pick<\n PayScheduleCreateUpdate,\n 'anchorPayDate' | 'anchorEndOfPayPeriod' | 'day1' | 'day2' | 'customName' | 'frequency'\n >\n >\n>\n\nconst [usePaySchedule, PayScheduleProvider] =\n createCompoundContext<PayScheduleContextType>('PayScheduleContext')\nexport { usePaySchedule, PayScheduleProvider }\n"],"names":["PayScheduleSchema","z","usePaySchedule","PayScheduleProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;AA2Ba,MAAAA,IAAoBC,EAAE,OAAO;AAAA,EACxC,WAAWA,EAAE,KAAK,CAAC,cAAc,oBAAoB,mBAAmB,SAAS,CAAC;AAAA,EAClF,eAAeA,EAAE,KAAK,EAAE,SAAS;AAAA,EACjC,sBAAsBA,EAAE,KAAK,EAAE,SAAS;AAAA,EACxC,MAAMA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EACzC,MAAMA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EACzC,YAAYA,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,qBAAqBA,EAAE,OAAO,EAAE,SAAS;AAAA,EACzC,uBAAuBA,EAAE,OAAO,EAAE,SAAS;AAC7C,CAAC,GAcK,CAACC,GAAgBC,CAAmB,IACxCC,EAA8C,oBAAoB;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const StateFormSchema:
|
|
3
|
-
export type StateFormInputs =
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const StateFormSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3
|
+
export type StateFormInputs = z.infer<typeof StateFormSchema>;
|
|
4
4
|
export declare function Form(): import("react/jsx-runtime").JSX.Element[] | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as m, Fragment as f, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { z as t } from "zod";
|
|
3
3
|
import { useTranslation as u } from "react-i18next";
|
|
4
4
|
import { useStateTaxesForm as x } from "./context.js";
|
|
5
5
|
import { QuestionInput as l } from "../../../Common/TaxInputs/TaxInputs.js";
|
|
6
6
|
import { useLocaleDateFormatter as T } from "../../../../contexts/LocaleProvider/useLocale.js";
|
|
7
7
|
import { useComponentContext as h } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
8
8
|
t.record(t.string(), t.record(t.string(), t.unknown()));
|
|
9
|
-
function
|
|
9
|
+
function w() {
|
|
10
10
|
const { t: s } = u("Company.StateTaxes", { keyPrefix: "form" }), i = T(), { stateTaxRequirements: p } = x(), r = h();
|
|
11
11
|
return p.requirementSets?.map(
|
|
12
12
|
({ requirements: c, label: d, effectiveFrom: n, key: a }) => /* @__PURE__ */ m(f, { children: [
|
|
@@ -29,6 +29,6 @@ function j() {
|
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
w as Form
|
|
33
33
|
};
|
|
34
34
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/Form.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/Form.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { useTranslation } from 'react-i18next'\nimport { Fragment } from 'react/jsx-runtime'\nimport { useStateTaxesForm } from './context'\nimport { QuestionInput } from '@/components/Common/TaxInputs/TaxInputs'\nimport { useLocaleDateFormatter } from '@/contexts/LocaleProvider/useLocale'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const StateFormSchema = z.record(z.string(), z.record(z.string(), z.unknown()))\n\nexport type StateFormInputs = z.infer<typeof StateFormSchema>\n\nexport function Form() {\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const dateFormatter = useLocaleDateFormatter()\n const { stateTaxRequirements } = useStateTaxesForm()\n const Components = useComponentContext()\n\n return stateTaxRequirements.requirementSets?.map(\n ({ requirements, label, effectiveFrom, key }) => (\n <Fragment key={key}>\n <div>\n <Components.Heading as=\"h4\">{label}</Components.Heading>\n {effectiveFrom && (\n <Components.Text className=\"lightText\">\n {t('effectiveFromLabel', { date: dateFormatter.format(new Date(effectiveFrom)) })}\n </Components.Text>\n )}\n </div>\n {requirements?.map(requirement => {\n return (\n <QuestionInput\n requirement={{\n ...requirement,\n key: `${key}.${requirement.key as string}`,\n }}\n questionType={requirement.metadata?.type ?? 'Text'}\n key={requirement.key}\n />\n )\n })}\n </Fragment>\n ),\n )\n}\n"],"names":["z","Form","t","useTranslation","dateFormatter","useLocaleDateFormatter","stateTaxRequirements","useStateTaxesForm","Components","useComponentContext","requirements","label","effectiveFrom","key","Fragment","jsxs","jsx","requirement","QuestionInput"],"mappings":";;;;;;;AAQ+BA,EAAE,OAAOA,EAAE,UAAUA,EAAE,OAAOA,EAAE,OAAO,GAAGA,EAAE,QAAA,CAAS,CAAC;AAI9E,SAASC,IAAO;AACf,QAAA,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClEC,IAAgBC,EAAuB,GACvC,EAAE,sBAAAC,EAAqB,IAAIC,EAAkB,GAC7CC,IAAaC,EAAoB;AAEvC,SAAOH,EAAqB,iBAAiB;AAAA,IAC3C,CAAC,EAAE,cAAAI,GAAc,OAAAC,GAAO,eAAAC,GAAe,KAAAC,EAAI,wBACxCC,GACC,EAAA,UAAA;AAAA,MAAA,gBAAAC,EAAC,OACC,EAAA,UAAA;AAAA,QAAA,gBAAAC,EAACR,EAAW,SAAX,EAAmB,IAAG,MAAM,UAAMG,GAAA;AAAA,QAClCC,KACE,gBAAAI,EAAAR,EAAW,MAAX,EAAgB,WAAU,aACxB,UAAEN,EAAA,sBAAsB,EAAE,MAAME,EAAc,OAAO,IAAI,KAAKQ,CAAa,CAAC,EAAA,CAAG,EAClF,CAAA;AAAA,MAAA,GAEJ;AAAA,MACCF,GAAc,IAAI,CAAeO,MAE9B,gBAAAD;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,aAAa;AAAA,YACX,GAAGD;AAAA,YACH,KAAK,GAAGJ,CAAG,IAAII,EAAY,GAAa;AAAA,UAC1C;AAAA,UACA,cAAcA,EAAY,UAAU,QAAQ;AAAA,QAAA;AAAA,QACvCA,EAAY;AAAA,MACnB,CAEH;AAAA,IAAA,EAAA,GApBYJ,CAqBf;AAAA,EAEJ;AACF;"}
|
|
@@ -1,111 +1,100 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useForm as
|
|
3
|
-
import {
|
|
4
|
-
import { useTaxRequirementsUpdateStateMutation as
|
|
5
|
-
import { useTaxRequirementsGetSuspense as
|
|
6
|
-
import
|
|
7
|
-
import { useMemo as
|
|
8
|
-
import { useTranslation as
|
|
1
|
+
import { jsx as t, jsxs as D, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { useForm as K, FormProvider as M } from "react-hook-form";
|
|
3
|
+
import { zodResolver as w } from "@hookform/resolvers/zod";
|
|
4
|
+
import { useTaxRequirementsUpdateStateMutation as z } from "@gusto/embedded-api/react-query/taxRequirementsUpdateState";
|
|
5
|
+
import { useTaxRequirementsGetSuspense as G } from "@gusto/embedded-api/react-query/taxRequirementsGet";
|
|
6
|
+
import { z as r } from "zod";
|
|
7
|
+
import { useMemo as L } from "react";
|
|
8
|
+
import { useTranslation as X } from "react-i18next";
|
|
9
9
|
import { Head as q } from "./Head.js";
|
|
10
|
-
import { StateTaxesFormProvider as
|
|
10
|
+
import { StateTaxesFormProvider as Y } from "./context.js";
|
|
11
11
|
import { Form as A } from "./Form.js";
|
|
12
|
-
import { Actions as
|
|
13
|
-
import { BaseComponent as
|
|
12
|
+
import { Actions as P } from "./Actions.js";
|
|
13
|
+
import { BaseComponent as $ } from "../../../Base/Base.js";
|
|
14
14
|
import { useI18n as I } from "../../../../i18n/I18n.js";
|
|
15
15
|
import { Flex as J } from "../../../Common/Flex/Flex.js";
|
|
16
16
|
import { Form as Q } from "../../../Common/Form/Form.js";
|
|
17
|
-
import { componentEvents as
|
|
17
|
+
import { componentEvents as k } from "../../../../shared/constants.js";
|
|
18
18
|
import { useBase as W } from "../../../Base/useBase.js";
|
|
19
|
-
function
|
|
20
|
-
return /* @__PURE__ */
|
|
19
|
+
function x(n) {
|
|
20
|
+
return /* @__PURE__ */ t($, { ...n, children: /* @__PURE__ */ t(Z, { ...n, children: n.children }) });
|
|
21
21
|
}
|
|
22
|
-
function Z({ companyId:
|
|
22
|
+
function Z({ companyId: n, state: S, className: j, children: v }) {
|
|
23
23
|
I("Company.StateTaxes");
|
|
24
|
-
const { onEvent: F, baseSubmitHandler:
|
|
24
|
+
const { onEvent: F, baseSubmitHandler: C } = W(), { t: l } = X("Company.StateTaxes", { keyPrefix: "form" }), { data: E } = G({ companyUuid: n, state: S }), f = E.taxRequirementsState, { mutateAsync: N, isPending: R } = z(), { dynamicSchema: V, defaultValues: O } = L(() => {
|
|
25
25
|
const d = {}, i = {};
|
|
26
|
-
return
|
|
27
|
-
if (!
|
|
28
|
-
const m =
|
|
29
|
-
|
|
30
|
-
if (!
|
|
31
|
-
const b =
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const n = parseFloat(u.min), l = parseFloat(u.max);
|
|
42
|
-
!isNaN(n) && !isNaN(l) && (c = e.pipe(
|
|
43
|
-
c,
|
|
44
|
-
e.transform((h) => Number(h)),
|
|
45
|
-
// Apply numeric validations after successful transform
|
|
46
|
-
e.minValue(n, f("validations.minValue", { min: n })),
|
|
47
|
-
e.maxValue(l, f("validations.maxValue", { max: l })),
|
|
48
|
-
e.transform((h) => String(h))
|
|
26
|
+
return f.requirementSets?.forEach((e) => {
|
|
27
|
+
if (!e.key) return;
|
|
28
|
+
const m = e.key, s = {}, p = {};
|
|
29
|
+
e.requirements?.forEach((o) => {
|
|
30
|
+
if (!o.key) return;
|
|
31
|
+
const b = o.key;
|
|
32
|
+
p[b] = String(o.value ?? "");
|
|
33
|
+
let y = r.string().min(1);
|
|
34
|
+
const c = o.metadata?.validation;
|
|
35
|
+
if (c && o.metadata?.type === "tax_rate")
|
|
36
|
+
if (c.type === "min_max") {
|
|
37
|
+
const a = parseFloat(c.min), u = parseFloat(c.max);
|
|
38
|
+
!isNaN(a) && !isNaN(u) && (y = r.preprocess(
|
|
39
|
+
(h) => Number(h),
|
|
40
|
+
r.number().min(a, l("validations.minValue", { min: a })).max(u, l("validations.maxValue", { max: u })).transform((h) => String(h))
|
|
49
41
|
));
|
|
50
42
|
} else {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
e.picklist(n, f("validations.oneOf", { values: n.join(", ") }))
|
|
56
|
-
);
|
|
43
|
+
const a = c.rates;
|
|
44
|
+
y = r.string().min(1).refine((u) => a.includes(u), {
|
|
45
|
+
message: l("validations.oneOf", { values: a.join(", ") })
|
|
46
|
+
});
|
|
57
47
|
}
|
|
58
|
-
s[b] =
|
|
59
|
-
}), Object.keys(s).length > 0 && (d[m] =
|
|
48
|
+
s[b] = y;
|
|
49
|
+
}), Object.keys(s).length > 0 && (d[m] = r.object(s), i[m] = p);
|
|
60
50
|
}), {
|
|
61
|
-
dynamicSchema:
|
|
62
|
-
// Cast defaultValues based on the final inferred schema type
|
|
51
|
+
dynamicSchema: r.object(d),
|
|
63
52
|
defaultValues: i
|
|
64
53
|
};
|
|
65
|
-
}, [
|
|
66
|
-
resolver:
|
|
54
|
+
}, [f, l]), { control: U, ...T } = K({
|
|
55
|
+
resolver: w(V),
|
|
67
56
|
defaultValues: O
|
|
68
57
|
}), _ = async (d) => {
|
|
69
|
-
await
|
|
70
|
-
const
|
|
71
|
-
const m =
|
|
58
|
+
await C(d, async (i) => {
|
|
59
|
+
const g = f.requirementSets?.filter((e) => e.key && i[e.key]).map((e) => {
|
|
60
|
+
const m = e.key, s = i[m];
|
|
72
61
|
return {
|
|
73
|
-
state:
|
|
62
|
+
state: e.state,
|
|
74
63
|
key: m,
|
|
75
|
-
effectiveFrom:
|
|
76
|
-
requirements: Object.entries(s).map(([
|
|
77
|
-
key:
|
|
78
|
-
value: String(
|
|
64
|
+
effectiveFrom: e.effectiveFrom,
|
|
65
|
+
requirements: Object.entries(s).map(([p, o]) => ({
|
|
66
|
+
key: p,
|
|
67
|
+
value: String(o)
|
|
79
68
|
}))
|
|
80
69
|
};
|
|
81
70
|
});
|
|
82
|
-
await
|
|
71
|
+
await N({
|
|
83
72
|
request: {
|
|
84
|
-
companyUuid:
|
|
85
|
-
requestBody: { requirementSets:
|
|
86
|
-
state:
|
|
73
|
+
companyUuid: n,
|
|
74
|
+
requestBody: { requirementSets: g },
|
|
75
|
+
state: S
|
|
87
76
|
}
|
|
88
|
-
}), F(
|
|
77
|
+
}), F(k.COMPANY_STATE_TAX_UPDATED);
|
|
89
78
|
});
|
|
90
|
-
},
|
|
91
|
-
F(
|
|
79
|
+
}, B = () => {
|
|
80
|
+
F(k.CANCEL);
|
|
92
81
|
};
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
|
|
82
|
+
return /* @__PURE__ */ t("section", { className: j, children: /* @__PURE__ */ t(M, { ...T, control: U, children: /* @__PURE__ */ t(Q, { onSubmit: T.handleSubmit(_), children: /* @__PURE__ */ t(
|
|
83
|
+
Y,
|
|
95
84
|
{
|
|
96
|
-
value: { stateTaxRequirements:
|
|
97
|
-
children: /* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */
|
|
85
|
+
value: { stateTaxRequirements: f, isPending: R, state: S, handleCancel: B },
|
|
86
|
+
children: /* @__PURE__ */ t(J, { flexDirection: "column", gap: 32, children: v || /* @__PURE__ */ D(H, { children: [
|
|
87
|
+
/* @__PURE__ */ t(q, {}),
|
|
88
|
+
/* @__PURE__ */ t(A, {}),
|
|
89
|
+
/* @__PURE__ */ t(P, {})
|
|
101
90
|
] }) })
|
|
102
91
|
}
|
|
103
92
|
) }) }) });
|
|
104
93
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
x.Head = q;
|
|
95
|
+
x.Form = A;
|
|
96
|
+
x.Actions = P;
|
|
108
97
|
export {
|
|
109
|
-
|
|
98
|
+
x as StateTaxesForm
|
|
110
99
|
};
|
|
111
100
|
//# sourceMappingURL=StateTaxesForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { valibotResolver } from '@hookform/resolvers/valibot'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport * as v from 'valibot'\nimport { useMemo } from 'react'\nimport type { InferInput } from 'valibot'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<\n string,\n v.ObjectSchema<\n Record<string, v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>,\n undefined\n >\n > = {}\n const values: Partial<Record<string, Record<string, string>>> = {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n // Explicitly type requirementShape to allow string indexing\n const requirementShape: Record<\n string,\n v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>\n > = {}\n const requirementValues: Record<string, string> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n // --- Default Value Logic ---\n requirementValues[requirementKey] = String(requirement.value ?? '')\n\n // --- Schema Logic ---\n // Explicitly type fieldSchema with a broad BaseSchema type to handle subsequent pipes\n // Since we don't know the type of the requirement.value, we use unknown()\n let fieldSchema: v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>> = v.pipe(\n v.unknown(),\n v.transform(input => String(input)),\n v.nonEmpty(),\n )\n\n const validation = requirement.metadata?.validation\n // Not all requirements have validation\n if (validation) {\n if (requirement.metadata?.type === 'tax_rate') {\n if (validation.type === 'min_max') {\n const min = parseFloat(validation.min as string)\n const max = parseFloat(validation.max as string)\n\n if (!isNaN(min) && !isNaN(max)) {\n // Pipe directly onto the current fieldSchema\n fieldSchema = v.pipe(\n fieldSchema,\n v.transform(input => {\n return Number(input)\n }),\n // Apply numeric validations after successful transform\n v.minValue(min, t('validations.minValue', { min })),\n v.maxValue(max, t('validations.maxValue', { max })),\n v.transform(num => String(num)),\n )\n }\n } else {\n //Type is one_of\n const oneOfValues = validation.rates as string[]\n fieldSchema = v.pipe(\n fieldSchema,\n v.transform(input => String(input)),\n v.picklist(oneOfValues, t('validations.oneOf', { values: oneOfValues.join(', ') })),\n )\n }\n }\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n // Assign the correctly typed object schema\n schemaShape[requirementSetKey] = v.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = v.object(schemaShape, undefined)\n\n // Return both the schema and the correctly typed default values\n return {\n dynamicSchema: finalSchema,\n // Cast defaultValues based on the final inferred schema type\n defaultValues: values as InferInput<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema returned by useMemo\n type InferredFormInputs = InferInput<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: valibotResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key]) // Type assertion for payload key\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n // Type assertion for payload access\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([key, value]) => ({\n key,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nStateTaxesForm.Head = Head\nStateTaxesForm.Form = Form\nStateTaxesForm.Actions = Actions\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","fieldSchema","v","input","validation","min","max","num","oneOfValues","control","methods","useForm","valibotResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","key","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAyBO,SAASA,EAAeC,GAAqD;AAEhF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,GAAW,OAAAC,GAAO,GAC1EW,IAAuBF,EAAK,sBAE5B,EAAE,aAAaG,GAAgB,WAAWC,EAAA,IAC9CC,EAAsC,GAGlC,EAAE,eAAAC,GAAe,eAAAC,EAAc,IAAIC,EAAQ,MAAM;AACrD,UAAMC,IAMF,CAAC,GACCC,IAA0D,CAAC;AAG5C,WAAAR,EAAA,iBAAiB,QAAQ,CAAkBS,MAA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AM;AAAA,EAChC;AAEA,SACG,gBAAAlD,EAAA,WAAA,EAAQ,WAAAK,GACP,UAAA,gBAAAL,EAACoD,KAAc,GAAGb,GAAS,SAAAD,GACzB,UAAA,gBAAAtC,EAACqD,GAAS,EAAA,UAAUd,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAA1C;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAAvC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA+C,EAAa;AAAA,MAE/E,UAAA,gBAAAnD,EAACuD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAjD,KAIG,gBAAAkD,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
1
|
+
{"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodTypeAny>>> = {}\n const values: Partial<Record<string, Record<string, string>>> = {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodTypeAny> = {}\n const requirementValues: Record<string, string> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n // --- Default Value Logic ---\n requirementValues[requirementKey] = String(requirement.value ?? '')\n\n // --- Schema Logic ---\n // Start with a basic string schema\n let fieldSchema: z.ZodTypeAny = z.string().min(1)\n\n const validation = requirement.metadata?.validation\n // Not all requirements have validation\n if (validation) {\n if (requirement.metadata?.type === 'tax_rate') {\n if (validation.type === 'min_max') {\n const min = parseFloat(validation.min as string)\n const max = parseFloat(validation.max as string)\n\n if (!isNaN(min) && !isNaN(max)) {\n fieldSchema = z.preprocess(\n val => Number(val),\n z\n .number()\n .min(min, t('validations.minValue', { min }))\n .max(max, t('validations.maxValue', { max }))\n .transform(num => String(num)),\n )\n }\n } else {\n //Type is one_of\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string()\n .min(1)\n .refine(val => oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([key, value]) => ({\n key,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nStateTaxesForm.Head = Head\nStateTaxesForm.Form = Form\nStateTaxesForm.Actions = Actions\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","fieldSchema","z","validation","min","max","val","num","oneOfValues","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","key","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,EAAeC,GAAqD;AAEhF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,GAAW,OAAAC,GAAO,GAC1EW,IAAuBF,EAAK,sBAE5B,EAAE,aAAaG,GAAgB,WAAWC,EAAA,IAC9CC,EAAsC,GAGlC,EAAE,eAAAC,GAAe,eAAAC,EAAc,IAAIC,EAAQ,MAAM;AACrD,UAAMC,IAAyE,CAAC,GAC1EC,IAA0D,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AD,GACzB,UAAA,gBAAAtC,EAACqD,GAAS,EAAA,UAAUd,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAA1C;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAAvC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA+C,EAAa;AAAA,MAE/E,UAAA,gBAAAnD,EAACuD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAjD,KAIG,gBAAAkD,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as s, jsxs as ue, Fragment as me } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { zodResolver as de } from "@hookform/resolvers/zod";
|
|
3
3
|
import { useState as _, useMemo as j, useEffect as le } from "react";
|
|
4
4
|
import { useForm as ce, FormProvider as fe } from "react-hook-form";
|
|
5
5
|
import { useTranslation as pe } from "react-i18next";
|
|
@@ -10,7 +10,7 @@ import { useJobsAndCompensationsDeleteMutation as he } from "@gusto/embedded-api
|
|
|
10
10
|
import { useJobsAndCompensationsUpdateCompensationMutation as Ae } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation";
|
|
11
11
|
import { useLocationsGetMinimumWagesSuspense as Oe } from "@gusto/embedded-api/react-query/locationsGetMinimumWages";
|
|
12
12
|
import { useEmployeeAddressesGetWorkAddressesSuspense as De } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
|
|
13
|
-
import { useQueryClient as be } from "@
|
|
13
|
+
import { useQueryClient as be } from "@tanstack/react-query";
|
|
14
14
|
import { useFederalTaxDetailsGetSuspense as ye } from "@gusto/embedded-api/react-query/federalTaxDetailsGet";
|
|
15
15
|
import { useEmployeesGetSuspense as Te } from "@gusto/embedded-api/react-query/employeesGet";
|
|
16
16
|
import { List as Y } from "./List.js";
|
|
@@ -33,12 +33,12 @@ const V = (e) => e?.compensations?.find((l) => l.uuid === e.currentCompensationU
|
|
|
33
33
|
data: { minimumWageList: X }
|
|
34
34
|
} = Oe({
|
|
35
35
|
locationUuid: g.locationUuid
|
|
36
|
-
}),
|
|
36
|
+
}), z = X, {
|
|
37
37
|
data: { employee: L }
|
|
38
38
|
} = Te({ employeeId: e });
|
|
39
39
|
if (!L)
|
|
40
40
|
throw new Error("Employee not found");
|
|
41
|
-
const { data:
|
|
41
|
+
const { data: Q } = ye({ companyId: L.companyUuid }), K = Q.federalTaxDetails.taxPayerType === "S-Corporation", J = Ae({
|
|
42
42
|
onSettled: () => T(D, [e])
|
|
43
43
|
}), v = Ee({
|
|
44
44
|
onSettled: () => T(D, [e])
|
|
@@ -156,7 +156,7 @@ const V = (e) => e?.compensations?.find((l) => l.uuid === e.currentCompensationU
|
|
|
156
156
|
primaryFlsaStatus: P,
|
|
157
157
|
showFlsaChangeWarning: Z,
|
|
158
158
|
mode: I,
|
|
159
|
-
minimumWages:
|
|
159
|
+
minimumWages: z,
|
|
160
160
|
handleFlsaChange: ae,
|
|
161
161
|
handleDelete: se,
|
|
162
162
|
handleEdit: ne,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compensation.js","sources":["../../../../src/components/Employee/Compensation/Compensation.tsx"],"sourcesContent":["import { valibotResolver } from '@hookform/resolvers/valibot'\nimport { useEffect, useMemo, useState } from 'react'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport {\n useJobsAndCompensationsGetJobsSuspense,\n invalidateJobsAndCompensationsGetJobs,\n} from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useJobsAndCompensationsDeleteMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDelete'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWagesSuspense } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useQueryClient } from '@gusto/embedded-api/ReactSDKProvider'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport { useFederalTaxDetailsGetSuspense } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { List } from './List'\nimport { Head } from './Head'\nimport { Edit } from './Edit'\nimport { Actions } from './Actions'\nimport {\n type CompensationInputs,\n type CompensationOutputs,\n CompensationProvider,\n CompensationSchema,\n type MODE,\n} from './useCompensation'\nimport { Form } from '@/components/Common/Form'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport type { PAY_PERIODS } from '@/shared/constants'\nimport { componentEvents, FlsaStatus } from '@/shared/constants'\nimport { useI18n } from '@/i18n'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n useBase,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nexport type CompensationDefaultValues = RequireAtLeastOne<{\n rate?: Job['rate']\n title?: Job['title']\n paymentUnit?: (typeof PAY_PERIODS)[keyof typeof PAY_PERIODS]\n flsaStatus?: FlsaStatusType\n}>\n\ninterface CompensationProps extends CommonComponentInterface {\n employeeId: string\n startDate: string\n defaultValues?: CompensationDefaultValues\n}\n\nexport function Compensation(props: CompensationProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst findCurrentCompensation = (employeeJob?: Job | null) => {\n return employeeJob?.compensations?.find(comp => comp.uuid === employeeJob.currentCompensationUuid)\n}\n\nconst Root = ({ employeeId, startDate, className, children, ...props }: CompensationProps) => {\n useI18n('Employee.Compensation')\n const { baseSubmitHandler, onEvent } = useBase()\n const queryClient = useQueryClient()\n\n const { data: jobsData } = useJobsAndCompensationsGetJobsSuspense({ employeeId })\n const employeeJobs = jobsData.jobList!\n\n const { data: addressesData } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n const workAddresses = addressesData.employeeWorkAddressList!\n\n const currentWorkAddress = workAddresses.find(address => address.active)!\n\n const {\n data: { minimumWageList },\n } = useLocationsGetMinimumWagesSuspense({\n locationUuid: currentWorkAddress.locationUuid!,\n })\n const minimumWages = minimumWageList!\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n if (!employee) {\n throw new Error('Employee not found')\n }\n\n const { data } = useFederalTaxDetailsGetSuspense({ companyId: employee.companyUuid! })\n const showTwoPercentStakeholder = data.federalTaxDetails!.taxPayerType === 'S-Corporation'\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const createEmployeeJobMutation = useJobsAndCompensationsCreateJobMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const updateEmployeeJobMutation = useJobsAndCompensationsUpdateMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const deleteEmployeeJobMutation = useJobsAndCompensationsDeleteMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n\n //Job being edited/created\n const [currentJob, setCurrentJob] = useState<Job | null>(\n employeeJobs.length === 1 ? (employeeJobs[0] ?? null) : null,\n )\n\n const [mode, setMode] = useState<MODE>(() => {\n if (!employeeJobs.length) {\n return 'ADD_INITIAL_JOB'\n }\n\n const currentCompensation = findCurrentCompensation(employeeJobs[0])\n\n if (employeeJobs.length === 1 && currentCompensation?.flsaStatus !== FlsaStatus.NONEXEMPT) {\n return 'EDIT_INITIAL_JOB'\n }\n\n return 'LIST'\n })\n\n const [showFlsaChangeWarning, setShowFlsaChangeWarning] = useState(false)\n //Getting current compensation for a job -> the one with the most recent effective date\n const currentCompensation = findCurrentCompensation(currentJob)\n /** Returns FLSA status of a current compensation of a primary job:\n * Employees can have multiple jobs, with multiple compensations, but only 1 job is primary with 1 current compensation\n */\n const primaryFlsaStatus = useMemo<string | undefined>(() => {\n return employeeJobs.reduce<string | undefined>((prev, curr) => {\n const compensation = curr.compensations?.find(\n comp => comp.uuid === curr.currentCompensationUuid,\n )\n if (!curr.primary || !compensation) return prev\n return compensation.flsaStatus ?? prev\n }, undefined)\n }, [employeeJobs])\n\n const defaultValues: CompensationInputs = useMemo(() => {\n return {\n jobTitle:\n currentJob?.title && currentJob.title !== ''\n ? currentJob.title\n : (props.defaultValues?.title ?? ''),\n flsaStatus:\n currentCompensation?.flsaStatus ?? primaryFlsaStatus ?? props.defaultValues?.flsaStatus,\n rate: Number(currentCompensation?.rate ?? props.defaultValues?.rate ?? 0),\n adjustForMinimumWage: currentCompensation?.adjustForMinimumWage ?? false,\n minimumWageId: currentCompensation?.minimumWages?.[0]?.uuid ?? '',\n paymentUnit: currentCompensation?.paymentUnit ?? props.defaultValues?.paymentUnit ?? 'Hour',\n stateWcCovered: currentJob?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? '',\n } as CompensationInputs\n }, [currentJob, currentCompensation, primaryFlsaStatus, props.defaultValues])\n\n const formMethods = useForm<CompensationInputs, unknown, CompensationOutputs>({\n resolver: valibotResolver(CompensationSchema),\n defaultValues,\n })\n const { resetField, setValue, handleSubmit, reset } = formMethods\n useEffect(() => {\n reset(defaultValues)\n }, [currentJob, defaultValues, reset])\n\n const submitWithEffect = async (newMode?: MODE) => {\n if (mode === 'LIST' && newMode === 'PROCEED') {\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n return\n }\n //If no job has been modified, switch to edit mode\n if (!currentJob && mode === 'LIST') {\n setMode('ADD_ADDITIONAL_JOB')\n return\n }\n //Performing post-submit state setting only on success\n await handleSubmit(async (data: CompensationOutputs) => {\n await onSubmit(data)\n switch (newMode) {\n case 'LIST':\n setMode('LIST')\n setCurrentJob(null)\n reset(defaultValues)\n break\n default:\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n }\n })()\n }\n const handleAdd = () => {\n setMode('ADD_ADDITIONAL_JOB')\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleCancelAddJob = () => {\n if (employeeJobs.length > 0) {\n setMode('LIST')\n } else {\n setMode('ADD_INITIAL_JOB')\n }\n\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleEdit = (uuid: string) => {\n const selectedJob = employeeJobs.find(job => uuid === job.uuid)\n if (selectedJob) {\n setMode('EDIT_ADDITIONAL_JOB')\n setCurrentJob(selectedJob)\n }\n }\n\n const handleDelete = async (jobId: string) => {\n await deleteEmployeeJobMutation.mutateAsync({ request: { jobId } })\n onEvent(componentEvents.EMPLOYEE_JOB_DELETED)\n }\n\n /**Update dependent field values upon change in FLSA type */\n const handleFlsaChange = (value: string | number) => {\n //Attempting to change flsa status from nonexempt should prompt user about deletion of other jobs associated with the employee\n if (currentCompensation?.flsaStatus === FlsaStatus.NONEXEMPT && employeeJobs.length > 1) {\n setShowFlsaChangeWarning(true)\n }\n if (value === FlsaStatus.OWNER) {\n setValue('paymentUnit', 'Paycheck')\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n } else if (\n value === FlsaStatus.COMISSION_ONLY_NONEXEMPT ||\n value === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', 'Year')\n setValue('rate', 0)\n } else {\n //reset fields\n resetField('paymentUnit', { defaultValue: currentCompensation?.paymentUnit })\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n }\n }\n\n const onSubmit: SubmitHandler<CompensationOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { jobTitle, twoPercentShareholder, ...compensationData } = payload\n let updatedJobData\n //Note: some of the type fixes below are due to the fact that API incorrectly defines current_compensation_uuid as optional\n if (!currentJob) {\n //Adding new job for NONEXEMPT\n const data = await createEmployeeJobMutation.mutateAsync({\n request: {\n employeeId,\n requestBody: {\n title: jobTitle,\n hireDate: startDate,\n stateWcCovered: compensationData.stateWcCovered,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_CREATED, updatedJobData)\n } else {\n const data = await updateEmployeeJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n requestBody: {\n title: jobTitle,\n version: currentJob.version as string,\n hireDate: startDate,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n stateWcCovered: compensationData.stateWcCovered,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, updatedJobData)\n }\n\n const { compensation } = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: updatedJobData.currentCompensationUuid!,\n requestBody: {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n version: updatedJobData.compensations?.find(\n comp => comp.uuid === updatedJobData.currentCompensationUuid,\n )?.version!,\n ...compensationData,\n minimumWages: compensationData.adjustForMinimumWage\n ? [{ uuid: compensationData.minimumWageId }]\n : [],\n },\n },\n })\n setShowFlsaChangeWarning(false)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensation)\n })\n }\n return (\n <section className={className}>\n <CompensationProvider\n value={{\n employeeJobs,\n currentJob,\n primaryFlsaStatus,\n showFlsaChangeWarning,\n mode,\n minimumWages,\n handleFlsaChange,\n handleDelete,\n handleEdit,\n handleAdd,\n submitWithEffect,\n handleCancelAddJob,\n isPending:\n updateCompensationMutation.isPending ||\n createEmployeeJobMutation.isPending ||\n updateEmployeeJobMutation.isPending ||\n deleteEmployeeJobMutation.isPending,\n state: currentWorkAddress.state,\n showTwoPercentStakeholder,\n }}\n >\n <FormProvider {...formMethods}>\n <Form>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <List />\n <Edit />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </CompensationProvider>\n </section>\n )\n}\n\nCompensation.Head = Head\nCompensation.List = List\nCompensation.Actions = Actions\nCompensation.Edit = Edit\n\nexport const CompensationContextual = () => {\n const { employeeId, onEvent, startDate, defaultValues } =\n useFlow<EmployeeOnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId || !startDate) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Compensation',\n param: !employeeId ? 'employeeId' : 'startDate',\n provider: 'FlowProvider',\n }),\n )\n }\n return (\n <Compensation\n employeeId={employeeId}\n startDate={startDate}\n onEvent={onEvent}\n defaultValues={defaultValues?.compensation}\n />\n )\n}\n"],"names":["Compensation","props","jsx","BaseComponent","Root","findCurrentCompensation","employeeJob","comp","employeeId","startDate","className","children","useI18n","baseSubmitHandler","onEvent","useBase","queryClient","useQueryClient","jobsData","useJobsAndCompensationsGetJobsSuspense","employeeJobs","addressesData","useEmployeeAddressesGetWorkAddressesSuspense","currentWorkAddress","address","minimumWageList","useLocationsGetMinimumWagesSuspense","minimumWages","employee","useEmployeesGetSuspense","data","useFederalTaxDetailsGetSuspense","showTwoPercentStakeholder","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","invalidateJobsAndCompensationsGetJobs","createEmployeeJobMutation","useJobsAndCompensationsCreateJobMutation","updateEmployeeJobMutation","useJobsAndCompensationsUpdateMutation","deleteEmployeeJobMutation","useJobsAndCompensationsDeleteMutation","currentJob","setCurrentJob","useState","mode","setMode","currentCompensation","FlsaStatus","showFlsaChangeWarning","setShowFlsaChangeWarning","primaryFlsaStatus","useMemo","prev","curr","compensation","defaultValues","formMethods","useForm","valibotResolver","CompensationSchema","resetField","setValue","handleSubmit","reset","useEffect","submitWithEffect","newMode","componentEvents","onSubmit","handleAdd","handleCancelAddJob","handleEdit","uuid","selectedJob","job","handleDelete","jobId","handleFlsaChange","value","payload","jobTitle","twoPercentShareholder","compensationData","updatedJobData","CompensationProvider","FormProvider","Form","jsxs","Fragment","Head","List","Edit","Actions","CompensationContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,SAASA,EAAaC,GAAmD;AAE5E,SAAA,gBAAAC,EAACC,IAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,MAAMI,IAA0B,CAACC,MACxBA,GAAa,eAAe,KAAK,OAAQC,EAAK,SAASD,EAAY,uBAAuB,GAG7FF,KAAO,CAAC,EAAE,YAAAI,GAAY,WAAAC,GAAW,WAAAC,GAAW,UAAAC,GAAU,GAAGV,QAA+B;AAC5F,EAAAW,GAAQ,uBAAuB;AAC/B,QAAM,EAAE,mBAAAC,GAAmB,SAAAC,EAAQ,IAAIC,GAAQ,GACzCC,IAAcC,GAAe,GAE7B,EAAE,MAAMC,EAAA,IAAaC,GAAuC,EAAE,YAAAX,GAAY,GAC1EY,IAAeF,EAAS,SAExB,EAAE,MAAMG,EAAA,IAAkBC,GAA6C,EAAE,YAAAd,GAAY,GAGrFe,IAFgBF,EAAc,wBAEK,KAAK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M,IAAI;AAAA,MACRuF,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAQxF,IAA4B,cAAf;AAAA,QACrB,UAAU;AAAA,MACX,CAAA;AAAA,IACH;AAGA,SAAA,gBAAAN;AAAA,IAACF;AAAA,IAAA;AAAA,MACC,YAAAQ;AAAA,MACA,WAAAC;AAAA,MACA,SAAAK;AAAA,MACA,eAAe0C,GAAe;AAAA,IAAA;AAAA,EAChC;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Compensation.js","sources":["../../../../src/components/Employee/Compensation/Compensation.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useMemo, useState } from 'react'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport {\n useJobsAndCompensationsGetJobsSuspense,\n invalidateJobsAndCompensationsGetJobs,\n} from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useJobsAndCompensationsDeleteMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDelete'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWagesSuspense } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport { useFederalTaxDetailsGetSuspense } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { List } from './List'\nimport { Head } from './Head'\nimport { Edit } from './Edit'\nimport { Actions } from './Actions'\nimport {\n type CompensationInputs,\n type CompensationOutputs,\n CompensationProvider,\n CompensationSchema,\n type MODE,\n} from './useCompensation'\nimport { Form } from '@/components/Common/Form'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport type { PAY_PERIODS } from '@/shared/constants'\nimport { componentEvents, FlsaStatus } from '@/shared/constants'\nimport { useI18n } from '@/i18n'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n useBase,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport type { EmployeeOnboardingContextInterface } from '@/components/Flow/EmployeeOnboardingFlow'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nexport type CompensationDefaultValues = RequireAtLeastOne<{\n rate?: Job['rate']\n title?: Job['title']\n paymentUnit?: (typeof PAY_PERIODS)[keyof typeof PAY_PERIODS]\n flsaStatus?: FlsaStatusType\n}>\n\ninterface CompensationProps extends CommonComponentInterface {\n employeeId: string\n startDate: string\n defaultValues?: CompensationDefaultValues\n}\n\nexport function Compensation(props: CompensationProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst findCurrentCompensation = (employeeJob?: Job | null) => {\n return employeeJob?.compensations?.find(comp => comp.uuid === employeeJob.currentCompensationUuid)\n}\n\nconst Root = ({ employeeId, startDate, className, children, ...props }: CompensationProps) => {\n useI18n('Employee.Compensation')\n const { baseSubmitHandler, onEvent } = useBase()\n const queryClient = useQueryClient()\n\n const { data: jobsData } = useJobsAndCompensationsGetJobsSuspense({ employeeId })\n const employeeJobs = jobsData.jobList!\n\n const { data: addressesData } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n const workAddresses = addressesData.employeeWorkAddressList!\n\n const currentWorkAddress = workAddresses.find(address => address.active)!\n\n const {\n data: { minimumWageList },\n } = useLocationsGetMinimumWagesSuspense({\n locationUuid: currentWorkAddress.locationUuid!,\n })\n const minimumWages = minimumWageList!\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n if (!employee) {\n throw new Error('Employee not found')\n }\n\n const { data } = useFederalTaxDetailsGetSuspense({ companyId: employee.companyUuid! })\n const showTwoPercentStakeholder = data.federalTaxDetails!.taxPayerType === 'S-Corporation'\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const createEmployeeJobMutation = useJobsAndCompensationsCreateJobMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const updateEmployeeJobMutation = useJobsAndCompensationsUpdateMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const deleteEmployeeJobMutation = useJobsAndCompensationsDeleteMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n\n //Job being edited/created\n const [currentJob, setCurrentJob] = useState<Job | null>(\n employeeJobs.length === 1 ? (employeeJobs[0] ?? null) : null,\n )\n\n const [mode, setMode] = useState<MODE>(() => {\n if (!employeeJobs.length) {\n return 'ADD_INITIAL_JOB'\n }\n\n const currentCompensation = findCurrentCompensation(employeeJobs[0])\n\n if (employeeJobs.length === 1 && currentCompensation?.flsaStatus !== FlsaStatus.NONEXEMPT) {\n return 'EDIT_INITIAL_JOB'\n }\n\n return 'LIST'\n })\n\n const [showFlsaChangeWarning, setShowFlsaChangeWarning] = useState(false)\n //Getting current compensation for a job -> the one with the most recent effective date\n const currentCompensation = findCurrentCompensation(currentJob)\n /** Returns FLSA status of a current compensation of a primary job:\n * Employees can have multiple jobs, with multiple compensations, but only 1 job is primary with 1 current compensation\n */\n const primaryFlsaStatus = useMemo<string | undefined>(() => {\n return employeeJobs.reduce<string | undefined>((prev, curr) => {\n const compensation = curr.compensations?.find(\n comp => comp.uuid === curr.currentCompensationUuid,\n )\n if (!curr.primary || !compensation) return prev\n return compensation.flsaStatus ?? prev\n }, undefined)\n }, [employeeJobs])\n\n const defaultValues: CompensationInputs = useMemo(() => {\n return {\n jobTitle:\n currentJob?.title && currentJob.title !== ''\n ? currentJob.title\n : (props.defaultValues?.title ?? ''),\n flsaStatus:\n currentCompensation?.flsaStatus ?? primaryFlsaStatus ?? props.defaultValues?.flsaStatus,\n rate: Number(currentCompensation?.rate ?? props.defaultValues?.rate ?? 0),\n adjustForMinimumWage: currentCompensation?.adjustForMinimumWage ?? false,\n minimumWageId: currentCompensation?.minimumWages?.[0]?.uuid ?? '',\n paymentUnit: currentCompensation?.paymentUnit ?? props.defaultValues?.paymentUnit ?? 'Hour',\n stateWcCovered: currentJob?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? '',\n } as CompensationInputs\n }, [currentJob, currentCompensation, primaryFlsaStatus, props.defaultValues])\n\n const formMethods = useForm<CompensationInputs, unknown, CompensationOutputs>({\n resolver: zodResolver(CompensationSchema),\n defaultValues,\n })\n const { resetField, setValue, handleSubmit, reset } = formMethods\n useEffect(() => {\n reset(defaultValues)\n }, [currentJob, defaultValues, reset])\n\n const submitWithEffect = async (newMode?: MODE) => {\n if (mode === 'LIST' && newMode === 'PROCEED') {\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n return\n }\n //If no job has been modified, switch to edit mode\n if (!currentJob && mode === 'LIST') {\n setMode('ADD_ADDITIONAL_JOB')\n return\n }\n //Performing post-submit state setting only on success\n await handleSubmit(async (data: CompensationOutputs) => {\n await onSubmit(data)\n switch (newMode) {\n case 'LIST':\n setMode('LIST')\n setCurrentJob(null)\n reset(defaultValues)\n break\n default:\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n }\n })()\n }\n const handleAdd = () => {\n setMode('ADD_ADDITIONAL_JOB')\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleCancelAddJob = () => {\n if (employeeJobs.length > 0) {\n setMode('LIST')\n } else {\n setMode('ADD_INITIAL_JOB')\n }\n\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleEdit = (uuid: string) => {\n const selectedJob = employeeJobs.find(job => uuid === job.uuid)\n if (selectedJob) {\n setMode('EDIT_ADDITIONAL_JOB')\n setCurrentJob(selectedJob)\n }\n }\n\n const handleDelete = async (jobId: string) => {\n await deleteEmployeeJobMutation.mutateAsync({ request: { jobId } })\n onEvent(componentEvents.EMPLOYEE_JOB_DELETED)\n }\n\n /**Update dependent field values upon change in FLSA type */\n const handleFlsaChange = (value: string | number) => {\n //Attempting to change flsa status from nonexempt should prompt user about deletion of other jobs associated with the employee\n if (currentCompensation?.flsaStatus === FlsaStatus.NONEXEMPT && employeeJobs.length > 1) {\n setShowFlsaChangeWarning(true)\n }\n if (value === FlsaStatus.OWNER) {\n setValue('paymentUnit', 'Paycheck')\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n } else if (\n value === FlsaStatus.COMISSION_ONLY_NONEXEMPT ||\n value === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', 'Year')\n setValue('rate', 0)\n } else {\n //reset fields\n resetField('paymentUnit', { defaultValue: currentCompensation?.paymentUnit })\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n }\n }\n\n const onSubmit: SubmitHandler<CompensationOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { jobTitle, twoPercentShareholder, ...compensationData } = payload\n let updatedJobData\n //Note: some of the type fixes below are due to the fact that API incorrectly defines current_compensation_uuid as optional\n if (!currentJob) {\n //Adding new job for NONEXEMPT\n const data = await createEmployeeJobMutation.mutateAsync({\n request: {\n employeeId,\n requestBody: {\n title: jobTitle,\n hireDate: startDate,\n stateWcCovered: compensationData.stateWcCovered,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_CREATED, updatedJobData)\n } else {\n const data = await updateEmployeeJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n requestBody: {\n title: jobTitle,\n version: currentJob.version as string,\n hireDate: startDate,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n stateWcCovered: compensationData.stateWcCovered,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, updatedJobData)\n }\n\n const { compensation } = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: updatedJobData.currentCompensationUuid!,\n requestBody: {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n version: updatedJobData.compensations?.find(\n comp => comp.uuid === updatedJobData.currentCompensationUuid,\n )?.version!,\n ...compensationData,\n minimumWages: compensationData.adjustForMinimumWage\n ? [{ uuid: compensationData.minimumWageId }]\n : [],\n },\n },\n })\n setShowFlsaChangeWarning(false)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensation)\n })\n }\n return (\n <section className={className}>\n <CompensationProvider\n value={{\n employeeJobs,\n currentJob,\n primaryFlsaStatus,\n showFlsaChangeWarning,\n mode,\n minimumWages,\n handleFlsaChange,\n handleDelete,\n handleEdit,\n handleAdd,\n submitWithEffect,\n handleCancelAddJob,\n isPending:\n updateCompensationMutation.isPending ||\n createEmployeeJobMutation.isPending ||\n updateEmployeeJobMutation.isPending ||\n deleteEmployeeJobMutation.isPending,\n state: currentWorkAddress.state,\n showTwoPercentStakeholder,\n }}\n >\n <FormProvider {...formMethods}>\n <Form>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <List />\n <Edit />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </CompensationProvider>\n </section>\n )\n}\n\nCompensation.Head = Head\nCompensation.List = List\nCompensation.Actions = Actions\nCompensation.Edit = Edit\n\nexport const CompensationContextual = () => {\n const { employeeId, onEvent, startDate, defaultValues } =\n useFlow<EmployeeOnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId || !startDate) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Compensation',\n param: !employeeId ? 'employeeId' : 'startDate',\n provider: 'FlowProvider',\n }),\n )\n }\n return (\n <Compensation\n employeeId={employeeId}\n startDate={startDate}\n onEvent={onEvent}\n defaultValues={defaultValues?.compensation}\n />\n )\n}\n"],"names":["Compensation","props","jsx","BaseComponent","Root","findCurrentCompensation","employeeJob","comp","employeeId","startDate","className","children","useI18n","baseSubmitHandler","onEvent","useBase","queryClient","useQueryClient","jobsData","useJobsAndCompensationsGetJobsSuspense","employeeJobs","addressesData","useEmployeeAddressesGetWorkAddressesSuspense","currentWorkAddress","address","minimumWageList","useLocationsGetMinimumWagesSuspense","minimumWages","employee","useEmployeesGetSuspense","data","useFederalTaxDetailsGetSuspense","showTwoPercentStakeholder","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","invalidateJobsAndCompensationsGetJobs","createEmployeeJobMutation","useJobsAndCompensationsCreateJobMutation","updateEmployeeJobMutation","useJobsAndCompensationsUpdateMutation","deleteEmployeeJobMutation","useJobsAndCompensationsDeleteMutation","currentJob","setCurrentJob","useState","mode","setMode","currentCompensation","FlsaStatus","showFlsaChangeWarning","setShowFlsaChangeWarning","primaryFlsaStatus","useMemo","prev","curr","compensation","defaultValues","formMethods","useForm","zodResolver","CompensationSchema","resetField","setValue","handleSubmit","reset","useEffect","submitWithEffect","newMode","componentEvents","onSubmit","handleAdd","handleCancelAddJob","handleEdit","uuid","selectedJob","job","handleDelete","jobId","handleFlsaChange","value","payload","jobTitle","twoPercentShareholder","compensationData","updatedJobData","CompensationProvider","FormProvider","Form","jsxs","Fragment","Head","List","Edit","Actions","CompensationContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,SAASA,EAAaC,GAAmD;AAE5E,SAAA,gBAAAC,EAACC,IAAe,EAAA,GAAGF,GAC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