@gusto/embedded-react-sdk 0.11.2 → 0.11.3-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 +4 -0
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +1 -1
- package/dist/components/Common/DocumentList/DocumentList.module.scss.js +1 -1
- package/dist/components/Common/DocumentViewer/DocumentViewer.module.scss.js +1 -1
- package/dist/components/Common/EmptyData/EmptyData.module.scss.js +1 -1
- package/dist/components/Common/FieldErrorMessage/FieldErrorMessage.module.scss.js +1 -1
- package/dist/components/Common/FieldLayout/FieldLayout.module.scss.js +6 -6
- package/dist/components/Common/Flex/Flex.d.ts +2 -2
- package/dist/components/Common/Flex/Flex.js +5 -5
- package/dist/components/Common/Flex/Flex.js.map +1 -1
- package/dist/components/Common/Form/Form.module.scss.js +2 -2
- package/dist/components/Common/Grid/Grid.d.ts +2 -2
- package/dist/components/Common/Grid/Grid.js +13 -13
- package/dist/components/Common/Grid/Grid.js.map +1 -1
- package/dist/components/Common/HorizontalFieldLayout/HorizontalFieldLayout.module.scss.js +12 -12
- package/dist/components/Common/InternalError/InternalError.module.scss.js +1 -1
- package/dist/components/Common/Loading/Loading.module.scss.js +1 -1
- package/dist/components/Common/PaginationControl/PaginationControl.module.scss.js +1 -1
- package/dist/components/Common/ReorderableList/ReorderableList.module.scss.js +15 -15
- package/dist/components/Common/RequirementsList/RequirementsList.module.scss.js +1 -1
- package/dist/components/Common/SignatureForm/SignatureForm.module.scss.js +6 -6
- package/dist/components/Common/UI/Alert/Alert.module.scss.js +1 -1
- package/dist/components/Common/UI/Badge/Badge.module.scss.js +1 -1
- package/dist/components/Common/UI/Button/Button.module.scss.js +1 -1
- package/dist/components/Common/UI/Button/ButtonIcon.module.scss.js +1 -1
- package/dist/components/Common/UI/CalendarPreview/CalendarPreview.module.scss.js +5 -5
- package/dist/components/Common/UI/Card/Card.module.scss.js +1 -1
- package/dist/components/Common/UI/Checkbox/Checkbox.module.scss.js +8 -8
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroup.module.scss.js +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBox.module.scss.js +1 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.module.scss.js +5 -5
- package/dist/components/Common/UI/Input/Input.module.scss.js +7 -7
- package/dist/components/Common/UI/Link/Link.module.scss.js +1 -1
- package/dist/components/Common/UI/List/List.module.scss.js +1 -1
- package/dist/components/Common/UI/Menu/Menu.module.scss.js +5 -5
- package/dist/components/Common/UI/NumberInput/NumberInput.js +36 -38
- package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/Common/UI/ProgressBar/ProgressBar.module.scss.js +1 -1
- package/dist/components/Common/UI/Radio/Radio.module.scss.js +1 -1
- package/dist/components/Common/UI/RadioGroup/RadioGroup.module.scss.js +1 -1
- package/dist/components/Common/UI/Select/Select.module.scss.js +1 -1
- package/dist/components/Common/UI/Switch/Switch.module.scss.js +4 -4
- package/dist/components/Common/UI/Table/Table.module.scss.js +1 -1
- package/dist/components/Common/UI/Text/Text.module.scss.js +14 -14
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +6 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +4 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +6 -5
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +7 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +4 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +4 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +4 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.module.scss.js +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +6 -5
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +8 -8
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +6 -5
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/Profile/useContractorProfile.js +3 -2
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Submit/index.module.scss.js +2 -2
- package/dist/components/Employee/Deductions/Deductions.d.ts +8 -14
- package/dist/components/Employee/Deductions/Deductions.js +47 -140
- package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsComponents.d.ts +23 -0
- package/dist/components/Employee/Deductions/DeductionsComponents.js +31 -0
- package/dist/components/Employee/Deductions/DeductionsComponents.js.map +1 -0
- package/dist/components/Employee/Deductions/DeductionsForm/DeductionsForm.d.ts +41 -0
- package/dist/components/Employee/Deductions/DeductionsForm/DeductionsForm.js +135 -0
- package/dist/components/Employee/Deductions/DeductionsForm/DeductionsForm.js.map +1 -0
- package/dist/components/Employee/Deductions/DeductionsList/DeductionsList.d.ts +6 -0
- package/dist/components/Employee/Deductions/DeductionsList/DeductionsList.js +99 -0
- package/dist/components/Employee/Deductions/DeductionsList/DeductionsList.js.map +1 -0
- package/dist/components/Employee/Deductions/IncludeDeductionsForm/IncludeDeductionsForm.d.ts +15 -0
- package/dist/components/Employee/Deductions/IncludeDeductionsForm/IncludeDeductionsForm.js +49 -0
- package/dist/components/Employee/Deductions/IncludeDeductionsForm/IncludeDeductionsForm.js.map +1 -0
- package/dist/components/Employee/Deductions/stateMachine.d.ts +7 -0
- package/dist/components/Employee/Deductions/stateMachine.js +107 -0
- package/dist/components/Employee/Deductions/stateMachine.js.map +1 -0
- package/dist/components/Employee/Deductions/useDeductions.d.ts +2 -2
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +4 -3
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.module.scss.js +6 -6
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +6 -5
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +4 -3
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +4 -3
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +3 -3
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ThemeProvider/ThemeProvider.d.ts +1 -5
- package/dist/contexts/ThemeProvider/ThemeProvider.js +18 -60
- package/dist/contexts/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/contexts/ThemeProvider/theme.d.ts +42 -11
- package/dist/contexts/ThemeProvider/theme.js +31 -15
- package/dist/contexts/ThemeProvider/theme.js.map +1 -1
- package/dist/helpers/responsive.d.ts +0 -3
- package/dist/helpers/responsive.js +20 -34
- package/dist/helpers/responsive.js.map +1 -1
- package/dist/i18n/en/Employee.Deductions.json.js +49 -51
- package/dist/i18n/en/Employee.Deductions.json.js.map +1 -1
- package/dist/shared/constants.d.ts +8 -0
- package/dist/shared/constants.js +9 -5
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +0 -1
- package/package.json +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInput.module.scss.js +0 -8
- package/dist/components/Common/UI/NumberInput/NumberInput.module.scss.js.map +0 -1
- package/dist/components/Employee/Deductions/Actions.js +0 -27
- package/dist/components/Employee/Deductions/Actions.js.map +0 -1
- package/dist/components/Employee/Deductions/DeductionForm.d.ts +0 -1
- package/dist/components/Employee/Deductions/DeductionForm.js +0 -78
- package/dist/components/Employee/Deductions/DeductionForm.js.map +0 -1
- package/dist/components/Employee/Deductions/DeductionsList.d.ts +0 -2
- package/dist/components/Employee/Deductions/DeductionsList.js +0 -60
- package/dist/components/Employee/Deductions/DeductionsList.js.map +0 -1
- package/dist/components/Employee/Deductions/Head.js +0 -13
- package/dist/components/Employee/Deductions/Head.js.map +0 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.d.ts +0 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +0 -27
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js.map +0 -1
- package/dist/components/Employee/Deductions/useDeductions.js +0 -33
- package/dist/components/Employee/Deductions/useDeductions.js.map +0 -1
- package/dist/contexts/ThemeProvider/createTheme.d.ts +0 -21
- package/dist/contexts/ThemeProvider/createTheme.js +0 -269
- package/dist/contexts/ThemeProvider/createTheme.js.map +0 -1
- package/dist/types/GTheme.d.ts +0 -254
- /package/dist/contexts/ThemeProvider/{createTheme.test.d.ts → theme.test.d.ts} +0 -0
|
@@ -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})\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})\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":";;;;;;;;;;;;;;;;AA2BO,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACxC,WAAWA,EAAE,KAAK,CAAC,cAAc,oBAAoB,mBAAmB,SAAS,CAAC;AAAA,EAClF,eAAeA,EAAE,KAAA,EAAO,SAAA;AAAA,EACxB,sBAAsBA,EAAE,KAAA,EAAO,SAAA;AAAA,EAC/B,MAAMA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAA;AAAA,EAChC,MAAMA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAA;AAAA,EAChC,YAAYA,EAAE,OAAA,EAAS,SAAA;AAAA,EACvB,qBAAqBA,EAAE,OAAA,EAAS,SAAA;AAClC,CAAC,GAcK,CAACC,GAAgBC,CAAmB,IACxCC,EAA8C,oBAAoB;"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, Fragment as f, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { z as t } from "zod";
|
|
3
3
|
import { useTranslation as u } from "react-i18next";
|
|
4
4
|
import { useStateTaxesForm as x } from "./context.js";
|
|
5
5
|
import { QuestionInput as l } from "../../../Common/TaxInputs/TaxInputs.js";
|
|
6
6
|
import { useLocaleDateFormatter as T } from "../../../../contexts/LocaleProvider/useLocale.js";
|
|
7
|
-
import { useComponentContext as
|
|
7
|
+
import { useComponentContext as y } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
8
8
|
t.record(t.string(), t.record(t.string(), t.unknown()));
|
|
9
9
|
function w() {
|
|
10
|
-
const { t: s } = u("Company.StateTaxes", { keyPrefix: "form" }), i = T(), { stateTaxRequirements: p } = x(), r =
|
|
10
|
+
const { t: s } = u("Company.StateTaxes", { keyPrefix: "form" }), i = T(), { stateTaxRequirements: p } = x(), r = y();
|
|
11
11
|
return p.requirementSets?.map(
|
|
12
|
-
({ requirements: c, label: d, effectiveFrom: n, key:
|
|
13
|
-
/* @__PURE__ */
|
|
12
|
+
({ requirements: c, label: d, effectiveFrom: n, key: m }) => /* @__PURE__ */ a(f, { children: [
|
|
13
|
+
/* @__PURE__ */ a("div", { children: [
|
|
14
14
|
/* @__PURE__ */ o(r.Heading, { as: "h3", children: d }),
|
|
15
|
-
n && /* @__PURE__ */ o(r.Text, {
|
|
15
|
+
n && /* @__PURE__ */ o(r.Text, { size: "sm", children: s("effectiveFromLabel", { date: i.format(new Date(n)) }) })
|
|
16
16
|
] }),
|
|
17
17
|
c?.map((e) => /* @__PURE__ */ o(
|
|
18
18
|
l,
|
|
19
19
|
{
|
|
20
20
|
requirement: {
|
|
21
21
|
...e,
|
|
22
|
-
key: `${
|
|
22
|
+
key: `${m}.${e.key}`
|
|
23
23
|
},
|
|
24
24
|
questionType: e.metadata?.type ?? "Text"
|
|
25
25
|
},
|
|
26
26
|
e.key
|
|
27
27
|
))
|
|
28
|
-
] },
|
|
28
|
+
] }, m)
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/Form.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { useTranslation } from 'react-i18next'\nimport { Fragment } from 'react/jsx-runtime'\nimport { useStateTaxesForm } from './context'\nimport { QuestionInput } from '@/components/Common/TaxInputs/TaxInputs'\nimport { useLocaleDateFormatter } from '@/contexts/LocaleProvider/useLocale'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const StateFormSchema = z.record(z.string(), z.record(z.string(), z.unknown()))\n\nexport type StateFormInputs = z.infer<typeof StateFormSchema>\n\nexport function Form() {\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const dateFormatter = useLocaleDateFormatter()\n const { stateTaxRequirements } = useStateTaxesForm()\n const Components = useComponentContext()\n\n return stateTaxRequirements.requirementSets?.map(\n ({ requirements, label, effectiveFrom, key }) => (\n <Fragment key={key}>\n <div>\n <Components.Heading as=\"h3\">{label}</Components.Heading>\n {effectiveFrom && (\n <Components.Text
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/Form.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { useTranslation } from 'react-i18next'\nimport { Fragment } from 'react/jsx-runtime'\nimport { useStateTaxesForm } from './context'\nimport { QuestionInput } from '@/components/Common/TaxInputs/TaxInputs'\nimport { useLocaleDateFormatter } from '@/contexts/LocaleProvider/useLocale'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const StateFormSchema = z.record(z.string(), z.record(z.string(), z.unknown()))\n\nexport type StateFormInputs = z.infer<typeof StateFormSchema>\n\nexport function Form() {\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const dateFormatter = useLocaleDateFormatter()\n const { stateTaxRequirements } = useStateTaxesForm()\n const Components = useComponentContext()\n\n return stateTaxRequirements.requirementSets?.map(\n ({ requirements, label, effectiveFrom, key }) => (\n <Fragment key={key}>\n <div>\n <Components.Heading as=\"h3\">{label}</Components.Heading>\n {effectiveFrom && (\n <Components.Text size=\"sm\">\n {t('effectiveFromLabel', { date: dateFormatter.format(new Date(effectiveFrom)) })}\n </Components.Text>\n )}\n </div>\n {requirements?.map(requirement => {\n return (\n <QuestionInput\n requirement={{\n ...requirement,\n key: `${key}.${requirement.key as string}`,\n }}\n questionType={requirement.metadata?.type ?? 'Text'}\n key={requirement.key}\n />\n )\n })}\n </Fragment>\n ),\n )\n}\n"],"names":["z","Form","t","useTranslation","dateFormatter","useLocaleDateFormatter","stateTaxRequirements","useStateTaxesForm","Components","useComponentContext","requirements","label","effectiveFrom","key","Fragment","jsxs","jsx","requirement","QuestionInput"],"mappings":";;;;;;;AAQ+BA,EAAE,OAAOA,EAAE,UAAUA,EAAE,OAAOA,EAAE,OAAA,GAAUA,EAAE,QAAA,CAAS,CAAC;AAI9E,SAASC,IAAO;AACrB,QAAM,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClEC,IAAgBC,EAAA,GAChB,EAAE,sBAAAC,EAAA,IAAyBC,EAAA,GAC3BC,IAAaC,EAAA;AAEnB,SAAOH,EAAqB,iBAAiB;AAAA,IAC3C,CAAC,EAAE,cAAAI,GAAc,OAAAC,GAAO,eAAAC,GAAe,KAAAC,EAAA,wBACpCC,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAC,EAAC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAAC,EAACR,EAAW,SAAX,EAAmB,IAAG,MAAM,UAAAG,GAAM;AAAA,QAClCC,KACC,gBAAAI,EAACR,EAAW,MAAX,EAAgB,MAAK,MACnB,UAAAN,EAAE,sBAAsB,EAAE,MAAME,EAAc,OAAO,IAAI,KAAKQ,CAAa,CAAC,EAAA,CAAG,EAAA,CAClF;AAAA,MAAA,GAEJ;AAAA,MACCF,GAAc,IAAI,CAAAO,MAEf,gBAAAD;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,aAAa;AAAA,YACX,GAAGD;AAAA,YACH,KAAK,GAAGJ,CAAG,IAAII,EAAY,GAAa;AAAA,UAAA;AAAA,UAE1C,cAAcA,EAAY,UAAU,QAAQ;AAAA,QAAA;AAAA,QACvCA,EAAY;AAAA,MAAA,CAGtB;AAAA,IAAA,EAAA,GApBYJ,CAqBf;AAAA,EAAA;AAGN;"}
|
|
@@ -11,10 +11,11 @@ import "../../../../shared/constants.js";
|
|
|
11
11
|
import "classnames";
|
|
12
12
|
import "dompurify";
|
|
13
13
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
|
+
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
15
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
|
-
const [
|
|
16
|
+
const [d, u] = t("StateTaxesFormContext");
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
u as StateTaxesFormProvider,
|
|
19
|
+
d as useStateTaxesForm
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/context.ts"],"sourcesContent":["import type { TaxRequirementsState } from '@gusto/embedded-api/models/components/taxrequirementsstate'\nimport { createCompoundContext } from '@/components/Base'\n\ninterface StateTaxFormContext {\n isPending: boolean\n state: string\n stateTaxRequirements: TaxRequirementsState\n handleCancel: () => void\n}\n\nconst [useStateTaxesForm, StateTaxesFormProvider] =\n createCompoundContext<StateTaxFormContext>('StateTaxesFormContext')\n\nexport { useStateTaxesForm, StateTaxesFormProvider }\n"],"names":["useStateTaxesForm","StateTaxesFormProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/context.ts"],"sourcesContent":["import type { TaxRequirementsState } from '@gusto/embedded-api/models/components/taxrequirementsstate'\nimport { createCompoundContext } from '@/components/Base'\n\ninterface StateTaxFormContext {\n isPending: boolean\n state: string\n stateTaxRequirements: TaxRequirementsState\n handleCancel: () => void\n}\n\nconst [useStateTaxesForm, StateTaxesFormProvider] =\n createCompoundContext<StateTaxFormContext>('StateTaxesFormContext')\n\nexport { useStateTaxesForm, StateTaxesFormProvider }\n"],"names":["useStateTaxesForm","StateTaxesFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAA2C,uBAAuB;"}
|
|
@@ -11,10 +11,11 @@ import "../../../../shared/constants.js";
|
|
|
11
11
|
import "classnames";
|
|
12
12
|
import "dompurify";
|
|
13
13
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
|
+
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
14
15
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
15
|
-
const [
|
|
16
|
+
const [d, u] = t("StateTaxesListContext");
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
u as StateTaxesListProvider,
|
|
19
|
+
d as useStateTaxesList
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/context.ts"],"sourcesContent":["import type { ResponseBody } from '@gusto/embedded-api/models/operations/getv1companiescompanyuuidtaxrequirements'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesListContextType = {\n isPending: boolean\n stateTaxRequirements: ResponseBody[]\n handleContinue: () => void\n handleChange: (state: string) => void\n}\n\nconst [useStateTaxesList, StateTaxesListProvider] =\n createCompoundContext<StateTaxesListContextType>('StateTaxesListContext')\n\nexport { useStateTaxesList, StateTaxesListProvider }\n"],"names":["useStateTaxesList","StateTaxesListProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/context.ts"],"sourcesContent":["import type { ResponseBody } from '@gusto/embedded-api/models/operations/getv1companiescompanyuuidtaxrequirements'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesListContextType = {\n isPending: boolean\n stateTaxRequirements: ResponseBody[]\n handleContinue: () => void\n handleChange: (state: string) => void\n}\n\nconst [useStateTaxesList, StateTaxesListProvider] =\n createCompoundContext<StateTaxesListContextType>('StateTaxesListContext')\n\nexport { useStateTaxesList, StateTaxesListProvider }\n"],"names":["useStateTaxesList","StateTaxesListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAAiD,uBAAuB;"}
|
|
@@ -12,19 +12,20 @@ import "../../../shared/constants.js";
|
|
|
12
12
|
import "classnames";
|
|
13
13
|
import "dompurify";
|
|
14
14
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
15
|
+
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
16
|
import { createCompoundContext as r } from "../../Base/createCompoundContext.js";
|
|
16
|
-
const
|
|
17
|
+
const z = t.object({
|
|
17
18
|
street1: t.string().min(1),
|
|
18
19
|
street2: t.string().optional(),
|
|
19
20
|
city: t.string().min(1),
|
|
20
21
|
state: t.string().min(1),
|
|
21
22
|
zip: t.string().min(1)
|
|
22
|
-
}), [
|
|
23
|
+
}), [b, h] = r(
|
|
23
24
|
"ContractorAddressContext"
|
|
24
25
|
);
|
|
25
26
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
z as AddressFormSchema,
|
|
28
|
+
h as AddressProvider,
|
|
29
|
+
b as useAddress
|
|
29
30
|
};
|
|
30
31
|
//# sourceMappingURL=useAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;AAiBO,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACxC,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,SAASA,EAAE,OAAA,EAAS,SAAA;AAAA,EACpB,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,OAAOA,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,KAAKA,EAAE,OAAA,EAAS,IAAI,CAAC;AACvB,CAAC,GAIK,CAACC,GAAYC,CAAe,IAAIC;AAAA,EACpC;AACF;"}
|
|
@@ -18,6 +18,7 @@ import { componentEvents as p } from "../../../shared/constants.js";
|
|
|
18
18
|
import "classnames";
|
|
19
19
|
import { removeNonDigits as J } from "../../../helpers/formattedStrings.js";
|
|
20
20
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
21
|
+
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
21
22
|
import { useI18n as K } from "../../../i18n/I18n.js";
|
|
22
23
|
import { SSN_REGEX as Y, NAME_REGEX as C } from "../../../helpers/validations.js";
|
|
23
24
|
import { formatDateToStringDate as ee } from "../../../helpers/dateFormatting.js";
|
|
@@ -95,7 +96,7 @@ const r = X, a = j, te = o.object({
|
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
);
|
|
98
|
-
function
|
|
99
|
+
function Fe({
|
|
99
100
|
companyId: n,
|
|
100
101
|
contractorId: t,
|
|
101
102
|
defaultValues: i
|
|
@@ -218,6 +219,6 @@ export {
|
|
|
218
219
|
a as ContractorType,
|
|
219
220
|
r as WageType,
|
|
220
221
|
se as createContractorProfileValidationSchema,
|
|
221
|
-
|
|
222
|
+
Fe as useContractorProfile
|
|
222
223
|
};
|
|
223
224
|
//# sourceMappingURL=useContractorProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport { useContractorsGet } from '@gusto/embedded-api/react-query/contractorsGet'\nimport type { PostV1CompaniesCompanyUuidContractorsRequestBody } from '@gusto/embedded-api/models/operations/postv1companiescompanyuuidcontractors'\nimport type { PutV1ContractorsContractorUuidRequestBody } from '@gusto/embedded-api/models/operations/putv1contractorscontractoruuid'\nimport {\n WageType as ApiWageType,\n ContractorType as ApiContractorType,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n inviteContractor: z.boolean().default(false),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (t: (key: string) => string) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.inviteContractor && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(t as (key: string) => string)\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Fetch existing contractor data if editing\n const existingContractorQuery = useContractorsGet(\n { contractorUuid: contractorId || '' },\n { enabled: !!contractorId },\n )\n\n const existingContractor = existingContractorQuery.data?.contractor\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n inviteContractor: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n ein: existingContractor.ein || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedInviteContractor = useWatch({\n control: formMethods.control,\n name: 'inviteContractor',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): PostV1CompaniesCompanyUuidContractorsRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.inviteContractor,\n email: data.inviteContractor ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n businessName: data.businessName,\n ein: data.ein,\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): PutV1ContractorsContractorUuidRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n if (contractorId && existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new Error('Contractor version is required for updates')\n }\n const version = String(existingContractor.version)\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId,\n requestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n requestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_SUBMITTED, payload)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n // Conditional rendering helpers\n const shouldShowEmailField = watchedInviteContractor\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n handleCancel,\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","t","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","useI18n","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","existingContractor","useContractorsGet","formDefaultValues","useMemo","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedInviteContractor","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","apiPayload","updateResponse","componentEvents","createResponse","handleCancel","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAA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,IAAA;AAAA,IAEF,cAAAP;AAAA;AAAA,IAGA,sBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAAC7C;AAAA,EAAA;AAEjB;"}
|
|
1
|
+
{"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport { useContractorsGet } from '@gusto/embedded-api/react-query/contractorsGet'\nimport type { PostV1CompaniesCompanyUuidContractorsRequestBody } from '@gusto/embedded-api/models/operations/postv1companiescompanyuuidcontractors'\nimport type { PutV1ContractorsContractorUuidRequestBody } from '@gusto/embedded-api/models/operations/putv1contractorscontractoruuid'\nimport {\n WageType as ApiWageType,\n ContractorType as ApiContractorType,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n inviteContractor: z.boolean().default(false),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (t: (key: string) => string) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.inviteContractor && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(t as (key: string) => string)\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Fetch existing contractor data if editing\n const existingContractorQuery = useContractorsGet(\n { contractorUuid: contractorId || '' },\n { enabled: !!contractorId },\n )\n\n const existingContractor = existingContractorQuery.data?.contractor\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n inviteContractor: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n ein: existingContractor.ein || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedInviteContractor = useWatch({\n control: formMethods.control,\n name: 'inviteContractor',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): PostV1CompaniesCompanyUuidContractorsRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.inviteContractor,\n email: data.inviteContractor ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n businessName: data.businessName,\n ein: data.ein,\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): PutV1ContractorsContractorUuidRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n if (contractorId && existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new Error('Contractor version is required for updates')\n }\n const version = String(existingContractor.version)\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId,\n requestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n requestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_SUBMITTED, payload)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n // Conditional rendering helpers\n const shouldShowEmailField = watchedInviteContractor\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n handleCancel,\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","t","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","useI18n","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","existingContractor","useContractorsGet","formDefaultValues","useMemo","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedInviteContractor","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","apiPayload","updateResponse","componentEvents","createResponse","handleCancel","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,kBAAkBA,EAAE,UAAU,QAAQ,EAAK;AAAA,EAC3C,OAAOA,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA;AAAA;AAAA,EAG1B,gBAAgBA,EAAE,KAAK,CAACH,EAAe,YAAYA,EAAe,QAAQ,CAAC;AAAA,EAC3E,UAAUG,EAAE,KAAK,CAACL,EAAS,QAAQA,EAAS,KAAK,CAAC;AAAA,EAClD,WAAWK,EAAE,KAAA;AAAA;AAAA,EAGb,WAAWA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,MAAMC,CAAU,EAAE,SAAA;AAAA,EAC/C,eAAeD,EAAE,OAAA,EAAS,SAAA;AAAA,EAC1B,UAAUA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,MAAMC,CAAU,EAAE,SAAA;AAAA,EAC9C,KAAKD,EAAE,OAAA,EAAS,SAAA;AAAA;AAAA,EAGhB,cAAcA,EAAE,OAAA,EAAS,SAAA;AAAA,EACzB,KAAKA,EAAE,OAAA,EAAS,SAAA;AAAA;AAAA,EAGhB,YAAYA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,SAAA;AAChC,CAAC,GAKYE,KAA0C,CAACC,MAC/CJ,GAAwB;AAAA,EAC7B,CAACK,GAAiCC,MAAyB;AAWzD,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,cAAc,OAAO5D,EAAe,WAAA;AAAA,IAC7C,EAAE,OAAO,YAAY,OAAOA,EAAe,SAAA;AAAA,EAAS,GAGhD6D,IAAkB;AAAA,IACtB,EAAE,OAAO,UAAU,OAAO/D,EAAS,OAAA;AAAA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCgE,IAAerC,KAAcG;AAGnC,SAAO;AAAA;AAAA,IAEL,aAAAO;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAAuB;AAAA,IAAA;AAAA,IAEF,cAAAP;AAAA;AAAA,IAGA,sBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAAC7C;AAAA,EAAA;AAEjB;"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
interface DeductionsProps extends CommonComponentInterface<'Employee.Deductions'> {
|
|
1
|
+
import { BaseComponentInterface } from '../../Base';
|
|
2
|
+
export interface DeductionsProps extends BaseComponentInterface<'Employee.Deductions'> {
|
|
4
3
|
employeeId: string;
|
|
5
4
|
}
|
|
6
|
-
declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}>;
|
|
13
|
-
export type IncludeDeductionsPayload = z.output<typeof IncludeDeductionsSchema>;
|
|
14
|
-
export declare function Deductions(props: DeductionsProps & BaseComponentInterface): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const Root: ({ employeeId, className, dictionary }: DeductionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function Deductions(props: DeductionsProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare namespace Deductions {
|
|
7
|
+
var DeductionsForm: typeof import("./DeductionsForm/DeductionsForm").DeductionsForm;
|
|
8
|
+
var DeductionsList: typeof import("./DeductionsList/DeductionsList").DeductionsList;
|
|
9
|
+
var IncludeDeductionsForm: typeof import("./IncludeDeductionsForm/IncludeDeductionsForm").IncludeDeductionsForm;
|
|
10
|
+
}
|
|
16
11
|
export declare const DeductionsContextual: () => import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
|
@@ -1,152 +1,59 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import { useComponentDictionary as
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
k("Employee.Deductions", a);
|
|
29
|
-
const { data: _ } = B({ employeeId: o }), f = _.garnishmentList, { mutateAsync: p, isPending: b } = j(), { mutateAsync: x, isPending: w } = R(), g = f.filter((r) => r.active), [u, m] = M(g.length < 1 ? "INITIAL" : "LIST"), [e, l] = M(null);
|
|
30
|
-
J("Employee.Deductions");
|
|
31
|
-
const D = Y(() => ({
|
|
32
|
-
amount: e?.amount ? Number(e.amount) : 0,
|
|
33
|
-
description: e?.description ?? "",
|
|
34
|
-
times: e?.times ?? null,
|
|
35
|
-
recurring: e?.recurring?.toString() ?? "true",
|
|
36
|
-
annualMaximum: e?.annualMaximum ? Number(e.annualMaximum) : null,
|
|
37
|
-
payPeriodMaximum: e?.payPeriodMaximum ? Number(e.payPeriodMaximum) : null,
|
|
38
|
-
deductAsPercentage: e?.deductAsPercentage?.toString() ?? "true",
|
|
39
|
-
active: !0,
|
|
40
|
-
courtOrdered: e?.courtOrdered ?? !1
|
|
41
|
-
}), [e]), I = O({
|
|
42
|
-
// resolver: zodResolver(IncludeDeductionsSchema),
|
|
43
|
-
defaultValues: { includeDeductions: "No" }
|
|
44
|
-
}), E = O({
|
|
45
|
-
resolver: y(G),
|
|
46
|
-
defaultValues: D
|
|
47
|
-
}), { reset: P } = E;
|
|
48
|
-
q(() => {
|
|
49
|
-
P(D);
|
|
50
|
-
}, [e, D, P, u]);
|
|
51
|
-
const F = async (r) => {
|
|
52
|
-
await h(r, async (n) => {
|
|
53
|
-
const { garnishment: c } = await p({
|
|
54
|
-
request: {
|
|
55
|
-
garnishmentId: n.uuid,
|
|
56
|
-
requestBody: {
|
|
57
|
-
...n,
|
|
58
|
-
totalAmount: n.totalAmount ?? void 0,
|
|
59
|
-
active: !1,
|
|
60
|
-
version: n.version
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
i(s.EMPLOYEE_DEDUCTION_DELETED, c);
|
|
65
|
-
});
|
|
66
|
-
}, v = async (r) => {
|
|
67
|
-
await h(r, async (n) => {
|
|
68
|
-
if ("includeDeductions" in n)
|
|
69
|
-
if (n.includeDeductions === "Yes")
|
|
70
|
-
m("ADD"), i(s.EMPLOYEE_DEDUCTION_ADD);
|
|
71
|
-
else {
|
|
72
|
-
i(s.EMPLOYEE_DEDUCTION_DONE);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (!("includeDeductions" in n)) {
|
|
76
|
-
if (u === "ADD") {
|
|
77
|
-
const { garnishment: c } = await x({
|
|
78
|
-
request: {
|
|
79
|
-
employeeId: o,
|
|
80
|
-
requestBody: { ...n, times: n.recurring ? null : 1 }
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
i(s.EMPLOYEE_DEDUCTION_CREATED, c);
|
|
84
|
-
} else if (u === "EDIT") {
|
|
85
|
-
const { garnishment: c } = await p({
|
|
86
|
-
request: {
|
|
87
|
-
garnishmentId: e?.uuid ?? "",
|
|
88
|
-
requestBody: {
|
|
89
|
-
...n,
|
|
90
|
-
version: e?.version,
|
|
91
|
-
times: n.recurring ? null : 1
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
i(s.EMPLOYEE_DEDUCTION_UPDATED, c), l(null);
|
|
96
|
-
}
|
|
97
|
-
m("LIST");
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
return /* @__PURE__ */ t("section", { className: d, children: /* @__PURE__ */ t(
|
|
102
|
-
z,
|
|
103
|
-
{
|
|
104
|
-
value: {
|
|
105
|
-
isPending: w || b,
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as l } from "react-i18next";
|
|
3
|
+
import { createMachine as D } from "robot3";
|
|
4
|
+
import { useGarnishmentsListSuspense as f } from "@gusto/embedded-api/react-query/garnishmentsList";
|
|
5
|
+
import { useMemo as d } from "react";
|
|
6
|
+
import { DeductionsListContextual as h, IncludeDeductionsFormContextual as F } from "./DeductionsComponents.js";
|
|
7
|
+
import { deductionsStateMachine as w } from "./stateMachine.js";
|
|
8
|
+
import { DeductionsForm as x } from "./DeductionsForm/DeductionsForm.js";
|
|
9
|
+
import { DeductionsList as C } from "./DeductionsList/DeductionsList.js";
|
|
10
|
+
import { IncludeDeductionsForm as g } from "./IncludeDeductionsForm/IncludeDeductionsForm.js";
|
|
11
|
+
import { Flow as v } from "../../Flow/Flow.js";
|
|
12
|
+
import { BaseComponent as L } from "../../Base/Base.js";
|
|
13
|
+
import "../../Base/useBase.js";
|
|
14
|
+
import { useComponentDictionary as E } from "../../../i18n/I18n.js";
|
|
15
|
+
import { useFlow as I } from "../../Flow/useFlow.js";
|
|
16
|
+
function M({ employeeId: o, onEvent: i, dictionary: r }) {
|
|
17
|
+
E("Employee.Deductions", r);
|
|
18
|
+
const { data: a } = f({ employeeId: o }), c = a.garnishmentList.filter((s) => s.active), t = d(
|
|
19
|
+
() => c.length > 0,
|
|
20
|
+
[c.length]
|
|
21
|
+
), m = t ? "viewDeductions" : "includeDeductions", u = t ? h : F, p = d(
|
|
22
|
+
() => D(
|
|
23
|
+
m,
|
|
24
|
+
w,
|
|
25
|
+
(s) => ({
|
|
26
|
+
...s,
|
|
27
|
+
component: u,
|
|
106
28
|
employeeId: o,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
i(s.EMPLOYEE_DEDUCTION_DONE);
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
children: u === "INITIAL" ? /* @__PURE__ */ t(C, { ...I, children: /* @__PURE__ */ A(L, { onSubmit: I.handleSubmit(v), children: [
|
|
124
|
-
/* @__PURE__ */ t(S, {}),
|
|
125
|
-
/* @__PURE__ */ t(K, {}),
|
|
126
|
-
/* @__PURE__ */ t(N, {})
|
|
127
|
-
] }) }) : /* @__PURE__ */ t(C, { ...E, children: /* @__PURE__ */ A(L, { onSubmit: E.handleSubmit(v), children: [
|
|
128
|
-
/* @__PURE__ */ t(S, {}),
|
|
129
|
-
/* @__PURE__ */ t(W, {}),
|
|
130
|
-
/* @__PURE__ */ t(Q, {}),
|
|
131
|
-
/* @__PURE__ */ t(N, {})
|
|
132
|
-
] }) })
|
|
133
|
-
}
|
|
134
|
-
) });
|
|
135
|
-
}, Oe = () => {
|
|
136
|
-
const { employeeId: o, onEvent: d } = X(), { t: a } = U("common");
|
|
29
|
+
currentDeductionId: null,
|
|
30
|
+
hasExistingDeductions: t
|
|
31
|
+
})
|
|
32
|
+
),
|
|
33
|
+
[m, u, o, t]
|
|
34
|
+
);
|
|
35
|
+
return /* @__PURE__ */ n(v, { machine: p, onEvent: i });
|
|
36
|
+
}
|
|
37
|
+
function e(o) {
|
|
38
|
+
return /* @__PURE__ */ n(L, { ...o, children: /* @__PURE__ */ n(M, { ...o }) });
|
|
39
|
+
}
|
|
40
|
+
const N = () => {
|
|
41
|
+
const { employeeId: o, onEvent: i } = I(), { t: r } = l("common");
|
|
137
42
|
if (!o)
|
|
138
43
|
throw new Error(
|
|
139
|
-
|
|
44
|
+
r("errors.missingParamsOrContext", {
|
|
140
45
|
component: "Deductions",
|
|
141
46
|
param: "employeeId",
|
|
142
47
|
provider: "FlowProvider"
|
|
143
48
|
})
|
|
144
49
|
);
|
|
145
|
-
return /* @__PURE__ */
|
|
50
|
+
return /* @__PURE__ */ n(e, { employeeId: o, onEvent: i });
|
|
146
51
|
};
|
|
52
|
+
e.DeductionsForm = x;
|
|
53
|
+
e.DeductionsList = C;
|
|
54
|
+
e.IncludeDeductionsForm = g;
|
|
147
55
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
$ as Root
|
|
56
|
+
e as Deductions,
|
|
57
|
+
N as DeductionsContextual
|
|
151
58
|
};
|
|
152
59
|
//# sourceMappingURL=Deductions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deductions.js","sources":["../../../../src/components/Employee/Deductions/Deductions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEffect, useMemo, useState } from 'react'\nimport { z } from 'zod'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useGarnishmentsListSuspense } from '@gusto/embedded-api/react-query/garnishmentsList'\nimport { type Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { useGarnishmentsCreateMutation } from '@gusto/embedded-api/react-query/garnishmentsCreate'\nimport { useGarnishmentsUpdateMutation } from '@gusto/embedded-api/react-query/garnishmentsUpdate'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport {\n type DeductionInputs,\n type DeductionPayload,\n DeductionSchema,\n DeductionsProvider,\n type MODE,\n} from './useDeductions'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { Form } from '@/components/Common/Form'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Actions } from '@/components/Employee/Deductions/Actions'\nimport { IncludeDeductionsForm } from '@/components/Employee/Deductions/IncludeDeductionsForm'\nimport { Head } from '@/components/Employee/Deductions/Head'\nimport { DeductionForm } from '@/components/Employee/Deductions/DeductionForm'\nimport { DeductionsList } from '@/components/Employee/Deductions/DeductionsList'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface DeductionsProps extends CommonComponentInterface<'Employee.Deductions'> {\n employeeId: string\n}\n\nconst IncludeDeductionsSchema = z.object({ includeDeductions: z.enum(['Yes', 'No']) })\nexport type IncludeDeductionsPayload = z.output<typeof IncludeDeductionsSchema>\n\nexport function Deductions(props: DeductionsProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nexport const Root = ({ employeeId, className, dictionary }: DeductionsProps) => {\n const { onEvent, baseSubmitHandler } = useBase()\n useComponentDictionary('Employee.Deductions', dictionary)\n\n const { data } = useGarnishmentsListSuspense({ employeeId })\n const deductions = data.garnishmentList!\n\n // Used for deletion or edit of deduction\n const { mutateAsync: updateDeduction, isPending: isPendingUpdate } =\n useGarnishmentsUpdateMutation()\n const { mutateAsync: createDeduction, isPending: isPendingCreate } =\n useGarnishmentsCreateMutation()\n\n const activeDeductions = deductions.filter(deduction => deduction.active)\n const [mode, setMode] = useState<MODE>(activeDeductions.length < 1 ? 'INITIAL' : 'LIST')\n const [currentDeduction, setCurrentDeduction] = useState<Garnishment | null>(null)\n useI18n('Employee.Deductions')\n\n const defaultValues: DeductionInputs = useMemo(() => {\n return {\n amount: currentDeduction?.amount ? Number(currentDeduction.amount) : 0,\n description: currentDeduction?.description ?? '',\n times: currentDeduction?.times ?? null,\n recurring: currentDeduction?.recurring?.toString() ?? 'true',\n annualMaximum: currentDeduction?.annualMaximum\n ? Number(currentDeduction.annualMaximum)\n : null,\n payPeriodMaximum: currentDeduction?.payPeriodMaximum\n ? Number(currentDeduction.payPeriodMaximum)\n : null,\n deductAsPercentage: currentDeduction?.deductAsPercentage?.toString() ?? 'true',\n active: true,\n courtOrdered: currentDeduction?.courtOrdered ?? false,\n } as DeductionInputs\n }, [currentDeduction])\n\n const includeDeductionsFormMethods = useForm<IncludeDeductionsPayload>({\n // resolver: zodResolver(IncludeDeductionsSchema),\n defaultValues: { includeDeductions: 'No' },\n })\n\n const formMethods = useForm<DeductionInputs, unknown, DeductionPayload>({\n resolver: zodResolver(DeductionSchema),\n defaultValues,\n })\n\n const { reset: resetForm } = formMethods\n\n useEffect(() => {\n resetForm(defaultValues)\n }, [currentDeduction, defaultValues, resetForm, mode])\n\n const handleDelete = async (deduction: Garnishment) => {\n await baseSubmitHandler(deduction, async payload => {\n //Deletion of deduction is simply updating it with active: false\n const { garnishment } = await updateDeduction({\n request: {\n garnishmentId: payload.uuid,\n requestBody: {\n ...payload,\n totalAmount: payload.totalAmount ?? undefined,\n active: false,\n version: payload.version as string,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DELETED, garnishment)\n })\n }\n const onSubmit: SubmitHandler<DeductionPayload | IncludeDeductionsPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n if ('includeDeductions' in payload) {\n if (payload.includeDeductions === 'Yes') {\n setMode('ADD')\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_ADD)\n } else {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DONE)\n return\n }\n }\n if (!('includeDeductions' in payload)) {\n if (mode === 'ADD') {\n const { garnishment: createDeductionResponse } = await createDeduction({\n request: {\n employeeId: employeeId,\n requestBody: { ...payload, times: payload.recurring ? null : 1 },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_CREATED, createDeductionResponse)\n } else if (mode === 'EDIT') {\n const { garnishment: updateDeductionResponse } = await updateDeduction({\n request: {\n garnishmentId: currentDeduction?.uuid ?? '',\n requestBody: {\n ...payload,\n version: currentDeduction?.version as string,\n times: payload.recurring ? null : 1,\n },\n },\n })\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_UPDATED, updateDeductionResponse)\n setCurrentDeduction(null)\n }\n setMode('LIST')\n }\n })\n }\n const handleAdd = () => {\n setMode('ADD')\n }\n const handleCancel = () => {\n setMode(activeDeductions.length < 1 ? 'INITIAL' : 'LIST')\n setCurrentDeduction(null)\n }\n const handleEdit = (deduction: Garnishment) => {\n setMode('EDIT')\n setCurrentDeduction(deduction)\n }\n const handlePassthrough = () => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_DONE)\n }\n return (\n <section className={className}>\n <DeductionsProvider\n value={{\n isPending: isPendingCreate || isPendingUpdate,\n employeeId,\n mode,\n deductions,\n handleAdd,\n handleCancel,\n handleDelete,\n handleEdit,\n handlePassthrough,\n }}\n >\n {mode === 'INITIAL' ? (\n <FormProvider {...includeDeductionsFormMethods}>\n <Form onSubmit={includeDeductionsFormMethods.handleSubmit(onSubmit)}>\n <Head />\n <IncludeDeductionsForm />\n <Actions />\n </Form>\n </FormProvider>\n ) : (\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Head />\n <DeductionsList />\n <DeductionForm />\n <Actions />\n </Form>\n </FormProvider>\n )}\n </DeductionsProvider>\n </section>\n )\n}\n\nexport const DeductionsContextual = () => {\n const { employeeId, onEvent } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Deductions',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <Deductions employeeId={employeeId} onEvent={onEvent} />\n}\n"],"names":["z","Deductions","props","jsx","BaseComponent","Root","employeeId","className","dictionary","onEvent","baseSubmitHandler","useBase","useComponentDictionary","data","useGarnishmentsListSuspense","deductions","updateDeduction","isPendingUpdate","useGarnishmentsUpdateMutation","createDeduction","isPendingCreate","useGarnishmentsCreateMutation","activeDeductions","deduction","mode","setMode","useState","currentDeduction","setCurrentDeduction","useI18n","defaultValues","useMemo","includeDeductionsFormMethods","useForm","formMethods","zodResolver","DeductionSchema","resetForm","useEffect","handleDelete","payload","garnishment","componentEvents","onSubmit","createDeductionResponse","updateDeductionResponse","DeductionsProvider","FormProvider","jsxs","Form","Head","IncludeDeductionsForm","Actions","DeductionsList","DeductionForm","DeductionsContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCgCA,EAAE,OAAO,EAAE,mBAAmBA,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,EAAA,CAAG;AAG9E,SAASC,EAAWC,GAAiD;AAC1E,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AACO,MAAMG,IAAO,CAAC,EAAE,YAAAC,GAAY,WAAAC,GAAW,YAAAC,QAAkC;AAC9E,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA;AACvC,EAAAC,EAAuB,uBAAuBJ,CAAU;AAExD,QAAM,EAAE,MAAAK,EAAA,IAASC,EAA4B,EAAE,YAAAR,GAAY,GACrDS,IAAaF,EAAK,iBAGlB,EAAE,aAAaG,GAAiB,WAAWC,EAAA,IAC/CC,EAAA,GACI,EAAE,aAAaC,GAAiB,WAAWC,EAAA,IAC/CC,EAAA,GAEIC,IAAmBP,EAAW,OAAO,CAAAQ,MAAaA,EAAU,MAAM,GAClE,CAACC,GAAMC,CAAO,IAAIC,EAAeJ,EAAiB,SAAS,IAAI,YAAY,MAAM,GACjF,CAACK,GAAkBC,CAAmB,IAAIF,EAA6B,IAAI;AACjF,EAAAG,EAAQ,qBAAqB;AAE7B,QAAMC,IAAiC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file":"Deductions.js","sources":["../../../../src/components/Employee/Deductions/Deductions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { createMachine } from 'robot3'\nimport { useGarnishmentsListSuspense } from '@gusto/embedded-api/react-query/garnishmentsList'\nimport { useMemo } from 'react'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport {\n IncludeDeductionsFormContextual,\n type DeductionsContextInterface,\n DeductionsListContextual,\n} from './DeductionsComponents'\nimport { deductionsStateMachine } from './stateMachine'\nimport { DeductionsForm } from './DeductionsForm/DeductionsForm'\nimport { DeductionsList } from './DeductionsList/DeductionsList'\nimport { IncludeDeductionsForm } from './IncludeDeductionsForm/IncludeDeductionsForm'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nexport interface DeductionsProps extends BaseComponentInterface<'Employee.Deductions'> {\n employeeId: string\n}\nfunction DeductionsFlow({ employeeId, onEvent, dictionary }: DeductionsProps) {\n useComponentDictionary('Employee.Deductions', dictionary)\n const { data } = useGarnishmentsListSuspense({ employeeId })\n const deductions = data.garnishmentList!\n const activeDeductions = deductions.filter(deduction => deduction.active)\n const hasExistingDeductions = useMemo(\n () => activeDeductions.length > 0,\n [activeDeductions.length],\n )\n\n // Determine initial state based on existing deductions\n const initialState: 'includeDeductions' | 'viewDeductions' = hasExistingDeductions\n ? 'viewDeductions'\n : 'includeDeductions'\n\n const initialComponent: React.ComponentType = hasExistingDeductions\n ? DeductionsListContextual\n : IncludeDeductionsFormContextual\n\n const manageDeductions = useMemo(\n () =>\n createMachine(\n initialState,\n deductionsStateMachine,\n (initialContext: DeductionsContextInterface) => ({\n ...initialContext,\n component: initialComponent,\n employeeId,\n currentDeductionId: null,\n hasExistingDeductions,\n }),\n ),\n [initialState, initialComponent, employeeId, hasExistingDeductions],\n )\n\n return <Flow machine={manageDeductions} onEvent={onEvent} />\n}\n\nexport function Deductions(props: DeductionsProps) {\n return (\n <BaseComponent {...props}>\n <DeductionsFlow {...props} />\n </BaseComponent>\n )\n}\n\nexport const DeductionsContextual = () => {\n const { employeeId, onEvent } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Deductions',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <Deductions employeeId={employeeId} onEvent={onEvent} />\n}\n\nDeductions.DeductionsForm = DeductionsForm\nDeductions.DeductionsList = DeductionsList\nDeductions.IncludeDeductionsForm = IncludeDeductionsForm\n"],"names":["DeductionsFlow","employeeId","onEvent","dictionary","useComponentDictionary","data","useGarnishmentsListSuspense","activeDeductions","deduction","hasExistingDeductions","useMemo","initialState","initialComponent","DeductionsListContextual","IncludeDeductionsFormContextual","manageDeductions","createMachine","deductionsStateMachine","initialContext","jsx","Flow","Deductions","props","BaseComponent","DeductionsContextual","useFlow","t","useTranslation","DeductionsForm","DeductionsList","IncludeDeductionsForm"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAASA,EAAe,EAAE,YAAAC,GAAY,SAAAC,GAAS,YAAAC,KAA+B;AAC5E,EAAAC,EAAuB,uBAAuBD,CAAU;AACxD,QAAM,EAAE,MAAAE,EAAA,IAASC,EAA4B,EAAE,YAAAL,GAAY,GAErDM,IADaF,EAAK,gBACY,OAAO,CAAAG,MAAaA,EAAU,MAAM,GAClEC,IAAwBC;AAAA,IAC5B,MAAMH,EAAiB,SAAS;AAAA,IAChC,CAACA,EAAiB,MAAM;AAAA,EAAA,GAIpBI,IAAuDF,IACzD,mBACA,qBAEEG,IAAwCH,IAC1CI,IACAC,GAEEC,IAAmBL;AAAA,IACvB,MACEM;AAAA,MACEL;AAAA,MACAM;AAAA,MACA,CAACC,OAAgD;AAAA,QAC/C,GAAGA;AAAA,QACH,WAAWN;AAAA,QACX,YAAAX;AAAA,QACA,oBAAoB;AAAA,QACpB,uBAAAQ;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACE,GAAcC,GAAkBX,GAAYQ,CAAqB;AAAA,EAAA;AAGpE,SAAO,gBAAAU,EAACC,GAAA,EAAK,SAASL,GAAkB,SAAAb,EAAA,CAAkB;AAC5D;AAEO,SAASmB,EAAWC,GAAwB;AACjD,SACE,gBAAAH,EAACI,KAAe,GAAGD,GACjB,4BAACtB,GAAA,EAAgB,GAAGsB,GAAO,EAAA,CAC7B;AAEJ;AAEO,MAAME,IAAuB,MAAM;AACxC,QAAM,EAAE,YAAAvB,GAAY,SAAAC,EAAA,IAAYuB,EAAA,GAC1B,EAAE,GAAAC,EAAA,IAAMC,EAAe,QAAQ;AAErC,MAAI,CAAC1B;AACH,UAAM,IAAI;AAAA,MACRyB,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAO;AAAA,QACP,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAGL,SAAO,gBAAAP,EAACE,GAAA,EAAW,YAAApB,GAAwB,SAAAC,EAAA,CAAkB;AAC/D;AAEAmB,EAAW,iBAAiBO;AAC5BP,EAAW,iBAAiBQ;AAC5BR,EAAW,wBAAwBS;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Garnishment } from '@gusto/embedded-api/models/components/garnishment';
|
|
2
|
+
import { FlowContextInterface } from '../../Flow/useFlow';
|
|
3
|
+
import { componentEvents } from '../../../shared/constants';
|
|
4
|
+
export type EventPayloads = {
|
|
5
|
+
[componentEvents.EMPLOYEE_DEDUCTION_INCLUDE_YES]: undefined;
|
|
6
|
+
[componentEvents.EMPLOYEE_DEDUCTION_INCLUDE_NO]: undefined;
|
|
7
|
+
[componentEvents.EMPLOYEE_DEDUCTION_ADD]: undefined;
|
|
8
|
+
[componentEvents.EMPLOYEE_DEDUCTION_CREATED]: Garnishment;
|
|
9
|
+
[componentEvents.EMPLOYEE_DEDUCTION_UPDATED]: Garnishment;
|
|
10
|
+
[componentEvents.EMPLOYEE_DEDUCTION_DELETED]: Garnishment;
|
|
11
|
+
[componentEvents.EMPLOYEE_DEDUCTION_EDIT]: Garnishment;
|
|
12
|
+
[componentEvents.EMPLOYEE_DEDUCTION_CANCEL]: undefined;
|
|
13
|
+
[componentEvents.EMPLOYEE_DEDUCTION_DONE]: undefined;
|
|
14
|
+
[componentEvents.CANCEL]: undefined;
|
|
15
|
+
};
|
|
16
|
+
export interface DeductionsContextInterface extends FlowContextInterface {
|
|
17
|
+
employeeId: string;
|
|
18
|
+
currentDeductionId?: string | null;
|
|
19
|
+
hasExistingDeductions?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function IncludeDeductionsFormContextual(): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function DeductionsListContextual(): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function DeductionFormContextual(): import("react/jsx-runtime").JSX.Element;
|