@gusto/embedded-react-sdk 0.57.2 → 0.57.3
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 +20 -0
- package/dist/components/Common/DateRangeFilter/DateRangeFilter.js +32 -32
- package/dist/components/Common/DateRangeFilter/DateRangeFilter.js.map +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +34 -14
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js +106 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js +136 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +38 -20
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +78 -44
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +45 -37
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +244 -95
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js +22 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js +13 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +48 -43
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js +57 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js +83 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js +84 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +109 -39
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js +5 -5
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js.map +1 -1
- package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js +4 -4
- package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js.map +1 -1
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js +3 -3
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js.map +1 -1
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js +6 -6
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js.map +1 -1
- package/dist/components/Contractor/Dashboard/Dashboard.js +20 -20
- package/dist/components/Contractor/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js +10 -10
- package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js.map +1 -1
- package/dist/components/Contractor/Landing/Landing.js +43 -39
- package/dist/components/Contractor/Landing/Landing.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +3 -3
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +1 -1
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +10 -10
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +4 -4
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +8 -8
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +5 -5
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js +3 -3
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js +1 -1
- package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js.map +1 -1
- package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js +2 -9
- package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Contractor/Submit/Submit.js +18 -18
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js +6 -6
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +25 -25
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js +15 -15
- package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.js +25 -25
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js +7 -7
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +6 -6
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
- package/dist/components/Employee/Landing/Landing.js +37 -33
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +27 -27
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js +6 -6
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js.map +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js +8 -15
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +11 -11
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js +12 -12
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +26 -26
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +66 -64
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +6 -6
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +6 -6
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +9 -9
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/helpers.js +1 -1
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/payrollTypes.js +1 -1
- package/dist/components/Payroll/payrollTypes.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js.map +1 -1
- package/dist/i18n/en/Company.Management.PaySchedule.json.js +31 -13
- package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +20 -12
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollHistory.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
- package/dist/package.json.js +1 -1
- package/dist/shared/constants.js +5 -5
- package/dist/shared/constants.js.map +1 -1
- package/dist/src/components/Common/DateRangeFilter/DateRangeFilter.d.ts +2 -2
- package/dist/src/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +10 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.d.ts +21 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.d.ts +34 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +9 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +5 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +10 -10
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +12 -4
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.d.ts +19 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.d.ts +17 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.d.ts +34 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +16 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.d.ts +23 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.d.ts +25 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.d.ts +1 -1
- package/dist/src/components/Contractor/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Employee/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/helpers.d.ts +2 -2
- package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +2 -2
- package/dist/src/i18n/types.d.ts +82 -4
- package/dist/src/models/external.d.ts +63 -48
- package/dist/src/shared/constants.d.ts +1 -1
- package/docs/guides/endpoint-inventory.json +33 -13
- package/package.json +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHomeAddressManagement.js","sources":["../../../../../src/components/Employee/HomeAddress/management/useHomeAddressManagement.tsx"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport type { EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { useEmployeeAddressesDeleteMutation } from '@gusto/embedded-api/react-query/employeeAddressesDelete'\nimport { useEmployeeAddressesGet } from '@gusto/embedded-api/react-query/employeeAddressesGet'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { useHomeAddressForm } from '@/components/Employee/Profile/shared/useHomeAddressForm'\nimport type {\n UseHomeAddressFormReady,\n UseHomeAddressFormResult,\n} from '@/components/Employee/Profile/shared/useHomeAddressForm'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseHookReady,\n HookErrorHandling,\n HookLoadingResult,\n} from '@/partner-hook-utils/types'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\n/**\n * Params for {@link useHomeAddressManagement}.\n *\n * @public\n */\nexport interface UseHomeAddressManagementParams {\n /** The associated employee identifier. */\n employeeId: string\n /** Event handler fired when a home address is deleted. */\n onEvent: OnEventType<EventType, unknown>\n}\n\ninterface UseHomeAddressManagementDataPendingForms extends Record<string, unknown> {\n employeeDisplayName: string\n employeeHomeAddresses: EmployeeAddress[] | undefined\n editingHomeAddressUuid: string | undefined\n editHomeAddressForm: UseHomeAddressFormResult\n createHomeAddressForm: UseHomeAddressFormResult\n}\n\ninterface UseHomeAddressManagementDataReady extends Record<string, unknown> {\n employeeDisplayName: string\n employeeHomeAddresses: EmployeeAddress[] | undefined\n editingHomeAddressUuid: string | undefined\n editHomeAddressForm: UseHomeAddressFormReady\n createHomeAddressForm: UseHomeAddressFormReady\n}\n\ninterface UseHomeAddressManagementStatusEmployeeError extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: true\n}\n\ninterface UseHomeAddressManagementStatusSuccess extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: false\n}\n\ninterface UseHomeAddressManagementActions {\n setEditAddressTarget: (homeAddressUuid: string | undefined) => void\n confirmDeleteHomeAddress: (homeAddressUuid: string) => Promise<boolean>\n}\n\ninterface UseHomeAddressManagementReadyEmployeeError extends BaseHookReady<\n UseHomeAddressManagementDataPendingForms,\n UseHomeAddressManagementStatusEmployeeError\n> {\n actions: UseHomeAddressManagementActions\n}\n\n/**\n * Ready state of {@link useHomeAddressManagement} when the employee was fetched successfully.\n *\n * @public\n */\nexport interface UseHomeAddressManagementReadySuccess extends BaseHookReady<\n UseHomeAddressManagementDataReady,\n UseHomeAddressManagementStatusSuccess\n> {\n /** Actions for changing edit target and confirming home address deletion. */\n actions: UseHomeAddressManagementActions\n}\n\ntype UseHomeAddressManagementReady =\n UseHomeAddressManagementReadyEmployeeError | UseHomeAddressManagementReadySuccess\n\n/**\n * Return type of {@link useHomeAddressManagement}.\n *\n * @public\n */\nexport type UseHomeAddressManagementResult = HookLoadingResult | UseHomeAddressManagementReady\n\n/**\n * Type guard for the success branch of {@link useHomeAddressManagement}.\n *\n * @param value - The hook result to narrow.\n * @returns `true` when the hook has finished loading and the employee fetch succeeded.\n * @public\n */\nexport function isUseHomeAddressManagementSuccess(\n value: UseHomeAddressManagementResult,\n): value is UseHomeAddressManagementReadySuccess {\n if (value.isLoading) {\n return false\n }\n return !value.status.isEmployeeError\n}\n\nfunction homeAddressFormsReady(\n editHomeAddressForm: UseHomeAddressFormResult,\n createHomeAddressForm: UseHomeAddressFormResult,\n): Pick<UseHomeAddressManagementDataReady, 'editHomeAddressForm' | 'createHomeAddressForm'> {\n if (editHomeAddressForm.isLoading) {\n throw new SDKInternalError('Edit home address form is still loading')\n }\n if (createHomeAddressForm.isLoading) {\n throw new SDKInternalError('Create home address form is still loading')\n }\n return {\n editHomeAddressForm,\n createHomeAddressForm,\n }\n}\n\n/**\n * Headless hook for managing an employee's home addresses.\n *\n * @remarks\n * Fetches the employee and their home addresses, exposes edit and create form hooks\n * for the address modal, and provides an action to delete a non-active address.\n * Use {@link isUseHomeAddressManagementSuccess} to narrow the ready state when the\n * employee fetch succeeded.\n *\n * @param params - {@link UseHomeAddressManagementParams}\n * @returns A {@link HookLoadingResult} while loading, or the ready state once data is available.\n * @public\n */\nexport function useHomeAddressManagement({\n employeeId,\n onEvent,\n}: UseHomeAddressManagementParams): UseHomeAddressManagementResult {\n const {\n baseSubmitHandler,\n error: rootSubmitError,\n setError: setRootSubmitError,\n } = useBaseSubmit('Employee.Management.HomeAddress')\n const deleteHomeAddressMutation = useEmployeeAddressesDeleteMutation()\n\n const [editTargetUuid, setEditAddressTarget] = useState<string | undefined>(undefined)\n\n const homeAddressesQuery = useEmployeeAddressesGet({ employeeId }, { enabled: !!employeeId })\n const employeeHomeAddresses = homeAddressesQuery.data?.employeeAddressList\n const currentHomeAddress =\n employeeHomeAddresses?.find(a => a.active) ?? employeeHomeAddresses?.[0]\n\n const editingHomeAddressUuid = editTargetUuid ?? currentHomeAddress?.uuid\n\n const editingHomeAddressRow = editingHomeAddressUuid\n ? employeeHomeAddresses?.find(a => a.uuid === editingHomeAddressUuid)\n : undefined\n\n const editHomeAddressForm = useHomeAddressForm({\n employeeId,\n homeAddressUuid: editingHomeAddressUuid,\n initialAddress: editingHomeAddressRow,\n withEffectiveDateField: true,\n })\n const createHomeAddressForm = useHomeAddressForm({\n employeeId,\n homeAddressUuid: undefined,\n withEffectiveDateField: true,\n })\n\n const employeeQuery = useEmployeesGet({ employeeId }, { enabled: !!employeeId })\n\n const employeeDisplayName = useMemo(() => {\n const employee = employeeQuery.data?.employee\n if (!employee) {\n return ''\n }\n return firstLastName({\n first_name: employee.firstName,\n last_name: employee.lastName,\n }).trim()\n }, [employeeQuery.data?.employee])\n\n // Form hooks are intentionally excluded here so their submit errors don't render in the\n // page-level BaseLayout outside the edit/create modal (SDK-930). The view renders those\n // errors inside the modal directly via the form hook's own errorHandling.\n const errorHandling: HookErrorHandling = composeErrorHandler(\n [employeeQuery, homeAddressesQuery],\n { submitError: rootSubmitError, setSubmitError: setRootSubmitError },\n )\n\n const confirmDeleteHomeAddress = async (homeAddressUuid: string): Promise<boolean> => {\n const snapshot = employeeHomeAddresses?.find(a => a.uuid === homeAddressUuid) ?? null\n\n let succeeded = false\n await baseSubmitHandler(\n { homeAddressUuid, snapshot },\n async ({ homeAddressUuid: uuid, snapshot: snap }) => {\n const target = employeeHomeAddresses?.find(a => a.uuid === uuid)\n if (!target) {\n throw new SDKInternalError('Home address not found')\n }\n if (target.active === true) {\n throw new SDKInternalError('Cannot delete the active home address')\n }\n\n await deleteHomeAddressMutation.mutateAsync({\n request: { homeAddressUuid: uuid },\n })\n succeeded = true\n if (snap) {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_HOME_ADDRESS_DELETED, snap)\n }\n },\n )\n return succeeded\n }\n\n const actions: UseHomeAddressManagementActions = {\n setEditAddressTarget,\n confirmDeleteHomeAddress,\n }\n\n const dataPayloadPendingForms: UseHomeAddressManagementDataPendingForms = {\n employeeDisplayName,\n employeeHomeAddresses,\n editingHomeAddressUuid,\n editHomeAddressForm,\n createHomeAddressForm,\n }\n\n if (employeeQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n if (employeeQuery.isError) {\n return {\n isLoading: false,\n data: dataPayloadPendingForms,\n status: {\n isDeletePending: deleteHomeAddressMutation.isPending,\n isEmployeeError: true,\n },\n errorHandling,\n actions,\n }\n }\n\n const isFormsLoading = editHomeAddressForm.isLoading || createHomeAddressForm.isLoading\n if (isFormsLoading) {\n return { isLoading: true, errorHandling }\n }\n\n const { editHomeAddressForm: editReady, createHomeAddressForm: createReady } =\n homeAddressFormsReady(editHomeAddressForm, createHomeAddressForm)\n\n const dataReady: UseHomeAddressManagementDataReady = {\n employeeDisplayName,\n employeeHomeAddresses,\n editingHomeAddressUuid,\n editHomeAddressForm: editReady,\n createHomeAddressForm: createReady,\n }\n\n return {\n isLoading: false,\n data: dataReady,\n status: {\n isDeletePending: deleteHomeAddressMutation.isPending,\n isEmployeeError: false,\n },\n errorHandling,\n actions,\n }\n}\n"],"names":["isUseHomeAddressManagementSuccess","value","homeAddressFormsReady","editHomeAddressForm","createHomeAddressForm","SDKInternalError","useHomeAddressManagement","employeeId","onEvent","baseSubmitHandler","rootSubmitError","setRootSubmitError","useBaseSubmit","deleteHomeAddressMutation","useEmployeeAddressesDeleteMutation","editTargetUuid","setEditAddressTarget","useState","homeAddressesQuery","useEmployeeAddressesGet","employeeHomeAddresses","currentHomeAddress","a","editingHomeAddressUuid","editingHomeAddressRow","useHomeAddressForm","employeeQuery","useEmployeesGet","employeeDisplayName","useMemo","employee","firstLastName","errorHandling","composeErrorHandler","actions","homeAddressUuid","snapshot","succeeded","uuid","snap","target","componentEvents","dataPayloadPendingForms","editReady","createReady"],"mappings":";;;;;;;;;;AAsGO,SAASA,GACdC,GAC+C;AAC/C,SAAIA,EAAM,YACD,KAEF,CAACA,EAAM,OAAO;AACvB;AAEA,SAASC,EACPC,GACAC,GAC0F;AAC1F,MAAID,EAAoB;AACtB,UAAM,IAAIE,EAAiB,yCAAyC;AAEtE,MAAID,EAAsB;AACxB,UAAM,IAAIC,EAAiB,2CAA2C;AAExE,SAAO;AAAA,IACL,qBAAAF;AAAA,IACA,uBAAAC;AAAA,EAAA;AAEJ;AAeO,SAASE,GAAyB;AAAA,EACvC,YAAAC;AAAA,EACA,SAAAC;AACF,GAAmE;AACjE,QAAM;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,iCAAiC,GAC7CC,IAA4BC,EAAA,GAE5B,CAACC,GAAgBC,CAAoB,IAAIC,EAA6B,MAAS,GAE/EC,IAAqBC,EAAwB,EAAE,YAAAZ,EAAA,GAAc,EAAE,SAAS,CAAC,CAACA,GAAY,GACtFa,IAAwBF,EAAmB,MAAM,qBACjDG,IACJD,GAAuB,KAAK,CAAAE,MAAKA,EAAE,MAAM,KAAKF,IAAwB,CAAC,GAEnEG,IAAyBR,KAAkBM,GAAo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AAS,EAAE,iBAAiByB,EAAA;AAAA,UAAK,CAClC,GACDD,IAAY,IACRE,KACF/B,EAAQiC,EAAgB,0CAA0CF,CAAI;AAAA,QAE1E;AAAA,MAAA,GAEKF;AAAA,IACT;AAAA,EAIE,GAGIK,IAAoE;AAAA,IACxE,qBAAAd;AAAA,IACA,uBAAAR;AAAA,IACA,wBAAAG;AAAA,IACA,qBAAApB;AAAA,IACA,uBAAAC;AAAA,EAAA;AAGF,MAAIsB,EAAc;AAChB,WAAO,EAAE,WAAW,IAAM,eAAAM,EAAA;AAG5B,MAAIN,EAAc;AAChB,WAAO;AAAA,MACL,WAAW;AAAA,MACX,MAAMgB;AAAA,MACN,QAAQ;AAAA,QACN,iBAAiB7B,EAA0B;AAAA,QAC3C,iBAAiB;AAAA,MAAA;AAAA,MAEnB,eAAAmB;AAAA,MACA,SAAAE;AAAA,IAAA;AAKJ,MADuB/B,EAAoB,aAAaC,EAAsB;AAE5E,WAAO,EAAE,WAAW,IAAM,eAAA4B,EAAA;AAG5B,QAAM,EAAE,qBAAqBW,GAAW,uBAAuBC,MAC7D1C,EAAsBC,GAAqBC,CAAqB;AAUlE,SAAO;AAAA,IACL,WAAW;AAAA,IACX,MAVmD;AAAA,MACnD,qBAAAwB;AAAA,MACA,uBAAAR;AAAA,MACA,wBAAAG;AAAA,MACA,qBAAqBoB;AAAA,MACrB,uBAAuBC;AAAA,IAAA;AAAA,IAMvB,QAAQ;AAAA,MACN,iBAAiB/B,EAA0B;AAAA,MAC3C,iBAAiB;AAAA,IAAA;AAAA,IAEnB,eAAAmB;AAAA,IACA,SAAAE;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useHomeAddressManagement.js","sources":["../../../../../src/components/Employee/HomeAddress/management/useHomeAddressManagement.tsx"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport type { EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { useEmployeeAddressesDeleteMutation } from '@gusto/embedded-api/react-query/employeeAddressesDelete'\nimport { useEmployeeAddressesGet } from '@gusto/embedded-api/react-query/employeeAddressesGet'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { useHomeAddressForm } from '@/components/Employee/Profile/shared/useHomeAddressForm'\nimport type {\n UseHomeAddressFormReady,\n UseHomeAddressFormResult,\n} from '@/components/Employee/Profile/shared/useHomeAddressForm'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseHookReady,\n HookErrorHandling,\n HookLoadingResult,\n} from '@/partner-hook-utils/types'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\n/**\n * Params for {@link useHomeAddressManagement}.\n *\n * @public\n */\nexport interface UseHomeAddressManagementParams {\n /** The associated employee identifier. */\n employeeId: string\n /** Event handler fired when a home address is deleted. */\n onEvent: OnEventType<EventType, unknown>\n}\n\ninterface UseHomeAddressManagementDataPendingForms extends Record<string, unknown> {\n employeeDisplayName: string\n employeeHomeAddresses: EmployeeAddress[] | undefined\n editingHomeAddressUuid: string | undefined\n editHomeAddressForm: UseHomeAddressFormResult\n createHomeAddressForm: UseHomeAddressFormResult\n}\n\ninterface UseHomeAddressManagementDataReady extends Record<string, unknown> {\n employeeDisplayName: string\n employeeHomeAddresses: EmployeeAddress[] | undefined\n editingHomeAddressUuid: string | undefined\n editHomeAddressForm: UseHomeAddressFormReady\n createHomeAddressForm: UseHomeAddressFormReady\n}\n\ninterface UseHomeAddressManagementStatusEmployeeError extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: true\n}\n\ninterface UseHomeAddressManagementStatusSuccess extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: false\n}\n\ninterface UseHomeAddressManagementActions {\n setEditAddressTarget: (homeAddressUuid: string | undefined) => void\n confirmDeleteHomeAddress: (homeAddressUuid: string) => Promise<boolean>\n}\n\ninterface UseHomeAddressManagementReadyEmployeeError extends BaseHookReady<\n UseHomeAddressManagementDataPendingForms,\n UseHomeAddressManagementStatusEmployeeError\n> {\n actions: UseHomeAddressManagementActions\n}\n\n/**\n * Ready state of {@link useHomeAddressManagement} when the employee was fetched successfully.\n *\n * @public\n */\nexport interface UseHomeAddressManagementReadySuccess extends BaseHookReady<\n UseHomeAddressManagementDataReady,\n UseHomeAddressManagementStatusSuccess\n> {\n /** Actions for changing edit target and confirming home address deletion. */\n actions: UseHomeAddressManagementActions\n}\n\ntype UseHomeAddressManagementReady =\n UseHomeAddressManagementReadyEmployeeError | UseHomeAddressManagementReadySuccess\n\n/**\n * Return type of {@link useHomeAddressManagement}.\n *\n * @public\n */\nexport type UseHomeAddressManagementResult = HookLoadingResult | UseHomeAddressManagementReady\n\n/**\n * Type guard for the success branch of {@link useHomeAddressManagement}.\n *\n * @param value - The hook result to narrow.\n * @returns `true` when the hook has finished loading and the employee fetch succeeded.\n * @public\n */\nexport function isUseHomeAddressManagementSuccess(\n value: UseHomeAddressManagementResult,\n): value is UseHomeAddressManagementReadySuccess {\n if (value.isLoading) {\n return false\n }\n return !value.status.isEmployeeError\n}\n\nfunction homeAddressFormsReady(\n editHomeAddressForm: UseHomeAddressFormResult,\n createHomeAddressForm: UseHomeAddressFormResult,\n): Pick<UseHomeAddressManagementDataReady, 'editHomeAddressForm' | 'createHomeAddressForm'> {\n if (editHomeAddressForm.isLoading) {\n throw new SDKInternalError('Edit home address form is still loading')\n }\n if (createHomeAddressForm.isLoading) {\n throw new SDKInternalError('Create home address form is still loading')\n }\n return {\n editHomeAddressForm,\n createHomeAddressForm,\n }\n}\n\n/**\n * Headless hook for managing an employee's home addresses.\n *\n * @remarks\n * Fetches the employee and their home addresses, exposes edit and create form hooks\n * for the address modal, and provides an action to delete a non-active address.\n * Use {@link isUseHomeAddressManagementSuccess} to narrow the ready state when the\n * employee fetch succeeded.\n *\n * @param params - {@link UseHomeAddressManagementParams}\n * @returns A {@link HookLoadingResult} while loading, or the ready state once data is available.\n * @public\n */\nexport function useHomeAddressManagement({\n employeeId,\n onEvent,\n}: UseHomeAddressManagementParams): UseHomeAddressManagementResult {\n const {\n baseSubmitHandler,\n error: rootSubmitError,\n setError: setRootSubmitError,\n } = useBaseSubmit('Employee.Management.HomeAddress')\n const deleteHomeAddressMutation = useEmployeeAddressesDeleteMutation()\n\n const [editTargetUuid, setEditAddressTarget] = useState<string | undefined>(undefined)\n\n const homeAddressesQuery = useEmployeeAddressesGet({ employeeId }, { enabled: !!employeeId })\n const employeeHomeAddresses = homeAddressesQuery.data?.employeeAddressList\n const currentHomeAddress =\n employeeHomeAddresses?.find(a => a.active) ?? employeeHomeAddresses?.[0]\n\n const editingHomeAddressUuid = editTargetUuid ?? currentHomeAddress?.uuid\n\n const editingHomeAddressRow = editingHomeAddressUuid\n ? employeeHomeAddresses?.find(a => a.uuid === editingHomeAddressUuid)\n : undefined\n\n const editHomeAddressForm = useHomeAddressForm({\n employeeId,\n homeAddressUuid: editingHomeAddressUuid,\n initialAddress: editingHomeAddressRow,\n withEffectiveDateField: true,\n })\n const createHomeAddressForm = useHomeAddressForm({\n employeeId,\n homeAddressUuid: undefined,\n withEffectiveDateField: true,\n })\n\n const employeeQuery = useEmployeesGet({ employeeId }, { enabled: !!employeeId })\n\n const employeeDisplayName = useMemo(() => {\n const employee = employeeQuery.data?.employeeShow\n if (!employee) {\n return ''\n }\n return firstLastName({\n first_name: employee.firstName,\n last_name: employee.lastName,\n }).trim()\n }, [employeeQuery.data?.employeeShow])\n\n // Form hooks are intentionally excluded here so their submit errors don't render in the\n // page-level BaseLayout outside the edit/create modal (SDK-930). The view renders those\n // errors inside the modal directly via the form hook's own errorHandling.\n const errorHandling: HookErrorHandling = composeErrorHandler(\n [employeeQuery, homeAddressesQuery],\n { submitError: rootSubmitError, setSubmitError: setRootSubmitError },\n )\n\n const confirmDeleteHomeAddress = async (homeAddressUuid: string): Promise<boolean> => {\n const snapshot = employeeHomeAddresses?.find(a => a.uuid === homeAddressUuid) ?? null\n\n let succeeded = false\n await baseSubmitHandler(\n { homeAddressUuid, snapshot },\n async ({ homeAddressUuid: uuid, snapshot: snap }) => {\n const target = employeeHomeAddresses?.find(a => a.uuid === uuid)\n if (!target) {\n throw new SDKInternalError('Home address not found')\n }\n if (target.active === true) {\n throw new SDKInternalError('Cannot delete the active home address')\n }\n\n await deleteHomeAddressMutation.mutateAsync({\n request: { homeAddressUuid: uuid },\n })\n succeeded = true\n if (snap) {\n onEvent(componentEvents.EMPLOYEE_MANAGEMENT_HOME_ADDRESS_DELETED, snap)\n }\n },\n )\n return succeeded\n }\n\n const actions: UseHomeAddressManagementActions = {\n setEditAddressTarget,\n confirmDeleteHomeAddress,\n }\n\n const dataPayloadPendingForms: UseHomeAddressManagementDataPendingForms = {\n employeeDisplayName,\n employeeHomeAddresses,\n editingHomeAddressUuid,\n editHomeAddressForm,\n createHomeAddressForm,\n }\n\n if (employeeQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n if (employeeQuery.isError) {\n return {\n isLoading: false,\n data: dataPayloadPendingForms,\n status: {\n isDeletePending: deleteHomeAddressMutation.isPending,\n isEmployeeError: true,\n },\n errorHandling,\n actions,\n }\n }\n\n const isFormsLoading = editHomeAddressForm.isLoading || createHomeAddressForm.isLoading\n if (isFormsLoading) {\n return { isLoading: true, errorHandling }\n }\n\n const { editHomeAddressForm: editReady, createHomeAddressForm: createReady } =\n homeAddressFormsReady(editHomeAddressForm, createHomeAddressForm)\n\n const dataReady: UseHomeAddressManagementDataReady = {\n employeeDisplayName,\n employeeHomeAddresses,\n editingHomeAddressUuid,\n editHomeAddressForm: editReady,\n createHomeAddressForm: createReady,\n }\n\n return {\n isLoading: false,\n data: dataReady,\n status: {\n isDeletePending: deleteHomeAddressMutation.isPending,\n isEmployeeError: false,\n },\n errorHandling,\n actions,\n }\n}\n"],"names":["isUseHomeAddressManagementSuccess","value","homeAddressFormsReady","editHomeAddressForm","createHomeAddressForm","SDKInternalError","useHomeAddressManagement","employeeId","onEvent","baseSubmitHandler","rootSubmitError","setRootSubmitError","useBaseSubmit","deleteHomeAddressMutation","useEmployeeAddressesDeleteMutation","editTargetUuid","setEditAddressTarget","useState","homeAddressesQuery","useEmployeeAddressesGet","employeeHomeAddresses","currentHomeAddress","a","editingHomeAddressUuid","editingHomeAddressRow","useHomeAddressForm","employeeQuery","useEmployeesGet","employeeDisplayName","useMemo","employee","firstLastName","errorHandling","composeErrorHandler","actions","homeAddressUuid","snapshot","succeeded","uuid","snap","target","componentEvents","dataPayloadPendingForms","editReady","createReady"],"mappings":";;;;;;;;;;AAsGO,SAASA,GACdC,GAC+C;AAC/C,SAAIA,EAAM,YACD,KAEF,CAACA,EAAM,OAAO;AACvB;AAEA,SAASC,EACPC,GACAC,GAC0F;AAC1F,MAAID,EAAoB;AACtB,UAAM,IAAIE,EAAiB,yCAAyC;AAEtE,MAAID,EAAsB;AACxB,UAAM,IAAIC,EAAiB,2CAA2C;AAExE,SAAO;AAAA,IACL,qBAAAF;AAAA,IACA,uBAAAC;AAAA,EAAA;AAEJ;AAeO,SAASE,GAAyB;AAAA,EACvC,YAAAC;AAAA,EACA,SAAAC;AACF,GAAmE;AACjE,QAAM;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,iCAAiC,GAC7CC,IAA4BC,EAAA,GAE5B,CAACC,GAAgBC,CAAoB,IAAIC,EAA6B,MAAS,GAE/EC,IAAqBC,EAAwB,EAAE,YAAAZ,EAAA,GAAc,EAAE,SAAS,CAAC,CAACA,GAAY,GACtFa,IAAwBF,EAAmB,MAAM,qBACjDG,IACJD,GAAuB,KAAK,CAAAE,MAAKA,EAAE,MAAM,KAAKF,IAAwB,CAAC,GAEnEG,IAAyBR,KAAkBM,GAAoB,MAE/DG,IAAwBD,IAC1BH,GAAuB,KAAK,OAAKE,EAAE,SAASC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E,KACF/B,EAAQiC,EAAgB,0CAA0CF,CAAI;AAAA,QAE1E;AAAA,MAAA,GAEKF;AAAA,IACT;AAAA,EAIE,GAGIK,IAAoE;AAAA,IACxE,qBAAAd;AAAA,IACA,uBAAAR;AAAA,IACA,wBAAAG;AAAA,IACA,qBAAApB;AAAA,IACA,uBAAAC;AAAA,EAAA;AAGF,MAAIsB,EAAc;AAChB,WAAO,EAAE,WAAW,IAAM,eAAAM,EAAA;AAG5B,MAAIN,EAAc;AAChB,WAAO;AAAA,MACL,WAAW;AAAA,MACX,MAAMgB;AAAA,MACN,QAAQ;AAAA,QACN,iBAAiB7B,EAA0B;AAAA,QAC3C,iBAAiB;AAAA,MAAA;AAAA,MAEnB,eAAAmB;AAAA,MACA,SAAAE;AAAA,IAAA;AAKJ,MADuB/B,EAAoB,aAAaC,EAAsB;AAE5E,WAAO,EAAE,WAAW,IAAM,eAAA4B,EAAA;AAG5B,QAAM,EAAE,qBAAqBW,GAAW,uBAAuBC,MAC7D1C,EAAsBC,GAAqBC,CAAqB;AAUlE,SAAO;AAAA,IACL,WAAW;AAAA,IACX,MAVmD;AAAA,MACnD,qBAAAwB;AAAA,MACA,uBAAAR;AAAA,MACA,wBAAAG;AAAA,MACA,qBAAqBoB;AAAA,MACrB,uBAAuBC;AAAA,IAAA;AAAA,IAMvB,QAAQ;AAAA,MACN,iBAAiB/B,EAA0B;AAAA,MAC3C,iBAAiB;AAAA,IAAA;AAAA,IAEnB,eAAAmB;AAAA,IACA,SAAAE;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,53 +1,57 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import { useEmployeesGetSuspense as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { useMemo as
|
|
7
|
-
import { BaseComponent as
|
|
8
|
-
import { useBase as
|
|
9
|
-
import { Flex as
|
|
10
|
-
import { ActionsLayout as
|
|
11
|
-
import { useComponentContext as
|
|
12
|
-
import { useI18n as
|
|
13
|
-
import { componentEvents as
|
|
14
|
-
import
|
|
15
|
-
function
|
|
16
|
-
return /* @__PURE__ */ e(
|
|
1
|
+
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as u } from "react-i18next";
|
|
3
|
+
import { useEmployeesGetSuspense as h } from "@gusto/embedded-api/react-query/employeesGet";
|
|
4
|
+
import { GetV1EmployeesQueryParamInclude as g } from "@gusto/embedded-api/models/operations/getv1employees";
|
|
5
|
+
import a from "dompurify";
|
|
6
|
+
import { useMemo as s } from "react";
|
|
7
|
+
import { BaseComponent as y } from "../../Base/Base.js";
|
|
8
|
+
import { useBase as x } from "../../Base/useBase.js";
|
|
9
|
+
import { Flex as m } from "../../Common/Flex/Flex.js";
|
|
10
|
+
import { ActionsLayout as E } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
11
|
+
import { useComponentContext as C } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
12
|
+
import { useI18n as N, useComponentDictionary as I } from "../../../i18n/I18n.js";
|
|
13
|
+
import { componentEvents as L } from "../../../shared/constants.js";
|
|
14
|
+
import S from "../../../assets/icons/icon-arrow-right.svg.js";
|
|
15
|
+
function k(t) {
|
|
16
|
+
return /* @__PURE__ */ e(y, { ...t, children: /* @__PURE__ */ e(D, { ...t, children: t.children }) });
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const { onEvent:
|
|
21
|
-
data: {
|
|
22
|
-
} =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const D = ({ employeeId: t, className: c, dictionary: p }) => {
|
|
19
|
+
N("Employee.Landing"), I("Employee.Landing", p);
|
|
20
|
+
const { onEvent: l } = x(), o = C(), {
|
|
21
|
+
data: { employeeShow: i }
|
|
22
|
+
} = h({
|
|
23
|
+
employeeId: t,
|
|
24
|
+
include: [g.CompanyName]
|
|
25
|
+
}), d = s(() => a.sanitize(i.firstName), [i]), f = s(
|
|
26
|
+
() => a.sanitize(i?.companyName ?? ""),
|
|
27
|
+
[i]
|
|
28
|
+
), { t: n } = u("Employee.Landing");
|
|
29
|
+
return /* @__PURE__ */ e("section", { className: c, children: /* @__PURE__ */ e(
|
|
26
30
|
o.Box,
|
|
27
31
|
{
|
|
28
|
-
footer: /* @__PURE__ */ e(
|
|
32
|
+
footer: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ r(
|
|
29
33
|
o.Button,
|
|
30
34
|
{
|
|
31
35
|
variant: "secondary",
|
|
32
36
|
onClick: () => {
|
|
33
|
-
|
|
37
|
+
l(L.EMPLOYEE_SELF_ONBOARDING_START);
|
|
34
38
|
},
|
|
35
39
|
children: [
|
|
36
40
|
n("getStartedCta"),
|
|
37
|
-
/* @__PURE__ */ e(
|
|
41
|
+
/* @__PURE__ */ e(S, { "aria-hidden": !0 })
|
|
38
42
|
]
|
|
39
43
|
}
|
|
40
44
|
) }),
|
|
41
|
-
children: /* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
45
|
+
children: /* @__PURE__ */ r(m, { alignItems: "center", flexDirection: "column", gap: 32, children: [
|
|
46
|
+
/* @__PURE__ */ r(m, { flexDirection: "column", gap: 4, children: [
|
|
43
47
|
/* @__PURE__ */ e(o.Heading, { as: "h2", children: n("landingSubtitle", {
|
|
44
|
-
firstName:
|
|
45
|
-
companyName:
|
|
48
|
+
firstName: d,
|
|
49
|
+
companyName: f,
|
|
46
50
|
interpolation: { escapeValue: !1 }
|
|
47
51
|
}) }),
|
|
48
52
|
/* @__PURE__ */ e(o.Text, { variant: "supporting", children: n("landingDescription") })
|
|
49
53
|
] }),
|
|
50
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ r(m, { flexDirection: "column", gap: 8, children: [
|
|
51
55
|
/* @__PURE__ */ e(o.Heading, { as: "h3", children: n("stepsSubtitle") }),
|
|
52
56
|
/* @__PURE__ */ e(
|
|
53
57
|
o.UnorderedList,
|
|
@@ -61,6 +65,6 @@ const B = ({ employeeId: t, companyId: p, className: l, dictionary: d }) => {
|
|
|
61
65
|
) });
|
|
62
66
|
};
|
|
63
67
|
export {
|
|
64
|
-
|
|
68
|
+
k as Landing
|
|
65
69
|
};
|
|
66
70
|
//# sourceMappingURL=Landing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Landing.js","sources":["../../../../src/components/Employee/Landing/Landing.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport {
|
|
1
|
+
{"version":3,"file":"Landing.js","sources":["../../../../src/components/Employee/Landing/Landing.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { GetV1EmployeesQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employees'\nimport DOMPurify from 'dompurify'\nimport { useMemo } from 'react'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { Flex, ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport ArrowRightIcon from '@/assets/icons/icon-arrow-right.svg?react'\n\n/**\n * Props for the {@link Landing} component.\n *\n * @public\n */\nexport interface LandingProps extends BaseComponentInterface<'Employee.Landing'> {\n /** UUID of the employee entering the self-onboarding flow. */\n employeeId: string\n /**\n * @deprecated\n * UUID of the company the employee belongs to.\n */\n companyId?: string\n}\n\n/**\n * Landing page for the employee self-onboarding flow. Displays a welcome\n * message and the list of onboarding steps the employee needs to complete.\n *\n * @public\n */\nexport function Landing(props: LandingProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, className, dictionary }: LandingProps) => {\n useI18n('Employee.Landing')\n useComponentDictionary('Employee.Landing', dictionary)\n const { onEvent } = useBase()\n const Components = useComponentContext()\n\n const {\n data: { employeeShow: employee },\n } = useEmployeesGetSuspense({\n employeeId,\n include: [GetV1EmployeesQueryParamInclude.CompanyName],\n })\n const sanitizedFirstName = useMemo(() => DOMPurify.sanitize(employee!.firstName), [employee])\n const sanitizedCompanyName = useMemo(\n () => DOMPurify.sanitize(employee?.companyName ?? ''),\n [employee],\n )\n\n const { t } = useTranslation('Employee.Landing')\n\n return (\n <section className={className}>\n <Components.Box\n footer={\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEE_SELF_ONBOARDING_START)\n }}\n >\n {t('getStartedCta')}\n <ArrowRightIcon aria-hidden />\n </Components.Button>\n </ActionsLayout>\n }\n >\n <Flex alignItems=\"center\" flexDirection=\"column\" gap={32}>\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">\n {t('landingSubtitle', {\n firstName: sanitizedFirstName,\n companyName: sanitizedCompanyName,\n interpolation: { escapeValue: false },\n })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">{t('landingDescription')}</Components.Text>\n </Flex>\n <Flex flexDirection=\"column\" gap={8}>\n <Components.Heading as=\"h3\">{t('stepsSubtitle')}</Components.Heading>\n <Components.UnorderedList\n items={[t('steps.personalInfo'), t('steps.taxInfo'), t('steps.bankInfo')]}\n />\n </Flex>\n </Flex>\n </Components.Box>\n </section>\n )\n}\n"],"names":["Landing","props","jsx","BaseComponent","Root","employeeId","className","dictionary","useI18n","useComponentDictionary","onEvent","useBase","Components","useComponentContext","employee","useEmployeesGetSuspense","GetV1EmployeesQueryParamInclude","sanitizedFirstName","useMemo","DOMPurify","sanitizedCompanyName","t","useTranslation","ActionsLayout","jsxs","componentEvents","ArrowRightIcon","Flex"],"mappings":";;;;;;;;;;;;;;AAkCO,SAASA,EAAQC,GAAqB;AAC3C,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAG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U,EAAW,SAAX,EAAmB,IAAG,MACpB,YAAE,mBAAmB;AAAA,YACpB,WAAWK;AAAA,YACX,aAAaG;AAAA,YACb,eAAe,EAAE,aAAa,GAAA;AAAA,UAAM,CACrC,GACH;AAAA,UACA,gBAAAlB,EAACU,EAAW,MAAX,EAAgB,SAAQ,cAAc,UAAAS,EAAE,oBAAoB,EAAA,CAAE;AAAA,QAAA,GACjE;AAAA,QACA,gBAAAG,EAACG,GAAA,EAAK,eAAc,UAAS,KAAK,GAChC,UAAA;AAAA,UAAA,gBAAAzB,EAACU,EAAW,SAAX,EAAmB,IAAG,MAAM,UAAAS,EAAE,eAAe,GAAE;AAAA,UAChD,gBAAAnB;AAAA,YAACU,EAAW;AAAA,YAAX;AAAA,cACC,OAAO,CAACS,EAAE,oBAAoB,GAAGA,EAAE,eAAe,GAAGA,EAAE,gBAAgB,CAAC;AAAA,YAAA;AAAA,UAAA;AAAA,QAC1E,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -9,8 +9,8 @@ import { useBase as B } from "../../Base/useBase.js";
|
|
|
9
9
|
import { Flex as r } from "../../Common/Flex/Flex.js";
|
|
10
10
|
import { ActionsLayout as u } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
11
11
|
import { RequirementsList as P } from "../../Common/RequirementsList/RequirementsList.js";
|
|
12
|
-
import { useComponentContext as
|
|
13
|
-
import { useI18n as
|
|
12
|
+
import { useComponentContext as w } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
+
import { useI18n as R, useComponentDictionary as G } from "../../../i18n/I18n.js";
|
|
14
14
|
import { EmployeeOnboardingStatus as f, EmployeeSelfOnboardingStatuses as F, componentEvents as g } from "../../../shared/constants.js";
|
|
15
15
|
import { useFlow as M } from "../../Flow/useFlow.js";
|
|
16
16
|
const q = [
|
|
@@ -29,32 +29,32 @@ function j(t) {
|
|
|
29
29
|
return /* @__PURE__ */ e(T, { ...t, children: /* @__PURE__ */ e(k, { ...t, children: t.children }) });
|
|
30
30
|
}
|
|
31
31
|
const k = ({ employeeId: t, className: l, isAdmin: m = !1, dictionary: c }) => {
|
|
32
|
-
|
|
33
|
-
const { onEvent: p } = B(), { t: n } = I("Employee.OnboardingSummary"),
|
|
34
|
-
data: {
|
|
35
|
-
} = A({ employeeId: t }), { firstName: h, lastName:
|
|
32
|
+
R("Employee.OnboardingSummary"), G("Employee.OnboardingSummary", c);
|
|
33
|
+
const { onEvent: p } = B(), { t: n } = I("Employee.OnboardingSummary"), o = w(), {
|
|
34
|
+
data: { employeeShow: b }
|
|
35
|
+
} = A({ employeeId: t }), { firstName: h, lastName: S } = b, { data: N } = L({ employeeId: t }), { onboardingStatus: s, onboardingSteps: d } = N.employeeOnboardingStatus, C = d?.length && d.findIndex((i) => i.required && !i.completed) > -1, E = s === f.ONBOARDING_COMPLETED || !C && s === f.SELF_ONBOARDING_PENDING_INVITE, _ = s === f.SELF_ONBOARDING_PENDING_INVITE || s !== void 0 && F.has(s), O = D(() => x.sanitize(h), [h]), y = D(() => x.sanitize(S), [S]);
|
|
36
36
|
return /* @__PURE__ */ e("section", { className: l, children: /* @__PURE__ */ a(r, { flexDirection: "column", gap: 20, children: [
|
|
37
|
-
/* @__PURE__ */ e(r, { alignItems: "center", flexDirection: "column", gap: 8, children: m ?
|
|
38
|
-
/* @__PURE__ */ e(
|
|
37
|
+
/* @__PURE__ */ e(r, { alignItems: "center", flexDirection: "column", gap: 8, children: m ? E ? /* @__PURE__ */ a(r, { flexDirection: "column", gap: 4, alignItems: "center", children: [
|
|
38
|
+
/* @__PURE__ */ e(o.Heading, { as: "h2", textAlign: "center", children: n("onboardedAdminSubtitle", {
|
|
39
39
|
name: `${O} ${y}`,
|
|
40
40
|
interpolation: { escapeValue: !1 }
|
|
41
41
|
}) }),
|
|
42
|
-
/* @__PURE__ */ e(
|
|
42
|
+
/* @__PURE__ */ e(o.Text, { variant: "supporting", children: n("onboardedAdminDescription") })
|
|
43
43
|
] }) : _ ? /* @__PURE__ */ a(r, { flexDirection: "column", gap: 4, alignItems: "center", children: [
|
|
44
|
-
/* @__PURE__ */ e(
|
|
44
|
+
/* @__PURE__ */ e(o.Heading, { as: "h2", textAlign: "center", children: n("handedOffAdminSubtitle", {
|
|
45
45
|
name: `${O} ${y}`,
|
|
46
46
|
interpolation: { escapeValue: !1 }
|
|
47
47
|
}) }),
|
|
48
|
-
/* @__PURE__ */ e(
|
|
48
|
+
/* @__PURE__ */ e(o.Text, { variant: "supporting", children: n("handedOffAdminDescription") })
|
|
49
49
|
] }) : /* @__PURE__ */ e(
|
|
50
|
-
|
|
50
|
+
o.Box,
|
|
51
51
|
{
|
|
52
52
|
header: /* @__PURE__ */ a(r, { flexDirection: "column", gap: 4, children: [
|
|
53
|
-
/* @__PURE__ */ e(
|
|
54
|
-
/* @__PURE__ */ e(
|
|
53
|
+
/* @__PURE__ */ e(o.Heading, { as: "h2", children: n("missingRequirementsSubtitle") }),
|
|
54
|
+
/* @__PURE__ */ e(o.Text, { variant: "supporting", children: n("missingRequirementsDescription") })
|
|
55
55
|
] }),
|
|
56
56
|
footer: /* @__PURE__ */ e(u, { children: /* @__PURE__ */ e(
|
|
57
|
-
|
|
57
|
+
o.Button,
|
|
58
58
|
{
|
|
59
59
|
variant: "secondary",
|
|
60
60
|
onClick: () => {
|
|
@@ -67,22 +67,22 @@ const k = ({ employeeId: t, className: l, isAdmin: m = !1, dictionary: c }) => {
|
|
|
67
67
|
P,
|
|
68
68
|
{
|
|
69
69
|
requirements: d.filter(
|
|
70
|
-
(
|
|
71
|
-
).map((
|
|
72
|
-
completed:
|
|
73
|
-
title: n(`steps.${
|
|
74
|
-
description: n(`stepsDescriptions.${
|
|
70
|
+
(i) => i.completed !== void 0 && $(i.id)
|
|
71
|
+
).map((i) => ({
|
|
72
|
+
completed: i.completed,
|
|
73
|
+
title: n(`steps.${i.id}`),
|
|
74
|
+
description: n(`stepsDescriptions.${i.id}`)
|
|
75
75
|
}))
|
|
76
76
|
}
|
|
77
77
|
)
|
|
78
78
|
}
|
|
79
79
|
) : /* @__PURE__ */ e(v, { children: /* @__PURE__ */ a(r, { flexDirection: "column", gap: 20, alignItems: "center", children: [
|
|
80
80
|
/* @__PURE__ */ a(r, { flexDirection: "column", gap: 4, alignItems: "center", children: [
|
|
81
|
-
/* @__PURE__ */ e(
|
|
82
|
-
/* @__PURE__ */ e(
|
|
81
|
+
/* @__PURE__ */ e(o.Heading, { as: "h2", textAlign: "center", children: n("onboardedSelfSubtitle") }),
|
|
82
|
+
/* @__PURE__ */ e(o.Text, { variant: "supporting", children: n("onboardedSelfDescription") })
|
|
83
83
|
] }),
|
|
84
84
|
/* @__PURE__ */ e(u, { justifyContent: "center", children: /* @__PURE__ */ e(
|
|
85
|
-
|
|
85
|
+
o.Button,
|
|
86
86
|
{
|
|
87
87
|
variant: "secondary",
|
|
88
88
|
onClick: () => {
|
|
@@ -92,8 +92,8 @@ const k = ({ employeeId: t, className: l, isAdmin: m = !1, dictionary: c }) => {
|
|
|
92
92
|
}
|
|
93
93
|
) })
|
|
94
94
|
] }) }) }),
|
|
95
|
-
m && (
|
|
96
|
-
|
|
95
|
+
m && (E || _) && /* @__PURE__ */ e(u, { justifyContent: "center", children: /* @__PURE__ */ e(
|
|
96
|
+
o.Button,
|
|
97
97
|
{
|
|
98
98
|
variant: "secondary",
|
|
99
99
|
onClick: () => {
|
|
@@ -103,7 +103,7 @@ const k = ({ employeeId: t, className: l, isAdmin: m = !1, dictionary: c }) => {
|
|
|
103
103
|
}
|
|
104
104
|
) })
|
|
105
105
|
] }) });
|
|
106
|
-
},
|
|
106
|
+
}, ie = () => {
|
|
107
107
|
const { employeeId: t, onEvent: l, isAdmin: m } = M(), { t: c } = I("common");
|
|
108
108
|
if (!t)
|
|
109
109
|
throw new Error(
|
|
@@ -117,6 +117,6 @@ const k = ({ employeeId: t, className: l, isAdmin: m = !1, dictionary: c }) => {
|
|
|
117
117
|
};
|
|
118
118
|
export {
|
|
119
119
|
j as OnboardingSummary,
|
|
120
|
-
|
|
120
|
+
ie as OnboardingSummaryContextual
|
|
121
121
|
};
|
|
122
122
|
//# sourceMappingURL=OnboardingSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingSummary.js","sources":["../../../../src/components/Employee/OnboardingSummary/OnboardingSummary.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeesGetOnboardingStatusSuspense } from '@gusto/embedded-api/react-query/employeesGetOnboardingStatus'\nimport DOMPurify from 'dompurify'\nimport { useMemo } from 'react'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlowComponents'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { Flex, ActionsLayout } from '@/components/Common'\nimport { RequirementsList } from '@/components/Common/RequirementsList/RequirementsList'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n EmployeeOnboardingStatus,\n EmployeeSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nconst KNOWN_STEP_IDS = [\n 'personal_details',\n 'compensation_details',\n 'add_work_address',\n 'add_home_address',\n 'federal_tax_setup',\n 'state_tax_setup',\n 'direct_deposit_setup',\n 'employee_form_signing',\n 'file_new_hire_report',\n 'admin_review',\n] as const\n\ntype KnownStepId = (typeof KNOWN_STEP_IDS)[number]\n\nconst isKnownStepId = (id: string | undefined): id is KnownStepId =>\n id !== undefined && (KNOWN_STEP_IDS as readonly string[]).includes(id)\n\n/**\n * Props for {@link OnboardingSummary}.\n *\n * @public\n */\nexport interface OnboardingSummaryProps extends BaseComponentInterface<'Employee.OnboardingSummary'> {\n /** The associated employee identifier. */\n employeeId: string\n /** When `true`, renders the admin-facing view of the onboarding summary. Defaults to `false`. */\n isAdmin?: boolean\n}\n\n/**\n * Displays a summary of an employee's onboarding status, listing completed and\n * outstanding steps. Rendered as a standalone step inside `OnboardingFlow`.\n *\n * @public\n */\nexport function OnboardingSummary(props: OnboardingSummaryProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, className, isAdmin = false, dictionary }: OnboardingSummaryProps) => {\n useI18n('Employee.OnboardingSummary')\n useComponentDictionary('Employee.OnboardingSummary', dictionary)\n const { onEvent } = useBase()\n const { t } = useTranslation('Employee.OnboardingSummary')\n const Components = useComponentContext()\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n const { firstName, lastName } = employee!\n\n const { data } = useEmployeesGetOnboardingStatusSuspense({ employeeId })\n const { onboardingStatus, onboardingSteps } = data.employeeOnboardingStatus!\n\n const hasMissingRequirements =\n onboardingSteps?.length &&\n onboardingSteps.findIndex(step => step.required && !step.completed) > -1\n\n const isOnboardingCompleted =\n onboardingStatus === EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n (!hasMissingRequirements &&\n onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE)\n\n const isEmployeeCompletingSelfOnboarding =\n onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE ||\n (onboardingStatus !== undefined && EmployeeSelfOnboardingStatuses.has(onboardingStatus))\n\n const sanitizedFirstName = useMemo(() => DOMPurify.sanitize(firstName), [firstName])\n const sanitizedLastName = useMemo(() => DOMPurify.sanitize(lastName), [lastName])\n\n return (\n <section className={className}>\n <Flex flexDirection=\"column\" gap={20}>\n <Flex alignItems=\"center\" flexDirection=\"column\" gap={8}>\n {isAdmin ? (\n isOnboardingCompleted ? (\n <Flex flexDirection=\"column\" gap={4} alignItems=\"center\">\n <Components.Heading as=\"h2\" textAlign=\"center\">\n {t('onboardedAdminSubtitle', {\n name: `${sanitizedFirstName} ${sanitizedLastName}`,\n interpolation: { escapeValue: false },\n })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('onboardedAdminDescription')}\n </Components.Text>\n </Flex>\n ) : isEmployeeCompletingSelfOnboarding ? (\n <Flex flexDirection=\"column\" gap={4} alignItems=\"center\">\n <Components.Heading as=\"h2\" textAlign=\"center\">\n {t('handedOffAdminSubtitle', {\n name: `${sanitizedFirstName} ${sanitizedLastName}`,\n interpolation: { escapeValue: false },\n })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('handedOffAdminDescription')}\n </Components.Text>\n </Flex>\n ) : (\n <Components.Box\n header={\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">\n {t('missingRequirementsSubtitle')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('missingRequirementsDescription')}\n </Components.Text>\n </Flex>\n }\n footer={\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEES_LIST)\n }}\n >\n {t('doneCta')}\n </Components.Button>\n </ActionsLayout>\n }\n >\n {onboardingSteps && (\n <RequirementsList\n requirements={onboardingSteps\n .filter(\n (step): step is typeof step & { id: KnownStepId; completed: boolean } =>\n step.completed !== undefined && isKnownStepId(step.id),\n )\n .map(step => ({\n completed: step.completed,\n title: t(`steps.${step.id}`),\n description: t(`stepsDescriptions.${step.id}`),\n }))}\n />\n )}\n </Components.Box>\n )\n ) : (\n <>\n <Flex flexDirection=\"column\" gap={20} alignItems=\"center\">\n <Flex flexDirection=\"column\" gap={4} alignItems=\"center\">\n <Components.Heading as=\"h2\" textAlign=\"center\">\n {t('onboardedSelfSubtitle')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('onboardedSelfDescription')}\n </Components.Text>\n </Flex>\n <ActionsLayout justifyContent=\"center\">\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_DONE)\n }}\n >\n {t('doneCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </>\n )}\n </Flex>\n\n {isAdmin && (isOnboardingCompleted || isEmployeeCompletingSelfOnboarding) && (\n <ActionsLayout justifyContent={'center'}>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEES_LIST)\n }}\n >\n {t('doneCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n </Flex>\n </section>\n )\n}\n\n/** @internal */\nexport const OnboardingSummaryContextual = () => {\n const { employeeId, onEvent, isAdmin } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Summary',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <OnboardingSummary employeeId={employeeId} onEvent={onEvent} isAdmin={isAdmin} />\n}\n"],"names":["KNOWN_STEP_IDS","isKnownStepId","id","OnboardingSummary","props","jsx","BaseComponent","Root","employeeId","className","isAdmin","dictionary","useI18n","useComponentDictionary","onEvent","useBase","t","useTranslation","Components","useComponentContext","employee","useEmployeesGetSuspense","firstName","lastName","data","useEmployeesGetOnboardingStatusSuspense","onboardingStatus","onboardingSteps","hasMissingRequirements","step","isOnboardingCompleted","EmployeeOnboardingStatus","isEmployeeCompletingSelfOnboarding","EmployeeSelfOnboardingStatuses","sanitizedFirstName","useMemo","DOMPurify","sanitizedLastName","jsxs","Flex","ActionsLayout","componentEvents","RequirementsList","OnboardingSummaryContextual","useFlow"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAMA,IAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAIMC,IAAgB,CAACC,MACrBA,MAAO,UAAcF,EAAqC,SAASE,CAAE;AAoBhE,SAASC,EAAkBC,GAA+B;AAC/D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,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,UAAAJ,EAAQ2B,EAAgB,cAAc;AAAA,QACxC;AAAA,QAEC,YAAE,SAAS;AAAA,MAAA;AAAA,IAAA,EACd,CACF;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF;AAEJ,GAGaE,KAA8B,MAAM;AAC/C,QAAM,EAAE,YAAAnC,GAAY,SAAAM,GAAS,SAAAJ,EAAA,IAAYkC,EAAA,GACnC,EAAE,GAAA5B,EAAA,IAAMC,EAAe,QAAQ;AAErC,MAAI,CAACT;AACH,UAAM,IAAI;AAAA,MACRQ,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAO;AAAA,QACP,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAGL,SAAO,gBAAAX,EAACF,GAAA,EAAkB,YAAAK,GAAwB,SAAAM,GAAkB,SAAAJ,EAAA,CAAkB;AACxF;"}
|
|
1
|
+
{"version":3,"file":"OnboardingSummary.js","sources":["../../../../src/components/Employee/OnboardingSummary/OnboardingSummary.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeesGetOnboardingStatusSuspense } from '@gusto/embedded-api/react-query/employeesGetOnboardingStatus'\nimport DOMPurify from 'dompurify'\nimport { useMemo } from 'react'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlowComponents'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { Flex, ActionsLayout } from '@/components/Common'\nimport { RequirementsList } from '@/components/Common/RequirementsList/RequirementsList'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n EmployeeOnboardingStatus,\n EmployeeSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nconst KNOWN_STEP_IDS = [\n 'personal_details',\n 'compensation_details',\n 'add_work_address',\n 'add_home_address',\n 'federal_tax_setup',\n 'state_tax_setup',\n 'direct_deposit_setup',\n 'employee_form_signing',\n 'file_new_hire_report',\n 'admin_review',\n] as const\n\ntype KnownStepId = (typeof KNOWN_STEP_IDS)[number]\n\nconst isKnownStepId = (id: string | undefined): id is KnownStepId =>\n id !== undefined && (KNOWN_STEP_IDS as readonly string[]).includes(id)\n\n/**\n * Props for {@link OnboardingSummary}.\n *\n * @public\n */\nexport interface OnboardingSummaryProps extends BaseComponentInterface<'Employee.OnboardingSummary'> {\n /** The associated employee identifier. */\n employeeId: string\n /** When `true`, renders the admin-facing view of the onboarding summary. Defaults to `false`. */\n isAdmin?: boolean\n}\n\n/**\n * Displays a summary of an employee's onboarding status, listing completed and\n * outstanding steps. Rendered as a standalone step inside `OnboardingFlow`.\n *\n * @public\n */\nexport function OnboardingSummary(props: OnboardingSummaryProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, className, isAdmin = false, dictionary }: OnboardingSummaryProps) => {\n useI18n('Employee.OnboardingSummary')\n useComponentDictionary('Employee.OnboardingSummary', dictionary)\n const { onEvent } = useBase()\n const { t } = useTranslation('Employee.OnboardingSummary')\n const Components = useComponentContext()\n\n const {\n data: { employeeShow: employee },\n } = useEmployeesGetSuspense({ employeeId })\n const { firstName, lastName } = employee!\n\n const { data } = useEmployeesGetOnboardingStatusSuspense({ employeeId })\n const { onboardingStatus, onboardingSteps } = data.employeeOnboardingStatus!\n\n const hasMissingRequirements =\n onboardingSteps?.length &&\n onboardingSteps.findIndex(step => step.required && !step.completed) > -1\n\n const isOnboardingCompleted =\n onboardingStatus === EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n (!hasMissingRequirements &&\n onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE)\n\n const isEmployeeCompletingSelfOnboarding =\n onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE ||\n (onboardingStatus !== undefined && EmployeeSelfOnboardingStatuses.has(onboardingStatus))\n\n const sanitizedFirstName = useMemo(() => DOMPurify.sanitize(firstName), [firstName])\n const sanitizedLastName = useMemo(() => DOMPurify.sanitize(lastName), [lastName])\n\n return (\n <section className={className}>\n <Flex flexDirection=\"column\" gap={20}>\n <Flex alignItems=\"center\" flexDirection=\"column\" gap={8}>\n {isAdmin ? (\n isOnboardingCompleted ? (\n <Flex flexDirection=\"column\" gap={4} alignItems=\"center\">\n <Components.Heading as=\"h2\" textAlign=\"center\">\n {t('onboardedAdminSubtitle', {\n name: `${sanitizedFirstName} ${sanitizedLastName}`,\n interpolation: { escapeValue: false },\n })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('onboardedAdminDescription')}\n </Components.Text>\n </Flex>\n ) : isEmployeeCompletingSelfOnboarding ? (\n <Flex flexDirection=\"column\" gap={4} alignItems=\"center\">\n <Components.Heading as=\"h2\" textAlign=\"center\">\n {t('handedOffAdminSubtitle', {\n name: `${sanitizedFirstName} ${sanitizedLastName}`,\n interpolation: { escapeValue: false },\n })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('handedOffAdminDescription')}\n </Components.Text>\n </Flex>\n ) : (\n <Components.Box\n header={\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">\n {t('missingRequirementsSubtitle')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('missingRequirementsDescription')}\n </Components.Text>\n </Flex>\n }\n footer={\n <ActionsLayout>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEES_LIST)\n }}\n >\n {t('doneCta')}\n </Components.Button>\n </ActionsLayout>\n }\n >\n {onboardingSteps && (\n <RequirementsList\n requirements={onboardingSteps\n .filter(\n (step): step is typeof step & { id: KnownStepId; completed: boolean } =>\n step.completed !== undefined && isKnownStepId(step.id),\n )\n .map(step => ({\n completed: step.completed,\n title: t(`steps.${step.id}`),\n description: t(`stepsDescriptions.${step.id}`),\n }))}\n />\n )}\n </Components.Box>\n )\n ) : (\n <>\n <Flex flexDirection=\"column\" gap={20} alignItems=\"center\">\n <Flex flexDirection=\"column\" gap={4} alignItems=\"center\">\n <Components.Heading as=\"h2\" textAlign=\"center\">\n {t('onboardedSelfSubtitle')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('onboardedSelfDescription')}\n </Components.Text>\n </Flex>\n <ActionsLayout justifyContent=\"center\">\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_DONE)\n }}\n >\n {t('doneCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </>\n )}\n </Flex>\n\n {isAdmin && (isOnboardingCompleted || isEmployeeCompletingSelfOnboarding) && (\n <ActionsLayout justifyContent={'center'}>\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.EMPLOYEES_LIST)\n }}\n >\n {t('doneCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n </Flex>\n </section>\n )\n}\n\n/** @internal */\nexport const OnboardingSummaryContextual = () => {\n const { employeeId, onEvent, isAdmin } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Summary',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <OnboardingSummary employeeId={employeeId} onEvent={onEvent} isAdmin={isAdmin} />\n}\n"],"names":["KNOWN_STEP_IDS","isKnownStepId","id","OnboardingSummary","props","jsx","BaseComponent","Root","employeeId","className","isAdmin","dictionary","useI18n","useComponentDictionary","onEvent","useBase","t","useTranslation","Components","useComponentContext","employee","useEmployeesGetSuspense","firstName","lastName","data","useEmployeesGetOnboardingStatusSuspense","onboardingStatus","onboardingSteps","hasMissingRequirements","step","isOnboardingCompleted","EmployeeOnboardingStatus","isEmployeeCompletingSelfOnboarding","EmployeeSelfOnboardingStatuses","sanitizedFirstName","useMemo","DOMPurify","sanitizedLastName","jsxs","Flex","ActionsLayout","componentEvents","RequirementsList","OnboardingSummaryContextual","useFlow"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAMA,IAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAIMC,IAAgB,CAACC,MACrBA,MAAO,UAAcF,EAAqC,SAASE,CAAE;AAoBhE,SAASC,EAAkBC,GAA+B;AAC/D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,YAAAC,GAAY,WAAAC,GAAW,SAAAC,IAAU,IAAO,YAAAC,QAAyC;AAC/F,EAAAC,EAAQ,4BAA4B,GACpCC,EAAuB,8BAA8BF,CAAU;AAC/D,QAAM,EAAE,SAAAG,EAAA,IAAYC,EAAA,GACd,EAAE,GAAAC,EAAA,IAAMC,EAAe,4BAA4B,GACnDC,IAAaC,EAAA,GAEb;AAAA,IACJ,MAAM,EAAE,cAAcC,EAAA;AAAA,EAAS,IAC7BC,EAAwB,EAAE,YAAAb,GAAY,GACpC,EAAE,WAAAc,GAAW,UAAAC,EAAA,IAAaH,GAE1B,EAAE,MAAAI,EAAA,IAASC,EAAwC,EAAE,YAAAjB,GAAY,GACjE,EAAE,kBAAAkB,GAAkB,iBAAAC,EAAA,IAAoBH,EAAK,0BAE7CI,IACJD,GAAiB,UACjBA,EAAgB,UAAU,CAAAE,MAAQA,EAAK,YAAY,CAACA,EAAK,SAAS,IAAI,IAElEC,IACJJ,MAAqBK,EAAyB,wBAC7C,CAACH,KACAF,MAAqBK,EAAyB,gCAE5CC,IACJN,MAAqBK,EAAyB,kCAC7CL,MAAqB,UAAaO,EAA+B,IAAIP,CAAgB,G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;AAAA,QAACa,EAAW;AAAA,QAAX;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,MAAM;AACb,YAAAJ,EAAQ2B,EAAgB,wBAAwB;AAAA,UAClD;AAAA,UAEC,YAAE,SAAS;AAAA,QAAA;AAAA,MAAA,EACd,CACF;AAAA,IAAA,EAAA,CACF,GACF,GAEJ;AAAA,IAEC/B,MAAYoB,KAAyBE,MACpC,gBAAA3B,EAACmC,GAAA,EAAc,gBAAgB,UAC7B,UAAA,gBAAAnC;AAAA,MAACa,EAAW;AAAA,MAAX;AAAA,QACC,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,UAAAJ,EAAQ2B,EAAgB,cAAc;AAAA,QACxC;AAAA,QAEC,YAAE,SAAS;AAAA,MAAA;AAAA,IAAA,EACd,CACF;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF;AAEJ,GAGaE,KAA8B,MAAM;AAC/C,QAAM,EAAE,YAAAnC,GAAY,SAAAM,GAAS,SAAAJ,EAAA,IAAYkC,EAAA,GACnC,EAAE,GAAA5B,EAAA,IAAMC,EAAe,QAAQ;AAErC,MAAI,CAACT;AACH,UAAM,IAAI;AAAA,MACRQ,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAO;AAAA,QACP,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAGL,SAAO,gBAAAX,EAACF,GAAA,EAAkB,YAAAK,GAAwB,SAAAM,GAAkB,SAAAJ,EAAA,CAAkB;AACxF;"}
|
package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js
CHANGED
|
@@ -45,10 +45,10 @@ function Ce({
|
|
|
45
45
|
validationMode: L = "onSubmit",
|
|
46
46
|
shouldFocusError: G = !0
|
|
47
47
|
}) {
|
|
48
|
-
const u = Q({ employeeId: i ?? "" }, { enabled: !!i }), t = u.data?.
|
|
48
|
+
const u = Q({ employeeId: i ?? "" }, { enabled: !!i }), t = u.data?.employeeShow, r = !i, c = ce(t), p = r ? "create" : "update", [S, w] = k(
|
|
49
49
|
() => $({ mode: p, optionalFieldsToRequire: O, hasSsn: t?.hasSsn }),
|
|
50
50
|
[p, O, t?.hasSsn]
|
|
51
|
-
),
|
|
51
|
+
), I = {
|
|
52
52
|
firstName: t?.firstName ?? a?.firstName ?? "",
|
|
53
53
|
middleInitial: t?.middleInitial ?? a?.middleInitial ?? "",
|
|
54
54
|
lastName: t?.lastName ?? a?.lastName ?? "",
|
|
@@ -57,11 +57,11 @@ function Ce({
|
|
|
57
57
|
ssn: a?.ssn ?? "",
|
|
58
58
|
selfOnboarding: a?.selfOnboarding ?? Oe(t)
|
|
59
59
|
}, d = x({
|
|
60
|
-
resolver: K(
|
|
60
|
+
resolver: K(S),
|
|
61
61
|
mode: L,
|
|
62
62
|
shouldFocusError: G,
|
|
63
|
-
defaultValues:
|
|
64
|
-
values:
|
|
63
|
+
defaultValues: I,
|
|
64
|
+
values: I,
|
|
65
65
|
resetOptions: { keepDirtyValues: !0 }
|
|
66
66
|
}), g = j(), y = J(), b = X(), R = g.isPending || y.isPending || b.isPending, {
|
|
67
67
|
baseSubmitHandler: v,
|
|
@@ -159,7 +159,7 @@ function Ce({
|
|
|
159
159
|
},
|
|
160
160
|
fieldsMetadata: C,
|
|
161
161
|
hookFormInternals: U,
|
|
162
|
-
getFormSubmissionValues: le(d,
|
|
162
|
+
getFormSubmissionValues: le(d, S)
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
}
|
package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmployeeDetailsForm.js","sources":["../../../../../../src/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { useMemo } from 'react'\nimport { useForm } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeesCreateMutation } from '@gusto/embedded-api/react-query/employeesCreate'\nimport { useEmployeesUpdateMutation } from '@gusto/embedded-api/react-query/employeesUpdate'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport {\n createEmployeeDetailsSchema,\n type EmployeeDetailsOptionalFieldsToRequire,\n type EmployeeDetailsFormData,\n type EmployeeDetailsFormOutputs,\n} from './employeeDetailsSchema'\nimport {\n FirstNameField,\n MiddleInitialField,\n LastNameField,\n EmailField,\n DateOfBirthField,\n SsnField,\n SelfOnboardingField,\n} from './fields'\nimport type {\n FirstNameFieldProps,\n MiddleInitialFieldProps,\n LastNameFieldProps,\n EmailFieldProps,\n DateOfBirthFieldProps,\n SsnFieldProps,\n SelfOnboardingFieldProps,\n} from './fields'\nimport { normalizeToISOString } from '@/helpers/dateFormatting'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { EmployeeOnboardingStatus } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\n\nexport type { EmployeeDetailsOptionalFieldsToRequire } from './employeeDetailsSchema'\n\n/** @internal */\nfunction buildEmployeeDetailsFieldsMetadata(\n base: Record<keyof EmployeeDetailsFormData, FieldMetadata>,\n) {\n return {\n firstName: base.firstName,\n middleInitial: base.middleInitial,\n lastName: base.lastName,\n email: base.email,\n dateOfBirth: base.dateOfBirth,\n ssn: base.ssn,\n selfOnboarding: base.selfOnboarding,\n } satisfies FieldsMetadata\n}\n\n/**\n * Optional callbacks passed to {@link UseEmployeeDetailsFormReady.actions.onSubmit | onSubmit}.\n *\n * @remarks\n * Only the callback matching the submit mode fires —\n * `onEmployeeCreated` on create, `onEmployeeUpdated` on update.\n * `onOnboardingStatusUpdated` fires when toggling the self-onboarding\n * switch changes the employee's onboarding status as part of an update.\n *\n * @public\n * @group Utility types\n */\nexport interface EmployeeDetailsSubmitCallbacks {\n /** Fired after a new employee is successfully created. */\n onEmployeeCreated?: (employee: Employee) => void\n /** Fired after an existing employee is successfully updated. */\n onEmployeeUpdated?: (employee: Employee) => void\n /** Fired when an update toggles self-onboarding and the employee's onboarding status changes. */\n onOnboardingStatusUpdated?: (status: unknown) => void\n}\n\n/**\n * Shared options merged into both branches of {@link UseEmployeeDetailsFormProps}.\n *\n * @public\n */\nexport type UseEmployeeDetailsFormSharedProps = {\n /** Whether to expose the self-onboarding toggle as `form.Fields.SelfOnboarding`. Defaults to `true`. */\n withSelfOnboardingField?: boolean\n /** Fields that are optional by default but should be promoted to required for this form instance. */\n optionalFieldsToRequire?: EmployeeDetailsOptionalFieldsToRequire\n /** Initial values applied before any employee data loads. */\n defaultValues?: Partial<EmployeeDetailsFormData>\n /** When validation runs. Forwarded to react-hook-form's `mode`. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Whether react-hook-form should focus the first error on validation failure. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Options for {@link useEmployeeDetailsForm}.\n *\n * @remarks\n * Discriminated by mode: in create mode supply `companyId` and omit\n * `employeeId`; in update mode supply `employeeId` (and optionally\n * `companyId`).\n *\n * @public\n * @group Utility types\n */\nexport type UseEmployeeDetailsFormProps =\n | (UseEmployeeDetailsFormSharedProps & { companyId: string; employeeId?: never })\n | (UseEmployeeDetailsFormSharedProps & { employeeId: string; companyId?: string })\n\n/**\n * The Field components exposed by {@link useEmployeeDetailsForm} as `form.Fields`.\n *\n * @remarks\n * Each entry is a component bound to a specific form field. `SelfOnboarding`\n * may be `undefined` when the field is not toggleable.\n *\n * @public\n */\nexport interface EmployeeDetailsFormFields {\n /** Bound to `firstName`. Text input. */\n FirstName: ComponentType<FirstNameFieldProps>\n /** Bound to `middleInitial`. Text input. */\n MiddleInitial: ComponentType<MiddleInitialFieldProps>\n /** Bound to `lastName`. Text input. */\n LastName: ComponentType<LastNameFieldProps>\n /** Bound to `email`. Text input. */\n Email: ComponentType<EmailFieldProps>\n /** Bound to `dateOfBirth`. Date picker. */\n DateOfBirth: ComponentType<DateOfBirthFieldProps>\n /** Bound to `ssn`. Text input. */\n Ssn: ComponentType<SsnFieldProps>\n /** Bound to `selfOnboarding`. Switch, or `undefined` when the field is not toggleable. */\n SelfOnboarding: ComponentType<SelfOnboardingFieldProps> | undefined\n}\n\n/**\n * The ready-state result returned by {@link useEmployeeDetailsForm} once data has loaded.\n *\n * @remarks\n * Provides the form's `data` snapshot, pending `status`, submit `actions`,\n * error handling, and the `form.Fields` map.\n *\n * @public\n */\nexport interface UseEmployeeDetailsFormReady extends BaseFormHookReady<\n EmployeeDetailsFieldsMetadata,\n EmployeeDetailsFormData,\n EmployeeDetailsFormFields\n> {\n /** The loaded employee data, or `null` in create mode. */\n data: {\n /** The employee being edited, or `null` in create mode. */\n employee: Employee | null\n }\n /** Submit status and form mode. */\n status: {\n /** `true` while the create, update, or onboarding-status mutation is in flight. */\n isPending: boolean\n /** `'create'` when no `employeeId` was supplied, `'update'` otherwise. */\n mode: 'create' | 'update'\n }\n /** Submit and related actions. */\n actions: {\n /** Validates the form and submits the changes. Returns the created or updated employee, or `undefined` when validation fails. */\n onSubmit: (\n callbacks?: EmployeeDetailsSubmitCallbacks,\n ) => Promise<HookSubmitResult<Employee> | undefined>\n }\n}\n\nconst isCurrentlySelfOnboarding = (employee?: Employee) => {\n if (!employee?.onboardingStatus) return false\n const selfOnboardingStatuses: string[] = [\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE,\n EmployeeOnboardingStatus.SELF_ONBOARDING_INVITED,\n EmployeeOnboardingStatus.SELF_ONBOARDING_INVITED_STARTED,\n EmployeeOnboardingStatus.SELF_ONBOARDING_INVITED_OVERDUE,\n EmployeeOnboardingStatus.SELF_ONBOARDING_COMPLETED_BY_EMPLOYEE,\n EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n ]\n return selfOnboardingStatuses.includes(employee.onboardingStatus)\n}\n\nconst canToggleSelfOnboarding = (employee?: Employee) => {\n if (!employee) return true\n return (\n employee.onboardingStatus === EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE ||\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n )\n}\n\n/**\n * Headless hook for creating or updating an employee's profile details — name, email, SSN, date of birth, and self-onboarding preference.\n *\n * @remarks\n * Returns a discriminated union: a loading variant while the underlying\n * employee fetch resolves, and a ready variant exposing the form's data,\n * pending status, submit action, error handling, and bound `Fields`.\n * Self-onboarding is only toggleable when the employee's onboarding status\n * allows it; otherwise `form.Fields.SelfOnboarding` is `undefined`.\n *\n * @param input - See {@link UseEmployeeDetailsFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseEmployeeDetailsFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * useEmployeeDetailsForm,\n * SDKFormProvider,\n * type UseEmployeeDetailsFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function EmployeeDetailsPage({ companyId, employeeId }: { companyId: string; employeeId?: string }) {\n * const employeeDetails = useEmployeeDetailsForm({ companyId, employeeId })\n *\n * if (employeeDetails.isLoading) return <div>Loading...</div>\n *\n * return <EmployeeDetailsReady employeeDetails={employeeDetails} />\n * }\n *\n * function EmployeeDetailsReady({ employeeDetails }: { employeeDetails: UseEmployeeDetailsFormReady }) {\n * const { Fields } = employeeDetails.form\n *\n * const handleSubmit = async () => {\n * await employeeDetails.actions.onSubmit({\n * onEmployeeCreated: emp => console.log('Created:', emp.uuid),\n * onEmployeeUpdated: emp => console.log('Updated:', emp.uuid),\n * })\n * }\n *\n * return (\n * <SDKFormProvider formHookResult={employeeDetails}>\n * <form onSubmit={e => { e.preventDefault(); void handleSubmit() }}>\n * <Fields.FirstName label=\"First name\" />\n * <Fields.LastName label=\"Last name\" />\n * <Fields.Email label=\"Personal email\" />\n * <Fields.DateOfBirth label=\"Date of birth\" />\n * <Fields.Ssn label=\"Social Security number\" />\n * <button type=\"submit\" disabled={employeeDetails.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useEmployeeDetailsForm({\n companyId,\n employeeId,\n withSelfOnboardingField = true,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseEmployeeDetailsFormProps): HookLoadingResult | UseEmployeeDetailsFormReady {\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employee = employeeQuery.data?.employee\n\n const isCreateMode = !employeeId\n const isSelfOnboardingToggleable = canToggleSelfOnboarding(employee)\n\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createEmployeeDetailsSchema({ mode, optionalFieldsToRequire, hasSsn: employee?.hasSsn }),\n [mode, optionalFieldsToRequire, employee?.hasSsn],\n )\n\n const resolvedDefaults: EmployeeDetailsFormData = {\n firstName: employee?.firstName ?? partnerDefaults?.firstName ?? '',\n middleInitial: employee?.middleInitial ?? partnerDefaults?.middleInitial ?? '',\n lastName: employee?.lastName ?? partnerDefaults?.lastName ?? '',\n email: employee?.email ?? partnerDefaults?.email ?? '',\n dateOfBirth: employee?.dateOfBirth ?? normalizeToISOString(partnerDefaults?.dateOfBirth),\n ssn: partnerDefaults?.ssn ?? '',\n selfOnboarding: partnerDefaults?.selfOnboarding ?? isCurrentlySelfOnboarding(employee),\n }\n\n const formMethods = useForm<EmployeeDetailsFormData, unknown, EmployeeDetailsFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const createEmployeeMutation = useEmployeesCreateMutation()\n const updateEmployeeMutation = useEmployeesUpdateMutation()\n const updateOnboardingStatusMutation = useEmployeesUpdateOnboardingStatusMutation()\n\n const isPending =\n createEmployeeMutation.isPending ||\n updateEmployeeMutation.isPending ||\n updateOnboardingStatusMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('EmployeeDetailsForm')\n\n const queries = employeeId ? [employeeQuery] : []\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildEmployeeDetailsFieldsMetadata(baseMetadata)\n\n const onSubmit = async (\n callbacks?: EmployeeDetailsSubmitCallbacks,\n ): Promise<HookSubmitResult<Employee> | undefined> => {\n let submitResult: HookSubmitResult<Employee> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: EmployeeDetailsFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const { selfOnboarding, dateOfBirth, ssn, ...body } = payload\n\n const cleanedSsn = ssn ? removeNonDigits(ssn) : undefined\n const hasSsnInput = cleanedSsn && cleanedSsn.length > 0\n\n let updatedEmployee: Employee\n\n if (isCreateMode) {\n if (!companyId) {\n throw new SDKInternalError('companyId is required to create an employee')\n }\n const result = await createEmployeeMutation.mutateAsync({\n request: {\n companyId,\n requestBody: {\n ...body,\n selfOnboarding,\n dateOfBirth: dateOfBirth ? new RFCDate(new Date(dateOfBirth)) : undefined,\n ssn: hasSsnInput ? cleanedSsn : undefined,\n },\n },\n })\n\n if (!result.employee) {\n throw new SDKInternalError('Employee creation failed')\n }\n\n updatedEmployee = result.employee\n callbacks?.onEmployeeCreated?.(updatedEmployee)\n } else {\n if (!employee) {\n throw new SDKInternalError('Employee data is not available')\n }\n\n if (isSelfOnboardingToggleable) {\n const currentIsSelfOnboarding =\n employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n\n if (selfOnboarding !== currentIsSelfOnboarding) {\n const { employeeOnboardingStatus } =\n await updateOnboardingStatusMutation.mutateAsync({\n request: {\n employeeId: employee.uuid,\n requestBody: {\n onboardingStatus: selfOnboarding\n ? EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n },\n },\n })\n\n callbacks?.onOnboardingStatusUpdated?.(employeeOnboardingStatus)\n }\n }\n\n const result = await updateEmployeeMutation.mutateAsync({\n request: {\n employeeId: employee.uuid,\n requestBody: {\n version: employee.version as string,\n ...body,\n dateOfBirth: dateOfBirth || undefined,\n ssn: hasSsnInput ? cleanedSsn : undefined,\n },\n },\n })\n\n if (!result.employee) {\n throw new SDKInternalError('Employee update failed')\n }\n\n updatedEmployee = result.employee\n callbacks?.onEmployeeUpdated?.(updatedEmployee)\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updatedEmployee,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading = employeeId ? employeeQuery.isLoading : false\n\n if (isDataLoading || (employeeId && !employee)) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n employee: employee ?? null,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n FirstName: FirstNameField,\n MiddleInitial: MiddleInitialField,\n LastName: LastNameField,\n Email: EmailField,\n DateOfBirth: DateOfBirthField,\n Ssn: SsnField,\n SelfOnboarding:\n withSelfOnboardingField && isSelfOnboardingToggleable ? SelfOnboardingField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Return type of {@link useEmployeeDetailsForm}.\n *\n * @public\n */\nexport type UseEmployeeDetailsFormResult = HookLoadingResult | UseEmployeeDetailsFormReady\n\n/**\n * Shape of `form.fieldsMetadata` returned by {@link useEmployeeDetailsForm}.\n *\n * @public\n */\nexport type EmployeeDetailsFieldsMetadata = ReturnType<typeof buildEmployeeDetailsFieldsMetadata>\n"],"names":["buildEmployeeDetailsFieldsMetadata","base","isCurrentlySelfOnboarding","employee","EmployeeOnboardingStatus","canToggleSelfOnboarding","useEmployeeDetailsForm","companyId","employeeId","withSelfOnboardingField","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","employeeQuery","useEmployeesGet","isCreateMode","isSelfOnboardingToggleable","mode","schema","metadataConfig","useMemo","createEmployeeDetailsSchema","resolvedDefaults","normalizeToISOString","formMethods","useForm","zodResolver","createEmployeeMutation","useEmployeesCreateMutation","updateEmployeeMutation","useEmployeesUpdateMutation","updateOnboardingStatusMutation","useEmployeesUpdateOnboardingStatusMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","callbacks","submitResult","resolve","data","payload","selfOnboarding","dateOfBirth","ssn","body","cleanedSsn","removeNonDigits","hasSsnInput","updatedEmployee","SDKInternalError","result","RFCDate","currentIsSelfOnboarding","employeeOnboardingStatus","hookFormInternals","useHookFormInternals","FirstNameField","MiddleInitialField","LastNameField","EmailField","DateOfBirthField","SsnField","SelfOnboardingField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,SAASA,GACPC,GACA;AACA,SAAO;AAAA,IACL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AA,cACb,MAAM9B,IAAe,WAAW;AAAA,cAChC,MAAMyC;AAAA,YAAA;AAAA,UAEV,CAAC,GACDV,EAAA;AAAA,QACF;AAAA,QACA,MAAM;AACJ,UAAAA,EAAA;AAAA,QACF;AAAA,MAAA,EACF;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMiB,IAAoBC,GAAqBvC,CAAW;AAI1D,UAFsBjB,IAAaM,EAAc,YAAY,OAEvCN,KAAc,CAACL,IAC5B,EAAE,WAAW,IAAe,eAAAoC,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,UAAUpC,KAAY;AAAA,IAAA;AAAA,IAExB,QAAQ;AAAA,MACN,WAAA+B;AAAA,MACA,MAAMlB,IAAgB,WAAsB;AAAA,IAAA;AAAA,IAE9C,SAAS,EAAE,UAAA4B,EAAA;AAAA,IACX,eAAAL;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,WAAW0B;AAAA,QACX,eAAeC;AAAA,QACf,UAAUC;AAAA,QACV,OAAOC;AAAA,QACP,aAAaC;AAAA,QACb,KAAKC;AAAA,QACL,gBACE7D,KAA2BQ,IAA6BsD,KAAsB;AAAA,MAAA;AAAA,MAElF,gBAAA5B;AAAA,MACA,mBAAAoB;AAAA,MACA,yBAAyBS,GAA8B/C,GAAaN,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useEmployeeDetailsForm.js","sources":["../../../../../../src/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { useMemo } from 'react'\nimport { useForm } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeesCreateMutation } from '@gusto/embedded-api/react-query/employeesCreate'\nimport { useEmployeesUpdateMutation } from '@gusto/embedded-api/react-query/employeesUpdate'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport {\n createEmployeeDetailsSchema,\n type EmployeeDetailsOptionalFieldsToRequire,\n type EmployeeDetailsFormData,\n type EmployeeDetailsFormOutputs,\n} from './employeeDetailsSchema'\nimport {\n FirstNameField,\n MiddleInitialField,\n LastNameField,\n EmailField,\n DateOfBirthField,\n SsnField,\n SelfOnboardingField,\n} from './fields'\nimport type {\n FirstNameFieldProps,\n MiddleInitialFieldProps,\n LastNameFieldProps,\n EmailFieldProps,\n DateOfBirthFieldProps,\n SsnFieldProps,\n SelfOnboardingFieldProps,\n} from './fields'\nimport { normalizeToISOString } from '@/helpers/dateFormatting'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { EmployeeOnboardingStatus } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\n\nexport type { EmployeeDetailsOptionalFieldsToRequire } from './employeeDetailsSchema'\n\n/** @internal */\nfunction buildEmployeeDetailsFieldsMetadata(\n base: Record<keyof EmployeeDetailsFormData, FieldMetadata>,\n) {\n return {\n firstName: base.firstName,\n middleInitial: base.middleInitial,\n lastName: base.lastName,\n email: base.email,\n dateOfBirth: base.dateOfBirth,\n ssn: base.ssn,\n selfOnboarding: base.selfOnboarding,\n } satisfies FieldsMetadata\n}\n\n/**\n * Optional callbacks passed to {@link UseEmployeeDetailsFormReady.actions.onSubmit | onSubmit}.\n *\n * @remarks\n * Only the callback matching the submit mode fires —\n * `onEmployeeCreated` on create, `onEmployeeUpdated` on update.\n * `onOnboardingStatusUpdated` fires when toggling the self-onboarding\n * switch changes the employee's onboarding status as part of an update.\n *\n * @public\n * @group Utility types\n */\nexport interface EmployeeDetailsSubmitCallbacks {\n /** Fired after a new employee is successfully created. */\n onEmployeeCreated?: (employee: Employee) => void\n /** Fired after an existing employee is successfully updated. */\n onEmployeeUpdated?: (employee: Employee) => void\n /** Fired when an update toggles self-onboarding and the employee's onboarding status changes. */\n onOnboardingStatusUpdated?: (status: unknown) => void\n}\n\n/**\n * Shared options merged into both branches of {@link UseEmployeeDetailsFormProps}.\n *\n * @public\n */\nexport type UseEmployeeDetailsFormSharedProps = {\n /** Whether to expose the self-onboarding toggle as `form.Fields.SelfOnboarding`. Defaults to `true`. */\n withSelfOnboardingField?: boolean\n /** Fields that are optional by default but should be promoted to required for this form instance. */\n optionalFieldsToRequire?: EmployeeDetailsOptionalFieldsToRequire\n /** Initial values applied before any employee data loads. */\n defaultValues?: Partial<EmployeeDetailsFormData>\n /** When validation runs. Forwarded to react-hook-form's `mode`. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Whether react-hook-form should focus the first error on validation failure. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Options for {@link useEmployeeDetailsForm}.\n *\n * @remarks\n * Discriminated by mode: in create mode supply `companyId` and omit\n * `employeeId`; in update mode supply `employeeId` (and optionally\n * `companyId`).\n *\n * @public\n * @group Utility types\n */\nexport type UseEmployeeDetailsFormProps =\n | (UseEmployeeDetailsFormSharedProps & { companyId: string; employeeId?: never })\n | (UseEmployeeDetailsFormSharedProps & { employeeId: string; companyId?: string })\n\n/**\n * The Field components exposed by {@link useEmployeeDetailsForm} as `form.Fields`.\n *\n * @remarks\n * Each entry is a component bound to a specific form field. `SelfOnboarding`\n * may be `undefined` when the field is not toggleable.\n *\n * @public\n */\nexport interface EmployeeDetailsFormFields {\n /** Bound to `firstName`. Text input. */\n FirstName: ComponentType<FirstNameFieldProps>\n /** Bound to `middleInitial`. Text input. */\n MiddleInitial: ComponentType<MiddleInitialFieldProps>\n /** Bound to `lastName`. Text input. */\n LastName: ComponentType<LastNameFieldProps>\n /** Bound to `email`. Text input. */\n Email: ComponentType<EmailFieldProps>\n /** Bound to `dateOfBirth`. Date picker. */\n DateOfBirth: ComponentType<DateOfBirthFieldProps>\n /** Bound to `ssn`. Text input. */\n Ssn: ComponentType<SsnFieldProps>\n /** Bound to `selfOnboarding`. Switch, or `undefined` when the field is not toggleable. */\n SelfOnboarding: ComponentType<SelfOnboardingFieldProps> | undefined\n}\n\n/**\n * The ready-state result returned by {@link useEmployeeDetailsForm} once data has loaded.\n *\n * @remarks\n * Provides the form's `data` snapshot, pending `status`, submit `actions`,\n * error handling, and the `form.Fields` map.\n *\n * @public\n */\nexport interface UseEmployeeDetailsFormReady extends BaseFormHookReady<\n EmployeeDetailsFieldsMetadata,\n EmployeeDetailsFormData,\n EmployeeDetailsFormFields\n> {\n /** The loaded employee data, or `null` in create mode. */\n data: {\n /** The employee being edited, or `null` in create mode. */\n employee: Employee | null\n }\n /** Submit status and form mode. */\n status: {\n /** `true` while the create, update, or onboarding-status mutation is in flight. */\n isPending: boolean\n /** `'create'` when no `employeeId` was supplied, `'update'` otherwise. */\n mode: 'create' | 'update'\n }\n /** Submit and related actions. */\n actions: {\n /** Validates the form and submits the changes. Returns the created or updated employee, or `undefined` when validation fails. */\n onSubmit: (\n callbacks?: EmployeeDetailsSubmitCallbacks,\n ) => Promise<HookSubmitResult<Employee> | undefined>\n }\n}\n\nconst isCurrentlySelfOnboarding = (employee?: Employee) => {\n if (!employee?.onboardingStatus) return false\n const selfOnboardingStatuses: string[] = [\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE,\n EmployeeOnboardingStatus.SELF_ONBOARDING_INVITED,\n EmployeeOnboardingStatus.SELF_ONBOARDING_INVITED_STARTED,\n EmployeeOnboardingStatus.SELF_ONBOARDING_INVITED_OVERDUE,\n EmployeeOnboardingStatus.SELF_ONBOARDING_COMPLETED_BY_EMPLOYEE,\n EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n ]\n return selfOnboardingStatuses.includes(employee.onboardingStatus)\n}\n\nconst canToggleSelfOnboarding = (employee?: Employee) => {\n if (!employee) return true\n return (\n employee.onboardingStatus === EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE ||\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n )\n}\n\n/**\n * Headless hook for creating or updating an employee's profile details — name, email, SSN, date of birth, and self-onboarding preference.\n *\n * @remarks\n * Returns a discriminated union: a loading variant while the underlying\n * employee fetch resolves, and a ready variant exposing the form's data,\n * pending status, submit action, error handling, and bound `Fields`.\n * Self-onboarding is only toggleable when the employee's onboarding status\n * allows it; otherwise `form.Fields.SelfOnboarding` is `undefined`.\n *\n * @param input - See {@link UseEmployeeDetailsFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseEmployeeDetailsFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * useEmployeeDetailsForm,\n * SDKFormProvider,\n * type UseEmployeeDetailsFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function EmployeeDetailsPage({ companyId, employeeId }: { companyId: string; employeeId?: string }) {\n * const employeeDetails = useEmployeeDetailsForm({ companyId, employeeId })\n *\n * if (employeeDetails.isLoading) return <div>Loading...</div>\n *\n * return <EmployeeDetailsReady employeeDetails={employeeDetails} />\n * }\n *\n * function EmployeeDetailsReady({ employeeDetails }: { employeeDetails: UseEmployeeDetailsFormReady }) {\n * const { Fields } = employeeDetails.form\n *\n * const handleSubmit = async () => {\n * await employeeDetails.actions.onSubmit({\n * onEmployeeCreated: emp => console.log('Created:', emp.uuid),\n * onEmployeeUpdated: emp => console.log('Updated:', emp.uuid),\n * })\n * }\n *\n * return (\n * <SDKFormProvider formHookResult={employeeDetails}>\n * <form onSubmit={e => { e.preventDefault(); void handleSubmit() }}>\n * <Fields.FirstName label=\"First name\" />\n * <Fields.LastName label=\"Last name\" />\n * <Fields.Email label=\"Personal email\" />\n * <Fields.DateOfBirth label=\"Date of birth\" />\n * <Fields.Ssn label=\"Social Security number\" />\n * <button type=\"submit\" disabled={employeeDetails.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useEmployeeDetailsForm({\n companyId,\n employeeId,\n withSelfOnboardingField = true,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseEmployeeDetailsFormProps): HookLoadingResult | UseEmployeeDetailsFormReady {\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employee = employeeQuery.data?.employeeShow\n\n const isCreateMode = !employeeId\n const isSelfOnboardingToggleable = canToggleSelfOnboarding(employee)\n\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createEmployeeDetailsSchema({ mode, optionalFieldsToRequire, hasSsn: employee?.hasSsn }),\n [mode, optionalFieldsToRequire, employee?.hasSsn],\n )\n\n const resolvedDefaults: EmployeeDetailsFormData = {\n firstName: employee?.firstName ?? partnerDefaults?.firstName ?? '',\n middleInitial: employee?.middleInitial ?? partnerDefaults?.middleInitial ?? '',\n lastName: employee?.lastName ?? partnerDefaults?.lastName ?? '',\n email: employee?.email ?? partnerDefaults?.email ?? '',\n dateOfBirth: employee?.dateOfBirth ?? normalizeToISOString(partnerDefaults?.dateOfBirth),\n ssn: partnerDefaults?.ssn ?? '',\n selfOnboarding: partnerDefaults?.selfOnboarding ?? isCurrentlySelfOnboarding(employee),\n }\n\n const formMethods = useForm<EmployeeDetailsFormData, unknown, EmployeeDetailsFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const createEmployeeMutation = useEmployeesCreateMutation()\n const updateEmployeeMutation = useEmployeesUpdateMutation()\n const updateOnboardingStatusMutation = useEmployeesUpdateOnboardingStatusMutation()\n\n const isPending =\n createEmployeeMutation.isPending ||\n updateEmployeeMutation.isPending ||\n updateOnboardingStatusMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('EmployeeDetailsForm')\n\n const queries = employeeId ? [employeeQuery] : []\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildEmployeeDetailsFieldsMetadata(baseMetadata)\n\n const onSubmit = async (\n callbacks?: EmployeeDetailsSubmitCallbacks,\n ): Promise<HookSubmitResult<Employee> | undefined> => {\n let submitResult: HookSubmitResult<Employee> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: EmployeeDetailsFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const { selfOnboarding, dateOfBirth, ssn, ...body } = payload\n\n const cleanedSsn = ssn ? removeNonDigits(ssn) : undefined\n const hasSsnInput = cleanedSsn && cleanedSsn.length > 0\n\n let updatedEmployee: Employee\n\n if (isCreateMode) {\n if (!companyId) {\n throw new SDKInternalError('companyId is required to create an employee')\n }\n const result = await createEmployeeMutation.mutateAsync({\n request: {\n companyId,\n requestBody: {\n ...body,\n selfOnboarding,\n dateOfBirth: dateOfBirth ? new RFCDate(new Date(dateOfBirth)) : undefined,\n ssn: hasSsnInput ? cleanedSsn : undefined,\n },\n },\n })\n\n if (!result.employee) {\n throw new SDKInternalError('Employee creation failed')\n }\n\n updatedEmployee = result.employee\n callbacks?.onEmployeeCreated?.(updatedEmployee)\n } else {\n if (!employee) {\n throw new SDKInternalError('Employee data is not available')\n }\n\n if (isSelfOnboardingToggleable) {\n const currentIsSelfOnboarding =\n employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n\n if (selfOnboarding !== currentIsSelfOnboarding) {\n const { employeeOnboardingStatus } =\n await updateOnboardingStatusMutation.mutateAsync({\n request: {\n employeeId: employee.uuid,\n requestBody: {\n onboardingStatus: selfOnboarding\n ? EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n },\n },\n })\n\n callbacks?.onOnboardingStatusUpdated?.(employeeOnboardingStatus)\n }\n }\n\n const result = await updateEmployeeMutation.mutateAsync({\n request: {\n employeeId: employee.uuid,\n requestBody: {\n version: employee.version as string,\n ...body,\n dateOfBirth: dateOfBirth || undefined,\n ssn: hasSsnInput ? cleanedSsn : undefined,\n },\n },\n })\n\n if (!result.employee) {\n throw new SDKInternalError('Employee update failed')\n }\n\n updatedEmployee = result.employee\n callbacks?.onEmployeeUpdated?.(updatedEmployee)\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updatedEmployee,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading = employeeId ? employeeQuery.isLoading : false\n\n if (isDataLoading || (employeeId && !employee)) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n employee: employee ?? null,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n FirstName: FirstNameField,\n MiddleInitial: MiddleInitialField,\n LastName: LastNameField,\n Email: EmailField,\n DateOfBirth: DateOfBirthField,\n Ssn: SsnField,\n SelfOnboarding:\n withSelfOnboardingField && isSelfOnboardingToggleable ? SelfOnboardingField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Return type of {@link useEmployeeDetailsForm}.\n *\n * @public\n */\nexport type UseEmployeeDetailsFormResult = HookLoadingResult | UseEmployeeDetailsFormReady\n\n/**\n * Shape of `form.fieldsMetadata` returned by {@link useEmployeeDetailsForm}.\n *\n * @public\n */\nexport type EmployeeDetailsFieldsMetadata = ReturnType<typeof buildEmployeeDetailsFieldsMetadata>\n"],"names":["buildEmployeeDetailsFieldsMetadata","base","isCurrentlySelfOnboarding","employee","EmployeeOnboardingStatus","canToggleSelfOnboarding","useEmployeeDetailsForm","companyId","employeeId","withSelfOnboardingField","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","employeeQuery","useEmployeesGet","isCreateMode","isSelfOnboardingToggleable","mode","schema","metadataConfig","useMemo","createEmployeeDetailsSchema","resolvedDefaults","normalizeToISOString","formMethods","useForm","zodResolver","createEmployeeMutation","useEmployeesCreateMutation","updateEmployeeMutation","useEmployeesUpdateMutation","updateOnboardingStatusMutation","useEmployeesUpdateOnboardingStatusMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","callbacks","submitResult","resolve","data","payload","selfOnboarding","dateOfBirth","ssn","body","cleanedSsn","removeNonDigits","hasSsnInput","updatedEmployee","SDKInternalError","result","RFCDate","currentIsSelfOnboarding","employeeOnboardingStatus","hookFormInternals","useHookFormInternals","FirstNameField","MiddleInitialField","LastNameField","EmailField","DateOfBirthField","SsnField","SelfOnboardingField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,SAASA,GACPC,GACA;AACA,SAAO;AAAA,IACL,WAAWA,EAAK;AAAA,IAChB,eAAeA,EAAK;AAAA,IACpB,UAAUA,EAAK;AAAA,IACf,OAAOA,EAAK;AAAA,IACZ,aAAaA,EAA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,MAAM;AACJ,UAAAA,EAAA;AAAA,QACF;AAAA,MAAA,EACF;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMiB,IAAoBC,GAAqBvC,CAAW;AAI1D,UAFsBjB,IAAaM,EAAc,YAAY,OAEvCN,KAAc,CAACL,IAC5B,EAAE,WAAW,IAAe,eAAAoC,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,UAAUpC,KAAY;AAAA,IAAA;AAAA,IAExB,QAAQ;AAAA,MACN,WAAA+B;AAAA,MACA,MAAMlB,IAAgB,WAAsB;AAAA,IAAA;AAAA,IAE9C,SAAS,EAAE,UAAA4B,EAAA;AAAA,IACX,eAAAL;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,WAAW0B;AAAA,QACX,eAAeC;AAAA,QACf,UAAUC;AAAA,QACV,OAAOC;AAAA,QACP,aAAaC;AAAA,QACb,KAAKC;AAAA,QACL,gBACE7D,KAA2BQ,IAA6BsD,KAAsB;AAAA,MAAA;AAAA,MAElF,gBAAA5B;AAAA,MACA,mBAAAoB;AAAA,MACA,yBAAyBS,GAA8B/C,GAAaN,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -3,7 +3,7 @@ import { composeErrorHandler as t } from "../../../../../partner-hook-utils/comp
|
|
|
3
3
|
function m({
|
|
4
4
|
employeeId: r
|
|
5
5
|
}) {
|
|
6
|
-
const e = n({ employeeId: r }, { staleTime: 1 / 0 }), o = t([e]), i = e.data?.
|
|
6
|
+
const e = n({ employeeId: r }, { staleTime: 1 / 0 }), o = t([e]), i = e.data?.employeeShow;
|
|
7
7
|
return e.isLoading || !i ? { isLoading: !0, errorHandling: o } : {
|
|
8
8
|
isLoading: !1,
|
|
9
9
|
data: { employee: i },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmployeeProfileSummary.js","sources":["../../../../../../src/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.tsx"],"sourcesContent":["import { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type { BaseHookReady, HookLoadingResult } from '@/partner-hook-utils/types'\n\n/**\n * Options for {@link useEmployeeProfileSummary}.\n *\n * @public\n */\nexport interface UseEmployeeProfileSummaryParams {\n /** The associated employee identifier. */\n employeeId: string\n}\n\ntype UseEmployeeProfileSummaryReady = BaseHookReady<\n { employee: Employee },\n { isFetching: boolean; isPending: boolean }\n>\n\n/**\n * Return type of {@link useEmployeeProfileSummary}.\n *\n * @public\n */\nexport type UseEmployeeProfileSummaryResult = HookLoadingResult | UseEmployeeProfileSummaryReady\n\n/**\n * Read-only data hook for the basic-details Profile card.\n *\n * @remarks\n * Fetches a single employee record scoped to the fields the\n * basic-details surface displays. Pair with {@link useEmployeeDetailsForm}\n * to render an edit form against the same record.\n *\n * @param input - See {@link UseEmployeeProfileSummaryParams}.\n * @returns A {@link HookLoadingResult} while loading, or the ready result with the loaded employee once available.\n * @public\n *\n * @example\n * ```tsx\n * import { useEmployeeProfileSummary } from '@gusto/embedded-react-sdk'\n *\n * function ProfileSummary({ employeeId }: { employeeId: string }) {\n * const summary = useEmployeeProfileSummary({ employeeId })\n *\n * if (summary.isLoading) return <div>Loading...</div>\n *\n * const { employee } = summary.data\n * return <h2>{employee.firstName} {employee.lastName}</h2>\n * }\n * ```\n */\nexport function useEmployeeProfileSummary({\n employeeId,\n}: UseEmployeeProfileSummaryParams): UseEmployeeProfileSummaryResult {\n const employeeQuery = useEmployeesGet({ employeeId }, { staleTime: Infinity })\n\n const errorHandling = composeErrorHandler([employeeQuery])\n\n const employee = employeeQuery.data?.
|
|
1
|
+
{"version":3,"file":"useEmployeeProfileSummary.js","sources":["../../../../../../src/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.tsx"],"sourcesContent":["import { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type { BaseHookReady, HookLoadingResult } from '@/partner-hook-utils/types'\n\n/**\n * Options for {@link useEmployeeProfileSummary}.\n *\n * @public\n */\nexport interface UseEmployeeProfileSummaryParams {\n /** The associated employee identifier. */\n employeeId: string\n}\n\ntype UseEmployeeProfileSummaryReady = BaseHookReady<\n { employee: Employee },\n { isFetching: boolean; isPending: boolean }\n>\n\n/**\n * Return type of {@link useEmployeeProfileSummary}.\n *\n * @public\n */\nexport type UseEmployeeProfileSummaryResult = HookLoadingResult | UseEmployeeProfileSummaryReady\n\n/**\n * Read-only data hook for the basic-details Profile card.\n *\n * @remarks\n * Fetches a single employee record scoped to the fields the\n * basic-details surface displays. Pair with {@link useEmployeeDetailsForm}\n * to render an edit form against the same record.\n *\n * @param input - See {@link UseEmployeeProfileSummaryParams}.\n * @returns A {@link HookLoadingResult} while loading, or the ready result with the loaded employee once available.\n * @public\n *\n * @example\n * ```tsx\n * import { useEmployeeProfileSummary } from '@gusto/embedded-react-sdk'\n *\n * function ProfileSummary({ employeeId }: { employeeId: string }) {\n * const summary = useEmployeeProfileSummary({ employeeId })\n *\n * if (summary.isLoading) return <div>Loading...</div>\n *\n * const { employee } = summary.data\n * return <h2>{employee.firstName} {employee.lastName}</h2>\n * }\n * ```\n */\nexport function useEmployeeProfileSummary({\n employeeId,\n}: UseEmployeeProfileSummaryParams): UseEmployeeProfileSummaryResult {\n const employeeQuery = useEmployeesGet({ employeeId }, { staleTime: Infinity })\n\n const errorHandling = composeErrorHandler([employeeQuery])\n\n const employee = employeeQuery.data?.employeeShow\n\n if (employeeQuery.isLoading || !employee) {\n return { isLoading: true, errorHandling }\n }\n\n return {\n isLoading: false,\n data: { employee },\n status: {\n isFetching: employeeQuery.isFetching,\n isPending: false,\n },\n errorHandling,\n }\n}\n"],"names":["useEmployeeProfileSummary","employeeId","employeeQuery","useEmployeesGet","errorHandling","composeErrorHandler","employee"],"mappings":";;AAqDO,SAASA,EAA0B;AAAA,EACxC,YAAAC;AACF,GAAqE;AACnE,QAAMC,IAAgBC,EAAgB,EAAE,YAAAF,EAAA,GAAc,EAAE,WAAW,OAAU,GAEvEG,IAAgBC,EAAoB,CAACH,CAAa,CAAC,GAEnDI,IAAWJ,EAAc,MAAM;AAErC,SAAIA,EAAc,aAAa,CAACI,IACvB,EAAE,WAAW,IAAM,eAAAF,EAAA,IAGrB;AAAA,IACL,WAAW;AAAA,IACX,MAAM,EAAE,UAAAE,EAAA;AAAA,IACR,QAAQ;AAAA,MACN,YAAYJ,EAAc;AAAA,MAC1B,WAAW;AAAA,IAAA;AAAA,IAEb,eAAAE;AAAA,EAAA;AAEJ;"}
|