@gusto/embedded-react-sdk 0.10.3 → 0.10.4
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 +17 -0
- package/dist/components/Base/Base.js +3 -2
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureForm.js +6 -4
- package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +12 -10
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +8 -6
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.js +13 -11
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +7 -6
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +9 -8
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +1 -0
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +3 -2
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +7 -6
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +10 -9
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/TitleSelect.js +8 -7
- package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +6 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +3 -2
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +8 -7
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +4 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +7 -6
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +8 -7
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +5 -4
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +6 -5
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js +17 -15
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +9 -7
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +7 -6
- package/dist/components/Company/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.js +17 -15
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +3 -2
- package/dist/components/Company/FederalTaxes/Form.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Head.js +11 -11
- package/dist/components/Company/FederalTaxes/Head.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +9 -8
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Actions.js +6 -5
- package/dist/components/Company/Industry/Actions.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +7 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/Edit.js +11 -10
- package/dist/components/Company/Industry/Edit.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +3 -2
- package/dist/components/Company/Locations/LocationForm/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.js +5 -4
- package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.js +9 -7
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +4 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +3 -2
- package/dist/components/Company/Locations/LocationsList/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +9 -8
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.js +11 -9
- package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +4 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/Completed.js +6 -5
- package/dist/components/Company/OnboardingOverview/Completed.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js +3 -2
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js +4 -2
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +4 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +88 -106
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +11 -10
- package/dist/components/Company/PaySchedule/_parts/Actions.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +65 -51
- package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Head.js +3 -2
- package/dist/components/Company/PaySchedule/_parts/Head.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.js +6 -5
- package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +6 -5
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +6 -5
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +7 -6
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +6 -5
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Address.js +2 -0
- package/dist/components/Contractor/Address/Address.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +3 -2
- package/dist/components/Contractor/Address/Form.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +6 -5
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/List/index.js +48 -50
- package/dist/components/Contractor/List/index.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +17 -16
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +3 -2
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +3 -2
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +3 -2
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +5 -4
- package/dist/components/Employee/Compensation/Actions.js.map +1 -1
- package/dist/components/Employee/Compensation/Edit.js +3 -2
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Compensation/List.js +6 -5
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Deductions/Actions.js +9 -8
- package/dist/components/Employee/Deductions/Actions.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsList.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsList.js.map +1 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +3 -2
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js.map +1 -1
- package/dist/components/Employee/Deductions/useDeductions.js +6 -5
- package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +5 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js +12 -10
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js +3 -2
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +10 -8
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +5 -4
- package/dist/components/Employee/EmployeeList/Actions.js.map +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +4 -2
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Head.js +3 -2
- package/dist/components/Employee/EmployeeList/Head.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +3 -2
- package/dist/components/Employee/EmployeeList/List.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +4 -3
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/Landing/Landing.js +7 -6
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Actions.js +6 -5
- package/dist/components/Employee/PaymentMethod/Actions.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +3 -2
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +3 -2
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +3 -2
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +3 -2
- package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +6 -5
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/Actions.js +7 -6
- package/dist/components/Employee/Profile/Actions.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +10 -9
- package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +5 -4
- package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +9 -8
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +4 -3
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/Taxes/Actions.js +8 -7
- package/dist/components/Employee/Taxes/Actions.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +5 -4
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +4 -3
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +3 -2
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/i18n/en/Company.Locations.json.js +2 -2
- package/dist/i18n/en/Company.PaySchedule.json.js +24 -19
- package/dist/i18n/en/Company.PaySchedule.json.js.map +1 -1
- package/dist/types/i18next.d.ts +5 -1
- package/package.json +4 -1
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useForm as
|
|
3
|
-
import { zodResolver as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { usePaySchedulesGetPreview as
|
|
6
|
-
import { usePaySchedulesUpdateMutation as
|
|
7
|
-
import { usePaySchedulesGetAllSuspense as
|
|
8
|
-
import { usePaySchedulesCreateMutation as
|
|
9
|
-
import { PayScheduleSchema as
|
|
10
|
-
import { Form as
|
|
11
|
-
import { BaseComponent as
|
|
12
|
-
import { useBase as
|
|
13
|
-
import { Flex as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
1
|
+
import { jsx as t, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { useForm as z, FormProvider as J } from "react-hook-form";
|
|
3
|
+
import { zodResolver as K } from "@hookform/resolvers/zod";
|
|
4
|
+
import { useState as A, useEffect as _ } from "react";
|
|
5
|
+
import { usePaySchedulesGetPreview as Q } from "@gusto/embedded-api/react-query/paySchedulesGetPreview";
|
|
6
|
+
import { usePaySchedulesUpdateMutation as W } from "@gusto/embedded-api/react-query/paySchedulesUpdate";
|
|
7
|
+
import { usePaySchedulesGetAllSuspense as X } from "@gusto/embedded-api/react-query/paySchedulesGetAll";
|
|
8
|
+
import { usePaySchedulesCreateMutation as Z } from "@gusto/embedded-api/react-query/paySchedulesCreate";
|
|
9
|
+
import { PayScheduleSchema as $, PayScheduleProvider as V } from "./usePaySchedule.js";
|
|
10
|
+
import { Form as ee } from "../../Common/Form/Form.js";
|
|
11
|
+
import { BaseComponent as oe } from "../../Base/Base.js";
|
|
12
|
+
import { useBase as re } from "../../Base/useBase.js";
|
|
13
|
+
import { Flex as ae } from "../../Common/Flex/Flex.js";
|
|
14
|
+
import "react-i18next";
|
|
15
|
+
import "classnames";
|
|
16
|
+
import { useI18n as te, useComponentDictionary as ne } from "../../../i18n/I18n.js";
|
|
17
|
+
import { componentEvents as p } from "../../../shared/constants.js";
|
|
18
|
+
import { formatDateToStringDate as v } from "../../../helpers/dateFormatting.js";
|
|
19
|
+
import { Head as w } from "./_parts/Head.js";
|
|
18
20
|
import { List as C } from "./_parts/List.js";
|
|
19
21
|
import { Edit as L } from "./_parts/Edit.js";
|
|
20
|
-
import { Actions as
|
|
21
|
-
const
|
|
22
|
+
import { Actions as q } from "./_parts/Actions.js";
|
|
23
|
+
const u = ({
|
|
22
24
|
companyId: n,
|
|
23
|
-
defaultValues:
|
|
25
|
+
defaultValues: s,
|
|
24
26
|
dictionary: a,
|
|
25
|
-
...
|
|
26
|
-
}) => (
|
|
27
|
-
const { baseSubmitHandler:
|
|
27
|
+
...P
|
|
28
|
+
}) => (te("Company.PaySchedule"), ne("Company.PaySchedule", a), /* @__PURE__ */ t(oe, { ...P, children: /* @__PURE__ */ t(ce, { companyId: n, defaultValues: s, children: P.children }) })), ce = ({ companyId: n, children: s, defaultValues: a }) => {
|
|
29
|
+
const { baseSubmitHandler: P, onEvent: h, fieldErrors: f } = re(), [i, m] = A("LIST_PAY_SCHEDULES"), [E, T] = A(null), O = {
|
|
28
30
|
frequency: a?.frequency ?? "Every week",
|
|
29
31
|
anchorPayDate: a?.anchorPayDate ? new Date(a.anchorPayDate) : void 0,
|
|
30
32
|
anchorEndOfPayPeriod: a?.anchorEndOfPayPeriod ? new Date(a.anchorEndOfPayPeriod) : void 0,
|
|
@@ -33,95 +35,75 @@ const f = ({
|
|
|
33
35
|
customName: a?.customName ?? "",
|
|
34
36
|
customTwicePerMonth: "false",
|
|
35
37
|
payPeriodPreviewRange: 0
|
|
36
|
-
},
|
|
38
|
+
}, { data: H } = X({
|
|
39
|
+
companyId: n
|
|
40
|
+
}), U = Z(), M = W(), D = z({
|
|
41
|
+
resolver: K($),
|
|
42
|
+
defaultValues: O
|
|
43
|
+
}), { watch: Y, setValue: S, reset: d, setError: l } = D;
|
|
44
|
+
_(() => {
|
|
45
|
+
f && f.forEach((o) => {
|
|
46
|
+
l(o.key, { message: o.message });
|
|
47
|
+
});
|
|
48
|
+
}, [l, f]);
|
|
49
|
+
const e = Y(), N = e.anchorPayDate && v(e.anchorPayDate) || "", b = e.anchorEndOfPayPeriod && v(e.anchorEndOfPayPeriod) || "", { data: g, isLoading: R } = Q(
|
|
37
50
|
{
|
|
38
51
|
companyId: n,
|
|
39
|
-
frequency:
|
|
40
|
-
anchorPayDate:
|
|
41
|
-
anchorEndOfPayPeriod:
|
|
42
|
-
day1:
|
|
43
|
-
day2:
|
|
52
|
+
frequency: e.frequency,
|
|
53
|
+
anchorPayDate: N,
|
|
54
|
+
anchorEndOfPayPeriod: b,
|
|
55
|
+
day1: e.day1 ?? void 0,
|
|
56
|
+
day2: e.day2 ?? void 0
|
|
44
57
|
},
|
|
45
58
|
{
|
|
46
|
-
enabled:
|
|
59
|
+
enabled: !!(e.anchorPayDate && e.anchorEndOfPayPeriod && (i === "ADD_PAY_SCHEDULE" || i === "EDIT_PAY_SCHEDULE"))
|
|
47
60
|
}
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
}, [A, D]);
|
|
60
|
-
const e = b();
|
|
61
|
-
w(() => {
|
|
62
|
-
e.frequency === "Twice per month" && e.day1 === 15 && e.day2 === 31 && e.customTwicePerMonth === void 0 ? v("customTwicePerMonth", "1st15th") : e.frequency === "Twice per month" && e.customTwicePerMonth === void 0 && v("customTwicePerMonth", "custom");
|
|
63
|
-
}, [e.frequency, e.day1, e.day2, v, e.customTwicePerMonth]), w(() => {
|
|
64
|
-
!e.anchorPayDate || !e.anchorEndOfPayPeriod || y({
|
|
65
|
-
frequency: e.frequency,
|
|
66
|
-
anchorPayDate: e.anchorPayDate.toString(),
|
|
67
|
-
anchorEndOfPayPeriod: e.anchorEndOfPayPeriod.toString(),
|
|
68
|
-
day1: e.day1 || void 0,
|
|
69
|
-
day2: e.day2 || void 0,
|
|
70
|
-
uuid: "",
|
|
71
|
-
version: i?.version || ""
|
|
72
|
-
//TODO: This needs to be set to something
|
|
73
|
-
});
|
|
74
|
-
}, [
|
|
75
|
-
e.anchorEndOfPayPeriod,
|
|
76
|
-
e.anchorPayDate,
|
|
77
|
-
e.day1,
|
|
78
|
-
e.day2,
|
|
79
|
-
e.frequency,
|
|
80
|
-
i?.version,
|
|
81
|
-
y
|
|
82
|
-
]);
|
|
83
|
-
const R = () => {
|
|
84
|
-
u("ADD_PAY_SCHEDULE"), s({});
|
|
85
|
-
}, x = () => {
|
|
86
|
-
u("LIST_PAY_SCHEDULES"), s({}), y(null);
|
|
87
|
-
}, B = (o) => {
|
|
88
|
-
s({
|
|
61
|
+
);
|
|
62
|
+
_(() => {
|
|
63
|
+
e.frequency === "Twice per month" && e.day1 === 15 && e.day2 === 31 && e.customTwicePerMonth === void 0 ? S("customTwicePerMonth", "1st15th") : e.frequency === "Twice per month" && e.customTwicePerMonth === void 0 && S("customTwicePerMonth", "custom");
|
|
64
|
+
}, [e.frequency, e.day1, e.day2, S, e.customTwicePerMonth]);
|
|
65
|
+
const x = () => {
|
|
66
|
+
m("ADD_PAY_SCHEDULE"), d({});
|
|
67
|
+
}, B = () => {
|
|
68
|
+
m("LIST_PAY_SCHEDULES"), d({});
|
|
69
|
+
}, F = (o) => {
|
|
70
|
+
d({
|
|
89
71
|
frequency: o.frequency,
|
|
90
72
|
anchorPayDate: o.anchorPayDate ? new Date(o.anchorPayDate) : void 0,
|
|
91
73
|
anchorEndOfPayPeriod: o.anchorEndOfPayPeriod ? new Date(o.anchorEndOfPayPeriod) : void 0,
|
|
92
74
|
day1: o.day1 ?? void 0,
|
|
93
75
|
day2: o.day2 ?? void 0,
|
|
94
76
|
customName: o.customName ?? ""
|
|
95
|
-
}), T(o),
|
|
96
|
-
},
|
|
97
|
-
|
|
77
|
+
}), T(o), m("EDIT_PAY_SCHEDULE");
|
|
78
|
+
}, I = () => {
|
|
79
|
+
h(p.PAY_SCHEDULE_DONE);
|
|
98
80
|
}, j = async (o) => {
|
|
99
|
-
await
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
const c = await
|
|
81
|
+
await P(o, async (r) => {
|
|
82
|
+
const y = (c) => c && v(c) || "";
|
|
83
|
+
if (i === "ADD_PAY_SCHEDULE") {
|
|
84
|
+
const c = await U.mutateAsync({
|
|
103
85
|
request: {
|
|
104
86
|
companyId: n,
|
|
105
87
|
requestBody: {
|
|
106
88
|
frequency: r.frequency,
|
|
107
|
-
anchorPayDate:
|
|
108
|
-
anchorEndOfPayPeriod:
|
|
89
|
+
anchorPayDate: y(r.anchorPayDate),
|
|
90
|
+
anchorEndOfPayPeriod: y(r.anchorEndOfPayPeriod),
|
|
109
91
|
customName: r.customName,
|
|
110
92
|
day1: r.day1,
|
|
111
93
|
day2: r.day2
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
96
|
});
|
|
115
|
-
|
|
116
|
-
} else if (
|
|
117
|
-
const c =
|
|
97
|
+
h(p.PAY_SCHEDULE_CREATED, c), d();
|
|
98
|
+
} else if (i === "EDIT_PAY_SCHEDULE") {
|
|
99
|
+
const c = E?.version, k = await M.mutateAsync({
|
|
118
100
|
request: {
|
|
119
|
-
payScheduleId:
|
|
101
|
+
payScheduleId: E?.uuid,
|
|
120
102
|
companyId: n,
|
|
121
103
|
requestBody: {
|
|
122
104
|
frequency: r.frequency,
|
|
123
|
-
anchorPayDate:
|
|
124
|
-
anchorEndOfPayPeriod:
|
|
105
|
+
anchorPayDate: y(r.anchorPayDate),
|
|
106
|
+
anchorEndOfPayPeriod: y(r.anchorEndOfPayPeriod),
|
|
125
107
|
customName: r.customName,
|
|
126
108
|
day1: r.day1,
|
|
127
109
|
day2: r.day2,
|
|
@@ -129,40 +111,40 @@ const f = ({
|
|
|
129
111
|
}
|
|
130
112
|
}
|
|
131
113
|
});
|
|
132
|
-
|
|
114
|
+
h(p.PAY_SCHEDULE_UPDATED, k), d();
|
|
133
115
|
}
|
|
134
|
-
|
|
116
|
+
m("LIST_PAY_SCHEDULES");
|
|
135
117
|
});
|
|
136
118
|
};
|
|
137
119
|
return /* @__PURE__ */ t(
|
|
138
|
-
|
|
120
|
+
V,
|
|
139
121
|
{
|
|
140
122
|
value: {
|
|
141
123
|
companyId: n,
|
|
142
|
-
handleAdd:
|
|
143
|
-
handleEdit:
|
|
144
|
-
handleCancel:
|
|
145
|
-
handleContinue:
|
|
146
|
-
mode:
|
|
147
|
-
paySchedules:
|
|
148
|
-
payPeriodPreview:
|
|
149
|
-
payPreviewLoading:
|
|
150
|
-
currentPaySchedule:
|
|
124
|
+
handleAdd: x,
|
|
125
|
+
handleEdit: F,
|
|
126
|
+
handleCancel: B,
|
|
127
|
+
handleContinue: I,
|
|
128
|
+
mode: i,
|
|
129
|
+
paySchedules: H.payScheduleList,
|
|
130
|
+
payPeriodPreview: g?.object?.payPeriods,
|
|
131
|
+
payPreviewLoading: R,
|
|
132
|
+
currentPaySchedule: E
|
|
151
133
|
},
|
|
152
|
-
children: /* @__PURE__ */ t("span", { "data-testid": "pay-schedule-edit-form", children: /* @__PURE__ */ t(
|
|
153
|
-
/* @__PURE__ */ t(
|
|
134
|
+
children: /* @__PURE__ */ t("span", { "data-testid": "pay-schedule-edit-form", children: /* @__PURE__ */ t(J, { ...D, children: /* @__PURE__ */ t(ee, { onSubmit: D.handleSubmit(j), children: s || /* @__PURE__ */ G(ae, { flexDirection: "column", children: [
|
|
135
|
+
/* @__PURE__ */ t(w, {}),
|
|
154
136
|
/* @__PURE__ */ t(C, {}),
|
|
155
137
|
/* @__PURE__ */ t(L, {}),
|
|
156
|
-
/* @__PURE__ */ t(
|
|
138
|
+
/* @__PURE__ */ t(q, {})
|
|
157
139
|
] }) }) }) })
|
|
158
140
|
}
|
|
159
141
|
);
|
|
160
142
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
143
|
+
u.Head = w;
|
|
144
|
+
u.List = C;
|
|
145
|
+
u.Edit = L;
|
|
146
|
+
u.Actions = q;
|
|
165
147
|
export {
|
|
166
|
-
|
|
148
|
+
u as PaySchedule
|
|
167
149
|
};
|
|
168
150
|
//# sourceMappingURL=PaySchedule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/PaySchedule.tsx"],"sourcesContent":["import type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { Frequency } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayschedules'\nimport type { MODE, PayScheduleInputs, PayScheduleOutputs } from './usePaySchedule'\nimport {\n PayScheduleProvider,\n PayScheduleSchema,\n type PayScheduleDefaultValues,\n} from './usePaySchedule'\nimport { Actions, Edit, Head, List } from './_parts'\nimport { Form } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface PayScheduleProps extends CommonComponentInterface<'Company.PaySchedule'> {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n dictionary,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\n useComponentDictionary('Company.PaySchedule', dictionary)\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} defaultValues={defaultValues}>\n {props.children}\n </Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ companyId, children, defaultValues }: PayScheduleProps) => {\n const { baseSubmitHandler, onEvent, fieldErrors } = useBase()\n const [mode, setMode] = useState<MODE>('LIST_PAY_SCHEDULES')\n const [currentPaySchedule, setCurrentPaySchedule] = useState<PayScheduleType | null>(null)\n const transformedDefaultValues: PayScheduleInputs = {\n frequency: defaultValues?.frequency ?? 'Every week',\n anchorPayDate: defaultValues?.anchorPayDate ? new Date(defaultValues.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: defaultValues?.anchorEndOfPayPeriod\n ? new Date(defaultValues.anchorEndOfPayPeriod)\n : undefined,\n day1: defaultValues?.day1 ?? undefined,\n day2: defaultValues?.day2 ?? undefined,\n customName: defaultValues?.customName ?? '',\n customTwicePerMonth: 'false',\n payPeriodPreviewRange: 0,\n }\n\n const [payScheduleDraft, setPayScheduleDraft] = useState<PayScheduleType | null>(null)\n const { data: payPreviewData, isLoading } = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: payScheduleDraft?.frequency as Frequency,\n anchorPayDate: payScheduleDraft?.anchorPayDate ?? '',\n anchorEndOfPayPeriod: payScheduleDraft?.anchorEndOfPayPeriod ?? '',\n day1: payScheduleDraft?.day1 ?? undefined,\n day2: payScheduleDraft?.day2 ?? undefined,\n },\n {\n enabled: true,\n }, // Casting to non-null because we know it's not null from the enabled prop\n )\n\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId,\n })\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const formMethods = useForm<PayScheduleInputs, unknown, PayScheduleOutputs>({\n resolver: zodResolver(PayScheduleSchema),\n defaultValues: transformedDefaultValues,\n })\n const { watch, setValue, reset, setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors) {\n // TODO: These error messages are not being localized correctly\n fieldErrors.forEach(error => {\n setError(error.key as keyof PayScheduleInputs, { message: error.message })\n })\n }\n }, [setError, fieldErrors])\n\n const allValues = watch()\n\n // Set the custom_twice_per_month value based on the frequency and day_1 and day_2 values as it is not set by the API call\n useEffect(() => {\n if (\n allValues.frequency === 'Twice per month' &&\n allValues.day1 === 15 &&\n allValues.day2 === 31 &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `1st15th`)\n } else if (\n allValues.frequency === 'Twice per month' &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `custom`)\n }\n }, [allValues.frequency, allValues.day1, allValues.day2, setValue, allValues.customTwicePerMonth])\n\n useEffect(() => {\n // Don't update if dates are not set\n if (!allValues.anchorPayDate || !allValues.anchorEndOfPayPeriod) {\n return\n }\n\n setPayScheduleDraft({\n frequency: allValues.frequency,\n anchorPayDate: allValues.anchorPayDate.toString(),\n anchorEndOfPayPeriod: allValues.anchorEndOfPayPeriod.toString(),\n day1: allValues.day1 || undefined,\n day2: allValues.day2 || undefined,\n uuid: '',\n version: currentPaySchedule?.version || '', //TODO: This needs to be set to something\n })\n }, [\n allValues.anchorEndOfPayPeriod,\n allValues.anchorPayDate,\n allValues.day1,\n allValues.day2,\n allValues.frequency,\n currentPaySchedule?.version,\n setPayScheduleDraft,\n ])\n\n // Custom effect to show/hide pay schedule preview errors\n\n const handleAdd = () => {\n setMode('ADD_PAY_SCHEDULE')\n reset({})\n }\n const handleCancel = () => {\n setMode('LIST_PAY_SCHEDULES')\n reset({})\n setPayScheduleDraft(null)\n }\n const handleEdit = (schedule: PayScheduleType) => {\n reset({\n frequency: schedule.frequency as Frequency,\n anchorPayDate: schedule.anchorPayDate ? new Date(schedule.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: schedule.anchorEndOfPayPeriod\n ? new Date(schedule.anchorEndOfPayPeriod)\n : undefined,\n day1: schedule.day1 ?? undefined,\n day2: schedule.day2 ?? undefined,\n customName: schedule.customName ?? '',\n })\n setCurrentPaySchedule(schedule)\n setMode('EDIT_PAY_SCHEDULE')\n }\n const handleContinue = () => {\n onEvent(componentEvents.PAY_SCHEDULE_DONE)\n }\n const onSubmit: SubmitHandler<PayScheduleOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const formatPayloadDate = (date: Date | undefined): string => {\n return date ? formatDateToStringDate(date) || '' : ''\n }\n\n if (mode === 'ADD_PAY_SCHEDULE') {\n const createPayScheduleResponse = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId: companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_CREATED, createPayScheduleResponse)\n reset()\n setPayScheduleDraft(null)\n } else if (mode === 'EDIT_PAY_SCHEDULE') {\n const version = currentPaySchedule?.version\n const updatePayScheduleResponse = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule?.uuid as string,\n companyId: companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n version: version as string,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_UPDATED, updatePayScheduleResponse)\n reset()\n setPayScheduleDraft(null)\n }\n setMode('LIST_PAY_SCHEDULES')\n })\n }\n\n return (\n <PayScheduleProvider\n value={{\n companyId,\n handleAdd,\n handleEdit,\n handleCancel,\n handleContinue,\n mode,\n paySchedules: paySchedules.payScheduleList,\n payPeriodPreview: payPreviewData?.object?.payPeriods,\n payPreviewLoading: isLoading,\n currentPaySchedule,\n }}\n >\n <span data-testid=\"pay-schedule-edit-form\">\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Edit />\n <Actions />\n </Flex>\n )}\n </Form>\n </FormProvider>\n </span>\n </PayScheduleProvider>\n )\n}\n\nPaySchedule.Head = Head\nPaySchedule.List = List\nPaySchedule.Edit = Edit\nPaySchedule.Actions = Actions\n"],"names":["PaySchedule","companyId","defaultValues","dictionary","props","useI18n","useComponentDictionary","jsx","BaseComponent","Root","children","baseSubmitHandler","onEvent","fieldErrors","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","payScheduleDraft","setPayScheduleDraft","payPreviewData","isLoading","usePaySchedulesGetPreview","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","zodResolver","PayScheduleSchema","watch","setValue","reset","setError","useEffect","error","allValues","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","formatDateToStringDate","createPayScheduleResponse","version","updatePayScheduleResponse","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,OACEC,GAAQ,qBAAqB,GAC7BC,GAAuB,uBAAuBH,CAAU,GAEtD,gBAAAI,EAACC,IAAe,EAAA,GAAGJ,GACjB,UAAA,gBAAAG,EAACE,MAAK,WAAAR,GAAsB,eAAAC,GACzB,UAAME,EAAA,SAAA,CACT,EACF,CA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/PaySchedule/PaySchedule.tsx"],"sourcesContent":["import type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { Frequency } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayschedules'\nimport type { MODE, PayScheduleInputs, PayScheduleOutputs } from './usePaySchedule'\nimport {\n PayScheduleProvider,\n PayScheduleSchema,\n type PayScheduleDefaultValues,\n} from './usePaySchedule'\nimport { Actions, Edit, Head, List } from './_parts'\nimport { Form } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface PayScheduleProps extends CommonComponentInterface<'Company.PaySchedule'> {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n dictionary,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\n useComponentDictionary('Company.PaySchedule', dictionary)\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} defaultValues={defaultValues}>\n {props.children}\n </Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ companyId, children, defaultValues }: PayScheduleProps) => {\n const { baseSubmitHandler, onEvent, fieldErrors } = useBase()\n const [mode, setMode] = useState<MODE>('LIST_PAY_SCHEDULES')\n const [currentPaySchedule, setCurrentPaySchedule] = useState<PayScheduleType | null>(null)\n const transformedDefaultValues: PayScheduleInputs = {\n frequency: defaultValues?.frequency ?? 'Every week',\n anchorPayDate: defaultValues?.anchorPayDate ? new Date(defaultValues.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: defaultValues?.anchorEndOfPayPeriod\n ? new Date(defaultValues.anchorEndOfPayPeriod)\n : undefined,\n day1: defaultValues?.day1 ?? undefined,\n day2: defaultValues?.day2 ?? undefined,\n customName: defaultValues?.customName ?? '',\n customTwicePerMonth: 'false',\n payPeriodPreviewRange: 0,\n }\n\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId,\n })\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const formMethods = useForm<PayScheduleInputs, unknown, PayScheduleOutputs>({\n resolver: zodResolver(PayScheduleSchema),\n defaultValues: transformedDefaultValues,\n })\n const { watch, setValue, reset, setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors) {\n // TODO: These error messages are not being localized correctly\n fieldErrors.forEach(error => {\n setError(error.key as keyof PayScheduleInputs, { message: error.message })\n })\n }\n }, [setError, fieldErrors])\n\n const allValues = watch()\n\n const formattedAnchorPayDate = allValues.anchorPayDate\n ? formatDateToStringDate(allValues.anchorPayDate) || ''\n : ''\n const formattedAnchorEndOfPayPeriod = allValues.anchorEndOfPayPeriod\n ? formatDateToStringDate(allValues.anchorEndOfPayPeriod) || ''\n : ''\n\n const { data: payPreviewData, isLoading } = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: allValues.frequency,\n anchorPayDate: formattedAnchorPayDate,\n anchorEndOfPayPeriod: formattedAnchorEndOfPayPeriod,\n day1: allValues.day1 ?? undefined,\n day2: allValues.day2 ?? undefined,\n },\n {\n enabled: Boolean(\n allValues.anchorPayDate &&\n allValues.anchorEndOfPayPeriod &&\n (mode === 'ADD_PAY_SCHEDULE' || mode === 'EDIT_PAY_SCHEDULE'),\n ),\n },\n )\n\n // Set the custom_twice_per_month value based on the frequency and day_1 and day_2 values as it is not set by the API call\n useEffect(() => {\n if (\n allValues.frequency === 'Twice per month' &&\n allValues.day1 === 15 &&\n allValues.day2 === 31 &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `1st15th`)\n } else if (\n allValues.frequency === 'Twice per month' &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `custom`)\n }\n }, [allValues.frequency, allValues.day1, allValues.day2, setValue, allValues.customTwicePerMonth])\n\n const handleAdd = () => {\n setMode('ADD_PAY_SCHEDULE')\n reset({})\n }\n const handleCancel = () => {\n setMode('LIST_PAY_SCHEDULES')\n reset({})\n }\n const handleEdit = (schedule: PayScheduleType) => {\n reset({\n frequency: schedule.frequency as Frequency,\n anchorPayDate: schedule.anchorPayDate ? new Date(schedule.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: schedule.anchorEndOfPayPeriod\n ? new Date(schedule.anchorEndOfPayPeriod)\n : undefined,\n day1: schedule.day1 ?? undefined,\n day2: schedule.day2 ?? undefined,\n customName: schedule.customName ?? '',\n })\n setCurrentPaySchedule(schedule)\n setMode('EDIT_PAY_SCHEDULE')\n }\n const handleContinue = () => {\n onEvent(componentEvents.PAY_SCHEDULE_DONE)\n }\n const onSubmit: SubmitHandler<PayScheduleOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const formatPayloadDate = (date: Date | undefined): string => {\n return date ? formatDateToStringDate(date) || '' : ''\n }\n\n if (mode === 'ADD_PAY_SCHEDULE') {\n const createPayScheduleResponse = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_CREATED, createPayScheduleResponse)\n reset()\n } else if (mode === 'EDIT_PAY_SCHEDULE') {\n const version = currentPaySchedule?.version\n const updatePayScheduleResponse = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule?.uuid as string,\n companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n version: version as string,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_UPDATED, updatePayScheduleResponse)\n reset()\n }\n setMode('LIST_PAY_SCHEDULES')\n })\n }\n\n return (\n <PayScheduleProvider\n value={{\n companyId,\n handleAdd,\n handleEdit,\n handleCancel,\n handleContinue,\n mode,\n paySchedules: paySchedules.payScheduleList,\n payPeriodPreview: payPreviewData?.object?.payPeriods,\n payPreviewLoading: isLoading,\n currentPaySchedule,\n }}\n >\n <span data-testid=\"pay-schedule-edit-form\">\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Edit />\n <Actions />\n </Flex>\n )}\n </Form>\n </FormProvider>\n </span>\n </PayScheduleProvider>\n )\n}\n\nPaySchedule.Head = Head\nPaySchedule.List = List\nPaySchedule.Edit = Edit\nPaySchedule.Actions = Actions\n"],"names":["PaySchedule","companyId","defaultValues","dictionary","props","useI18n","useComponentDictionary","jsx","BaseComponent","Root","children","baseSubmitHandler","onEvent","fieldErrors","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","zodResolver","PayScheduleSchema","watch","setValue","reset","setError","useEffect","error","allValues","formattedAnchorPayDate","formatDateToStringDate","formattedAnchorEndOfPayPeriod","payPreviewData","isLoading","usePaySchedulesGetPreview","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","createPayScheduleResponse","version","updatePayScheduleResponse","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,OACEC,GAAQ,qBAAqB,GAC7BC,GAAuB,uBAAuBH,CAAU,GAEtD,gBAAAI,EAACC,IAAe,EAAA,GAAGJ,GACjB,UAAA,gBAAAG,EAACE,MAAK,WAAAR,GAAsB,eAAAC,GACzB,UAAME,EAAA,SAAA,CACT,EACF,CAAA,IAIEK,KAAO,CAAC,EAAE,WAAAR,GAAW,UAAAS,GAAU,eAAAR,QAAsC;AACzE,QAAM,EAAE,mBAAAS,GAAmB,SAAAC,GAAS,aAAAC,EAAA,IAAgBC,GAAQ,GACtD,CAACC,GAAMC,CAAO,IAAIC,EAAe,oBAAoB,GACrD,CAACC,GAAoBC,CAAqB,IAAIF,EAAiC,IAAI,GACnFG,IAA8C;AAAA,IAClD,WAAWlB,GAAe,aAAa;AAAA,IACvC,eAAeA,GAAe,gBAAgB,IAAI,KAAKA,EAAc,aAAa,IAAI;AAAA,IACtF,sBAAsBA,GAAe,uBACjC,IAAI,KAAKA,EAAc,oBAAoB,IAC3C;AAAA,IACJ,MAAMA,GAAe,QAAQ;AAAA,IAC7B,MAAMA,GAAe,QAAQ;AAAA,IAC7B,YAAYA,GAAe,cAAc;AAAA,IACzC,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,EACzB,GAEM,EAAE,MAAMmB,EAAa,IAAIC,EAA8B;AAAA,IAC3D,WAAArB;AAAA,EAAA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EAAY,OAAOgE;AACnBhE,EAAY,OAAOiE;AACnBjE,EAAY,UAAUkE;"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { jsxs as e, Fragment as d, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as l } from "react-i18next";
|
|
3
3
|
import { usePaySchedule as m } from "../usePaySchedule.js";
|
|
4
|
-
import
|
|
4
|
+
import "classnames";
|
|
5
|
+
import { ActionsLayout as i } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
5
6
|
import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
6
|
-
const
|
|
7
|
-
const { t: n } = l("Company.PaySchedule"), { mode: c, handleAdd:
|
|
7
|
+
const E = () => {
|
|
8
|
+
const { t: n } = l("Company.PaySchedule"), { mode: c, handleAdd: a, handleCancel: r, handleContinue: s } = m(), t = u();
|
|
8
9
|
return /* @__PURE__ */ e(d, { children: [
|
|
9
|
-
c === "LIST_PAY_SCHEDULES" && /* @__PURE__ */ e(
|
|
10
|
+
c === "LIST_PAY_SCHEDULES" && /* @__PURE__ */ e(i, { children: [
|
|
10
11
|
/* @__PURE__ */ o(
|
|
11
12
|
t.Button,
|
|
12
13
|
{
|
|
13
14
|
variant: "secondary",
|
|
14
15
|
onClick: () => {
|
|
15
|
-
|
|
16
|
+
a();
|
|
16
17
|
},
|
|
17
18
|
children: n("addAnotherPayScheduleCta")
|
|
18
19
|
}
|
|
@@ -28,26 +29,26 @@ const S = () => {
|
|
|
28
29
|
}
|
|
29
30
|
)
|
|
30
31
|
] }),
|
|
31
|
-
c === "ADD_PAY_SCHEDULE" && /* @__PURE__ */ e(
|
|
32
|
+
c === "ADD_PAY_SCHEDULE" && /* @__PURE__ */ e(i, { children: [
|
|
32
33
|
/* @__PURE__ */ o(
|
|
33
34
|
t.Button,
|
|
34
35
|
{
|
|
35
36
|
variant: "secondary",
|
|
36
37
|
onClick: () => {
|
|
37
|
-
|
|
38
|
+
r();
|
|
38
39
|
},
|
|
39
40
|
children: n("actions.cancel")
|
|
40
41
|
}
|
|
41
42
|
),
|
|
42
43
|
/* @__PURE__ */ o(t.Button, { type: "submit", children: n("actions.save") })
|
|
43
44
|
] }),
|
|
44
|
-
c === "EDIT_PAY_SCHEDULE" && /* @__PURE__ */ e(
|
|
45
|
+
c === "EDIT_PAY_SCHEDULE" && /* @__PURE__ */ e(i, { children: [
|
|
45
46
|
/* @__PURE__ */ o(
|
|
46
47
|
t.Button,
|
|
47
48
|
{
|
|
48
49
|
variant: "secondary",
|
|
49
50
|
onClick: () => {
|
|
50
|
-
|
|
51
|
+
r();
|
|
51
52
|
},
|
|
52
53
|
children: n("actions.cancel")
|
|
53
54
|
}
|
|
@@ -57,6 +58,6 @@ const S = () => {
|
|
|
57
58
|
] });
|
|
58
59
|
};
|
|
59
60
|
export {
|
|
60
|
-
|
|
61
|
+
E as Actions
|
|
61
62
|
};
|
|
62
63
|
//# sourceMappingURL=Actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const Actions = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const { mode, handleAdd, handleCancel, handleContinue } = usePaySchedule()\n const Components = useComponentContext()\n\n return (\n <>\n {mode === 'LIST_PAY_SCHEDULES' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleAdd()\n }}\n >\n {t('addAnotherPayScheduleCta')}\n </Components.Button>\n <Components.Button\n variant=\"primary\"\n onClick={() => {\n handleContinue()\n }}\n >\n {t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n {mode === 'ADD_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n {mode === 'EDIT_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n </>\n )\n}\n"],"names":["Actions","t","useTranslation","mode","handleAdd","handleCancel","handleContinue","usePaySchedule","Components","useComponentContext","jsxs","Fragment","ActionsLayout","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const Actions = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const { mode, handleAdd, handleCancel, handleContinue } = usePaySchedule()\n const Components = useComponentContext()\n\n return (\n <>\n {mode === 'LIST_PAY_SCHEDULES' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleAdd()\n }}\n >\n {t('addAnotherPayScheduleCta')}\n </Components.Button>\n <Components.Button\n variant=\"primary\"\n onClick={() => {\n handleContinue()\n }}\n >\n {t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n {mode === 'ADD_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n {mode === 'EDIT_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n </>\n )\n}\n"],"names":["Actions","t","useTranslation","mode","handleAdd","handleCancel","handleContinue","usePaySchedule","Components","useComponentContext","jsxs","Fragment","ActionsLayout","jsx"],"mappings":";;;;;;AAKO,MAAMA,IAAU,MAAM;AAC3B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5C,EAAE,MAAAC,GAAM,WAAAC,GAAW,cAAAC,GAAc,gBAAAC,EAAA,IAAmBC,EAAe,GACnEC,IAAaC,EAAoB;AAEvC,SAEK,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAASR,MAAA,0CACPS,GACC,EAAA,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAACL,EAAW;AAAA,QAAX;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,MAAM;AACH,YAAAJ,EAAA;AAAA,UACZ;AAAA,UAEC,YAAE,0BAA0B;AAAA,QAAA;AAAA,MAC/B;AAAA,MACA,gBAAAS;AAAA,QAACL,EAAW;AAAA,QAAX;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,MAAM;AACE,YAAAF,EAAA;AAAA,UACjB;AAAA,UAEC,YAAE,aAAa;AAAA,QAAA;AAAA,MAAA;AAAA,IAClB,GACF;AAAA,IAEDH,MAAS,sBACR,gBAAAO,EAACE,GACC,EAAA,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAACL,EAAW;AAAA,QAAX;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,MAAM;AACA,YAAAH,EAAA;AAAA,UACf;AAAA,UAEC,YAAE,gBAAgB;AAAA,QAAA;AAAA,MACrB;AAAA,MACA,gBAAAQ,EAACL,EAAW,QAAX,EAAkB,MAAK,UAAU,UAAAP,EAAE,cAAc,EAAE,CAAA;AAAA,IAAA,GACtD;AAAA,IAEDE,MAAS,uBACR,gBAAAO,EAACE,GACC,EAAA,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAACL,EAAW;AAAA,QAAX;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,MAAM;AACA,YAAAH,EAAA;AAAA,UACf;AAAA,UAEC,YAAE,gBAAgB;AAAA,QAAA;AAAA,MACrB;AAAA,MACA,gBAAAQ,EAACL,EAAW,QAAX,EAAkB,MAAK,UAAU,UAAAP,EAAE,cAAc,EAAE,CAAA;AAAA,IAAA,EACtD,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useFormContext as
|
|
3
|
-
import { useTranslation as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { usePaySchedule as
|
|
6
|
-
import
|
|
7
|
-
import { Flex as
|
|
8
|
-
import { Grid as
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext as S, useWatch as u } from "react-hook-form";
|
|
3
|
+
import { useTranslation as T } from "react-i18next";
|
|
4
|
+
import { useState as N, useEffect as h } from "react";
|
|
5
|
+
import { usePaySchedule as x } from "../usePaySchedule.js";
|
|
6
|
+
import n from "./Edit.module.scss.js";
|
|
7
|
+
import { Flex as f } from "../../../Common/Flex/Flex.js";
|
|
8
|
+
import { Grid as E } from "../../../Common/Grid/Grid.js";
|
|
9
|
+
import "classnames";
|
|
10
|
+
import { useComponentContext as R } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
11
|
+
import { formatDateNamedWeekdayShortPlusDate as P } from "../../../../helpers/dateFormatting.js";
|
|
12
|
+
import { TextInputField as O } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
13
|
+
import { SelectField as v } from "../../../Common/Fields/SelectField/SelectField.js";
|
|
14
|
+
import { RadioGroupField as F } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
14
15
|
import { NumberInputField as D } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
15
|
-
import { DatePickerField as
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
-
|
|
16
|
+
import { DatePickerField as w } from "../../../Common/Fields/DatePickerField/DatePickerField.js";
|
|
17
|
+
const J = () => {
|
|
18
|
+
const d = R(), { t: e } = T("Company.PaySchedule"), { payPeriodPreview: t, mode: p, payPreviewLoading: b } = x(), { setValue: o } = S(), [a, g] = N(0), i = u({ name: "frequency" }), l = u({ name: "customTwicePerMonth" }), y = u({ name: "payPeriodPreviewRange" }), q = i === "Twice per month" && l === "custom" || i === "Monthly", C = i === "Twice per month" && l === "custom";
|
|
19
|
+
return h(() => {
|
|
20
|
+
i === "Twice per month" && l === "1st15th" && (o("day1", 15), o("day2", 31));
|
|
21
|
+
}, [i, l, o]), h(() => {
|
|
22
|
+
y === void 0 && o("payPeriodPreviewRange", a);
|
|
23
|
+
}, [a, o, y]), p !== "EDIT_PAY_SCHEDULE" && p !== "ADD_PAY_SCHEDULE" ? null : /* @__PURE__ */ r("div", { className: n.payScheduleContainer, children: /* @__PURE__ */ m(E, { gap: 32, gridTemplateColumns: { base: "1fr", small: "1fr 1fr" }, children: [
|
|
24
|
+
/* @__PURE__ */ r("div", { className: n.payScheduleForm, children: /* @__PURE__ */ m(f, { flexDirection: "column", children: [
|
|
25
|
+
/* @__PURE__ */ r(O, { name: "customName", label: "Name", isRequired: !0 }),
|
|
26
|
+
/* @__PURE__ */ r(
|
|
27
|
+
v,
|
|
27
28
|
{
|
|
28
29
|
name: "frequency",
|
|
29
30
|
label: e("labels.frequency"),
|
|
@@ -32,11 +33,12 @@ const z = () => {
|
|
|
32
33
|
{ value: "Every other week", label: e("frequencies.everyOtherWeek") },
|
|
33
34
|
{ value: "Twice per month", label: e("frequencies.twicePerMonth") },
|
|
34
35
|
{ value: "Monthly", label: e("frequencies.monthly") }
|
|
35
|
-
]
|
|
36
|
+
],
|
|
37
|
+
isRequired: !0
|
|
36
38
|
}
|
|
37
39
|
),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
i === "Twice per month" && /* @__PURE__ */ r(
|
|
41
|
+
F,
|
|
40
42
|
{
|
|
41
43
|
name: "customTwicePerMonth",
|
|
42
44
|
label: e("labels.frequencyOptions"),
|
|
@@ -47,69 +49,81 @@ const z = () => {
|
|
|
47
49
|
]
|
|
48
50
|
}
|
|
49
51
|
),
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
|
|
52
|
+
/* @__PURE__ */ r(
|
|
53
|
+
w,
|
|
52
54
|
{
|
|
53
55
|
name: "anchorPayDate",
|
|
54
56
|
label: e("labels.firstPayDate"),
|
|
55
|
-
description: e("descriptions.anchorPayDateDescription")
|
|
57
|
+
description: e("descriptions.anchorPayDateDescription"),
|
|
58
|
+
isRequired: !0
|
|
56
59
|
}
|
|
57
60
|
),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
|
|
61
|
+
/* @__PURE__ */ r(
|
|
62
|
+
w,
|
|
60
63
|
{
|
|
61
64
|
name: "anchorEndOfPayPeriod",
|
|
62
65
|
label: e("labels.firstPayPeriodEndDate"),
|
|
63
|
-
description: e("descriptions.anchorEndOfPayPeriodDescription")
|
|
66
|
+
description: e("descriptions.anchorEndOfPayPeriodDescription"),
|
|
67
|
+
isRequired: !0
|
|
64
68
|
}
|
|
65
69
|
),
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ r("div", { className: q ? "" : n.visuallyHidden, children: /* @__PURE__ */ r(D, { name: "day1", label: e("labels.firstPayDayOfTheMonth"), isRequired: !0 }) }),
|
|
71
|
+
/* @__PURE__ */ r("div", { className: C ? "" : n.visuallyHidden, children: /* @__PURE__ */ r(D, { name: "day2", label: e("labels.lastPayDayOfTheMonth"), isRequired: !0 }) })
|
|
68
72
|
] }) }),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
!
|
|
71
|
-
|
|
73
|
+
/* @__PURE__ */ r(f, { flexDirection: "column", gap: 4, justifyContent: "center", alignItems: "center", children: t && t[a] ? /* @__PURE__ */ m("div", { className: n.calendarContainer, children: [
|
|
74
|
+
!b && /* @__PURE__ */ r(
|
|
75
|
+
v,
|
|
72
76
|
{
|
|
73
77
|
name: "payPeriodPreviewRange",
|
|
74
78
|
label: e("labels.preview"),
|
|
75
|
-
options:
|
|
79
|
+
options: t.map((s, c) => ({
|
|
76
80
|
value: String(c),
|
|
77
|
-
label: `${
|
|
81
|
+
label: `${P(s.startDate)} – ${P(s.endDate)}`
|
|
78
82
|
})),
|
|
79
|
-
defaultValue: String(
|
|
83
|
+
defaultValue: String(a),
|
|
80
84
|
onChange: (s) => {
|
|
81
85
|
const c = Number(s);
|
|
82
86
|
isNaN(c) || g(c);
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
d.CalendarPreview,
|
|
88
92
|
{
|
|
89
93
|
dateRange: {
|
|
90
|
-
start: new Date(
|
|
91
|
-
end: new Date(
|
|
94
|
+
start: new Date(t[a].startDate),
|
|
95
|
+
end: new Date(t[a].endDate),
|
|
92
96
|
label: e("payPreview.payPeriod") || "Pay Period"
|
|
93
97
|
},
|
|
94
98
|
highlightDates: [
|
|
95
99
|
{
|
|
96
|
-
date: new Date(
|
|
100
|
+
date: new Date(t[a].checkDate),
|
|
97
101
|
highlightColor: "primary",
|
|
98
102
|
label: e("payPreview.payday") || "Payday"
|
|
99
103
|
},
|
|
100
104
|
{
|
|
101
|
-
date: new Date(
|
|
105
|
+
date: new Date(t[a].runPayrollBy),
|
|
102
106
|
highlightColor: "secondary",
|
|
103
107
|
label: e("payPreview.payrollDeadline") || "Payroll Deadline"
|
|
104
108
|
}
|
|
105
109
|
]
|
|
106
110
|
},
|
|
107
|
-
|
|
111
|
+
a
|
|
108
112
|
)
|
|
109
|
-
] })
|
|
113
|
+
] }) : /* @__PURE__ */ r("div", { className: n.calendarContainer, children: /* @__PURE__ */ r(
|
|
114
|
+
d.Alert,
|
|
115
|
+
{
|
|
116
|
+
status: "info",
|
|
117
|
+
label: e("previewAlert.title", "Pay Schedule Preview"),
|
|
118
|
+
children: /* @__PURE__ */ r(d.Text, { children: e(
|
|
119
|
+
"previewAlert.description",
|
|
120
|
+
"Complete all the required fields on the left to see a preview of your pay schedule."
|
|
121
|
+
) })
|
|
122
|
+
}
|
|
123
|
+
) }) })
|
|
110
124
|
] }) });
|
|
111
125
|
};
|
|
112
126
|
export {
|
|
113
|
-
|
|
127
|
+
J as Edit
|
|
114
128
|
};
|
|
115
129
|
//# sourceMappingURL=Edit.js.map
|