@gusto/embedded-react-sdk 0.10.6-rc.2 → 0.10.7
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 +7 -0
- package/dist/components/Base/Base.js +19 -18
- 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 +7 -6
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +8 -7
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Common/TaxInputs/TaxInputs.d.ts +5 -1
- package/dist/components/Common/TaxInputs/TaxInputs.js +64 -56
- package/dist/components/Common/TaxInputs/TaxInputs.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 +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +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 +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +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 +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 +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +9 -8
- 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 +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +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 +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 +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 +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +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/useFederalTaxes.js +1 -1
- package/dist/components/Company/Industry/Actions.js +1 -1
- package/dist/components/Company/Industry/Context.js +1 -1
- package/dist/components/Company/Industry/Edit.js +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +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 +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +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 +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 +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +18 -16
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +26 -25
- 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 +1 -1
- package/dist/components/Company/StateTaxes/StateTaxes.js +23 -44
- package/dist/components/Company/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesComponents.d.ts +6 -8
- package/dist/components/Company/StateTaxes/StateTaxesComponents.js +15 -16
- package/dist/components/Company/StateTaxes/StateTaxesComponents.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +65 -59
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +1 -1
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.d.ts +5 -0
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js +48 -0
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js.map +1 -0
- 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 +7 -6
- package/dist/components/Contractor/Address/Form.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +1 -1
- package/dist/components/Contractor/List/index.js +3 -2
- 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 +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 +6 -5
- 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 +1 -1
- package/dist/components/Employee/Deductions/Actions.js +1 -1
- package/dist/components/Employee/Deductions/DeductionForm.js +1 -1
- package/dist/components/Employee/Deductions/DeductionsList.js +1 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +1 -1
- package/dist/components/Employee/Deductions/useDeductions.js +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +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 +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 +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +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 +15 -14
- package/dist/components/Employee/EmployeeList/List.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +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 +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 +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 +4 -3
- package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +1 -1
- package/dist/components/Employee/Profile/Actions.js +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 +1 -1
- package/dist/components/Employee/Profile/useProfile.js +1 -1
- package/dist/components/Employee/Taxes/Actions.js +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +1 -1
- package/dist/i18n/en/Company.StateTaxes.json.js +2 -1
- package/dist/i18n/en/Company.StateTaxes.json.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +1 -0
- package/package.json +2 -2
- package/dist/components/Company/StateTaxes/stateTaxesReducer.d.ts +0 -20
- package/dist/components/Company/StateTaxes/stateTaxesReducer.js +0 -40
- package/dist/components/Company/StateTaxes/stateTaxesReducer.js.map +0 -1
|
@@ -1,100 +1,106 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as a, jsxs as D, Fragment as H } from "react/jsx-runtime";
|
|
2
2
|
import { useForm as K, FormProvider as M } from "react-hook-form";
|
|
3
3
|
import { zodResolver as w } from "@hookform/resolvers/zod";
|
|
4
4
|
import { useTaxRequirementsUpdateStateMutation as z } from "@gusto/embedded-api/react-query/taxRequirementsUpdateState";
|
|
5
5
|
import { useTaxRequirementsGetSuspense as G } from "@gusto/embedded-api/react-query/taxRequirementsGet";
|
|
6
|
-
import { z as
|
|
6
|
+
import { z as r } from "zod";
|
|
7
7
|
import { useMemo as L } from "react";
|
|
8
8
|
import { useTranslation as X } from "react-i18next";
|
|
9
|
-
import { Head as
|
|
9
|
+
import { Head as k } from "./Head.js";
|
|
10
10
|
import { StateTaxesFormProvider as Y } from "./context.js";
|
|
11
|
-
import { Form as
|
|
12
|
-
import { Actions as
|
|
11
|
+
import { Form as A } from "./Form.js";
|
|
12
|
+
import { Actions as P } from "./Actions.js";
|
|
13
13
|
import { BaseComponent as $ } from "../../../Base/Base.js";
|
|
14
14
|
import { useI18n as I } from "../../../../i18n/I18n.js";
|
|
15
15
|
import { Flex as J } from "../../../Common/Flex/Flex.js";
|
|
16
16
|
import { Form as Q } from "../../../Common/Form/Form.js";
|
|
17
|
-
import { componentEvents as
|
|
17
|
+
import { componentEvents as q } from "../../../../shared/constants.js";
|
|
18
18
|
import { useBase as W } from "../../../Base/useBase.js";
|
|
19
|
-
function
|
|
20
|
-
return /* @__PURE__ */
|
|
19
|
+
function h(i) {
|
|
20
|
+
return /* @__PURE__ */ a($, { ...i, children: /* @__PURE__ */ a(Z, { ...i, children: i.children }) });
|
|
21
21
|
}
|
|
22
|
-
function Z({ companyId:
|
|
22
|
+
function Z({ companyId: i, state: y, className: _, children: x }) {
|
|
23
23
|
I("Company.StateTaxes");
|
|
24
|
-
const { onEvent: F, baseSubmitHandler:
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
if (!
|
|
28
|
-
const m =
|
|
29
|
-
|
|
30
|
-
if (!
|
|
31
|
-
const g =
|
|
32
|
-
p[g] =
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
const { onEvent: F, baseSubmitHandler: j } = W(), { t: o } = X("Company.StateTaxes", { keyPrefix: "form" }), { data: C } = G({ companyUuid: i, state: y }), l = C.taxRequirementsState, { mutateAsync: E, isPending: N } = z(), { dynamicSchema: R, defaultValues: V } = L(() => {
|
|
25
|
+
const f = {}, s = {};
|
|
26
|
+
return l.requirementSets?.forEach((t) => {
|
|
27
|
+
if (!t.key) return;
|
|
28
|
+
const m = t.key, c = {}, p = {};
|
|
29
|
+
t.requirements?.forEach((e) => {
|
|
30
|
+
if (!e.key) return;
|
|
31
|
+
const g = e.key;
|
|
32
|
+
p[g] = e.metadata?.type === "radio" ? e.value ?? void 0 : e.value ? String(e.value) : "";
|
|
33
|
+
let v = r.string({
|
|
34
|
+
required_error: o("validations.required")
|
|
35
|
+
}).min(1, o("validations.required"));
|
|
36
|
+
const d = e.metadata?.validation;
|
|
37
|
+
if (d && e.metadata?.type === "tax_rate")
|
|
38
|
+
if (d.type === "min_max") {
|
|
39
|
+
const n = parseFloat(d.min), u = parseFloat(d.max);
|
|
40
|
+
!isNaN(n) && !isNaN(u) && (v = r.preprocess(
|
|
41
|
+
(S) => Number(S),
|
|
42
|
+
r.number().min(n, o("validations.minValue", { min: n })).max(u, o("validations.maxValue", { max: u })).transform((S) => String(S))
|
|
41
43
|
));
|
|
42
44
|
} else {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const n = d.rates;
|
|
46
|
+
v = r.string({
|
|
47
|
+
required_error: o("validations.required")
|
|
48
|
+
}).min(1, o("validations.required")).refine((u) => n.includes(u), {
|
|
49
|
+
message: o("validations.oneOf", { values: n.join(", ") })
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
e.metadata?.type === "radio" && (v = r.boolean({
|
|
53
|
+
required_error: o("validations.required")
|
|
54
|
+
})), c[g] = v;
|
|
55
|
+
}), Object.keys(c).length > 0 && (f[m] = r.object(c), s[m] = p);
|
|
50
56
|
}), {
|
|
51
|
-
dynamicSchema:
|
|
52
|
-
defaultValues:
|
|
57
|
+
dynamicSchema: r.object(f),
|
|
58
|
+
defaultValues: s
|
|
53
59
|
};
|
|
54
|
-
}, [
|
|
55
|
-
resolver: w(
|
|
56
|
-
defaultValues:
|
|
57
|
-
}),
|
|
58
|
-
await
|
|
59
|
-
const b =
|
|
60
|
-
const m =
|
|
60
|
+
}, [l, o]), { control: O, ...T } = K({
|
|
61
|
+
resolver: w(R),
|
|
62
|
+
defaultValues: V
|
|
63
|
+
}), U = async (f) => {
|
|
64
|
+
await j(f, async (s) => {
|
|
65
|
+
const b = l.requirementSets?.filter((t) => t.key && s[t.key]).map((t) => {
|
|
66
|
+
const m = t.key, c = s[m];
|
|
61
67
|
return {
|
|
62
|
-
state:
|
|
68
|
+
state: t.state,
|
|
63
69
|
key: m,
|
|
64
|
-
effectiveFrom:
|
|
65
|
-
requirements: Object.entries(
|
|
70
|
+
effectiveFrom: t.effectiveFrom,
|
|
71
|
+
requirements: Object.entries(c).map(([p, e]) => ({
|
|
66
72
|
key: p,
|
|
67
|
-
value: String(
|
|
73
|
+
value: String(e)
|
|
68
74
|
}))
|
|
69
75
|
};
|
|
70
76
|
});
|
|
71
|
-
await
|
|
77
|
+
await E({
|
|
72
78
|
request: {
|
|
73
|
-
companyUuid:
|
|
79
|
+
companyUuid: i,
|
|
74
80
|
requestBody: { requirementSets: b },
|
|
75
|
-
state:
|
|
81
|
+
state: y
|
|
76
82
|
}
|
|
77
|
-
}), F(
|
|
83
|
+
}), F(q.COMPANY_STATE_TAX_UPDATED);
|
|
78
84
|
});
|
|
79
85
|
}, B = () => {
|
|
80
|
-
F(
|
|
86
|
+
F(q.CANCEL);
|
|
81
87
|
};
|
|
82
|
-
return /* @__PURE__ */
|
|
88
|
+
return /* @__PURE__ */ a("section", { className: _, children: /* @__PURE__ */ a(M, { ...T, control: O, children: /* @__PURE__ */ a(Q, { onSubmit: T.handleSubmit(U), children: /* @__PURE__ */ a(
|
|
83
89
|
Y,
|
|
84
90
|
{
|
|
85
|
-
value: { stateTaxRequirements:
|
|
86
|
-
children: /* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
91
|
+
value: { stateTaxRequirements: l, isPending: N, state: y, handleCancel: B },
|
|
92
|
+
children: /* @__PURE__ */ a(J, { flexDirection: "column", gap: 32, children: x || /* @__PURE__ */ D(H, { children: [
|
|
93
|
+
/* @__PURE__ */ a(k, {}),
|
|
94
|
+
/* @__PURE__ */ a(A, {}),
|
|
95
|
+
/* @__PURE__ */ a(P, {})
|
|
90
96
|
] }) })
|
|
91
97
|
}
|
|
92
98
|
) }) }) });
|
|
93
99
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
h.Head = k;
|
|
101
|
+
h.Form = A;
|
|
102
|
+
h.Actions = P;
|
|
97
103
|
export {
|
|
98
|
-
|
|
104
|
+
h as StateTaxesForm
|
|
99
105
|
};
|
|
100
106
|
//# sourceMappingURL=StateTaxesForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodTypeAny>>> = {}\n const values: Partial<Record<string, Record<string, string | boolean>>> = {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodTypeAny> = {}\n const requirementValues: Record<string, string | boolean> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n // --- Default Value Logic ---\n requirementValues[requirementKey] = requirement.value ?? ''\n\n // --- Schema Logic ---\n // Start with a basic string schema\n let fieldSchema: z.ZodTypeAny = z.string().min(1)\n\n const validation = requirement.metadata?.validation\n // Not all requirements have validation\n if (validation) {\n if (requirement.metadata?.type === 'tax_rate') {\n if (validation.type === 'min_max') {\n const min = parseFloat(validation.min as string)\n const max = parseFloat(validation.max as string)\n\n if (!isNaN(min) && !isNaN(max)) {\n fieldSchema = z.preprocess(\n val => Number(val),\n z\n .number()\n .min(min, t('validations.minValue', { min }))\n .max(max, t('validations.maxValue', { max }))\n .transform(num => String(num)),\n )\n }\n } else {\n //Type is one_of\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string()\n .min(1)\n .refine(val => oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n }\n if (requirement.metadata?.type === 'radio') {\n fieldSchema = z.boolean()\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([key, value]) => ({\n key,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nStateTaxesForm.Head = Head\nStateTaxesForm.Form = Form\nStateTaxesForm.Actions = Actions\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","fieldSchema","z","validation","min","max","val","num","oneOfValues","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","key","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,EAAeC,GAAqD;AAEhF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,GAAW,OAAAC,GAAO,GAC1EW,IAAuBF,EAAK,sBAE5B,EAAE,aAAaG,GAAgB,WAAWC,EAAA,IAC9CC,EAAsC,GAGlC,EAAE,eAAAC,GAAe,eAAAC,EAAc,IAAIC,EAAQ,MAAM;AACrD,UAAMC,IAAyE,CAAC,GAC1EC,IAAoE,CAAC;AAGtD,WAAAR,EAAA,iBAAiB,QAAQ,CAAkBS,MAAA;AAC1D,UAAA,CAACA,EAAe,IAAK;A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d,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAA1C;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAAvC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA+C,EAAa;AAAA,MAE/E,UAAA,gBAAAnD,EAACuD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAjD,KAIG,gBAAAkD,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
1
|
+
{"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodTypeAny>>> = {}\n const values: Partial<Record<string, Record<string, string | boolean | number | undefined>>> =\n {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodTypeAny> = {}\n const requirementValues: Record<string, string | boolean | number | undefined> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n // --- Default Value Logic ---\n requirementValues[requirementKey] =\n requirement.metadata?.type === 'radio'\n ? (requirement.value ?? undefined)\n : requirement.value\n ? String(requirement.value)\n : ''\n\n // --- Schema Logic ---\n // Start with a basic string schema\n let fieldSchema: z.ZodTypeAny = z\n .string({\n required_error: t('validations.required'),\n })\n .min(1, t('validations.required'))\n\n const validation = requirement.metadata?.validation\n // Not all requirements have validation\n if (validation) {\n if (requirement.metadata?.type === 'tax_rate') {\n if (validation.type === 'min_max') {\n const min = parseFloat(validation.min as string)\n const max = parseFloat(validation.max as string)\n\n if (!isNaN(min) && !isNaN(max)) {\n fieldSchema = z.preprocess(\n val => Number(val),\n z\n .number()\n .min(min, t('validations.minValue', { min }))\n .max(max, t('validations.maxValue', { max }))\n .transform(num => String(num)),\n )\n }\n } else {\n //Type is one_of\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string({\n required_error: t('validations.required'),\n })\n .min(1, t('validations.required'))\n .refine(val => oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n }\n if (requirement.metadata?.type === 'radio') {\n fieldSchema = z.boolean({\n required_error: t('validations.required'),\n })\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([key, value]) => ({\n key,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n\nStateTaxesForm.Head = Head\nStateTaxesForm.Form = Form\nStateTaxesForm.Actions = Actions\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","fieldSchema","z","validation","min","max","val","num","oneOfValues","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","key","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,EAAeC,GAAqD;AAEhF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,GAAW,OAAAC,GAAO,GAC1EW,IAAuBF,EAAK,sBAE5B,EAAE,aAAaG,GAAgB,WAAWC,EAAA,IAC9CC,EAAsC,GAGlC,EAAE,eAAAC,GAAe,eAAAC,EAAc,IAAIC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MAAA,CACD;AACH,YAAMjC,EAAe;AAAA,QACnB,SAAS;AAAA,UACP,aAAab;AAAA,UACb,aAAa,EAAE,iBAAA0C,EAAgB;AAAA,UAC/B,OAAAzC;AAAA,QAAA;AAAA,MACF,CACD,GACDI,EAAQ0C,EAAgB,yBAAyB;AAAA,IAAA,CAClD;AAAA,EACH,GAEMC,IAAe,MAAM;AACzB,IAAA3C,EAAQ0C,EAAgB,MAAM;AAAA,EAChC;AAEA,SACG,gBAAAlD,EAAA,WAAA,EAAQ,WAAAK,GACP,UAAA,gBAAAL,EAACoD,KAAc,GAAGb,GAAS,SAAAD,GACzB,UAAA,gBAAAtC,EAACqD,GAAS,EAAA,UAAUd,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAA1C;AAAA,IAACsD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAAvC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA+C,EAAa;AAAA,MAE/E,UAAA,gBAAAnD,EAACuD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAjD,KAIG,gBAAAkD,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzD,EAAC0D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
@@ -8,9 +8,9 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import "../../../Base/useBase.js";
|
|
10
10
|
import "../../../../shared/constants.js";
|
|
11
|
+
import "classnames";
|
|
11
12
|
import "dompurify";
|
|
12
13
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
-
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
14
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
15
|
const [c, d] = t("StateTaxesFormContext");
|
|
16
16
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as i } from "react-i18next";
|
|
3
3
|
import { useStateTaxesList as e } from "./context.js";
|
|
4
|
-
import "
|
|
4
|
+
import "classnames";
|
|
5
5
|
import { ActionsLayout as m } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
6
|
import { useComponentContext as s } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
7
|
function l() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s, Fragment as p } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as o } from "react-i18next";
|
|
3
3
|
import { useStateTaxesList as l } from "./context.js";
|
|
4
|
-
import "
|
|
4
|
+
import "classnames";
|
|
5
5
|
import { EmptyData as c } from "../../../Common/EmptyData/EmptyData.js";
|
|
6
6
|
import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
7
|
import { useDataView as d } from "../../../Common/DataView/useDataView.js";
|
|
@@ -8,9 +8,9 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import "../../../Base/useBase.js";
|
|
10
10
|
import "../../../../shared/constants.js";
|
|
11
|
+
import "classnames";
|
|
11
12
|
import "dompurify";
|
|
12
13
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
-
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
14
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
15
|
const [c, d] = t("StateTaxesListContext");
|
|
16
16
|
export {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const stateTaxesStateMachine: {
|
|
2
|
+
viewStateTaxes: import('robot3').MachineState<"company/stateTaxes/done" | "company/stateTaxes/edit">;
|
|
3
|
+
editStateTaxes: import('robot3').MachineState<"company/stateTaxes/updated" | "CANCEL">;
|
|
4
|
+
done: import('robot3').MachineState<string>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { state as o, transition as e, reduce as T } from "robot3";
|
|
2
|
+
import { StateTaxesListContextual as n, StateTaxesFormContextual as i } from "./StateTaxesComponents.js";
|
|
3
|
+
import { componentEvents as a } from "../../../shared/constants.js";
|
|
4
|
+
const S = {
|
|
5
|
+
viewStateTaxes: o(
|
|
6
|
+
e(
|
|
7
|
+
a.COMPANY_STATE_TAX_EDIT,
|
|
8
|
+
"editStateTaxes",
|
|
9
|
+
T(
|
|
10
|
+
(t, s) => ({
|
|
11
|
+
...t,
|
|
12
|
+
component: i,
|
|
13
|
+
state: s.payload.state
|
|
14
|
+
})
|
|
15
|
+
)
|
|
16
|
+
),
|
|
17
|
+
e(a.COMPANY_STATE_TAX_DONE, "done")
|
|
18
|
+
),
|
|
19
|
+
editStateTaxes: o(
|
|
20
|
+
e(
|
|
21
|
+
a.COMPANY_STATE_TAX_UPDATED,
|
|
22
|
+
"viewStateTaxes",
|
|
23
|
+
T(
|
|
24
|
+
(t, s) => ({
|
|
25
|
+
...t,
|
|
26
|
+
component: n,
|
|
27
|
+
state: void 0
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
),
|
|
31
|
+
e(
|
|
32
|
+
a.CANCEL,
|
|
33
|
+
"viewStateTaxes",
|
|
34
|
+
T(
|
|
35
|
+
(t) => ({
|
|
36
|
+
...t,
|
|
37
|
+
component: n,
|
|
38
|
+
state: void 0
|
|
39
|
+
})
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
),
|
|
43
|
+
done: o()
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
S as stateTaxesStateMachine
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=stateTaxesStateMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateTaxesStateMachine.js","sources":["../../../../src/components/Company/StateTaxes/stateTaxesStateMachine.tsx"],"sourcesContent":["import { reduce, state, state as final, transition } from 'robot3'\nimport type { ComponentType } from 'react'\nimport type { StateTaxesContextInterface } from './StateTaxesComponents'\nimport { StateTaxesFormContextual, StateTaxesListContextual } from './StateTaxesComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType } from '@/types/Helpers'\n\ntype EventPayloads = {\n [componentEvents.COMPANY_STATE_TAX_UPDATED]: undefined\n [componentEvents.COMPANY_STATE_TAX_EDIT]: { state: string }\n}\n\nexport const stateTaxesStateMachine = {\n viewStateTaxes: state(\n transition(\n componentEvents.COMPANY_STATE_TAX_EDIT,\n 'editStateTaxes',\n reduce(\n (\n ctx: StateTaxesContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.COMPANY_STATE_TAX_EDIT>,\n ): StateTaxesContextInterface => ({\n ...ctx,\n component: StateTaxesFormContextual as ComponentType,\n state: ev.payload.state,\n }),\n ),\n ),\n transition(componentEvents.COMPANY_STATE_TAX_DONE, 'done'),\n ),\n editStateTaxes: state(\n transition(\n componentEvents.COMPANY_STATE_TAX_UPDATED,\n 'viewStateTaxes',\n reduce(\n (\n ctx: StateTaxesContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.COMPANY_STATE_TAX_UPDATED>,\n ): StateTaxesContextInterface => ({\n ...ctx,\n component: StateTaxesListContextual as ComponentType,\n state: undefined,\n }),\n ),\n ),\n transition(\n componentEvents.CANCEL,\n 'viewStateTaxes',\n reduce(\n (ctx: StateTaxesContextInterface): StateTaxesContextInterface => ({\n ...ctx,\n component: StateTaxesListContextual as ComponentType,\n state: undefined,\n }),\n ),\n ),\n ),\n done: final(),\n}\n"],"names":["stateTaxesStateMachine","state","transition","componentEvents","reduce","ctx","ev","StateTaxesFormContextual","StateTaxesListContextual","final"],"mappings":";;;AAYO,MAAMA,IAAyB;AAAA,EACpC,gBAAgBC;AAAA,IACdC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CACEC,GACAC,OACgC;AAAA,UAChC,GAAGD;AAAA,UACH,WAAWE;AAAA,UACX,OAAOD,EAAG,QAAQ;AAAA,QACpB;AAAA,MAAA;AAAA,IAEJ;AAAA,IACAJ,EAAWC,EAAgB,wBAAwB,MAAM;AAAA,EAC3D;AAAA,EACA,gBAAgBF;AAAA,IACdC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CACEC,GACAC,OACgC;AAAA,UAChC,GAAGD;AAAA,UACH,WAAWG;AAAA,UACX,OAAO;AAAA,QACT;AAAA,MAAA;AAAA,IAEJ;AAAA,IACAN;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CAACC,OAAiE;AAAA,UAChE,GAAGA;AAAA,UACH,WAAWG;AAAA,UACX,OAAO;AAAA,QACT;AAAA,MAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EACA,MAAMC,EAAM;AACd;"}
|
|
@@ -11,6 +11,8 @@ import { Actions as f } from "./Actions.js";
|
|
|
11
11
|
import { Form as N } from "../../Common/Form/Form.js";
|
|
12
12
|
import { useComponentDictionary as j, useI18n as q } from "../../../i18n/I18n.js";
|
|
13
13
|
import { Flex as w } from "../../Common/Flex/Flex.js";
|
|
14
|
+
import "react-i18next";
|
|
15
|
+
import "classnames";
|
|
14
16
|
import { BaseComponent as G } from "../../Base/Base.js";
|
|
15
17
|
import { useBase as M } from "../../Base/useBase.js";
|
|
16
18
|
import { contractorEvents as a } from "../../../shared/constants.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Address.js","sources":["../../../../src/components/Contractor/Address/Address.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddressSuspense } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport { useContractorsUpdateAddressMutation } from '@gusto/embedded-api/react-query/contractorsUpdateAddress'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { AddressFormSchema, AddressProvider } from './useAddress'\nimport { Head } from './Head'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { AddressDefaultValues, AddressFormValues } from './useAddress'\nimport { Form as HtmlForm } from '@/components/Common/Form/Form'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { Flex } from '@/components/Common'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { contractorEvents } from '@/shared/constants'\n\nexport interface AddressProps extends BaseComponentInterface<'Contractor.Address'> {\n contractorId: string\n defaultValues?: AddressDefaultValues\n children?: ReactNode\n className?: string\n}\n\nexport function Address(props: AddressProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ contractorId, defaultValues, children, className, dictionary }: AddressProps) {\n useComponentDictionary('Contractor.Address', dictionary)\n useI18n('Contractor.Address')\n\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const { data: addressData } = useContractorsGetAddressSuspense({ contractorUuid: contractorId })\n\n const { mutateAsync: updateAddress, isPending: isUpdatingAddressPending } =\n useContractorsUpdateAddressMutation()\n\n const contractor = contractorData.contractor\n const contractorType = contractorData.contractor?.type\n const address = addressData.contractorAddress\n\n const formDefaultValues = {\n street1: address?.street1 || defaultValues?.street1 || '',\n street2: address?.street2 || defaultValues?.street2 || '',\n city: address?.city || defaultValues?.city || '',\n state: address?.state || defaultValues?.state || '',\n zip: address?.zip || defaultValues?.zip || '',\n }\n\n const formMethods = useForm<AddressFormValues>({\n resolver: zodResolver(AddressFormSchema),\n defaultValues: formDefaultValues,\n })\n\n const onSubmit = async (data: AddressFormValues) => {\n await baseSubmitHandler(data, async payload => {\n const { contractorAddress } = await updateAddress({\n request: {\n contractorUuid: contractorId,\n requestBody: {\n version: address?.version as string,\n street1: payload.street1,\n street2: payload.street2,\n city: payload.city,\n state: payload.state,\n zip: payload.zip,\n },\n },\n })\n\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_UPDATED, contractorAddress)\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_DONE)\n })\n }\n\n return (\n <section className={className}>\n <AddressProvider\n value={{\n contractor,\n contractorType,\n address,\n isPending: isUpdatingAddressPending,\n }}\n >\n <FormProvider {...formMethods}>\n <HtmlForm onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </HtmlForm>\n </FormProvider>\n </AddressProvider>\n </section>\n )\n}\n\nAddress.Head = Head\nAddress.Form = Form\nAddress.Actions = Actions\n\nexport default Address\n"],"names":["Address","props","jsx","BaseComponent","Root","contractorId","defaultValues","children","className","dictionary","useComponentDictionary","useI18n","onEvent","baseSubmitHandler","useBase","contractorData","useContractorsGetSuspense","addressData","useContractorsGetAddressSuspense","updateAddress","isUpdatingAddressPending","useContractorsUpdateAddressMutation","contractor","contractorType","address","formDefaultValues","formMethods","useForm","zodResolver","AddressFormSchema","onSubmit","data","payload","contractorAddress","contractorEvents","AddressProvider","FormProvider","HtmlForm","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Address.js","sources":["../../../../src/components/Contractor/Address/Address.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddressSuspense } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport { useContractorsUpdateAddressMutation } from '@gusto/embedded-api/react-query/contractorsUpdateAddress'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { AddressFormSchema, AddressProvider } from './useAddress'\nimport { Head } from './Head'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { AddressDefaultValues, AddressFormValues } from './useAddress'\nimport { Form as HtmlForm } from '@/components/Common/Form/Form'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { Flex } from '@/components/Common'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { contractorEvents } from '@/shared/constants'\n\nexport interface AddressProps extends BaseComponentInterface<'Contractor.Address'> {\n contractorId: string\n defaultValues?: AddressDefaultValues\n children?: ReactNode\n className?: string\n}\n\nexport function Address(props: AddressProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ contractorId, defaultValues, children, className, dictionary }: AddressProps) {\n useComponentDictionary('Contractor.Address', dictionary)\n useI18n('Contractor.Address')\n\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const { data: addressData } = useContractorsGetAddressSuspense({ contractorUuid: contractorId })\n\n const { mutateAsync: updateAddress, isPending: isUpdatingAddressPending } =\n useContractorsUpdateAddressMutation()\n\n const contractor = contractorData.contractor\n const contractorType = contractorData.contractor?.type\n const address = addressData.contractorAddress\n\n const formDefaultValues = {\n street1: address?.street1 || defaultValues?.street1 || '',\n street2: address?.street2 || defaultValues?.street2 || '',\n city: address?.city || defaultValues?.city || '',\n state: address?.state || defaultValues?.state || '',\n zip: address?.zip || defaultValues?.zip || '',\n }\n\n const formMethods = useForm<AddressFormValues>({\n resolver: zodResolver(AddressFormSchema),\n defaultValues: formDefaultValues,\n })\n\n const onSubmit = async (data: AddressFormValues) => {\n await baseSubmitHandler(data, async payload => {\n const { contractorAddress } = await updateAddress({\n request: {\n contractorUuid: contractorId,\n requestBody: {\n version: address?.version as string,\n street1: payload.street1,\n street2: payload.street2,\n city: payload.city,\n state: payload.state,\n zip: payload.zip,\n },\n },\n })\n\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_UPDATED, contractorAddress)\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_DONE)\n })\n }\n\n return (\n <section className={className}>\n <AddressProvider\n value={{\n contractor,\n contractorType,\n address,\n isPending: isUpdatingAddressPending,\n }}\n >\n <FormProvider {...formMethods}>\n <HtmlForm onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </HtmlForm>\n </FormProvider>\n </AddressProvider>\n </section>\n )\n}\n\nAddress.Head = Head\nAddress.Form = Form\nAddress.Actions = Actions\n\nexport default Address\n"],"names":["Address","props","jsx","BaseComponent","Root","contractorId","defaultValues","children","className","dictionary","useComponentDictionary","useI18n","onEvent","baseSubmitHandler","useBase","contractorData","useContractorsGetSuspense","addressData","useContractorsGetAddressSuspense","updateAddress","isUpdatingAddressPending","useContractorsUpdateAddressMutation","contractor","contractorType","address","formDefaultValues","formMethods","useForm","zodResolver","AddressFormSchema","onSubmit","data","payload","contractorAddress","contractorEvents","AddressProvider","FormProvider","HtmlForm","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AA0BO,SAASA,EAAQC,GAAqB;AAEzC,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,cAAAC,GAAc,eAAAC,GAAe,UAAAC,GAAU,WAAAC,GAAW,YAAAC,KAA4B;AAC5F,EAAAC,EAAuB,sBAAsBD,CAAU,GACvDE,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AACiC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,YAAAb;AAAA,QACA,gBAAAC;AAAA,QACA,SAAAC;AAAA,QACA,WAAWJ;AAAA,MACb;AAAA,MAEA,4BAACgB,GAAc,EAAA,GAAGV,GAChB,UAAC,gBAAAxB,EAAAmC,GAAA,EAAS,UAAUX,EAAY,aAAaI,CAAQ,GACnD,UAAA,gBAAA5B,EAACoC,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAA/B,KAIG,gBAAAgC,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAtC,EAACuC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEA3C,EAAQ,OAAOyC;AACfzC,EAAQ,OAAO0C;AACf1C,EAAQ,UAAU2C;"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as i } from "react-i18next";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { Grid as o } from "../../Common/Grid/Grid.js";
|
|
4
|
+
import "classnames";
|
|
5
|
+
import { STATES_ABBR as l } from "../../../shared/constants.js";
|
|
5
6
|
import { TextInputField as t } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
6
7
|
import { SelectField as m } from "../../Common/Fields/SelectField/SelectField.js";
|
|
7
|
-
function
|
|
8
|
+
function v() {
|
|
8
9
|
const { t: e } = i("Contractor.Address");
|
|
9
|
-
return /* @__PURE__ */ s(
|
|
10
|
+
return /* @__PURE__ */ s(o, { gridTemplateColumns: { base: "1fr", small: ["1fr", "1fr"] }, gap: 20, children: [
|
|
10
11
|
/* @__PURE__ */ r(
|
|
11
12
|
t,
|
|
12
13
|
{
|
|
@@ -30,7 +31,7 @@ function g() {
|
|
|
30
31
|
m,
|
|
31
32
|
{
|
|
32
33
|
name: "state",
|
|
33
|
-
options:
|
|
34
|
+
options: l.map((a) => ({
|
|
34
35
|
label: e(`statesHash.${a}`, { ns: "common", defaultValue: a }),
|
|
35
36
|
value: a
|
|
36
37
|
})),
|
|
@@ -44,6 +45,6 @@ function g() {
|
|
|
44
45
|
] });
|
|
45
46
|
}
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
+
v as Form
|
|
48
49
|
};
|
|
49
50
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../../src/components/Contractor/Address/Form.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { TextInputField, SelectField, Grid } from '@/components/Common'\nimport { STATES_ABBR } from '@/shared/constants'\n\nexport function Form() {\n const { t } = useTranslation('Contractor.Address')\n\n return (\n <Grid gridTemplateColumns={{ base: '1fr', small: ['1fr', '1fr'] }} gap={20}>\n <TextInputField\n name=\"street1\"\n label={t('street1')}\n isRequired\n errorMessage={t('validations.street1')}\n />\n <TextInputField name=\"street2\" label={t('street2')} />\n <TextInputField\n name=\"city\"\n label={t('city')}\n isRequired\n errorMessage={t('validations.city')}\n />\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map(stateAbbr => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common', defaultValue: stateAbbr }),\n value: stateAbbr,\n }))}\n label={t('state')}\n placeholder={t('statePlaceholder')}\n errorMessage={t('validations.state')}\n isRequired\n />\n <TextInputField name=\"zip\" label={t('zip')} isRequired errorMessage={t('validations.zip')} />\n </Grid>\n )\n}\n"],"names":["Form","t","useTranslation","jsxs","Grid","jsx","TextInputField","SelectField","STATES_ABBR","stateAbbr"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../../src/components/Contractor/Address/Form.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { TextInputField, SelectField, Grid } from '@/components/Common'\nimport { STATES_ABBR } from '@/shared/constants'\n\nexport function Form() {\n const { t } = useTranslation('Contractor.Address')\n\n return (\n <Grid gridTemplateColumns={{ base: '1fr', small: ['1fr', '1fr'] }} gap={20}>\n <TextInputField\n name=\"street1\"\n label={t('street1')}\n isRequired\n errorMessage={t('validations.street1')}\n />\n <TextInputField name=\"street2\" label={t('street2')} />\n <TextInputField\n name=\"city\"\n label={t('city')}\n isRequired\n errorMessage={t('validations.city')}\n />\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map(stateAbbr => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common', defaultValue: stateAbbr }),\n value: stateAbbr,\n }))}\n label={t('state')}\n placeholder={t('statePlaceholder')}\n errorMessage={t('validations.state')}\n isRequired\n />\n <TextInputField name=\"zip\" label={t('zip')} isRequired errorMessage={t('validations.zip')} />\n </Grid>\n )\n}\n"],"names":["Form","t","useTranslation","jsxs","Grid","jsx","TextInputField","SelectField","STATES_ABBR","stateAbbr"],"mappings":";;;;;;;AAIO,SAASA,IAAO;AACrB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,oBAAoB;AAEjD,SACG,gBAAAC,EAAAC,GAAA,EAAK,qBAAqB,EAAE,MAAM,OAAO,OAAO,CAAC,OAAO,KAAK,EAAE,GAAG,KAAK,IACtE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,SAAS;AAAA,QAClB,YAAU;AAAA,QACV,cAAcA,EAAE,qBAAqB;AAAA,MAAA;AAAA,IACvC;AAAA,sBACCK,GAAe,EAAA,MAAK,WAAU,OAAOL,EAAE,SAAS,GAAG;AAAA,IACpD,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,MAAM;AAAA,QACf,YAAU;AAAA,QACV,cAAcA,EAAE,kBAAkB;AAAA,MAAA;AAAA,IACpC;AAAA,IACA,gBAAAI;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,SAASC,EAAY,IAAI,CAAcC,OAAA;AAAA,UACrC,OAAOR,EAAE,cAAcQ,CAAS,IAAI,EAAE,IAAI,UAAU,cAAcA,GAAW;AAAA,UAC7E,OAAOA;AAAA,QAAA,EACP;AAAA,QACF,OAAOR,EAAE,OAAO;AAAA,QAChB,aAAaA,EAAE,kBAAkB;AAAA,QACjC,cAAcA,EAAE,mBAAmB;AAAA,QACnC,YAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IACC,gBAAAI,EAAAC,GAAA,EAAe,MAAK,OAAM,OAAOL,EAAE,KAAK,GAAG,YAAU,IAAC,cAAcA,EAAE,iBAAiB,EAAG,CAAA;AAAA,EAAA,GAC7F;AAEJ;"}
|
|
@@ -9,9 +9,9 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
9
9
|
import "@tanstack/react-query";
|
|
10
10
|
import "../../Base/useBase.js";
|
|
11
11
|
import "../../../shared/constants.js";
|
|
12
|
+
import "classnames";
|
|
12
13
|
import "dompurify";
|
|
13
14
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
15
|
import { createCompoundContext as r } from "../../Base/createCompoundContext.js";
|
|
16
16
|
const u = t.object({
|
|
17
17
|
street1: t.string().min(1),
|
|
@@ -3,6 +3,7 @@ import { useTranslation as s } from "react-i18next";
|
|
|
3
3
|
import { useContractors as d } from "./useContractorList.js";
|
|
4
4
|
import { Flex as u } from "../../Common/Flex/Flex.js";
|
|
5
5
|
import { Grid as f } from "../../Common/Grid/Grid.js";
|
|
6
|
+
import "classnames";
|
|
6
7
|
import { EmptyData as C } from "../../Common/EmptyData/EmptyData.js";
|
|
7
8
|
import { ActionsLayout as L } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
8
9
|
import { firstLastName as g } from "../../../helpers/formattedStrings.js";
|
|
@@ -64,7 +65,7 @@ function j({
|
|
|
64
65
|
/* @__PURE__ */ t(x, { label: n("contractorListLabel"), ...l })
|
|
65
66
|
] });
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function W({
|
|
68
69
|
companyId: e,
|
|
69
70
|
handleAdd: o,
|
|
70
71
|
handleEdit: r
|
|
@@ -74,7 +75,7 @@ function U({
|
|
|
74
75
|
}
|
|
75
76
|
export {
|
|
76
77
|
j as ContractorList,
|
|
77
|
-
|
|
78
|
+
W as ContractorListWithApi,
|
|
78
79
|
H as EmptyDataContractorsList,
|
|
79
80
|
D as Head
|
|
80
81
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Contractor/List/index.tsx"],"sourcesContent":["import { type Contractor } from '@gusto/embedded-api/models/components/contractor'\nimport { useTranslation } from 'react-i18next'\nimport { useContractors } from './useContractorList'\nimport { ActionsLayout, DataView, EmptyData, Flex, Grid, useDataView } from '@/components/Common'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { ContractorOnboardingStatusBadge } from '@/components/Common/OnboardingStatusBadge'\nimport { useI18n } from '@/i18n'\n\nexport type ContractorListDisplay = Pick<\n Contractor,\n 'onboardingStatus' | 'firstName' | 'lastName' | 'onboarded'\n>\n\nexport interface HeadProps {\n count: number\n handleAdd: () => void\n}\nexport function Head({ count, handleAdd }: HeadProps) {\n const { Button, Heading } = useComponentContext()\n const { t } = useTranslation('Contractor.ContractorList')\n\n return (\n <Flex alignItems=\"center\" justifyContent=\"space-between\">\n <Heading as=\"h2\">{t('title')}</Heading>\n\n {count !== 0 && (\n <Button variant=\"secondary\" onClick={handleAdd}>\n {t('addAnotherCTA')}\n </Button>\n )}\n </Flex>\n )\n}\n\nexport interface EmptyDataContractorsListProps {\n handleAdd: () => void\n}\nexport function EmptyDataContractorsList({ handleAdd }: EmptyDataContractorsListProps) {\n const { Button } = useComponentContext()\n const { t } = useTranslation('Contractor.ContractorList')\n\n return (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')}>\n <ActionsLayout justifyContent=\"center\">\n <Button onClick={handleAdd}>{t('addContractorCTA')}</Button>\n </ActionsLayout>\n </EmptyData>\n )\n}\n\nexport interface ContractorListProps {\n contractors: ContractorListDisplay[]\n handleAdd: () => void\n handleEdit: () => void\n totalCount: number\n}\n\nexport function ContractorList({\n contractors,\n handleAdd,\n handleEdit,\n totalCount,\n}: ContractorListProps) {\n useI18n('Contractor.ContractorList')\n const { t } = useTranslation('Contractor.ContractorList')\n\n const dataViewProps = useDataView<ContractorListDisplay>({\n columns: [\n {\n title: t('listHeaders.name'),\n render: contractor =>\n firstLastName({ first_name: contractor.firstName, last_name: contractor.lastName }),\n },\n {\n title: t('listHeaders.status'),\n render: ({ onboarded, onboardingStatus }) => (\n <ContractorOnboardingStatusBadge\n onboarded={onboarded}\n onboardingStatus={onboardingStatus}\n />\n ),\n },\n ],\n data: contractors,\n itemMenu: () => (\n <HamburgerMenu\n items={[{ label: t('editCTA'), icon: <PencilSvg aria-hidden />, onClick: handleEdit }]}\n triggerLabel={t('editCTA')}\n isLoading={false}\n />\n ),\n emptyState: () => <EmptyDataContractorsList handleAdd={handleAdd} />,\n })\n\n return (\n <Grid gap={20}>\n <Head count={totalCount} handleAdd={handleAdd} />\n <DataView label={t('contractorListLabel')} {...dataViewProps} />\n </Grid>\n )\n}\n\nexport interface ContractorListWithApiProps {\n companyId: string\n handleAdd: () => void\n handleEdit: () => void\n}\n\nexport function ContractorListWithApi({\n companyId,\n handleAdd,\n handleEdit,\n}: ContractorListWithApiProps) {\n const contractorProps = useContractors({ companyUuid: companyId, handleAdd })\n\n return <ContractorList handleEdit={handleEdit} {...contractorProps} />\n}\n"],"names":["Head","count","handleAdd","Button","Heading","useComponentContext","t","useTranslation","jsxs","Flex","jsx","EmptyDataContractorsList","EmptyData","ActionsLayout","ContractorList","contractors","handleEdit","totalCount","useI18n","dataViewProps","useDataView","contractor","firstLastName","onboarded","onboardingStatus","ContractorOnboardingStatusBadge","HamburgerMenu","PencilSvg","Grid","DataView","ContractorListWithApi","companyId","contractorProps","useContractors"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Contractor/List/index.tsx"],"sourcesContent":["import { type Contractor } from '@gusto/embedded-api/models/components/contractor'\nimport { useTranslation } from 'react-i18next'\nimport { useContractors } from './useContractorList'\nimport { ActionsLayout, DataView, EmptyData, Flex, Grid, useDataView } from '@/components/Common'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { ContractorOnboardingStatusBadge } from '@/components/Common/OnboardingStatusBadge'\nimport { useI18n } from '@/i18n'\n\nexport type ContractorListDisplay = Pick<\n Contractor,\n 'onboardingStatus' | 'firstName' | 'lastName' | 'onboarded'\n>\n\nexport interface HeadProps {\n count: number\n handleAdd: () => void\n}\nexport function Head({ count, handleAdd }: HeadProps) {\n const { Button, Heading } = useComponentContext()\n const { t } = useTranslation('Contractor.ContractorList')\n\n return (\n <Flex alignItems=\"center\" justifyContent=\"space-between\">\n <Heading as=\"h2\">{t('title')}</Heading>\n\n {count !== 0 && (\n <Button variant=\"secondary\" onClick={handleAdd}>\n {t('addAnotherCTA')}\n </Button>\n )}\n </Flex>\n )\n}\n\nexport interface EmptyDataContractorsListProps {\n handleAdd: () => void\n}\nexport function EmptyDataContractorsList({ handleAdd }: EmptyDataContractorsListProps) {\n const { Button } = useComponentContext()\n const { t } = useTranslation('Contractor.ContractorList')\n\n return (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')}>\n <ActionsLayout justifyContent=\"center\">\n <Button onClick={handleAdd}>{t('addContractorCTA')}</Button>\n </ActionsLayout>\n </EmptyData>\n )\n}\n\nexport interface ContractorListProps {\n contractors: ContractorListDisplay[]\n handleAdd: () => void\n handleEdit: () => void\n totalCount: number\n}\n\nexport function ContractorList({\n contractors,\n handleAdd,\n handleEdit,\n totalCount,\n}: ContractorListProps) {\n useI18n('Contractor.ContractorList')\n const { t } = useTranslation('Contractor.ContractorList')\n\n const dataViewProps = useDataView<ContractorListDisplay>({\n columns: [\n {\n title: t('listHeaders.name'),\n render: contractor =>\n firstLastName({ first_name: contractor.firstName, last_name: contractor.lastName }),\n },\n {\n title: t('listHeaders.status'),\n render: ({ onboarded, onboardingStatus }) => (\n <ContractorOnboardingStatusBadge\n onboarded={onboarded}\n onboardingStatus={onboardingStatus}\n />\n ),\n },\n ],\n data: contractors,\n itemMenu: () => (\n <HamburgerMenu\n items={[{ label: t('editCTA'), icon: <PencilSvg aria-hidden />, onClick: handleEdit }]}\n triggerLabel={t('editCTA')}\n isLoading={false}\n />\n ),\n emptyState: () => <EmptyDataContractorsList handleAdd={handleAdd} />,\n })\n\n return (\n <Grid gap={20}>\n <Head count={totalCount} handleAdd={handleAdd} />\n <DataView label={t('contractorListLabel')} {...dataViewProps} />\n </Grid>\n )\n}\n\nexport interface ContractorListWithApiProps {\n companyId: string\n handleAdd: () => void\n handleEdit: () => void\n}\n\nexport function ContractorListWithApi({\n companyId,\n handleAdd,\n handleEdit,\n}: ContractorListWithApiProps) {\n const contractorProps = useContractors({ companyUuid: companyId, handleAdd })\n\n return <ContractorList handleEdit={handleEdit} {...contractorProps} />\n}\n"],"names":["Head","count","handleAdd","Button","Heading","useComponentContext","t","useTranslation","jsxs","Flex","jsx","EmptyDataContractorsList","EmptyData","ActionsLayout","ContractorList","contractors","handleEdit","totalCount","useI18n","dataViewProps","useDataView","contractor","firstLastName","onboarded","onboardingStatus","ContractorOnboardingStatusBadge","HamburgerMenu","PencilSvg","Grid","DataView","ContractorListWithApi","companyId","contractorProps","use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,OAAOf,EAAE,oBAAoB;AAAA,QAC7B,QAAQ,CAAC,EAAE,WAAAiB,GAAW,kBAAAC,EACpB,MAAA,gBAAAd;AAAA,UAACe;AAAA,UAAA;AAAA,YACC,WAAAF;AAAA,YACA,kBAAAC;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAGN;AAAA,IACA,MAAMT;AAAA,IACN,UAAU,MACR,gBAAAL;AAAA,MAACgB;AAAA,MAAA;AAAA,QACC,OAAO,CAAC,EAAE,OAAOpB,EAAE,SAAS,GAAG,MAAM,gBAAAI,EAACiB,KAAU,eAAW,GAAA,CAAC,GAAI,SAASX,GAAY;AAAA,QACrF,cAAcV,EAAE,SAAS;AAAA,QACzB,WAAW;AAAA,MAAA;AAAA,IACb;AAAA,IAEF,YAAY,MAAO,gBAAAI,EAAAC,GAAA,EAAyB,WAAAT,EAAsB,CAAA;AAAA,EAAA,CACnE;AAGC,SAAA,gBAAAM,EAACoB,GAAK,EAAA,KAAK,IACT,UAAA;AAAA,IAAC,gBAAAlB,EAAAV,GAAA,EAAK,OAAOiB,GAAY,WAAAf,EAAsB,CAAA;AAAA,sBAC9C2B,GAAS,EAAA,OAAOvB,EAAE,qBAAqB,GAAI,GAAGa,EAAe,CAAA;AAAA,EAAA,GAChE;AAEJ;AAQO,SAASW,EAAsB;AAAA,EACpC,WAAAC;AAAA,EACA,WAAA7B;AAAA,EACA,YAAAc;AACF,GAA+B;AAC7B,QAAMgB,IAAkBC,EAAe,EAAE,aAAaF,GAAW,WAAA7B,GAAW;AAE5E,SAAQ,gBAAAQ,EAAAI,GAAA,EAAe,YAAAE,GAAyB,GAAGgB,EAAiB,CAAA;AACtE;"}
|
|
@@ -11,9 +11,10 @@ import { BaseComponent as g } from "../../Base/Base.js";
|
|
|
11
11
|
import { useBase as A } from "../../Base/useBase.js";
|
|
12
12
|
import { useComponentContext as B } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
13
|
import { Form as P } from "../../Common/Form/Form.js";
|
|
14
|
-
import { STATES_ABBR as j, componentEvents as
|
|
14
|
+
import { STATES_ABBR as j, componentEvents as p } from "../../../shared/constants.js";
|
|
15
15
|
import { ActionsLayout as L } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
16
16
|
import { Flex as M } from "../../Common/Flex/Flex.js";
|
|
17
|
+
import "classnames";
|
|
17
18
|
import { RadioGroupField as U } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
18
19
|
import { SelectField as q } from "../../Common/Fields/SelectField/SelectField.js";
|
|
19
20
|
const W = r.union([
|
|
@@ -25,38 +26,38 @@ const W = r.union([
|
|
|
25
26
|
fileNewHireReport: r.boolean().refine((o) => !o)
|
|
26
27
|
})
|
|
27
28
|
]);
|
|
28
|
-
function
|
|
29
|
+
function le(o) {
|
|
29
30
|
return /* @__PURE__ */ e(g, { ...o, children: /* @__PURE__ */ e(k, { ...o, children: o.children }) });
|
|
30
31
|
}
|
|
31
|
-
function k({ contractorId: o, className:
|
|
32
|
+
function k({ contractorId: o, className: u, dictionary: d }) {
|
|
32
33
|
F("Contractor.NewHireReport", d), x("Contractor.NewHireReport");
|
|
33
34
|
const { t } = v("Contractor.NewHireReport"), { onEvent: m, baseSubmitHandler: f } = A(), s = B(), {
|
|
34
35
|
data: { contractor: R }
|
|
35
|
-
} = y({ contractorUuid: o }),
|
|
36
|
+
} = y({ contractorUuid: o }), i = R, { mutateAsync: h, isPending: H } = D(), w = O(
|
|
36
37
|
() => ({
|
|
37
|
-
fileNewHireReport:
|
|
38
|
-
state:
|
|
38
|
+
fileNewHireReport: i.fileNewHireReport || !1,
|
|
39
|
+
state: i.workState || null
|
|
39
40
|
}),
|
|
40
|
-
[
|
|
41
|
+
[i]
|
|
41
42
|
), a = S({
|
|
42
43
|
resolver: _(W),
|
|
43
44
|
defaultValues: w
|
|
44
|
-
}), N = E({ control: a.control, name: "fileNewHireReport" }), b = async (
|
|
45
|
-
await f(
|
|
45
|
+
}), N = E({ control: a.control, name: "fileNewHireReport" }), b = async (n) => {
|
|
46
|
+
await f(n, async (l) => {
|
|
46
47
|
const C = await h({
|
|
47
48
|
request: {
|
|
48
49
|
contractorUuid: o,
|
|
49
50
|
requestBody: {
|
|
50
51
|
fileNewHireReport: l.fileNewHireReport,
|
|
51
52
|
workState: "state" in l ? l.state : null,
|
|
52
|
-
version:
|
|
53
|
+
version: i.version
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
|
-
m(
|
|
57
|
+
m(p.CONTRACTOR_NEW_HIRE_REPORT_UPDATED, C), m(p.CONTRACTOR_NEW_HIRE_REPORT_DONE);
|
|
57
58
|
});
|
|
58
59
|
};
|
|
59
|
-
return /* @__PURE__ */ e("section", { className:
|
|
60
|
+
return /* @__PURE__ */ e("section", { className: u, children: /* @__PURE__ */ e(T, { ...a, children: /* @__PURE__ */ e(P, { onSubmit: a.handleSubmit(b), children: /* @__PURE__ */ c(M, { flexDirection: "column", children: [
|
|
60
61
|
/* @__PURE__ */ c("header", { children: [
|
|
61
62
|
/* @__PURE__ */ e(s.Heading, { as: "h2", children: t("title") }),
|
|
62
63
|
/* @__PURE__ */ e(s.Text, { children: t("description") })
|
|
@@ -83,9 +84,9 @@ function k({ contractorId: o, className: p, dictionary: d }) {
|
|
|
83
84
|
q,
|
|
84
85
|
{
|
|
85
86
|
name: "state",
|
|
86
|
-
options: j.map((
|
|
87
|
-
label: t(`statesHash.${
|
|
88
|
-
value:
|
|
87
|
+
options: j.map((n) => ({
|
|
88
|
+
label: t(`statesHash.${n}`, { ns: "common" }),
|
|
89
|
+
value: n
|
|
89
90
|
})),
|
|
90
91
|
label: t("stateSelectionLabel"),
|
|
91
92
|
placeholder: "",
|
|
@@ -105,6 +106,6 @@ function k({ contractorId: o, className: p, dictionary: d }) {
|
|
|
105
106
|
] }) }) }) });
|
|
106
107
|
}
|
|
107
108
|
export {
|
|
108
|
-
|
|
109
|
+
le as NewHireReport
|
|
109
110
|
};
|
|
110
111
|
//# sourceMappingURL=NewHireReport.js.map
|