@gusto/embedded-react-sdk 0.49.0 → 0.50.0
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 +26 -0
- package/dist/components/Base/createCompoundContext.d.ts +1 -1
- package/dist/components/Base/createCompoundContext.js.map +1 -1
- package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/components/Common/UI/CalendarPreview/CalendarLegend.d.ts +1 -1
- package/dist/components/Common/UI/CalendarPreview/CalendarLegend.js.map +1 -1
- package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
- package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +5 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +5 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +7 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +5 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +5 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/signCompanyFormSchema.d.ts +1 -0
- package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/signCompanyFormSchema.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +10 -8
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +8 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +5 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +5 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingFlow/OnboardingFlow.d.ts +1 -1
- package/dist/components/Company/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +5 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.d.ts +1 -0
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +5 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +5 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/contractorAddressSchema.d.ts +1 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/contractorAddressSchema.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.d.ts +38 -0
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -1
- package/dist/components/Contractor/Documents/DocumentsList/useContractorDocumentsList/useContractorDocumentsList.d.ts +1 -0
- package/dist/components/Contractor/Documents/DocumentsList/useContractorDocumentsList/useContractorDocumentsList.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.d.ts +3 -3
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.d.ts +5 -5
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +105 -108
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.module.scss.js +8 -0
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.module.scss.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/index.d.ts +2 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/fields.d.ts +93 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/fields.js +22 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/fields.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/index.d.ts +5 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/useContractorBankAccountForm.d.ts +127 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/useContractorBankAccountForm.js +109 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/useContractorBankAccountForm.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/useContractorBankAccountFormSchema.d.ts +83 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/useContractorBankAccountFormSchema.js +42 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/useContractorBankAccountFormSchema.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/contractorPaymentMethodSchema.d.ts +58 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/contractorPaymentMethodSchema.js +21 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/contractorPaymentMethodSchema.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/fields.d.ts +20 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/fields.js +9 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/fields.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/index.d.ts +5 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/useContractorPaymentMethodForm.d.ts +117 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/useContractorPaymentMethodForm.js +91 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorPaymentMethodForm/useContractorPaymentMethodForm.js.map +1 -0
- package/dist/components/Contractor/PaymentMethod/types.d.ts +0 -5
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.d.ts +2 -2
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlow.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.d.ts +1 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.d.ts +45 -0
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.d.ts +1 -0
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js.map +1 -1
- package/dist/components/Employee/Dashboard/DashboardFlow.d.ts +1 -1
- package/dist/components/Employee/Dashboard/DashboardFlow.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.d.ts +1 -0
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useDeductionForm/deductionFormSchema.d.ts +1 -0
- package/dist/components/Employee/Deductions/shared/useDeductionForm/deductionFormSchema.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +5 -3
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/Documents/shared/useSignEmployeeForm/signEmployeeFormSchema.d.ts +1 -0
- package/dist/components/Employee/Documents/shared/useSignEmployeeForm/signEmployeeFormSchema.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +2 -2
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +1 -1
- package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/federalTaxesSchema.d.ts +1 -0
- package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/federalTaxesSchema.js.map +1 -1
- package/dist/components/Employee/OnboardingExecutionFlow/OnboardingExecutionFlow.d.ts +2 -2
- package/dist/components/Employee/OnboardingExecutionFlow/OnboardingExecutionFlow.js.map +1 -1
- package/dist/components/Employee/OnboardingFlow/OnboardingFlow.d.ts +3 -3
- package/dist/components/Employee/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/useBankForm.d.ts +4 -4
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/useBankForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/useBankFormSchema.d.ts +1 -0
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/useBankFormSchema.js +7 -6
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/useBankFormSchema.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/usePaymentMethodForm/usePaymentMethodForm.d.ts +1 -1
- package/dist/components/Employee/PaymentMethod/shared/usePaymentMethodForm/usePaymentMethodForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/usePaymentMethodForm/usePaymentMethodFormSchema.d.ts +1 -0
- package/dist/components/Employee/PaymentMethod/shared/usePaymentMethodForm/usePaymentMethodFormSchema.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/useSplitPaymentsForm.d.ts +2 -2
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/useSplitPaymentsForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.d.ts +11 -12
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.d.ts +36 -0
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.d.ts +31 -0
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/workAddressSchema.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/workAddressSchema.js.map +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingFlow.d.ts +2 -2
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingFlow.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldProps.d.ts +36 -18
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.d.ts +113 -13
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/index.d.ts +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/useEmployeeStateTaxesForm.d.ts +2 -7
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/useEmployeeStateTaxesForm.js.map +1 -1
- package/dist/components/Flow/Flow.js +1 -1
- package/dist/components/InformationRequests/InformationRequests.d.ts +3 -3
- package/dist/components/InformationRequests/InformationRequests.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +10 -8
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/helpers/validations.d.ts +12 -0
- package/dist/helpers/validations.js +6 -4
- package/dist/helpers/validations.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +247 -237
- package/dist/index.js.map +1 -1
- package/dist/models/external.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/types/sdkError.js +13 -6
- package/dist/types/sdkError.js.map +1 -1
- package/package.json +7 -7
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.d.ts +0 -3
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +0 -56
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +0 -1
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.d.ts +0 -2
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +0 -33
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +0 -1
- /package/docs/{appendix → guides}/endpoint-inventory.json +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContractorDetailsForm.js","sources":["../../../../../../src/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Contractor } from '@gusto/embedded-api-v-2025-11-15/models/components/contractor'\nimport type { ContractorCreateRequestBody } from '@gusto/embedded-api-v-2025-11-15/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api-v-2025-11-15/models/components/contractorupdaterequestbody'\nimport { useContractorsGet } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsGet'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsUpdate'\nimport {\n ContractorType,\n WageType,\n createContractorDetailsSchema,\n type ContractorDetailsOptionalFieldsToRequire,\n type ContractorDetailsFormData,\n type ContractorDetailsFormOutputs,\n} from './contractorDetailsSchema'\nimport {\n TypeField,\n WageTypeField,\n StartDateField,\n HourlyRateField,\n SelfOnboardingField,\n FileNewHireReportField,\n EmailField,\n FirstNameField,\n LastNameField,\n MiddleInitialField,\n BusinessNameField,\n SsnField,\n EinField,\n WorkStateField,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport {\n ContractorSelfOnboardingStatuses,\n ContractorOnboardingStatus,\n STATES_ABBR,\n} from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\n\nexport type { ContractorDetailsOptionalFieldsToRequire } from './contractorDetailsSchema'\n\n/**\n * Optional overrides passed to {@link UseContractorDetailsFormReady.actions.onSubmit | onSubmit}.\n *\n * @public\n */\nexport interface ContractorDetailsSubmitOptions {\n /** Override the company identifier supplied to the hook (e.g. after creating the company in the same flow). Only used in create mode. */\n companyId?: string\n}\n\n/**\n * Shared options merged into both branches of {@link UseContractorDetailsFormProps}.\n *\n * @public\n */\nexport type UseContractorDetailsFormSharedProps = {\n /** Whether to expose the self-onboarding toggle as `form.Fields.SelfOnboarding`. Defaults to `true`. */\n withSelfOnboardingField?: boolean\n /** Fields that are optional by default but should be promoted to required for this form instance. */\n optionalFieldsToRequire?: ContractorDetailsOptionalFieldsToRequire\n /** Initial values applied before any contractor data loads. */\n defaultValues?: Partial<ContractorDetailsFormData>\n /** When validation runs. Forwarded to react-hook-form's `mode`. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Whether react-hook-form should focus the first error on validation failure. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Options for {@link useContractorDetailsForm}.\n *\n * @remarks\n * Discriminated by mode: in create mode supply `companyId` and omit\n * `contractorId`; in update mode supply `contractorId` (and optionally\n * `companyId`).\n *\n * @public\n */\nexport type UseContractorDetailsFormProps =\n | (UseContractorDetailsFormSharedProps & { companyId: string; contractorId?: never })\n | (UseContractorDetailsFormSharedProps & { contractorId: string; companyId?: string })\n\n/**\n * The Field components exposed by {@link useContractorDetailsForm} as `form.Fields`.\n *\n * @remarks\n * Conditionally-visible fields are `undefined` when they do not apply to the\n * current `type`, `wageType`, or self-onboarding selection. Always null-check\n * before rendering.\n *\n * @public\n */\nexport interface ContractorDetailsFields {\n /** Radio group bound to `type`. Always available. */\n Type: typeof TypeField\n /** Radio group bound to `wageType`. Always available. */\n WageType: typeof WageTypeField\n /** Date picker bound to `startDate`. Always available. */\n StartDate: typeof StartDateField\n /** Number input bound to `hourlyRate`; available only when `wageType` is `Hourly`. */\n HourlyRate: typeof HourlyRateField | undefined\n /** Switch bound to `selfOnboarding`; available only when toggleable. */\n SelfOnboarding: typeof SelfOnboardingField | undefined\n /** Switch bound to `fileNewHireReport`; available only for individual contractors. */\n FileNewHireReport: typeof FileNewHireReportField | undefined\n /** Text input bound to `email`; available only when self-onboarding is enabled. */\n Email: typeof EmailField | undefined\n /** Text input bound to `firstName`; available only for individual contractors. */\n FirstName: typeof FirstNameField | undefined\n /** Text input bound to `lastName`; available only for individual contractors. */\n LastName: typeof LastNameField | undefined\n /** Text input bound to `middleInitial`; available only for individual contractors. */\n MiddleInitial: typeof MiddleInitialField | undefined\n /** Text input bound to `businessName`; available only for business contractors. */\n BusinessName: typeof BusinessNameField | undefined\n /** Text input bound to `ssn`; available only for individual contractors. */\n Ssn: typeof SsnField | undefined\n /** Text input bound to `ein`; available only for business contractors. */\n Ein: typeof EinField | undefined\n /** Select bound to `workState`; available only for individual contractors filing a new-hire report. */\n WorkState: typeof WorkStateField | undefined\n}\n\n/**\n * The ready-state result returned by {@link useContractorDetailsForm} once data has loaded.\n *\n * @public\n */\nexport interface UseContractorDetailsFormReady extends BaseFormHookReady<\n FieldsMetadata,\n ContractorDetailsFormData,\n ContractorDetailsFields\n> {\n /** The loaded contractor data, or `null` in create mode. */\n data: {\n /** The contractor being edited, or `null` in create mode. */\n contractor: Contractor | null\n }\n /** Submit status and form mode. */\n status: {\n /** `true` while the create or update mutation is in flight. */\n isPending: boolean\n /** `'create'` when no `contractorId` was supplied, `'update'` otherwise. */\n mode: 'create' | 'update'\n }\n /** Submit and related actions. */\n actions: {\n /** Validates the form and submits the changes. Returns the created or updated contractor, or `undefined` when validation fails. */\n onSubmit: (\n options?: ContractorDetailsSubmitOptions,\n ) => Promise<HookSubmitResult<Contractor> | undefined>\n }\n}\n\nconst isCurrentlySelfOnboarding = (contractor?: Contractor) =>\n !!contractor?.onboardingStatus &&\n ContractorSelfOnboardingStatuses.has(contractor.onboardingStatus)\n\nconst canToggleSelfOnboarding = (contractor?: Contractor) => {\n if (!contractor) return true\n return (\n contractor.onboardingStatus === ContractorOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE ||\n contractor.onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_NOT_INVITED\n )\n}\n\n/**\n * Headless hook for creating or updating a contractor's profile details —\n * individual vs. business type, wage type, names, SSN/EIN, work state, and the\n * self-onboarding preference.\n *\n * @remarks\n * Returns a discriminated union: a loading variant while the contractor fetch\n * resolves, and a ready variant exposing the form's data, pending status,\n * submit action, error handling, and bound `Fields`. Field visibility is\n * driven by the current `type` and `wageType` (self-onboarding only toggles the\n * `Email` field); fields that do not apply are `undefined` on `form.Fields`.\n * SSN/EIN are exposed by contractor type regardless of self-onboarding — each\n * consumer decides whether to render them. Self-onboarding is only toggleable\n * when the contractor's onboarding status allows it.\n *\n * @param input - See {@link UseContractorDetailsFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseContractorDetailsFormReady} once ready.\n * @public\n */\nexport function useContractorDetailsForm({\n companyId,\n contractorId,\n withSelfOnboardingField = true,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseContractorDetailsFormProps): HookLoadingResult | UseContractorDetailsFormReady {\n const contractorQuery = useContractorsGet(\n { contractorUuid: contractorId ?? '' },\n { enabled: !!contractorId },\n )\n\n const contractor = contractorQuery.data?.contractor\n\n const isCreateMode = !contractorId\n const isSelfOnboardingToggleable = canToggleSelfOnboarding(contractor)\n\n const mode = isCreateMode ? 'create' : 'update'\n const hasSsn = contractor?.hasSsn ?? false\n const hasEin = contractor?.hasEin ?? false\n\n const [schema, metadataConfig] = useMemo(\n () => createContractorDetailsSchema({ mode, optionalFieldsToRequire, hasSsn, hasEin }),\n [mode, optionalFieldsToRequire, hasSsn, hasEin],\n )\n\n const parsedHourlyRate =\n contractor?.hourlyRate != null ? parseFloat(contractor.hourlyRate) : undefined\n\n const resolvedDefaults: ContractorDetailsFormData = useMemo(\n () => ({\n type: contractor?.type ?? partnerDefaults?.type ?? ContractorType.Individual,\n wageType: contractor?.wageType ?? partnerDefaults?.wageType ?? WageType.Fixed,\n startDate:\n contractor?.startDate ??\n partnerDefaults?.startDate ??\n new Date().toISOString().split('T')[0]!,\n hourlyRate: parsedHourlyRate ?? partnerDefaults?.hourlyRate ?? NaN,\n selfOnboarding: partnerDefaults?.selfOnboarding ?? isCurrentlySelfOnboarding(contractor),\n fileNewHireReport:\n contractor?.fileNewHireReport ?? partnerDefaults?.fileNewHireReport ?? false,\n email: contractor?.email ?? partnerDefaults?.email ?? '',\n firstName: contractor?.firstName ?? partnerDefaults?.firstName ?? '',\n lastName: contractor?.lastName ?? partnerDefaults?.lastName ?? '',\n middleInitial: contractor?.middleInitial ?? partnerDefaults?.middleInitial ?? '',\n businessName: contractor?.businessName ?? partnerDefaults?.businessName ?? '',\n workState: contractor?.workState ?? partnerDefaults?.workState ?? '',\n ssn: partnerDefaults?.ssn ?? '',\n ein: partnerDefaults?.ein ?? '',\n }),\n [contractor, partnerDefaults, parsedHourlyRate],\n )\n\n const formMethods = useForm<ContractorDetailsFormData, unknown, ContractorDetailsFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const [watchedType, watchedWageType, watchedSelfOnboarding, watchedFileNewHireReport] = useWatch({\n control: formMethods.control,\n name: ['type', 'wageType', 'selfOnboarding', 'fileNewHireReport'],\n })\n\n // Render-gating: a field shows when it applies to the current selection. The\n // schema mirrors this via `getExcludedContractorFields` so off-screen fields\n // never trip a phantom required error.\n const isIndividual = watchedType === ContractorType.Individual\n const isBusiness = watchedType === ContractorType.Business\n const isHourly = watchedWageType === WageType.Hourly\n\n const createContractorMutation = useContractorsCreateMutation()\n const updateContractorMutation = useContractorsUpdateMutation()\n\n const isPending = createContractorMutation.isPending || updateContractorMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('ContractorDetailsForm')\n\n const queries = contractorId ? [contractorQuery] : []\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n\n const typeEntries = [ContractorType.Individual, ContractorType.Business]\n const wageTypeEntries = [WageType.Hourly, WageType.Fixed]\n const fieldsMetadata = {\n ...baseMetadata,\n type: withOptions(\n baseMetadata.type,\n typeEntries.map(value => ({ value, label: value })),\n typeEntries,\n ),\n wageType: withOptions(\n baseMetadata.wageType,\n wageTypeEntries.map(value => ({ value, label: value })),\n wageTypeEntries,\n ),\n workState: withOptions(\n baseMetadata.workState,\n STATES_ABBR.map(abbr => ({ value: abbr, label: abbr })),\n STATES_ABBR,\n ),\n }\n\n const onSubmit = async (\n options?: ContractorDetailsSubmitOptions,\n ): Promise<HookSubmitResult<Contractor> | undefined> => {\n let submitResult: HookSubmitResult<Contractor> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: ContractorDetailsFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const selfOnboardingEnabled = payload.selfOnboarding\n const cleanedSsn = payload.ssn ? removeNonDigits(payload.ssn) : ''\n const cleanedEin = payload.ein ? removeNonDigits(payload.ein) : ''\n\n const requestBody: ContractorCreateRequestBody = {\n type: payload.type,\n wageType: payload.wageType,\n startDate: payload.startDate,\n selfOnboarding: selfOnboardingEnabled,\n email: selfOnboardingEnabled ? payload.email || undefined : undefined,\n hourlyRate:\n payload.wageType === WageType.Hourly ? String(payload.hourlyRate) : undefined,\n ...(payload.type === ContractorType.Individual\n ? {\n firstName: payload.firstName,\n lastName: payload.lastName,\n middleInitial: payload.middleInitial || undefined,\n fileNewHireReport: payload.fileNewHireReport,\n workState: payload.fileNewHireReport\n ? payload.workState || undefined\n : undefined,\n ssn: cleanedSsn || undefined,\n }\n : {\n fileNewHireReport: false,\n businessName: payload.businessName,\n ein: cleanedEin || undefined,\n }),\n }\n\n let savedContractor: Contractor\n\n if (isCreateMode) {\n const resolvedCompanyId = options?.companyId ?? companyId\n if (!resolvedCompanyId) {\n throw new SDKInternalError('companyId is required to create a contractor')\n }\n\n const result = await createContractorMutation.mutateAsync({\n request: {\n companyUuid: resolvedCompanyId,\n contractorCreateRequestBody: { ...requestBody, isActive: true },\n },\n })\n\n if (!result.contractor) {\n throw new SDKInternalError('Contractor creation failed')\n }\n\n savedContractor = result.contractor\n } else {\n if (!contractor?.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n\n const updateBody: ContractorUpdateRequestBody = {\n ...requestBody,\n version: contractor.version,\n }\n\n const result = await updateContractorMutation.mutateAsync({\n request: {\n contractorUuid: contractor.uuid,\n contractorUpdateRequestBody: updateBody,\n },\n })\n\n if (!result.contractor) {\n throw new SDKInternalError('Contractor update failed')\n }\n\n savedContractor = result.contractor\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: savedContractor,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading = contractorId ? contractorQuery.isLoading : false\n\n if (isDataLoading || (contractorId && !contractor)) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n contractor: contractor ?? null,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Type: TypeField,\n WageType: WageTypeField,\n StartDate: StartDateField,\n HourlyRate: isHourly ? HourlyRateField : undefined,\n SelfOnboarding:\n withSelfOnboardingField && isSelfOnboardingToggleable ? SelfOnboardingField : undefined,\n FileNewHireReport: isIndividual ? FileNewHireReportField : undefined,\n Email: watchedSelfOnboarding ? EmailField : undefined,\n FirstName: isIndividual ? FirstNameField : undefined,\n LastName: isIndividual ? LastNameField : undefined,\n MiddleInitial: isIndividual ? MiddleInitialField : undefined,\n BusinessName: isBusiness ? BusinessNameField : undefined,\n Ssn: isIndividual ? SsnField : undefined,\n Ein: isBusiness ? EinField : undefined,\n WorkState: isIndividual && watchedFileNewHireReport ? WorkStateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Return type of {@link useContractorDetailsForm}.\n *\n * @public\n */\nexport type UseContractorDetailsFormResult = HookLoadingResult | UseContractorDetailsFormReady\n\n/**\n * Shape of `form.fieldsMetadata` returned by {@link useContractorDetailsForm}.\n *\n * @public\n */\nexport type ContractorDetailsFieldsMetadata =\n UseContractorDetailsFormReady['form']['fieldsMetadata']\n\n/**\n * Shape of `form.Fields` returned by {@link useContractorDetailsForm}.\n *\n * @public\n */\nexport type ContractorDetailsFormFields = UseContractorDetailsFormReady['form']['Fields']\n"],"names":["isCurrentlySelfOnboarding","contractor","ContractorSelfOnboardingStatuses","canToggleSelfOnboarding","ContractorOnboardingStatus","useContractorDetailsForm","companyId","contractorId","withSelfOnboardingField","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","contractorQuery","useContractorsGet","isCreateMode","isSelfOnboardingToggleable","mode","hasSsn","hasEin","schema","metadataConfig","useMemo","createContractorDetailsSchema","parsedHourlyRate","resolvedDefaults","ContractorType","WageType","formMethods","useForm","zodResolver","watchedType","watchedWageType","watchedSelfOnboarding","watchedFileNewHireReport","useWatch","isIndividual","isBusiness","isHourly","createContractorMutation","useContractorsCreateMutation","updateContractorMutation","useContractorsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","typeEntries","wageTypeEntries","fieldsMetadata","withOptions","value","STATES_ABBR","abbr","onSubmit","options","submitResult","resolve","data","payload","selfOnboardingEnabled","cleanedSsn","removeNonDigits","cleanedEin","requestBody","savedContractor","resolvedCompanyId","SDKInternalError","result","updateBody","hookFormInternals","useHookFormInternals","TypeField","WageTypeField","StartDateField","HourlyRateField","SelfOnboardingField","FileNewHireReportField","EmailField","FirstNameField","LastNameField","MiddleInitialField","BusinessNameField","SsnField","EinField","WorkStateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;AA0KA,MAAMA,KAA4B,CAACC,MACjC,CAAC,CAACA,GAAY,oBACdC,GAAiC,IAAID,EAAW,gBAAgB,GAE5DE,KAA0B,CAACF,MAC1BA,IAEHA,EAAW,qBAAqBG,EAA2B,+BAC3DH,EAAW,qBAAqBG,EAA2B,8BAHr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AAY/C,KAAc;AAAA,IAAA;AAAA,IAE5B,QAAQ;AAAA,MACN,WAAA0C;AAAA,MACA,MAAM5B,IAAgB,WAAsB;AAAA,IAAA;AAAA,IAE9C,SAAS,EAAE,UAAA4C,GAAA;AAAA,IACX,eAAAX;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,MAAM6B;AAAA,QACN,UAAUC;AAAA,QACV,WAAWC;AAAA,QACX,YAAYzC,IAAW0C,KAAkB;AAAA,QACzC,gBACExE,KAA2BQ,IAA6BiE,KAAsB;AAAA,QAChF,mBAAmB7C,IAAe8C,KAAyB;AAAA,QAC3D,OAAOjD,IAAwBkD,KAAa;AAAA,QAC5C,WAAW/C,IAAegD,KAAiB;AAAA,QAC3C,UAAUhD,IAAeiD,KAAgB;AAAA,QACzC,eAAejD,IAAekD,KAAqB;AAAA,QACnD,cAAcjD,IAAakD,KAAoB;AAAA,QAC/C,KAAKnD,IAAeoD,KAAW;AAAA,QAC/B,KAAKnD,IAAaoD,KAAW;AAAA,QAC7B,WAAWrD,KAAgBF,IAA2BwD,KAAiB;AAAA,MAAA;AAAA,MAEzE,gBAAApC;AAAA,MACA,mBAAAqB;AAAA,MACA,yBAAyBgB,GAA8B/D,GAAaR,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useContractorDetailsForm.js","sources":["../../../../../../src/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Contractor } from '@gusto/embedded-api-v-2025-11-15/models/components/contractor'\nimport type { ContractorCreateRequestBody } from '@gusto/embedded-api-v-2025-11-15/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api-v-2025-11-15/models/components/contractorupdaterequestbody'\nimport { useContractorsGet } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsGet'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsUpdate'\nimport {\n ContractorType,\n WageType,\n createContractorDetailsSchema,\n type ContractorDetailsOptionalFieldsToRequire,\n type ContractorDetailsFormData,\n type ContractorDetailsFormOutputs,\n} from './contractorDetailsSchema'\nimport {\n TypeField,\n WageTypeField,\n StartDateField,\n HourlyRateField,\n SelfOnboardingField,\n FileNewHireReportField,\n EmailField,\n FirstNameField,\n LastNameField,\n MiddleInitialField,\n BusinessNameField,\n SsnField,\n EinField,\n WorkStateField,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport {\n ContractorSelfOnboardingStatuses,\n ContractorOnboardingStatus,\n STATES_ABBR,\n} from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\n\nexport type { ContractorDetailsOptionalFieldsToRequire } from './contractorDetailsSchema'\n\n/**\n * Optional overrides passed to {@link UseContractorDetailsFormReady.actions.onSubmit | onSubmit}.\n *\n * @public\n */\nexport interface ContractorDetailsSubmitOptions {\n /** Override the company identifier supplied to the hook (e.g. after creating the company in the same flow). Only used in create mode. */\n companyId?: string\n}\n\n/**\n * Shared options merged into both branches of {@link UseContractorDetailsFormProps}.\n *\n * @public\n */\nexport type UseContractorDetailsFormSharedProps = {\n /** Whether to expose the self-onboarding toggle as `form.Fields.SelfOnboarding`. Defaults to `true`. */\n withSelfOnboardingField?: boolean\n /** Fields that are optional by default but should be promoted to required for this form instance. */\n optionalFieldsToRequire?: ContractorDetailsOptionalFieldsToRequire\n /** Initial values applied before any contractor data loads. */\n defaultValues?: Partial<ContractorDetailsFormData>\n /** When validation runs. Forwarded to react-hook-form's `mode`. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Whether react-hook-form should focus the first error on validation failure. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Options for {@link useContractorDetailsForm}.\n *\n * @remarks\n * Discriminated by mode: in create mode supply `companyId` and omit\n * `contractorId`; in update mode supply `contractorId` (and optionally\n * `companyId`).\n *\n * @public\n */\nexport type UseContractorDetailsFormProps =\n | (UseContractorDetailsFormSharedProps & { companyId: string; contractorId?: never })\n | (UseContractorDetailsFormSharedProps & { contractorId: string; companyId?: string })\n\n/**\n * The Field components exposed by {@link useContractorDetailsForm} as `form.Fields`.\n *\n * @remarks\n * Conditionally-visible fields are `undefined` when they do not apply to the\n * current `type`, `wageType`, or self-onboarding selection. Always null-check\n * before rendering.\n *\n * @public\n */\nexport interface ContractorDetailsFields {\n /** Radio group bound to `type`. Always available. */\n Type: typeof TypeField\n /** Radio group bound to `wageType`. Always available. */\n WageType: typeof WageTypeField\n /** Date picker bound to `startDate`. Always available. */\n StartDate: typeof StartDateField\n /** Number input bound to `hourlyRate`; available only when `wageType` is `Hourly`. */\n HourlyRate: typeof HourlyRateField | undefined\n /** Switch bound to `selfOnboarding`; available only when toggleable. */\n SelfOnboarding: typeof SelfOnboardingField | undefined\n /** Switch bound to `fileNewHireReport`; available only for individual contractors. */\n FileNewHireReport: typeof FileNewHireReportField | undefined\n /** Text input bound to `email`; available only when self-onboarding is enabled. */\n Email: typeof EmailField | undefined\n /** Text input bound to `firstName`; available only for individual contractors. */\n FirstName: typeof FirstNameField | undefined\n /** Text input bound to `lastName`; available only for individual contractors. */\n LastName: typeof LastNameField | undefined\n /** Text input bound to `middleInitial`; available only for individual contractors. */\n MiddleInitial: typeof MiddleInitialField | undefined\n /** Text input bound to `businessName`; available only for business contractors. */\n BusinessName: typeof BusinessNameField | undefined\n /** Text input bound to `ssn`; available only for individual contractors. */\n Ssn: typeof SsnField | undefined\n /** Text input bound to `ein`; available only for business contractors. */\n Ein: typeof EinField | undefined\n /** Select bound to `workState`; available only for individual contractors filing a new-hire report. */\n WorkState: typeof WorkStateField | undefined\n}\n\n/**\n * The ready-state result returned by {@link useContractorDetailsForm} once data has loaded.\n *\n * @public\n */\nexport interface UseContractorDetailsFormReady extends BaseFormHookReady<\n FieldsMetadata,\n ContractorDetailsFormData,\n ContractorDetailsFields\n> {\n /** The loaded contractor data, or `null` in create mode. */\n data: {\n /** The contractor being edited, or `null` in create mode. */\n contractor: Contractor | null\n }\n /** Submit status and form mode. */\n status: {\n /** `true` while the create or update mutation is in flight. */\n isPending: boolean\n /** `'create'` when no `contractorId` was supplied, `'update'` otherwise. */\n mode: 'create' | 'update'\n }\n /** Submit and related actions. */\n actions: {\n /** Validates the form and submits the changes. Returns the created or updated contractor, or `undefined` when validation fails. */\n onSubmit: (\n options?: ContractorDetailsSubmitOptions,\n ) => Promise<HookSubmitResult<Contractor> | undefined>\n }\n}\n\nconst isCurrentlySelfOnboarding = (contractor?: Contractor) =>\n !!contractor?.onboardingStatus &&\n ContractorSelfOnboardingStatuses.has(contractor.onboardingStatus)\n\nconst canToggleSelfOnboarding = (contractor?: Contractor) => {\n if (!contractor) return true\n return (\n contractor.onboardingStatus === ContractorOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE ||\n contractor.onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_NOT_INVITED\n )\n}\n\n/**\n * Headless hook for creating or updating a contractor's profile details —\n * individual vs. business type, wage type, names, SSN/EIN, work state, and the\n * self-onboarding preference.\n *\n * @remarks\n * Returns a discriminated union: a loading variant while the contractor fetch\n * resolves, and a ready variant exposing the form's data, pending status,\n * submit action, error handling, and bound `Fields`. Field visibility is\n * driven by the current `type` and `wageType` (self-onboarding only toggles the\n * `Email` field); fields that do not apply are `undefined` on `form.Fields`.\n * SSN/EIN are exposed by contractor type regardless of self-onboarding — each\n * consumer decides whether to render them. Self-onboarding is only toggleable\n * when the contractor's onboarding status allows it.\n *\n * @param input - See {@link UseContractorDetailsFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseContractorDetailsFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * useContractorDetailsForm,\n * SDKFormProvider,\n * type UseContractorDetailsFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function ContractorDetailsPage({\n * companyId,\n * contractorId,\n * }: {\n * companyId: string\n * contractorId: string\n * }) {\n * const contractorDetails = useContractorDetailsForm({ companyId, contractorId })\n *\n * if (contractorDetails.isLoading) return <div>Loading...</div>\n *\n * return <ContractorDetailsReady contractorDetails={contractorDetails} />\n * }\n *\n * function ContractorDetailsReady({\n * contractorDetails,\n * }: {\n * contractorDetails: UseContractorDetailsFormReady\n * }) {\n * const { Fields } = contractorDetails.form\n *\n * return (\n * <SDKFormProvider formHookResult={contractorDetails}>\n * <form onSubmit={e => { e.preventDefault(); void contractorDetails.actions.onSubmit() }}>\n * <Fields.Type label=\"Contractor type\" />\n * <Fields.WageType label=\"Wage type\" />\n * {Fields.FirstName && <Fields.FirstName label=\"First name\" />}\n * {Fields.LastName && <Fields.LastName label=\"Last name\" />}\n * {Fields.BusinessName && <Fields.BusinessName label=\"Business name\" />}\n * <Fields.StartDate label=\"Start date\" />\n * <button type=\"submit\" disabled={contractorDetails.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useContractorDetailsForm({\n companyId,\n contractorId,\n withSelfOnboardingField = true,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseContractorDetailsFormProps): HookLoadingResult | UseContractorDetailsFormReady {\n const contractorQuery = useContractorsGet(\n { contractorUuid: contractorId ?? '' },\n { enabled: !!contractorId },\n )\n\n const contractor = contractorQuery.data?.contractor\n\n const isCreateMode = !contractorId\n const isSelfOnboardingToggleable = canToggleSelfOnboarding(contractor)\n\n const mode = isCreateMode ? 'create' : 'update'\n const hasSsn = contractor?.hasSsn ?? false\n const hasEin = contractor?.hasEin ?? false\n\n const [schema, metadataConfig] = useMemo(\n () => createContractorDetailsSchema({ mode, optionalFieldsToRequire, hasSsn, hasEin }),\n [mode, optionalFieldsToRequire, hasSsn, hasEin],\n )\n\n const parsedHourlyRate =\n contractor?.hourlyRate != null ? parseFloat(contractor.hourlyRate) : undefined\n\n const resolvedDefaults: ContractorDetailsFormData = useMemo(\n () => ({\n type: contractor?.type ?? partnerDefaults?.type ?? ContractorType.Individual,\n wageType: contractor?.wageType ?? partnerDefaults?.wageType ?? WageType.Fixed,\n startDate:\n contractor?.startDate ??\n partnerDefaults?.startDate ??\n new Date().toISOString().split('T')[0]!,\n hourlyRate: parsedHourlyRate ?? partnerDefaults?.hourlyRate ?? NaN,\n selfOnboarding: partnerDefaults?.selfOnboarding ?? isCurrentlySelfOnboarding(contractor),\n fileNewHireReport:\n contractor?.fileNewHireReport ?? partnerDefaults?.fileNewHireReport ?? false,\n email: contractor?.email ?? partnerDefaults?.email ?? '',\n firstName: contractor?.firstName ?? partnerDefaults?.firstName ?? '',\n lastName: contractor?.lastName ?? partnerDefaults?.lastName ?? '',\n middleInitial: contractor?.middleInitial ?? partnerDefaults?.middleInitial ?? '',\n businessName: contractor?.businessName ?? partnerDefaults?.businessName ?? '',\n workState: contractor?.workState ?? partnerDefaults?.workState ?? '',\n ssn: partnerDefaults?.ssn ?? '',\n ein: partnerDefaults?.ein ?? '',\n }),\n [contractor, partnerDefaults, parsedHourlyRate],\n )\n\n const formMethods = useForm<ContractorDetailsFormData, unknown, ContractorDetailsFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const [watchedType, watchedWageType, watchedSelfOnboarding, watchedFileNewHireReport] = useWatch({\n control: formMethods.control,\n name: ['type', 'wageType', 'selfOnboarding', 'fileNewHireReport'],\n })\n\n // Render-gating: a field shows when it applies to the current selection. The\n // schema mirrors this via `getExcludedContractorFields` so off-screen fields\n // never trip a phantom required error.\n const isIndividual = watchedType === ContractorType.Individual\n const isBusiness = watchedType === ContractorType.Business\n const isHourly = watchedWageType === WageType.Hourly\n\n const createContractorMutation = useContractorsCreateMutation()\n const updateContractorMutation = useContractorsUpdateMutation()\n\n const isPending = createContractorMutation.isPending || updateContractorMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('ContractorDetailsForm')\n\n const queries = contractorId ? [contractorQuery] : []\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n\n const typeEntries = [ContractorType.Individual, ContractorType.Business]\n const wageTypeEntries = [WageType.Hourly, WageType.Fixed]\n const fieldsMetadata = {\n ...baseMetadata,\n type: withOptions(\n baseMetadata.type,\n typeEntries.map(value => ({ value, label: value })),\n typeEntries,\n ),\n wageType: withOptions(\n baseMetadata.wageType,\n wageTypeEntries.map(value => ({ value, label: value })),\n wageTypeEntries,\n ),\n workState: withOptions(\n baseMetadata.workState,\n STATES_ABBR.map(abbr => ({ value: abbr, label: abbr })),\n STATES_ABBR,\n ),\n }\n\n const onSubmit = async (\n options?: ContractorDetailsSubmitOptions,\n ): Promise<HookSubmitResult<Contractor> | undefined> => {\n let submitResult: HookSubmitResult<Contractor> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: ContractorDetailsFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const selfOnboardingEnabled = payload.selfOnboarding\n const cleanedSsn = payload.ssn ? removeNonDigits(payload.ssn) : ''\n const cleanedEin = payload.ein ? removeNonDigits(payload.ein) : ''\n\n const requestBody: ContractorCreateRequestBody = {\n type: payload.type,\n wageType: payload.wageType,\n startDate: payload.startDate,\n selfOnboarding: selfOnboardingEnabled,\n email: selfOnboardingEnabled ? payload.email || undefined : undefined,\n hourlyRate:\n payload.wageType === WageType.Hourly ? String(payload.hourlyRate) : undefined,\n ...(payload.type === ContractorType.Individual\n ? {\n firstName: payload.firstName,\n lastName: payload.lastName,\n middleInitial: payload.middleInitial || undefined,\n fileNewHireReport: payload.fileNewHireReport,\n workState: payload.fileNewHireReport\n ? payload.workState || undefined\n : undefined,\n ssn: cleanedSsn || undefined,\n }\n : {\n fileNewHireReport: false,\n businessName: payload.businessName,\n ein: cleanedEin || undefined,\n }),\n }\n\n let savedContractor: Contractor\n\n if (isCreateMode) {\n const resolvedCompanyId = options?.companyId ?? companyId\n if (!resolvedCompanyId) {\n throw new SDKInternalError('companyId is required to create a contractor')\n }\n\n const result = await createContractorMutation.mutateAsync({\n request: {\n companyUuid: resolvedCompanyId,\n contractorCreateRequestBody: { ...requestBody, isActive: true },\n },\n })\n\n if (!result.contractor) {\n throw new SDKInternalError('Contractor creation failed')\n }\n\n savedContractor = result.contractor\n } else {\n if (!contractor?.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n\n const updateBody: ContractorUpdateRequestBody = {\n ...requestBody,\n version: contractor.version,\n }\n\n const result = await updateContractorMutation.mutateAsync({\n request: {\n contractorUuid: contractor.uuid,\n contractorUpdateRequestBody: updateBody,\n },\n })\n\n if (!result.contractor) {\n throw new SDKInternalError('Contractor update failed')\n }\n\n savedContractor = result.contractor\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: savedContractor,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading = contractorId ? contractorQuery.isLoading : false\n\n if (isDataLoading || (contractorId && !contractor)) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n contractor: contractor ?? null,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Type: TypeField,\n WageType: WageTypeField,\n StartDate: StartDateField,\n HourlyRate: isHourly ? HourlyRateField : undefined,\n SelfOnboarding:\n withSelfOnboardingField && isSelfOnboardingToggleable ? SelfOnboardingField : undefined,\n FileNewHireReport: isIndividual ? FileNewHireReportField : undefined,\n Email: watchedSelfOnboarding ? EmailField : undefined,\n FirstName: isIndividual ? FirstNameField : undefined,\n LastName: isIndividual ? LastNameField : undefined,\n MiddleInitial: isIndividual ? MiddleInitialField : undefined,\n BusinessName: isBusiness ? BusinessNameField : undefined,\n Ssn: isIndividual ? SsnField : undefined,\n Ein: isBusiness ? EinField : undefined,\n WorkState: isIndividual && watchedFileNewHireReport ? WorkStateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Return type of {@link useContractorDetailsForm}.\n *\n * @public\n */\nexport type UseContractorDetailsFormResult = HookLoadingResult | UseContractorDetailsFormReady\n\n/**\n * Shape of `form.fieldsMetadata` returned by {@link useContractorDetailsForm}.\n *\n * @public\n */\nexport type ContractorDetailsFieldsMetadata =\n UseContractorDetailsFormReady['form']['fieldsMetadata']\n\n/**\n * Shape of `form.Fields` returned by {@link useContractorDetailsForm}.\n *\n * @public\n */\nexport type ContractorDetailsFormFields = UseContractorDetailsFormReady['form']['Fields']\n"],"names":["isCurrentlySelfOnboarding","contractor","ContractorSelfOnboardingStatuses","canToggleSelfOnboarding","ContractorOnboardingStatus","useContractorDetailsForm","companyId","contractorId","withSelfOnboardingField","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","contractorQuery","useContractorsGet","isCreateMode","isSelfOnboardingToggleable","mode","hasSsn","hasEin","schema","metadataConfig","useMemo","createContractorDetailsSchema","parsedHourlyRate","resolvedDefaults","ContractorType","WageType","formMethods","useForm","zodResolver","watchedType","watchedWageType","watchedSelfOnboarding","watchedFileNewHireReport","useWatch","isIndividual","isBusiness","isHourly","createContractorMutation","useContractorsCreateMutation","updateContractorMutation","useContractorsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","typeEntries","wageTypeEntries","fieldsMetadata","withOptions","value","STATES_ABBR","abbr","onSubmit","options","submitResult","resolve","data","payload","selfOnboardingEnabled","cleanedSsn","removeNonDigits","cleanedEin","requestBody","savedContractor","resolvedCompanyId","SDKInternalError","result","updateBody","hookFormInternals","useHookFormInternals","TypeField","WageTypeField","StartDateField","HourlyRateField","SelfOnboardingField","FileNewHireReportField","EmailField","FirstNameField","LastNameField","MiddleInitialField","BusinessNameField","SsnField","EinField","WorkStateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;AA0KA,MAAMA,KAA4B,CAACC,MACjC,CAAC,CAACA,GAAY,oBACdC,GAAiC,IAAID,EAAW,gBAAgB,GAE5DE,KAA0B,CAACF,MAC1BA,IAEHA,EAAW,qBAAqBG,EAA2B,+BAC3DH,EAAW,qBAAqBG,EAA2B,8BAHrC;AAuEnB,SAASC,GAAyB;AAAA,EACvC,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,yBAAAC,IAA0B;AAAA,EAC1B,yBAAAC;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAAqF;AACnF,QAAMC,IAAkBC;AAAA,IACtB,EAAE,gBAAgBP,KAAgB,GAAA;AAAA,IAClC,EAAE,SAAS,CAAC,CAACA,EAAA;AAAA,EAAa,GAGtBN,IAAaY,EAAgB,MAAM,YAEnCE,IAAe,CAACR,GAChBS,IAA6Bb,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;AAAA,QAC3D,OAAOjD,IAAwBkD,KAAa;AAAA,QAC5C,WAAW/C,IAAegD,KAAiB;AAAA,QAC3C,UAAUhD,IAAeiD,KAAgB;AAAA,QACzC,eAAejD,IAAekD,KAAqB;AAAA,QACnD,cAAcjD,IAAakD,KAAoB;AAAA,QAC/C,KAAKnD,IAAeoD,KAAW;AAAA,QAC/B,KAAKnD,IAAaoD,KAAW;AAAA,QAC7B,WAAWrD,KAAgBF,IAA2BwD,KAAiB;AAAA,MAAA;AAAA,MAEzE,gBAAApC;AAAA,MACA,mBAAAqB;AAAA,MACA,yBAAyBgB,GAA8B/D,GAAaR,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compensationSchema.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n type OptionalFieldsToRequire,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN, coerceToISODate } from '@/partner-hook-utils/form/preprocessors'\nimport { FLSA_OVERTIME_SALARY_LIMIT, FlsaStatus, PAY_PERIODS } from '@/shared/constants'\nimport { yearlyRate } from '@/helpers/payRateCalculator'\n\n/**\n * Validation error codes produced by the {@link useCompensationForm} schema.\n *\n * @remarks\n * Use these constants as the keys in a field's `validationMessages` prop to\n * map an error code to a user-facing message.\n *\n * | Code | When it triggers |\n * | ---- | ---------------- |\n * | `REQUIRED` | A required field is empty (per mode and `optionalFieldsToRequire`). |\n * | `RATE_MINIMUM` | `rate` is less than `$1.00` for non-commission FLSA statuses. |\n * | `RATE_EXEMPT_THRESHOLD` | FLSA `Exempt` employees must clear the federal salary threshold (annualized). |\n * | `PAYMENT_UNIT_OWNER` | `Owner` FLSA status requires `paymentUnit === 'Paycheck'`. |\n * | `PAYMENT_UNIT_COMMISSION` | Commission-only FLSA statuses require `paymentUnit === 'Year'`. |\n * | `RATE_COMMISSION_ZERO` | Commission-only FLSA statuses require `rate === 0`. |\n * | `EFFECTIVE_DATE_BEFORE_HIRE` | `effectiveDate` precedes the parent job's `hireDate`. |\n * | `EFFECTIVE_DATE_BEFORE_MIN` | `effectiveDate` precedes the caller-supplied minimum (typically tomorrow). |\n *\n * @public\n *\n * @example\n * ```tsx\n * import { CompensationErrorCodes } from '@gusto/embedded-react-sdk'\n *\n * <Fields.Rate\n * label=\"Compensation amount\"\n * validationMessages={{\n * [CompensationErrorCodes.REQUIRED]: 'Amount is required',\n * [CompensationErrorCodes.RATE_MINIMUM]: 'Amount must be at least $1.00',\n * [CompensationErrorCodes.RATE_EXEMPT_THRESHOLD]: 'Exempt employees must meet the salary threshold',\n * }}\n * />\n * ```\n */\nexport const CompensationErrorCodes = {\n REQUIRED: 'REQUIRED',\n RATE_MINIMUM: 'RATE_MINIMUM',\n RATE_EXEMPT_THRESHOLD: 'RATE_EXEMPT_THRESHOLD',\n PAYMENT_UNIT_OWNER: 'PAYMENT_UNIT_OWNER',\n PAYMENT_UNIT_COMMISSION: 'PAYMENT_UNIT_COMMISSION',\n RATE_COMMISSION_ZERO: 'RATE_COMMISSION_ZERO',\n EFFECTIVE_DATE_BEFORE_HIRE: 'EFFECTIVE_DATE_BEFORE_HIRE',\n EFFECTIVE_DATE_BEFORE_MIN: 'EFFECTIVE_DATE_BEFORE_MIN',\n} as const\n\n/**\n * Union of every error code produced by the {@link useCompensationForm} schema.\n *\n * @public\n */\nexport type CompensationErrorCode =\n (typeof CompensationErrorCodes)[keyof typeof CompensationErrorCodes]\n\nconst fieldValidators = {\n /**\n * Optional in both modes. Setting title here scopes the change to this\n * compensation's `effectiveDate` — pair it with a future-dated comp to\n * schedule a promotion title alongside a rate change. Use\n * `useJobForm.Fields.Title` instead when creating a job (title is required\n * by the API on job creation) or when renaming the active role\n * immediately, and avoid rendering both fields on the same screen.\n */\n title: z.string(),\n // `flsaStatus` is `.optional()` so the field can render an empty placeholder\n // until the user (or partner default) picks one. Requiredness is still\n // enforced via `requiredFieldsConfig` on submit in `create` mode.\n flsaStatus: z\n .enum([\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n ])\n .optional(),\n paymentUnit: z.enum([\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n ]),\n rate: z.preprocess(coerceNaN(0), z.number()),\n /**\n * The effective date a new compensation should take effect on.\n *\n * - **create mode (`compensationId` absent)**: required; partners typically default\n * to the parent job's `hireDate` (onboarding stub-fill) or a future date\n * (rate change). Must be on or after `hireDate`. Server-side this maps to\n * POST /v1/jobs/:jobId/compensations.\n * - **update mode (`compensationId` present)**: optional; if omitted the API\n * keeps the existing effective date. The `hireDate` lower bound is **not**\n * enforced — loaded values may legitimately predate the hire date. Maps to\n * PUT /v1/compensations/:id.\n */\n effectiveDate: z.preprocess(coerceToISODate, z.iso.date().nullable()),\n adjustForMinimumWage: z.boolean(),\n minimumWageId: z.string(),\n}\n\n/**\n * Shape of the form values managed by {@link useCompensationForm}.\n *\n * @remarks\n * Accepted as `defaultValues` on `useCompensationForm` and returned by\n * `form.getFormSubmissionValues()` once the form has validated. `effectiveDate`\n * is an ISO date string (`YYYY-MM-DD`) or `null`; `flsaStatus` is optional so\n * the field can render an empty placeholder when nothing is preselected\n * (requiredness is enforced on submit per mode).\n *\n * @public\n */\nexport type CompensationFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n\nconst requiredFieldsConfig = {\n title: 'never',\n flsaStatus: 'create',\n paymentUnit: 'create',\n rate: 'create',\n effectiveDate: 'create',\n minimumWageId: data => data.adjustForMinimumWage,\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\nfunction validateFlsaRules(data: CompensationFormData, ctx: z.RefinementCtx) {\n const { flsaStatus, paymentUnit, rate } = data\n\n if (\n flsaStatus === FlsaStatus.EXEMPT ||\n flsaStatus === FlsaStatus.SALARIED_NONEXEMPT ||\n flsaStatus === FlsaStatus.NONEXEMPT\n ) {\n // Surface the EXEMPT salary-threshold issue *before* the generic minimum,\n // so a partner setting rate=0 with EXEMPT sees the more actionable\n // \"must meet salary threshold\" message rather than the generic\n // \"amount must be at least $1.00\".\n if (\n flsaStatus === FlsaStatus.EXEMPT &&\n yearlyRate(rate, paymentUnit) < FLSA_OVERTIME_SALARY_LIMIT\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_EXEMPT_THRESHOLD,\n })\n } else if (rate < 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_MINIMUM,\n })\n }\n } else if (flsaStatus === FlsaStatus.OWNER) {\n if (paymentUnit !== PAY_PERIODS.PAYCHECK) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['paymentUnit'],\n message: CompensationErrorCodes.PAYMENT_UNIT_OWNER,\n })\n }\n if (rate < 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_MINIMUM,\n })\n }\n } else if (\n flsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT ||\n flsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT\n ) {\n if (paymentUnit !== PAY_PERIODS.YEAR) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['paymentUnit'],\n message: CompensationErrorCodes.PAYMENT_UNIT_COMMISSION,\n })\n }\n if (rate !== 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_COMMISSION_ZERO,\n })\n }\n }\n}\n\n/**\n * Override which fields are required on a given submission mode of {@link useCompensationForm}.\n *\n * @remarks\n * Each mode key lists the fields that are optional by default for that mode\n * but should be promoted to required. `adjustForMinimumWage` is always\n * required and `minimumWageId` is automatically required when\n * `adjustForMinimumWage` is `true` — neither is configurable here.\n *\n * | Field | Required on create | Required on update | Configurable? |\n * | ----- | ------------------ | ------------------ | ------------- |\n * | `flsaStatus` | Yes | No | Yes (on update) |\n * | `paymentUnit` | Yes | No | Yes (on update) |\n * | `rate` | Yes | No | Yes (on update) |\n * | `effectiveDate` | Yes | No | Yes (on update) |\n * | `title` | No | No | Yes (either mode) |\n * | `adjustForMinimumWage` | Yes | Yes | No |\n * | `minimumWageId` | When toggle is on | When toggle is on | No |\n *\n * @public\n *\n * @example\n * ```tsx\n * const compensation = useCompensationForm({\n * employeeId,\n * jobId,\n * compensationId,\n * optionalFieldsToRequire: {\n * update: ['title', 'rate'],\n * },\n * })\n * ```\n */\nexport type CompensationOptionalFieldsToRequire = OptionalFieldsToRequire<\n typeof requiredFieldsConfig\n>\n\n/**\n * Validated submission shape produced by the {@link useCompensationForm} schema.\n *\n * @remarks\n * Identical to {@link CompensationFormData} — exposed as a separate alias so\n * the input vs. output sides of the schema remain distinguishable in advanced\n * usages.\n *\n * @public\n */\nexport type CompensationFormOutputs = CompensationFormData\n\n/** @internal */\nexport interface CompensationSchemaOptions {\n /** Selects required-field rules: `'create'` (POST) or `'update'` (PUT). Defaults to `'create'`. */\n mode?: 'create' | 'update'\n /** Promote default-optional fields to required for the selected mode. See {@link CompensationOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n /**\n * Lower bound for `effectiveDate` (typically the parent job's `hireDate`).\n * Only enforced in `create` mode — on `update` the loaded effective date\n * may legitimately predate the hire date and is left as-is. Surfaces an\n * `EFFECTIVE_DATE_BEFORE_HIRE` issue when violated.\n */\n hireDate?: string | null\n /**\n * Absolute lower bound for `effectiveDate`, enforced in both create and\n * update modes whenever provided. Typically `addDays(today, 1)` (tomorrow)\n * for management screens where effective dates must be in the future, or\n * `max(tomorrow, hireDate)` for secondary new jobs. Surfaces an\n * `EFFECTIVE_DATE_BEFORE_MIN` issue when violated.\n *\n * **Callers must only pass this when the carve-out cannot fire.** The\n * carve-out (`willDeleteSecondaryJobs` in update mode) forces `effectiveDate`\n * to today on a disabled field — passing `minEffectiveDate` for a primary\n * job in update mode would cause a spurious validation failure on submit.\n * Secondary jobs are safe because their FLSA field is hidden, preventing the\n * carve-out from activating.\n */\n minEffectiveDate?: string | null\n /**\n * When `false`, drops `effectiveDate` from the validated shape — the field\n * becomes hook-managed (e.g. seeded from the parent job's `hireDate` during\n * onboarding). Partners may still supply the value at submit time via\n * `CompensationSubmitOptions.effectiveDate`. Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\n/** @internal */\nexport function createCompensationSchema(options: CompensationSchemaOptions = {}) {\n const {\n mode = 'create',\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate,\n withEffectiveDateField = true,\n } = options\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: CompensationErrorCodes.REQUIRED,\n mode,\n optionalFieldsToRequire,\n excludeFields: withEffectiveDateField ? [] : ['effectiveDate'],\n superRefine: (data, ctx) => {\n validateFlsaRules(data, ctx)\n // Enforce the hire-date lower bound in create mode always, and in\n // update mode when `minEffectiveDate` is also set (management screens\n // where the user is actively picking a new date). On plain update\n // without `minEffectiveDate`, the loaded effectiveDate can legitimately\n // predate the hire date (stub or out-of-order data) and the API\n // accepts the unchanged value — blocking the submit would trap\n // partners whose flow doesn't render Fields.EffectiveDate.\n // When `withEffectiveDateField` is false the field is excluded from\n // the shape and `data.effectiveDate` is undefined — this check\n // naturally short-circuits.\n if (\n hireDate &&\n data.effectiveDate &&\n data.effectiveDate < hireDate &&\n (mode === 'create' || minEffectiveDate)\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['effectiveDate'],\n message: CompensationErrorCodes.EFFECTIVE_DATE_BEFORE_HIRE,\n })\n }\n // Enforce the caller-supplied minimum effective date in both modes.\n // Callers must only pass this when the carve-out cannot fire (see\n // CompensationSchemaOptions.minEffectiveDate for details).\n if (minEffectiveDate && data.effectiveDate && data.effectiveDate < minEffectiveDate) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['effectiveDate'],\n message: CompensationErrorCodes.EFFECTIVE_DATE_BEFORE_MIN,\n })\n }\n },\n })\n}\n"],"names":["CompensationErrorCodes","fieldValidators","z","FlsaStatus","PAY_PERIODS","coerceNaN","coerceToISODate","requiredFieldsConfig","data","validateFlsaRules","ctx","flsaStatus","paymentUnit","rate","yearlyRate","FLSA_OVERTIME_SALARY_LIMIT","createCompensationSchema","options","mode","optionalFieldsToRequire","hireDate","minEffectiveDate","withEffectiveDateField","buildFormSchema"],"mappings":";;;;;AA4CO,MAAMA,IAAyB;AAAA,EACpC,UAAU;AAAA,EACV,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,4BAA4B;AAAA,EAC5B,2BAA2B;AAC7B,GAUMC,IAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAStB,OAAOC,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA,EAIT,YAAYA,EACT,KAAK;AAAA,IACJC,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,EAAA,CACZ,EACA,SAAA;AAAA,EACH,aAAaD,EAAE,KAAK;AAAA,IAClBE,EAAY;AAAA,IACZA,EAAY;AAAA,IACZA,EAAY;AAAA,IACZA,EAAY;AAAA,IACZA,EAAY;AAAA,EAAA,CACb;AAAA,EACD,MAAMF,EAAE,WAAWG,EAAU,CAAC,GAAGH,EAAE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SAAS;AAAA,IACX,MAAMR,EAAE,aAAa;AAAA,IACrB,MAAM,CAAC,aAAa;AAAA,IACpB,SAASF,EAAuB;AAAA,EAAA,CACjC,GAECa,MAAS,KACXH,EAAI,SAAS;AAAA,IACX,MAAMR,EAAE,aAAa;AAAA,IACrB,MAAM,CAAC,MAAM;AAAA,IACb,SAASF,EAAuB;AAAA,EAAA,CACjC;AAGP;AAyFO,SAASgB,EAAyBC,IAAqC,IAAI;AAChF,QAAM;AAAA,IACJ,MAAAC,IAAO;AAAA,IACP,yBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,wBAAAC,IAAyB;AAAA,EAAA,IACvBL;AAEJ,SAAOM,EAAgBtB,GAAiB;AAAA,IACtC,sBAAAM;AAAA,IACA,mBAAmBP,EAAuB;AAAA,IAC1C,MAAAkB;AAAA,IACA,yBAAAC;AAAA,IACA,eAAeG,IAAyB,KAAK,CAAC,eAAe;AAAA,IAC7D,aAAa,CAACd,GAAME,MAAQ;AAC1B,MAAAD,EAAkBD,GAAME,CAAG,GAYzBU,KACAZ,EAAK,iBACLA,EAAK,gBAAgBY,MACpBF,MAAS,YAAYG,MAEtBX,EAAI,SAAS;AAAA,QACX,MAAMR,EAAE,aAAa;AAAA,QACrB,MAAM,CAAC,eAAe;AAAA,QACtB,SAASF,EAAuB;AAAA,MAAA,CACjC,GAKCqB,KAAoBb,EAAK,iBAAiBA,EAAK,gBAAgBa,KACjEX,EAAI,SAAS;AAAA,QACX,MAAMR,EAAE,aAAa;AAAA,QACrB,MAAM,CAAC,eAAe;AAAA,QACtB,SAASF,EAAuB;AAAA,MAAA,CACjC;AAAA,IAEL;AAAA,EAAA,CACD;AACH;"}
|
|
1
|
+
{"version":3,"file":"compensationSchema.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n type OptionalFieldsToRequire,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN, coerceToISODate } from '@/partner-hook-utils/form/preprocessors'\nimport { FLSA_OVERTIME_SALARY_LIMIT, FlsaStatus, PAY_PERIODS } from '@/shared/constants'\nimport { yearlyRate } from '@/helpers/payRateCalculator'\n\n/**\n * Validation error codes produced by the {@link useCompensationForm} schema.\n *\n * @remarks\n * Use these constants as the keys in a field's `validationMessages` prop to\n * map an error code to a user-facing message.\n *\n * | Code | When it triggers |\n * | ---- | ---------------- |\n * | `REQUIRED` | A required field is empty (per mode and `optionalFieldsToRequire`). |\n * | `RATE_MINIMUM` | `rate` is less than `$1.00` for non-commission FLSA statuses. |\n * | `RATE_EXEMPT_THRESHOLD` | FLSA `Exempt` employees must clear the federal salary threshold (annualized). |\n * | `PAYMENT_UNIT_OWNER` | `Owner` FLSA status requires `paymentUnit === 'Paycheck'`. |\n * | `PAYMENT_UNIT_COMMISSION` | Commission-only FLSA statuses require `paymentUnit === 'Year'`. |\n * | `RATE_COMMISSION_ZERO` | Commission-only FLSA statuses require `rate === 0`. |\n * | `EFFECTIVE_DATE_BEFORE_HIRE` | `effectiveDate` precedes the parent job's `hireDate`. |\n * | `EFFECTIVE_DATE_BEFORE_MIN` | `effectiveDate` precedes the caller-supplied minimum (typically tomorrow). |\n *\n * @public\n *\n * @example\n * ```tsx\n * import { CompensationErrorCodes } from '@gusto/embedded-react-sdk'\n *\n * <Fields.Rate\n * label=\"Compensation amount\"\n * validationMessages={{\n * [CompensationErrorCodes.REQUIRED]: 'Amount is required',\n * [CompensationErrorCodes.RATE_MINIMUM]: 'Amount must be at least $1.00',\n * [CompensationErrorCodes.RATE_EXEMPT_THRESHOLD]: 'Exempt employees must meet the salary threshold',\n * }}\n * />\n * ```\n */\nexport const CompensationErrorCodes = {\n REQUIRED: 'REQUIRED',\n RATE_MINIMUM: 'RATE_MINIMUM',\n RATE_EXEMPT_THRESHOLD: 'RATE_EXEMPT_THRESHOLD',\n PAYMENT_UNIT_OWNER: 'PAYMENT_UNIT_OWNER',\n PAYMENT_UNIT_COMMISSION: 'PAYMENT_UNIT_COMMISSION',\n RATE_COMMISSION_ZERO: 'RATE_COMMISSION_ZERO',\n EFFECTIVE_DATE_BEFORE_HIRE: 'EFFECTIVE_DATE_BEFORE_HIRE',\n EFFECTIVE_DATE_BEFORE_MIN: 'EFFECTIVE_DATE_BEFORE_MIN',\n} as const\n\n/**\n * Union of every error code produced by the {@link useCompensationForm} schema.\n *\n * @public\n */\nexport type CompensationErrorCode =\n (typeof CompensationErrorCodes)[keyof typeof CompensationErrorCodes]\n\nconst fieldValidators = {\n /**\n * Optional in both modes. Setting title here scopes the change to this\n * compensation's `effectiveDate` — pair it with a future-dated comp to\n * schedule a promotion title alongside a rate change. Use\n * `useJobForm.Fields.Title` instead when creating a job (title is required\n * by the API on job creation) or when renaming the active role\n * immediately, and avoid rendering both fields on the same screen.\n */\n title: z.string(),\n // `flsaStatus` is `.optional()` so the field can render an empty placeholder\n // until the user (or partner default) picks one. Requiredness is still\n // enforced via `requiredFieldsConfig` on submit in `create` mode.\n flsaStatus: z\n .enum([\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n ])\n .optional(),\n paymentUnit: z.enum([\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n ]),\n rate: z.preprocess(coerceNaN(0), z.number()),\n /**\n * The effective date a new compensation should take effect on.\n *\n * - **create mode (`compensationId` absent)**: required; partners typically default\n * to the parent job's `hireDate` (onboarding stub-fill) or a future date\n * (rate change). Must be on or after `hireDate`. Server-side this maps to\n * POST /v1/jobs/:jobId/compensations.\n * - **update mode (`compensationId` present)**: optional; if omitted the API\n * keeps the existing effective date. The `hireDate` lower bound is **not**\n * enforced — loaded values may legitimately predate the hire date. Maps to\n * PUT /v1/compensations/:id.\n */\n effectiveDate: z.preprocess(coerceToISODate, z.iso.date().nullable()),\n adjustForMinimumWage: z.boolean(),\n minimumWageId: z.string(),\n}\n\n/**\n * Shape of the form values managed by {@link useCompensationForm}.\n *\n * @remarks\n * Accepted as `defaultValues` on `useCompensationForm` and returned by\n * `form.getFormSubmissionValues()` once the form has validated. `effectiveDate`\n * is an ISO date string (`YYYY-MM-DD`) or `null`; `flsaStatus` is optional so\n * the field can render an empty placeholder when nothing is preselected\n * (requiredness is enforced on submit per mode).\n *\n * @public\n * @interface\n */\nexport type CompensationFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n\nconst requiredFieldsConfig = {\n title: 'never',\n flsaStatus: 'create',\n paymentUnit: 'create',\n rate: 'create',\n effectiveDate: 'create',\n minimumWageId: data => data.adjustForMinimumWage,\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\nfunction validateFlsaRules(data: CompensationFormData, ctx: z.RefinementCtx) {\n const { flsaStatus, paymentUnit, rate } = data\n\n if (\n flsaStatus === FlsaStatus.EXEMPT ||\n flsaStatus === FlsaStatus.SALARIED_NONEXEMPT ||\n flsaStatus === FlsaStatus.NONEXEMPT\n ) {\n // Surface the EXEMPT salary-threshold issue *before* the generic minimum,\n // so a partner setting rate=0 with EXEMPT sees the more actionable\n // \"must meet salary threshold\" message rather than the generic\n // \"amount must be at least $1.00\".\n if (\n flsaStatus === FlsaStatus.EXEMPT &&\n yearlyRate(rate, paymentUnit) < FLSA_OVERTIME_SALARY_LIMIT\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_EXEMPT_THRESHOLD,\n })\n } else if (rate < 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_MINIMUM,\n })\n }\n } else if (flsaStatus === FlsaStatus.OWNER) {\n if (paymentUnit !== PAY_PERIODS.PAYCHECK) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['paymentUnit'],\n message: CompensationErrorCodes.PAYMENT_UNIT_OWNER,\n })\n }\n if (rate < 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_MINIMUM,\n })\n }\n } else if (\n flsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT ||\n flsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT\n ) {\n if (paymentUnit !== PAY_PERIODS.YEAR) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['paymentUnit'],\n message: CompensationErrorCodes.PAYMENT_UNIT_COMMISSION,\n })\n }\n if (rate !== 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_COMMISSION_ZERO,\n })\n }\n }\n}\n\n/**\n * Override which fields are required on a given submission mode of {@link useCompensationForm}.\n *\n * @remarks\n * Each mode key lists the fields that are optional by default for that mode\n * but should be promoted to required. `adjustForMinimumWage` is always\n * required and `minimumWageId` is automatically required when\n * `adjustForMinimumWage` is `true` — neither is configurable here.\n *\n * | Field | Required on create | Required on update | Configurable? |\n * | ----- | ------------------ | ------------------ | ------------- |\n * | `flsaStatus` | Yes | No | Yes (on update) |\n * | `paymentUnit` | Yes | No | Yes (on update) |\n * | `rate` | Yes | No | Yes (on update) |\n * | `effectiveDate` | Yes | No | Yes (on update) |\n * | `title` | No | No | Yes (either mode) |\n * | `adjustForMinimumWage` | Yes | Yes | No |\n * | `minimumWageId` | When toggle is on | When toggle is on | No |\n *\n * @public\n *\n * @example\n * ```tsx\n * const compensation = useCompensationForm({\n * employeeId,\n * jobId,\n * compensationId,\n * optionalFieldsToRequire: {\n * update: ['title', 'rate'],\n * },\n * })\n * ```\n */\nexport type CompensationOptionalFieldsToRequire = OptionalFieldsToRequire<\n typeof requiredFieldsConfig\n>\n\n/**\n * Validated submission shape produced by the {@link useCompensationForm} schema.\n *\n * @remarks\n * Identical to {@link CompensationFormData} — exposed as a separate alias so\n * the input vs. output sides of the schema remain distinguishable in advanced\n * usages.\n *\n * @public\n */\nexport type CompensationFormOutputs = CompensationFormData\n\n/** @internal */\nexport interface CompensationSchemaOptions {\n /** Selects required-field rules: `'create'` (POST) or `'update'` (PUT). Defaults to `'create'`. */\n mode?: 'create' | 'update'\n /** Promote default-optional fields to required for the selected mode. See {@link CompensationOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n /**\n * Lower bound for `effectiveDate` (typically the parent job's `hireDate`).\n * Only enforced in `create` mode — on `update` the loaded effective date\n * may legitimately predate the hire date and is left as-is. Surfaces an\n * `EFFECTIVE_DATE_BEFORE_HIRE` issue when violated.\n */\n hireDate?: string | null\n /**\n * Absolute lower bound for `effectiveDate`, enforced in both create and\n * update modes whenever provided. Typically `addDays(today, 1)` (tomorrow)\n * for management screens where effective dates must be in the future, or\n * `max(tomorrow, hireDate)` for secondary new jobs. Surfaces an\n * `EFFECTIVE_DATE_BEFORE_MIN` issue when violated.\n *\n * **Callers must only pass this when the carve-out cannot fire.** The\n * carve-out (`willDeleteSecondaryJobs` in update mode) forces `effectiveDate`\n * to today on a disabled field — passing `minEffectiveDate` for a primary\n * job in update mode would cause a spurious validation failure on submit.\n * Secondary jobs are safe because their FLSA field is hidden, preventing the\n * carve-out from activating.\n */\n minEffectiveDate?: string | null\n /**\n * When `false`, drops `effectiveDate` from the validated shape — the field\n * becomes hook-managed (e.g. seeded from the parent job's `hireDate` during\n * onboarding). Partners may still supply the value at submit time via\n * `CompensationSubmitOptions.effectiveDate`. Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\n/** @internal */\nexport function createCompensationSchema(options: CompensationSchemaOptions = {}) {\n const {\n mode = 'create',\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate,\n withEffectiveDateField = true,\n } = options\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: CompensationErrorCodes.REQUIRED,\n mode,\n optionalFieldsToRequire,\n excludeFields: withEffectiveDateField ? [] : ['effectiveDate'],\n superRefine: (data, ctx) => {\n validateFlsaRules(data, ctx)\n // Enforce the hire-date lower bound in create mode always, and in\n // update mode when `minEffectiveDate` is also set (management screens\n // where the user is actively picking a new date). On plain update\n // without `minEffectiveDate`, the loaded effectiveDate can legitimately\n // predate the hire date (stub or out-of-order data) and the API\n // accepts the unchanged value — blocking the submit would trap\n // partners whose flow doesn't render Fields.EffectiveDate.\n // When `withEffectiveDateField` is false the field is excluded from\n // the shape and `data.effectiveDate` is undefined — this check\n // naturally short-circuits.\n if (\n hireDate &&\n data.effectiveDate &&\n data.effectiveDate < hireDate &&\n (mode === 'create' || minEffectiveDate)\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['effectiveDate'],\n message: CompensationErrorCodes.EFFECTIVE_DATE_BEFORE_HIRE,\n })\n }\n // Enforce the caller-supplied minimum effective date in both modes.\n // Callers must only pass this when the carve-out cannot fire (see\n // CompensationSchemaOptions.minEffectiveDate for details).\n if (minEffectiveDate && data.effectiveDate && data.effectiveDate < minEffectiveDate) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['effectiveDate'],\n message: CompensationErrorCodes.EFFECTIVE_DATE_BEFORE_MIN,\n })\n }\n },\n })\n}\n"],"names":["CompensationErrorCodes","fieldValidators","z","FlsaStatus","PAY_PERIODS","coerceNaN","coerceToISODate","requiredFieldsConfig","data","validateFlsaRules","ctx","flsaStatus","paymentUnit","rate","yearlyRate","FLSA_OVERTIME_SALARY_LIMIT","createCompensationSchema","options","mode","optionalFieldsToRequire","hireDate","minEffectiveDate","withEffectiveDateField","buildFormSchema"],"mappings":";;;;;AA4CO,MAAMA,IAAyB;AAAA,EACpC,UAAU;AAAA,EACV,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,E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EAAK,iBACLA,EAAK,gBAAgBY,MACpBF,MAAS,YAAYG,MAEtBX,EAAI,SAAS;AAAA,QACX,MAAMR,EAAE,aAAa;AAAA,QACrB,MAAM,CAAC,eAAe;AAAA,QACtB,SAASF,EAAuB;AAAA,MAAA,CACjC,GAKCqB,KAAoBb,EAAK,iBAAiBA,EAAK,gBAAgBa,KACjEX,EAAI,SAAS;AAAA,QACX,MAAMR,EAAE,aAAa;AAAA,QACrB,MAAM,CAAC,eAAe;AAAA,QACtB,SAASF,EAAuB;AAAA,MAAA,CACjC;AAAA,IAEL;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -20,7 +20,7 @@ export interface DashboardFlowProps extends BaseComponentInterface<never> {
|
|
|
20
20
|
*
|
|
21
21
|
* Every tab section of the dashboard is also exported as a self-contained
|
|
22
22
|
* block that can be dropped into a custom layout without the surrounding
|
|
23
|
-
* dashboard chrome (see the
|
|
23
|
+
* dashboard chrome (see the blocks below).
|
|
24
24
|
*
|
|
25
25
|
* Each block wraps its read-only card, its edit form, and the card↔form
|
|
26
26
|
* transitions as a single drop-in. For cases where that built-in orchestration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardFlow.js","sources":["../../../../src/components/Employee/Dashboard/DashboardFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { dashboardStateMachine } from './dashboardStateMachine'\nimport { type DashboardContextInterface, DashboardViewContextual } from './DashboardComponents'\nimport { Flow } from '@/components/Flow/Flow'\nimport type { BaseComponentInterface } from '@/components/Base'\n\n/**\n * Props for {@link DashboardFlow}.\n *\n * @public\n */\nexport interface DashboardFlowProps extends BaseComponentInterface<never> {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Hub for viewing and managing a single employee's profile, pay, and documents.\n *\n * @remarks\n * Renders a tabbed view of an employee's profile (Basic details, Job and pay,\n * Taxes, Documents), wires the card surfaces to their corresponding edit\n * screens via an internal state machine, and surfaces success alerts at the\n * top of the dashboard after each successful edit. Wraps the dashboard in\n * error and suspense boundaries.\n *\n * Every tab section of the dashboard is also exported as a self-contained\n * block that can be dropped into a custom layout without the surrounding\n * dashboard chrome (see the sub-components below).\n *\n * Each block wraps its read-only card, its edit form, and the card↔form\n * transitions as a single drop-in. For cases where that built-in orchestration\n * doesn't fit — rendering a form in a modal, driving navigation via a router,\n * or showing a card read-only — each block's card and form are also exported\n * individually (e.g. {@link CompensationCard}, {@link CompensationEditForm}).\n * Using the individual pieces means owning the swap, any success alerts, and\n * cross-component state yourself.\n *\n * The dashboard composes self-fetching cards and their edit forms and forwards\n * every event they emit to the partner via `onEvent`; its internal state\n * machine also reacts to a subset of these events to swap between the cards\n * and edit screens and to surface success alerts. The table below is the\n * complete, current set of events observable from `DashboardFlow`, grouped by\n * the tab that emits them.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/profile/editRequested` | Fired when \"Edit\" is clicked on the Basic details (Profile) card | `{ employeeId: string }` |\n * | `employee/management/profile/updated` | Fired after the basic-details edit form is saved; the dashboard returns to the cards and surfaces the \"Profile updated\" alert | Updated `Employee` entity |\n * | `employee/management/profile/editCancelled` | Fired when the user clicks Cancel on the basic-details edit form; the dashboard returns to the cards | — |\n * | `employee/management/homeAddress/editRequested` | Fired when \"Manage\" is clicked on the Home address card | `{ employeeId: string }` |\n * | `employee/management/homeAddress/created` | Fired after a new home address is created on the manage screen; the manage screen stays open | Created `EmployeeAddress` entity |\n * | `employee/management/homeAddress/updated` | Fired after a home address is updated on the manage screen; the manage screen stays open | Updated `EmployeeAddress` entity |\n * | `employee/management/homeAddress/deleted` | Fired after a non-active home address is deleted on the manage screen; the manage screen stays open | Deleted `EmployeeAddress` entity |\n * | `employee/management/homeAddress/editCancelled` | Fired when the user clicks Back on the manage screen; the dashboard returns to the cards | — |\n * | `employee/management/workAddress/editRequested` | Fired when \"Manage\" is clicked on the Work address card | `{ employeeId: string }` |\n * | `employee/management/workAddress/created` | Fired after a new work address is created on the manage screen; the manage screen stays open | Created `EmployeeWorkAddress` entity |\n * | `employee/management/workAddress/updated` | Fired after a work address is updated on the manage screen; the manage screen stays open | Updated `EmployeeWorkAddress` entity |\n * | `employee/management/workAddress/deleted` | Fired after a work address is deleted on the manage screen; the manage screen stays open | Deleted `EmployeeWorkAddress` entity |\n * | `employee/management/workAddress/editCancelled` | Fired when the user clicks Back on the manage screen; the dashboard returns to the cards | — |\n * | `employee/management/compensation/card/editRequested` | Fired when an \"Edit\" CTA is clicked for a job on the Compensation card | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/addRequested` | Fired when \"Add job\" is clicked from the Compensation card's empty state | `{ employeeId: string }` |\n * | `employee/management/compensation/card/addAnotherRequested` | Fired when \"Add another job\" is clicked on the Compensation card | `{ employeeId: string }` |\n * | `employee/management/compensation/card/jobDeleted` | Fired after a non-primary job is deleted via the card's confirm dialog | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/changeCancelled` | Fired after a scheduled future-dated change is cancelled from the card | `{ employeeId: string, compensationId: string }` |\n * | `employee/management/compensation/editForm/submitted` | Fired after an edit-compensation save completes; the dashboard returns to the cards | Updated `Compensation` entity |\n * | `employee/management/compensation/editForm/cancelled` | Fired when the user cancels the edit-compensation form; the dashboard returns to the cards | — |\n * | `employee/management/compensation/addJobForm/submitted` | Fired after the first job and compensation are saved; the dashboard returns to the cards and surfaces the \"Job added\" alert | Updated `Compensation` entity |\n * | `employee/management/compensation/addJobForm/cancelled` | Fired when the user cancels the add-job form; the dashboard returns to the cards | — |\n * | `employee/management/compensation/addAnotherJobForm/submitted` | Fired after a secondary job and compensation are saved; the dashboard returns to the cards and surfaces the \"Job added\" alert | Updated `Compensation` entity |\n * | `employee/management/compensation/addAnotherJobForm/cancelled` | Fired when the user cancels the add-another-job form; the dashboard returns to the cards | — |\n * | `employee/management/paymentMethod/card/addRequested` | Fired when \"Add bank account\" / \"Add another bank account\" is clicked on the Payment card | — |\n * | `employee/management/paymentMethod/card/splitRequested` | Fired when \"Split paycheck\" is clicked on the Payment card | — |\n * | `employee/management/paymentMethod/card/bankAccountDeleted` | Fired after a bank account is deleted from the card; the dashboard surfaces the \"Bank account deleted\" alert | Response from the Delete a bank account endpoint |\n * | `employee/management/paymentMethod/bankForm/submitted` | Fired after a new bank account is saved; the dashboard returns to the cards and surfaces the \"Bank account added\" alert | Created `EmployeeBankAccount` entity |\n * | `employee/management/paymentMethod/bankForm/cancelled` | Fired when the user cancels the add-bank-account screen; the dashboard returns to the cards | — |\n * | `employee/management/paymentMethod/splitForm/submitted` | Fired after the split configuration is saved; the dashboard returns to the cards and surfaces the \"Split updated\" alert | Updated `EmployeePaymentMethod` entity |\n * | `employee/management/paymentMethod/splitForm/cancelled` | Fired when the user cancels the split-paycheck screen; the dashboard returns to the cards | — |\n * | `employee/management/deductions/card/addRequested` | Fired when \"Add deduction\" is clicked on the Deductions card | `{ employeeId: string }` |\n * | `employee/management/deductions/card/editRequested` | Fired when a row's \"Edit\" menu item is chosen on the Deductions card | The `Garnishment` row being edited |\n * | `employee/management/deductions/card/deleted` | Fired after the soft-delete dialog is confirmed; the dashboard surfaces the \"Deduction deleted\" alert | The now-inactive `Garnishment` |\n * | `employee/management/deductions/editForm/created` | Fired after a new deduction is created; the dashboard returns to the cards and surfaces the \"Deduction added\" alert | The created `Garnishment` |\n * | `employee/management/deductions/editForm/updated` | Fired after a deduction is updated; the dashboard returns to the cards and surfaces the \"Deduction updated\" alert | The updated `Garnishment` |\n * | `employee/management/deductions/editForm/cancelled` | Fired when the user cancels the add/edit deduction form; the dashboard returns to the cards | — |\n * | `employee/management/paystubs/card/downloadRequested` | Fired when a paystub row's download button is clicked, before the PDF is fetched | `{ employeeId: string, payrollUuid: string }` |\n * | `employee/management/paystubs/card/downloaded` | Fired after the paystub PDF is fetched and opened in a new tab | `{ employeeId: string, payrollUuid: string }` |\n * | `employee/management/federalTaxes/card/editRequested` | Fired when \"Edit\" is clicked on the Federal taxes card | `{ employeeId: string }` |\n * | `employee/management/federalTaxes/editForm/submitted` | Fired after a federal-taxes save succeeds; the dashboard returns to the cards and surfaces the \"Federal taxes updated\" alert | Updated `EmployeeFederalTax` entity |\n * | `employee/management/federalTaxes/editForm/cancelled` | Fired when the user cancels the federal-taxes edit form; the dashboard returns to the cards | — |\n * | `employee/management/stateTaxes/editRequested` | Fired when \"Edit\" is clicked on the State taxes card | `{ employeeId: string }` |\n * | `employee/management/stateTaxes/updated` | Fired after a state-taxes save succeeds; the dashboard returns to the cards and surfaces the \"State taxes updated\" alert | `{ employeeStateTaxesList: EmployeeStateTaxesList[] }` |\n * | `employee/management/stateTaxes/editCancelled` | Fired when the user cancels the state-taxes edit form; the dashboard returns to the cards | — |\n * | `employee/management/documents/card/viewRequested` | Fired when a document row's \"View\" CTA is clicked; the dashboard swaps to the read-only document viewer | `{ employeeId: string, formId: string }` |\n * | `CANCEL` | Fired when the user clicks Back in the document viewer; the dashboard returns to the cards | — |\n * | `employee/dashboard/tabChange` | Fired when the user switches dashboard tabs | `{ tab: 'basicDetails' \\| 'jobAndPay' \\| 'taxes' \\| 'documents' }` |\n * | `employee/dismiss` | Fired when the user dismisses a top-of-dashboard success alert | — |\n *\n * @components\n * - {@link Dashboard}\n * - {@link ProfileEditForm}\n * - {@link HomeAddressEditForm}\n * - {@link WorkAddressEditForm}\n * - {@link FederalTaxesEditForm}\n * - {@link StateTaxesEditForm}\n * - {@link PaymentMethodBankForm}\n * - {@link PaymentMethodSplitForm}\n * - {@link CompensationAddJobForm}\n * - {@link CompensationEditForm}\n * - {@link CompensationAddAnotherJobForm}\n * - {@link DeductionsEditForm}\n * - {@link DocumentManager}\n *\n * @param props - See {@link DashboardFlowProps}.\n * @returns The tabbed dashboard with internal navigation between cards and edit screens.\n * @public\n * @group Flow Components\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { EmployeeManagement } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <EmployeeManagement.DashboardFlow\n * employeeId=\"4b3f930f-82cd-48a8-b797-798686e12e5e\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport const DashboardFlow = ({ employeeId, onEvent }: DashboardFlowProps) => {\n const dashboardMachine = useMemo(\n () =>\n createMachine(\n 'index',\n dashboardStateMachine,\n (initialContext: DashboardContextInterface) => ({\n ...initialContext,\n component: DashboardViewContextual,\n employeeId,\n }),\n ),\n [employeeId],\n )\n\n return <Flow machine={dashboardMachine} onEvent={onEvent} />\n}\n"],"names":["DashboardFlow","employeeId","onEvent","dashboardMachine","useMemo","createMachine","dashboardStateMachine","initialContext","DashboardViewContextual","jsx","Flow"],"mappings":";;;;;;AAqIO,MAAMA,IAAgB,CAAC,EAAE,YAAAC,GAAY,SAAAC,QAAkC;AAC5E,QAAMC,IAAmBC;AAAA,IACvB,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAA+C;AAAA,QAC9C,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,YAAAP;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACA,CAAU;AAAA,EAAA;AAGb,SAAO,gBAAAQ,EAACC,GAAA,EAAK,SAASP,GAAkB,SAAAD,EAAA,CAAkB;AAC5D;"}
|
|
1
|
+
{"version":3,"file":"DashboardFlow.js","sources":["../../../../src/components/Employee/Dashboard/DashboardFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { dashboardStateMachine } from './dashboardStateMachine'\nimport { type DashboardContextInterface, DashboardViewContextual } from './DashboardComponents'\nimport { Flow } from '@/components/Flow/Flow'\nimport type { BaseComponentInterface } from '@/components/Base'\n\n/**\n * Props for {@link DashboardFlow}.\n *\n * @public\n */\nexport interface DashboardFlowProps extends BaseComponentInterface<never> {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Hub for viewing and managing a single employee's profile, pay, and documents.\n *\n * @remarks\n * Renders a tabbed view of an employee's profile (Basic details, Job and pay,\n * Taxes, Documents), wires the card surfaces to their corresponding edit\n * screens via an internal state machine, and surfaces success alerts at the\n * top of the dashboard after each successful edit. Wraps the dashboard in\n * error and suspense boundaries.\n *\n * Every tab section of the dashboard is also exported as a self-contained\n * block that can be dropped into a custom layout without the surrounding\n * dashboard chrome (see the blocks below).\n *\n * Each block wraps its read-only card, its edit form, and the card↔form\n * transitions as a single drop-in. For cases where that built-in orchestration\n * doesn't fit — rendering a form in a modal, driving navigation via a router,\n * or showing a card read-only — each block's card and form are also exported\n * individually (e.g. {@link CompensationCard}, {@link CompensationEditForm}).\n * Using the individual pieces means owning the swap, any success alerts, and\n * cross-component state yourself.\n *\n * The dashboard composes self-fetching cards and their edit forms and forwards\n * every event they emit to the partner via `onEvent`; its internal state\n * machine also reacts to a subset of these events to swap between the cards\n * and edit screens and to surface success alerts. The table below is the\n * complete, current set of events observable from `DashboardFlow`, grouped by\n * the tab that emits them.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/profile/editRequested` | Fired when \"Edit\" is clicked on the Basic details (Profile) card | `{ employeeId: string }` |\n * | `employee/management/profile/updated` | Fired after the basic-details edit form is saved; the dashboard returns to the cards and surfaces the \"Profile updated\" alert | Updated `Employee` entity |\n * | `employee/management/profile/editCancelled` | Fired when the user clicks Cancel on the basic-details edit form; the dashboard returns to the cards | — |\n * | `employee/management/homeAddress/editRequested` | Fired when \"Manage\" is clicked on the Home address card | `{ employeeId: string }` |\n * | `employee/management/homeAddress/created` | Fired after a new home address is created on the manage screen; the manage screen stays open | Created `EmployeeAddress` entity |\n * | `employee/management/homeAddress/updated` | Fired after a home address is updated on the manage screen; the manage screen stays open | Updated `EmployeeAddress` entity |\n * | `employee/management/homeAddress/deleted` | Fired after a non-active home address is deleted on the manage screen; the manage screen stays open | Deleted `EmployeeAddress` entity |\n * | `employee/management/homeAddress/editCancelled` | Fired when the user clicks Back on the manage screen; the dashboard returns to the cards | — |\n * | `employee/management/workAddress/editRequested` | Fired when \"Manage\" is clicked on the Work address card | `{ employeeId: string }` |\n * | `employee/management/workAddress/created` | Fired after a new work address is created on the manage screen; the manage screen stays open | Created `EmployeeWorkAddress` entity |\n * | `employee/management/workAddress/updated` | Fired after a work address is updated on the manage screen; the manage screen stays open | Updated `EmployeeWorkAddress` entity |\n * | `employee/management/workAddress/deleted` | Fired after a work address is deleted on the manage screen; the manage screen stays open | Deleted `EmployeeWorkAddress` entity |\n * | `employee/management/workAddress/editCancelled` | Fired when the user clicks Back on the manage screen; the dashboard returns to the cards | — |\n * | `employee/management/compensation/card/editRequested` | Fired when an \"Edit\" CTA is clicked for a job on the Compensation card | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/addRequested` | Fired when \"Add job\" is clicked from the Compensation card's empty state | `{ employeeId: string }` |\n * | `employee/management/compensation/card/addAnotherRequested` | Fired when \"Add another job\" is clicked on the Compensation card | `{ employeeId: string }` |\n * | `employee/management/compensation/card/jobDeleted` | Fired after a non-primary job is deleted via the card's confirm dialog | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/changeCancelled` | Fired after a scheduled future-dated change is cancelled from the card | `{ employeeId: string, compensationId: string }` |\n * | `employee/management/compensation/editForm/submitted` | Fired after an edit-compensation save completes; the dashboard returns to the cards | Updated `Compensation` entity |\n * | `employee/management/compensation/editForm/cancelled` | Fired when the user cancels the edit-compensation form; the dashboard returns to the cards | — |\n * | `employee/management/compensation/addJobForm/submitted` | Fired after the first job and compensation are saved; the dashboard returns to the cards and surfaces the \"Job added\" alert | Updated `Compensation` entity |\n * | `employee/management/compensation/addJobForm/cancelled` | Fired when the user cancels the add-job form; the dashboard returns to the cards | — |\n * | `employee/management/compensation/addAnotherJobForm/submitted` | Fired after a secondary job and compensation are saved; the dashboard returns to the cards and surfaces the \"Job added\" alert | Updated `Compensation` entity |\n * | `employee/management/compensation/addAnotherJobForm/cancelled` | Fired when the user cancels the add-another-job form; the dashboard returns to the cards | — |\n * | `employee/management/paymentMethod/card/addRequested` | Fired when \"Add bank account\" / \"Add another bank account\" is clicked on the Payment card | — |\n * | `employee/management/paymentMethod/card/splitRequested` | Fired when \"Split paycheck\" is clicked on the Payment card | — |\n * | `employee/management/paymentMethod/card/bankAccountDeleted` | Fired after a bank account is deleted from the card; the dashboard surfaces the \"Bank account deleted\" alert | Response from the Delete a bank account endpoint |\n * | `employee/management/paymentMethod/bankForm/submitted` | Fired after a new bank account is saved; the dashboard returns to the cards and surfaces the \"Bank account added\" alert | Created `EmployeeBankAccount` entity |\n * | `employee/management/paymentMethod/bankForm/cancelled` | Fired when the user cancels the add-bank-account screen; the dashboard returns to the cards | — |\n * | `employee/management/paymentMethod/splitForm/submitted` | Fired after the split configuration is saved; the dashboard returns to the cards and surfaces the \"Split updated\" alert | Updated `EmployeePaymentMethod` entity |\n * | `employee/management/paymentMethod/splitForm/cancelled` | Fired when the user cancels the split-paycheck screen; the dashboard returns to the cards | — |\n * | `employee/management/deductions/card/addRequested` | Fired when \"Add deduction\" is clicked on the Deductions card | `{ employeeId: string }` |\n * | `employee/management/deductions/card/editRequested` | Fired when a row's \"Edit\" menu item is chosen on the Deductions card | The `Garnishment` row being edited |\n * | `employee/management/deductions/card/deleted` | Fired after the soft-delete dialog is confirmed; the dashboard surfaces the \"Deduction deleted\" alert | The now-inactive `Garnishment` |\n * | `employee/management/deductions/editForm/created` | Fired after a new deduction is created; the dashboard returns to the cards and surfaces the \"Deduction added\" alert | The created `Garnishment` |\n * | `employee/management/deductions/editForm/updated` | Fired after a deduction is updated; the dashboard returns to the cards and surfaces the \"Deduction updated\" alert | The updated `Garnishment` |\n * | `employee/management/deductions/editForm/cancelled` | Fired when the user cancels the add/edit deduction form; the dashboard returns to the cards | — |\n * | `employee/management/paystubs/card/downloadRequested` | Fired when a paystub row's download button is clicked, before the PDF is fetched | `{ employeeId: string, payrollUuid: string }` |\n * | `employee/management/paystubs/card/downloaded` | Fired after the paystub PDF is fetched and opened in a new tab | `{ employeeId: string, payrollUuid: string }` |\n * | `employee/management/federalTaxes/card/editRequested` | Fired when \"Edit\" is clicked on the Federal taxes card | `{ employeeId: string }` |\n * | `employee/management/federalTaxes/editForm/submitted` | Fired after a federal-taxes save succeeds; the dashboard returns to the cards and surfaces the \"Federal taxes updated\" alert | Updated `EmployeeFederalTax` entity |\n * | `employee/management/federalTaxes/editForm/cancelled` | Fired when the user cancels the federal-taxes edit form; the dashboard returns to the cards | — |\n * | `employee/management/stateTaxes/editRequested` | Fired when \"Edit\" is clicked on the State taxes card | `{ employeeId: string }` |\n * | `employee/management/stateTaxes/updated` | Fired after a state-taxes save succeeds; the dashboard returns to the cards and surfaces the \"State taxes updated\" alert | `{ employeeStateTaxesList: EmployeeStateTaxesList[] }` |\n * | `employee/management/stateTaxes/editCancelled` | Fired when the user cancels the state-taxes edit form; the dashboard returns to the cards | — |\n * | `employee/management/documents/card/viewRequested` | Fired when a document row's \"View\" CTA is clicked; the dashboard swaps to the read-only document viewer | `{ employeeId: string, formId: string }` |\n * | `CANCEL` | Fired when the user clicks Back in the document viewer; the dashboard returns to the cards | — |\n * | `employee/dashboard/tabChange` | Fired when the user switches dashboard tabs | `{ tab: 'basicDetails' \\| 'jobAndPay' \\| 'taxes' \\| 'documents' }` |\n * | `employee/dismiss` | Fired when the user dismisses a top-of-dashboard success alert | — |\n *\n * @components\n * - {@link Dashboard}\n * - {@link ProfileEditForm}\n * - {@link HomeAddressEditForm}\n * - {@link WorkAddressEditForm}\n * - {@link FederalTaxesEditForm}\n * - {@link StateTaxesEditForm}\n * - {@link PaymentMethodBankForm}\n * - {@link PaymentMethodSplitForm}\n * - {@link CompensationAddJobForm}\n * - {@link CompensationEditForm}\n * - {@link CompensationAddAnotherJobForm}\n * - {@link DeductionsEditForm}\n * - {@link DocumentManager}\n *\n * @param props - See {@link DashboardFlowProps}.\n * @returns The tabbed dashboard with internal navigation between cards and edit screens.\n * @public\n * @group Flow Components\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { EmployeeManagement } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <EmployeeManagement.DashboardFlow\n * employeeId=\"4b3f930f-82cd-48a8-b797-798686e12e5e\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport const DashboardFlow = ({ employeeId, onEvent }: DashboardFlowProps) => {\n const dashboardMachine = useMemo(\n () =>\n createMachine(\n 'index',\n dashboardStateMachine,\n (initialContext: DashboardContextInterface) => ({\n ...initialContext,\n component: DashboardViewContextual,\n employeeId,\n }),\n ),\n [employeeId],\n )\n\n return <Flow machine={dashboardMachine} onEvent={onEvent} />\n}\n"],"names":["DashboardFlow","employeeId","onEvent","dashboardMachine","useMemo","createMachine","dashboardStateMachine","initialContext","DashboardViewContextual","jsx","Flow"],"mappings":";;;;;;AAqIO,MAAMA,IAAgB,CAAC,EAAE,YAAAC,GAAY,SAAAC,QAAkC;AAC5E,QAAMC,IAAmBC;AAAA,IACvB,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAA+C;AAAA,QAC9C,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,YAAAP;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACA,CAAU;AAAA,EAAA;AAGb,SAAO,gBAAAQ,EAACC,GAAA,EAAK,SAASP,GAAkB,SAAAD,EAAA,CAAkB;AAC5D;"}
|
|
@@ -40,6 +40,7 @@ export declare function getRequiredAttrKeys(agency?: Agencies | null): Set<Suppo
|
|
|
40
40
|
* Shape of the values managed by the child support garnishment form.
|
|
41
41
|
*
|
|
42
42
|
* @public
|
|
43
|
+
* @interface
|
|
43
44
|
*/
|
|
44
45
|
export type ChildSupportGarnishmentFormData = { state: string; fipsCode: string; caseNumber: string; orderNumber: string; remittanceNumber: string; payPeriodMaximum: number; amount: number; paymentPeriod: "Every week" | "Every other week" | "Twice per month" | "Monthly"; };
|
|
45
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"childSupportGarnishmentFormSchema.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport { PaymentPeriod } from '@gusto/embedded-api-v-2025-11-15/models/components/garnishmentchildsupport'\nimport type { Agencies } from '@gusto/embedded-api-v-2025-11-15/models/components/childsupportdata'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN } from '@/partner-hook-utils/form/preprocessors'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by the child support garnishment form schema.\n * Map these codes to localized copy in `validationMessages` when composing the\n * hook.\n *\n * @public\n */\nexport const ChildSupportGarnishmentFormErrorCodes = {\n REQUIRED: 'REQUIRED',\n NEGATIVE_AMOUNT: 'NEGATIVE_AMOUNT',\n PERCENT_OUT_OF_RANGE: 'PERCENT_OUT_OF_RANGE',\n} as const\n\n/**\n * Union of validation error code strings emitted by the child support\n * garnishment form schema.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormErrorCode =\n (typeof ChildSupportGarnishmentFormErrorCodes)[keyof typeof ChildSupportGarnishmentFormErrorCodes]\n\n// ── Required-attribute keys recognized from the API ────────────────────\n\n/**\n * Child support attribute keys that the form recognizes. Each state agency\n * declares which of these keys it requires; the hook exposes the resolved\n * subset via `requiredAttrKeys` so callers can drive their own UI on which\n * `caseNumber` / `orderNumber` / `remittanceNumber` fields are required.\n *\n * @public\n */\nexport const SUPPORTED_REQUIRED_ATTR_KEYS = [\n 'case_number',\n 'order_number',\n 'remittance_number',\n] as const\n\n/**\n * Union of child support attribute key strings recognized by the form.\n *\n * @public\n */\nexport type SupportedRequiredAttrKey = (typeof SUPPORTED_REQUIRED_ATTR_KEYS)[number]\n\n/** @internal */\nexport function getRequiredAttrKeys(agency?: Agencies | null): Set<SupportedRequiredAttrKey> {\n const keys = new Set<SupportedRequiredAttrKey>()\n if (!agency?.requiredAttributes) return keys\n for (const attr of agency.requiredAttributes) {\n if (!attr.key) continue\n if ((SUPPORTED_REQUIRED_ATTR_KEYS as readonly string[]).includes(attr.key)) {\n keys.add(attr.key as SupportedRequiredAttrKey)\n }\n }\n return keys\n}\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst PERCENT_MIN = 0\nconst PERCENT_MAX = 100\n\nconst fieldValidators = {\n state: z.string(),\n fipsCode: z.string(),\n caseNumber: z.string(),\n orderNumber: z.string(),\n remittanceNumber: z.string(),\n // Currency cap on the pay-period — required, ≥ 0.\n payPeriodMaximum: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: ChildSupportGarnishmentFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n // Percentage of paycheck, 0-100. Required.\n amount: z.preprocess(\n coerceNaN(0),\n z\n .number()\n .min(PERCENT_MIN, {\n message: ChildSupportGarnishmentFormErrorCodes.PERCENT_OUT_OF_RANGE,\n })\n .max(PERCENT_MAX, {\n message: ChildSupportGarnishmentFormErrorCodes.PERCENT_OUT_OF_RANGE,\n }),\n ),\n paymentPeriod: z.enum(PaymentPeriod),\n}\n\n/**\n * Shape of the values managed by the child support garnishment form.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n\n/**\n * Shape of the validated values produced by the child support garnishment\n * form on submit.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormOutputs = ChildSupportGarnishmentFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n//\n// `state`, `fipsCode`, `payPeriodMaximum`, `amount`, `paymentPeriod` are\n// always required. The three agency-attribute fields toggle requiredness\n// based on the currently selected agency — see `createChildSupportGarnishmentFormSchema`\n// which assigns 'always' / 'never' per call.\n\n/** @internal */\ninterface ChildSupportGarnishmentFormSchemaOptions {\n mode?: 'create' | 'update'\n /**\n * The agency record matching the currently selected `state`. Used only when\n * `agencyList` is not provided — `requiredAttributes` are pinned to this\n * single agency, so the schema must be rebuilt whenever the user picks a\n * different state. Prefer passing `agencyList` instead so requiredness\n * tracks the form's `state` value dynamically.\n */\n selectedAgency?: Agencies | null\n /**\n * Full list of agencies. When provided, the schema's requiredness for\n * `caseNumber` / `orderNumber` / `remittanceNumber` is computed at validation\n * time by looking up the agency whose `state` matches the form's `state`\n * value — so a single schema instance stays correct as the user changes\n * states. Takes precedence over `selectedAgency`.\n */\n agencyList?: readonly Agencies[]\n}\n\n/** @internal */\nexport function createChildSupportGarnishmentFormSchema({\n mode = 'create',\n selectedAgency,\n agencyList,\n}: ChildSupportGarnishmentFormSchemaOptions = {}) {\n // Read `data.state` eagerly (outside the `agencyList.find` callback) so that\n // `buildFormSchema`'s proxy-based predicate-dep detection always observes\n // the `state` access — otherwise an empty `agencyList` at schema-build time\n // would short-circuit the `find` before the proxy sees `data.state` and\n // `useDeriveFieldsMetadata` would treat the field metadata as static.\n const requiredFieldsConfig = agencyList\n ? ({\n caseNumber: data => {\n const state = data.state\n return getRequiredAttrKeys(agencyList.find(a => a.state === state)).has('case_number')\n },\n orderNumber: data => {\n const state = data.state\n return getRequiredAttrKeys(agencyList.find(a => a.state === state)).has('order_number')\n },\n remittanceNumber: data => {\n const state = data.state\n return getRequiredAttrKeys(agencyList.find(a => a.state === state)).has(\n 'remittance_number',\n )\n },\n } satisfies RequiredFieldConfig<typeof fieldValidators>)\n : (() => {\n const requiredAttrKeys = getRequiredAttrKeys(selectedAgency)\n return {\n caseNumber: requiredAttrKeys.has('case_number') ? 'always' : 'never',\n orderNumber: requiredAttrKeys.has('order_number') ? 'always' : 'never',\n remittanceNumber: requiredAttrKeys.has('remittance_number') ? 'always' : 'never',\n } satisfies RequiredFieldConfig<typeof fieldValidators>\n })()\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: ChildSupportGarnishmentFormErrorCodes.REQUIRED,\n mode,\n })\n}\n"],"names":["ChildSupportGarnishmentFormErrorCodes","SUPPORTED_REQUIRED_ATTR_KEYS","getRequiredAttrKeys","agency","keys","attr","PERCENT_MIN","PERCENT_MAX","fieldValidators","z","coerceNaN","PaymentPeriod","createChildSupportGarnishmentFormSchema","mode","selectedAgency","agencyList","requiredFieldsConfig","data","state","a","requiredAttrKeys","buildFormSchema"],"mappings":";;;;AAkBO,MAAMA,IAAwC;AAAA,EACnD,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,sBAAsB;AACxB,GAqBaC,IAA+B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF;AAUO,SAASC,EAAoBC,GAAyD;AAC3F,QAAMC,wBAAW,IAAA;AACjB,MAAI,CAACD,GAAQ,mBAAoB,QAAOC;AACxC,aAAWC,KAAQF,EAAO;AACxB,IAAKE,EAAK,OACLJ,EAAmD,SAASI,EAAK,GAAG,KACvED,EAAK,IAAIC,EAAK,GAA+B;AAGjD,SAAOD;AACT;AAIA,MAAME,IAAc,GACdC,IAAc,KAEdC,IAAkB;AAAA,EACtB,OAAOC,EAAE,OAAA;AAAA,EACT,UAAUA,EAAE,OAAA;AAAA,EACZ,YAAYA,EAAE,OAAA;AAAA,EACd,aAAaA,EAAE,OAAA;AAAA,EACf,kBAAkBA,EAAE,OAAA;AAAA;AAAA,EAEpB,kBAAkBA,EAAE;AAAA,IAClBC,EAAU,CAAC;AAAA,IACXD,EAAE,SAAS,IAAI,GAAG,EAAE,SAAST,EAAsC,gBAAA,CAAiB;AAAA,EAAA;AAAA;AAAA,EAGtF,QAAQS,EAAE;AAAA,IACRC,EAAU,CAAC;AAAA,IACXD,EACG,OAAA,EACA,IAAIH,GAAa;AAAA,MAChB,SAASN,EAAsC;AAAA,IAAA,CAChD,EACA,IAAIO,GAAa;AAAA,MAChB,SAASP,EAAsC;AAAA,IAAA,CAChD;AAAA,EAAA;AAAA,EAEL,eAAeS,EAAE,KAAKE,CAAa;AACrC;
|
|
1
|
+
{"version":3,"file":"childSupportGarnishmentFormSchema.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport { PaymentPeriod } from '@gusto/embedded-api-v-2025-11-15/models/components/garnishmentchildsupport'\nimport type { Agencies } from '@gusto/embedded-api-v-2025-11-15/models/components/childsupportdata'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN } from '@/partner-hook-utils/form/preprocessors'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by the child support garnishment form schema.\n * Map these codes to localized copy in `validationMessages` when composing the\n * hook.\n *\n * @public\n */\nexport const ChildSupportGarnishmentFormErrorCodes = {\n REQUIRED: 'REQUIRED',\n NEGATIVE_AMOUNT: 'NEGATIVE_AMOUNT',\n PERCENT_OUT_OF_RANGE: 'PERCENT_OUT_OF_RANGE',\n} as const\n\n/**\n * Union of validation error code strings emitted by the child support\n * garnishment form schema.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormErrorCode =\n (typeof ChildSupportGarnishmentFormErrorCodes)[keyof typeof ChildSupportGarnishmentFormErrorCodes]\n\n// ── Required-attribute keys recognized from the API ────────────────────\n\n/**\n * Child support attribute keys that the form recognizes. Each state agency\n * declares which of these keys it requires; the hook exposes the resolved\n * subset via `requiredAttrKeys` so callers can drive their own UI on which\n * `caseNumber` / `orderNumber` / `remittanceNumber` fields are required.\n *\n * @public\n */\nexport const SUPPORTED_REQUIRED_ATTR_KEYS = [\n 'case_number',\n 'order_number',\n 'remittance_number',\n] as const\n\n/**\n * Union of child support attribute key strings recognized by the form.\n *\n * @public\n */\nexport type SupportedRequiredAttrKey = (typeof SUPPORTED_REQUIRED_ATTR_KEYS)[number]\n\n/** @internal */\nexport function getRequiredAttrKeys(agency?: Agencies | null): Set<SupportedRequiredAttrKey> {\n const keys = new Set<SupportedRequiredAttrKey>()\n if (!agency?.requiredAttributes) return keys\n for (const attr of agency.requiredAttributes) {\n if (!attr.key) continue\n if ((SUPPORTED_REQUIRED_ATTR_KEYS as readonly string[]).includes(attr.key)) {\n keys.add(attr.key as SupportedRequiredAttrKey)\n }\n }\n return keys\n}\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst PERCENT_MIN = 0\nconst PERCENT_MAX = 100\n\nconst fieldValidators = {\n state: z.string(),\n fipsCode: z.string(),\n caseNumber: z.string(),\n orderNumber: z.string(),\n remittanceNumber: z.string(),\n // Currency cap on the pay-period — required, ≥ 0.\n payPeriodMaximum: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: ChildSupportGarnishmentFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n // Percentage of paycheck, 0-100. Required.\n amount: z.preprocess(\n coerceNaN(0),\n z\n .number()\n .min(PERCENT_MIN, {\n message: ChildSupportGarnishmentFormErrorCodes.PERCENT_OUT_OF_RANGE,\n })\n .max(PERCENT_MAX, {\n message: ChildSupportGarnishmentFormErrorCodes.PERCENT_OUT_OF_RANGE,\n }),\n ),\n paymentPeriod: z.enum(PaymentPeriod),\n}\n\n/**\n * Shape of the values managed by the child support garnishment form.\n *\n * @public\n * @interface\n */\nexport type ChildSupportGarnishmentFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n\n/**\n * Shape of the validated values produced by the child support garnishment\n * form on submit.\n *\n * @public\n */\nexport type ChildSupportGarnishmentFormOutputs = ChildSupportGarnishmentFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n//\n// `state`, `fipsCode`, `payPeriodMaximum`, `amount`, `paymentPeriod` are\n// always required. The three agency-attribute fields toggle requiredness\n// based on the currently selected agency — see `createChildSupportGarnishmentFormSchema`\n// which assigns 'always' / 'never' per call.\n\n/** @internal */\ninterface ChildSupportGarnishmentFormSchemaOptions {\n mode?: 'create' | 'update'\n /**\n * The agency record matching the currently selected `state`. Used only when\n * `agencyList` is not provided — `requiredAttributes` are pinned to this\n * single agency, so the schema must be rebuilt whenever the user picks a\n * different state. Prefer passing `agencyList` instead so requiredness\n * tracks the form's `state` value dynamically.\n */\n selectedAgency?: Agencies | null\n /**\n * Full list of agencies. When provided, the schema's requiredness for\n * `caseNumber` / `orderNumber` / `remittanceNumber` is computed at validation\n * time by looking up the agency whose `state` matches the form's `state`\n * value — so a single schema instance stays correct as the user changes\n * states. Takes precedence over `selectedAgency`.\n */\n agencyList?: readonly Agencies[]\n}\n\n/** @internal */\nexport function createChildSupportGarnishmentFormSchema({\n mode = 'create',\n selectedAgency,\n agencyList,\n}: ChildSupportGarnishmentFormSchemaOptions = {}) {\n // Read `data.state` eagerly (outside the `agencyList.find` callback) so that\n // `buildFormSchema`'s proxy-based predicate-dep detection always observes\n // the `state` access — otherwise an empty `agencyList` at schema-build time\n // would short-circuit the `find` before the proxy sees `data.state` and\n // `useDeriveFieldsMetadata` would treat the field metadata as static.\n const requiredFieldsConfig = agencyList\n ? ({\n caseNumber: data => {\n const state = data.state\n return getRequiredAttrKeys(agencyList.find(a => a.state === state)).has('case_number')\n },\n orderNumber: data => {\n const state = data.state\n return getRequiredAttrKeys(agencyList.find(a => a.state === state)).has('order_number')\n },\n remittanceNumber: data => {\n const state = data.state\n return getRequiredAttrKeys(agencyList.find(a => a.state === state)).has(\n 'remittance_number',\n )\n },\n } satisfies RequiredFieldConfig<typeof fieldValidators>)\n : (() => {\n const requiredAttrKeys = getRequiredAttrKeys(selectedAgency)\n return {\n caseNumber: requiredAttrKeys.has('case_number') ? 'always' : 'never',\n orderNumber: requiredAttrKeys.has('order_number') ? 'always' : 'never',\n remittanceNumber: requiredAttrKeys.has('remittance_number') ? 'always' : 'never',\n } satisfies RequiredFieldConfig<typeof fieldValidators>\n })()\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: ChildSupportGarnishmentFormErrorCodes.REQUIRED,\n mode,\n })\n}\n"],"names":["ChildSupportGarnishmentFormErrorCodes","SUPPORTED_REQUIRED_ATTR_KEYS","getRequiredAttrKeys","agency","keys","attr","PERCENT_MIN","PERCENT_MAX","fieldValidators","z","coerceNaN","PaymentPeriod","createChildSupportGarnishmentFormSchema","mode","selectedAgency","agencyList","requiredFieldsConfig","data","state","a","requiredAttrKeys","buildFormSchema"],"mappings":";;;;AAkBO,MAAMA,IAAwC;AAAA,EACnD,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,sBAAsB;AACxB,GAqBaC,IAA+B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF;AAUO,SAASC,EAAoBC,GAAyD;AAC3F,QAAMC,wBAAW,IAAA;AACjB,MAAI,CAACD,GAAQ,mBAAoB,QAAOC;AACxC,aAAWC,KAAQF,EAAO;AACxB,IAAKE,EAAK,OACLJ,EAAmD,SAASI,EAAK,GAAG,KACvED,EAAK,IAAIC,EAAK,GAA+B;AAGjD,SAAOD;AACT;AAIA,MAAME,IAAc,GACdC,IAAc,KAEdC,IAAkB;AAAA,EACtB,OAAOC,EAAE,OAAA;AAAA,EACT,UAAUA,EAAE,OAAA;AAAA,EACZ,YAAYA,EAAE,OAAA;AAAA,EACd,aAAaA,EAAE,OAAA;AAAA,EACf,kBAAkBA,EAAE,OAAA;AAAA;AAAA,EAEpB,kBAAkBA,EAAE;AAAA,IAClBC,EAAU,CAAC;AAAA,IACXD,EAAE,SAAS,IAAI,GAAG,EAAE,SAAST,EAAsC,gBAAA,CAAiB;AAAA,EAAA;AAAA;AAAA,EAGtF,QAAQS,EAAE;AAAA,IACRC,EAAU,CAAC;AAAA,IACXD,EACG,OAAA,EACA,IAAIH,GAAa;AAAA,MAChB,SAASN,EAAsC;AAAA,IAAA,CAChD,EACA,IAAIO,GAAa;AAAA,MAChB,SAASP,EAAsC;AAAA,IAAA,CAChD;AAAA,EAAA;AAAA,EAEL,eAAeS,EAAE,KAAKE,CAAa;AACrC;AAiDO,SAASC,EAAwC;AAAA,EACtD,MAAAC,IAAO;AAAA,EACP,gBAAAC;AAAA,EACA,YAAAC;AACF,IAA8C,IAAI;AAMhD,QAAMC,IAAuBD,IACxB;AAAA,IACC,YAAY,CAAAE,MAAQ;AAClB,YAAMC,IAAQD,EAAK;AACnB,aAAOf,EAAoBa,EAAW,KAAK,CAAAI,MAAKA,EAAE,UAAUD,CAAK,CAAC,EAAE,IAAI,aAAa;AAAA,IACvF;AAAA,IACA,aAAa,CAAAD,MAAQ;AACnB,YAAMC,IAAQD,EAAK;AACnB,aAAOf,EAAoBa,EAAW,KAAK,CAAAI,MAAKA,EAAE,UAAUD,CAAK,CAAC,EAAE,IAAI,cAAc;AAAA,IACxF;AAAA,IACA,kBAAkB,CAAAD,MAAQ;AACxB,YAAMC,IAAQD,EAAK;AACnB,aAAOf,EAAoBa,EAAW,KAAK,CAAAI,MAAKA,EAAE,UAAUD,CAAK,CAAC,EAAE;AAAA,QAClE;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA,KAED,MAAM;AACL,UAAME,IAAmBlB,EAAoBY,CAAc;AAC3D,WAAO;AAAA,MACL,YAAYM,EAAiB,IAAI,aAAa,IAAI,WAAW;AAAA,MAC7D,aAAaA,EAAiB,IAAI,cAAc,IAAI,WAAW;AAAA,MAC/D,kBAAkBA,EAAiB,IAAI,mBAAmB,IAAI,WAAW;AAAA,IAAA;AAAA,EAE7E,GAAA;AAEJ,SAAOC,EAAgBb,GAAiB;AAAA,IACtC,sBAAAQ;AAAA,IACA,mBAAmBhB,EAAsC;AAAA,IACzD,MAAAa;AAAA,EAAA,CACD;AACH;"}
|
package/dist/components/Employee/Deductions/shared/useDeductionForm/deductionFormSchema.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type DeductionFormErrorCode = (typeof DeductionFormErrorCodes)[keyof type
|
|
|
20
20
|
* Shape of the values managed by the deduction form.
|
|
21
21
|
*
|
|
22
22
|
* @public
|
|
23
|
+
* @interface
|
|
23
24
|
*/
|
|
24
25
|
export type DeductionFormData = { description: string; recurring: boolean; deductAsPercentage: boolean; amount: number; totalAmount: number; annualMaximum: number; garnishmentType: "child_support" | "federal_tax_lien" | "state_tax_lien" | "student_loan" | "creditor_garnishment" | "federal_loan" | "other_garnishment"; };
|
|
25
26
|
/**
|
package/dist/components/Employee/Deductions/shared/useDeductionForm/deductionFormSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deductionFormSchema.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useDeductionForm/deductionFormSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport { GarnishmentType } from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n type OptionalFieldsToRequire,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN, coerceStringBoolean } from '@/partner-hook-utils/form/preprocessors'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by the deduction form schema. Map these\n * codes to localized copy in `validationMessages` when composing the hook.\n *\n * @public\n */\nexport const DeductionFormErrorCodes = {\n REQUIRED: 'REQUIRED',\n NEGATIVE_AMOUNT: 'NEGATIVE_AMOUNT',\n} as const\n\n/**\n * Union of validation error code strings emitted by the deduction form schema.\n *\n * @public\n */\nexport type DeductionFormErrorCode =\n (typeof DeductionFormErrorCodes)[keyof typeof DeductionFormErrorCodes]\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst fieldValidators = {\n description: z.string(),\n // Radio groups deliver `'true'`/`'false'` strings; coerce to boolean for the\n // submit payload. Matches the useJobForm pattern.\n recurring: z.preprocess(coerceStringBoolean, z.boolean()),\n deductAsPercentage: z.preprocess(coerceStringBoolean, z.boolean()),\n // Currency / percent input. NumberInputField writes `number | undefined`;\n // coerce to a numeric so .min(0) runs reliably. The number-to-string\n // conversion the garnishment API expects happens inside the hook's onSubmit,\n // so the form value stays a number end-to-end (input === output).\n amount: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: DeductionFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n // Optional caps. The hook drops them to `null` on the wire when 0 — matches\n // the legacy DeductionSchema's \"0 means no cap\" behavior.\n totalAmount: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: DeductionFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n annualMaximum: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: DeductionFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n // Only used when `courtOrdered: true` — see `excludeFields` below.\n garnishmentType: z.enum(GarnishmentType),\n}\n\n/**\n * Shape of the values managed by the deduction form.\n *\n * @public\n */\nexport type DeductionFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n\n/**\n * Shape of the validated values produced by the deduction form on submit.\n *\n * @public\n */\nexport type DeductionFormOutputs = DeductionFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n//\n// `description`, `recurring`, `deductAsPercentage`, `amount` are required by\n// default. `garnishmentType` is required only when present in the shape\n// (court-ordered branch). `totalAmount` and `annualMaximum` are caps the\n// partner can leave blank.\n\nconst requiredFieldsConfig = {\n totalAmount: 'never',\n annualMaximum: 'never',\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\n/**\n * Keys of optional deduction fields that can be promoted to required via the\n * hook's `optionalFieldsToRequire` option.\n *\n * @public\n */\nexport type DeductionFormOptionalFieldsToRequire = OptionalFieldsToRequire<\n typeof requiredFieldsConfig\n>\n\n/** @internal */\ninterface DeductionFormSchemaOptions {\n mode?: 'create' | 'update'\n /**\n * Court-ordered garnishments require `garnishmentType` (Federal Tax Lien,\n * Student Loan, etc.). Non-court-ordered \"custom\" deductions don't carry a\n * type — the field is excluded from the schema entirely, matching the legacy\n * GarnishmentForm vs CustomDeductionForm split.\n */\n courtOrdered: boolean\n optionalFieldsToRequire?: DeductionFormOptionalFieldsToRequire\n}\n\n/** @internal */\nexport function createDeductionFormSchema(options: DeductionFormSchemaOptions) {\n const { mode = 'create', courtOrdered, optionalFieldsToRequire } = options\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: DeductionFormErrorCodes.REQUIRED,\n mode,\n optionalFieldsToRequire,\n excludeFields: courtOrdered ? [] : ['garnishmentType'],\n })\n}\n"],"names":["DeductionFormErrorCodes","fieldValidators","z","coerceStringBoolean","coerceNaN","GarnishmentType","requiredFieldsConfig","createDeductionFormSchema","options","mode","courtOrdered","optionalFieldsToRequire","buildFormSchema"],"mappings":";;;;AAiBO,MAAMA,IAA0B;AAAA,EACrC,UAAU;AAAA,EACV,iBAAiB;AACnB,GAYMC,IAAkB;AAAA,EACtB,aAAaC,EAAE,OAAA;AAAA;AAAA;AAAA,EAGf,WAAWA,EAAE,WAAWC,GAAqBD,EAAE,SAAS;AAAA,EACxD,oBAAoBA,EAAE,WAAWC,GAAqBD,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjE,QAAQA,EAAE;AAAA,IACRE,EAAU,CAAC;AAAA,IACXF,EAAE,SAAS,IAAI,GAAG,EAAE,SAASF,EAAwB,gBAAA,CAAiB;AAAA,EAAA;AAAA;AAAA;AAAA,EAIxE,aAAaE,EAAE;AAAA,IACbE,EAAU,CAAC;AAAA,IACXF,EAAE,SAAS,IAAI,GAAG,EAAE,SAASF,EAAwB,gBAAA,CAAiB;AAAA,EAAA;AAAA,EAExE,eAAeE,EAAE;AAAA,IACfE,EAAU,CAAC;AAAA,IACXF,EAAE,SAAS,IAAI,GAAG,EAAE,SAASF,EAAwB,gBAAA,CAAiB;AAAA,EAAA;AAAA;AAAA,EAGxE,iBAAiBE,EAAE,KAAKG,CAAe;AACzC,
|
|
1
|
+
{"version":3,"file":"deductionFormSchema.js","sources":["../../../../../../src/components/Employee/Deductions/shared/useDeductionForm/deductionFormSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport { GarnishmentType } from '@gusto/embedded-api-v-2025-11-15/models/components/garnishment'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n type OptionalFieldsToRequire,\n} from '@/partner-hook-utils/form/buildFormSchema'\nimport { coerceNaN, coerceStringBoolean } from '@/partner-hook-utils/form/preprocessors'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by the deduction form schema. Map these\n * codes to localized copy in `validationMessages` when composing the hook.\n *\n * @public\n */\nexport const DeductionFormErrorCodes = {\n REQUIRED: 'REQUIRED',\n NEGATIVE_AMOUNT: 'NEGATIVE_AMOUNT',\n} as const\n\n/**\n * Union of validation error code strings emitted by the deduction form schema.\n *\n * @public\n */\nexport type DeductionFormErrorCode =\n (typeof DeductionFormErrorCodes)[keyof typeof DeductionFormErrorCodes]\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst fieldValidators = {\n description: z.string(),\n // Radio groups deliver `'true'`/`'false'` strings; coerce to boolean for the\n // submit payload. Matches the useJobForm pattern.\n recurring: z.preprocess(coerceStringBoolean, z.boolean()),\n deductAsPercentage: z.preprocess(coerceStringBoolean, z.boolean()),\n // Currency / percent input. NumberInputField writes `number | undefined`;\n // coerce to a numeric so .min(0) runs reliably. The number-to-string\n // conversion the garnishment API expects happens inside the hook's onSubmit,\n // so the form value stays a number end-to-end (input === output).\n amount: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: DeductionFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n // Optional caps. The hook drops them to `null` on the wire when 0 — matches\n // the legacy DeductionSchema's \"0 means no cap\" behavior.\n totalAmount: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: DeductionFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n annualMaximum: z.preprocess(\n coerceNaN(0),\n z.number().min(0, { message: DeductionFormErrorCodes.NEGATIVE_AMOUNT }),\n ),\n // Only used when `courtOrdered: true` — see `excludeFields` below.\n garnishmentType: z.enum(GarnishmentType),\n}\n\n/**\n * Shape of the values managed by the deduction form.\n *\n * @public\n * @interface\n */\nexport type DeductionFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n\n/**\n * Shape of the validated values produced by the deduction form on submit.\n *\n * @public\n */\nexport type DeductionFormOutputs = DeductionFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n//\n// `description`, `recurring`, `deductAsPercentage`, `amount` are required by\n// default. `garnishmentType` is required only when present in the shape\n// (court-ordered branch). `totalAmount` and `annualMaximum` are caps the\n// partner can leave blank.\n\nconst requiredFieldsConfig = {\n totalAmount: 'never',\n annualMaximum: 'never',\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\n/**\n * Keys of optional deduction fields that can be promoted to required via the\n * hook's `optionalFieldsToRequire` option.\n *\n * @public\n */\nexport type DeductionFormOptionalFieldsToRequire = OptionalFieldsToRequire<\n typeof requiredFieldsConfig\n>\n\n/** @internal */\ninterface DeductionFormSchemaOptions {\n mode?: 'create' | 'update'\n /**\n * Court-ordered garnishments require `garnishmentType` (Federal Tax Lien,\n * Student Loan, etc.). Non-court-ordered \"custom\" deductions don't carry a\n * type — the field is excluded from the schema entirely, matching the legacy\n * GarnishmentForm vs CustomDeductionForm split.\n */\n courtOrdered: boolean\n optionalFieldsToRequire?: DeductionFormOptionalFieldsToRequire\n}\n\n/** @internal */\nexport function createDeductionFormSchema(options: DeductionFormSchemaOptions) {\n const { mode = 'create', courtOrdered, optionalFieldsToRequire } = options\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: DeductionFormErrorCodes.REQUIRED,\n mode,\n optionalFieldsToRequire,\n excludeFields: courtOrdered ? [] : ['garnishmentType'],\n })\n}\n"],"names":["DeductionFormErrorCodes","fieldValidators","z","coerceStringBoolean","coerceNaN","GarnishmentType","requiredFieldsConfig","createDeductionFormSchema","options","mode","courtOrdered","optionalFieldsToRequire","buildFormSchema"],"mappings":";;;;AAiBO,MAAMA,IAA0B;AAAA,EACrC,UAAU;AAAA,EACV,iBAAiB;AACnB,GAYMC,IAAkB;AAAA,EACtB,aAAaC,EAAE,OAAA;AAAA;AAAA;AAAA,EAGf,WAAWA,EAAE,WAAWC,GAAqBD,EAAE,SAAS;AAAA,EACxD,oBAAoBA,EAAE,WAAWC,GAAqBD,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjE,QAAQA,EAAE;AAAA,IACRE,EAAU,CAAC;AAAA,IACXF,EAAE,SAAS,IAAI,GAAG,EAAE,SAASF,EAAwB,gBAAA,CAAiB;AAAA,EAAA;AAAA;AAAA;AAAA,EAIxE,aAAaE,EAAE;AAAA,IACbE,EAAU,CAAC;AAAA,IACXF,EAAE,SAAS,IAAI,GAAG,EAAE,SAASF,EAAwB,gBAAA,CAAiB;AAAA,EAAA;AAAA,EAExE,eAAeE,EAAE;AAAA,IACfE,EAAU,CAAC;AAAA,IACXF,EAAE,SAAS,IAAI,GAAG,EAAE,SAASF,EAAwB,gBAAA,CAAiB;AAAA,EAAA;AAAA;AAAA,EAGxE,iBAAiBE,EAAE,KAAKG,CAAe;AACzC,GA0BMC,IAAuB;AAAA,EAC3B,aAAa;AAAA,EACb,eAAe;AACjB;AA0BO,SAASC,EAA0BC,GAAqC;AAC7E,QAAM,EAAE,MAAAC,IAAO,UAAU,cAAAC,GAAc,yBAAAC,MAA4BH;AAEnE,SAAOI,EAAgBX,GAAiB;AAAA,IACtC,sBAAAK;AAAA,IACA,mBAAmBN,EAAwB;AAAA,IAC3C,MAAAS;AAAA,IACA,yBAAAE;AAAA,IACA,eAAeD,IAAe,CAAA,IAAK,CAAC,iBAAiB;AAAA,EAAA,CACtD;AACH;"}
|
package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js
CHANGED
|
@@ -9,12 +9,14 @@ import "@gusto/embedded-api-v-2025-11-15/models/errors/gustoembeddederror";
|
|
|
9
9
|
import "@gusto/embedded-api-v-2025-11-15/models/errors/sdkvalidationerror";
|
|
10
10
|
import "@gusto/embedded-api-v-2025-11-15/models/errors/unprocessableentityerror";
|
|
11
11
|
import "@gusto/embedded-api-v-2025-11-15/models/errors/httpclienterrors";
|
|
12
|
+
import "dompurify";
|
|
13
|
+
import "../../../../../../contexts/LocaleProvider/useLocale.js";
|
|
12
14
|
import "../../../../../../shared/constants.js";
|
|
13
15
|
import "../../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
16
|
import { createCompoundContext as t } from "../../../../../Base/createCompoundContext.js";
|
|
15
|
-
const [
|
|
17
|
+
const [f, v] = t("DocumentListContext");
|
|
16
18
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
v as DocumentListProvider,
|
|
20
|
+
f as useDocumentList
|
|
19
21
|
};
|
|
20
22
|
//# sourceMappingURL=useDocumentList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocumentList.js","sources":["../../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api-v-2025-11-15/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype DocumentListContextType = {\n employeeForms: Form[]\n hasSignedAllForms: boolean\n handleContinue: () => void\n handleRequestFormToSign: (form: Form) => void\n documentListError: Error | null\n formToSign?: Form\n}\n\nconst [useDocumentList, DocumentListProvider] =\n createCompoundContext<DocumentListContextType>('DocumentListContext')\nexport { useDocumentList, DocumentListProvider }\n"],"names":["useDocumentList","DocumentListProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDocumentList.js","sources":["../../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api-v-2025-11-15/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype DocumentListContextType = {\n employeeForms: Form[]\n hasSignedAllForms: boolean\n handleContinue: () => void\n handleRequestFormToSign: (form: Form) => void\n documentListError: Error | null\n formToSign?: Form\n}\n\nconst [useDocumentList, DocumentListProvider] =\n createCompoundContext<DocumentListContextType>('DocumentListContext')\nexport { useDocumentList, DocumentListProvider }\n"],"names":["useDocumentList","DocumentListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;AAYA,MAAM,CAACA,GAAiBC,CAAoB,IAC1CC,EAA+C,qBAAqB;"}
|
package/dist/components/Employee/Documents/shared/useSignEmployeeForm/signEmployeeFormSchema.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ export type SignEmployeeFormField = "signature" | "confirmSignature" | "usedPrep
|
|
|
103
103
|
* Shape of the values managed by the I-9 sign-employee form.
|
|
104
104
|
*
|
|
105
105
|
* @public
|
|
106
|
+
* @interface
|
|
106
107
|
*/
|
|
107
108
|
export type SignEmployeeFormData = { signature: string; confirmSignature: boolean; usedPreparer: "yes" | "no"; preparerFirstName: string; preparerLastName: string; preparerStreet1: string; preparerStreet2: string; preparerCity: string; preparerState: string; preparerZip: string; preparerSignature: string; preparerAgree: boolean; preparer2FirstName: string; preparer2LastName: string; preparer2Street1: string; preparer2Street2: string; preparer2City: string; preparer2State: string; preparer2Zip: string; preparer2Signature: string; preparer2Agree: boolean; preparer3FirstName: string; preparer3LastName: string; preparer3Street1: string; preparer3Street2: string; preparer3City: string; preparer3State: string; preparer3Zip: string; preparer3Signature: string; preparer3Agree: boolean; preparer4FirstName: string; preparer4LastName: string; preparer4Street1: string; preparer4Street2: string; preparer4City: string; preparer4State: string; preparer4Zip: string; preparer4Signature: string; preparer4Agree: boolean; };
|
|
108
109
|
/**
|
package/dist/components/Employee/Documents/shared/useSignEmployeeForm/signEmployeeFormSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signEmployeeFormSchema.js","sources":["../../../../../../src/components/Employee/Documents/shared/useSignEmployeeForm/signEmployeeFormSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n} from '@/partner-hook-utils/form/buildFormSchema'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by the I-9 sign-employee form schema. Map\n * these codes to localized copy in `validationMessages` when composing the\n * hook.\n *\n * @public\n */\nexport const SignEmployeeFormErrorCodes = {\n REQUIRED: 'REQUIRED',\n} as const\n\n/**\n * Union of validation error code strings emitted by the I-9 sign-employee\n * form schema.\n *\n * @public\n */\nexport type SignEmployeeFormErrorCode =\n (typeof SignEmployeeFormErrorCodes)[keyof typeof SignEmployeeFormErrorCodes]\n\n// ── Preparer naming helpers ────────────────────────────────────────────\n\n/**\n * Maximum number of I-9 preparers and translators the form supports.\n *\n * @public\n */\nexport const MAX_PREPARERS = 4\n\n/**\n * One-based preparer index used to reference preparer field groups (1–4).\n *\n * @public\n */\nexport type PreparerIndex = 1 | 2 | 3 | 4\n\n/**\n * Suffix segment of a preparer field name — the part that follows\n * `preparer` (or `preparerN`) in the field key.\n *\n * @public\n */\nexport type PreparerFieldSuffix =\n | 'FirstName'\n | 'LastName'\n | 'Street1'\n | 'Street2'\n | 'City'\n | 'State'\n | 'Zip'\n | 'Signature'\n | 'Agree'\n\n/** @internal */\nexport function preparerFieldName(index: PreparerIndex, field: PreparerFieldSuffix): string {\n return index === 1 ? `preparer${field}` : `preparer${index}${field}`\n}\n\n// ── Preparer field name constants ──────────────────────────────────────\n\ntype PreparerFieldMap = Record<\n | 'firstName'\n | 'lastName'\n | 'street1'\n | 'street2'\n | 'city'\n | 'state'\n | 'zip'\n | 'signature'\n | 'agree',\n SignEmployeeFormField\n>\n\nconst PREPARER_1 = {\n firstName: 'preparerFirstName',\n lastName: 'preparerLastName',\n street1: 'preparerStreet1',\n street2: 'preparerStreet2',\n city: 'preparerCity',\n state: 'preparerState',\n zip: 'preparerZip',\n signature: 'preparerSignature',\n agree: 'preparerAgree',\n} as const\n\nconst PREPARER_2 = {\n firstName: 'preparer2FirstName',\n lastName: 'preparer2LastName',\n street1: 'preparer2Street1',\n street2: 'preparer2Street2',\n city: 'preparer2City',\n state: 'preparer2State',\n zip: 'preparer2Zip',\n signature: 'preparer2Signature',\n agree: 'preparer2Agree',\n} as const\n\nconst PREPARER_3 = {\n firstName: 'preparer3FirstName',\n lastName: 'preparer3LastName',\n street1: 'preparer3Street1',\n street2: 'preparer3Street2',\n city: 'preparer3City',\n state: 'preparer3State',\n zip: 'preparer3Zip',\n signature: 'preparer3Signature',\n agree: 'preparer3Agree',\n} as const\n\nconst PREPARER_4 = {\n firstName: 'preparer4FirstName',\n lastName: 'preparer4LastName',\n street1: 'preparer4Street1',\n street2: 'preparer4Street2',\n city: 'preparer4City',\n state: 'preparer4State',\n zip: 'preparer4Zip',\n signature: 'preparer4Signature',\n agree: 'preparer4Agree',\n} as const\n\n/**\n * Per-preparer field name maps indexed by preparer position (0-based). Use\n * these to look up the form field name for a given preparer slot — for\n * example `PREPARERS_BY_INDEX[1].firstName` resolves to\n * `'preparer2FirstName'`.\n *\n * @public\n */\nexport const PREPARERS_BY_INDEX = [\n PREPARER_1,\n PREPARER_2,\n PREPARER_3,\n PREPARER_4,\n] satisfies PreparerFieldMap[]\n\n// ── Per-preparer field name lists (used for excludeFields) ──────────────\n\ntype ValuesOf<T> = T[keyof T]\n\nconst PREPARER_1_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_1) as ValuesOf<\n typeof PREPARER_1\n>[]\nconst PREPARER_2_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_2) as ValuesOf<\n typeof PREPARER_2\n>[]\nconst PREPARER_3_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_3) as ValuesOf<\n typeof PREPARER_3\n>[]\nconst PREPARER_4_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_4) as ValuesOf<\n typeof PREPARER_4\n>[]\n\n/**\n * Flat list of preparer field names per preparer slot (0-based), useful for\n * iterating every field that belongs to a single preparer.\n *\n * @public\n */\nexport const PREPARER_FIELDS_BY_INDEX: SignEmployeeFormField[][] = [\n PREPARER_1_FIELDS,\n PREPARER_2_FIELDS,\n PREPARER_3_FIELDS,\n PREPARER_4_FIELDS,\n]\n\nconst ALL_PREPARER_FIELDS = PREPARER_FIELDS_BY_INDEX.flat()\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst agreeValidator = z.boolean().refine(val => val, {\n message: SignEmployeeFormErrorCodes.REQUIRED,\n})\n\nconst fieldValidators = {\n signature: z.string(),\n confirmSignature: agreeValidator,\n usedPreparer: z.enum(['yes', 'no']),\n\n // Preparer 1\n [PREPARER_1.firstName]: z.string(),\n [PREPARER_1.lastName]: z.string(),\n [PREPARER_1.street1]: z.string(),\n [PREPARER_1.street2]: z.string(),\n [PREPARER_1.city]: z.string(),\n [PREPARER_1.state]: z.string(),\n [PREPARER_1.zip]: z.string(),\n [PREPARER_1.signature]: z.string(),\n [PREPARER_1.agree]: agreeValidator,\n\n // Preparer 2\n [PREPARER_2.firstName]: z.string(),\n [PREPARER_2.lastName]: z.string(),\n [PREPARER_2.street1]: z.string(),\n [PREPARER_2.street2]: z.string(),\n [PREPARER_2.city]: z.string(),\n [PREPARER_2.state]: z.string(),\n [PREPARER_2.zip]: z.string(),\n [PREPARER_2.signature]: z.string(),\n [PREPARER_2.agree]: agreeValidator,\n\n // Preparer 3\n [PREPARER_3.firstName]: z.string(),\n [PREPARER_3.lastName]: z.string(),\n [PREPARER_3.street1]: z.string(),\n [PREPARER_3.street2]: z.string(),\n [PREPARER_3.city]: z.string(),\n [PREPARER_3.state]: z.string(),\n [PREPARER_3.zip]: z.string(),\n [PREPARER_3.signature]: z.string(),\n [PREPARER_3.agree]: agreeValidator,\n\n // Preparer 4\n [PREPARER_4.firstName]: z.string(),\n [PREPARER_4.lastName]: z.string(),\n [PREPARER_4.street1]: z.string(),\n [PREPARER_4.street2]: z.string(),\n [PREPARER_4.city]: z.string(),\n [PREPARER_4.state]: z.string(),\n [PREPARER_4.zip]: z.string(),\n [PREPARER_4.signature]: z.string(),\n [PREPARER_4.agree]: agreeValidator,\n}\n\n/**\n * Field names accepted by the I-9 sign-employee form.\n *\n * @public\n */\nexport type SignEmployeeFormField = keyof typeof fieldValidators\n\n/**\n * Shape of the values managed by the I-9 sign-employee form.\n *\n * @public\n */\nexport type SignEmployeeFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n/**\n * Shape of the validated values produced by the I-9 sign-employee form on\n * submit.\n *\n * @public\n */\nexport type SignEmployeeFormOutputs = SignEmployeeFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n\nconst requiredFieldsConfig = {\n [PREPARER_1.street2]: 'never',\n [PREPARER_2.street2]: 'never',\n [PREPARER_3.street2]: 'never',\n [PREPARER_4.street2]: 'never',\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\n// ── Schema factory ─────────────────────────────────────────────────────\n\n/** @internal */\ninterface SignEmployeeFormSchemaOptions {\n isI9?: boolean\n preparerCount?: number\n}\n\n/** @internal */\nexport function createSignEmployeeFormSchema(options: SignEmployeeFormSchemaOptions = {}) {\n const { isI9 = false, preparerCount = 0 } = options\n\n const excludeFields: SignEmployeeFormField[] = []\n\n if (!isI9) {\n excludeFields.push('usedPreparer', ...ALL_PREPARER_FIELDS)\n } else {\n for (let index = 0; index < MAX_PREPARERS; index++) {\n if (index + 1 > preparerCount) {\n const preparerFields = PREPARER_FIELDS_BY_INDEX[index]\n if (preparerFields) excludeFields.push(...preparerFields)\n }\n }\n }\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: SignEmployeeFormErrorCodes.REQUIRED,\n mode: 'create',\n excludeFields,\n })\n}\n"],"names":["SignEmployeeFormErrorCodes","MAX_PREPARERS","preparerFieldName","index","field","PREPARER_1","PREPARER_2","PREPARER_3","PREPARER_4","PREPARERS_BY_INDEX","PREPARER_1_FIELDS","PREPARER_2_FIELDS","PREPARER_3_FIELDS","PREPARER_4_FIELDS","PREPARER_FIELDS_BY_INDEX","ALL_PREPARER_FIELDS","agreeValidator","z","val","fieldValidators","requiredFieldsConfig","createSignEmployeeFormSchema","options","isI9","preparerCount","excludeFields","preparerFields","buildFormSchema"],"mappings":";;AAeO,MAAMA,IAA6B;AAAA,EACxC,UAAU;AACZ,GAkBaC,IAAgB;AA2BtB,SAASC,EAAkBC,GAAsBC,GAAoC;AAC1F,SAAOD,MAAU,IAAI,WAAWC,CAAK,KAAK,WAAWD,CAAK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
|
1
|
+
{"version":3,"file":"signEmployeeFormSchema.js","sources":["../../../../../../src/components/Employee/Documents/shared/useSignEmployeeForm/signEmployeeFormSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n buildFormSchema,\n type RequiredFieldConfig,\n} from '@/partner-hook-utils/form/buildFormSchema'\n\n// ── Error codes ────────────────────────────────────────────────────────\n\n/**\n * Validation error codes emitted by the I-9 sign-employee form schema. Map\n * these codes to localized copy in `validationMessages` when composing the\n * hook.\n *\n * @public\n */\nexport const SignEmployeeFormErrorCodes = {\n REQUIRED: 'REQUIRED',\n} as const\n\n/**\n * Union of validation error code strings emitted by the I-9 sign-employee\n * form schema.\n *\n * @public\n */\nexport type SignEmployeeFormErrorCode =\n (typeof SignEmployeeFormErrorCodes)[keyof typeof SignEmployeeFormErrorCodes]\n\n// ── Preparer naming helpers ────────────────────────────────────────────\n\n/**\n * Maximum number of I-9 preparers and translators the form supports.\n *\n * @public\n */\nexport const MAX_PREPARERS = 4\n\n/**\n * One-based preparer index used to reference preparer field groups (1–4).\n *\n * @public\n */\nexport type PreparerIndex = 1 | 2 | 3 | 4\n\n/**\n * Suffix segment of a preparer field name — the part that follows\n * `preparer` (or `preparerN`) in the field key.\n *\n * @public\n */\nexport type PreparerFieldSuffix =\n | 'FirstName'\n | 'LastName'\n | 'Street1'\n | 'Street2'\n | 'City'\n | 'State'\n | 'Zip'\n | 'Signature'\n | 'Agree'\n\n/** @internal */\nexport function preparerFieldName(index: PreparerIndex, field: PreparerFieldSuffix): string {\n return index === 1 ? `preparer${field}` : `preparer${index}${field}`\n}\n\n// ── Preparer field name constants ──────────────────────────────────────\n\ntype PreparerFieldMap = Record<\n | 'firstName'\n | 'lastName'\n | 'street1'\n | 'street2'\n | 'city'\n | 'state'\n | 'zip'\n | 'signature'\n | 'agree',\n SignEmployeeFormField\n>\n\nconst PREPARER_1 = {\n firstName: 'preparerFirstName',\n lastName: 'preparerLastName',\n street1: 'preparerStreet1',\n street2: 'preparerStreet2',\n city: 'preparerCity',\n state: 'preparerState',\n zip: 'preparerZip',\n signature: 'preparerSignature',\n agree: 'preparerAgree',\n} as const\n\nconst PREPARER_2 = {\n firstName: 'preparer2FirstName',\n lastName: 'preparer2LastName',\n street1: 'preparer2Street1',\n street2: 'preparer2Street2',\n city: 'preparer2City',\n state: 'preparer2State',\n zip: 'preparer2Zip',\n signature: 'preparer2Signature',\n agree: 'preparer2Agree',\n} as const\n\nconst PREPARER_3 = {\n firstName: 'preparer3FirstName',\n lastName: 'preparer3LastName',\n street1: 'preparer3Street1',\n street2: 'preparer3Street2',\n city: 'preparer3City',\n state: 'preparer3State',\n zip: 'preparer3Zip',\n signature: 'preparer3Signature',\n agree: 'preparer3Agree',\n} as const\n\nconst PREPARER_4 = {\n firstName: 'preparer4FirstName',\n lastName: 'preparer4LastName',\n street1: 'preparer4Street1',\n street2: 'preparer4Street2',\n city: 'preparer4City',\n state: 'preparer4State',\n zip: 'preparer4Zip',\n signature: 'preparer4Signature',\n agree: 'preparer4Agree',\n} as const\n\n/**\n * Per-preparer field name maps indexed by preparer position (0-based). Use\n * these to look up the form field name for a given preparer slot — for\n * example `PREPARERS_BY_INDEX[1].firstName` resolves to\n * `'preparer2FirstName'`.\n *\n * @public\n */\nexport const PREPARERS_BY_INDEX = [\n PREPARER_1,\n PREPARER_2,\n PREPARER_3,\n PREPARER_4,\n] satisfies PreparerFieldMap[]\n\n// ── Per-preparer field name lists (used for excludeFields) ──────────────\n\ntype ValuesOf<T> = T[keyof T]\n\nconst PREPARER_1_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_1) as ValuesOf<\n typeof PREPARER_1\n>[]\nconst PREPARER_2_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_2) as ValuesOf<\n typeof PREPARER_2\n>[]\nconst PREPARER_3_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_3) as ValuesOf<\n typeof PREPARER_3\n>[]\nconst PREPARER_4_FIELDS: SignEmployeeFormField[] = Object.values(PREPARER_4) as ValuesOf<\n typeof PREPARER_4\n>[]\n\n/**\n * Flat list of preparer field names per preparer slot (0-based), useful for\n * iterating every field that belongs to a single preparer.\n *\n * @public\n */\nexport const PREPARER_FIELDS_BY_INDEX: SignEmployeeFormField[][] = [\n PREPARER_1_FIELDS,\n PREPARER_2_FIELDS,\n PREPARER_3_FIELDS,\n PREPARER_4_FIELDS,\n]\n\nconst ALL_PREPARER_FIELDS = PREPARER_FIELDS_BY_INDEX.flat()\n\n// ── Field validators ───────────────────────────────────────────────────\n\nconst agreeValidator = z.boolean().refine(val => val, {\n message: SignEmployeeFormErrorCodes.REQUIRED,\n})\n\nconst fieldValidators = {\n signature: z.string(),\n confirmSignature: agreeValidator,\n usedPreparer: z.enum(['yes', 'no']),\n\n // Preparer 1\n [PREPARER_1.firstName]: z.string(),\n [PREPARER_1.lastName]: z.string(),\n [PREPARER_1.street1]: z.string(),\n [PREPARER_1.street2]: z.string(),\n [PREPARER_1.city]: z.string(),\n [PREPARER_1.state]: z.string(),\n [PREPARER_1.zip]: z.string(),\n [PREPARER_1.signature]: z.string(),\n [PREPARER_1.agree]: agreeValidator,\n\n // Preparer 2\n [PREPARER_2.firstName]: z.string(),\n [PREPARER_2.lastName]: z.string(),\n [PREPARER_2.street1]: z.string(),\n [PREPARER_2.street2]: z.string(),\n [PREPARER_2.city]: z.string(),\n [PREPARER_2.state]: z.string(),\n [PREPARER_2.zip]: z.string(),\n [PREPARER_2.signature]: z.string(),\n [PREPARER_2.agree]: agreeValidator,\n\n // Preparer 3\n [PREPARER_3.firstName]: z.string(),\n [PREPARER_3.lastName]: z.string(),\n [PREPARER_3.street1]: z.string(),\n [PREPARER_3.street2]: z.string(),\n [PREPARER_3.city]: z.string(),\n [PREPARER_3.state]: z.string(),\n [PREPARER_3.zip]: z.string(),\n [PREPARER_3.signature]: z.string(),\n [PREPARER_3.agree]: agreeValidator,\n\n // Preparer 4\n [PREPARER_4.firstName]: z.string(),\n [PREPARER_4.lastName]: z.string(),\n [PREPARER_4.street1]: z.string(),\n [PREPARER_4.street2]: z.string(),\n [PREPARER_4.city]: z.string(),\n [PREPARER_4.state]: z.string(),\n [PREPARER_4.zip]: z.string(),\n [PREPARER_4.signature]: z.string(),\n [PREPARER_4.agree]: agreeValidator,\n}\n\n/**\n * Field names accepted by the I-9 sign-employee form.\n *\n * @public\n */\nexport type SignEmployeeFormField = keyof typeof fieldValidators\n\n/**\n * Shape of the values managed by the I-9 sign-employee form.\n *\n * @public\n * @interface\n */\nexport type SignEmployeeFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\n/**\n * Shape of the validated values produced by the I-9 sign-employee form on\n * submit.\n *\n * @public\n */\nexport type SignEmployeeFormOutputs = SignEmployeeFormData\n\n// ── Required fields config ─────────────────────────────────────────────\n\nconst requiredFieldsConfig = {\n [PREPARER_1.street2]: 'never',\n [PREPARER_2.street2]: 'never',\n [PREPARER_3.street2]: 'never',\n [PREPARER_4.street2]: 'never',\n} satisfies RequiredFieldConfig<typeof fieldValidators>\n\n// ── Schema factory ─────────────────────────────────────────────────────\n\n/** @internal */\ninterface SignEmployeeFormSchemaOptions {\n isI9?: boolean\n preparerCount?: number\n}\n\n/** @internal */\nexport function createSignEmployeeFormSchema(options: SignEmployeeFormSchemaOptions = {}) {\n const { isI9 = false, preparerCount = 0 } = options\n\n const excludeFields: SignEmployeeFormField[] = []\n\n if (!isI9) {\n excludeFields.push('usedPreparer', ...ALL_PREPARER_FIELDS)\n } else {\n for (let index = 0; index < MAX_PREPARERS; index++) {\n if (index + 1 > preparerCount) {\n const preparerFields = PREPARER_FIELDS_BY_INDEX[index]\n if (preparerFields) excludeFields.push(...preparerFields)\n }\n }\n }\n\n return buildFormSchema(fieldValidators, {\n requiredFieldsConfig,\n requiredErrorCode: SignEmployeeFormErrorCodes.REQUIRED,\n mode: 'create',\n excludeFields,\n })\n}\n"],"names":["SignEmployeeFormErrorCodes","MAX_PREPARERS","preparerFieldName","index","field","PREPARER_1","PREPARER_2","PREPARER_3","PREPARER_4","PREPARERS_BY_INDEX","PREPARER_1_FIELDS","PREPARER_2_FIELDS","PREPARER_3_FIELDS","PREPARER_4_FIELDS","PREPARER_FIELDS_BY_INDEX","ALL_PREPARER_FIELDS","agreeValidator","z","val","fieldValidators","requiredFieldsConfig","createSignEmployeeFormSchema","options","isI9","preparerCount","excludeFields","preparerFields","buildFormSchema"],"mappings":";;AAeO,MAAMA,IAA6B;AAAA,EACxC,UAAU;AACZ,GAkBaC,IAAgB;AA2BtB,SAASC,EAAkBC,GAAsBC,GAAoC;AAC1F,SAAOD,MAAU,IAAI,WAAWC,CAAK,KAAK,WAAWD,CAAK,GAAGC,CAAK;AACpE;AAiBA,MAAMC,IAAa;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,WAAW;AAAA,EACX,OAAO;AACT,GAEMC,IAAa;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,WAAW;AAAA,EACX,OAAO;AACT,GAEMC,IAAa;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,WAAW;AAAA,EACX,OAAO;AACT,GAEMC,IAAa;AAAA,EACjB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,WAAW;AAAA,EACX,OAAO;AACT,GAUaC,IAAqB;AAAA,EAChCJ;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AACF,GAMME,IAA6C,OAAO,OAAOL,CAAU,GAGrEM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tCG,IAAyC,CAAA;AAE/C,MAAI,CAACF;AACH,IAAAE,EAAc,KAAK,gBAAgB,GAAGV,CAAmB;AAAA;AAEzD,aAASZ,IAAQ,GAAGA,IAAQF,GAAeE;AACzC,UAAIA,IAAQ,IAAIqB,GAAe;AAC7B,cAAME,IAAiBZ,EAAyBX,CAAK;AACrD,QAAIuB,KAAgBD,EAAc,KAAK,GAAGC,CAAc;AAAA,MAC1D;AAIJ,SAAOC,EAAgBR,GAAiB;AAAA,IACtC,sBAAAC;AAAA,IACA,mBAAmBpB,EAA2B;AAAA,IAC9C,MAAM;AAAA,IACN,eAAAyB;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -10,8 +10,8 @@ import { EmployeeListFlowProps } from './EmployeeListFlowComponents';
|
|
|
10
10
|
* employees" header is added to each sub-flow so the admin can return to the
|
|
11
11
|
* list at any time.
|
|
12
12
|
*
|
|
13
|
-
* The flow forwards every event emitted by its
|
|
14
|
-
* see the events table on each
|
|
13
|
+
* The flow forwards every event emitted by its blocks to `onEvent`;
|
|
14
|
+
* see the events table on each block for the full set of events and
|
|
15
15
|
* payloads observable from this flow.
|
|
16
16
|
*
|
|
17
17
|
* @components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmployeeListFlow.js","sources":["../../../../src/components/Employee/EmployeeListFlow/EmployeeListFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { employeeListStateMachine } from './employeeListStateMachine'\nimport {\n EmployeeListContextual,\n type EmployeeListFlowContextInterface,\n type EmployeeListFlowProps,\n} from './EmployeeListFlowComponents'\nimport { Flow } from '@/components/Flow/Flow'\n\n/**\n * Hub for viewing and managing all employees, including onboarding new ones.\n *\n * @remarks\n * Drop-in entry point for managing all employees in a company. Begins on the\n * management employee list and routes into {@link DashboardFlow},\n * {@link TerminationFlow}, or {@link EmployeeOnboarding.OnboardingExecutionFlow | OnboardingExecutionFlow} based on the\n * action the admin invokes on a row (or the \"Add employee\" CTA). A \"Back to\n * employees\" header is added to each sub-flow so the admin can return to the\n * list at any time.\n *\n * The flow forwards every event emitted by its
|
|
1
|
+
{"version":3,"file":"EmployeeListFlow.js","sources":["../../../../src/components/Employee/EmployeeListFlow/EmployeeListFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { employeeListStateMachine } from './employeeListStateMachine'\nimport {\n EmployeeListContextual,\n type EmployeeListFlowContextInterface,\n type EmployeeListFlowProps,\n} from './EmployeeListFlowComponents'\nimport { Flow } from '@/components/Flow/Flow'\n\n/**\n * Hub for viewing and managing all employees, including onboarding new ones.\n *\n * @remarks\n * Drop-in entry point for managing all employees in a company. Begins on the\n * management employee list and routes into {@link DashboardFlow},\n * {@link TerminationFlow}, or {@link EmployeeOnboarding.OnboardingExecutionFlow | OnboardingExecutionFlow} based on the\n * action the admin invokes on a row (or the \"Add employee\" CTA). A \"Back to\n * employees\" header is added to each sub-flow so the admin can return to the\n * list at any time.\n *\n * The flow forwards every event emitted by its blocks to `onEvent`;\n * see the events table on each block for the full set of events and\n * payloads observable from this flow.\n *\n * @components\n * - {@link EmployeeList}\n * - {@link DashboardFlow}\n * - {@link TerminationFlow}\n * - {@link EmployeeOnboarding.OnboardingExecutionFlow | OnboardingExecutionFlow}\n *\n * @param props - See {@link EmployeeListFlowProps}.\n * @returns The employee list workflow with internal navigation to the dashboard, termination, and onboarding flows.\n * @public\n * @group Flow Components\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { EmployeeManagement } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <EmployeeManagement.EmployeeListFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport const EmployeeListFlow = ({ companyId, onEvent }: EmployeeListFlowProps) => {\n const machine = useMemo(\n () =>\n createMachine(\n 'list',\n employeeListStateMachine,\n (initialContext: EmployeeListFlowContextInterface) => ({\n ...initialContext,\n component: EmployeeListContextual,\n companyId,\n }),\n ),\n [companyId],\n )\n return <Flow machine={machine} onEvent={onEvent} />\n}\n"],"names":["EmployeeListFlow","companyId","onEvent","machine","useMemo","createMachine","employeeListStateMachine","initialContext","EmployeeListContextual","jsx","Flow"],"mappings":";;;;;;AAkDO,MAAMA,IAAmB,CAAC,EAAE,WAAAC,GAAW,SAAAC,QAAqC;AACjF,QAAMC,IAAUC;AAAA,IACd,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAAsD;AAAA,QACrD,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAAP;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACA,CAAS;AAAA,EAAA;AAEZ,SAAO,gBAAAQ,EAACC,GAAA,EAAK,SAAAP,GAAkB,SAAAD,EAAA,CAAkB;AACnD;"}
|
|
@@ -3,10 +3,10 @@ import { useTranslation as E, Trans as s } from "react-i18next";
|
|
|
3
3
|
import { BaseLayout as x } from "../../../Base/Base.js";
|
|
4
4
|
import "../../../Base/useBase.js";
|
|
5
5
|
import { Form as b } from "../../../Common/Form/Form.js";
|
|
6
|
-
import { Flex as l } from "../../../Common/Flex/Flex.js";
|
|
7
6
|
import { SDKFormProvider as I } from "../../../../partner-hook-utils/form/SDKFormProvider.js";
|
|
8
7
|
import { useComponentContext as R } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
9
8
|
import { useI18n as D, useComponentDictionary as F } from "../../../../i18n/I18n.js";
|
|
9
|
+
import { Flex as l } from "../../../Common/Flex/Flex.js";
|
|
10
10
|
function C({
|
|
11
11
|
federalTaxes: r,
|
|
12
12
|
onSubmit: d,
|
package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/federalTaxesSchema.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type FederalTaxesField = "filingStatus" | "twoJobs" | "dependentsAmount"
|
|
|
39
39
|
* Shape of the values managed by the federal taxes form.
|
|
40
40
|
*
|
|
41
41
|
* @public
|
|
42
|
+
* @interface
|
|
42
43
|
*/
|
|
43
44
|
export type FederalTaxesFormData = { filingStatus: string; twoJobs: boolean; dependentsAmount: number; otherIncome: number; deductions: number; extraWithholding: number; };
|
|
44
45
|
/**
|