@gusto/embedded-react-sdk 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +5 -3
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js.map +1 -1
- package/dist/components/Common/FadeIn/FadeIn.module.scss.js +4 -4
- package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.js +1 -1
- package/dist/components/Common/FieldCaption/FieldCaption.js.map +1 -0
- package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.js +1 -1
- package/dist/components/Common/FieldDescription/FieldDescription.js.map +1 -0
- package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.js +1 -1
- package/dist/components/Common/FieldErrorMessage/FieldErrorMessage.js.map +1 -0
- package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.js +1 -1
- package/dist/components/Common/FieldLayout/FieldLayout.js.map +1 -0
- package/dist/components/Common/FieldLayout/FieldLayoutTypes.d.ts +52 -0
- package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.js +1 -1
- package/dist/components/Common/Fieldset/Fieldset.js.map +1 -0
- package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.js +2 -2
- package/dist/components/Common/HorizontalFieldLayout/HorizontalFieldLayout.js.map +1 -0
- package/dist/components/Common/SignatureForm/SignatureForm.d.ts +12 -6
- package/dist/components/Common/SignatureForm/SignatureForm.js +10 -10
- package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Common/UI/Alert/Alert.d.ts +1 -1
- package/dist/components/Common/UI/Alert/Alert.js +13 -12
- package/dist/components/Common/UI/Alert/Alert.js.map +1 -1
- package/dist/components/Common/UI/Alert/AlertTypes.d.ts +16 -4
- package/dist/components/Common/UI/Badge/BadgeTypes.d.ts +6 -0
- package/dist/components/Common/UI/Button/Button.js +28 -27
- package/dist/components/Common/UI/Button/Button.js.map +1 -1
- package/dist/components/Common/UI/Button/Button.module.scss.js +1 -1
- package/dist/components/Common/UI/Button/ButtonTypes.d.ts +29 -4
- package/dist/components/Common/UI/CalendarPreview/CalendarPreviewTypes.d.ts +24 -0
- package/dist/components/Common/UI/Card/Card.module.scss.js +1 -1
- package/dist/components/Common/UI/Card/CardTypes.d.ts +12 -4
- package/dist/components/Common/UI/Checkbox/Checkbox.js +4 -4
- package/dist/components/Common/UI/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Common/UI/Checkbox/CheckboxTypes.d.ts +16 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.js +4 -4
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.d.ts +33 -3
- package/dist/components/Common/UI/ComboBox/ComboBox.js +8 -8
- package/dist/components/Common/UI/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +31 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.js +13 -13
- package/dist/components/Common/UI/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/Common/UI/DatePicker/DatePickerTypes.d.ts +25 -1
- package/dist/components/Common/UI/Heading/HeadingTypes.d.ts +12 -0
- package/dist/components/Common/UI/Link/LinkTypes.d.ts +53 -1
- package/dist/components/Common/UI/List/ListTypes.d.ts +3 -5
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +30 -0
- package/dist/components/Common/UI/NumberInput/NumberInput.js +4 -4
- package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInputTypes.d.ts +34 -1
- package/dist/components/Common/UI/ProgressBar/ProgressBarTypes.d.ts +12 -0
- package/dist/components/Common/UI/Radio/Radio.js +1 -1
- package/dist/components/Common/UI/Radio/Radio.js.map +1 -1
- package/dist/components/Common/UI/Radio/RadioTypes.d.ts +16 -1
- package/dist/components/Common/UI/RadioGroup/RadioGroup.js +4 -4
- package/dist/components/Common/UI/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.d.ts +33 -3
- package/dist/components/Common/UI/Select/Select.js +8 -8
- package/dist/components/Common/UI/Select/Select.js.map +1 -1
- package/dist/components/Common/UI/Select/SelectTypes.d.ts +34 -1
- package/dist/components/Common/UI/Switch/Switch.js +1 -1
- package/dist/components/Common/UI/Switch/Switch.js.map +1 -1
- package/dist/components/Common/UI/Switch/SwitchTypes.d.ts +25 -1
- package/dist/components/Common/UI/Table/TableTypes.d.ts +21 -0
- package/dist/components/Common/UI/Text/TextTypes.d.ts +18 -0
- package/dist/components/Common/UI/TextInput/TextInput.js +1 -1
- package/dist/components/Common/UI/TextInput/TextInput.js.map +1 -1
- package/dist/components/Common/UI/TextInput/TextInputTypes.d.ts +22 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.js +12 -12
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +7 -7
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.d.ts +2 -2
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.d.ts +41 -15
- package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.js +17 -20
- package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +10 -10
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.d.ts +17 -11
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +42 -45
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js +6 -6
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.d.ts +12 -6
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +2 -2
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js +10 -10
- package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.d.ts +12 -6
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +17 -17
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
- package/dist/components/Company/DocumentSignerFlow/SignatureForm/SignatureForm.js +1 -1
- package/dist/components/Company/DocumentSignerFlow/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.js +5 -5
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.d.ts +18 -8
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +12 -16
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Industry.js +1 -1
- package/dist/components/Company/Industry/Industry.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.d.ts +27 -11
- package/dist/components/Company/Locations/LocationForm/Form.js +24 -24
- package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.js +24 -24
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +7 -7
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.js +28 -31
- package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.module.scss.js +8 -0
- package/dist/components/Company/PaySchedule/_parts/List.module.scss.js.map +1 -0
- package/dist/components/Company/PaySchedule/usePaySchedule.d.ts +31 -13
- package/dist/components/Company/PaySchedule/usePaySchedule.js +15 -20
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.d.ts +3 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +3 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +66 -77
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Employee/Compensation/Compensation.js +5 -5
- package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
- package/dist/components/Employee/Compensation/List.js +10 -10
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Compensation/useCompensation.d.ts +90 -42
- package/dist/components/Employee/Compensation/useCompensation.js +45 -69
- package/dist/components/Employee/Compensation/useCompensation.js.map +1 -1
- package/dist/components/Employee/Deductions/Deductions.d.ts +9 -5
- package/dist/components/Employee/Deductions/Deductions.js +13 -13
- package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
- package/dist/components/Employee/Deductions/useDeductions.d.ts +34 -14
- package/dist/components/Employee/Deductions/useDeductions.js +14 -32
- package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccount.d.ts +22 -10
- package/dist/components/Employee/PaymentMethod/BankAccount.js +9 -9
- package/dist/components/Employee/PaymentMethod/BankAccount.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js +13 -13
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.d.ts +10 -6
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +8 -8
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.d.ts +92 -37
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +35 -42
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.d.ts +68 -31
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +33 -46
- package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Profile/HomeAddress.d.ts +33 -13
- package/dist/components/Employee/Profile/HomeAddress.js +39 -38
- package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.d.ts +81 -32
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +60 -74
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/Profile.js +51 -55
- package/dist/components/Employee/Profile/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/SelfPersonalDetails.d.ts +44 -15
- package/dist/components/Employee/Profile/SelfPersonalDetails.js +18 -21
- package/dist/components/Employee/Profile/SelfPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.d.ts +28 -12
- package/dist/components/Employee/Taxes/FederalForm.js +28 -28
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/StateForm.d.ts +9 -5
- package/dist/components/Employee/Taxes/StateForm.js +5 -5
- package/dist/components/Employee/Taxes/StateForm.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +31 -34
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/contexts/ApiProvider/ApiProvider.d.ts +5 -0
- package/dist/contexts/ApiProvider/ApiProvider.js +34 -0
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +16 -16
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/helpers/validations.d.ts +6 -5
- package/dist/helpers/validations.js +10 -17
- package/dist/helpers/validations.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +7 -4
- package/dist/components/Common/UI/FieldCaption/FieldCaption.js.map +0 -1
- package/dist/components/Common/UI/FieldDescription/FieldDescription.js.map +0 -1
- package/dist/components/Common/UI/FieldErrorMessage/FieldErrorMessage.js.map +0 -1
- package/dist/components/Common/UI/FieldLayout/FieldLayout.js.map +0 -1
- package/dist/components/Common/UI/FieldLayout/FieldLayoutTypes.d.ts +0 -19
- package/dist/components/Common/UI/Fieldset/Fieldset.js.map +0 -1
- package/dist/components/Common/UI/HorizontalFieldLayout/HorizontalFieldLayout.js.map +0 -1
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/FieldCaption.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldCaption → FieldCaption}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/FieldDescription.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldDescription → FieldDescription}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/FieldErrorMessage.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldErrorMessage → FieldErrorMessage}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.d.ts +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.module.scss.js +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/FieldLayout.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/FieldLayout → FieldLayout}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.d.ts +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.module.scss.js +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/Fieldset.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/Fieldset → Fieldset}/index.d.ts +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.d.ts +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.module.scss.js +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayout.module.scss.js.map +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/HorizontalFieldLayoutTypes.d.ts +0 -0
- /package/dist/components/Common/{UI/HorizontalFieldLayout → HorizontalFieldLayout}/index.d.ts +0 -0
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsxs as t, jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { z as i } from "zod";
|
|
3
3
|
import { useTranslation as l } from "react-i18next";
|
|
4
4
|
import { zipValidation as n, phoneValidation as m } from "../../../../helpers/validations.js";
|
|
5
|
-
import { Flex as
|
|
6
|
-
import { Grid as
|
|
5
|
+
import { Flex as d } from "../../../Common/Flex/Flex.js";
|
|
6
|
+
import { Grid as p } from "../../../Common/Grid/Grid.js";
|
|
7
7
|
import { STATES_ABBR as c } from "../../../../shared/constants.js";
|
|
8
|
-
import { useMaskedTransform as
|
|
8
|
+
import { useMaskedTransform as u, commonMasks as b } from "../../../../helpers/mask.js";
|
|
9
9
|
import { TextInputField as s } from "../../../Common/Fields/TextInputField/TextInputField.js";
|
|
10
10
|
import { SelectField as f } from "../../../Common/Fields/SelectField/SelectField.js";
|
|
11
11
|
import { CheckboxGroupField as g } from "../../../Common/Fields/CheckboxGroupField/CheckboxGroupField.js";
|
|
12
|
-
const
|
|
12
|
+
const q = i.object({
|
|
13
13
|
phoneNumber: m,
|
|
14
|
-
street1:
|
|
15
|
-
street2:
|
|
16
|
-
city:
|
|
17
|
-
state:
|
|
14
|
+
street1: i.string().min(1),
|
|
15
|
+
street2: i.string().optional(),
|
|
16
|
+
city: i.string().min(1),
|
|
17
|
+
state: i.string().min(1),
|
|
18
18
|
zip: n,
|
|
19
|
-
addressType:
|
|
19
|
+
addressType: i.array(i.enum(["mailingAddress", "filingAddress"])).optional()
|
|
20
20
|
});
|
|
21
|
-
function
|
|
22
|
-
const { t: e } = l("Company.Locations"), o = b
|
|
23
|
-
return /* @__PURE__ */ t(
|
|
21
|
+
function k() {
|
|
22
|
+
const { t: e } = l("Company.Locations"), o = u(b.phoneMask);
|
|
23
|
+
return /* @__PURE__ */ t(d, { flexDirection: "column", gap: 20, children: [
|
|
24
24
|
/* @__PURE__ */ t(
|
|
25
|
-
|
|
25
|
+
p,
|
|
26
26
|
{
|
|
27
27
|
gap: { base: 20, small: 8 },
|
|
28
28
|
gridTemplateColumns: { base: "1fr", small: ["1fr", "1fr"] },
|
|
29
29
|
children: [
|
|
30
|
-
/* @__PURE__ */
|
|
30
|
+
/* @__PURE__ */ r(
|
|
31
31
|
s,
|
|
32
32
|
{
|
|
33
33
|
name: "street1",
|
|
@@ -36,8 +36,8 @@ function q() {
|
|
|
36
36
|
errorMessage: e("validations.street1")
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
39
|
+
/* @__PURE__ */ r(s, { name: "street2", label: e("street2Label") }),
|
|
40
|
+
/* @__PURE__ */ r(
|
|
41
41
|
s,
|
|
42
42
|
{
|
|
43
43
|
name: "city",
|
|
@@ -46,7 +46,7 @@ function q() {
|
|
|
46
46
|
errorMessage: e("validations.city")
|
|
47
47
|
}
|
|
48
48
|
),
|
|
49
|
-
/* @__PURE__ */
|
|
49
|
+
/* @__PURE__ */ r(
|
|
50
50
|
f,
|
|
51
51
|
{
|
|
52
52
|
name: "state",
|
|
@@ -60,7 +60,7 @@ function q() {
|
|
|
60
60
|
isRequired: !0
|
|
61
61
|
}
|
|
62
62
|
),
|
|
63
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ r(
|
|
64
64
|
s,
|
|
65
65
|
{
|
|
66
66
|
name: "zip",
|
|
@@ -69,7 +69,7 @@ function q() {
|
|
|
69
69
|
errorMessage: e("validations.zip")
|
|
70
70
|
}
|
|
71
71
|
),
|
|
72
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ r(
|
|
73
73
|
s,
|
|
74
74
|
{
|
|
75
75
|
name: "phoneNumber",
|
|
@@ -82,7 +82,7 @@ function q() {
|
|
|
82
82
|
]
|
|
83
83
|
}
|
|
84
84
|
),
|
|
85
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ r(
|
|
86
86
|
g,
|
|
87
87
|
{
|
|
88
88
|
name: "addressType",
|
|
@@ -104,7 +104,7 @@ function q() {
|
|
|
104
104
|
] });
|
|
105
105
|
}
|
|
106
106
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
k as Form,
|
|
108
|
+
q as LocationFormSchema
|
|
109
109
|
};
|
|
110
110
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../../../src/components/Company/Locations/LocationForm/Form.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../../../src/components/Company/Locations/LocationForm/Form.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { useTranslation } from 'react-i18next'\nimport { phoneValidation, zipValidation } from '@/helpers/validations'\nimport { CheckboxGroupField, Flex, Grid, SelectField, TextInputField } from '@/components/Common'\nimport { STATES_ABBR } from '@/shared/constants'\nimport { commonMasks, useMaskedTransform } from '@/helpers/mask'\n\nexport const LocationFormSchema = z.object({\n phoneNumber: phoneValidation,\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: zipValidation,\n addressType: z.array(z.enum(['mailingAddress', 'filingAddress'])).optional(),\n})\n\nexport type LocationFormInputs = z.infer<typeof LocationFormSchema>\n\nexport function Form() {\n const { t } = useTranslation('Company.Locations')\n const transform = useMaskedTransform(commonMasks.phoneMask)\n\n return (\n <Flex flexDirection=\"column\" gap={20}>\n <Grid\n gap={{ base: 20, small: 8 }}\n gridTemplateColumns={{ base: '1fr', small: ['1fr', '1fr'] }}\n >\n <TextInputField\n name=\"street1\"\n isRequired\n label={t('street1Label')}\n errorMessage={t('validations.street1')}\n />\n <TextInputField name=\"street2\" label={t('street2Label')} />\n <TextInputField\n name=\"city\"\n label={t('cityLabel')}\n isRequired\n errorMessage={t('validations.city')}\n />\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map((stateAbbr: (typeof STATES_ABBR)[number]) => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common' }),\n value: stateAbbr,\n }))}\n label={t('stateLabel')}\n placeholder={t('statePlaceholder')}\n errorMessage={t('validations.state')}\n isRequired\n />\n <TextInputField\n name=\"zip\"\n isRequired\n label={t('zipLabel')}\n errorMessage={t('validations.zip')}\n />\n <TextInputField\n name=\"phoneNumber\"\n isRequired\n label={t('phoneNumberLabel')}\n errorMessage={t('validations.phone')}\n transform={transform}\n />\n </Grid>\n <CheckboxGroupField\n name=\"addressType\"\n label={t('addressTypeLabel')}\n options={[\n {\n value: 'mailingAddress',\n label: t('mailingAddressLabel'),\n description: t('mailingAddressDescription'),\n },\n {\n value: 'filingAddress',\n label: t('filingAddressLabel'),\n description: t('filingAddressDescription'),\n },\n ]}\n />\n </Flex>\n )\n}\n"],"names":["LocationFormSchema","z","phoneValidation","zipValidation","Form","t","useTranslation","transform","useMaskedTransform","commonMasks","jsxs","Flex","Grid","jsx","TextInputField","SelectField","STATES_ABBR","stateAbbr","CheckboxGroupField"],"mappings":";;;;;;;;;;;AAOa,MAAAA,IAAqBC,EAAE,OAAO;AAAA,EACzC,aAAaC;AAAA,EACb,SAASD,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,SAASA,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,OAAOA,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,KAAKE;AAAA,EACL,aAAaF,EAAE,MAAMA,EAAE,KAAK,CAAC,kBAAkB,eAAe,CAAC,CAAC,EAAE,SAAS;AAC7E,CAAC;AAIM,SAASG,IAAO;AACrB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,mBAAmB,GAC1CC,IAAYC,EAAmBC,EAAY,SAAS;AAE1D,SACG,gBAAAC,EAAAC,GAAA,EAAK,eAAc,UAAS,KAAK,IAChC,UAAA;AAAA,IAAA,gBAAAD;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,KAAK,EAAE,MAAM,IAAI,OAAO,EAAE;AAAA,QAC1B,qBAAqB,EAAE,MAAM,OAAO,OA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MAAK;AAAA,QACL,OAAOb,EAAE,kBAAkB;AAAA,QAC3B,SAAS;AAAA,UACP;AAAA,YACE,OAAO;AAAA,YACP,OAAOA,EAAE,qBAAqB;AAAA,YAC9B,aAAaA,EAAE,2BAA2B;AAAA,UAC5C;AAAA,UACA;AAAA,YACE,OAAO;AAAA,YACP,OAAOA,EAAE,oBAAoB;AAAA,YAC7B,aAAaA,EAAE,0BAA0B;AAAA,UAAA;AAAA,QAC3C;AAAA,MACF;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsx as o, jsxs as O, Fragment as S } from "react/jsx-runtime";
|
|
2
2
|
import { useForm as q, FormProvider as x } from "react-hook-form";
|
|
3
|
-
import {
|
|
3
|
+
import { zodResolver as R } from "@hookform/resolvers/zod";
|
|
4
4
|
import { useLocationsUpdateMutation as w } from "@gusto/embedded-api/react-query/locationsUpdate";
|
|
5
5
|
import { useLocationsRetrieveSuspense as B } from "@gusto/embedded-api/react-query/locationsRetrieve";
|
|
6
6
|
import { invalidateAllLocationsGet as I } from "@gusto/embedded-api/react-query/locationsGet";
|
|
7
7
|
import { useLocationsCreateMutation as M } from "@gusto/embedded-api/react-query/locationsCreate";
|
|
8
|
-
import { useQueryClient as _ } from "@
|
|
9
|
-
import { Head as
|
|
10
|
-
import { LocationFormSchema as
|
|
8
|
+
import { useQueryClient as _ } from "@tanstack/react-query";
|
|
9
|
+
import { Head as f } from "./Head.js";
|
|
10
|
+
import { LocationFormSchema as z, Form as l } from "./Form.js";
|
|
11
11
|
import { Actions as A } from "./Actions.js";
|
|
12
|
-
import { LocationsFormProvider as
|
|
13
|
-
import { Form as
|
|
14
|
-
import { Flex as
|
|
12
|
+
import { LocationsFormProvider as H } from "./useLocationForm.js";
|
|
13
|
+
import { Form as U } from "../../../Common/Form/Form.js";
|
|
14
|
+
import { Flex as j } from "../../../Common/Flex/Flex.js";
|
|
15
15
|
import { BaseComponent as Y } from "../../../Base/Base.js";
|
|
16
16
|
import { useBase as G } from "../../../Base/useBase.js";
|
|
17
17
|
import { useI18n as Q } from "../../../../i18n/I18n.js";
|
|
18
|
-
import { componentEvents as
|
|
18
|
+
import { componentEvents as a } from "../../../../shared/constants.js";
|
|
19
19
|
function V(t) {
|
|
20
20
|
const {
|
|
21
21
|
data: { location: e }
|
|
@@ -29,8 +29,8 @@ function y({
|
|
|
29
29
|
children: r
|
|
30
30
|
}) {
|
|
31
31
|
Q("Company.Locations");
|
|
32
|
-
const { onEvent: i, baseSubmitHandler:
|
|
33
|
-
resolver: R(
|
|
32
|
+
const { onEvent: i, baseSubmitHandler: C } = G(), { mutateAsync: L, isPending: g } = M(), { mutateAsync: v, isPending: h } = w(), F = _(), P = ["mailingAddress", "filingAddress"], { control: T, ...c } = q({
|
|
33
|
+
resolver: R(z),
|
|
34
34
|
defaultValues: {
|
|
35
35
|
city: e?.city ?? "",
|
|
36
36
|
phoneNumber: e?.phoneNumber ?? "",
|
|
@@ -40,42 +40,42 @@ function y({
|
|
|
40
40
|
zip: e?.zip ?? "",
|
|
41
41
|
addressType: P.filter((n) => e?.[n] ?? !1)
|
|
42
42
|
}
|
|
43
|
-
}),
|
|
44
|
-
i(
|
|
43
|
+
}), b = () => {
|
|
44
|
+
i(a.CANCEL);
|
|
45
45
|
}, D = async (n) => {
|
|
46
|
-
await
|
|
46
|
+
await C(n, async (E) => {
|
|
47
47
|
const { addressType: u, ...N } = E, p = {
|
|
48
48
|
...N,
|
|
49
49
|
mailingAddress: u?.includes("mailingAddress"),
|
|
50
50
|
filingAddress: u?.includes("filingAddress")
|
|
51
51
|
};
|
|
52
52
|
if (e && e.version !== void 0) {
|
|
53
|
-
const { location:
|
|
53
|
+
const { location: m } = await v({
|
|
54
54
|
request: {
|
|
55
55
|
locationId: e.uuid,
|
|
56
56
|
requestBody: { ...p, version: e.version }
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
i(
|
|
59
|
+
i(a.COMPANY_LOCATION_UPDATED, m);
|
|
60
60
|
} else {
|
|
61
|
-
const { location:
|
|
61
|
+
const { location: m } = await L({
|
|
62
62
|
request: {
|
|
63
63
|
companyId: t,
|
|
64
64
|
requestBody: p
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
-
i(
|
|
67
|
+
i(a.COMPANY_LOCATION_CREATED, m);
|
|
68
68
|
}
|
|
69
69
|
await I(F);
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
|
-
return /* @__PURE__ */ o("section", { className: s, children: /* @__PURE__ */ o(x, { ...c, control:
|
|
73
|
-
|
|
72
|
+
return /* @__PURE__ */ o("section", { className: s, children: /* @__PURE__ */ o(x, { ...c, control: T, children: /* @__PURE__ */ o(U, { onSubmit: c.handleSubmit(D), children: /* @__PURE__ */ o(
|
|
73
|
+
H,
|
|
74
74
|
{
|
|
75
|
-
value: { handleCancel:
|
|
76
|
-
children: /* @__PURE__ */ o(
|
|
77
|
-
/* @__PURE__ */ o(l, {}),
|
|
75
|
+
value: { handleCancel: b, isPending: g || h },
|
|
76
|
+
children: /* @__PURE__ */ o(j, { flexDirection: "column", gap: 32, children: r || /* @__PURE__ */ O(S, { children: [
|
|
78
77
|
/* @__PURE__ */ o(f, {}),
|
|
78
|
+
/* @__PURE__ */ o(l, {}),
|
|
79
79
|
/* @__PURE__ */ o(A, {})
|
|
80
80
|
] }) })
|
|
81
81
|
}
|
|
@@ -90,8 +90,8 @@ function d({
|
|
|
90
90
|
}) {
|
|
91
91
|
return /* @__PURE__ */ o(Y, { ...i, children: e ? /* @__PURE__ */ o(V, { companyId: t, locationId: e, className: s, children: r }) : /* @__PURE__ */ o(y, { companyId: t, className: s, children: r }) });
|
|
92
92
|
}
|
|
93
|
-
d.Head =
|
|
94
|
-
d.Form =
|
|
93
|
+
d.Head = f;
|
|
94
|
+
d.Form = l;
|
|
95
95
|
d.Actions = A;
|
|
96
96
|
export {
|
|
97
97
|
d as LocationForm
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationForm.js","sources":["../../../../../src/components/Company/Locations/LocationForm/LocationForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport {
|
|
1
|
+
{"version":3,"file":"LocationForm.js","sources":["../../../../../src/components/Company/Locations/LocationForm/LocationForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useLocationsUpdateMutation } from '@gusto/embedded-api/react-query/locationsUpdate'\nimport { useLocationsRetrieveSuspense } from '@gusto/embedded-api/react-query/locationsRetrieve'\nimport { invalidateAllLocationsGet } from '@gusto/embedded-api/react-query/locationsGet'\nimport { useLocationsCreateMutation } from '@gusto/embedded-api/react-query/locationsCreate'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { Head } from './Head'\nimport type { LocationFormInputs } from './Form'\nimport { Form, LocationFormSchema } from './Form'\nimport { Actions } from './Actions'\nimport { LocationsFormProvider } from './useLocationForm'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { Flex } from '@/components/Common'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport type { WithRequired } from '@/types/Helpers'\n\ninterface LocationFormProps extends CommonComponentInterface {\n companyId: string\n locationId?: string\n}\n\n/**Accounting for conditional logic where location data needs to be fetched only if locationId is present */\nfunction RootWithLocation(props: WithRequired<LocationFormProps, 'locationId'>) {\n const {\n data: { location },\n } = useLocationsRetrieveSuspense({ locationId: props.locationId })\n return <Root {...props} location={location} />\n}\n\nfunction Root({\n companyId,\n location,\n className,\n children,\n}: LocationFormProps & { location?: Location }) {\n useI18n('Company.Locations')\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { mutateAsync: createLocation, isPending: isPendingCreate } = useLocationsCreateMutation()\n const { mutateAsync: updateLocation, isPending: isPendingUpdate } = useLocationsUpdateMutation()\n const queryClient = useQueryClient()\n const addressType = ['mailingAddress', 'filingAddress'] as const\n\n const { control, ...methods } = useForm<LocationFormInputs>({\n resolver: zodResolver(LocationFormSchema),\n defaultValues: {\n city: location?.city ?? '',\n phoneNumber: location?.phoneNumber ?? '',\n street1: location?.street1 ?? '',\n street2: location?.street2 ?? '',\n state: location?.state ?? '',\n zip: location?.zip ?? '',\n addressType: addressType.filter(key => location?.[key] ?? false),\n },\n })\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n const onSubmit = async (data: LocationFormInputs) => {\n await baseSubmitHandler(data, async innerData => {\n const { addressType, ...payload } = innerData\n\n const requestBody = {\n ...payload,\n mailingAddress: addressType?.includes('mailingAddress'),\n filingAddress: addressType?.includes('filingAddress'),\n }\n\n if (location && location.version !== undefined) {\n // Edit existing location\n const { location: responseData } = await updateLocation({\n request: {\n locationId: location.uuid,\n requestBody: { ...requestBody, version: location.version },\n },\n })\n onEvent(componentEvents.COMPANY_LOCATION_UPDATED, responseData)\n } else {\n // Add new location\n const { location: responseData } = await createLocation({\n request: {\n companyId,\n requestBody,\n },\n })\n onEvent(componentEvents.COMPANY_LOCATION_CREATED, responseData)\n }\n\n // Invalidate cache after mutation\n await invalidateAllLocationsGet(queryClient)\n })\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <LocationsFormProvider\n value={{ handleCancel, isPending: isPendingCreate || isPendingUpdate }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </LocationsFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nexport function LocationForm({\n companyId,\n locationId,\n className,\n children,\n ...props\n}: LocationFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n {locationId ? (\n <RootWithLocation companyId={companyId} locationId={locationId} className={className}>\n {children}\n </RootWithLocation>\n ) : (\n <Root companyId={companyId} className={className}>\n {children}\n </Root>\n )}\n </BaseComponent>\n )\n}\n\nLocationForm.Head = Head\nLocationForm.Form = Form\nLocationForm.Actions = Actions\n"],"names":["RootWithLocation","props","location","useLocationsRetrieveSuspense","jsx","Root","companyId","className","children","useI18n","onEvent","baseSubmitHandler","useBase","createLocation","isPendingCreate","useLocationsCreateMutation","updateLocation","isPendingUpdate","useLocationsUpdateMutation","queryClient","useQueryClient","addressType","control","methods","useForm","zodResolver","LocationFormSchema","key","handleCancel","componentEvents","onSubmit","data","innerData","payload","requestBody","responseData","invalidateAllLocationsGet","FormProvider","HtmlForm","LocationsFormProvider","Flex","jsxs","Fragment","Head","Form","Actions","LocationForm","locationId","BaseComponent"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,SAASA,EAAiBC,GAAsD;AACxE,QAAA;AAAA,IACJ,MAAM,EAAE,UAAAC,EAAS;AAAA,MACfC,EAA6B,EAAE,YAAYF,EAAM,YAAY;AACjE,SAAQ,gBAAAG,EAAAC,GAAA,EAAM,GAAGJ,GAAO,UAAAC,EAAoB,CAAA;AAC9C;AAEA,SAASG,EAAK;AAAA,EACZ,WAAAC;AAAA,EACA,UAAAJ;AAAA,EACA,WAAAK;AAAA,EACA,UAAAC;AACF,GAAgD;AAC9C,EAAAC,EAAQ,mBAAmB;AAC3B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GAEzC,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAAoBC,EAA2B,GACzF,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAAoBC,EAA2B,GACzFC,IAAcC,EAAe,GAC7BC,IAAc,CAAC,kBAAkB,eAAe,GAEhD,EAAE,SAAAC,GAAS,GAAGC,EAAA,IAAYC,EAA4B;AAAA,IAC1D,UAAUC,EAAYC,CAAkB;AAAA,IACxC,eAAe;AAAA,MACb,MAAMxB,GAAU,QAAQ;AAAA,MACxB,aAA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AAUf,EAAQ,aAAaO,CAAQ,GAC/C,UAAA,gBAAA1B;AAAA,IAACmC;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,cAAAX,GAAc,WAAWd,KAAmBG,EAAgB;AAAA,MAErE,UAAA,gBAAAb,EAACoC,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAhC,KAIG,gBAAAiC,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAtC,EAACuC,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;AAEO,SAASC,EAAa;AAAA,EAC3B,WAAAxC;AAAA,EACA,YAAAyC;AAAA,EACA,WAAAxC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGP;AACL,GAA+C;AAC7C,2BACG+C,GAAe,EAAA,GAAG/C,GAChB,UAAA8C,sBACE/C,GAAiB,EAAA,WAAAM,GAAsB,YAAAyC,GAAwB,WAAAxC,GAC7D,UAAAC,GACH,IAEA,gBAAAJ,EAACC,KAAK,WAAAC,GAAsB,WAAAC,GACzB,UAAAC,EACH,CAAA,GAEJ;AAEJ;AAEAsC,EAAa,OAAOH;AACpBG,EAAa,OAAOF;AACpBE,EAAa,UAAUD;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as t, jsxs as k } from "react/jsx-runtime";
|
|
2
|
-
import { useForm as
|
|
3
|
-
import {
|
|
2
|
+
import { useForm as z, FormProvider as Q } from "react-hook-form";
|
|
3
|
+
import { zodResolver as J } from "@hookform/resolvers/zod";
|
|
4
4
|
import { useState as v, useEffect as p } from "react";
|
|
5
5
|
import { usePaySchedulesGetPreview as K } from "@gusto/embedded-api/react-query/paySchedulesGetPreview";
|
|
6
6
|
import { usePaySchedulesUpdateMutation as W } from "@gusto/embedded-api/react-query/paySchedulesUpdate";
|
|
7
7
|
import { usePaySchedulesGetAllSuspense as X, invalidateAllPaySchedulesGetAll as Z } from "@gusto/embedded-api/react-query/paySchedulesGetAll";
|
|
8
8
|
import { usePaySchedulesCreateMutation as $ } from "@gusto/embedded-api/react-query/paySchedulesCreate";
|
|
9
|
-
import { useQueryClient as V } from "@
|
|
9
|
+
import { useQueryClient as V } from "@tanstack/react-query";
|
|
10
10
|
import { PayScheduleSchema as ee, PayScheduleProvider as oe } from "./usePaySchedule.js";
|
|
11
11
|
import { Form as re } from "../../Common/Form/Form.js";
|
|
12
12
|
import { BaseComponent as ae } from "../../Base/Base.js";
|
|
@@ -48,7 +48,7 @@ const h = ({
|
|
|
48
48
|
// Casting to non-null because we know it's not null from the enabled prop
|
|
49
49
|
), { data: N } = X({
|
|
50
50
|
companyId: n
|
|
51
|
-
}),
|
|
51
|
+
}), g = $(), b = W(), S = z({
|
|
52
52
|
resolver: J(ee),
|
|
53
53
|
defaultValues: M
|
|
54
54
|
}), { watch: R, setValue: l, reset: s, setError: A } = S;
|
|
@@ -99,7 +99,7 @@ const h = ({
|
|
|
99
99
|
await T(o, async (r) => {
|
|
100
100
|
const u = (c) => c && ie(c) || "";
|
|
101
101
|
if (D === "ADD_PAY_SCHEDULE") {
|
|
102
|
-
const c = await
|
|
102
|
+
const c = await g.mutateAsync({
|
|
103
103
|
request: {
|
|
104
104
|
companyId: n,
|
|
105
105
|
requestBody: {
|
|
@@ -114,7 +114,7 @@ const h = ({
|
|
|
114
114
|
});
|
|
115
115
|
f(w.PAY_SCHEDULE_CREATED, c), s(), y(null);
|
|
116
116
|
} else if (D === "EDIT_PAY_SCHEDULE") {
|
|
117
|
-
const c = i?.version, I = await
|
|
117
|
+
const c = i?.version, I = await b.mutateAsync({
|
|
118
118
|
request: {
|
|
119
119
|
payScheduleId: i?.uuid,
|
|
120
120
|
companyId: n,
|
|
@@ -149,7 +149,7 @@ const h = ({
|
|
|
149
149
|
payPreviewLoading: Y,
|
|
150
150
|
currentPaySchedule: i
|
|
151
151
|
},
|
|
152
|
-
children: /* @__PURE__ */ t("span", { "data-testid": "pay-schedule-edit-form", children: /* @__PURE__ */ t(
|
|
152
|
+
children: /* @__PURE__ */ t("span", { "data-testid": "pay-schedule-edit-form", children: /* @__PURE__ */ t(Q, { ...S, children: /* @__PURE__ */ t(re, { onSubmit: S.handleSubmit(G), children: P || /* @__PURE__ */ k(ne, { flexDirection: "column", children: [
|
|
153
153
|
/* @__PURE__ */ t(q, {}),
|
|
154
154
|
/* @__PURE__ */ t(_, {}),
|
|
155
155
|
/* @__PURE__ */ t(C, {}),
|
|
@@ -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 { valibotResolver } from '@hookform/resolvers/valibot'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport {\n usePaySchedulesGetAllSuspense,\n invalidateAllPaySchedulesGetAll,\n} 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 { useQueryClient } from '@gusto/embedded-api/ReactSDKProvider'\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'\n\ninterface PayScheduleProps extends CommonComponentInterface {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\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 queryClient = useQueryClient()\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: valibotResolver(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 await invalidateAllPaySchedulesGetAll(queryClient)\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","props","useI18n","jsx","BaseComponent","Root","children","queryClient","useQueryClient","baseSubmitHandler","onEvent","fieldErrors","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","payScheduleDraft","setPayScheduleDraft","payPreviewData","isLoading","usePaySchedulesGetPreview","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","valibotResolver","PayScheduleSchema","watch","setValue","reset","setError","useEffect","error","allValues","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","formatDateToStringDate","createPayScheduleResponse","version","updatePayScheduleResponse","invalidateAllPaySchedulesGetAll","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACL,OACEC,GAAQ,qBAAqB,GA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A;AAAA,IAAA;AAAA,EACF;AAEJ;AAEAnE,EAAY,OAAOgE;AACnBhE,EAAY,OAAOiE;AACnBjE,EAAY,OAAOkE;AACnBlE,EAAY,UAAUmE;"}
|
|
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 {\n usePaySchedulesGetAllSuspense,\n invalidateAllPaySchedulesGetAll,\n} 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 { useQueryClient } from '@tanstack/react-query'\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'\n\ninterface PayScheduleProps extends CommonComponentInterface {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\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 queryClient = useQueryClient()\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 await invalidateAllPaySchedulesGetAll(queryClient)\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","props","useI18n","jsx","BaseComponent","Root","children","queryClient","useQueryClient","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","invalidateAllPaySchedulesGetAll","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACL,OACEC,GAAQ,qBAAqB,GAE3B,gBAAAC,EAACC,IAAe,EAAA,GAAGH,GACjB,UAAA,gBAAAE,EAACE,MAAK,WAAAN,GAAsB,eAAAC,GACzB,UAAMC,EAAA,SAAA,CACT,EACF,CAAA,IAIEI,KAAO,CAAC,EAAE,WAAAN,GAAW,UAAAO,GAAU,eAAAN,QAAsC;AACzE,QAAMO,IAAcC,EAAe,GAC7B,EAAE,mBAAAC,GAAmB,SAAAC,GAAS,aAA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pB,MAAMA,EAAQ;AAAA,cACd,MAAMA,EAAQ;AAAA,cACd,SAAAK;AAAA,YAAA;AAAA,UACF;AAAA,QACF,CACD;AACO,QAAA5C,EAAAoC,EAAgB,sBAAsBS,CAAyB,GACjEnB,EAAA,GACNhB,EAAoB,IAAI;AAAA,MAAA;AAE1B,YAAMoC,EAAgCjD,CAAW,GACjDO,EAAQ,oBAAoB;AAAA,IAAA,CAC7B;AAAA,EACH;AAGE,SAAA,gBAAAX;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,WAAA1D;AAAA,QACA,WAAA0C;AAAA,QACA,YAAAE;AAAA,QACA,cAAAD;AAAA,QACA,gBAAAG;AAAA,QACA,MAAAhC;AAAA,QACA,cAAcW,EAAa;AAAA,QAC3B,kBAAkBH,GAAgB,QAAQ;AAAA,QAC1C,mBAAmBC;AAAA,QACnB,oBAAAN;AAAA,MACF;AAAA,MAEA,UAAA,gBAAAb,EAAC,UAAK,eAAY,0BAChB,4BAACuD,GAAc,EAAA,GAAG5B,GAChB,UAAC,gBAAA3B,EAAAwD,IAAA,EAAK,UAAU7B,EAAY,aAAaiB,CAAQ,GAC9C,UAAAzC,KAGE,gBAAAsD,EAAAC,IAAA,EAAK,eAAc,UAClB,UAAA;AAAA,QAAA,gBAAA1D,EAAC2D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEAnE,EAAY,OAAOgE;AACnBhE,EAAY,OAAOiE;AACnBjE,EAAY,OAAOkE;AACnBlE,EAAY,UAAUmE;"}
|
|
@@ -1,60 +1,57 @@
|
|
|
1
1
|
import { jsx as e, jsxs as p } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as h } from "react-i18next";
|
|
3
3
|
import { usePaySchedule as y } from "../usePaySchedule.js";
|
|
4
|
-
import
|
|
4
|
+
import o from "./List.module.scss.js";
|
|
5
|
+
import { Flex as s } from "../../../Common/Flex/Flex.js";
|
|
5
6
|
import f from "../../../../assets/icons/pencil.svg.js";
|
|
6
7
|
import { useComponentContext as S } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
|
-
import { HamburgerMenu as
|
|
8
|
-
import { VisuallyHidden as
|
|
9
|
-
import { useDataView as
|
|
10
|
-
import { DataView as
|
|
11
|
-
const
|
|
12
|
-
const { t:
|
|
8
|
+
import { HamburgerMenu as v } from "../../../Common/HamburgerMenu/HamburgerMenu.js";
|
|
9
|
+
import { VisuallyHidden as g } from "../../../Common/VisuallyHidden/VisuallyHidden.js";
|
|
10
|
+
import { useDataView as L } from "../../../Common/DataView/useDataView.js";
|
|
11
|
+
import { DataView as C } from "../../../Common/DataView/DataView.js";
|
|
12
|
+
const H = () => {
|
|
13
|
+
const { t: n } = h("Company.PaySchedule"), r = S(), { paySchedules: c, mode: m, handleEdit: l } = y(), { ...d } = L({
|
|
13
14
|
data: c || [],
|
|
14
15
|
columns: [
|
|
15
16
|
{
|
|
16
|
-
title:
|
|
17
|
+
title: n("payScheduleList.name"),
|
|
17
18
|
key: "customName",
|
|
18
19
|
render: (t) => {
|
|
19
20
|
const a = !!t.name;
|
|
20
21
|
let i = a ? t.name : t.customName;
|
|
21
22
|
i && i.length > 1 ? i = i.charAt(0).toUpperCase() + i.slice(1) : i = t.customName;
|
|
22
23
|
const u = t.customName;
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ e(s, { flexDirection: "column", gap: 0, children: /* @__PURE__ */ p("div", { className: o.content, children: [
|
|
24
25
|
/* @__PURE__ */ e("div", { children: i }),
|
|
25
26
|
a && /* @__PURE__ */ e("div", { children: u })
|
|
26
|
-
] });
|
|
27
|
+
] }) });
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
|
-
title: /* @__PURE__ */ e(
|
|
31
|
+
title: /* @__PURE__ */ e(g, { children: n("payScheduleList.active") }),
|
|
31
32
|
key: "active",
|
|
32
|
-
render: (t) => /* @__PURE__ */ e(
|
|
33
|
-
}
|
|
33
|
+
render: (t) => /* @__PURE__ */ e(s, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ e("div", { className: o.content, children: t.active ? /* @__PURE__ */ e(r.Badge, { status: "success", children: n("payScheduleList.active") }) : /* @__PURE__ */ e(r.Badge, { status: "info", children: n("payScheduleList.inactive") }) }) })
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
itemMenu: (t) => /* @__PURE__ */ e(
|
|
37
|
+
v,
|
|
34
38
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
render: (t) => /* @__PURE__ */ e(
|
|
38
|
-
L,
|
|
39
|
+
triggerLabel: "Actions",
|
|
40
|
+
items: [
|
|
39
41
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
l(t);
|
|
46
|
-
},
|
|
47
|
-
icon: /* @__PURE__ */ e(f, { "aria-hidden": !0 })
|
|
48
|
-
}
|
|
49
|
-
]
|
|
42
|
+
label: n("payScheduleList.edit"),
|
|
43
|
+
onClick: () => {
|
|
44
|
+
l(t);
|
|
45
|
+
},
|
|
46
|
+
icon: /* @__PURE__ */ e(f, { "aria-hidden": !0 })
|
|
50
47
|
}
|
|
51
|
-
|
|
48
|
+
]
|
|
52
49
|
}
|
|
53
|
-
|
|
50
|
+
)
|
|
54
51
|
});
|
|
55
|
-
return m !== "LIST_PAY_SCHEDULES" ? null : /* @__PURE__ */ e(
|
|
52
|
+
return m !== "LIST_PAY_SCHEDULES" ? null : /* @__PURE__ */ e(C, { label: "test", ...d });
|
|
56
53
|
};
|
|
57
54
|
export {
|
|
58
|
-
|
|
55
|
+
H as List
|
|
59
56
|
};
|
|
60
57
|
//# sourceMappingURL=List.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { useDataView, DataView, Flex, VisuallyHidden } from '@/components/Common'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n const { paySchedules, mode, handleEdit } = usePaySchedule()\n\n const { ...dataViewProps } = useDataView({\n data: paySchedules || [],\n columns: [\n {\n title: t('payScheduleList.name'),\n key: 'customName',\n render: schedule => {\n const hasName = !!schedule.name\n let displayName = hasName ? schedule.name : schedule.customName\n if (displayName && displayName.length > 1) {\n displayName = displayName.charAt(0).toUpperCase() + displayName.slice(1)\n } else {\n displayName = schedule.customName\n }\n const displayFrequency = schedule.customName\n return (\n <Flex flexDirection={'column'} gap={0}>\n <div>{displayName}</div>\n
|
|
1
|
+
{"version":3,"file":"List.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport styles from './List.module.scss'\nimport { useDataView, DataView, Flex, VisuallyHidden } from '@/components/Common'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const Components = useComponentContext()\n const { paySchedules, mode, handleEdit } = usePaySchedule()\n\n const { ...dataViewProps } = useDataView({\n data: paySchedules || [],\n columns: [\n {\n title: t('payScheduleList.name'),\n key: 'customName',\n render: schedule => {\n const hasName = !!schedule.name\n let displayName = hasName ? schedule.name : schedule.customName\n if (displayName && displayName.length > 1) {\n displayName = displayName.charAt(0).toUpperCase() + displayName.slice(1)\n } else {\n displayName = schedule.customName\n }\n const displayFrequency = schedule.customName\n return (\n <Flex flexDirection={'column'} gap={0}>\n <div className={styles.content}>\n <div>{displayName}</div>\n {hasName && <div>{displayFrequency}</div>}\n </div>\n </Flex>\n )\n },\n },\n {\n title: <VisuallyHidden>{t('payScheduleList.active')}</VisuallyHidden>,\n key: 'active',\n render: schedule => (\n <Flex alignItems={'center'} justifyContent={'center'}>\n <div className={styles.content}>\n {schedule.active ? (\n <Components.Badge status=\"success\">{t('payScheduleList.active')}</Components.Badge>\n ) : (\n <Components.Badge status=\"info\">{t('payScheduleList.inactive')}</Components.Badge>\n )}\n </div>\n </Flex>\n ),\n },\n ],\n itemMenu: schedule => {\n return (\n <HamburgerMenu\n triggerLabel=\"Actions\"\n items={[\n {\n label: t('payScheduleList.edit'),\n onClick: () => {\n handleEdit(schedule)\n },\n icon: <PencilSvg aria-hidden />,\n },\n ]}\n />\n )\n },\n })\n\n if (mode !== 'LIST_PAY_SCHEDULES') {\n return null\n }\n\n return <DataView label=\"test\" {...dataViewProps} />\n}\n"],"names":["List","t","useTranslation","Components","useComponentContext","paySchedules","mode","handleEdit","usePaySchedule","dataViewProps","useDataView","schedule","hasName","displayName","displayFrequency","jsx","Flex","jsxs","styles","VisuallyHidden","HamburgerMenu","PencilSvg","DataView"],"mappings":";;;;;;;;;;;AAQO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAoB,GACjC,EAAE,cAAAC,GAAc,MAAAC,GAAM,YAAAC,EAAA,IAAeC,EAAe,GAEpD,EAAE,GAAGC,EAAc,IAAIC,EAAY;AAAA,IACvC,MAAML,KAAgB,CAAC;AAAA,IACvB,SAAS;AAAA,MACP;AAAA,QACE,OAAOJ,EAAE,sBAAsB;AAAA,QAC/B,KAAK;AAAA,QACL,QAAQ,CAAYU,MAAA;AACZ,gBAAAC,IAAU,CAAC,CAACD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