@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":"useCompensationManagement.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsDeleteCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDeleteCompensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport {\n getPendingCompensationChanges,\n type PendingCompensationChange,\n} from '../getPendingCompensationChanges'\nimport { derivePrimaryFlsaStatus } from '@/components/Employee/Compensation/shared/derivePrimaryFlsaStatus'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type { BaseHookReady, HookLoadingResult, HookSubmitResult } from '@/partner-hook-utils/types'\n\n/**\n * Props for {@link useCompensationManagement}.\n *\n * @public\n */\nexport interface UseCompensationManagementProps {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Ready state of {@link useCompensationManagement}.\n *\n * @public\n */\nexport interface UseCompensationManagementReady extends BaseHookReady<\n {\n jobs: Job[]\n primaryJob?: Job\n primaryFlsaStatus?: string\n hasMultipleJobs: boolean\n pendingChanges: PendingCompensationChange[]\n /** First name from the shared employee fetch; useful for cosmetic copy\n * in alerts (e.g. \"Heads up, Jane has pending changes\"). Optional\n * because the employee record can omit it. */\n employeeFirstName?: string\n },\n {\n isPending: boolean\n cancellingCompensationUuid: string | null\n }\n> {\n /** Actions available when the hook has loaded. */\n actions: {\n cancelPendingChange: (\n pendingChange: PendingCompensationChange,\n ) => Promise<HookSubmitResult<unknown> | undefined>\n }\n}\n\n/**\n * Return type of {@link useCompensationManagement}.\n *\n * @public\n */\nexport type UseCompensationManagementResult = HookLoadingResult | UseCompensationManagementReady\n\n/**\n * Non-Suspense queries powering the standalone Compensation management card.\n * Returns jobs + pending-changes + the employee's first name (for cosmetic\n * alert copy) along with a cancel-pending-change action.\n *\n * @public\n */\nexport function useCompensationManagement({\n employeeId,\n}: UseCompensationManagementProps): UseCompensationManagementResult {\n // staleTime: Infinity on dashboard reads — the SDK QueryClient already\n // invalidates all queries on any mutation success, so post-write\n // freshness is preserved. Without this, every subscriber re-mount\n // (e.g. tab navigation) would fire a redundant background refetch.\n //\n // GET /v1/employees/:id/jobs?include=all_compensations returns all effective-\n // dated compensations (current + future) with compensation.title on each,\n // which is required for pending-change detection. Without the include param,\n // only the current compensation is returned.\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId, include: GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations },\n { staleTime: Infinity },\n )\n // Employee query is a lightweight secondary fetch for cosmetic data only\n // (first name used in alert copy). Jobs / compensation data comes from jobsQuery.\n const employeeQuery = useEmployeesGet({ employeeId }, { staleTime: Infinity })\n const cancelCompensationMutation = useJobsAndCompensationsDeleteCompensationMutation()\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('Employee.Management.Compensation')\n\n const employee = employeeQuery.data?.
|
|
1
|
+
{"version":3,"file":"useCompensationManagement.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.tsx"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsDeleteCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDeleteCompensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport {\n getPendingCompensationChanges,\n type PendingCompensationChange,\n} from '../getPendingCompensationChanges'\nimport { derivePrimaryFlsaStatus } from '@/components/Employee/Compensation/shared/derivePrimaryFlsaStatus'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type { BaseHookReady, HookLoadingResult, HookSubmitResult } from '@/partner-hook-utils/types'\n\n/**\n * Props for {@link useCompensationManagement}.\n *\n * @public\n */\nexport interface UseCompensationManagementProps {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Ready state of {@link useCompensationManagement}.\n *\n * @public\n */\nexport interface UseCompensationManagementReady extends BaseHookReady<\n {\n jobs: Job[]\n primaryJob?: Job\n primaryFlsaStatus?: string\n hasMultipleJobs: boolean\n pendingChanges: PendingCompensationChange[]\n /** First name from the shared employee fetch; useful for cosmetic copy\n * in alerts (e.g. \"Heads up, Jane has pending changes\"). Optional\n * because the employee record can omit it. */\n employeeFirstName?: string\n },\n {\n isPending: boolean\n cancellingCompensationUuid: string | null\n }\n> {\n /** Actions available when the hook has loaded. */\n actions: {\n cancelPendingChange: (\n pendingChange: PendingCompensationChange,\n ) => Promise<HookSubmitResult<unknown> | undefined>\n }\n}\n\n/**\n * Return type of {@link useCompensationManagement}.\n *\n * @public\n */\nexport type UseCompensationManagementResult = HookLoadingResult | UseCompensationManagementReady\n\n/**\n * Non-Suspense queries powering the standalone Compensation management card.\n * Returns jobs + pending-changes + the employee's first name (for cosmetic\n * alert copy) along with a cancel-pending-change action.\n *\n * @public\n */\nexport function useCompensationManagement({\n employeeId,\n}: UseCompensationManagementProps): UseCompensationManagementResult {\n // staleTime: Infinity on dashboard reads — the SDK QueryClient already\n // invalidates all queries on any mutation success, so post-write\n // freshness is preserved. Without this, every subscriber re-mount\n // (e.g. tab navigation) would fire a redundant background refetch.\n //\n // GET /v1/employees/:id/jobs?include=all_compensations returns all effective-\n // dated compensations (current + future) with compensation.title on each,\n // which is required for pending-change detection. Without the include param,\n // only the current compensation is returned.\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId, include: GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations },\n { staleTime: Infinity },\n )\n // Employee query is a lightweight secondary fetch for cosmetic data only\n // (first name used in alert copy). Jobs / compensation data comes from jobsQuery.\n const employeeQuery = useEmployeesGet({ employeeId }, { staleTime: Infinity })\n const cancelCompensationMutation = useJobsAndCompensationsDeleteCompensationMutation()\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('Employee.Management.Compensation')\n\n const employee = employeeQuery.data?.employeeShow\n\n const jobs = useMemo(() => jobsQuery.data?.jobs ?? [], [jobsQuery.data?.jobs])\n const primaryJob = useMemo(() => jobs.find(job => job.primary === true), [jobs])\n const primaryFlsaStatus = useMemo(() => derivePrimaryFlsaStatus(jobs), [jobs])\n const hasMultipleJobs = jobs.length > 1\n\n const pendingChanges = useMemo(() => getPendingCompensationChanges(jobs), [jobs])\n\n const cancellingCompensationUuid = cancelCompensationMutation.isPending\n ? cancelCompensationMutation.variables.request.compensationId\n : null\n\n const cancelPendingChange = useCallback(\n async (\n pendingChange: PendingCompensationChange,\n ): Promise<HookSubmitResult<unknown> | undefined> => {\n let submitResult: HookSubmitResult<unknown> | undefined\n await baseSubmitHandler(pendingChange, async ({ compensationUuid }) => {\n const data = await cancelCompensationMutation.mutateAsync({\n request: { compensationId: compensationUuid },\n })\n submitResult = { mode: 'update', data }\n })\n return submitResult\n },\n [baseSubmitHandler, cancelCompensationMutation],\n )\n\n const isPending =\n jobsQuery.isFetching || employeeQuery.isFetching || cancelCompensationMutation.isPending\n\n const errorHandling = composeErrorHandler([jobsQuery, employeeQuery], {\n submitError,\n setSubmitError,\n })\n\n // The card depends on the jobs fetch (jobs, pending changes, FLSA status).\n // The employee fetch is cosmetic (first name for alert copy) and is not\n // gated on here so the card can render as soon as jobs resolve.\n if (jobsQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n return {\n isLoading: false,\n data: {\n jobs,\n primaryJob,\n primaryFlsaStatus,\n hasMultipleJobs,\n pendingChanges,\n employeeFirstName: employee?.firstName ?? undefined,\n },\n status: {\n isPending,\n cancellingCompensationUuid,\n },\n actions: {\n cancelPendingChange,\n },\n errorHandling,\n }\n}\n"],"names":["useCompensationManagement","employeeId","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","employeeQuery","useEmployeesGet","cancelCompensationMutation","useJobsAndCompensationsDeleteCompensationMutation","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","employee","jobs","useMemo","primaryJob","job","primaryFlsaStatus","derivePrimaryFlsaStatus","hasMultipleJobs","pendingChanges","getPendingCompensationChanges","cancellingCompensationUuid","cancelPendingChange","useCallback","pendingChange","submitResult","compensationUuid","isPending","errorHandling","composeErrorHandler"],"mappings":";;;;;;;;;AAqEO,SAASA,EAA0B;AAAA,EACxC,YAAAC;AACF,GAAoE;AAUlE,QAAMC,IAAYC;AAAA,IAChB,EAAE,YAAAF,GAAY,SAASG,EAA8C,iBAAA;AAAA,IACrE,EAAE,WAAW,MAAA;AAAA,EAAS,GAIlBC,IAAgBC,EAAgB,EAAE,YAAAL,EAAA,GAAc,EAAE,WAAW,OAAU,GACvEM,IAA6BC,EAAA,GAC7B;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,kCAAkC,GAE9CC,IAAWR,EAAc,MAAM,cAE/BS,IAAOC,EAAQ,MAAMb,EAAU,MAAM,QAAQ,CAAA,GAAI,CAACA,EAAU,MAAM,IAAI,CAAC,GACvEc,IAAaD,EAAQ,MAAMD,EAAK,KAAK,CAAAG,MAAOA,EAAI,YAAY,EAAI,GAAG,CAACH,CAAI,CAAC,GACzEI,IAAoBH,EAAQ,MAAMI,EAAwBL,CAAI,GAAG,CAACA,CAAI,CAAC,GACvEM,IAAkBN,EAAK,SAAS,GAEhCO,IAAiBN,EAAQ,MAAMO,EAA8BR,CAAI,GAAG,CAACA,CAAI,CAAC,GAE1ES,IAA6BhB,EAA2B,YAC1DA,EAA2B,UAAU,QAAQ,iBAC7C,MAEEiB,IAAsBC;AAAA,IAC1B,OACEC,MACmD;AACnD,UAAIC;AACJ,mBAAMlB,EAAkBiB,GAAe,OAAO,EAAE,kBAAAE,QAAuB;AAIrE,QAAAD,IAAe,EAAE,MAAM,UAAU,MAHpB,MAAMpB,EAA2B,YAAY;AAAA,UACxD,SAAS,EAAE,gBAAgBqB,EAAA;AAAA,QAAiB,CAC7C,EACgC;AAAA,MACnC,CAAC,GACMD;AAAA,IACT;AAAA,IACA,CAAClB,GAAmBF,CAA0B;AAAA,EAAA,GAG1CsB,IACJ3B,EAAU,cAAcG,EAAc,cAAcE,EAA2B,WAE3EuB,IAAgBC,EAAoB,CAAC7B,GAAWG,CAAa,GAAG;AAAA,IACpE,aAAAK;AAAA,IACA,gBAAAC;AAAA,EAAA,CACD;AAKD,SAAIT,EAAU,YACL,EAAE,WAAW,IAAM,eAAA4B,EAAA,IAGrB;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,MAAAhB;AAAA,MACA,YAAAE;AAAA,MACA,mBAAAE;AAAA,MACA,iBAAAE;AAAA,MACA,gBAAAC;AAAA,MACA,mBAAmBR,GAAU,aAAa;AAAA,IAAA;AAAA,IAE5C,QAAQ;AAAA,MACN,WAAAgB;AAAA,MACA,4BAAAN;AAAA,IAAA;AAAA,IAEF,SAAS;AAAA,MACP,qBAAAC;AAAA,IAAA;AAAA,IAEF,eAAAM;AAAA,EAAA;AAEJ;"}
|
|
@@ -66,7 +66,7 @@ function st({
|
|
|
66
66
|
), S = Ce(
|
|
67
67
|
{ employeeId: e ?? "" },
|
|
68
68
|
{ enabled: !!e }
|
|
69
|
-
), w = ve({ employeeId: e ?? "" }, { enabled: !!e }), u = p.data?.jobs, y = S.data?.employeeWorkAddressesList?.find((C) => C.active) ?? null, W = w.data?.
|
|
69
|
+
), w = ve({ employeeId: e ?? "" }, { enabled: !!e }), u = p.data?.jobs, y = S.data?.employeeWorkAddressesList?.find((C) => C.active) ?? null, W = w.data?.employeeShow ?? null, M = W?.companyUuid, F = Se(
|
|
70
70
|
{ companyId: M ?? "" },
|
|
71
71
|
{ enabled: !!M }
|
|
72
72
|
), D = F.data?.federalTaxDetails?.taxableAsScorp === !0, b = y?.state === "WA", o = P(() => Ee(u, a), [u, a]), l = !a, q = l ? "create" : "update", [E, N] = P(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useJobForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useJobForm/useJobForm.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { useMemo, useState } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useFederalTaxDetailsGet } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport {\n createJobSchema,\n type JobOptionalFieldsToRequire,\n type JobFormData,\n type JobFormOutputs,\n} from './jobSchema'\nimport {\n JobTitleField,\n HireDateField,\n TwoPercentShareholderField,\n StateWcCoveredField,\n StateWcClassCodeField,\n} from './fields'\nimport type {\n JobTitleFieldProps,\n HireDateFieldProps,\n TwoPercentShareholderFieldProps,\n StateWcCoveredFieldProps,\n StateWcClassCodeFieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { withFlags } from '@/partner-hook-utils/form/withFlags'\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 { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { WA_RISK_CLASS_CODES, type WARiskClassCode } from '@/models/WA_RISK_CODES'\n\n/**\n * Optional values supplied to {@link useJobForm}'s `actions.onSubmit` at submit time.\n *\n * @remarks\n * Use these when a value isn't sourced from a rendered field — typically\n * because the hook was configured with `withHireDateField: false`, or because\n * the employee being saved was created in the same submit chain and the\n * `employeeId` wasn't known at hook construction.\n *\n * @public\n */\nexport interface JobSubmitOptions {\n /** Override the `employeeId` configured at hook construction. Useful when the employee is created in the same submit chain. */\n employeeId?: string\n /**\n * Supply `hireDate` at submit time rather than via a rendered field. Use\n * with `withHireDateField: false` for screens that derive hireDate from\n * external context (e.g. the employee's `startDate` during onboarding).\n * Falls back to the loaded job's `hireDate` on update mode when omitted;\n * required (or sourced from a default) on create mode.\n */\n hireDate?: string\n}\n\n/**\n * Configuration options for {@link useJobForm}.\n *\n * @remarks\n * Presence or absence of `jobId` selects the API verb — see the `jobId` field\n * description. `employeeId` is optional so the hook can be composed alongside\n * an employee-creation step; supply it at submit time via\n * {@link JobSubmitOptions.employeeId} in that case.\n *\n * @public\n */\nexport interface UseJobFormProps {\n /** UUID of the employee whose job is being created or edited. May be omitted when the employee is created in the same submit chain — supply the value via {@link JobSubmitOptions.employeeId} at submit time. */\n employeeId?: string\n /** Present → update mode (PUT /v1/jobs/:id with `version`). Omitted → create mode (POST /v1/employees/:id/jobs). */\n jobId?: string\n /** Override fields that are optional on a given mode to be required. See {@link JobOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: JobOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update mode. */\n defaultValues?: Partial<JobFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.HireDate` (becomes `undefined`) and removes\n * `hireDate` from schema validation. Supply the value via\n * {@link JobSubmitOptions.hireDate} at submit time, or rely on the loaded\n * job's existing value on update. Use this when the date is driven by\n * external context rather than user input (e.g. the employee's `startDate`).\n * Defaults to `true`.\n */\n withHireDateField?: boolean\n /**\n * When `false`, hides `Fields.Title` (becomes `undefined`), removes\n * `title` from schema validation, and skips sending `title` on PUT/POST.\n * Use this when another form owns the title field — e.g. compensation\n * edit surfaces render the title via `CompFields.Title` because title\n * lives on compensation in the API (`job.title` is just a denormalized\n * snapshot of the primary comp's title). Defaults to `true` so the\n * standalone job-creation flow still gathers a title for the create\n * body.\n */\n withTitleField?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useJobForm().form.Fields`.\n *\n * @remarks\n * Each property is either the field component or `undefined`. A field is\n * `undefined` when conditions for rendering it aren't met — see each member\n * for its visibility rule. Always null-check conditional fields (e.g.\n * `{Fields.TwoPercentShareholder && <Fields.TwoPercentShareholder ... />}`)\n * before rendering.\n *\n * @public\n */\nexport interface JobFormFields {\n /** Bound to `title`. Job title text input. `undefined` when `withTitleField: false`. */\n Title: ComponentType<JobTitleFieldProps> | undefined\n /** Bound to `hireDate`. Hire date picker. `undefined` when `withHireDateField: false`. */\n HireDate: ComponentType<HireDateFieldProps> | undefined\n /** Bound to `twoPercentShareholder`. S-Corp 2% shareholder checkbox. `undefined` when the company is not taxable as an S-Corp (see `data.showTwoPercentShareholder`). */\n TwoPercentShareholder: ComponentType<TwoPercentShareholderFieldProps> | undefined\n /** Bound to `stateWcCovered`. Washington state workers' compensation coverage radio group. `undefined` when the active work address is not in Washington (see `data.showStateWc`). */\n StateWcCovered: ComponentType<StateWcCoveredFieldProps> | undefined\n /** Bound to `stateWcClassCode`. Washington state workers' compensation risk class code select. `undefined` when the active work address is not in Washington or when `stateWcCovered` is `false`. */\n StateWcClassCode: ComponentType<StateWcClassCodeFieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link useJobForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends\n * {@link BaseFormHookReady} with the job-specific `data`, `status`,\n * `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UseJobFormReady extends BaseFormHookReady<\n JobFieldsMetadata,\n JobFormData,\n JobFormFields\n> {\n /** Job-specific data payload: the loaded job (if any), the employee's other jobs, the employee record, the active work address, and presentation flags for conditional fields. */\n data: {\n /** The job row loaded for update; `null` in create mode. */\n currentJob: Job | null\n /** All jobs for the employee, when employeeId is set. Useful for screen-level cross-checks across jobs. */\n jobs: Job[] | undefined\n /** The loaded employee record, or `null` when `employeeId` was omitted. */\n employee: Employee | null\n /** The employee's active work address, or `null` when none is set. */\n currentWorkAddress: EmployeeWorkAddress | null\n /** True when the company is taxable as an S-Corp; use this to decide whether to render `TwoPercentShareholder`. */\n showTwoPercentShareholder: boolean\n /**\n * True when the active work-address state is WA; use this to decide whether to render\n * `StateWcCovered`. `Fields.StateWcClassCode` is additionally gated on `stateWcCovered === true`,\n * so most callers only need to check `Fields.StateWcCovered` / `Fields.StateWcClassCode`\n * truthiness rather than this flag directly.\n */\n showStateWc: boolean\n }\n /** Submission state. `isPending` is `true` while any in-flight mutation (including the secondary-compensation correction block) hasn't settled. `mode` reflects whether the next submit will create or update. */\n status: { isPending: boolean; mode: 'create' | 'update' }\n /** Submit actions exposed by the hook. */\n actions: {\n /** Validates the form, runs the appropriate create/update mutation, and resolves to a {@link HookSubmitResult} containing the saved job. Resolves to `undefined` on validation failure or mutation error. */\n onSubmit: (options?: JobSubmitOptions) => Promise<HookSubmitResult<Job> | undefined>\n }\n}\n\nfunction findJob(jobs: Job[] | undefined, jobId: string | undefined): Job | null {\n if (!jobs || !jobId) return null\n return jobs.find(j => j.uuid === jobId) ?? null\n}\n\n/** @internal */\nfunction buildJobFieldsMetadata(\n base: Record<keyof JobFormData, FieldMetadata>,\n {\n showTwoPercentShareholder,\n showStateWc,\n }: { showTwoPercentShareholder: boolean; showStateWc: boolean },\n) {\n return {\n title: base.title,\n hireDate: base.hireDate,\n twoPercentShareholder: withFlags(base.twoPercentShareholder, {\n isDisabled: !showTwoPercentShareholder,\n }),\n stateWcCovered: withOptions<boolean>(\n withFlags(base.stateWcCovered, { isDisabled: !showStateWc }),\n [\n { label: 'Yes', value: 'true' },\n { label: 'No', value: 'false' },\n ],\n [true, false],\n ),\n stateWcClassCode: withOptions<WARiskClassCode>(\n withFlags(base.stateWcClassCode, { isDisabled: !showStateWc }),\n WA_RISK_CLASS_CODES.map(({ code, description }) => ({\n value: code,\n label: `${code}: ${description}`,\n })),\n WA_RISK_CLASS_CODES,\n ),\n } satisfies FieldsMetadata\n}\n\n/**\n * Headless hook for creating or updating an employee's job — title, hire date, S-Corp 2% shareholder flag, and Washington state workers' compensation fields.\n *\n * @remarks\n * Companion hook to `useCompensationForm`. Jobs and their compensations are\n * separate entities in the Gusto API and this hook focuses exclusively on\n * the job side. Presence of `jobId` selects the verb:\n *\n * | Hook config | Mode | API call |\n * | ----------- | ---- | -------- |\n * | `{ employeeId, jobId }` | update | `PUT /v1/jobs/:jobId` (with `version`) |\n * | `{ employeeId }` (no `jobId`) | create | `POST /v1/employees/:employeeId/jobs` |\n * | `{}` + submit `employeeId` | create | `POST /v1/employees/:options.employeeId/jobs` |\n *\n * Creating a job auto-creates a stub compensation. To update the stub in the\n * same flow, capture `currentCompensationUuid` (and the compensation's\n * `version` from `compensations[]`) from the create response and thread them\n * into `useCompensationForm.actions.onSubmit({ jobId, compensationId, compensationVersion })`.\n *\n * When the primary job's `hireDate` changes, secondary compensation effective\n * dates are corrected after the PUT; `isPending` stays `true` through that.\n *\n * @param input - {@link UseJobFormProps} — `employeeId`, `jobId` (toggle create/update), and configuration for required-field overrides, default values, and which fields the hook renders.\n * @returns A {@link HookLoadingResult} while data is loading, or a {@link UseJobFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useJobForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function JobForm({ employeeId }: { employeeId: string }) {\n * const job = useJobForm({ employeeId })\n * if (job.isLoading) return null\n *\n * const { Fields } = job.form\n * return (\n * <form onSubmit={e => { e.preventDefault(); job.actions.onSubmit() }}>\n * <SDKFormProvider formHookResult={job}>\n * {Fields.Title && <Fields.Title label=\"Job title\" />}\n * {Fields.HireDate && <Fields.HireDate label=\"Hire date\" />}\n * {Fields.TwoPercentShareholder && (\n * <Fields.TwoPercentShareholder label=\"2% S-Corp shareholder\" />\n * )}\n * </SDKFormProvider>\n * <button type=\"submit\" disabled={job.status.isPending}>Save</button>\n * </form>\n * )\n * }\n * ```\n */\nexport function useJobForm({\n employeeId,\n jobId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withHireDateField = true,\n withTitleField = true,\n}: UseJobFormProps): HookLoadingResult | UseJobFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active) ?? null\n const employee = employeeQuery.data?.employee ?? null\n const companyUuid = employee?.companyUuid\n\n const taxQuery = useFederalTaxDetailsGet(\n { companyId: companyUuid ?? '' },\n { enabled: !!companyUuid },\n )\n const federalTaxDetails = taxQuery.data?.federalTaxDetails\n const showTwoPercentShareholder = federalTaxDetails?.taxableAsScorp === true\n const showStateWc = currentWorkAddress?.state === 'WA'\n\n const currentJob = useMemo(() => findJob(employeeJobs, jobId), [employeeJobs, jobId])\n const isCreateMode = !jobId\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createJobSchema({ mode, optionalFieldsToRequire, withHireDateField, withTitleField }),\n [mode, optionalFieldsToRequire, withHireDateField, withTitleField],\n )\n\n const resolvedDefaults: JobFormData = useMemo(\n () => ({\n title: currentJob?.title ?? partnerDefaults?.title ?? '',\n hireDate: currentJob?.hireDate ?? partnerDefaults?.hireDate ?? null,\n twoPercentShareholder:\n currentJob?.twoPercentShareholder ?? partnerDefaults?.twoPercentShareholder ?? false,\n stateWcCovered: currentJob?.stateWcCovered ?? partnerDefaults?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? partnerDefaults?.stateWcClassCode ?? '',\n }),\n [currentJob, partnerDefaults],\n )\n\n const formMethods = useForm<JobFormData, unknown, JobFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedStateWcCovered = useWatch({ control: formMethods.control, name: 'stateWcCovered' })\n\n const createJobMutation = useJobsAndCompensationsCreateJobMutation()\n const updateJobMutation = useJobsAndCompensationsUpdateMutation()\n const updateSecondaryCompMutation = useJobsAndCompensationsUpdateCompensationMutation()\n // Tracks the post-primary-PUT corrective block (jobs refetch + parallel\n // secondary comp PUTs). No single mutation hook reports `isPending` for the\n // whole window — the refetch isn't a mutation, and `Promise.all` over one\n // mutation hook makes its `isPending` track the latest-settled call — so we\n // OR this in to keep the spinner solid through it.\n const [isCorrectingSecondaries, setIsCorrectingSecondaries] = useState(false)\n const isPending =\n createJobMutation.isPending ||\n updateJobMutation.isPending ||\n updateSecondaryCompMutation.isPending ||\n isCorrectingSecondaries\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('JobForm')\n\n const queriesForErrors = employeeId ? [jobsQuery, addressesQuery, employeeQuery, taxQuery] : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildJobFieldsMetadata(baseMetadata, {\n showTwoPercentShareholder,\n showStateWc,\n })\n\n const onSubmit = async (\n options?: JobSubmitOptions,\n ): Promise<HookSubmitResult<Job> | undefined> => {\n let submitResult: HookSubmitResult<Job> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: JobFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedEmployeeId = options?.employeeId ?? employeeId\n if (!resolvedEmployeeId) {\n throw new SDKInternalError('employeeId is required to submit a job')\n }\n\n const stateWcClassCode = payload.stateWcCovered ? payload.stateWcClassCode : null\n\n // Mirror the work/home address pattern: when the field is rendered\n // the payload value wins; when it isn't, fall back to a submit-time\n // override (`options.hireDate`), then to the loaded job's existing\n // value on update mode. Create mode requires a resolved value —\n // hireDate is mandatory on POST /v1/employees/:id/jobs.\n const resolvedHireDate =\n withHireDateField && payload.hireDate\n ? payload.hireDate\n : (options?.hireDate ?? currentJob?.hireDate ?? null)\n\n // When the title field is suppressed (steady-state edits drive\n // title through useCompensationForm), omit it from the body so\n // the server preserves the existing value rather than clobbering\n // it with whatever sat in form state.\n const titleToSend = withTitleField ? payload.title : undefined\n\n // When a primary job's hire_date is PUT and the value actually\n // changes, the API unconditionally overwrites every secondary's\n // current-compensation effective_date to match the new hire_date.\n // That's already the outcome we want for a secondary whose\n // effective_date was before the new hire_date, so there's nothing\n // to correct there. It's only wrong for a secondary whose\n // effective_date was already on or after the new hire_date — the\n // API clobbers that one too, erasing a deliberately future-dated\n // comp. Read those originals now so we can restore them below; by\n // the time we re-fetch they'll be gone.\n const shouldCorrectSecondaries =\n !isCreateMode &&\n currentJob?.primary === true &&\n !!resolvedHireDate &&\n resolvedHireDate !== currentJob.hireDate\n const secondariesNeedingRestore = shouldCorrectSecondaries\n ? (employeeJobs ?? [])\n .filter(j => !j.primary && j.currentCompensationUuid)\n .map(j => ({\n compId: j.currentCompensationUuid!,\n effectiveDate: j.compensations?.find(c => c.uuid === j.currentCompensationUuid)\n ?.effectiveDate,\n }))\n .filter(\n (entry): entry is { compId: string; effectiveDate: string } =>\n !!entry.effectiveDate && entry.effectiveDate > resolvedHireDate,\n )\n : []\n\n let updatedJob: Job\n\n if (isCreateMode) {\n if (!resolvedHireDate) {\n throw new SDKInternalError(\n withHireDateField\n ? 'hireDate is required to create a job'\n : 'hireDate is required to create a job. Pass it via JobSubmitOptions when withHireDateField is false.',\n )\n }\n if (titleToSend === undefined) {\n throw new SDKInternalError(\n 'title is required to create a job. Set withTitleField: true (the default) on useJobForm for create flows.',\n )\n }\n const result = await createJobMutation.mutateAsync({\n request: {\n employeeId: resolvedEmployeeId,\n jobsCreateRequestBody: {\n title: titleToSend,\n hireDate: resolvedHireDate,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job creation failed')\n }\n updatedJob = result.job\n } else {\n if (!currentJob) {\n throw new SDKInternalError('Cannot update job: no matching job on file')\n }\n const result = await updateJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n jobsUpdateRequestBody: {\n version: currentJob.version as string,\n title: titleToSend,\n hireDate: resolvedHireDate ?? undefined,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job update failed')\n }\n updatedJob = result.job\n\n // The primary PUT above clobbered every secondary's\n // current-compensation effective_date to the new hire_date,\n // including the ones that needed to stay where they were.\n // Refetch jobs for the bumped versions, then restore just those\n // secondaries in parallel — the requests are independent\n // (different compensation_id, separate versions), and\n // `Promise.all` still surfaces the first rejection through the\n // surrounding baseSubmitHandler's catch.\n if (secondariesNeedingRestore.length > 0) {\n setIsCorrectingSecondaries(true)\n try {\n const refreshed = await jobsQuery.refetch()\n const freshComps = (refreshed.data?.jobs ?? []).flatMap(\n j => j.compensations ?? [],\n )\n await Promise.all(\n secondariesNeedingRestore.flatMap(entry => {\n const freshComp = freshComps.find(c => c.uuid === entry.compId)\n if (!freshComp?.version) return []\n\n return [\n updateSecondaryCompMutation.mutateAsync({\n request: {\n compensationId: entry.compId,\n compensationsUpdateRequestBody: {\n version: freshComp.version,\n effectiveDate: entry.effectiveDate,\n },\n },\n }),\n ]\n }),\n )\n } finally {\n setIsCorrectingSecondaries(false)\n }\n }\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updatedJob,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading || addressesQuery.isLoading || employeeQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n currentJob,\n jobs: employeeJobs,\n employee,\n currentWorkAddress,\n showTwoPercentShareholder,\n showStateWc,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: withTitleField ? JobTitleField : undefined,\n HireDate: withHireDateField ? HireDateField : undefined,\n TwoPercentShareholder: showTwoPercentShareholder ? TwoPercentShareholderField : undefined,\n StateWcCovered: showStateWc ? StateWcCoveredField : undefined,\n StateWcClassCode: showStateWc && watchedStateWcCovered ? StateWcClassCodeField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link useJobForm}.\n *\n * @remarks\n * Branch on `isLoading` to narrow to either {@link HookLoadingResult} or\n * {@link UseJobFormReady}.\n *\n * @public\n */\nexport type UseJobFormResult = HookLoadingResult | UseJobFormReady\n\n/**\n * Shape of the per-field metadata exposed at `useJobForm().form.fieldsMetadata`.\n *\n * @remarks\n * Maps each field name in {@link JobFormData} to its presentation metadata —\n * including the registered `name`, whether the field is required or disabled,\n * and (for select-like fields) the option list.\n *\n * @public\n */\nexport type JobFieldsMetadata = ReturnType<typeof buildJobFieldsMetadata>\n"],"names":["findJob","jobs","jobId","j","buildJobFieldsMetadata","base","showTwoPercentShareholder","showStateWc","withFlags","withOptions","WA_RISK_CLASS_CODES","code","description","useJobForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withHireDateField","withTitleField","jobsQuery","useJobsAndCompensationsGetJobs","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","employee","companyUuid","taxQuery","useFederalTaxDetailsGet","currentJob","useMemo","isCreateMode","mode","schema","metadataConfig","createJobSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedStateWcCovered","useWatch","createJobMutation","useJobsAndCompensationsCreateJobMutation","updateJobMutation","useJobsAndCompensationsUpdateMutation","updateSecondaryCompMutation","useJobsAndCompensationsUpdateCompensationMutation","isCorrectingSecondaries","setIsCorrectingSecondaries","useState","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","options","submitResult","resolve","data","payload","resolvedEmployeeId","SDKInternalError","stateWcClassCode","resolvedHireDate","titleToSend","secondariesNeedingRestore","c","entry","updatedJob","result","freshComps","freshComp","isDataLoading","hookFormInternals","useHookFormInternals","JobTitleField","HireDateField","TwoPercentShareholderField","StateWcCoveredField","StateWcClassCodeField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+LA,SAASA,GAAQC,GAAyBC,GAAuC;AAC/E,SAAI,CAACD,KAAQ,CAACC,IAAc,OACrBD,EAAK,KAAK,CAAAE,MAAKA,EAAE,SAASD,CAAK,KAAK;AAC7C;AAGA,SAASE,GACPC,GACA;AAAA,EACE,2BAAAC;AAAA,EACA,aAAAC;AACF,GACA;AACA,SAAO;AAAA,IACL,OAAOF,EAAK;AAAA,IACZ,UAAUA,EAAK;AAAA,IACf,uBAAuBG,EAAUH,EAAK,uBAAuB;AAAA,MAC3D,YAAY,CAACC;AAAA,IAAA,CACd;AAAA,IACD,gBAAgBG;AAAA,MACdD,EAAUH,EAAK,gBAAgB,EAAE,YAAY,CAACE,GAAa;AAAA,MAC3D;AAAA,QACE,EAAE,OAAO,OAAO,OAAO,OAAA;AAAA,QACvB,EAAE,OAAO,MAAM,OAAO,QAAA;AAAA,MAAQ;AAAA,MAEhC,CAAC,IAAM,EAAK;AAAA,IAAA;AAAA,IAEd,kBAAkBE;AAAA,MAChBD,EAAUH,EAAK,kBAAkB,EAAE,YAAY,CAACE,GAAa;AAAA,MAC7DG,EAAoB,IAAI,CAAC,EAAE,MAAAC,GAAM,aAAAC,SAAmB;AAAA,QAClD,OAAOD;AAAA,QACP,OAAO,GAAGA,CAAI,KAAKC,CAAW;AAAA,MAAA,EAC9B;AAAA,MACFF;AAAA,IAAA;AAAA,EACF;AAEJ;AAoDO,SAASG,GAAW;AAAA,EACzB,YAAAC;AAAA,EACA,OAAAZ;AAAA,EACA,yBAAAa;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AAAA,EACnB,mBAAAC,IAAoB;AAA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EACT,GAEMgB,KAAgBtE,IAClBO,EAAU,aAAaE,EAAe,aAAaE,EAAc,YACjE,IAEE4D,KAAoBC,GAAqB5C,CAAW;AAE1D,SAAI0C,MAAkBtE,MAAe,CAACa,KAAgB,CAACG,KAC9C,EAAE,WAAW,IAAe,eAAA+B,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,YAAA3B;AAAA,MACA,MAAMP;AAAA,MACN,UAAAG;AAAA,MACA,oBAAAF;AAAA,MACA,2BAAAtB;AAAA,MACA,aAAAC;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAiD;AAAA,MACA,MAAMpB,IAAe,WAAW;AAAA,IAAA;AAAA,IAElC,SAAS,EAAE,UAAA8B,GAAA;AAAA,IACX,eAAAL;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAOzC,IAAiBmE,KAAgB;AAAA,QACxC,UAAUpE,IAAoBqE,KAAgB;AAAA,QAC9C,uBAAuBlF,IAA4BmF,KAA6B;AAAA,QAChF,gBAAgBlF,IAAcmF,KAAsB;AAAA,QACpD,kBAAkBnF,KAAesC,IAAwB8C,KAAwB;AAAA,MAAA;AAAA,MAEnF,gBAAA1B;AAAA,MACA,mBAAAoB;AAAA,MACA,yBAAyBO,GAA8BlD,GAAaJ,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useJobForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useJobForm/useJobForm.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { useMemo, useState } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useFederalTaxDetailsGet } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport {\n createJobSchema,\n type JobOptionalFieldsToRequire,\n type JobFormData,\n type JobFormOutputs,\n} from './jobSchema'\nimport {\n JobTitleField,\n HireDateField,\n TwoPercentShareholderField,\n StateWcCoveredField,\n StateWcClassCodeField,\n} from './fields'\nimport type {\n JobTitleFieldProps,\n HireDateFieldProps,\n TwoPercentShareholderFieldProps,\n StateWcCoveredFieldProps,\n StateWcClassCodeFieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { withFlags } from '@/partner-hook-utils/form/withFlags'\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 { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { WA_RISK_CLASS_CODES, type WARiskClassCode } from '@/models/WA_RISK_CODES'\n\n/**\n * Optional values supplied to {@link useJobForm}'s `actions.onSubmit` at submit time.\n *\n * @remarks\n * Use these when a value isn't sourced from a rendered field — typically\n * because the hook was configured with `withHireDateField: false`, or because\n * the employee being saved was created in the same submit chain and the\n * `employeeId` wasn't known at hook construction.\n *\n * @public\n */\nexport interface JobSubmitOptions {\n /** Override the `employeeId` configured at hook construction. Useful when the employee is created in the same submit chain. */\n employeeId?: string\n /**\n * Supply `hireDate` at submit time rather than via a rendered field. Use\n * with `withHireDateField: false` for screens that derive hireDate from\n * external context (e.g. the employee's `startDate` during onboarding).\n * Falls back to the loaded job's `hireDate` on update mode when omitted;\n * required (or sourced from a default) on create mode.\n */\n hireDate?: string\n}\n\n/**\n * Configuration options for {@link useJobForm}.\n *\n * @remarks\n * Presence or absence of `jobId` selects the API verb — see the `jobId` field\n * description. `employeeId` is optional so the hook can be composed alongside\n * an employee-creation step; supply it at submit time via\n * {@link JobSubmitOptions.employeeId} in that case.\n *\n * @public\n */\nexport interface UseJobFormProps {\n /** UUID of the employee whose job is being created or edited. May be omitted when the employee is created in the same submit chain — supply the value via {@link JobSubmitOptions.employeeId} at submit time. */\n employeeId?: string\n /** Present → update mode (PUT /v1/jobs/:id with `version`). Omitted → create mode (POST /v1/employees/:id/jobs). */\n jobId?: string\n /** Override fields that are optional on a given mode to be required. See {@link JobOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: JobOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update mode. */\n defaultValues?: Partial<JobFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.HireDate` (becomes `undefined`) and removes\n * `hireDate` from schema validation. Supply the value via\n * {@link JobSubmitOptions.hireDate} at submit time, or rely on the loaded\n * job's existing value on update. Use this when the date is driven by\n * external context rather than user input (e.g. the employee's `startDate`).\n * Defaults to `true`.\n */\n withHireDateField?: boolean\n /**\n * When `false`, hides `Fields.Title` (becomes `undefined`), removes\n * `title` from schema validation, and skips sending `title` on PUT/POST.\n * Use this when another form owns the title field — e.g. compensation\n * edit surfaces render the title via `CompFields.Title` because title\n * lives on compensation in the API (`job.title` is just a denormalized\n * snapshot of the primary comp's title). Defaults to `true` so the\n * standalone job-creation flow still gathers a title for the create\n * body.\n */\n withTitleField?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useJobForm().form.Fields`.\n *\n * @remarks\n * Each property is either the field component or `undefined`. A field is\n * `undefined` when conditions for rendering it aren't met — see each member\n * for its visibility rule. Always null-check conditional fields (e.g.\n * `{Fields.TwoPercentShareholder && <Fields.TwoPercentShareholder ... />}`)\n * before rendering.\n *\n * @public\n */\nexport interface JobFormFields {\n /** Bound to `title`. Job title text input. `undefined` when `withTitleField: false`. */\n Title: ComponentType<JobTitleFieldProps> | undefined\n /** Bound to `hireDate`. Hire date picker. `undefined` when `withHireDateField: false`. */\n HireDate: ComponentType<HireDateFieldProps> | undefined\n /** Bound to `twoPercentShareholder`. S-Corp 2% shareholder checkbox. `undefined` when the company is not taxable as an S-Corp (see `data.showTwoPercentShareholder`). */\n TwoPercentShareholder: ComponentType<TwoPercentShareholderFieldProps> | undefined\n /** Bound to `stateWcCovered`. Washington state workers' compensation coverage radio group. `undefined` when the active work address is not in Washington (see `data.showStateWc`). */\n StateWcCovered: ComponentType<StateWcCoveredFieldProps> | undefined\n /** Bound to `stateWcClassCode`. Washington state workers' compensation risk class code select. `undefined` when the active work address is not in Washington or when `stateWcCovered` is `false`. */\n StateWcClassCode: ComponentType<StateWcClassCodeFieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link useJobForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends\n * {@link BaseFormHookReady} with the job-specific `data`, `status`,\n * `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UseJobFormReady extends BaseFormHookReady<\n JobFieldsMetadata,\n JobFormData,\n JobFormFields\n> {\n /** Job-specific data payload: the loaded job (if any), the employee's other jobs, the employee record, the active work address, and presentation flags for conditional fields. */\n data: {\n /** The job row loaded for update; `null` in create mode. */\n currentJob: Job | null\n /** All jobs for the employee, when employeeId is set. Useful for screen-level cross-checks across jobs. */\n jobs: Job[] | undefined\n /** The loaded employee record, or `null` when `employeeId` was omitted. */\n employee: Employee | null\n /** The employee's active work address, or `null` when none is set. */\n currentWorkAddress: EmployeeWorkAddress | null\n /** True when the company is taxable as an S-Corp; use this to decide whether to render `TwoPercentShareholder`. */\n showTwoPercentShareholder: boolean\n /**\n * True when the active work-address state is WA; use this to decide whether to render\n * `StateWcCovered`. `Fields.StateWcClassCode` is additionally gated on `stateWcCovered === true`,\n * so most callers only need to check `Fields.StateWcCovered` / `Fields.StateWcClassCode`\n * truthiness rather than this flag directly.\n */\n showStateWc: boolean\n }\n /** Submission state. `isPending` is `true` while any in-flight mutation (including the secondary-compensation correction block) hasn't settled. `mode` reflects whether the next submit will create or update. */\n status: { isPending: boolean; mode: 'create' | 'update' }\n /** Submit actions exposed by the hook. */\n actions: {\n /** Validates the form, runs the appropriate create/update mutation, and resolves to a {@link HookSubmitResult} containing the saved job. Resolves to `undefined` on validation failure or mutation error. */\n onSubmit: (options?: JobSubmitOptions) => Promise<HookSubmitResult<Job> | undefined>\n }\n}\n\nfunction findJob(jobs: Job[] | undefined, jobId: string | undefined): Job | null {\n if (!jobs || !jobId) return null\n return jobs.find(j => j.uuid === jobId) ?? null\n}\n\n/** @internal */\nfunction buildJobFieldsMetadata(\n base: Record<keyof JobFormData, FieldMetadata>,\n {\n showTwoPercentShareholder,\n showStateWc,\n }: { showTwoPercentShareholder: boolean; showStateWc: boolean },\n) {\n return {\n title: base.title,\n hireDate: base.hireDate,\n twoPercentShareholder: withFlags(base.twoPercentShareholder, {\n isDisabled: !showTwoPercentShareholder,\n }),\n stateWcCovered: withOptions<boolean>(\n withFlags(base.stateWcCovered, { isDisabled: !showStateWc }),\n [\n { label: 'Yes', value: 'true' },\n { label: 'No', value: 'false' },\n ],\n [true, false],\n ),\n stateWcClassCode: withOptions<WARiskClassCode>(\n withFlags(base.stateWcClassCode, { isDisabled: !showStateWc }),\n WA_RISK_CLASS_CODES.map(({ code, description }) => ({\n value: code,\n label: `${code}: ${description}`,\n })),\n WA_RISK_CLASS_CODES,\n ),\n } satisfies FieldsMetadata\n}\n\n/**\n * Headless hook for creating or updating an employee's job — title, hire date, S-Corp 2% shareholder flag, and Washington state workers' compensation fields.\n *\n * @remarks\n * Companion hook to `useCompensationForm`. Jobs and their compensations are\n * separate entities in the Gusto API and this hook focuses exclusively on\n * the job side. Presence of `jobId` selects the verb:\n *\n * | Hook config | Mode | API call |\n * | ----------- | ---- | -------- |\n * | `{ employeeId, jobId }` | update | `PUT /v1/jobs/:jobId` (with `version`) |\n * | `{ employeeId }` (no `jobId`) | create | `POST /v1/employees/:employeeId/jobs` |\n * | `{}` + submit `employeeId` | create | `POST /v1/employees/:options.employeeId/jobs` |\n *\n * Creating a job auto-creates a stub compensation. To update the stub in the\n * same flow, capture `currentCompensationUuid` (and the compensation's\n * `version` from `compensations[]`) from the create response and thread them\n * into `useCompensationForm.actions.onSubmit({ jobId, compensationId, compensationVersion })`.\n *\n * When the primary job's `hireDate` changes, secondary compensation effective\n * dates are corrected after the PUT; `isPending` stays `true` through that.\n *\n * @param input - {@link UseJobFormProps} — `employeeId`, `jobId` (toggle create/update), and configuration for required-field overrides, default values, and which fields the hook renders.\n * @returns A {@link HookLoadingResult} while data is loading, or a {@link UseJobFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useJobForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function JobForm({ employeeId }: { employeeId: string }) {\n * const job = useJobForm({ employeeId })\n * if (job.isLoading) return null\n *\n * const { Fields } = job.form\n * return (\n * <form onSubmit={e => { e.preventDefault(); job.actions.onSubmit() }}>\n * <SDKFormProvider formHookResult={job}>\n * {Fields.Title && <Fields.Title label=\"Job title\" />}\n * {Fields.HireDate && <Fields.HireDate label=\"Hire date\" />}\n * {Fields.TwoPercentShareholder && (\n * <Fields.TwoPercentShareholder label=\"2% S-Corp shareholder\" />\n * )}\n * </SDKFormProvider>\n * <button type=\"submit\" disabled={job.status.isPending}>Save</button>\n * </form>\n * )\n * }\n * ```\n */\nexport function useJobForm({\n employeeId,\n jobId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withHireDateField = true,\n withTitleField = true,\n}: UseJobFormProps): HookLoadingResult | UseJobFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active) ?? null\n const employee = employeeQuery.data?.employeeShow ?? null\n const companyUuid = employee?.companyUuid\n\n const taxQuery = useFederalTaxDetailsGet(\n { companyId: companyUuid ?? '' },\n { enabled: !!companyUuid },\n )\n const federalTaxDetails = taxQuery.data?.federalTaxDetails\n const showTwoPercentShareholder = federalTaxDetails?.taxableAsScorp === true\n const showStateWc = currentWorkAddress?.state === 'WA'\n\n const currentJob = useMemo(() => findJob(employeeJobs, jobId), [employeeJobs, jobId])\n const isCreateMode = !jobId\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createJobSchema({ mode, optionalFieldsToRequire, withHireDateField, withTitleField }),\n [mode, optionalFieldsToRequire, withHireDateField, withTitleField],\n )\n\n const resolvedDefaults: JobFormData = useMemo(\n () => ({\n title: currentJob?.title ?? partnerDefaults?.title ?? '',\n hireDate: currentJob?.hireDate ?? partnerDefaults?.hireDate ?? null,\n twoPercentShareholder:\n currentJob?.twoPercentShareholder ?? partnerDefaults?.twoPercentShareholder ?? false,\n stateWcCovered: currentJob?.stateWcCovered ?? partnerDefaults?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? partnerDefaults?.stateWcClassCode ?? '',\n }),\n [currentJob, partnerDefaults],\n )\n\n const formMethods = useForm<JobFormData, unknown, JobFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedStateWcCovered = useWatch({ control: formMethods.control, name: 'stateWcCovered' })\n\n const createJobMutation = useJobsAndCompensationsCreateJobMutation()\n const updateJobMutation = useJobsAndCompensationsUpdateMutation()\n const updateSecondaryCompMutation = useJobsAndCompensationsUpdateCompensationMutation()\n // Tracks the post-primary-PUT corrective block (jobs refetch + parallel\n // secondary comp PUTs). No single mutation hook reports `isPending` for the\n // whole window — the refetch isn't a mutation, and `Promise.all` over one\n // mutation hook makes its `isPending` track the latest-settled call — so we\n // OR this in to keep the spinner solid through it.\n const [isCorrectingSecondaries, setIsCorrectingSecondaries] = useState(false)\n const isPending =\n createJobMutation.isPending ||\n updateJobMutation.isPending ||\n updateSecondaryCompMutation.isPending ||\n isCorrectingSecondaries\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('JobForm')\n\n const queriesForErrors = employeeId ? [jobsQuery, addressesQuery, employeeQuery, taxQuery] : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildJobFieldsMetadata(baseMetadata, {\n showTwoPercentShareholder,\n showStateWc,\n })\n\n const onSubmit = async (\n options?: JobSubmitOptions,\n ): Promise<HookSubmitResult<Job> | undefined> => {\n let submitResult: HookSubmitResult<Job> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: JobFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedEmployeeId = options?.employeeId ?? employeeId\n if (!resolvedEmployeeId) {\n throw new SDKInternalError('employeeId is required to submit a job')\n }\n\n const stateWcClassCode = payload.stateWcCovered ? payload.stateWcClassCode : null\n\n // Mirror the work/home address pattern: when the field is rendered\n // the payload value wins; when it isn't, fall back to a submit-time\n // override (`options.hireDate`), then to the loaded job's existing\n // value on update mode. Create mode requires a resolved value —\n // hireDate is mandatory on POST /v1/employees/:id/jobs.\n const resolvedHireDate =\n withHireDateField && payload.hireDate\n ? payload.hireDate\n : (options?.hireDate ?? currentJob?.hireDate ?? null)\n\n // When the title field is suppressed (steady-state edits drive\n // title through useCompensationForm), omit it from the body so\n // the server preserves the existing value rather than clobbering\n // it with whatever sat in form state.\n const titleToSend = withTitleField ? payload.title : undefined\n\n // When a primary job's hire_date is PUT and the value actually\n // changes, the API unconditionally overwrites every secondary's\n // current-compensation effective_date to match the new hire_date.\n // That's already the outcome we want for a secondary whose\n // effective_date was before the new hire_date, so there's nothing\n // to correct there. It's only wrong for a secondary whose\n // effective_date was already on or after the new hire_date — the\n // API clobbers that one too, erasing a deliberately future-dated\n // comp. Read those originals now so we can restore them below; by\n // the time we re-fetch they'll be gone.\n const shouldCorrectSecondaries =\n !isCreateMode &&\n currentJob?.primary === true &&\n !!resolvedHireDate &&\n resolvedHireDate !== currentJob.hireDate\n const secondariesNeedingRestore = shouldCorrectSecondaries\n ? (employeeJobs ?? [])\n .filter(j => !j.primary && j.currentCompensationUuid)\n .map(j => ({\n compId: j.currentCompensationUuid!,\n effectiveDate: j.compensations?.find(c => c.uuid === j.currentCompensationUuid)\n ?.effectiveDate,\n }))\n .filter(\n (entry): entry is { compId: string; effectiveDate: string } =>\n !!entry.effectiveDate && entry.effectiveDate > resolvedHireDate,\n )\n : []\n\n let updatedJob: Job\n\n if (isCreateMode) {\n if (!resolvedHireDate) {\n throw new SDKInternalError(\n withHireDateField\n ? 'hireDate is required to create a job'\n : 'hireDate is required to create a job. Pass it via JobSubmitOptions when withHireDateField is false.',\n )\n }\n if (titleToSend === undefined) {\n throw new SDKInternalError(\n 'title is required to create a job. Set withTitleField: true (the default) on useJobForm for create flows.',\n )\n }\n const result = await createJobMutation.mutateAsync({\n request: {\n employeeId: resolvedEmployeeId,\n jobsCreateRequestBody: {\n title: titleToSend,\n hireDate: resolvedHireDate,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job creation failed')\n }\n updatedJob = result.job\n } else {\n if (!currentJob) {\n throw new SDKInternalError('Cannot update job: no matching job on file')\n }\n const result = await updateJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n jobsUpdateRequestBody: {\n version: currentJob.version as string,\n title: titleToSend,\n hireDate: resolvedHireDate ?? undefined,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job update failed')\n }\n updatedJob = result.job\n\n // The primary PUT above clobbered every secondary's\n // current-compensation effective_date to the new hire_date,\n // including the ones that needed to stay where they were.\n // Refetch jobs for the bumped versions, then restore just those\n // secondaries in parallel — the requests are independent\n // (different compensation_id, separate versions), and\n // `Promise.all` still surfaces the first rejection through the\n // surrounding baseSubmitHandler's catch.\n if (secondariesNeedingRestore.length > 0) {\n setIsCorrectingSecondaries(true)\n try {\n const refreshed = await jobsQuery.refetch()\n const freshComps = (refreshed.data?.jobs ?? []).flatMap(\n j => j.compensations ?? [],\n )\n await Promise.all(\n secondariesNeedingRestore.flatMap(entry => {\n const freshComp = freshComps.find(c => c.uuid === entry.compId)\n if (!freshComp?.version) return []\n\n return [\n updateSecondaryCompMutation.mutateAsync({\n request: {\n compensationId: entry.compId,\n compensationsUpdateRequestBody: {\n version: freshComp.version,\n effectiveDate: entry.effectiveDate,\n },\n },\n }),\n ]\n }),\n )\n } finally {\n setIsCorrectingSecondaries(false)\n }\n }\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updatedJob,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading || addressesQuery.isLoading || employeeQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n currentJob,\n jobs: employeeJobs,\n employee,\n currentWorkAddress,\n showTwoPercentShareholder,\n showStateWc,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: withTitleField ? JobTitleField : undefined,\n HireDate: withHireDateField ? HireDateField : undefined,\n TwoPercentShareholder: showTwoPercentShareholder ? TwoPercentShareholderField : undefined,\n StateWcCovered: showStateWc ? StateWcCoveredField : undefined,\n StateWcClassCode: showStateWc && watchedStateWcCovered ? StateWcClassCodeField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link useJobForm}.\n *\n * @remarks\n * Branch on `isLoading` to narrow to either {@link HookLoadingResult} or\n * {@link UseJobFormReady}.\n *\n * @public\n */\nexport type UseJobFormResult = HookLoadingResult | UseJobFormReady\n\n/**\n * Shape of the per-field metadata exposed at `useJobForm().form.fieldsMetadata`.\n *\n * @remarks\n * Maps each field name in {@link JobFormData} to its presentation metadata —\n * including the registered `name`, whether the field is required or disabled,\n * and (for select-like fields) the option list.\n *\n * @public\n */\nexport type JobFieldsMetadata = ReturnType<typeof buildJobFieldsMetadata>\n"],"names":["findJob","jobs","jobId","j","buildJobFieldsMetadata","base","showTwoPercentShareholder","showStateWc","withFlags","withOptions","WA_RISK_CLASS_CODES","code","description","useJobForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withHireDateField","withTitleField","jobsQuery","useJobsAndCompensationsGetJobs","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","employee","companyUuid","taxQuery","useFederalTaxDetailsGet","currentJob","useMemo","isCreateMode","mode","schema","metadataConfig","createJobSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedStateWcCovered","useWatch","createJobMutation","useJobsAndCompensationsCreateJobMutation","updateJobMutation","useJobsAndCompensationsUpdateMutation","updateSecondaryCompMutation","useJobsAndCompensationsUpdateCompensationMutation","isCorrectingSecondaries","setIsCorrectingSecondaries","useState","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","options","submitResult","resolve","data","payload","resolvedEmployeeId","SDKInternalError","stateWcClassCode","resolvedHireDate","titleToSend","secondariesNeedingRestore","c","entry","updatedJob","result","freshComps","freshComp","isDataLoading","hookFormInternals","useHookFormInternals","JobTitleField","HireDateField","TwoPercentShareholderField","StateWcCoveredField","StateWcClassCodeField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+LA,SAASA,GAAQC,GAAyBC,GAAuC;AAC/E,SAAI,CAACD,KAAQ,CAACC,IAAc,OACrBD,EAAK,KAAK,CAAAE,MAAKA,EAAE,SAASD,CAAK,KAAK;AAC7C;AAGA,SAASE,GACPC,GACA;AAAA,EACE,2BAAAC;AAAA,EACA,aAAAC;AACF,GACA;AACA,SAAO;AAAA,IACL,OAAOF,EAAK;AAAA,IACZ,UAAUA,EAAK;AAAA,IACf,uBAAuBG,EAAUH,EAAK,uBAAuB;AAAA,MAC3D,YAAY,CAACC;AAAA,IAAA,CACd;AAAA,IACD,gBAAgBG;AAAA,MACdD,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C,UAAUpE,IAAoBqE,KAAgB;AAAA,QAC9C,uBAAuBlF,IAA4BmF,KAA6B;AAAA,QAChF,gBAAgBlF,IAAcmF,KAAsB;AAAA,QACpD,kBAAkBnF,KAAesC,IAAwB8C,KAAwB;AAAA,MAAA;AAAA,MAEnF,gBAAA1B;AAAA,MACA,mBAAAoB;AAAA,MACA,yBAAyBO,GAA8BlD,GAAaJ,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -7,20 +7,20 @@ import { JobAndPayView as C } from "./JobAndPayView.js";
|
|
|
7
7
|
import { TaxesViewWithData as E } from "./TaxesView.js";
|
|
8
8
|
import { Flex as l } from "../../Common/Flex/Flex.js";
|
|
9
9
|
import { useComponentContext as b } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
|
-
import { BaseBoundaries as
|
|
11
|
-
import { useI18n as
|
|
12
|
-
import { componentEvents as
|
|
13
|
-
import { firstLastName as
|
|
10
|
+
import { BaseBoundaries as S } from "../../Base/Base.js";
|
|
11
|
+
import { useI18n as j, useComponentDictionary as B } from "../../../i18n/I18n.js";
|
|
12
|
+
import { componentEvents as N } from "../../../shared/constants.js";
|
|
13
|
+
import { firstLastName as P } from "../../../helpers/formattedStrings.js";
|
|
14
14
|
import { DocumentsCard as _ } from "../Documents/management/DocumentsCard/DocumentsCard.js";
|
|
15
|
-
function
|
|
16
|
-
employeeId:
|
|
17
|
-
dictionary:
|
|
15
|
+
function w({
|
|
16
|
+
employeeId: o,
|
|
17
|
+
dictionary: a,
|
|
18
18
|
onEvent: t,
|
|
19
19
|
selectedTab: r,
|
|
20
20
|
LoaderComponent: p,
|
|
21
21
|
className: d
|
|
22
22
|
}) {
|
|
23
|
-
|
|
23
|
+
j("Employee.Dashboard"), B("Employee.Dashboard", a);
|
|
24
24
|
const { t: n } = c("Employee.Dashboard"), u = b(), [f, D] = y("basicDetails"), s = r ?? f, h = [
|
|
25
25
|
{
|
|
26
26
|
id: "basicDetails",
|
|
@@ -44,7 +44,7 @@ function H({
|
|
|
44
44
|
}
|
|
45
45
|
];
|
|
46
46
|
return /* @__PURE__ */ i(l, { className: d, flexDirection: "column", gap: 32, children: [
|
|
47
|
-
/* @__PURE__ */ e(T, { fallback: null, children: /* @__PURE__ */ e(
|
|
47
|
+
/* @__PURE__ */ e(T, { fallback: null, children: /* @__PURE__ */ e(H, { employeeId: o }) }),
|
|
48
48
|
/* @__PURE__ */ i(l, { flexDirection: "column", gap: 8, children: [
|
|
49
49
|
/* @__PURE__ */ e(
|
|
50
50
|
u.Tabs,
|
|
@@ -53,19 +53,19 @@ function H({
|
|
|
53
53
|
selectedId: s,
|
|
54
54
|
onSelectionChange: (x) => {
|
|
55
55
|
const m = x;
|
|
56
|
-
D(m), t(
|
|
56
|
+
D(m), t(N.EMPLOYEE_DASHBOARD_TAB_CHANGE, { tab: m });
|
|
57
57
|
},
|
|
58
58
|
"aria-label": n("tabsLabel")
|
|
59
59
|
}
|
|
60
60
|
),
|
|
61
61
|
/* @__PURE__ */ i(l, { flexDirection: "column", gap: 24, children: [
|
|
62
|
-
s === "basicDetails" && /* @__PURE__ */ e(g, { employeeId:
|
|
63
|
-
s === "jobAndPay" && /* @__PURE__ */ e(C, { employeeId:
|
|
64
|
-
s === "taxes" && /* @__PURE__ */ e(E, { employeeId:
|
|
62
|
+
s === "basicDetails" && /* @__PURE__ */ e(g, { employeeId: o, onEvent: t }),
|
|
63
|
+
s === "jobAndPay" && /* @__PURE__ */ e(C, { employeeId: o, onEvent: t }),
|
|
64
|
+
s === "taxes" && /* @__PURE__ */ e(E, { employeeId: o, onEvent: t }),
|
|
65
65
|
s === "documents" && /* @__PURE__ */ e(
|
|
66
66
|
_,
|
|
67
67
|
{
|
|
68
|
-
employeeId:
|
|
68
|
+
employeeId: o,
|
|
69
69
|
onEvent: t,
|
|
70
70
|
LoaderComponent: p
|
|
71
71
|
}
|
|
@@ -74,23 +74,23 @@ function H({
|
|
|
74
74
|
] })
|
|
75
75
|
] });
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
const { t:
|
|
79
|
-
data: {
|
|
80
|
-
} = A({ employeeId:
|
|
77
|
+
function H({ employeeId: o }) {
|
|
78
|
+
const { t: a } = c("Employee.Dashboard"), t = b(), {
|
|
79
|
+
data: { employeeShow: r }
|
|
80
|
+
} = A({ employeeId: o });
|
|
81
81
|
return /* @__PURE__ */ i(l, { flexDirection: "column", gap: 4, children: [
|
|
82
|
-
/* @__PURE__ */ e(t.Heading, { as: "h2", children:
|
|
83
|
-
/* @__PURE__ */ e(t.Text, { variant: "supporting", children:
|
|
82
|
+
/* @__PURE__ */ e(t.Heading, { as: "h2", children: P({ first_name: r?.firstName, last_name: r?.lastName }) }),
|
|
83
|
+
/* @__PURE__ */ e(t.Text, { variant: "supporting", children: a("employeeRoleLabel") })
|
|
84
84
|
] });
|
|
85
85
|
}
|
|
86
|
-
function Q({ FallbackComponent:
|
|
86
|
+
function Q({ FallbackComponent: o, LoaderComponent: a, ...t }) {
|
|
87
87
|
return /* @__PURE__ */ e(
|
|
88
|
-
|
|
88
|
+
S,
|
|
89
89
|
{
|
|
90
90
|
componentName: "Employee.Dashboard",
|
|
91
|
-
FallbackComponent:
|
|
92
|
-
LoaderComponent:
|
|
93
|
-
children: /* @__PURE__ */ e(
|
|
91
|
+
FallbackComponent: o,
|
|
92
|
+
LoaderComponent: a,
|
|
93
|
+
children: /* @__PURE__ */ e(w, { ...t, LoaderComponent: a })
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.js","sources":["../../../../src/components/Employee/Dashboard/Dashboard.tsx"],"sourcesContent":["import { Suspense, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { BasicDetailsView } from './BasicDetailsView'\nimport { JobAndPayView } from './JobAndPayView'\nimport { TaxesViewWithData } from './TaxesView'\nimport { DocumentsCard } from '@/components/Employee/Documents/management/DocumentsCard'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { BaseBoundaries, type BaseComponentInterface } from '@/components/Base/Base'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\n/** @public */\nexport type DashboardTab = 'basicDetails' | 'jobAndPay' | 'taxes' | 'documents'\n\n/** @public */\nexport interface DashboardProps extends BaseComponentInterface<'Employee.Dashboard'> {\n /** The associated employee identifier. */\n employeeId: string\n /** The currently active tab. Defaults to `'basicDetails'` when uncontrolled. */\n selectedTab?: DashboardTab\n}\n\nfunction DashboardRoot({\n employeeId,\n dictionary,\n onEvent,\n selectedTab: controlledTab,\n LoaderComponent,\n className,\n}: DashboardProps) {\n useI18n('Employee.Dashboard')\n useComponentDictionary('Employee.Dashboard', dictionary)\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const [internalTab, setInternalTab] = useState<DashboardTab>('basicDetails')\n const selectedTab = controlledTab ?? internalTab\n\n const tabs = [\n {\n id: 'basicDetails' as const,\n label: t('tabs.basicDetails'),\n content: null,\n },\n {\n id: 'jobAndPay' as const,\n label: t('tabs.jobAndPay'),\n content: null,\n },\n {\n id: 'taxes' as const,\n label: t('tabs.taxes'),\n content: null,\n },\n {\n id: 'documents' as const,\n label: t('tabs.documents'),\n content: null,\n },\n ]\n\n return (\n <Flex className={className} flexDirection=\"column\" gap={32}>\n <Suspense fallback={null}>\n <DashboardHeader employeeId={employeeId} />\n </Suspense>\n\n <Flex flexDirection=\"column\" gap={8}>\n <Components.Tabs\n tabs={tabs}\n selectedId={selectedTab}\n onSelectionChange={id => {\n const next = id as DashboardTab\n setInternalTab(next)\n onEvent(componentEvents.EMPLOYEE_DASHBOARD_TAB_CHANGE, { tab: next })\n }}\n aria-label={t('tabsLabel')}\n />\n\n <Flex flexDirection=\"column\" gap={24}>\n {selectedTab === 'basicDetails' && (\n <BasicDetailsView employeeId={employeeId} onEvent={onEvent} />\n )}\n\n {selectedTab === 'jobAndPay' && (\n <JobAndPayView employeeId={employeeId} onEvent={onEvent} />\n )}\n\n {selectedTab === 'taxes' && (\n <TaxesViewWithData employeeId={employeeId} onEvent={onEvent} />\n )}\n\n {selectedTab === 'documents' && (\n <DocumentsCard\n employeeId={employeeId}\n onEvent={onEvent}\n LoaderComponent={LoaderComponent}\n />\n )}\n </Flex>\n </Flex>\n </Flex>\n )\n}\n\nfunction DashboardHeader({ employeeId }: { employeeId: string }) {\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n return (\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">\n {firstLastName({ first_name: employee?.firstName, last_name: employee?.lastName })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">{t('employeeRoleLabel')}</Components.Text>\n </Flex>\n )\n}\n\n/**\n * Employee self-service dashboard summarizing a single employee's basic details, job and pay, taxes, and documents.\n *\n * @remarks\n * Renders a tabbed overview of the employee, wrapped in the SDK's standard error and suspense\n * boundaries. The active tab may be controlled via `selectedTab` or left uncontrolled, in which\n * case it defaults to basic details. Each tab composes the read-only section cards listed below.\n *\n * @components\n * - {@link ProfileCard}\n * - {@link HomeAddressCard}\n * - {@link WorkAddressCard}\n * - {@link CompensationCard}\n * - {@link PaymentMethodCard}\n * - {@link DeductionsCard}\n * - {@link PaystubsCard}\n * - {@link FederalTaxesCard}\n * - {@link StateTaxesCard}\n * - {@link DocumentsCard}\n *\n * @param props - Component props. See {@link DashboardProps}.\n * @returns A React element rendering the employee dashboard.\n * @public\n */\nexport function Dashboard({ FallbackComponent, LoaderComponent, ...props }: DashboardProps) {\n return (\n <BaseBoundaries\n componentName=\"Employee.Dashboard\"\n FallbackComponent={FallbackComponent}\n LoaderComponent={LoaderComponent}\n >\n <DashboardRoot {...props} LoaderComponent={LoaderComponent} />\n </BaseBoundaries>\n )\n}\n"],"names":["DashboardRoot","employeeId","dictionary","onEvent","controlledTab","LoaderComponent","className","useI18n","useComponentDictionary","t","useTranslation","Components","useComponentContext","internalTab","setInternalTab","useState","selectedTab","tabs","Flex","jsx","Suspense","DashboardHeader","jsxs","id","next","componentEvents","BasicDetailsView","JobAndPayView","TaxesViewWithData","DocumentsCard","employee","useEmployeesGetSuspense","firstLastName","Dashboard","FallbackComponent","props","BaseBoundaries"],"mappings":";;;;;;;;;;;;;;AAyBA,SAASA,EAAc;AAAA,EACrB,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAaC;AAAA,EACb,iBAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,EAAAC,EAAQ,oBAAoB,GAC5BC,EAAuB,sBAAsBN,CAAU;AACvD,QAAM,EAAE,GAAAO,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GACb,CAACC,GAAaC,CAAc,IAAIC,EAAuB,cAAc,GACrEC,IAAcZ,KAAiBS,GAE/BI,IAAO;AAAA,IACX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOR,EAAE,mBAAmB;AAAA,MAC5B,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOA,EAAE,gBAAgB;AAAA,MACzB,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOA,EAAE,YAAY;AAAA,MACrB,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOA,EAAE,gBAAgB;AAAA,MACzB,SAAS;AAAA,IAAA;AAAA,EACX;AAGF,2BACGS,GAAA,EAAK,WAAAZ,GAAsB,eAAc,UAAS,KAAK,IACtD,UAAA;AAAA,IAAA,gBAAAa,EAACC,KAAS,UAAU,MAClB,UAAA,gBAAAD,EAACE,GAAA,EAAgB,YAAApB,GAAwB,GAC3C;AAAA,IAEA,gBAAAqB,EAACJ,GAAA,EAAK,eAAc,UAAS,KAAK,GAChC,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAACR,EAAW;AAAA,QAAX;AAAA,UACC,MAAAM;AAAA,UACA,YAAYD;AAAA,UACZ,mBAAmB,CAAAO,MAAM;AACvB,kBAAMC,IAAOD;AACb,YAAAT,EAAeU,CAAI,GACnBrB,EAAQsB,EAAgB,+BAA+B,EAAE,KAAKD,GAAM;AAAA,UACtE;AAAA,UACA,cAAYf,EAAE,WAAW;AAAA,QAAA;AAAA,MAAA;AAAA,MAG3B,gBAAAa,EAACJ,GAAA,EAAK,eAAc,UAAS,KAAK,IAC/B,UAAA;AAAA,QAAAF,MAAgB,kBACf,gBAAAG,EAACO,GAAA,EAAiB,YAAAzB,GAAwB,SAAAE,GAAkB;AAAA,QAG7Da,MAAgB,eACf,gBAAAG,EAACQ,GAAA,EAAc,YAAA1B,GAAwB,SAAAE,GAAkB;AAAA,QAG1Da,MAAgB,WACf,gBAAAG,EAACS,GAAA,EAAkB,YAAA3B,GAAwB,SAAAE,GAAkB;AAAA,QAG9Da,MAAgB,eACf,gBAAAG;AAAA,UAACU;AAAA,UAAA;AAAA,YACC,YAAA5B;AAAA,YACA,SAAAE;AAAA,YACA,iBAAAE;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CAEJ;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;AAEA,SAASgB,EAAgB,EAAE,YAAApB,KAAsC;AAC/D,QAAM,EAAE,GAAAQ,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GACb;AAAA,IACJ,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"Dashboard.js","sources":["../../../../src/components/Employee/Dashboard/Dashboard.tsx"],"sourcesContent":["import { Suspense, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { BasicDetailsView } from './BasicDetailsView'\nimport { JobAndPayView } from './JobAndPayView'\nimport { TaxesViewWithData } from './TaxesView'\nimport { DocumentsCard } from '@/components/Employee/Documents/management/DocumentsCard'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { BaseBoundaries, type BaseComponentInterface } from '@/components/Base/Base'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\n/** @public */\nexport type DashboardTab = 'basicDetails' | 'jobAndPay' | 'taxes' | 'documents'\n\n/** @public */\nexport interface DashboardProps extends BaseComponentInterface<'Employee.Dashboard'> {\n /** The associated employee identifier. */\n employeeId: string\n /** The currently active tab. Defaults to `'basicDetails'` when uncontrolled. */\n selectedTab?: DashboardTab\n}\n\nfunction DashboardRoot({\n employeeId,\n dictionary,\n onEvent,\n selectedTab: controlledTab,\n LoaderComponent,\n className,\n}: DashboardProps) {\n useI18n('Employee.Dashboard')\n useComponentDictionary('Employee.Dashboard', dictionary)\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const [internalTab, setInternalTab] = useState<DashboardTab>('basicDetails')\n const selectedTab = controlledTab ?? internalTab\n\n const tabs = [\n {\n id: 'basicDetails' as const,\n label: t('tabs.basicDetails'),\n content: null,\n },\n {\n id: 'jobAndPay' as const,\n label: t('tabs.jobAndPay'),\n content: null,\n },\n {\n id: 'taxes' as const,\n label: t('tabs.taxes'),\n content: null,\n },\n {\n id: 'documents' as const,\n label: t('tabs.documents'),\n content: null,\n },\n ]\n\n return (\n <Flex className={className} flexDirection=\"column\" gap={32}>\n <Suspense fallback={null}>\n <DashboardHeader employeeId={employeeId} />\n </Suspense>\n\n <Flex flexDirection=\"column\" gap={8}>\n <Components.Tabs\n tabs={tabs}\n selectedId={selectedTab}\n onSelectionChange={id => {\n const next = id as DashboardTab\n setInternalTab(next)\n onEvent(componentEvents.EMPLOYEE_DASHBOARD_TAB_CHANGE, { tab: next })\n }}\n aria-label={t('tabsLabel')}\n />\n\n <Flex flexDirection=\"column\" gap={24}>\n {selectedTab === 'basicDetails' && (\n <BasicDetailsView employeeId={employeeId} onEvent={onEvent} />\n )}\n\n {selectedTab === 'jobAndPay' && (\n <JobAndPayView employeeId={employeeId} onEvent={onEvent} />\n )}\n\n {selectedTab === 'taxes' && (\n <TaxesViewWithData employeeId={employeeId} onEvent={onEvent} />\n )}\n\n {selectedTab === 'documents' && (\n <DocumentsCard\n employeeId={employeeId}\n onEvent={onEvent}\n LoaderComponent={LoaderComponent}\n />\n )}\n </Flex>\n </Flex>\n </Flex>\n )\n}\n\nfunction DashboardHeader({ employeeId }: { employeeId: string }) {\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const {\n data: { employeeShow: employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n return (\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">\n {firstLastName({ first_name: employee?.firstName, last_name: employee?.lastName })}\n </Components.Heading>\n <Components.Text variant=\"supporting\">{t('employeeRoleLabel')}</Components.Text>\n </Flex>\n )\n}\n\n/**\n * Employee self-service dashboard summarizing a single employee's basic details, job and pay, taxes, and documents.\n *\n * @remarks\n * Renders a tabbed overview of the employee, wrapped in the SDK's standard error and suspense\n * boundaries. The active tab may be controlled via `selectedTab` or left uncontrolled, in which\n * case it defaults to basic details. Each tab composes the read-only section cards listed below.\n *\n * @components\n * - {@link ProfileCard}\n * - {@link HomeAddressCard}\n * - {@link WorkAddressCard}\n * - {@link CompensationCard}\n * - {@link PaymentMethodCard}\n * - {@link DeductionsCard}\n * - {@link PaystubsCard}\n * - {@link FederalTaxesCard}\n * - {@link StateTaxesCard}\n * - {@link DocumentsCard}\n *\n * @param props - Component props. See {@link DashboardProps}.\n * @returns A React element rendering the employee dashboard.\n * @public\n */\nexport function Dashboard({ FallbackComponent, LoaderComponent, ...props }: DashboardProps) {\n return (\n <BaseBoundaries\n componentName=\"Employee.Dashboard\"\n FallbackComponent={FallbackComponent}\n LoaderComponent={LoaderComponent}\n >\n <DashboardRoot {...props} LoaderComponent={LoaderComponent} />\n </BaseBoundaries>\n )\n}\n"],"names":["DashboardRoot","employeeId","dictionary","onEvent","controlledTab","LoaderComponent","className","useI18n","useComponentDictionary","t","useTranslation","Components","useComponentContext","internalTab","setInternalTab","useState","selectedTab","tabs","Flex","jsx","Suspense","DashboardHeader","jsxs","id","next","componentEvents","BasicDetailsView","JobAndPayView","TaxesViewWithData","DocumentsCard","employee","useEmployeesGetSuspense","firstLastName","Dashboard","FallbackComponent","props","BaseBoundaries"],"mappings":";;;;;;;;;;;;;;AAyBA,SAASA,EAAc;AAAA,EACrB,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAaC;AAAA,EACb,iBAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,EAAAC,EAAQ,oBAAoB,GAC5BC,EAAuB,sBAAsBN,CAAU;AACvD,QAAM,EAAE,GAAAO,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GACb,CAACC,GAAaC,CAAc,IAAIC,EAAuB,cAAc,GACrEC,IAAcZ,KAAiBS,GAE/BI,IAAO;AAAA,IACX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOR,EAAE,mBAAmB;AAAA,MAC5B,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOA,EAAE,gBAAgB;AAAA,MACzB,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOA,EAAE,YAAY;AAAA,MACrB,SAAS;AAAA,IAAA;AAAA,IAEX;AAAA,MACE,IAAI;AAAA,MACJ,OAAOA,EAAE,gBAAgB;AAAA,MACzB,SAAS;AAAA,IAAA;AAAA,EACX;AAGF,2BACGS,GAAA,EAAK,WAAAZ,GAAsB,eAAc,UAAS,K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AAqB,EAACJ,GAAA,EAAK,eAAc,UAAS,KAAK,GAChC,UAAA;AAAA,IAAA,gBAAAC,EAACR,EAAW,SAAX,EAAmB,IAAG,MACpB,UAAAqB,EAAc,EAAE,YAAYF,GAAU,WAAW,WAAWA,GAAU,SAAA,CAAU,GACnF;AAAA,IACA,gBAAAX,EAACR,EAAW,MAAX,EAAgB,SAAQ,cAAc,UAAAF,EAAE,mBAAmB,EAAA,CAAE;AAAA,EAAA,GAChE;AAEJ;AA0BO,SAASwB,EAAU,EAAE,mBAAAC,GAAmB,iBAAA7B,GAAiB,GAAG8B,KAAyB;AAC1F,SACE,gBAAAhB;AAAA,IAACiB;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,mBAAAF;AAAA,MACA,iBAAA7B;AAAA,MAEA,UAAA,gBAAAc,EAACnB,GAAA,EAAe,GAAGmC,GAAO,iBAAA9B,EAAA,CAAkC;AAAA,IAAA;AAAA,EAAA;AAGlE;"}
|
|
@@ -3,9 +3,9 @@ import { createMachine as f } from "robot3";
|
|
|
3
3
|
import { useMemo as l } from "react";
|
|
4
4
|
import { useEmployeesGetSuspense as g } from "@gusto/embedded-api/react-query/employeesGet";
|
|
5
5
|
import { useEmployeeFormsListSuspense as D } from "@gusto/embedded-api/react-query/employeeFormsList";
|
|
6
|
-
import { EmploymentEligibilityContextual as
|
|
7
|
-
import { documentSignerMachine as
|
|
8
|
-
import { Flow as
|
|
6
|
+
import { EmploymentEligibilityContextual as S, DocumentListContextual as d } from "./documentSignerStateMachine.js";
|
|
7
|
+
import { documentSignerMachine as y } from "./stateMachine.js";
|
|
8
|
+
import { Flow as E } from "../../../../Flow/Flow.js";
|
|
9
9
|
import { BaseComponent as x } from "../../../../Base/Base.js";
|
|
10
10
|
import "../../../../Base/useBase.js";
|
|
11
11
|
import { useComponentDictionary as C } from "../../../../../i18n/I18n.js";
|
|
@@ -15,20 +15,20 @@ function O(o) {
|
|
|
15
15
|
}
|
|
16
16
|
function M({ employeeId: o, onEvent: i, dictionary: s, withEmployeeI9: t = !1 }) {
|
|
17
17
|
C("Employee.DocumentSigner", s);
|
|
18
|
-
const { data: a } = g({ employeeId: o }), { data: c } = D({ employeeId: o }), u = a.
|
|
18
|
+
const { data: a } = g({ employeeId: o }), { data: c } = D({ employeeId: o }), u = a.employeeShow?.onboardingDocumentsConfig?.i9Document === !0, m = c.forms?.find((e) => e.name === F), r = t && u && (!m || m.requiresSigning === !0), p = l(
|
|
19
19
|
() => f(
|
|
20
20
|
r ? "employmentEligibility" : "index",
|
|
21
|
-
|
|
21
|
+
y,
|
|
22
22
|
(e) => ({
|
|
23
23
|
...e,
|
|
24
|
-
component: r ?
|
|
24
|
+
component: r ? S : d,
|
|
25
25
|
employeeId: o,
|
|
26
26
|
withEmployeeI9: t
|
|
27
27
|
})
|
|
28
28
|
),
|
|
29
29
|
[o, t]
|
|
30
30
|
);
|
|
31
|
-
return /* @__PURE__ */ n(
|
|
31
|
+
return /* @__PURE__ */ n(E, { machine: p, onEvent: i });
|
|
32
32
|
}
|
|
33
33
|
export {
|
|
34
34
|
O as DocumentSigner
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentSigner.js","sources":["../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeeFormsListSuspense } from '@gusto/embedded-api/react-query/employeeFormsList'\nimport {\n DocumentListContextual,\n EmploymentEligibilityContextual,\n type DocumentSignerContextInterface,\n} from './documentSignerStateMachine'\nimport { documentSignerMachine } from './stateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { I9_FORM_NAME } from '@/shared/constants'\n\n/**\n * Props for {@link DocumentSigner}.\n *\n * @public\n */\nexport interface DocumentSignerProps extends BaseComponentInterface<'Employee.DocumentSigner'> {\n /** The associated employee identifier. */\n employeeId: string\n /** When `true`, the flow routes through I-9 employment eligibility before listing documents for signing. Defaults to `false`. */\n withEmployeeI9?: boolean\n}\n\n/**\n * Onboarding step for signing employee documents.\n *\n * @remarks\n * Lists the employee's pending forms and routes through the signing UI for each\n * one. When `withEmployeeI9` is `true` and the employee's I-9 has not been\n * signed, the flow starts on the I-9 employment eligibility step before\n * presenting the document list.\n *\n * Each form's description is rendered as returned by the API, unless the `dictionary` prop\n * supplies a `forms.<name>.description` override for that form's `name` (e.g.\n * `forms.employee_direct_deposit.description`).\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/employmentEligibility/done` | Fired after I-9 employment eligibility is captured | The updated I-9 authorization |\n * | `employee/forms/view` | Fired when a form's \"Sign\" action is selected from the document list | `{ uuid: string; name?: string }` |\n * | `employee/forms/sign` | Fired after a form is successfully signed | {@link APIModels.Form} |\n * | `employee/employmentEligibility/change` | Fired when the user requests to change their I-9 eligibility status | — |\n * | `employee/forms/done` | Fired when all required forms have been signed and the parent flow can advance | — |\n * | `cancel` | Fired when the user cancels signing a form and returns to the document list | — |\n *\n * @components\n * - {@link EmploymentEligibility}\n * - {@link I9SignatureForm}\n * - {@link DocumentList}\n * - {@link SignatureForm}\n *\n * @param props - See {@link DocumentSignerProps}.\n * @returns The document signer flow.\n * @public\n */\nexport function DocumentSigner(props: DocumentSignerProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, onEvent, dictionary, withEmployeeI9 = false }: DocumentSignerProps) {\n useComponentDictionary('Employee.DocumentSigner', dictionary)\n\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: formsData } = useEmployeeFormsListSuspense({ employeeId })\n\n const employeeHasI9Enabled
|
|
1
|
+
{"version":3,"file":"DocumentSigner.js","sources":["../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeeFormsListSuspense } from '@gusto/embedded-api/react-query/employeeFormsList'\nimport {\n DocumentListContextual,\n EmploymentEligibilityContextual,\n type DocumentSignerContextInterface,\n} from './documentSignerStateMachine'\nimport { documentSignerMachine } from './stateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { I9_FORM_NAME } from '@/shared/constants'\n\n/**\n * Props for {@link DocumentSigner}.\n *\n * @public\n */\nexport interface DocumentSignerProps extends BaseComponentInterface<'Employee.DocumentSigner'> {\n /** The associated employee identifier. */\n employeeId: string\n /** When `true`, the flow routes through I-9 employment eligibility before listing documents for signing. Defaults to `false`. */\n withEmployeeI9?: boolean\n}\n\n/**\n * Onboarding step for signing employee documents.\n *\n * @remarks\n * Lists the employee's pending forms and routes through the signing UI for each\n * one. When `withEmployeeI9` is `true` and the employee's I-9 has not been\n * signed, the flow starts on the I-9 employment eligibility step before\n * presenting the document list.\n *\n * Each form's description is rendered as returned by the API, unless the `dictionary` prop\n * supplies a `forms.<name>.description` override for that form's `name` (e.g.\n * `forms.employee_direct_deposit.description`).\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/employmentEligibility/done` | Fired after I-9 employment eligibility is captured | The updated I-9 authorization |\n * | `employee/forms/view` | Fired when a form's \"Sign\" action is selected from the document list | `{ uuid: string; name?: string }` |\n * | `employee/forms/sign` | Fired after a form is successfully signed | {@link APIModels.Form} |\n * | `employee/employmentEligibility/change` | Fired when the user requests to change their I-9 eligibility status | — |\n * | `employee/forms/done` | Fired when all required forms have been signed and the parent flow can advance | — |\n * | `cancel` | Fired when the user cancels signing a form and returns to the document list | — |\n *\n * @components\n * - {@link EmploymentEligibility}\n * - {@link I9SignatureForm}\n * - {@link DocumentList}\n * - {@link SignatureForm}\n *\n * @param props - See {@link DocumentSignerProps}.\n * @returns The document signer flow.\n * @public\n */\nexport function DocumentSigner(props: DocumentSignerProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, onEvent, dictionary, withEmployeeI9 = false }: DocumentSignerProps) {\n useComponentDictionary('Employee.DocumentSigner', dictionary)\n\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: formsData } = useEmployeeFormsListSuspense({ employeeId })\n\n const employeeHasI9Enabled =\n employeeData.employeeShow?.onboardingDocumentsConfig?.i9Document === true\n\n const i9Form = formsData.forms?.find(form => form.name === I9_FORM_NAME)\n const needsI9Form =\n withEmployeeI9 && employeeHasI9Enabled && (!i9Form || i9Form.requiresSigning === true)\n\n const machine = useMemo(\n () =>\n createMachine(\n needsI9Form ? 'employmentEligibility' : 'index',\n documentSignerMachine,\n (initialContext: DocumentSignerContextInterface) => ({\n ...initialContext,\n component: needsI9Form ? EmploymentEligibilityContextual : DocumentListContextual,\n employeeId,\n withEmployeeI9,\n }),\n ),\n [employeeId, withEmployeeI9],\n )\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n"],"names":["DocumentSigner","props","jsx","BaseComponent","Root","employeeId","onEvent","dictionary","withEmployeeI9","useComponentDictionary","employeeData","useEmployeesGetSuspense","formsData","useEmployeeFormsListSuspense","employeeHasI9Enabled","i9Form","form","I9_FORM_NAME","needsI9Form","machine","useMemo","createMachine","documentSignerMachine","initialContext","EmploymentEligibilityContextual","DocumentListContextual","Flow"],"mappings":";;;;;;;;;;;;AA4DO,SAASA,EAAeC,GAA4B;AACzD,SACE,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAEA,SAASG,EAAK,EAAE,YAAAC,GAAY,SAAAC,GAAS,YAAAC,GAAY,gBAAAC,IAAiB,MAA8B;AAC9F,EAAAC,EAAuB,2BAA2BF,CAAU;AAE5D,QAAM,EAAE,MAAMG,EAAA,IAAiBC,EAAwB,EAAE,YAAAN,GAAY,GAC/D,EAAE,MAAMO,EAAA,IAAcC,EAA6B,EAAE,YAAAR,GAAY,GAEjES,IACJJ,EAAa,cAAc,2BAA2B,eAAe,IAEjEK,IAASH,EAAU,OAAO,KAAK,CAAAI,MAAQA,EAAK,SAASC,CAAY,GACjEC,IACJV,KAAkBM,MAAyB,CAACC,KAAUA,EAAO,oBAAoB,KAE7EI,IAAUC;AAAA,IACd,MACEC;AAAA,MACEH,IAAc,0BAA0B;AAAA,MACxCI;AAAA,MACA,CAACC,OAAoD;AAAA,QACnD,GAAGA;AAAA,QACH,WAAWL,IAAcM,IAAkCC;AAAA,QAC3D,YAAApB;AAAA,QACA,gBAAAG;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACH,GAAYG,CAAc;AAAA,EAAA;AAG7B,SAAO,gBAAAN,EAACwB,GAAA,EAAK,SAAAP,GAAkB,SAAAb,EAAA,CAAkB;AACnD;"}
|
package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js
CHANGED
|
@@ -14,7 +14,7 @@ function P(o) {
|
|
|
14
14
|
}
|
|
15
15
|
const U = ({ employeeId: o, dictionary: t, className: r }) => {
|
|
16
16
|
N("Employee.EmployeeDocuments", t);
|
|
17
|
-
const { onEvent: s, baseSubmitHandler: u } = b(), { data: a } = y({ employeeId: o }), e = a.
|
|
17
|
+
const { onEvent: s, baseSubmitHandler: u } = b(), { data: a } = y({ employeeId: o }), e = a.employeeShow, c = e?.onboardingDocumentsConfig?.i9Document ?? !1, p = e?.onboardingStatus ? C.has(e.onboardingStatus) || e.onboardingStatus === _.SELF_ONBOARDING_PENDING_INVITE : !1, { mutateAsync: E } = f(), l = d({
|
|
18
18
|
mutationKey: g()
|
|
19
19
|
}) > 0;
|
|
20
20
|
return /* @__PURE__ */ n(
|
package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmployeeDocuments.js","sources":["../../../../../../src/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.tsx"],"sourcesContent":["import { useIsMutating } from '@tanstack/react-query'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n useEmployeesUpdateOnboardingDocumentsConfigMutation,\n mutationKeyEmployeesUpdateOnboardingDocumentsConfig,\n} from '@gusto/embedded-api/react-query/employeesUpdateOnboardingDocumentsConfig'\nimport {\n EmployeeDocumentsPresentation,\n type EmployeeDocumentsFormValues,\n} from './EmployeeDocumentsPresentation'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n'\nimport {\n componentEvents,\n EmployeeSelfOnboardingStatuses,\n EmployeeOnboardingStatus,\n} from '@/shared/constants'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport type { OnboardingContextInterface } from '@/components/Employee/OnboardingFlow/OnboardingFlowComponents'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\n/**\n * Props for {@link EmployeeDocuments}.\n *\n * @public\n */\nexport interface EmployeeDocumentsProps extends BaseComponentInterface<'Employee.EmployeeDocuments'> {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Onboarding step for selecting which documents the employee must complete.\n *\n * @remarks\n * Shows the I-9 toggle when the employee is self-onboarding (so the employee\n * can choose whether their employer will collect I-9 verification) and a\n * summary otherwise. Persists the selection to the employee's onboarding\n * documents configuration and advances the parent flow.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/onboardingDocumentsConfig/updated` | Fired after the employee's documents configuration is saved | The updated documents configuration response |\n * | `employee/documents/done` | Fired when the step is complete and the parent flow can advance | — |\n *\n * @param props - Component props including `employeeId` and `onEvent`.\n * @returns The employee documents onboarding step.\n * @public\n */\nexport function EmployeeDocuments(props: EmployeeDocumentsProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, dictionary, className }: EmployeeDocumentsProps) => {\n useComponentDictionary('Employee.EmployeeDocuments', dictionary)\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = useEmployeesGetSuspense({ employeeId })\n const employee = data.
|
|
1
|
+
{"version":3,"file":"EmployeeDocuments.js","sources":["../../../../../../src/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.tsx"],"sourcesContent":["import { useIsMutating } from '@tanstack/react-query'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n useEmployeesUpdateOnboardingDocumentsConfigMutation,\n mutationKeyEmployeesUpdateOnboardingDocumentsConfig,\n} from '@gusto/embedded-api/react-query/employeesUpdateOnboardingDocumentsConfig'\nimport {\n EmployeeDocumentsPresentation,\n type EmployeeDocumentsFormValues,\n} from './EmployeeDocumentsPresentation'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n'\nimport {\n componentEvents,\n EmployeeSelfOnboardingStatuses,\n EmployeeOnboardingStatus,\n} from '@/shared/constants'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport type { OnboardingContextInterface } from '@/components/Employee/OnboardingFlow/OnboardingFlowComponents'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\n/**\n * Props for {@link EmployeeDocuments}.\n *\n * @public\n */\nexport interface EmployeeDocumentsProps extends BaseComponentInterface<'Employee.EmployeeDocuments'> {\n /** The associated employee identifier. */\n employeeId: string\n}\n\n/**\n * Onboarding step for selecting which documents the employee must complete.\n *\n * @remarks\n * Shows the I-9 toggle when the employee is self-onboarding (so the employee\n * can choose whether their employer will collect I-9 verification) and a\n * summary otherwise. Persists the selection to the employee's onboarding\n * documents configuration and advances the parent flow.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `employee/onboardingDocumentsConfig/updated` | Fired after the employee's documents configuration is saved | The updated documents configuration response |\n * | `employee/documents/done` | Fired when the step is complete and the parent flow can advance | — |\n *\n * @param props - Component props including `employeeId` and `onEvent`.\n * @returns The employee documents onboarding step.\n * @public\n */\nexport function EmployeeDocuments(props: EmployeeDocumentsProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, dictionary, className }: EmployeeDocumentsProps) => {\n useComponentDictionary('Employee.EmployeeDocuments', dictionary)\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = useEmployeesGetSuspense({ employeeId })\n const employee = data.employeeShow\n const currentI9Status = employee?.onboardingDocumentsConfig?.i9Document ?? false\n\n const isEmployeeSelfOnboarding = employee?.onboardingStatus\n ? EmployeeSelfOnboardingStatuses.has(employee.onboardingStatus) ||\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : false\n\n const { mutateAsync: updateOnboardingDocumentsConfig } =\n useEmployeesUpdateOnboardingDocumentsConfigMutation()\n\n const isMutating = useIsMutating({\n mutationKey: mutationKeyEmployeesUpdateOnboardingDocumentsConfig(),\n })\n const isPending = isMutating > 0\n\n const onSubmit = async (formData: EmployeeDocumentsFormValues) => {\n await baseSubmitHandler(formData, async () => {\n const response = await updateOnboardingDocumentsConfig({\n request: {\n employeeId,\n employeeOnboardingDocumentsConfigRequest: {\n i9Document: formData.includeI9,\n },\n },\n })\n\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_DOCUMENTS_CONFIG_UPDATED, response)\n onEvent(componentEvents.EMPLOYEE_DOCUMENTS_DONE)\n })\n }\n\n const handleDone = () => {\n onEvent(componentEvents.EMPLOYEE_DOCUMENTS_DONE)\n }\n\n return (\n <EmployeeDocumentsPresentation\n className={className}\n isEmployeeSelfOnboarding={isEmployeeSelfOnboarding}\n currentI9Status={currentI9Status}\n onSubmit={onSubmit}\n onDone={handleDone}\n isPending={isPending}\n />\n )\n}\n\n/** @internal */\nexport const EmployeeDocumentsContextual = () => {\n const { employeeId, onEvent } = useFlow<OnboardingContextInterface>()\n\n return <EmployeeDocuments employeeId={ensureRequired(employeeId)} onEvent={onEvent} />\n}\n"],"names":["EmployeeDocuments","props","jsx","BaseComponent","Root","employeeId","dictionary","className","useComponentDictionary","onEvent","baseSubmitHandler","useBase","data","useEmployeesGetSuspense","employee","currentI9Status","isEmployeeSelfOnboarding","EmployeeSelfOnboardingStatuses","EmployeeOnboardingStatus","updateOnboardingDocumentsConfig","useEmployeesUpdateOnboardingDocumentsConfigMutation","isPending","useIsMutating","mutationKeyEmployeesUpdateOnboardingDocumentsConfig","EmployeeDocumentsPresentation","formData","response","componentEvents","EmployeeDocumentsContextual","useFlow","ensureRequired"],"mappings":";;;;;;;;;;;AAkDO,SAASA,EAAkBC,GAA+B;AAC/D,SACE,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,YAAAC,GAAY,YAAAC,GAAY,WAAAC,QAAwC;AAC9E,EAAAC,EAAuB,8BAA8BF,CAAU;AAC/D,QAAM,EAAE,SAAAG,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GAEjC,EAAE,MAAAC,EAAA,IAASC,EAAwB,EAAE,YAAAR,GAAY,GACjDS,IAAWF,EAAK,cAChBG,IAAkBD,GAAU,2BAA2B,cAAc,IAErEE,IAA2BF,GAAU,mBACvCG,EAA+B,IAAIH,EAAS,gBAAgB,KAC5DA,EAAS,qBAAqBI,EAAyB,iCACvD,IAEE,EAAE,aAAaC,EAAA,IACnBC,EAAA,GAKIC,IAHaC,EAAc;AAAA,IAC/B,aAAaC,EAAA;AAAA,EAAoD,CAClE,IAC8B;AAsB/B,SACE,gBAAArB;AAAA,IAACsB;AAAA,IAAA;AAAA,MACC,WAAAjB;AAAA,MACA,0BAAAS;AAAA,MACA,iBAAAD;AAAA,MACA,UAzBa,OAAOU,MAA0C;AAChE,cAAMf,EAAkBe,GAAU,YAAY;AAC5C,gBAAMC,IAAW,MAAMP,EAAgC;AAAA,YACrD,SAAS;AAAA,cACP,YAAAd;AAAA,cACA,0CAA0C;AAAA,gBACxC,YAAYoB,EAAS;AAAA,cAAA;AAAA,YACvB;AAAA,UACF,CACD;AAED,UAAAhB,EAAQkB,EAAgB,8CAA8CD,CAAQ,GAC9EjB,EAAQkB,EAAgB,uBAAuB;AAAA,QACjD,CAAC;AAAA,MACH;AAAA,MAYI,QAVe,MAAM;AACvB,QAAAlB,EAAQkB,EAAgB,uBAAuB;AAAA,MACjD;AAAA,MASI,WAAAN;AAAA,IAAA;AAAA,EAAA;AAGN,GAGaO,IAA8B,MAAM;AAC/C,QAAM,EAAE,YAAAvB,GAAY,SAAAI,EAAA,IAAYoB,EAAA;AAEhC,2BAAQ7B,GAAA,EAAkB,YAAY8B,EAAezB,CAAU,GAAG,SAAAI,GAAkB;AACtF;"}
|
|
@@ -29,22 +29,22 @@ function se({
|
|
|
29
29
|
baseSubmitHandler: H,
|
|
30
30
|
error: h,
|
|
31
31
|
setError: L
|
|
32
|
-
} = C("Employee.Management.HomeAddress"), m = _(), [w, D] = N(void 0), f = T({ employeeId: e }, { enabled: !!e }), r = f.data?.employeeAddressList,
|
|
32
|
+
} = C("Employee.Management.HomeAddress"), m = _(), [w, D] = N(void 0), f = T({ employeeId: e }, { enabled: !!e }), r = f.data?.employeeAddressList, S = r?.find((s) => s.active) ?? r?.[0], t = w ?? S?.uuid, F = t ? r?.find((s) => s.uuid === t) : void 0, u = y({
|
|
33
33
|
employeeId: e,
|
|
34
34
|
homeAddressUuid: t,
|
|
35
|
-
initialAddress:
|
|
35
|
+
initialAddress: F,
|
|
36
36
|
withEffectiveDateField: !0
|
|
37
37
|
}), c = y({
|
|
38
38
|
employeeId: e,
|
|
39
39
|
homeAddressUuid: void 0,
|
|
40
40
|
withEffectiveDateField: !0
|
|
41
41
|
}), o = G({ employeeId: e }, { enabled: !!e }), l = U(() => {
|
|
42
|
-
const s = o.data?.
|
|
42
|
+
const s = o.data?.employeeShow;
|
|
43
43
|
return s ? Q({
|
|
44
44
|
first_name: s.firstName,
|
|
45
45
|
last_name: s.lastName
|
|
46
46
|
}).trim() : "";
|
|
47
|
-
}, [o.data?.
|
|
47
|
+
}, [o.data?.employeeShow]), d = O(
|
|
48
48
|
[o, f],
|
|
49
49
|
{ submitError: h, setSubmitError: L }
|
|
50
50
|
), E = {
|
|
@@ -66,7 +66,7 @@ function se({
|
|
|
66
66
|
}
|
|
67
67
|
), A;
|
|
68
68
|
}
|
|
69
|
-
},
|
|
69
|
+
}, M = {
|
|
70
70
|
employeeDisplayName: l,
|
|
71
71
|
employeeHomeAddresses: r,
|
|
72
72
|
editingHomeAddressUuid: t,
|
|
@@ -78,7 +78,7 @@ function se({
|
|
|
78
78
|
if (o.isError)
|
|
79
79
|
return {
|
|
80
80
|
isLoading: !1,
|
|
81
|
-
data:
|
|
81
|
+
data: M,
|
|
82
82
|
status: {
|
|
83
83
|
isDeletePending: m.isPending,
|
|
84
84
|
isEmployeeError: !0
|