@gusto/embedded-react-sdk 0.37.0-rc.3 → 0.37.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +8 -7
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +5 -4
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.js +88 -69
- package/dist/components/Common/UI/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/Common/UI/DatePicker/DatePickerTypes.d.ts +13 -0
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +7 -6
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +9 -8
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +11 -11
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +7 -6
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/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/Actions.js +6 -6
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +4 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +7 -6
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +8 -7
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +6 -5
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.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/Actions.js +7 -6
- package/dist/components/Company/FederalTaxes/Actions.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/Actions.js +6 -5
- package/dist/components/Company/Industry/Actions.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +7 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/Edit.js +11 -10
- package/dist/components/Company/Industry/Edit.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +3 -2
- package/dist/components/Company/Locations/LocationForm/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +4 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +3 -2
- package/dist/components/Company/Locations/LocationsList/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +7 -6
- package/dist/components/Company/Locations/LocationsList/List.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/PaySchedule.js +60 -58
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +11 -10
- package/dist/components/Company/PaySchedule/_parts/Actions.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +39 -36
- package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.d.ts +1 -0
- package/dist/components/Company/PaySchedule/usePaySchedule.js +6 -5
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +6 -5
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +7 -6
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +6 -5
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +4 -4
- package/dist/components/Contractor/Address/useAddress.js +6 -5
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +3 -2
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +1 -1
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
- package/dist/components/Contractor/Profile/useContractorProfile.js +3 -2
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +1 -1
- package/dist/components/Employee/Compensation/List.js +6 -5
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +5 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +16 -16
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +5 -4
- package/dist/components/Employee/EmployeeList/Actions.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +10 -10
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +4 -3
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/Actions.js +3 -2
- package/dist/components/Employee/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalForm.js +5 -4
- package/dist/components/Employee/FederalTaxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +4 -3
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Actions.js +6 -5
- package/dist/components/Employee/PaymentMethod/Actions.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +4 -4
- package/dist/components/Employee/PaymentMethod/Split.js +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +6 -5
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/Actions.js +7 -6
- package/dist/components/Employee/Profile/Actions.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +5 -4
- package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +10 -9
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +4 -3
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/StateTaxes/Actions.js +7 -6
- package/dist/components/Employee/StateTaxes/Actions.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +4 -3
- package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
- package/dist/components/Employee/Taxes/Actions.js +8 -7
- package/dist/components/Employee/Taxes/Actions.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +5 -4
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +4 -3
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +48 -48
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js +10 -10
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +10 -10
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.js +15 -14
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +3 -2
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js +4 -4
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +12 -11
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +1 -0
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +3 -2
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js +10 -10
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +44 -55
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +3 -2
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.js +9 -8
- package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.js +12 -11
- package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.js +3 -2
- package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.js +8 -7
- package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.js +9 -8
- package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.js +13 -12
- package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/CompensationForm.js +4 -4
- package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/EmployeeDetailsForm.js +1 -1
- package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/WorkAddressForm.js +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +3 -2
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/i18n/en/Company.PaySchedule.json.js +6 -6
- package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js +8 -8
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +2 -1
- package/docs/reference/endpoint-inventory.json +9 -0
- package/package.json +3 -3
|
@@ -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 paymentSpeed?: string\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":";;;;;;;;;;;;;;;;AA4BO,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,16 +1,17 @@
|
|
|
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";
|
|
4
5
|
import { ActionsLayout as m } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
5
6
|
import { useComponentContext as c } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
6
|
-
function
|
|
7
|
-
const { t } = a("Company.StateTaxes", { keyPrefix: "form" }), { handleCancel:
|
|
7
|
+
function x() {
|
|
8
|
+
const { t } = a("Company.StateTaxes", { keyPrefix: "form" }), { handleCancel: r, isPending: e } = s(), o = c();
|
|
8
9
|
return /* @__PURE__ */ i(m, { children: [
|
|
9
|
-
/* @__PURE__ */ n(o.Button, { variant: "secondary", onClick:
|
|
10
|
-
/* @__PURE__ */ n(o.Button, { variant: "primary", type: "submit", isDisabled:
|
|
10
|
+
/* @__PURE__ */ n(o.Button, { variant: "secondary", onClick: r, children: t("cancelCta") }),
|
|
11
|
+
/* @__PURE__ */ n(o.Button, { variant: "primary", type: "submit", isDisabled: e, children: t("saveCta") })
|
|
11
12
|
] });
|
|
12
13
|
}
|
|
13
14
|
export {
|
|
14
|
-
|
|
15
|
+
x as Actions
|
|
15
16
|
};
|
|
16
17
|
//# 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;AACxB,QAAM,EAAE,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,cAAAC,GAAc,WAAAC,EAAA,IAAcC,EAAA,GAC9BC,IAAaC,EAAA;AAEnB,2BACGC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC,EAACH,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAASH,GAC7C,UAAA,EAAE,WAAW,EAAA,CAChB;AAAA,IACA,gBAAAM,EAACH,EAAW,QAAX,EAAkB,SAAQ,WAAU,MAAK,UAAS,YAAYF,GAC5D,UAAA,EAAE,SAAS,EAAA,CACd;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -11,10 +11,11 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
11
11
|
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
12
12
|
import "../../../../shared/constants.js";
|
|
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;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as i } from "react-i18next";
|
|
3
3
|
import { useStateTaxesList as e } from "./context.js";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import "../../../../shared/constants.js";
|
|
5
|
+
import { ActionsLayout as m } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
|
+
import { useComponentContext as s } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
|
+
function l() {
|
|
8
|
+
const { t: o } = i("Company.StateTaxes"), n = s(), { handleContinue: r } = e();
|
|
9
|
+
return /* @__PURE__ */ t(m, { children: /* @__PURE__ */ t(n.Button, { variant: "primary", onClick: r, children: o("list.continueCta") }) });
|
|
9
10
|
}
|
|
10
11
|
export {
|
|
11
|
-
|
|
12
|
+
l as Actions
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=Actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useStateTaxesList } from './context'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport function Actions() {\n const { t } = useTranslation('Company.StateTaxes')\n const Components = useComponentContext()\n const { handleContinue } = useStateTaxesList()\n return (\n <ActionsLayout>\n <Components.Button variant=\"primary\" onClick={handleContinue}>\n {t('list.continueCta')}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["Actions","t","useTranslation","Components","useComponentContext","handleContinue","useStateTaxesList","jsx","ActionsLayout"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useStateTaxesList } from './context'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport function Actions() {\n const { t } = useTranslation('Company.StateTaxes')\n const Components = useComponentContext()\n const { handleContinue } = useStateTaxesList()\n return (\n <ActionsLayout>\n <Components.Button variant=\"primary\" onClick={handleContinue}>\n {t('list.continueCta')}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["Actions","t","useTranslation","Components","useComponentContext","handleContinue","useStateTaxesList","jsx","ActionsLayout"],"mappings":";;;;;;AAKO,SAASA,IAAU;AACxB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GACb,EAAE,gBAAAC,EAAA,IAAmBC,EAAA;AAC3B,SACE,gBAAAC,EAACC,GAAA,EACC,UAAA,gBAAAD,EAACJ,EAAW,QAAX,EAAkB,SAAQ,WAAU,SAASE,GAC3C,UAAAJ,EAAE,kBAAkB,GACvB,GACF;AAEJ;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as s, Fragment as p } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as o } from "react-i18next";
|
|
3
3
|
import { useStateTaxesList as l } from "./context.js";
|
|
4
|
+
import "../../../../shared/constants.js";
|
|
4
5
|
import { EmptyData as c } from "../../../Common/EmptyData/EmptyData.js";
|
|
5
6
|
import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
6
7
|
import { useDataView as d } from "../../../Common/DataView/useDataView.js";
|
|
7
8
|
import { DataView as C } from "../../../Common/DataView/DataView.js";
|
|
8
|
-
const
|
|
9
|
-
const { stateTaxRequirements:
|
|
10
|
-
data:
|
|
9
|
+
const k = () => {
|
|
10
|
+
const { stateTaxRequirements: r, handleChange: n } = l(), a = u(), { t } = o("Company.StateTaxes", { keyPrefix: "list" }), { t: i } = o("common", { keyPrefix: "statesHash" }), { ...m } = d({
|
|
11
|
+
data: r,
|
|
11
12
|
columns: [
|
|
12
13
|
{
|
|
13
14
|
key: "state",
|
|
@@ -25,7 +26,7 @@ const S = () => {
|
|
|
25
26
|
{
|
|
26
27
|
variant: "secondary",
|
|
27
28
|
onClick: () => {
|
|
28
|
-
|
|
29
|
+
n(e.state);
|
|
29
30
|
},
|
|
30
31
|
children: e.setupComplete ? t("editStateTaxCta") : t("continueStateTaxSetupCta")
|
|
31
32
|
}
|
|
@@ -35,6 +36,6 @@ const S = () => {
|
|
|
35
36
|
return /* @__PURE__ */ s(C, { label: t("requirementsListLabel"), ...m });
|
|
36
37
|
};
|
|
37
38
|
export {
|
|
38
|
-
|
|
39
|
+
k as List
|
|
39
40
|
};
|
|
40
41
|
//# sourceMappingURL=List.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useStateTaxesList } from './context'\nimport { DataView, EmptyData, useDataView } from '@/components/Common'\nimport type { STATES_ABBR } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const List = () => {\n const { stateTaxRequirements, handleChange } = useStateTaxesList()\n const Components = useComponentContext()\n\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'list' })\n const { t: statesHash } = useTranslation('common', { keyPrefix: 'statesHash' })\n\n const { ...dataViewProps } = useDataView({\n data: stateTaxRequirements,\n columns: [\n {\n key: 'state',\n title: t('requirementsListCol1'),\n render: requirement => {\n return <span>{statesHash(requirement.state as (typeof STATES_ABBR)[number])}</span>\n },\n },\n {\n key: 'status',\n title: t('requirementsListCol2'),\n render: requirement => {\n return (\n <>\n <Components.Badge status={requirement.setupComplete ? 'success' : 'warning'}>\n {requirement.setupComplete ? t('completeBadge') : t('incompleteBadge')}\n </Components.Badge>\n </>\n )\n },\n },\n ],\n itemMenu: requirement => {\n return (\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleChange(requirement.state)\n }}\n >\n {requirement.setupComplete ? t('editStateTaxCta') : t('continueStateTaxSetupCta')}\n </Components.Button>\n )\n },\n\n emptyState: () => (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')} />\n ),\n })\n return <DataView label={t('requirementsListLabel')} {...dataViewProps} />\n}\n"],"names":["List","stateTaxRequirements","handleChange","useStateTaxesList","Components","useComponentContext","useTranslation","statesHash","dataViewProps","useDataView","requirement","jsx","EmptyData","DataView"],"mappings":"
|
|
1
|
+
{"version":3,"file":"List.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useStateTaxesList } from './context'\nimport { DataView, EmptyData, useDataView } from '@/components/Common'\nimport type { STATES_ABBR } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const List = () => {\n const { stateTaxRequirements, handleChange } = useStateTaxesList()\n const Components = useComponentContext()\n\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'list' })\n const { t: statesHash } = useTranslation('common', { keyPrefix: 'statesHash' })\n\n const { ...dataViewProps } = useDataView({\n data: stateTaxRequirements,\n columns: [\n {\n key: 'state',\n title: t('requirementsListCol1'),\n render: requirement => {\n return <span>{statesHash(requirement.state as (typeof STATES_ABBR)[number])}</span>\n },\n },\n {\n key: 'status',\n title: t('requirementsListCol2'),\n render: requirement => {\n return (\n <>\n <Components.Badge status={requirement.setupComplete ? 'success' : 'warning'}>\n {requirement.setupComplete ? t('completeBadge') : t('incompleteBadge')}\n </Components.Badge>\n </>\n )\n },\n },\n ],\n itemMenu: requirement => {\n return (\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n handleChange(requirement.state)\n }}\n >\n {requirement.setupComplete ? t('editStateTaxCta') : t('continueStateTaxSetupCta')}\n </Components.Button>\n )\n },\n\n emptyState: () => (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')} />\n ),\n })\n return <DataView label={t('requirementsListLabel')} {...dataViewProps} />\n}\n"],"names":["List","stateTaxRequirements","handleChange","useStateTaxesList","Components","useComponentContext","useTranslation","statesHash","dataViewProps","useDataView","requirement","jsx","EmptyData","DataView"],"mappings":";;;;;;;;AAMO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,sBAAAC,GAAsB,cAAAC,EAAA,IAAiBC,EAAA,GACzCC,IAAaC,EAAA,GAEb,EAAE,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,GAAGC,MAAeD,EAAe,UAAU,EAAE,WAAW,cAAc,GAExE,EAAE,GAAGE,EAAA,IAAkBC,EAAY;AAAA,IACvC,MAAMR;AAAA,IACN,SAAS;AAAA,MACP;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,sBAAsB;AAAA,QAC/B,QAAQ,CAAAS,MACC,gBAAAC,EAAC,QAAA,EAAM,UAAAJ,EAAWG,EAAY,KAAqC,GAAE;AAAA,MAC9E;AAAA,MAEF;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,sBAAsB;AAAA,QAC/B,QAAQ,CAAAA,6BAGF,UAAA,gBAAAC,EAACP,EAAW,OAAX,EAAiB,QAAQM,EAAY,gBAAgB,YAAY,WAC/D,UAAAA,EAAY,gBAAgB,EAAE,eAAe,IAAI,EAAE,iBAAiB,GACvE,GACF;AAAA,MAEJ;AAAA,IACF;AAAA,IAEF,UAAU,CAAAA,MAEN,gBAAAC;AAAA,MAACP,EAAW;AAAA,MAAX;AAAA,QACC,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,UAAAF,EAAaQ,EAAY,KAAK;AAAA,QAChC;AAAA,QAEC,YAAY,gBAAgB,EAAE,iBAAiB,IAAI,EAAE,0BAA0B;AAAA,MAAA;AAAA,IAAA;AAAA,IAKtF,YAAY,MACV,gBAAAC,EAACC,GAAA,EAAU,OAAO,EAAE,iBAAiB,GAAG,aAAa,EAAE,uBAAuB,EAAA,CAAG;AAAA,EAAA,CAEpF;AACD,2BAAQC,GAAA,EAAS,OAAO,EAAE,uBAAuB,GAAI,GAAGL,GAAe;AACzE;"}
|
|
@@ -11,10 +11,11 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
11
11
|
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
12
12
|
import "../../../../shared/constants.js";
|
|
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;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as i } from "react-i18next";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { STATES_ABBR as o } from "../../../shared/constants.js";
|
|
4
|
+
import { Grid as l } from "../../Common/Grid/Grid.js";
|
|
5
5
|
import { TextInputField as t } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
6
6
|
import { SelectField as m } from "../../Common/Fields/SelectField/SelectField.js";
|
|
7
7
|
function g() {
|
|
8
8
|
const { t: e } = i("Contractor.Address");
|
|
9
|
-
return /* @__PURE__ */ s(
|
|
9
|
+
return /* @__PURE__ */ s(l, { gridTemplateColumns: { base: "1fr", small: ["1fr", "1fr"] }, gap: 20, children: [
|
|
10
10
|
/* @__PURE__ */ r(
|
|
11
11
|
t,
|
|
12
12
|
{
|
|
@@ -30,7 +30,7 @@ function g() {
|
|
|
30
30
|
m,
|
|
31
31
|
{
|
|
32
32
|
name: "state",
|
|
33
|
-
options:
|
|
33
|
+
options: o.map((a) => ({
|
|
34
34
|
label: e(`statesHash.${a}`, { ns: "common", defaultValue: a }),
|
|
35
35
|
value: a
|
|
36
36
|
})),
|
|
@@ -12,19 +12,20 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
12
12
|
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
13
13
|
import "../../../shared/constants.js";
|
|
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;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsxs as n, Fragment as o, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as t } from "react-i18next";
|
|
3
|
+
import "../../../shared/constants.js";
|
|
3
4
|
import { TextInputField as a } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
4
5
|
import { RadioGroupField as i } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
5
|
-
function
|
|
6
|
+
function p({ bankAccount: u }) {
|
|
6
7
|
const { t: e } = t("Contractor.PaymentMethod", { keyPrefix: "bankAccountForm" });
|
|
7
8
|
return /* @__PURE__ */ n(o, { children: [
|
|
8
9
|
/* @__PURE__ */ r(
|
|
@@ -48,6 +49,6 @@ function b({ bankAccount: u }) {
|
|
|
48
49
|
] });
|
|
49
50
|
}
|
|
50
51
|
export {
|
|
51
|
-
|
|
52
|
+
p as BankAccountForm
|
|
52
53
|
};
|
|
53
54
|
//# sourceMappingURL=BankAccountForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BankAccountForm.js","sources":["../../../../src/components/Contractor/PaymentMethod/BankAccountForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { BankAccountFormProps } from './types'\nimport { RadioGroupField, TextInputField } from '@/components/Common'\n\nexport function BankAccountForm({ bankAccount }: BankAccountFormProps) {\n const { t } = useTranslation('Contractor.PaymentMethod', { keyPrefix: 'bankAccountForm' })\n\n return (\n <>\n <TextInputField\n name=\"name\"\n isRequired\n label={t('nameLabel')}\n errorMessage={t('validations.accountName')}\n />\n\n <TextInputField\n name=\"routingNumber\"\n label={t('routingNumberLabel')}\n isRequired\n description={t('routingNumberDescription')}\n errorMessage={t('validations.routingNumber')}\n />\n\n <TextInputField\n name=\"accountNumber\"\n label={t('accountNumberLabel')}\n errorMessage={t('validations.accountNumber')}\n isRequired\n />\n\n <RadioGroupField\n name=\"accountType\"\n isRequired\n label={t('accountTypeLabel')}\n options={[\n { value: 'Checking', label: t('accountTypeChecking') },\n { value: 'Savings', label: t('accountTypeSavings') },\n ]}\n />\n </>\n )\n}\n"],"names":["BankAccountForm","bankAccount","t","useTranslation","jsxs","Fragment","jsx","TextInputField","RadioGroupField"],"mappings":"
|
|
1
|
+
{"version":3,"file":"BankAccountForm.js","sources":["../../../../src/components/Contractor/PaymentMethod/BankAccountForm.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { BankAccountFormProps } from './types'\nimport { RadioGroupField, TextInputField } from '@/components/Common'\n\nexport function BankAccountForm({ bankAccount }: BankAccountFormProps) {\n const { t } = useTranslation('Contractor.PaymentMethod', { keyPrefix: 'bankAccountForm' })\n\n return (\n <>\n <TextInputField\n name=\"name\"\n isRequired\n label={t('nameLabel')}\n errorMessage={t('validations.accountName')}\n />\n\n <TextInputField\n name=\"routingNumber\"\n label={t('routingNumberLabel')}\n isRequired\n description={t('routingNumberDescription')}\n errorMessage={t('validations.routingNumber')}\n />\n\n <TextInputField\n name=\"accountNumber\"\n label={t('accountNumberLabel')}\n errorMessage={t('validations.accountNumber')}\n isRequired\n />\n\n <RadioGroupField\n name=\"accountType\"\n isRequired\n label={t('accountTypeLabel')}\n options={[\n { value: 'Checking', label: t('accountTypeChecking') },\n { value: 'Savings', label: t('accountTypeSavings') },\n ]}\n />\n </>\n )\n}\n"],"names":["BankAccountForm","bankAccount","t","useTranslation","jsxs","Fragment","jsx","TextInputField","RadioGroupField"],"mappings":";;;;;AAIO,SAASA,EAAgB,EAAE,aAAAC,KAAqC;AACrE,QAAM,EAAE,GAAAC,MAAMC,EAAe,4BAA4B,EAAE,WAAW,mBAAmB;AAEzF,SACE,gBAAAC,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAOL,EAAE,WAAW;AAAA,QACpB,cAAcA,EAAE,yBAAyB;AAAA,MAAA;AAAA,IAAA;AAAA,IAG3C,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,oBAAoB;AAAA,QAC7B,YAAU;AAAA,QACV,aAAaA,EAAE,0BAA0B;AAAA,QACzC,cAAcA,EAAE,2BAA2B;AAAA,MAAA;AAAA,IAAA;AAAA,IAG7C,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,oBAAoB;AAAA,QAC7B,cAAcA,EAAE,2BAA2B;AAAA,QAC3C,YAAU;AAAA,MAAA;AAAA,IAAA;AAAA,IAGZ,gBAAAI;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAON,EAAE,kBAAkB;AAAA,QAC3B,SAAS;AAAA,UACP,EAAE,OAAO,YAAY,OAAOA,EAAE,qBAAqB,EAAA;AAAA,UACnD,EAAE,OAAO,WAAW,OAAOA,EAAE,oBAAoB,EAAA;AAAA,QAAE;AAAA,MACrD;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
|
|
@@ -6,15 +6,15 @@ import { useComponentContext as D } from "../../../contexts/ComponentAdapter/use
|
|
|
6
6
|
import { useI18n as I } from "../../../i18n/I18n.js";
|
|
7
7
|
import { Form as O } from "../../Common/Form/Form.js";
|
|
8
8
|
import { Grid as n } from "../../Common/Grid/Grid.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { ContractorOnboardingStatus as G } from "../../../shared/constants.js";
|
|
9
|
+
import { usePlaceholderSSN as x, normalizeSSN as w } from "../../../helpers/ssn.js";
|
|
10
|
+
import { usePlaceholderEin as E, normalizeEin as j } from "../../../helpers/federalEin.js";
|
|
11
|
+
import { ContractorOnboardingStatus as v } from "../../../shared/constants.js";
|
|
13
12
|
import { TextInputField as l } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
14
13
|
import { RadioGroupField as d } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
15
|
-
import { NumberInputField as
|
|
16
|
-
import { Flex as
|
|
17
|
-
import { SwitchField as
|
|
14
|
+
import { NumberInputField as G } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
15
|
+
import { Flex as z } from "../../Common/Flex/Flex.js";
|
|
16
|
+
import { SwitchField as A } from "../../Common/Fields/SwitchField/SwitchField.js";
|
|
17
|
+
import { DatePickerField as B } from "../../Common/Fields/DatePickerField/DatePickerField.js";
|
|
18
18
|
function re({
|
|
19
19
|
formMethods: u,
|
|
20
20
|
handleSubmit: f,
|
|
@@ -33,7 +33,7 @@ function re({
|
|
|
33
33
|
}) {
|
|
34
34
|
const a = D();
|
|
35
35
|
I("Contractor.Profile");
|
|
36
|
-
const { t: e } = T("Contractor.Profile"), q =
|
|
36
|
+
const { t: e } = T("Contractor.Profile"), q = x(t?.hasSsn ?? !1), P = E(t?.hasEin ?? !1);
|
|
37
37
|
return /* @__PURE__ */ i("section", { className: F, children: /* @__PURE__ */ i(S, { ...u, children: /* @__PURE__ */ r(O, { onSubmit: f, children: [
|
|
38
38
|
/* @__PURE__ */ r(n, { gridTemplateColumns: "1fr", gap: 24, className: "mb-8", children: [
|
|
39
39
|
/* @__PURE__ */ r("header", { children: [
|
|
@@ -42,12 +42,12 @@ function re({
|
|
|
42
42
|
] }),
|
|
43
43
|
/* @__PURE__ */ i("div", { className: C.switchFieldContainer, children: /* @__PURE__ */ r(n, { gap: 16, children: [
|
|
44
44
|
/* @__PURE__ */ i(
|
|
45
|
-
|
|
45
|
+
A,
|
|
46
46
|
{
|
|
47
47
|
name: "selfOnboarding",
|
|
48
48
|
label: e("fields.selfOnboarding.label"),
|
|
49
49
|
description: e("fields.selfOnboarding.description"),
|
|
50
|
-
isDisabled: t && t.onboardingStatus !==
|
|
50
|
+
isDisabled: t && t.onboardingStatus !== v.ADMIN_ONBOARDING_INCOMPLETE
|
|
51
51
|
}
|
|
52
52
|
),
|
|
53
53
|
p && /* @__PURE__ */ i(
|
|
@@ -81,7 +81,7 @@ function re({
|
|
|
81
81
|
name: "ssn",
|
|
82
82
|
label: e("fields.ssn.label"),
|
|
83
83
|
placeholder: q,
|
|
84
|
-
transform:
|
|
84
|
+
transform: w,
|
|
85
85
|
isRequired: !0
|
|
86
86
|
}
|
|
87
87
|
)
|
|
@@ -101,7 +101,7 @@ function re({
|
|
|
101
101
|
name: "ein",
|
|
102
102
|
label: e("fields.ein.label"),
|
|
103
103
|
placeholder: P,
|
|
104
|
-
transform:
|
|
104
|
+
transform: j,
|
|
105
105
|
isRequired: !0
|
|
106
106
|
}
|
|
107
107
|
)
|
|
@@ -116,7 +116,7 @@ function re({
|
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
118
|
h && /* @__PURE__ */ i(
|
|
119
|
-
|
|
119
|
+
G,
|
|
120
120
|
{
|
|
121
121
|
name: "hourlyRate",
|
|
122
122
|
label: e("fields.hourlyRate.label"),
|
|
@@ -126,7 +126,7 @@ function re({
|
|
|
126
126
|
}
|
|
127
127
|
),
|
|
128
128
|
/* @__PURE__ */ i(
|
|
129
|
-
|
|
129
|
+
B,
|
|
130
130
|
{
|
|
131
131
|
name: "startDate",
|
|
132
132
|
label: e("fields.startDate.label"),
|
|
@@ -135,7 +135,7 @@ function re({
|
|
|
135
135
|
}
|
|
136
136
|
)
|
|
137
137
|
] }),
|
|
138
|
-
/* @__PURE__ */ i(
|
|
138
|
+
/* @__PURE__ */ i(z, { gap: 12, justifyContent: "flex-end", children: /* @__PURE__ */ i(a.Button, { type: "submit", variant: "primary", isDisabled: o.isSubmitting, children: o.isSubmitting ? e(s ? "buttons.updating" : "buttons.creating") : e(s ? "buttons.update" : "buttons.create") }) })
|
|
139
139
|
] }) }) });
|
|
140
140
|
}
|
|
141
141
|
export {
|
|
@@ -17,6 +17,7 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
|
17
17
|
import { SDKInternalError as Y } from "../../../types/sdkError.js";
|
|
18
18
|
import { ContractorSelfOnboardingStatuses as x, componentEvents as b, ContractorOnboardingStatus as ee } from "../../../shared/constants.js";
|
|
19
19
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
20
|
+
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
20
21
|
import { useI18n as oe } from "../../../i18n/I18n.js";
|
|
21
22
|
import { SSN_REGEX as se, NAME_REGEX as N } from "../../../helpers/validations.js";
|
|
22
23
|
import { removeNonDigits as ae } from "../../../helpers/formattedStrings.js";
|
|
@@ -95,7 +96,7 @@ const i = k, a = J, ie = s.object({
|
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
);
|
|
98
|
-
function
|
|
99
|
+
function Ae({
|
|
99
100
|
companyId: t,
|
|
100
101
|
contractorId: f,
|
|
101
102
|
defaultValues: m,
|
|
@@ -228,6 +229,6 @@ export {
|
|
|
228
229
|
a as ContractorType,
|
|
229
230
|
i as WageType,
|
|
230
231
|
re as createContractorProfileValidationSchema,
|
|
231
|
-
|
|
232
|
+
Ae as useContractorProfile
|
|
232
233
|
};
|
|
233
234
|
//# 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 type { ContractorCreateRequestBody } from '@gusto/embedded-api/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api/models/components/contractorupdaterequestbody'\nimport {\n ContractorWageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} 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'\nimport { SDKInternalError } from '@/types/sdkError'\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 selfOnboarding: z.boolean(),\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 = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !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 if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\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 if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\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 existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\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(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: 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 selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\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 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, unknown, 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 watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? 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 fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\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 let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: 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 contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\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 // 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\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\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","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,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,CACrD,GACAC,GACAC,MAEOL,GAAwB;AAAA,EAC7B,CAACM,GAAiCC,MAAyB;AAWzD,QATID,EAAK,kBAAkB,CAACA,EAAK,SAC/BC,EAAI,SAAS;AAAA,MACX,MAAMN,EAAE,aAAa;AAAA,MACrB,MAAM,CAAC,OAAO;AAAA,MACd,SAAS,EAAE,mBAAmB;AAAA,IAAA,CAC/B,GAICK,EAAK,mBAAmBR,EAAe;AAiBzC,UAhBKQ,EAAK,aAC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AgB1C,EAAe,cAAc,CAAC6C,GACnEmB,IAAqBtB,MAAgB1C,EAAe,YAAY,CAAC6C,GAGjEoB,IAAwB;AAAA,IAC5B,EAAE,OAAO,cAAc,OAAOjE,EAAe,WAAA;AAAA,IAC7C,EAAE,OAAO,YAAY,OAAOA,EAAe,SAAA;AAAA,EAAS,GAGhDkE,IAAkB;AAAA,IACtB,EAAE,OAAO,UAAU,OAAOpE,EAAS,OAAA;AAAA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;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 type { ContractorCreateRequestBody } from '@gusto/embedded-api/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api/models/components/contractorupdaterequestbody'\nimport {\n ContractorWageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} 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'\nimport { SDKInternalError } from '@/types/sdkError'\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 selfOnboarding: z.boolean(),\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 = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !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 if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\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 if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\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 existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\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(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: 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 selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\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 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, unknown, 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 watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? 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 fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\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 let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: 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 contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\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 // 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\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\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","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,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,CACrD,GACAC,GACAC,MAEOL,GAAwB;AAAA,EAC7B,CAACM,GAAiCC,MAAyB;AAWzD,QATID,EAAK,kBAAkB,CAACA,EAAK,SAC/BC,EAAI,SAAS;AAAA,MACX,MAAMN,EAAE,aAAa;AAAA,MACrB,MAAM,CAAC,OAAO;AAAA,MACd,SAAS,EAAE,mBAAmB;AAAA,IAAA,CAC/B,GAICK,EAAK,mBAAmBR,EAAe;AAi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S,QACpDiE,IAAqBrB,MAAgB1C,EAAe,cAAc,CAAC6C,GACnEmB,IAAqBtB,MAAgB1C,EAAe,YAAY,CAAC6C,GAGjEoB,IAAwB;AAAA,IAC5B,EAAE,OAAO,cAAc,OAAOjE,EAAe,WAAA;AAAA,IAC7C,EAAE,OAAO,YAAY,OAAOA,EAAe,SAAA;AAAA,EAAS,GAGhDkE,IAAkB;AAAA,IACtB,EAAE,OAAO,UAAU,OAAOpE,EAAS,OAAA;AAAA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
|
|
@@ -2,8 +2,8 @@ import { jsxs as A, jsx as i } from "react/jsx-runtime";
|
|
|
2
2
|
import { useFormContext as l, useWatch as d } from "react-hook-form";
|
|
3
3
|
import { useTranslation as T } from "react-i18next";
|
|
4
4
|
import { useCompensation as O } from "./useCompensation.js";
|
|
5
|
-
import { ActionsLayout as u } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
6
5
|
import { FlsaStatus as a } from "../../../shared/constants.js";
|
|
6
|
+
import { ActionsLayout as u } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
7
7
|
import { useComponentContext as C } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
8
8
|
const B = () => {
|
|
9
9
|
const { isPending: s, mode: t, submitWithEffect: o, handleAdd: D, handleCancelAddJob: I, primaryFlsaStatus: r } = O(), { t: n } = T("Employee.Compensation"), { control: m } = l(), c = d({ control: m, name: "flsaStatus" }), e = C();
|
|
@@ -3,11 +3,12 @@ import { useTranslation as p } from "react-i18next";
|
|
|
3
3
|
import { useCompensation as d } from "./useCompensation.js";
|
|
4
4
|
import C from "../../../assets/icons/pencil.svg.js";
|
|
5
5
|
import c from "../../../assets/icons/trashcan.svg.js";
|
|
6
|
+
import "../../../shared/constants.js";
|
|
6
7
|
import { HamburgerMenu as f } from "../../Common/HamburgerMenu/HamburgerMenu.js";
|
|
7
8
|
import { useDataView as y } from "../../Common/DataView/useDataView.js";
|
|
8
9
|
import { DataView as g } from "../../Common/DataView/DataView.js";
|
|
9
|
-
const
|
|
10
|
-
const { employeeJobs: i, mode: o, isPending:
|
|
10
|
+
const P = () => {
|
|
11
|
+
const { employeeJobs: i, mode: o, isPending: r, handleEdit: l, handleDelete: s } = d(), { t } = p("Employee.Compensation"), { ...m } = y({
|
|
11
12
|
data: i,
|
|
12
13
|
columns: [
|
|
13
14
|
{
|
|
@@ -45,7 +46,7 @@ const D = () => {
|
|
|
45
46
|
label: t("allCompensations.editCta"),
|
|
46
47
|
icon: /* @__PURE__ */ a(C, { "aria-hidden": !0 }),
|
|
47
48
|
onClick: () => {
|
|
48
|
-
|
|
49
|
+
l(e.uuid);
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
...e.primary ? [] : [
|
|
@@ -58,7 +59,7 @@ const D = () => {
|
|
|
58
59
|
}
|
|
59
60
|
]
|
|
60
61
|
],
|
|
61
|
-
isLoading:
|
|
62
|
+
isLoading: r
|
|
62
63
|
}
|
|
63
64
|
)
|
|
64
65
|
});
|
|
@@ -66,6 +67,6 @@ const D = () => {
|
|
|
66
67
|
return /* @__PURE__ */ a(g, { "data-testid": "data-view", label: t("allCompensations.tableLabel"), ...m });
|
|
67
68
|
};
|
|
68
69
|
export {
|
|
69
|
-
|
|
70
|
+
P as List
|
|
70
71
|
};
|
|
71
72
|
//# sourceMappingURL=List.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../src/components/Employee/Compensation/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useCompensation } from './useCompensation'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport { DataView, useDataView } from '@/components/Common'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { employeeJobs, mode, isPending, handleEdit, handleDelete } = useCompensation()\n const { t } = useTranslation('Employee.Compensation')\n\n const { ...dataViewProps } = useDataView({\n data: employeeJobs,\n columns: [\n {\n key: 'title',\n title: t('allCompensations.jobColumn'),\n render: (job: Job) => job.title || '',\n },\n {\n key: 'flsaStatus',\n title: t('allCompensations.typeColumn'),\n render: (job: Job) => {\n const flsaStatus = job.compensations?.find(\n comp => comp.uuid === job.currentCompensationUuid,\n )?.flsaStatus\n return flsaStatus !== undefined ? t(`flsaStatusLabels.${flsaStatus}`) : null\n },\n },\n {\n key: 'rate',\n title: t('allCompensations.amountColumn'),\n render: (job: Job) => job.rate?.toString() || '',\n },\n {\n key: 'paymentUnit',\n title: t('allCompensations.perColumn'),\n render: (job: Job) => job.paymentUnit || '',\n },\n ],\n itemMenu: (job: Job) => (\n <HamburgerMenu\n triggerLabel={t('hamburgerTitle')}\n items={[\n {\n label: t('allCompensations.editCta'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n handleEdit(job.uuid)\n },\n },\n ...(!job.primary\n ? [\n {\n label: t('allCompensations.deleteCta'),\n icon: <TrashCanSvg aria-hidden />,\n onClick: () => {\n handleDelete(job.uuid)\n },\n },\n ]\n : []),\n ]}\n isLoading={isPending}\n />\n ),\n })\n\n if (mode !== 'LIST') {\n return\n }\n\n return (\n <DataView data-testid=\"data-view\" label={t('allCompensations.tableLabel')} {...dataViewProps} />\n )\n}\n"],"names":["List","employeeJobs","mode","isPending","handleEdit","handleDelete","useCompensation","useTranslation","dataViewProps","useDataView","job","flsaStatus","comp","jsx","HamburgerMenu","PencilSvg","TrashCanSvg","DataView"],"mappings":"
|
|
1
|
+
{"version":3,"file":"List.js","sources":["../../../../src/components/Employee/Compensation/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useCompensation } from './useCompensation'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport { DataView, useDataView } from '@/components/Common'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\n\nexport const List = () => {\n const { employeeJobs, mode, isPending, handleEdit, handleDelete } = useCompensation()\n const { t } = useTranslation('Employee.Compensation')\n\n const { ...dataViewProps } = useDataView({\n data: employeeJobs,\n columns: [\n {\n key: 'title',\n title: t('allCompensations.jobColumn'),\n render: (job: Job) => job.title || '',\n },\n {\n key: 'flsaStatus',\n title: t('allCompensations.typeColumn'),\n render: (job: Job) => {\n const flsaStatus = job.compensations?.find(\n comp => comp.uuid === job.currentCompensationUuid,\n )?.flsaStatus\n return flsaStatus !== undefined ? t(`flsaStatusLabels.${flsaStatus}`) : null\n },\n },\n {\n key: 'rate',\n title: t('allCompensations.amountColumn'),\n render: (job: Job) => job.rate?.toString() || '',\n },\n {\n key: 'paymentUnit',\n title: t('allCompensations.perColumn'),\n render: (job: Job) => job.paymentUnit || '',\n },\n ],\n itemMenu: (job: Job) => (\n <HamburgerMenu\n triggerLabel={t('hamburgerTitle')}\n items={[\n {\n label: t('allCompensations.editCta'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n handleEdit(job.uuid)\n },\n },\n ...(!job.primary\n ? [\n {\n label: t('allCompensations.deleteCta'),\n icon: <TrashCanSvg aria-hidden />,\n onClick: () => {\n handleDelete(job.uuid)\n },\n },\n ]\n : []),\n ]}\n isLoading={isPending}\n />\n ),\n })\n\n if (mode !== 'LIST') {\n return\n }\n\n return (\n <DataView data-testid=\"data-view\" label={t('allCompensations.tableLabel')} {...dataViewProps} />\n )\n}\n"],"names":["List","employeeJobs","mode","isPending","handleEdit","handleDelete","useCompensation","useTranslation","dataViewProps","useDataView","job","flsaStatus","comp","jsx","HamburgerMenu","PencilSvg","TrashCanSvg","DataView"],"mappings":";;;;;;;;;AAQO,MAAMA,IAAO,MAAM;AACxB,QAAM,EAAE,cAAAC,GAAc,MAAAC,GAAM,WAAAC,GAAW,YAAAC,GAAY,cAAAC,EAAA,IAAiBC,EAAA,GAC9D,EAAE,EAAA,IAAMC,EAAe,uBAAuB,GAE9C,EAAE,GAAGC,EAAA,IAAkBC,EAAY;AAAA,IACvC,MAAMR;AAAA,IACN,SAAS;AAAA,MACP;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,4BAA4B;AAAA,QACrC,QAAQ,CAACS,MAAaA,EAAI,SAAS;AAAA,MAAA;AAAA,MAErC;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,6BAA6B;AAAA,QACtC,QAAQ,CAACA,MAAa;AACpB,gBAAMC,IAAaD,EAAI,eAAe;AAAA,YACpC,CAAAE,MAAQA,EAAK,SAASF,EAAI;AAAA,UAAA,GACzB;AACH,iBAAOC,MAAe,SAAY,EAAE,oBAAoBA,CAAU,EAAE,IAAI;AAAA,QAC1E;AAAA,MAAA;AAAA,MAEF;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,+BAA+B;AAAA,QACxC,QAAQ,CAACD,MAAaA,EAAI,MAAM,cAAc;AAAA,MAAA;AAAA,MAEhD;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,4BAA4B;AAAA,QACrC,QAAQ,CAACA,MAAaA,EAAI,eAAe;AAAA,MAAA;AAAA,IAC3C;AAAA,IAEF,UAAU,CAACA,MACT,gBAAAG;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,cAAc,EAAE,gBAAgB;AAAA,QAChC,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