@gusto/embedded-react-sdk 0.10.6 → 0.10.7-rc.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 +7 -0
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +7 -8
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +4 -5
- 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/AssignSignatorySelection.js +6 -7
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +8 -9
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +6 -7
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +6 -6
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +6 -7
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +7 -8
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +5 -6
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +6 -7
- package/dist/components/Company/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +8 -9
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Actions.js +5 -6
- package/dist/components/Company/Industry/Actions.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/Edit.js +10 -11
- package/dist/components/Company/Industry/Edit.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +2 -3
- package/dist/components/Company/Locations/LocationForm/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +2 -3
- package/dist/components/Company/Locations/LocationsList/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +2 -3
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +10 -11
- package/dist/components/Company/PaySchedule/_parts/Actions.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +5 -6
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxes.js +44 -23
- package/dist/components/Company/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesComponents.d.ts +8 -6
- package/dist/components/Company/StateTaxes/StateTaxesComponents.js +16 -15
- package/dist/components/Company/StateTaxes/StateTaxesComponents.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +5 -6
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +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 +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +6 -7
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +5 -6
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/stateTaxesReducer.d.ts +20 -0
- package/dist/components/Company/StateTaxes/stateTaxesReducer.js +40 -0
- package/dist/components/Company/StateTaxes/stateTaxesReducer.js.map +1 -0
- package/dist/components/Contractor/Address/Form.js +4 -4
- package/dist/components/Contractor/Address/useAddress.js +5 -6
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +2 -3
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +1 -1
- package/dist/components/Employee/Compensation/List.js +5 -6
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Deductions/Actions.js +8 -9
- package/dist/components/Employee/Deductions/Actions.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionForm.js +2 -3
- package/dist/components/Employee/Deductions/DeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsList.js +2 -3
- package/dist/components/Employee/Deductions/DeductionsList.js.map +1 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +2 -3
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js.map +1 -1
- package/dist/components/Employee/Deductions/useDeductions.js +5 -6
- package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +4 -5
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +4 -5
- package/dist/components/Employee/EmployeeList/Actions.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +12 -12
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +3 -4
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Actions.js +5 -6
- package/dist/components/Employee/PaymentMethod/Actions.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +2 -3
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +5 -6
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/Actions.js +6 -7
- package/dist/components/Employee/Profile/Actions.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +8 -9
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +3 -4
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/Taxes/Actions.js +7 -8
- package/dist/components/Employee/Taxes/Actions.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +4 -5
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +2 -3
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +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/stateTaxesStateMachine.d.ts +0 -5
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js +0 -48
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js.map +0 -1
|
@@ -10,11 +10,10 @@ import "../../Base/useBase.js";
|
|
|
10
10
|
import "../../../shared/constants.js";
|
|
11
11
|
import "dompurify";
|
|
12
12
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
13
|
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
15
|
-
const [
|
|
14
|
+
const [w, x] = o("OnboardingOverviewContext");
|
|
16
15
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
x as OnboardingOverviewProvider,
|
|
17
|
+
w as useOnboardingOverview
|
|
19
18
|
};
|
|
20
19
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../../src/components/Company/OnboardingOverview/context.ts"],"sourcesContent":["import type { OnboardingStep } from '@gusto/embedded-api/models/components/companyonboardingstatus'\nimport { createCompoundContext } from '@/components/Base'\n\ntype OnboardingOverviewContextType = {\n onboardingCompleted?: boolean\n onboardingSteps?: OnboardingStep[]\n handleDone: () => void\n handleContinue: () => void\n}\n\nconst [useOnboardingOverview, OnboardingOverviewProvider] =\n createCompoundContext<OnboardingOverviewContextType>('OnboardingOverviewContext')\n\nexport { useOnboardingOverview, OnboardingOverviewProvider }\n"],"names":["useOnboardingOverview","OnboardingOverviewProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../src/components/Company/OnboardingOverview/context.ts"],"sourcesContent":["import type { OnboardingStep } from '@gusto/embedded-api/models/components/companyonboardingstatus'\nimport { createCompoundContext } from '@/components/Base'\n\ntype OnboardingOverviewContextType = {\n onboardingCompleted?: boolean\n onboardingSteps?: OnboardingStep[]\n handleDone: () => void\n handleContinue: () => void\n}\n\nconst [useOnboardingOverview, OnboardingOverviewProvider] =\n createCompoundContext<OnboardingOverviewContextType>('OnboardingOverviewContext')\n\nexport { useOnboardingOverview, OnboardingOverviewProvider }\n"],"names":["useOnboardingOverview","OnboardingOverviewProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAuBC,CAA0B,IACtDC,EAAqD,2BAA2B;"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { jsxs as e, Fragment as d, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as l } from "react-i18next";
|
|
3
3
|
import { usePaySchedule as m } from "../usePaySchedule.js";
|
|
4
|
-
import "
|
|
5
|
-
import { ActionsLayout as i } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
4
|
+
import { ActionsLayout as a } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
5
|
import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
|
-
const
|
|
8
|
-
const { t: n } = l("Company.PaySchedule"), { mode: c, handleAdd:
|
|
6
|
+
const S = () => {
|
|
7
|
+
const { t: n } = l("Company.PaySchedule"), { mode: c, handleAdd: r, handleCancel: i, handleContinue: s } = m(), t = u();
|
|
9
8
|
return /* @__PURE__ */ e(d, { children: [
|
|
10
|
-
c === "LIST_PAY_SCHEDULES" && /* @__PURE__ */ e(
|
|
9
|
+
c === "LIST_PAY_SCHEDULES" && /* @__PURE__ */ e(a, { children: [
|
|
11
10
|
/* @__PURE__ */ o(
|
|
12
11
|
t.Button,
|
|
13
12
|
{
|
|
14
13
|
variant: "secondary",
|
|
15
14
|
onClick: () => {
|
|
16
|
-
|
|
15
|
+
r();
|
|
17
16
|
},
|
|
18
17
|
children: n("addAnotherPayScheduleCta")
|
|
19
18
|
}
|
|
@@ -29,26 +28,26 @@ const E = () => {
|
|
|
29
28
|
}
|
|
30
29
|
)
|
|
31
30
|
] }),
|
|
32
|
-
c === "ADD_PAY_SCHEDULE" && /* @__PURE__ */ e(
|
|
31
|
+
c === "ADD_PAY_SCHEDULE" && /* @__PURE__ */ e(a, { children: [
|
|
33
32
|
/* @__PURE__ */ o(
|
|
34
33
|
t.Button,
|
|
35
34
|
{
|
|
36
35
|
variant: "secondary",
|
|
37
36
|
onClick: () => {
|
|
38
|
-
|
|
37
|
+
i();
|
|
39
38
|
},
|
|
40
39
|
children: n("actions.cancel")
|
|
41
40
|
}
|
|
42
41
|
),
|
|
43
42
|
/* @__PURE__ */ o(t.Button, { type: "submit", children: n("actions.save") })
|
|
44
43
|
] }),
|
|
45
|
-
c === "EDIT_PAY_SCHEDULE" && /* @__PURE__ */ e(
|
|
44
|
+
c === "EDIT_PAY_SCHEDULE" && /* @__PURE__ */ e(a, { children: [
|
|
46
45
|
/* @__PURE__ */ o(
|
|
47
46
|
t.Button,
|
|
48
47
|
{
|
|
49
48
|
variant: "secondary",
|
|
50
49
|
onClick: () => {
|
|
51
|
-
|
|
50
|
+
i();
|
|
52
51
|
},
|
|
53
52
|
children: n("actions.cancel")
|
|
54
53
|
}
|
|
@@ -58,6 +57,6 @@ const E = () => {
|
|
|
58
57
|
] });
|
|
59
58
|
};
|
|
60
59
|
export {
|
|
61
|
-
|
|
60
|
+
S as Actions
|
|
62
61
|
};
|
|
63
62
|
//# sourceMappingURL=Actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const Actions = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const { mode, handleAdd, handleCancel, handleContinue } = usePaySchedule()\n const Components = useComponentContext()\n\n return (\n <>\n {mode === 'LIST_PAY_SCHEDULES' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleAdd()\n }}\n >\n {t('addAnotherPayScheduleCta')}\n </Components.Button>\n <Components.Button\n variant=\"primary\"\n onClick={() => {\n handleContinue()\n }}\n >\n {t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n {mode === 'ADD_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n {mode === 'EDIT_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n </>\n )\n}\n"],"names":["Actions","t","useTranslation","mode","handleAdd","handleCancel","handleContinue","usePaySchedule","Components","useComponentContext","jsxs","Fragment","ActionsLayout","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/PaySchedule/_parts/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { usePaySchedule } from '../usePaySchedule'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const Actions = () => {\n const { t } = useTranslation('Company.PaySchedule')\n const { mode, handleAdd, handleCancel, handleContinue } = usePaySchedule()\n const Components = useComponentContext()\n\n return (\n <>\n {mode === 'LIST_PAY_SCHEDULES' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleAdd()\n }}\n >\n {t('addAnotherPayScheduleCta')}\n </Components.Button>\n <Components.Button\n variant=\"primary\"\n onClick={() => {\n handleContinue()\n }}\n >\n {t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n {mode === 'ADD_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n {mode === 'EDIT_PAY_SCHEDULE' && (\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleCancel()\n }}\n >\n {t('actions.cancel')}\n </Components.Button>\n <Components.Button type=\"submit\">{t('actions.save')}</Components.Button>\n </ActionsLayout>\n )}\n </>\n )\n}\n"],"names":["Actions","t","useTranslation","mode","handleAdd","handleCancel","handleContinue","usePaySchedule","Components","useComponentContext","jsxs","Fragment","ActionsLayout","jsx"],"mappings":";;;;;AAKO,MAAMA,IAAU,MAAM;AAC3B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,q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A;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -11,9 +11,8 @@ import "../../Base/useBase.js";
|
|
|
11
11
|
import "../../../shared/constants.js";
|
|
12
12
|
import "dompurify";
|
|
13
13
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
14
|
import { createCompoundContext as e } from "../../Base/createCompoundContext.js";
|
|
16
|
-
const
|
|
15
|
+
const s = o.object({
|
|
17
16
|
frequency: o.enum(["Every week", "Every other week", "Twice per month", "Monthly"]),
|
|
18
17
|
anchorPayDate: o.date().optional(),
|
|
19
18
|
anchorEndOfPayPeriod: o.date().optional(),
|
|
@@ -22,10 +21,10 @@ const w = o.object({
|
|
|
22
21
|
customName: o.string().optional(),
|
|
23
22
|
customTwicePerMonth: o.string().optional(),
|
|
24
23
|
payPeriodPreviewRange: o.number().optional()
|
|
25
|
-
}), [
|
|
24
|
+
}), [w, x] = e("PayScheduleContext");
|
|
26
25
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
x as PayScheduleProvider,
|
|
27
|
+
s as PayScheduleSchema,
|
|
28
|
+
w as usePaySchedule
|
|
30
29
|
};
|
|
31
30
|
//# sourceMappingURL=usePaySchedule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/usePaySchedule.ts"],"sourcesContent":["import type { PayScheduleCreateUpdate } from '@gusto/embedded-api/models/components/payschedulecreateupdate'\nimport type { PayScheduleList } from '@gusto/embedded-api/models/components/payschedulelist'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { PayPeriods } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayschedulespreview'\nimport { z } from 'zod'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport { createCompoundContext } from '@/components/Base'\n\nexport type MODE =\n | 'LIST_PAY_SCHEDULES'\n | 'ADD_PAY_SCHEDULE'\n | 'EDIT_PAY_SCHEDULE'\n | 'PREVIEW_PAY_SCHEDULE'\n\ntype PayScheduleContextType = {\n companyId: string\n handleAdd: () => void\n handleEdit: (schedule: PayScheduleType) => void\n handleCancel: () => void\n handleContinue: () => void\n mode: MODE\n paySchedules: PayScheduleList[] | undefined | null\n currentPaySchedule: PayScheduleType | undefined | null\n payPeriodPreview?: PayPeriods[]\n payPreviewLoading?: boolean\n}\n\nexport const PayScheduleSchema = z.object({\n frequency: z.enum(['Every week', 'Every other week', 'Twice per month', 'Monthly']),\n anchorPayDate: z.date().optional(),\n anchorEndOfPayPeriod: z.date().optional(),\n day1: z.number().min(1).max(31).optional(),\n day2: z.number().min(1).max(31).optional(),\n customName: z.string().optional(),\n customTwicePerMonth: z.string().optional(),\n payPeriodPreviewRange: z.number().optional(),\n})\n\nexport type PayScheduleInputs = z.input<typeof PayScheduleSchema>\nexport type PayScheduleOutputs = z.output<typeof PayScheduleSchema>\n\nexport type PayScheduleDefaultValues = RequireAtLeastOne<\n Partial<\n Pick<\n PayScheduleCreateUpdate,\n 'anchorPayDate' | 'anchorEndOfPayPeriod' | 'day1' | 'day2' | 'customName' | 'frequency'\n >\n >\n>\n\nconst [usePaySchedule, PayScheduleProvider] =\n createCompoundContext<PayScheduleContextType>('PayScheduleContext')\nexport { usePaySchedule, PayScheduleProvider }\n"],"names":["PayScheduleSchema","z","usePaySchedule","PayScheduleProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/usePaySchedule.ts"],"sourcesContent":["import type { PayScheduleCreateUpdate } from '@gusto/embedded-api/models/components/payschedulecreateupdate'\nimport type { PayScheduleList } from '@gusto/embedded-api/models/components/payschedulelist'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { PayPeriods } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayschedulespreview'\nimport { z } from 'zod'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport { createCompoundContext } from '@/components/Base'\n\nexport type MODE =\n | 'LIST_PAY_SCHEDULES'\n | 'ADD_PAY_SCHEDULE'\n | 'EDIT_PAY_SCHEDULE'\n | 'PREVIEW_PAY_SCHEDULE'\n\ntype PayScheduleContextType = {\n companyId: string\n handleAdd: () => void\n handleEdit: (schedule: PayScheduleType) => void\n handleCancel: () => void\n handleContinue: () => void\n mode: MODE\n paySchedules: PayScheduleList[] | undefined | null\n currentPaySchedule: PayScheduleType | undefined | null\n payPeriodPreview?: PayPeriods[]\n payPreviewLoading?: boolean\n}\n\nexport const PayScheduleSchema = z.object({\n frequency: z.enum(['Every week', 'Every other week', 'Twice per month', 'Monthly']),\n anchorPayDate: z.date().optional(),\n anchorEndOfPayPeriod: z.date().optional(),\n day1: z.number().min(1).max(31).optional(),\n day2: z.number().min(1).max(31).optional(),\n customName: z.string().optional(),\n customTwicePerMonth: z.string().optional(),\n payPeriodPreviewRange: z.number().optional(),\n})\n\nexport type PayScheduleInputs = z.input<typeof PayScheduleSchema>\nexport type PayScheduleOutputs = z.output<typeof PayScheduleSchema>\n\nexport type PayScheduleDefaultValues = RequireAtLeastOne<\n Partial<\n Pick<\n PayScheduleCreateUpdate,\n 'anchorPayDate' | 'anchorEndOfPayPeriod' | 'day1' | 'day2' | 'customName' | 'frequency'\n >\n >\n>\n\nconst [usePaySchedule, PayScheduleProvider] =\n createCompoundContext<PayScheduleContextType>('PayScheduleContext')\nexport { usePaySchedule, PayScheduleProvider }\n"],"names":["PayScheduleSchema","z","usePaySchedule","PayScheduleProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;AA2Ba,MAAAA,IAAoBC,EAAE,OAAO;AAAA,EACxC,WAAWA,EAAE,KAAK,CAAC,cAAc,oBAAoB,mBAAmB,SAAS,CAAC;AAAA,EAClF,eAAeA,EAAE,KAAK,EAAE,SAAS;AAAA,EACjC,sBAAsBA,EAAE,KAAK,EAAE,SAAS;AAAA,EACxC,MAAMA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EACzC,MAAMA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EACzC,YAAYA,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,qBAAqBA,EAAE,OAAO,EAAE,SAAS;AAAA,EACzC,uBAAuBA,EAAE,OAAO,EAAE,SAAS;AAC7C,CAAC,GAcK,CAACC,GAAgBC,CAAmB,IACxCC,EAA8C,oBAAoB;"}
|
|
@@ -1,27 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { StateTaxesListContextual as
|
|
5
|
-
import { StateTaxesList as
|
|
6
|
-
import { StateTaxesForm as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { useReducer as T } from "react";
|
|
3
|
+
import { stateTaxesReducer as S, initialState as p } from "./stateTaxesReducer.js";
|
|
4
|
+
import { StateTaxesListContextual as f, StateTaxesFormContextual as u } from "./StateTaxesComponents.js";
|
|
5
|
+
import { StateTaxesList as A } from "./StateTaxesList/StateTaxesList.js";
|
|
6
|
+
import { StateTaxesForm as E } from "./StateTaxesForm/StateTaxesForm.js";
|
|
7
|
+
import { useComponentDictionary as C } from "../../../i18n/I18n.js";
|
|
8
|
+
import { componentEvents as e } from "../../../shared/constants.js";
|
|
9
|
+
function c({ companyId: n, onEvent: s, dictionary: x }) {
|
|
10
|
+
C("Company.StateTaxes", x);
|
|
11
|
+
const [r, a] = T(S, p), i = {
|
|
12
|
+
companyId: n,
|
|
13
|
+
stateData: r,
|
|
14
|
+
onEvent: (t, o) => {
|
|
15
|
+
switch (t) {
|
|
16
|
+
case e.COMPANY_STATE_TAX_EDIT:
|
|
17
|
+
a({ type: t, payload: o });
|
|
18
|
+
break;
|
|
19
|
+
case e.COMPANY_STATE_TAX_UPDATED:
|
|
20
|
+
a({ type: t });
|
|
21
|
+
break;
|
|
22
|
+
case e.COMPANY_STATE_TAX_DONE:
|
|
23
|
+
a({ type: t });
|
|
24
|
+
break;
|
|
25
|
+
case e.CANCEL:
|
|
26
|
+
a({ type: t });
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
s(t, o);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
s(t, o);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
switch (r.state) {
|
|
36
|
+
case "editStateTaxes":
|
|
37
|
+
return /* @__PURE__ */ m(u, { ...i });
|
|
38
|
+
case "viewStateTaxes":
|
|
39
|
+
default:
|
|
40
|
+
return /* @__PURE__ */ m(f, { ...i });
|
|
41
|
+
}
|
|
21
42
|
}
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
c.StateTaxesList = A;
|
|
44
|
+
c.StateTaxesForm = E;
|
|
24
45
|
export {
|
|
25
|
-
|
|
46
|
+
c as StateTaxes
|
|
26
47
|
};
|
|
27
48
|
//# sourceMappingURL=StateTaxes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTaxes.js","sources":["../../../../src/components/Company/StateTaxes/StateTaxes.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"StateTaxes.js","sources":["../../../../src/components/Company/StateTaxes/StateTaxes.tsx"],"sourcesContent":["import { useReducer } from 'react'\nimport { stateTaxesReducer, initialState } from './stateTaxesReducer'\nimport type { StateTaxesContextInterface } from './StateTaxesComponents'\nimport { StateTaxesListContextual, StateTaxesFormContextual } from './StateTaxesComponents'\nimport { StateTaxesList } from './StateTaxesList/StateTaxesList'\nimport { StateTaxesForm } from './StateTaxesForm/StateTaxesForm'\nimport type { BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { componentEvents } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { EventType } from '@/shared/constants'\n\nexport interface StateTaxesProps extends BaseComponentInterface<'Company.StateTaxes'> {\n companyId: string\n}\n\nexport function StateTaxes({ companyId, onEvent, dictionary }: StateTaxesProps) {\n useComponentDictionary('Company.StateTaxes', dictionary)\n\n const [stateData, dispatch] = useReducer(stateTaxesReducer, initialState)\n\n const handleEvent: OnEventType<EventType, unknown> = (eventType, data) => {\n // Handle the event and dispatch to reducer\n switch (eventType) {\n case componentEvents.COMPANY_STATE_TAX_EDIT:\n dispatch({ type: eventType, payload: data as { state: string } })\n break\n case componentEvents.COMPANY_STATE_TAX_UPDATED:\n dispatch({ type: eventType })\n break\n case componentEvents.COMPANY_STATE_TAX_DONE:\n dispatch({ type: eventType })\n break\n case componentEvents.CANCEL:\n dispatch({ type: eventType })\n break\n default:\n // Pass through other events to parent\n onEvent(eventType, data)\n break\n }\n\n onEvent(eventType, data)\n }\n\n const contextProps: StateTaxesContextInterface = {\n companyId,\n stateData,\n onEvent: handleEvent,\n }\n\n // Render the appropriate component based on state\n switch (stateData.state) {\n case 'editStateTaxes':\n return <StateTaxesFormContextual {...contextProps} />\n case 'viewStateTaxes':\n default:\n return <StateTaxesListContextual {...contextProps} />\n }\n}\n\nStateTaxes.StateTaxesList = StateTaxesList\nStateTaxes.StateTaxesForm = StateTaxesForm\n"],"names":["StateTaxes","companyId","onEvent","dictionary","useComponentDictionary","stateData","dispatch","useReducer","stateTaxesReducer","initialState","contextProps","eventType","data","componentEvents","jsx","StateTaxesFormContextual","StateTaxesListContextual","StateTaxesList","StateTaxesForm"],"mappings":";;;;;;;;AAgBO,SAASA,EAAW,EAAE,WAAAC,GAAW,SAAAC,GAAS,YAAAC,KAA+B;AAC9E,EAAAC,EAAuB,sBAAsBD,CAAU;AAEvD,QAAM,CAACE,GAAWC,CAAQ,IAAIC,EAAWC,GAAmBC,CAAY,GA0BlEC,IAA2C;AAAA,IAC/C,WAAAT;AAAA,IACA,WAAAI;AAAA,IACA,SA3BmD,CAACM,GAAWC,MAAS;AAExE,cAAQD,GAAW;AAAA,QACjB,KAAKE,EAAgB;AACnB,UAAAP,EAAS,EAAE,MAAMK,GAAW,SAASC,GAA2B;AAChE;AAAA,QACF,KAAKC,EAAgB;AACV,UAAAP,EAAA,EAAE,MAAMK,GAAW;AAC5B;AAAA,QACF,KAAKE,EAAgB;AACV,UAAAP,EAAA,EAAE,MAAMK,GAAW;AAC5B;AAAA,QACF,KAAKE,EAAgB;AACV,UAAAP,EAAA,EAAE,MAAMK,GAAW;AAC5B;AAAA,QACF;AAEE,UAAAT,EAAQS,GAAWC,CAAI;AACvB;AAAA,MAAA;AAGJ,MAAAV,EAAQS,GAAWC,CAAI;AAAA,IACzB;AAAA,EAMA;AAGA,UAAQP,EAAU,OAAO;AAAA,IACvB,KAAK;AACI,aAAA,gBAAAS,EAACC,GAA0B,EAAA,GAAGL,EAAc,CAAA;AAAA,IACrD,KAAK;AAAA,IACL;AACS,aAAA,gBAAAI,EAACE,GAA0B,EAAA,GAAGN,EAAc,CAAA;AAAA,EAAA;AAEzD;AAEAV,EAAW,iBAAiBiB;AAC5BjB,EAAW,iBAAiBkB;"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { StateTaxesStateData } from './stateTaxesReducer';
|
|
2
|
+
import { OnEventType } from '../../Base/useBase';
|
|
3
|
+
import { EventType } from '../../../shared/constants';
|
|
4
|
+
export interface StateTaxesContextInterface {
|
|
3
5
|
companyId: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
stateData: StateTaxesStateData;
|
|
7
|
+
onEvent: OnEventType<EventType, unknown>;
|
|
6
8
|
}
|
|
7
|
-
export declare function StateTaxesListContextual(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare function StateTaxesFormContextual(): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function StateTaxesListContextual({ companyId, onEvent }: StateTaxesContextInterface): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function StateTaxesFormContextual({ companyId, stateData, onEvent, }: StateTaxesContextInterface): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { StateTaxesList as m } from "./StateTaxesList/StateTaxesList.js";
|
|
3
|
-
import { StateTaxesForm as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { companyId: t, onEvent: o } = r();
|
|
8
|
-
return /* @__PURE__ */ n(m, { onEvent: o, companyId: e(t) });
|
|
3
|
+
import { StateTaxesForm as n } from "./StateTaxesForm/StateTaxesForm.js";
|
|
4
|
+
import { ensureRequired as o } from "../../../helpers/ensureRequired.js";
|
|
5
|
+
function p({ companyId: t, onEvent: e }) {
|
|
6
|
+
return /* @__PURE__ */ r(m, { onEvent: e, companyId: o(t) });
|
|
9
7
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
function f({
|
|
9
|
+
companyId: t,
|
|
10
|
+
stateData: e,
|
|
11
|
+
onEvent: a
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ r(
|
|
14
|
+
n,
|
|
14
15
|
{
|
|
15
|
-
companyId:
|
|
16
|
-
state: e
|
|
16
|
+
companyId: o(t),
|
|
17
|
+
state: o(e.selectedState),
|
|
17
18
|
onEvent: a
|
|
18
19
|
}
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
22
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
f as StateTaxesFormContextual,
|
|
24
|
+
p as StateTaxesListContextual
|
|
24
25
|
};
|
|
25
26
|
//# sourceMappingURL=StateTaxesComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTaxesComponents.js","sources":["../../../../src/components/Company/StateTaxes/StateTaxesComponents.tsx"],"sourcesContent":["import { StateTaxesList } from './StateTaxesList/StateTaxesList'\nimport { StateTaxesForm } from './StateTaxesForm/StateTaxesForm'\nimport {
|
|
1
|
+
{"version":3,"file":"StateTaxesComponents.js","sources":["../../../../src/components/Company/StateTaxes/StateTaxesComponents.tsx"],"sourcesContent":["import { StateTaxesList } from './StateTaxesList/StateTaxesList'\nimport { StateTaxesForm } from './StateTaxesForm/StateTaxesForm'\nimport type { StateTaxesStateData } from './stateTaxesReducer'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { EventType } from '@/shared/constants'\n\nexport interface StateTaxesContextInterface {\n companyId: string\n stateData: StateTaxesStateData\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function StateTaxesListContextual({ companyId, onEvent }: StateTaxesContextInterface) {\n return <StateTaxesList onEvent={onEvent} companyId={ensureRequired(companyId)} />\n}\n\nexport function StateTaxesFormContextual({\n companyId,\n stateData,\n onEvent,\n}: StateTaxesContextInterface) {\n return (\n <StateTaxesForm\n companyId={ensureRequired(companyId)}\n state={ensureRequired(stateData.selectedState)}\n onEvent={onEvent}\n />\n )\n}\n"],"names":["StateTaxesListContextual","companyId","onEvent","StateTaxesList","ensureRequired","StateTaxesFormContextual","stateData","jsx","StateTaxesForm"],"mappings":";;;;AAaO,SAASA,EAAyB,EAAE,WAAAC,GAAW,SAAAC,KAAuC;AAC3F,2BAAQC,GAAe,EAAA,SAAAD,GAAkB,WAAWE,EAAeH,CAAS,GAAG;AACjF;AAEO,SAASI,EAAyB;AAAA,EACvC,WAAAJ;AAAA,EACA,WAAAK;AAAA,EACA,SAAAJ;AACF,GAA+B;AAE3B,SAAA,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWJ,EAAeH,CAAS;AAAA,MACnC,OAAOG,EAAeE,EAAU,aAAa;AAAA,MAC7C,SAAAJ;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as a } from "react-i18next";
|
|
3
3
|
import { useStateTaxesForm as s } from "./context.js";
|
|
4
|
-
import "../../../../shared/constants.js";
|
|
5
4
|
import { ActionsLayout as m } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
5
|
import { useComponentContext as c } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
|
-
function
|
|
8
|
-
const { t } = a("Company.StateTaxes", { keyPrefix: "form" }), { handleCancel:
|
|
6
|
+
function d() {
|
|
7
|
+
const { t } = a("Company.StateTaxes", { keyPrefix: "form" }), { handleCancel: e, isPending: r } = s(), o = c();
|
|
9
8
|
return /* @__PURE__ */ i(m, { children: [
|
|
10
|
-
/* @__PURE__ */ n(o.Button, { variant: "secondary", onClick:
|
|
11
|
-
/* @__PURE__ */ n(o.Button, { variant: "primary", type: "submit", isDisabled:
|
|
9
|
+
/* @__PURE__ */ n(o.Button, { variant: "secondary", onClick: e, children: t("cancelCta") }),
|
|
10
|
+
/* @__PURE__ */ n(o.Button, { variant: "primary", type: "submit", isDisabled: r, children: t("saveCta") })
|
|
12
11
|
] });
|
|
13
12
|
}
|
|
14
13
|
export {
|
|
15
|
-
|
|
14
|
+
d as Actions
|
|
16
15
|
};
|
|
17
16
|
//# sourceMappingURL=Actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useStateTaxesForm } from './context'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport function Actions() {\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { handleCancel, isPending } = useStateTaxesForm()\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button variant=\"primary\" type=\"submit\" isDisabled={isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["Actions","useTranslation","handleCancel","isPending","useStateTaxesForm","Components","useComponentContext","ActionsLayout","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useStateTaxesForm } from './context'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport function Actions() {\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { handleCancel, isPending } = useStateTaxesForm()\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleCancel}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button variant=\"primary\" type=\"submit\" isDisabled={isPending}>\n {t('saveCta')}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["Actions","useTranslation","handleCancel","isPending","useStateTaxesForm","Components","useComponentContext","ActionsLayout","jsx"],"mappings":";;;;;AAKO,SAASA,IAAU;AAClB,QAAA,EAAE,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,cAAAC,GAAc,WAAAC,EAAU,IAAIC,EAAkB,GAChDC,IAAaC,EAAoB;AAEvC,2BACGC,GACC,EAAA,UAAA;AAAA,IAAC,gBAAAC,EAAAH,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAASH,GAC7C,UAAE,EAAA,WAAW,EAChB,CAAA;AAAA,IACC,gBAAAM,EAAAH,EAAW,QAAX,EAAkB,SAAQ,WAAU,MAAK,UAAS,YAAYF,GAC5D,UAAE,EAAA,SAAS,EACd,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -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,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AAA,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;"}
|
|
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;AA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MAAA,EAAA,CACX,EAEJ,CAAA;AAAA,IAAA;AAAA,EAAA,EAEJ,CAAA,EACF,CAAA,GACF;AAEJ;AAEA9D,EAAe,OAAO4D;AACtB5D,EAAe,OAAO6D;AACtB7D,EAAe,UAAU8D;"}
|
|
@@ -10,11 +10,10 @@ import "../../../Base/useBase.js";
|
|
|
10
10
|
import "../../../../shared/constants.js";
|
|
11
11
|
import "dompurify";
|
|
12
12
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
-
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
13
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
|
-
const [
|
|
14
|
+
const [T, c] = t("StateTaxesFormContext");
|
|
16
15
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
c as StateTaxesFormProvider,
|
|
17
|
+
T as useStateTaxesForm
|
|
19
18
|
};
|
|
20
19
|
//# sourceMappingURL=context.js.map
|