@gusto/embedded-react-sdk 0.48.0 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/components/Common/EmptyData/EmptyData.d.ts +1 -1
- package/dist/components/Common/EmptyData/EmptyData.js +10 -12
- package/dist/components/Common/EmptyData/EmptyData.js.map +1 -1
- package/dist/components/Common/EmptyData/EmptyData.module.scss.js +6 -10
- package/dist/components/Common/EmptyData/EmptyData.module.scss.js.map +1 -1
- package/dist/components/Common/Form/Form.d.ts +1 -1
- package/dist/components/Common/Form/Form.js +8 -7
- package/dist/components/Common/Form/Form.js.map +1 -1
- package/dist/components/Common/UI/Card/Card.js +8 -8
- package/dist/components/Common/UI/Card/Card.js.map +1 -1
- package/dist/components/Common/UI/Card/Card.module.scss.js +5 -3
- package/dist/components/Common/UI/Card/Card.module.scss.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +13 -13
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -17
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -17
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -19
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccount.js +6 -7
- package/dist/components/Company/BankAccount/BankAccount.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -17
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -17
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentSigner.js +2 -3
- package/dist/components/Company/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +12 -26
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -20
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/IndustrySelect.js +6 -8
- package/dist/components/Company/Industry/IndustrySelect.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -17
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -17
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +4 -18
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PayScheduleForm.js +5 -4
- package/dist/components/Company/PaySchedule/PayScheduleForm.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -17
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -17
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +5 -19
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +2 -3
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js +2 -3
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js.map +1 -1
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +13 -13
- package/dist/components/Contractor/Profile/useContractorProfile.js +39 -48
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Compensation/management/Compensation.js +2 -3
- package/dist/components/Employee/Compensation/management/Compensation.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationAddAnotherJobForm/CompensationAddAnotherJobForm.js +8 -9
- package/dist/components/Employee/Compensation/management/CompensationAddAnotherJobForm/CompensationAddAnotherJobForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationAddJobForm/CompensationAddJobForm.js +2 -3
- package/dist/components/Employee/Compensation/management/CompensationAddJobForm/CompensationAddJobForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationEditForm/CompensationEditForm.js +2 -3
- package/dist/components/Employee/Compensation/management/CompensationEditForm/CompensationEditForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationEditJobForm/CompensationEditJobForm.js +2 -3
- package/dist/components/Employee/Compensation/management/CompensationEditJobForm/CompensationEditJobForm.js.map +1 -1
- package/dist/components/Employee/Compensation/management/CompensationEditPendingJobForm/CompensationEditPendingJobForm.js +2 -3
- package/dist/components/Employee/Compensation/management/CompensationEditPendingJobForm/CompensationEditPendingJobForm.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/Compensation.js +2 -3
- package/dist/components/Employee/Compensation/onboarding/Compensation.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +2 -3
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +6 -6
- package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +10 -10
- package/dist/components/Employee/Deductions/management/Deductions.js +2 -3
- package/dist/components/Employee/Deductions/management/Deductions.js.map +1 -1
- package/dist/components/Employee/Deductions/management/DeductionsEditForm/DeductionsEditForm.js +2 -3
- package/dist/components/Employee/Deductions/management/DeductionsEditForm/DeductionsEditForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +1 -1
- package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +2 -2
- package/dist/components/Employee/Documents/management/Documents.js +2 -3
- package/dist/components/Employee/Documents/management/Documents.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -17
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js +11 -12
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +16 -16
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/I9SignatureForm/I9SignatureForm.js +3 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/I9SignatureForm/I9SignatureForm.js.map +1 -1
- package/dist/components/Employee/Documents/shared/SignatureForm/SignatureForm.js +3 -1
- package/dist/components/Employee/Documents/shared/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +2 -2
- package/dist/components/Employee/FederalTaxes/management/FederalTaxes.js +9 -10
- package/dist/components/Employee/FederalTaxes/management/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.js +2 -3
- package/dist/components/Employee/FederalTaxes/management/FederalTaxesEditForm.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.js +8 -9
- package/dist/components/Employee/FederalTaxes/onboarding/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +13 -14
- package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js +2 -3
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/management/PaymentMethod.js +6 -7
- package/dist/components/Employee/PaymentMethod/management/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/onboarding/PaymentMethod.js +6 -7
- package/dist/components/Employee/PaymentMethod/onboarding/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
- package/dist/components/Employee/Profile/management/Profile.js +11 -12
- package/dist/components/Employee/Profile/management/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/management/ProfileEditForm.js +12 -13
- package/dist/components/Employee/Profile/management/ProfileEditForm.js.map +1 -1
- package/dist/components/Employee/Profile/onboarding/AdminProfile.js +10 -11
- package/dist/components/Employee/Profile/onboarding/AdminProfile.js.map +1 -1
- package/dist/components/Employee/Profile/onboarding/EmployeeProfile.js +2 -3
- package/dist/components/Employee/Profile/onboarding/EmployeeProfile.js.map +1 -1
- package/dist/components/Employee/Profile/onboarding/Profile.js +11 -12
- package/dist/components/Employee/Profile/onboarding/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +6 -6
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
- package/dist/components/Employee/StateTaxes/management/StateTaxes.js +9 -10
- package/dist/components/Employee/StateTaxes/management/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.js +6 -7
- package/dist/components/Employee/StateTaxes/management/StateTaxesEditForm.js.map +1 -1
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.js +2 -3
- package/dist/components/Employee/StateTaxes/onboarding/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js +2 -3
- package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js +10 -10
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js +6 -7
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js +7 -8
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequests.js +7 -8
- package/dist/components/InformationRequests/InformationRequests.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js +16 -17
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsBanner/ConfirmWireDetailsBanner.js +2 -3
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsBanner/ConfirmWireDetailsBanner.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +8 -8
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.js +0 -1
- package/dist/components/Payroll/ConfirmWireDetails/WireInstructions/WireInstructions.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +25 -34
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +1 -1
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +2 -3
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceipts.js +6 -7
- package/dist/components/Payroll/PayrollReceipts/PayrollReceipts.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCases.js +6 -7
- package/dist/components/Payroll/RecoveryCases/RecoveryCases.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesList/RecoveryCasesList.js +2 -3
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesList/RecoveryCasesList.js.map +1 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js +10 -10
- package/dist/components/Payroll/usePreparedPayrollData.js +22 -33
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/TimeOff/AddEmployeesHoliday/AddEmployeesHoliday.js +2 -3
- package/dist/components/TimeOff/AddEmployeesHoliday/AddEmployeesHoliday.js.map +1 -1
- package/dist/components/TimeOff/AddEmployeesToPolicy/AddEmployeesToPolicy.js +2 -3
- package/dist/components/TimeOff/AddEmployeesToPolicy/AddEmployeesToPolicy.js.map +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyList.js +2 -3
- package/dist/components/TimeOff/PolicyList/PolicyList.js.map +1 -1
- package/dist/i18n/en/common.json.d.ts +0 -1
- package/dist/i18n/en/common.json.js +2 -2
- package/dist/node_modules/react-dnd/dist/core/DndProvider.js +1 -1
- package/dist/node_modules/react-dnd/dist/core/DndProvider.js.map +1 -1
- package/dist/partner-hook-utils/composeErrorHandler.js +3 -1
- package/dist/partner-hook-utils/composeErrorHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +0 -1
- package/package.json +19 -7
- package/dist/assets/icons/magnifyingGlass.png.js +0 -5
- package/dist/assets/icons/magnifyingGlass.png.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentsList.js","sources":["../../../../../src/components/Contractor/Payments/PaymentsList/PaymentsList.tsx"],"sourcesContent":["import { useState, useMemo, useCallback } from 'react'\nimport { useContractorPaymentGroupsGetListSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorPaymentGroupsGetList'\nimport { useInformationRequestsGetInformationRequestsSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/informationRequestsGetInformationRequests'\nimport { InformationRequestStatus } from '@gusto/embedded-api-v-2025-11-15/models/components/informationrequest'\nimport type { InternalAlert } from '../types'\nimport { PaymentsListPresentation } from './PaymentsListPresentation'\nimport { useComponentDictionary } from '@/i18n'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { componentEvents } from '@/shared/constants'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface PaymentsListProps extends BaseComponentInterface<'Contractor.Payments.PaymentsList'> {\n companyId: string\n alerts?: InternalAlert[]\n}\n\nexport function PaymentsList(props: PaymentsListProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst calculateDateRange = (months: number = 3) => {\n const endDate = new Date()\n const startDate = new Date()\n\n startDate.setMonth(startDate.getMonth() - months)\n //Max range allowed by the API is 12 months\n endDate.setMonth(endDate.getMonth() + (12 - months))\n\n return {\n startDate: startDate.toISOString().split('T')[0] || '',\n endDate: endDate.toISOString().split('T')[0] || '',\n }\n}\n\nexport const Root = ({ companyId, dictionary, onEvent, alerts }: PaymentsListProps) => {\n useComponentDictionary('Contractor.Payments.PaymentsList', dictionary)\n\n const [numberOfMonths, setNumberOfMonths] = useState(3)\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination()\n\n const { startDate, endDate } = useMemo(() => calculateDateRange(numberOfMonths), [numberOfMonths])\n\n const { data } = useContractorPaymentGroupsGetListSuspense({\n companyId,\n startDate,\n endDate,\n page: currentPage,\n per: itemsPerPage,\n })\n const contractorPayments = data.contractorPaymentGroupWithBlockers || []\n const paginationProps = getPaginationProps(data.httpMeta.response.headers)\n\n const { data: informationRequestsData } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n const informationRequests = informationRequestsData.informationRequests ?? []\n\n const hasUnresolvedWireInRequests = useMemo(() => {\n return contractorPayments.some(payment => {\n const creditBlockers = payment.creditBlockers || []\n return creditBlockers.some(blocker => {\n if (blocker.status !== 'unresolved') return false\n const wireOption = blocker.unblockOptions?.find(\n option => option.unblockType === 'submit_wire',\n )\n return wireOption && 'metadata' in wireOption && wireOption.metadata.wireInRequestUuid\n })\n })\n }, [contractorPayments])\n\n const handleRespondToRfi = useCallback(() => {\n onEvent(componentEvents.CONTRACTOR_PAYMENT_RFI_RESPOND)\n }, [onEvent])\n\n const rfiAlerts = useMemo(() => {\n const rfiAlertsArray: InternalAlert[] = []\n\n const hasPendingResponseRfis = informationRequests.some(\n request => request.status === InformationRequestStatus.PendingResponse,\n )\n const hasPendingReviewRfis = informationRequests.some(\n request => request.status === InformationRequestStatus.PendingReview,\n )\n\n if (hasPendingResponseRfis) {\n rfiAlertsArray.push({\n type: 'error',\n title: 'rfiPendingResponseTitle',\n content: 'rfiPendingResponseDescription',\n onAction: handleRespondToRfi,\n actionLabel: 'rfiRespondCta',\n })\n } else if (hasPendingReviewRfis) {\n rfiAlertsArray.push({\n type: 'info',\n title: 'rfiPendingReviewTitle',\n content: 'rfiPendingReviewDescription',\n })\n }\n\n return rfiAlertsArray\n }, [informationRequests, handleRespondToRfi])\n\n const onCreatePayment = () => {\n onEvent(componentEvents.CONTRACTOR_PAYMENT_CREATE)\n }\n\n const handleDateRangeChange = (numberOfMonths: number) => {\n setNumberOfMonths(numberOfMonths)\n }\n\n const onViewPayment = (paymentId: string) => {\n onEvent(componentEvents.CONTRACTOR_PAYMENT_VIEW, { paymentId })\n }\n\n const allAlerts = useMemo(() => {\n return [...rfiAlerts, ...(alerts || [])]\n }, [rfiAlerts, alerts])\n\n return (\n <PaymentsListPresentation\n contractorPayments={contractorPayments}\n numberOfMonths={numberOfMonths}\n onCreatePayment={onCreatePayment}\n onDateRangeChange={handleDateRangeChange}\n onViewPayment={onViewPayment}\n alerts={allAlerts}\n companyId={companyId}\n hasUnresolvedWireInRequests={hasUnresolvedWireInRequests}\n onEvent={onEvent}\n paginationProps={paginationProps}\n />\n )\n}\n"],"names":["PaymentsList","props","jsx","BaseComponent","Root","calculateDateRange","months","endDate","startDate","companyId","dictionary","onEvent","alerts","useComponentDictionary","numberOfMonths","setNumberOfMonths","useState","currentPage","itemsPerPage","getPaginationProps","usePagination","useMemo","data","useContractorPaymentGroupsGetListSuspense","contractorPayments","paginationProps","informationRequestsData","useInformationRequestsGetInformationRequestsSuspense","informationRequests","hasUnresolvedWireInRequests","payment","blocker","wireOption","option","handleRespondToRfi","useCallback","componentEvents","rfiAlerts","rfiAlertsArray","hasPendingResponseRfis","request","InformationRequestStatus","hasPendingReviewRfis","onCreatePayment","handleDateRangeChange","onViewPayment","paymentId","allAlerts","PaymentsListPresentation"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PaymentsList.js","sources":["../../../../../src/components/Contractor/Payments/PaymentsList/PaymentsList.tsx"],"sourcesContent":["import { useState, useMemo, useCallback } from 'react'\nimport { useContractorPaymentGroupsGetListSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorPaymentGroupsGetList'\nimport { useInformationRequestsGetInformationRequestsSuspense } from '@gusto/embedded-api-v-2025-11-15/react-query/informationRequestsGetInformationRequests'\nimport { InformationRequestStatus } from '@gusto/embedded-api-v-2025-11-15/models/components/informationrequest'\nimport type { InternalAlert } from '../types'\nimport { PaymentsListPresentation } from './PaymentsListPresentation'\nimport { useComponentDictionary } from '@/i18n'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { componentEvents } from '@/shared/constants'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface PaymentsListProps extends BaseComponentInterface<'Contractor.Payments.PaymentsList'> {\n companyId: string\n alerts?: InternalAlert[]\n}\n\nexport function PaymentsList(props: PaymentsListProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst calculateDateRange = (months: number = 3) => {\n const endDate = new Date()\n const startDate = new Date()\n\n startDate.setMonth(startDate.getMonth() - months)\n //Max range allowed by the API is 12 months\n endDate.setMonth(endDate.getMonth() + (12 - months))\n\n return {\n startDate: startDate.toISOString().split('T')[0] || '',\n endDate: endDate.toISOString().split('T')[0] || '',\n }\n}\n\nexport const Root = ({ companyId, dictionary, onEvent, alerts }: PaymentsListProps) => {\n useComponentDictionary('Contractor.Payments.PaymentsList', dictionary)\n\n const [numberOfMonths, setNumberOfMonths] = useState(3)\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination()\n\n const { startDate, endDate } = useMemo(() => calculateDateRange(numberOfMonths), [numberOfMonths])\n\n const { data } = useContractorPaymentGroupsGetListSuspense({\n companyId,\n startDate,\n endDate,\n page: currentPage,\n per: itemsPerPage,\n })\n const contractorPayments = data.contractorPaymentGroupWithBlockers || []\n const paginationProps = getPaginationProps(data.httpMeta.response.headers)\n\n const { data: informationRequestsData } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n const informationRequests = informationRequestsData.informationRequests ?? []\n\n const hasUnresolvedWireInRequests = useMemo(() => {\n return contractorPayments.some(payment => {\n const creditBlockers = payment.creditBlockers || []\n return creditBlockers.some(blocker => {\n if (blocker.status !== 'unresolved') return false\n const wireOption = blocker.unblockOptions?.find(\n option => option.unblockType === 'submit_wire',\n )\n return wireOption && 'metadata' in wireOption && wireOption.metadata.wireInRequestUuid\n })\n })\n }, [contractorPayments])\n\n const handleRespondToRfi = useCallback(() => {\n onEvent(componentEvents.CONTRACTOR_PAYMENT_RFI_RESPOND)\n }, [onEvent])\n\n const rfiAlerts = useMemo(() => {\n const rfiAlertsArray: InternalAlert[] = []\n\n const hasPendingResponseRfis = informationRequests.some(\n request => request.status === InformationRequestStatus.PendingResponse,\n )\n const hasPendingReviewRfis = informationRequests.some(\n request => request.status === InformationRequestStatus.PendingReview,\n )\n\n if (hasPendingResponseRfis) {\n rfiAlertsArray.push({\n type: 'error',\n title: 'rfiPendingResponseTitle',\n content: 'rfiPendingResponseDescription',\n onAction: handleRespondToRfi,\n actionLabel: 'rfiRespondCta',\n })\n } else if (hasPendingReviewRfis) {\n rfiAlertsArray.push({\n type: 'info',\n title: 'rfiPendingReviewTitle',\n content: 'rfiPendingReviewDescription',\n })\n }\n\n return rfiAlertsArray\n }, [informationRequests, handleRespondToRfi])\n\n const onCreatePayment = () => {\n onEvent(componentEvents.CONTRACTOR_PAYMENT_CREATE)\n }\n\n const handleDateRangeChange = (numberOfMonths: number) => {\n setNumberOfMonths(numberOfMonths)\n }\n\n const onViewPayment = (paymentId: string) => {\n onEvent(componentEvents.CONTRACTOR_PAYMENT_VIEW, { paymentId })\n }\n\n const allAlerts = useMemo(() => {\n return [...rfiAlerts, ...(alerts || [])]\n }, [rfiAlerts, alerts])\n\n return (\n <PaymentsListPresentation\n contractorPayments={contractorPayments}\n numberOfMonths={numberOfMonths}\n onCreatePayment={onCreatePayment}\n onDateRangeChange={handleDateRangeChange}\n onViewPayment={onViewPayment}\n alerts={allAlerts}\n companyId={companyId}\n hasUnresolvedWireInRequests={hasUnresolvedWireInRequests}\n onEvent={onEvent}\n paginationProps={paginationProps}\n />\n )\n}\n"],"names":["PaymentsList","props","jsx","BaseComponent","Root","calculateDateRange","months","endDate","startDate","companyId","dictionary","onEvent","alerts","useComponentDictionary","numberOfMonths","setNumberOfMonths","useState","currentPage","itemsPerPage","getPaginationProps","usePagination","useMemo","data","useContractorPaymentGroupsGetListSuspense","contractorPayments","paginationProps","informationRequestsData","useInformationRequestsGetInformationRequestsSuspense","informationRequests","hasUnresolvedWireInRequests","payment","blocker","wireOption","option","handleRespondToRfi","useCallback","componentEvents","rfiAlerts","rfiAlertsArray","hasPendingResponseRfis","request","InformationRequestStatus","hasPendingReviewRfis","onCreatePayment","handleDateRangeChange","onViewPayment","paymentId","allAlerts","PaymentsListPresentation"],"mappings":";;;;;;;;;;AAgBO,SAASA,EAAaC,GAA0B;AACrD,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMI,IAAqB,CAACC,IAAiB,MAAM;AACjD,Q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AA,MACR,WAAAtC;AAAA,MACA,6BAAAoB;AAAA,MACA,SAAAlB;AAAA,MACA,iBAAAc;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -5,15 +5,15 @@ import { useComponentContext as T } from "../../../contexts/ComponentAdapter/use
|
|
|
5
5
|
import { useI18n as x } from "../../../i18n/I18n.js";
|
|
6
6
|
import { Form as C } from "../../Common/Form/Form.js";
|
|
7
7
|
import { Grid as d } from "../../Common/Grid/Grid.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { DatePickerField as O } from "../../Common/Fields/DatePickerField/DatePickerField.js";
|
|
9
|
+
import { usePlaceholderSSN as E, normalizeSSN as j } from "../../../helpers/ssn.js";
|
|
10
|
+
import { usePlaceholderEin as v, normalizeEin as w } from "../../../helpers/federalEin.js";
|
|
11
|
+
import { ContractorOnboardingStatus as B } from "../../../shared/constants.js";
|
|
11
12
|
import { Flex as n } from "../../Common/Flex/Flex.js";
|
|
12
13
|
import { TextInputField as l } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
13
14
|
import { RadioGroupField as u } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
14
|
-
import { NumberInputField as
|
|
15
|
-
import { SwitchField as
|
|
16
|
-
import { DatePickerField as z } from "../../Common/Fields/DatePickerField/DatePickerField.js";
|
|
15
|
+
import { NumberInputField as G } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
16
|
+
import { SwitchField as z } from "../../Common/Fields/SwitchField/SwitchField.js";
|
|
17
17
|
function ee({
|
|
18
18
|
formMethods: f,
|
|
19
19
|
handleSubmit: c,
|
|
@@ -32,7 +32,7 @@ function ee({
|
|
|
32
32
|
}) {
|
|
33
33
|
const a = T();
|
|
34
34
|
x("Contractor.Profile");
|
|
35
|
-
const { t: e } = I("Contractor.Profile"), F =
|
|
35
|
+
const { t: e } = I("Contractor.Profile"), F = E(t?.hasSsn ?? !1), P = v(t?.hasEin ?? !1);
|
|
36
36
|
return /* @__PURE__ */ i("section", { className: D, children: /* @__PURE__ */ i(S, { ...f, children: /* @__PURE__ */ r(C, { onSubmit: c, children: [
|
|
37
37
|
/* @__PURE__ */ r(n, { flexDirection: "column", gap: 20, alignItems: "stretch", children: [
|
|
38
38
|
/* @__PURE__ */ i("header", { children: /* @__PURE__ */ r(n, { flexDirection: "column", gap: 4, children: [
|
|
@@ -41,12 +41,12 @@ function ee({
|
|
|
41
41
|
] }) }),
|
|
42
42
|
/* @__PURE__ */ i(a.Box, { children: /* @__PURE__ */ r(d, { gap: 16, children: [
|
|
43
43
|
/* @__PURE__ */ i(
|
|
44
|
-
|
|
44
|
+
z,
|
|
45
45
|
{
|
|
46
46
|
name: "selfOnboarding",
|
|
47
47
|
label: e("fields.selfOnboarding.label"),
|
|
48
48
|
description: e("fields.selfOnboarding.description"),
|
|
49
|
-
isDisabled: t && t.onboardingStatus !==
|
|
49
|
+
isDisabled: t && t.onboardingStatus !== B.ADMIN_ONBOARDING_INCOMPLETE
|
|
50
50
|
}
|
|
51
51
|
),
|
|
52
52
|
p && /* @__PURE__ */ i(
|
|
@@ -80,7 +80,7 @@ function ee({
|
|
|
80
80
|
name: "ssn",
|
|
81
81
|
label: e("fields.ssn.label"),
|
|
82
82
|
placeholder: F,
|
|
83
|
-
transform:
|
|
83
|
+
transform: j,
|
|
84
84
|
isRequired: !0
|
|
85
85
|
}
|
|
86
86
|
)
|
|
@@ -100,7 +100,7 @@ function ee({
|
|
|
100
100
|
name: "ein",
|
|
101
101
|
label: e("fields.ein.label"),
|
|
102
102
|
placeholder: P,
|
|
103
|
-
transform:
|
|
103
|
+
transform: w,
|
|
104
104
|
isRequired: !0
|
|
105
105
|
}
|
|
106
106
|
)
|
|
@@ -115,7 +115,7 @@ function ee({
|
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
117
|
g && /* @__PURE__ */ i(
|
|
118
|
-
|
|
118
|
+
G,
|
|
119
119
|
{
|
|
120
120
|
name: "hourlyRate",
|
|
121
121
|
label: e("fields.hourlyRate.label"),
|
|
@@ -125,7 +125,7 @@ function ee({
|
|
|
125
125
|
}
|
|
126
126
|
),
|
|
127
127
|
/* @__PURE__ */ i(
|
|
128
|
-
|
|
128
|
+
O,
|
|
129
129
|
{
|
|
130
130
|
name: "startDate",
|
|
131
131
|
label: e("fields.startDate.label"),
|
|
@@ -6,30 +6,21 @@ import { z as s } from "zod";
|
|
|
6
6
|
import { useContractorsCreateMutation as k } from "@gusto/embedded-api-v-2025-11-15/react-query/contractorsCreate";
|
|
7
7
|
import { useContractorsUpdateMutation as K } from "@gusto/embedded-api-v-2025-11-15/react-query/contractorsUpdate";
|
|
8
8
|
import { WageType as L, ContractorType as J } from "@gusto/embedded-api-v-2025-11-15/models/components/contractor";
|
|
9
|
-
import "react/jsx-runtime";
|
|
10
|
-
import "react-error-boundary";
|
|
11
|
-
import "@tanstack/react-query";
|
|
12
9
|
import { useBase as Q } from "../../Base/useBase.js";
|
|
13
|
-
import "
|
|
14
|
-
import "@gusto/embedded-api-v-2025-11-15/models/errors/gustoembeddederror";
|
|
15
|
-
import "@gusto/embedded-api-v-2025-11-15/models/errors/sdkvalidationerror";
|
|
16
|
-
import "@gusto/embedded-api-v-2025-11-15/models/errors/unprocessableentityerror";
|
|
17
|
-
import { SDKInternalError as Y } from "../../../types/sdkError.js";
|
|
10
|
+
import { useI18n as Y } from "../../../i18n/I18n.js";
|
|
18
11
|
import { ContractorSelfOnboardingStatuses as x, componentEvents as b, ContractorOnboardingStatus as ee } from "../../../shared/constants.js";
|
|
19
|
-
import "../../../
|
|
20
|
-
import "../../../
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
import { normalizeEin as ie } from "../../../helpers/federalEin.js";
|
|
26
|
-
const n = L, a = J, ne = s.object({
|
|
12
|
+
import { SSN_REGEX as oe, NAME_REGEX as T } from "../../../helpers/validations.js";
|
|
13
|
+
import { removeNonDigits as se } from "../../../helpers/formattedStrings.js";
|
|
14
|
+
import { formatDateToStringDate as ae } from "../../../helpers/dateFormatting.js";
|
|
15
|
+
import { normalizeEin as te } from "../../../helpers/federalEin.js";
|
|
16
|
+
import { SDKInternalError as ne } from "../../../types/sdkError.js";
|
|
17
|
+
const i = L, a = J, ie = s.object({
|
|
27
18
|
// Self-onboarding toggle
|
|
28
19
|
selfOnboarding: s.boolean(),
|
|
29
20
|
email: s.string().email().optional(),
|
|
30
21
|
// Required contractor fields
|
|
31
22
|
contractorType: s.enum([a.Individual, a.Business]),
|
|
32
|
-
wageType: s.enum([
|
|
23
|
+
wageType: s.enum([i.Hourly, i.Fixed]),
|
|
33
24
|
startDate: s.date(),
|
|
34
25
|
// Individual contractor fields
|
|
35
26
|
firstName: s.string().min(1).regex(T).optional(),
|
|
@@ -41,79 +32,79 @@ const n = L, a = J, ne = s.object({
|
|
|
41
32
|
ein: s.string().optional(),
|
|
42
33
|
// Wage fields
|
|
43
34
|
hourlyRate: s.number().min(0).optional()
|
|
44
|
-
}), re = (t, f,
|
|
45
|
-
(e,
|
|
46
|
-
if (e.selfOnboarding && !e.email &&
|
|
35
|
+
}), re = (t, f, u) => ie.superRefine(
|
|
36
|
+
(e, n) => {
|
|
37
|
+
if (e.selfOnboarding && !e.email && n.addIssue({
|
|
47
38
|
code: s.ZodIssueCode.custom,
|
|
48
39
|
path: ["email"],
|
|
49
40
|
message: t("validations.email")
|
|
50
41
|
}), e.contractorType === a.Individual)
|
|
51
|
-
if (e.firstName ||
|
|
42
|
+
if (e.firstName || n.addIssue({
|
|
52
43
|
code: s.ZodIssueCode.custom,
|
|
53
44
|
path: ["firstName"],
|
|
54
45
|
message: t("validations.firstName")
|
|
55
|
-
}), e.lastName ||
|
|
46
|
+
}), e.lastName || n.addIssue({
|
|
56
47
|
code: s.ZodIssueCode.custom,
|
|
57
48
|
path: ["lastName"],
|
|
58
49
|
message: t("validations.lastName")
|
|
59
50
|
}), !e.ssn)
|
|
60
|
-
!f && !e.selfOnboarding &&
|
|
51
|
+
!f && !e.selfOnboarding && n.addIssue({
|
|
61
52
|
code: s.ZodIssueCode.custom,
|
|
62
53
|
path: ["ssn"],
|
|
63
54
|
message: t("validations.ssn")
|
|
64
55
|
});
|
|
65
56
|
else {
|
|
66
|
-
const l =
|
|
67
|
-
|
|
57
|
+
const l = se(e.ssn);
|
|
58
|
+
oe.test(l) || n.addIssue({
|
|
68
59
|
code: s.ZodIssueCode.custom,
|
|
69
60
|
path: ["ssn"],
|
|
70
61
|
message: t("validations.ssnFormat")
|
|
71
62
|
});
|
|
72
63
|
}
|
|
73
64
|
if (e.contractorType === a.Business)
|
|
74
|
-
if (e.businessName ||
|
|
65
|
+
if (e.businessName || n.addIssue({
|
|
75
66
|
code: s.ZodIssueCode.custom,
|
|
76
67
|
path: ["businessName"],
|
|
77
68
|
message: t("validations.businessName")
|
|
78
69
|
}), !e.ein)
|
|
79
|
-
!
|
|
70
|
+
!u && !e.selfOnboarding && n.addIssue({
|
|
80
71
|
code: s.ZodIssueCode.custom,
|
|
81
72
|
path: ["ein"],
|
|
82
73
|
message: t("validations.ein")
|
|
83
74
|
});
|
|
84
75
|
else {
|
|
85
|
-
const l =
|
|
86
|
-
/^\d{2}-\d{7}$/.test(l) ||
|
|
76
|
+
const l = te(e.ein);
|
|
77
|
+
/^\d{2}-\d{7}$/.test(l) || n.addIssue({
|
|
87
78
|
code: s.ZodIssueCode.custom,
|
|
88
79
|
path: ["ein"],
|
|
89
80
|
message: t("validations.einFormat")
|
|
90
81
|
});
|
|
91
82
|
}
|
|
92
|
-
e.wageType ===
|
|
83
|
+
e.wageType === i.Hourly && (e.hourlyRate === void 0 || e.hourlyRate < 0) && n.addIssue({
|
|
93
84
|
code: s.ZodIssueCode.custom,
|
|
94
85
|
path: ["hourlyRate"],
|
|
95
86
|
message: t("validations.hourlyRate")
|
|
96
87
|
});
|
|
97
88
|
}
|
|
98
89
|
);
|
|
99
|
-
function
|
|
90
|
+
function Re({
|
|
100
91
|
companyId: t,
|
|
101
92
|
contractorId: f,
|
|
102
|
-
defaultValues:
|
|
93
|
+
defaultValues: u,
|
|
103
94
|
existingContractor: e
|
|
104
95
|
}) {
|
|
105
|
-
|
|
106
|
-
const { t:
|
|
107
|
-
|
|
96
|
+
Y("Contractor.Profile");
|
|
97
|
+
const { t: n } = $("Contractor.Profile"), { onEvent: l, baseSubmitHandler: g } = Q(), S = re(
|
|
98
|
+
n,
|
|
108
99
|
e?.hasSsn ?? !1,
|
|
109
100
|
e?.hasEin ?? !1
|
|
110
101
|
), { mutateAsync: R, isPending: w } = k(), { mutateAsync: O, isPending: D } = K(), I = G(
|
|
111
102
|
() => ({
|
|
112
103
|
selfOnboarding: !1,
|
|
113
104
|
contractorType: a.Business,
|
|
114
|
-
wageType:
|
|
105
|
+
wageType: i.Fixed,
|
|
115
106
|
startDate: /* @__PURE__ */ new Date(),
|
|
116
|
-
...
|
|
107
|
+
...u,
|
|
117
108
|
// Override with existing contractor data if available
|
|
118
109
|
...e && {
|
|
119
110
|
selfOnboarding: e.onboardingStatus ? (
|
|
@@ -121,7 +112,7 @@ function Ae({
|
|
|
121
112
|
x.has(e.onboardingStatus)
|
|
122
113
|
) : !1,
|
|
123
114
|
contractorType: e.type || a.Business,
|
|
124
|
-
wageType: e.wageType ||
|
|
115
|
+
wageType: e.wageType || i.Fixed,
|
|
125
116
|
startDate: e.startDate ? new Date(e.startDate) : /* @__PURE__ */ new Date(),
|
|
126
117
|
firstName: e.firstName || void 0,
|
|
127
118
|
middleInitial: e.middleInitial || void 0,
|
|
@@ -134,23 +125,23 @@ function Ae({
|
|
|
134
125
|
})() : void 0
|
|
135
126
|
}
|
|
136
127
|
}),
|
|
137
|
-
[e,
|
|
128
|
+
[e, u]
|
|
138
129
|
), d = j({
|
|
139
130
|
resolver: X(S),
|
|
140
131
|
defaultValues: I,
|
|
141
132
|
...e && { values: I },
|
|
142
133
|
resetOptions: { keepDirtyValues: !0 }
|
|
143
|
-
}), { handleSubmit: E, formState: F } = d,
|
|
134
|
+
}), { handleSubmit: E, formState: F } = d, m = v({ control: d.control, name: "contractorType" }), P = v({ control: d.control, name: "wageType" }), y = v({
|
|
144
135
|
control: d.control,
|
|
145
136
|
name: "selfOnboarding"
|
|
146
137
|
}), N = (o) => {
|
|
147
138
|
const r = {
|
|
148
139
|
type: o.contractorType,
|
|
149
140
|
wageType: o.wageType,
|
|
150
|
-
startDate:
|
|
141
|
+
startDate: ae(o.startDate) || "",
|
|
151
142
|
selfOnboarding: o.selfOnboarding,
|
|
152
143
|
email: o.selfOnboarding ? o.email : void 0,
|
|
153
|
-
hourlyRate: o.wageType ===
|
|
144
|
+
hourlyRate: o.wageType === i.Hourly ? String(o.hourlyRate) : void 0,
|
|
154
145
|
isActive: !0
|
|
155
146
|
};
|
|
156
147
|
return o.contractorType === a.Individual ? {
|
|
@@ -176,7 +167,7 @@ function Ae({
|
|
|
176
167
|
let c = e?.uuid;
|
|
177
168
|
if (e) {
|
|
178
169
|
if (!e.version)
|
|
179
|
-
throw new
|
|
170
|
+
throw new ne("Contractor version is required for updates");
|
|
180
171
|
const h = e.version, p = B(r, h), V = await O({
|
|
181
172
|
request: {
|
|
182
173
|
contractorUuid: c,
|
|
@@ -198,12 +189,12 @@ function Ae({
|
|
|
198
189
|
contractorId: c
|
|
199
190
|
});
|
|
200
191
|
});
|
|
201
|
-
}, A = !!y, H =
|
|
192
|
+
}, A = !!y, H = m === a.Business, Z = m === a.Individual, _ = P === i.Hourly, U = m === a.Individual && !y, M = m === a.Business && !y, W = [
|
|
202
193
|
{ label: "Individual", value: a.Individual },
|
|
203
194
|
{ label: "Business", value: a.Business }
|
|
204
195
|
], q = [
|
|
205
|
-
{ label: "Hourly", value:
|
|
206
|
-
{ label: "Fixed", value:
|
|
196
|
+
{ label: "Hourly", value: i.Hourly },
|
|
197
|
+
{ label: "Fixed", value: i.Fixed }
|
|
207
198
|
], z = w || D;
|
|
208
199
|
return {
|
|
209
200
|
// Form methods and submission
|
|
@@ -229,8 +220,8 @@ function Ae({
|
|
|
229
220
|
}
|
|
230
221
|
export {
|
|
231
222
|
a as ContractorType,
|
|
232
|
-
|
|
223
|
+
i as WageType,
|
|
233
224
|
re as createContractorProfileValidationSchema,
|
|
234
|
-
|
|
225
|
+
Re as useContractorProfile
|
|
235
226
|
};
|
|
236
227
|
//# sourceMappingURL=useContractorProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsUpdate'\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 {\n WageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { SDKInternalError } from '@/types/sdkError'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n selfOnboarding: z.boolean(),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n }\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n }\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData, unknown, ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n ...(existingContractor && { values: formDefaultValues }),\n resetOptions: { keepDirtyValues: true },\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,OAAOA,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA;AAAA;AAAA,EAG1B,gBAAgBA,EAAE,KAAK,CAAC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AA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
|
|
1
|
+
{"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api-v-2025-11-15/react-query/contractorsUpdate'\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 {\n WageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api-v-2025-11-15/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { SDKInternalError } from '@/types/sdkError'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n selfOnboarding: z.boolean(),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n }\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n }\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData, unknown, ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n ...(existingContractor && { values: formDefaultValues }),\n resetOptions: { keepDirtyValues: true },\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;AA6BO,MAAM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oB,IAAwB;AAAA,IAC5B,EAAE,OAAO,cAAc,OAAOjE,EAAe,WAAA;AAAA,IAC7C,EAAE,OAAO,YAAY,OAAOA,EAAe,SAAA;AAAA,EAAS,GAGhDkE,IAAkB;AAAA,IACtB,EAAE,OAAO,UAAU,OAAOpE,EAAS,OAAA;AAAA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
|
|
@@ -5,7 +5,6 @@ import { CompensationCardContextual as i } from "./CompensationComponents.js";
|
|
|
5
5
|
import { compensationStateMachine as p } from "./compensationStateMachine.js";
|
|
6
6
|
import { Flow as s } from "../../../Flow/Flow.js";
|
|
7
7
|
import { BaseBoundaries as c } from "../../../Base/Base.js";
|
|
8
|
-
import "../../../Base/useBase.js";
|
|
9
8
|
import { useComponentDictionary as u, useI18n as f } from "../../../../i18n/I18n.js";
|
|
10
9
|
function l({ employeeId: o, onEvent: n }) {
|
|
11
10
|
f("Employee.Management.Compensation");
|
|
@@ -20,7 +19,7 @@ function l({ employeeId: o, onEvent: n }) {
|
|
|
20
19
|
);
|
|
21
20
|
return /* @__PURE__ */ m(s, { machine: e, onEvent: n });
|
|
22
21
|
}
|
|
23
|
-
function
|
|
22
|
+
function w({
|
|
24
23
|
dictionary: o,
|
|
25
24
|
FallbackComponent: n,
|
|
26
25
|
...e
|
|
@@ -35,6 +34,6 @@ function B({
|
|
|
35
34
|
);
|
|
36
35
|
}
|
|
37
36
|
export {
|
|
38
|
-
|
|
37
|
+
w as Compensation
|
|
39
38
|
};
|
|
40
39
|
//# sourceMappingURL=Compensation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compensation.js","sources":["../../../../../src/components/Employee/Compensation/management/Compensation.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport {\n CompensationCardContextual,\n type CompensationContextInterface,\n} from './CompensationComponents'\nimport { compensationStateMachine } from './compensationStateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport {\n BaseBoundaries,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { type EventType } from '@/shared/constants'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { useI18n } from '@/i18n'\nimport type { OnEventType } from '@/components/Base/useBase'\n\n/**\n * Props for {@link Compensation}.\n *\n * @public\n */\nexport interface CompensationProps extends CommonComponentInterface<'Employee.Management.Compensation'> {\n /** The associated employee identifier. */\n employeeId: string\n /** Callback invoked when the block emits an event. See the events table on {@link Compensation} for the available event types and payloads. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nfunction CompensationFlow({ employeeId, onEvent }: CompensationProps) {\n useI18n('Employee.Management.Compensation')\n\n const machine = useMemo(\n () =>\n createMachine('card', compensationStateMachine, (ctx: CompensationContextInterface) => ({\n ...ctx,\n component: CompensationCardContextual,\n employeeId,\n successAlert: null,\n })),\n [employeeId],\n )\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n\n/**\n * Self-contained block for viewing and managing an employee's jobs and compensation — the same experience the dashboard surfaces, but as a drop-in component that doesn't require the surrounding dashboard chrome.\n *\n * @remarks\n * Renders a read-only card showing the employee's job(s), pay type, wage, and effective date, along with affordances to edit a job's compensation, add a first job from the empty state, add another job (when the primary job is Nonexempt), delete a non-primary job, and cancel a scheduled future-dated change. Choosing to edit or add a job swaps the card for the corresponding form; a successful add returns to the card with a dismissible \"Job successfully added.\" alert, an edit returns to the card without an alert, and cancelling returns without saving. Wraps everything in error and suspense boundaries.\n *\n * The card and form surfaces ({@link CompensationCard}, {@link CompensationEditForm}, {@link CompensationAddJobForm}, {@link CompensationAddAnotherJobForm}) are also exported individually for cases where that orchestration is the wrong fit — for example, when a form needs to render in a modal or drawer, when the card needs to appear read-only with no edit/add affordances, or when the swap is driven by a router. Using them directly means owning the swap, the alert, and any cross-component state yourself.\n *\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/compensation/card/editRequested` | Fired when an \"Edit\" CTA is clicked for a job; the block opens the edit form for that job | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/addRequested` | Fired when the \"Add job\" CTA is clicked from the card's empty state; the block opens the add-first-job form | `{ employeeId: string }` |\n * | `employee/management/compensation/card/addAnotherRequested` | Fired when the \"Add another job\" CTA is clicked; the block opens the add-another-job form | `{ employeeId: string }` |\n * | `employee/management/compensation/card/jobDeleted` | Fired after a non-primary job is deleted via the card's confirm dialog; the block stays on the card | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/changeCancelled` | Fired after a scheduled future-dated change is cancelled from the card; the block stays on the card | `{ employeeId: string, compensationId: string }` |\n * | `employee/management/compensation/editForm/submitted` | Fired after an edit-compensation save completes; the block returns to the card view | Updated `Compensation` entity |\n * | `employee/management/compensation/editForm/cancelled` | Fired when the user cancels the edit form; the block returns to the card view | — |\n * | `employee/management/compensation/addJobForm/submitted` | Fired after the first job + compensation are saved; the block returns to the card 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 block returns to the card view | — |\n * | `employee/management/compensation/addAnotherJobForm/submitted` | Fired after a secondary job + compensation are saved; the block returns to the card 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 block returns to the card view | — |\n * | `employee/management/compensation/alertDismissed` | Fired when the user dismisses the \"Job added\" success alert above the card | `null` |\n *\n * @param props - See {@link CompensationProps}.\n * @returns The rendered compensation block.\n * @public\n * @group Block Components\n */\nexport function Compensation({\n dictionary,\n FallbackComponent,\n ...props\n}: CompensationProps & BaseComponentInterface<'Employee.Management.Compensation'>) {\n useComponentDictionary('Employee.Management.Compensation', dictionary)\n return (\n <BaseBoundaries\n componentName=\"Employee.Management.Compensation\"\n FallbackComponent={FallbackComponent}\n >\n <CompensationFlow {...props} />\n </BaseBoundaries>\n )\n}\n"],"names":["CompensationFlow","employeeId","onEvent","useI18n","machine","useMemo","createMachine","compensationStateMachine","ctx","CompensationCardContextual","jsx","Flow","Compensation","dictionary","FallbackComponent","props","useComponentDictionary","BaseBoundaries"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Compensation.js","sources":["../../../../../src/components/Employee/Compensation/management/Compensation.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport {\n CompensationCardContextual,\n type CompensationContextInterface,\n} from './CompensationComponents'\nimport { compensationStateMachine } from './compensationStateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport {\n BaseBoundaries,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { type EventType } from '@/shared/constants'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { useI18n } from '@/i18n'\nimport type { OnEventType } from '@/components/Base/useBase'\n\n/**\n * Props for {@link Compensation}.\n *\n * @public\n */\nexport interface CompensationProps extends CommonComponentInterface<'Employee.Management.Compensation'> {\n /** The associated employee identifier. */\n employeeId: string\n /** Callback invoked when the block emits an event. See the events table on {@link Compensation} for the available event types and payloads. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nfunction CompensationFlow({ employeeId, onEvent }: CompensationProps) {\n useI18n('Employee.Management.Compensation')\n\n const machine = useMemo(\n () =>\n createMachine('card', compensationStateMachine, (ctx: CompensationContextInterface) => ({\n ...ctx,\n component: CompensationCardContextual,\n employeeId,\n successAlert: null,\n })),\n [employeeId],\n )\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n\n/**\n * Self-contained block for viewing and managing an employee's jobs and compensation — the same experience the dashboard surfaces, but as a drop-in component that doesn't require the surrounding dashboard chrome.\n *\n * @remarks\n * Renders a read-only card showing the employee's job(s), pay type, wage, and effective date, along with affordances to edit a job's compensation, add a first job from the empty state, add another job (when the primary job is Nonexempt), delete a non-primary job, and cancel a scheduled future-dated change. Choosing to edit or add a job swaps the card for the corresponding form; a successful add returns to the card with a dismissible \"Job successfully added.\" alert, an edit returns to the card without an alert, and cancelling returns without saving. Wraps everything in error and suspense boundaries.\n *\n * The card and form surfaces ({@link CompensationCard}, {@link CompensationEditForm}, {@link CompensationAddJobForm}, {@link CompensationAddAnotherJobForm}) are also exported individually for cases where that orchestration is the wrong fit — for example, when a form needs to render in a modal or drawer, when the card needs to appear read-only with no edit/add affordances, or when the swap is driven by a router. Using them directly means owning the swap, the alert, and any cross-component state yourself.\n *\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/compensation/card/editRequested` | Fired when an \"Edit\" CTA is clicked for a job; the block opens the edit form for that job | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/addRequested` | Fired when the \"Add job\" CTA is clicked from the card's empty state; the block opens the add-first-job form | `{ employeeId: string }` |\n * | `employee/management/compensation/card/addAnotherRequested` | Fired when the \"Add another job\" CTA is clicked; the block opens the add-another-job form | `{ employeeId: string }` |\n * | `employee/management/compensation/card/jobDeleted` | Fired after a non-primary job is deleted via the card's confirm dialog; the block stays on the card | `{ employeeId: string, jobId: string }` |\n * | `employee/management/compensation/card/changeCancelled` | Fired after a scheduled future-dated change is cancelled from the card; the block stays on the card | `{ employeeId: string, compensationId: string }` |\n * | `employee/management/compensation/editForm/submitted` | Fired after an edit-compensation save completes; the block returns to the card view | Updated `Compensation` entity |\n * | `employee/management/compensation/editForm/cancelled` | Fired when the user cancels the edit form; the block returns to the card view | — |\n * | `employee/management/compensation/addJobForm/submitted` | Fired after the first job + compensation are saved; the block returns to the card 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 block returns to the card view | — |\n * | `employee/management/compensation/addAnotherJobForm/submitted` | Fired after a secondary job + compensation are saved; the block returns to the card 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 block returns to the card view | — |\n * | `employee/management/compensation/alertDismissed` | Fired when the user dismisses the \"Job added\" success alert above the card | `null` |\n *\n * @param props - See {@link CompensationProps}.\n * @returns The rendered compensation block.\n * @public\n * @group Block Components\n */\nexport function Compensation({\n dictionary,\n FallbackComponent,\n ...props\n}: CompensationProps & BaseComponentInterface<'Employee.Management.Compensation'>) {\n useComponentDictionary('Employee.Management.Compensation', dictionary)\n return (\n <BaseBoundaries\n componentName=\"Employee.Management.Compensation\"\n FallbackComponent={FallbackComponent}\n >\n <CompensationFlow {...props} />\n </BaseBoundaries>\n )\n}\n"],"names":["CompensationFlow","employeeId","onEvent","useI18n","machine","useMemo","createMachine","compensationStateMachine","ctx","CompensationCardContextual","jsx","Flow","Compensation","dictionary","FallbackComponent","props","useComponentDictionary","BaseBoundaries"],"mappings":";;;;;;;;AA8BA,SAASA,EAAiB,EAAE,YAAAC,GAAY,SAAAC,KAA8B;AACpE,EAAAC,EAAQ,kCAAkC;AAE1C,QAAMC,IAAUC;AAAA,IACd,MACEC,EAAc,QAAQC,GAA0B,CAACC,OAAuC;AAAA,MACtF,GAAGA;AAAA,MACH,WAAWC;AAAA,MACX,YAAAR;AAAA,MACA,cAAc;AAAA,IAAA,EACd;AAAA,IACJ,CAACA,CAAU;AAAA,EAAA;AAGb,SAAO,gBAAAS,EAACC,GAAA,EAAK,SAAAP,GAAkB,SAAAF,EAAA,CAAkB;AACnD;AA8BO,SAASU,EAAa;AAAA,EAC3B,YAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,GAAGC;AACL,GAAmF;AACjF,SAAAC,EAAuB,oCAAoCH,CAAU,GAEnE,gBAAAH;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,mBAAAH;AAAA,MAEA,UAAA,gBAAAJ,EAACV,GAAA,EAAkB,GAAGe,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGnC;"}
|
|
@@ -7,14 +7,13 @@ import { useCompensationForm as y } from "../../shared/useCompensationForm/useCo
|
|
|
7
7
|
import { AddCompensationFormBody as v } from "../../shared/AddCompensationFormBody.js";
|
|
8
8
|
import { useManagementCompensationDictionary as O } from "../useManagementCompensationDictionary.js";
|
|
9
9
|
import T from "./CompensationAddAnotherJobForm.module.scss.js";
|
|
10
|
-
import { BaseBoundaries as R, BaseLayout as
|
|
11
|
-
import "../../../../Base/useBase.js";
|
|
10
|
+
import { BaseBoundaries as R, BaseLayout as c } from "../../../../Base/Base.js";
|
|
12
11
|
import { Form as I } from "../../../../Common/Form/Form.js";
|
|
13
12
|
import { useComponentDictionary as L, useI18n as S } from "../../../../../i18n/I18n.js";
|
|
14
|
-
import { composeErrorHandler as
|
|
13
|
+
import { composeErrorHandler as p } from "../../../../../partner-hook-utils/composeErrorHandler.js";
|
|
15
14
|
import { composeSubmitHandler as J } from "../../../../../partner-hook-utils/form/composeSubmitHandler.js";
|
|
16
15
|
import { componentEvents as l } from "../../../../../shared/constants.js";
|
|
17
|
-
function
|
|
16
|
+
function X({
|
|
18
17
|
dictionary: i,
|
|
19
18
|
...r
|
|
20
19
|
}) {
|
|
@@ -41,8 +40,8 @@ function H({
|
|
|
41
40
|
shouldFocusError: !1
|
|
42
41
|
});
|
|
43
42
|
if (t.isLoading || e.isLoading) {
|
|
44
|
-
const o =
|
|
45
|
-
return /* @__PURE__ */ n(
|
|
43
|
+
const o = p([t, e]);
|
|
44
|
+
return /* @__PURE__ */ n(c, { isLoading: !0, error: o.errors });
|
|
46
45
|
}
|
|
47
46
|
const C = t.data.jobs?.find((o) => o.primary)?.hireDate ?? void 0, d = J([t, e], async () => {
|
|
48
47
|
const o = await t.actions.onSubmit({ employeeId: i, hireDate: C });
|
|
@@ -62,8 +61,8 @@ function H({
|
|
|
62
61
|
l.EMPLOYEE_MANAGEMENT_COMPENSATION_ADD_ANOTHER_JOB_FORM_SUBMITTED,
|
|
63
62
|
u.data
|
|
64
63
|
);
|
|
65
|
-
}), M =
|
|
66
|
-
return /* @__PURE__ */ n("section", { className: D(T.container, r), children: /* @__PURE__ */ n(
|
|
64
|
+
}), M = p([d]), g = t.status.isPending || e.status.isPending;
|
|
65
|
+
return /* @__PURE__ */ n("section", { className: D(T.container, r), children: /* @__PURE__ */ n(c, { error: M.errors, children: /* @__PURE__ */ n(I, { onSubmit: d.handleSubmit, children: /* @__PURE__ */ n(
|
|
67
66
|
v,
|
|
68
67
|
{
|
|
69
68
|
jobForm: t,
|
|
@@ -81,6 +80,6 @@ function H({
|
|
|
81
80
|
) }) }) });
|
|
82
81
|
}
|
|
83
82
|
export {
|
|
84
|
-
|
|
83
|
+
X as CompensationAddAnotherJobForm
|
|
85
84
|
};
|
|
86
85
|
//# sourceMappingURL=CompensationAddAnotherJobForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompensationAddAnotherJobForm.js","sources":["../../../../../../src/components/Employee/Compensation/management/CompensationAddAnotherJobForm/CompensationAddAnotherJobForm.tsx"],"sourcesContent":["import { useState } from 'react'\nimport classNames from 'classnames'\nimport { useTranslation } from 'react-i18next'\nimport { useJobForm } from '../../shared/useJobForm'\nimport { useCompensationForm } from '../../shared/useCompensationForm'\nimport { AddCompensationFormBody } from '../../shared/AddCompensationFormBody'\nimport { useManagementCompensationDictionary } from '../useManagementCompensationDictionary'\nimport styles from './CompensationAddAnotherJobForm.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\n/**\n * Props for {@link CompensationAddAnotherJobForm}.\n *\n * @public\n */\nexport interface CompensationAddAnotherJobFormProps extends CommonComponentInterface<'Employee.Management.Compensation'> {\n /** The associated employee identifier. */\n employeeId: string\n /** Callback invoked when the form emits an event. See the events table on {@link CompensationAddAnotherJobForm} for the available event types and payloads. */\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**\n * Standalone form for adding a secondary job and compensation to an employee from the management surface.\n *\n * @remarks\n * Routed from {@link CompensationCard}'s `employee/management/compensation/card/addAnotherRequested` event. Emits its own scoped `submitted` and `cancelled` events — both are your cue to return to the card. {@link Compensation} bundles the card, this form, and the swap and alert wiring as a single drop-in; reach for this form directly only when that orchestration is the wrong fit.\n *\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/compensation/addAnotherJobForm/submitted` | Fired after the secondary job and compensation are saved; use it to return to the card | Saved `Compensation` entity |\n * | `employee/management/compensation/addAnotherJobForm/cancelled` | Fired when the user clicks Cancel; use it to return to the card | — |\n *\n * @param props - See {@link CompensationAddAnotherJobFormProps}.\n * @returns The rendered add-another-job form.\n * @public\n * @group Block Components\n */\nexport function CompensationAddAnotherJobForm({\n dictionary,\n ...props\n}: CompensationAddAnotherJobFormProps) {\n useComponentDictionary('Employee.Management.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Management.Compensation\">\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction Root({\n employeeId,\n className,\n onEvent,\n}: Omit<CompensationAddAnotherJobFormProps, 'dictionary'>) {\n useI18n('Employee.Management.Compensation')\n const { t } = useTranslation('Employee.Management.Compensation')\n const formDictionary = useManagementCompensationDictionary()\n\n // Track jobId locally so a partial-failure submit chain (job POST succeeds,\n // comp PUT fails) doesn't re-POST and create a duplicate job on retry.\n const [resolvedJobId, setResolvedJobId] = useState<string | undefined>(undefined)\n\n const jobForm = useJobForm({\n employeeId,\n jobId: resolvedJobId,\n withHireDateField: false,\n optionalFieldsToRequire: { update: ['title'] },\n shouldFocusError: false,\n })\n\n const resolvedCompensationId = jobForm.isLoading\n ? undefined\n : (jobForm.data.currentJob?.currentCompensationUuid ?? undefined)\n\n const compensationForm = useCompensationForm({\n employeeId,\n jobId: resolvedJobId,\n compensationId: resolvedCompensationId,\n withEffectiveDateField: true,\n optionalFieldsToRequire: { update: ['flsaStatus', 'rate', 'paymentUnit'] },\n shouldFocusError: false,\n })\n\n if (jobForm.isLoading || compensationForm.isLoading) {\n const loadingErrorHandling = composeErrorHandler([jobForm, compensationForm])\n return <BaseLayout isLoading error={loadingErrorHandling.errors} />\n }\n\n // The API defaults a secondary job's hire_date to the primary job's hire_date\n // when omitted. We pass it explicitly to satisfy the SDK hook's requirement\n // and mirror the API's own default behavior. React Query dedupes this query\n // since useJobForm has already loaded it.\n const primaryHireDate = jobForm.data.jobs?.find(j => j.primary)?.hireDate ?? undefined\n\n const submitResult = composeSubmitHandler([jobForm, compensationForm], async () => {\n const jobResult = await jobForm.actions.onSubmit({ employeeId, hireDate: primaryHireDate })\n if (!jobResult) return\n\n const stubCompensation = jobResult.data.compensations?.find(\n c => c.uuid === jobResult.data.currentCompensationUuid,\n )\n\n const compensationResult = await compensationForm.actions.onSubmit({\n jobId: jobResult.data.uuid,\n compensationId: jobResult.data.currentCompensationUuid ?? undefined,\n compensationVersion: stubCompensation?.version ?? undefined,\n })\n if (!compensationResult) {\n setResolvedJobId(jobResult.data.uuid)\n return\n }\n\n onEvent(\n componentEvents.EMPLOYEE_MANAGEMENT_COMPENSATION_ADD_ANOTHER_JOB_FORM_SUBMITTED,\n compensationResult.data,\n )\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n const isPending = jobForm.status.isPending || compensationForm.status.isPending\n\n return (\n <section className={classNames(styles.container, className)}>\n <BaseLayout error={errorHandling.errors}>\n <Form onSubmit={submitResult.handleSubmit}>\n <AddCompensationFormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n title={t('addAnotherJobTitle')}\n submitCtaLabel={t('saveNewJobCta')}\n isPending={isPending}\n onCancel={() => {\n onEvent(\n componentEvents.EMPLOYEE_MANAGEMENT_COMPENSATION_ADD_ANOTHER_JOB_FORM_CANCELLED,\n )\n }}\n dictionary={formDictionary}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["CompensationAddAnotherJobForm","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","Root","employeeId","className","onEvent","useI18n","t","useTranslation","formDictionary","useManagementCompensationDictionary","resolvedJobId","setResolvedJobId","useState","jobForm","useJobForm","resolvedCompensationId","compensationForm","useCompensationForm","loadingErrorHandling","composeErrorHandler","BaseLayout","primaryHireDate","j","submitResult","composeSubmitHandler","jobResult","stubCompensation","c","compensationResult","componentEvents","errorHandling","isPending","classNames","styles","Form","AddCompensationFormBody"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompensationAddAnotherJobForm.js","sources":["../../../../../../src/components/Employee/Compensation/management/CompensationAddAnotherJobForm/CompensationAddAnotherJobForm.tsx"],"sourcesContent":["import { useState } from 'react'\nimport classNames from 'classnames'\nimport { useTranslation } from 'react-i18next'\nimport { useJobForm } from '../../shared/useJobForm'\nimport { useCompensationForm } from '../../shared/useCompensationForm'\nimport { AddCompensationFormBody } from '../../shared/AddCompensationFormBody'\nimport { useManagementCompensationDictionary } from '../useManagementCompensationDictionary'\nimport styles from './CompensationAddAnotherJobForm.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\n/**\n * Props for {@link CompensationAddAnotherJobForm}.\n *\n * @public\n */\nexport interface CompensationAddAnotherJobFormProps extends CommonComponentInterface<'Employee.Management.Compensation'> {\n /** The associated employee identifier. */\n employeeId: string\n /** Callback invoked when the form emits an event. See the events table on {@link CompensationAddAnotherJobForm} for the available event types and payloads. */\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**\n * Standalone form for adding a secondary job and compensation to an employee from the management surface.\n *\n * @remarks\n * Routed from {@link CompensationCard}'s `employee/management/compensation/card/addAnotherRequested` event. Emits its own scoped `submitted` and `cancelled` events — both are your cue to return to the card. {@link Compensation} bundles the card, this form, and the swap and alert wiring as a single drop-in; reach for this form directly only when that orchestration is the wrong fit.\n *\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/management/compensation/addAnotherJobForm/submitted` | Fired after the secondary job and compensation are saved; use it to return to the card | Saved `Compensation` entity |\n * | `employee/management/compensation/addAnotherJobForm/cancelled` | Fired when the user clicks Cancel; use it to return to the card | — |\n *\n * @param props - See {@link CompensationAddAnotherJobFormProps}.\n * @returns The rendered add-another-job form.\n * @public\n * @group Block Components\n */\nexport function CompensationAddAnotherJobForm({\n dictionary,\n ...props\n}: CompensationAddAnotherJobFormProps) {\n useComponentDictionary('Employee.Management.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Management.Compensation\">\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction Root({\n employeeId,\n className,\n onEvent,\n}: Omit<CompensationAddAnotherJobFormProps, 'dictionary'>) {\n useI18n('Employee.Management.Compensation')\n const { t } = useTranslation('Employee.Management.Compensation')\n const formDictionary = useManagementCompensationDictionary()\n\n // Track jobId locally so a partial-failure submit chain (job POST succeeds,\n // comp PUT fails) doesn't re-POST and create a duplicate job on retry.\n const [resolvedJobId, setResolvedJobId] = useState<string | undefined>(undefined)\n\n const jobForm = useJobForm({\n employeeId,\n jobId: resolvedJobId,\n withHireDateField: false,\n optionalFieldsToRequire: { update: ['title'] },\n shouldFocusError: false,\n })\n\n const resolvedCompensationId = jobForm.isLoading\n ? undefined\n : (jobForm.data.currentJob?.currentCompensationUuid ?? undefined)\n\n const compensationForm = useCompensationForm({\n employeeId,\n jobId: resolvedJobId,\n compensationId: resolvedCompensationId,\n withEffectiveDateField: true,\n optionalFieldsToRequire: { update: ['flsaStatus', 'rate', 'paymentUnit'] },\n shouldFocusError: false,\n })\n\n if (jobForm.isLoading || compensationForm.isLoading) {\n const loadingErrorHandling = composeErrorHandler([jobForm, compensationForm])\n return <BaseLayout isLoading error={loadingErrorHandling.errors} />\n }\n\n // The API defaults a secondary job's hire_date to the primary job's hire_date\n // when omitted. We pass it explicitly to satisfy the SDK hook's requirement\n // and mirror the API's own default behavior. React Query dedupes this query\n // since useJobForm has already loaded it.\n const primaryHireDate = jobForm.data.jobs?.find(j => j.primary)?.hireDate ?? undefined\n\n const submitResult = composeSubmitHandler([jobForm, compensationForm], async () => {\n const jobResult = await jobForm.actions.onSubmit({ employeeId, hireDate: primaryHireDate })\n if (!jobResult) return\n\n const stubCompensation = jobResult.data.compensations?.find(\n c => c.uuid === jobResult.data.currentCompensationUuid,\n )\n\n const compensationResult = await compensationForm.actions.onSubmit({\n jobId: jobResult.data.uuid,\n compensationId: jobResult.data.currentCompensationUuid ?? undefined,\n compensationVersion: stubCompensation?.version ?? undefined,\n })\n if (!compensationResult) {\n setResolvedJobId(jobResult.data.uuid)\n return\n }\n\n onEvent(\n componentEvents.EMPLOYEE_MANAGEMENT_COMPENSATION_ADD_ANOTHER_JOB_FORM_SUBMITTED,\n compensationResult.data,\n )\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n const isPending = jobForm.status.isPending || compensationForm.status.isPending\n\n return (\n <section className={classNames(styles.container, className)}>\n <BaseLayout error={errorHandling.errors}>\n <Form onSubmit={submitResult.handleSubmit}>\n <AddCompensationFormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n title={t('addAnotherJobTitle')}\n submitCtaLabel={t('saveNewJobCta')}\n isPending={isPending}\n onCancel={() => {\n onEvent(\n componentEvents.EMPLOYEE_MANAGEMENT_COMPENSATION_ADD_ANOTHER_JOB_FORM_CANCELLED,\n )\n }}\n dictionary={formDictionary}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["CompensationAddAnotherJobForm","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","Root","employeeId","className","onEvent","useI18n","t","useTranslation","formDictionary","useManagementCompensationDictionary","resolvedJobId","setResolvedJobId","useState","jobForm","useJobForm","resolvedCompensationId","compensationForm","useCompensationForm","loadingErrorHandling","composeErrorHandler","BaseLayout","primaryHireDate","j","submitResult","composeSubmitHandler","jobResult","stubCompensation","c","compensationResult","componentEvents","errorHandling","isPending","classNames","styles","Form","AddCompensationFormBody"],"mappings":";;;;;;;;;;;;;;;AA4CO,SAASA,EAA8B;AAAA,EAC5C,YAAAC;AAAA,EACA,GAAGC;AACL,GAAuC;AACrC,SAAAC,EAAuB,oCAAoCF,CAAU,GAEnE,gBAAAG,EAACC,KAAe,eAAc,oCAC5B,4BAACC,GAAA,EAAM,GAAGJ,GAAO,EAAA,CACnB;AAEJ;AAEA,SAASI,EAAK;AAAA,EACZ,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AACF,GAA2D;AACzD,EAAAC,EAAQ,kCAAkC;AAC1C,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,kCAAkC,GACzDC,IAAiBC,EAAA,GAIjB,CAACC,GAAeC,CAAgB,IAAIC,EAA6B,MAAS,GAE1EC,IAAUC,EAAW;AAAA,IACzB,YAAAZ;AAAA,IACA,OAAOQ;AAAA,IACP,mBAAmB;AAAA,IACnB,yBAAyB,EAAE,QAAQ,CAAC,OAAO,EAAA;AAAA,IAC3C,kBAAkB;AAAA,EAAA,CACnB,GAEKK,IAAyBF,EAAQ,YACnC,SACCA,EAAQ,KAAK,YAAY,2BAA2B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