@gusto/embedded-react-sdk 0.57.2 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +108 -0
- package/dist/components/Common/DataView/DataCards/DataCards.js +98 -66
- package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +11 -9
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.js +86 -75
- package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
- package/dist/components/Common/DataView/DataView.js.map +1 -1
- package/dist/components/Common/DataView/getSortControls.js +22 -0
- package/dist/components/Common/DataView/getSortControls.js.map +1 -0
- package/dist/components/Common/DataView/useDataView.js +30 -24
- package/dist/components/Common/DataView/useDataView.js.map +1 -1
- 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/Common/UI/Table/Table.js +65 -25
- package/dist/components/Common/UI/Table/Table.js.map +1 -1
- package/dist/components/Common/UI/Table/Table.module.scss.js +8 -4
- package/dist/components/Common/UI/Table/Table.module.scss.js.map +1 -1
- package/dist/components/Common/UI/Table/TableTypes.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +30 -45
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/PayScheduleComponents.js +11 -12
- package/dist/components/Company/PaySchedule/PayScheduleComponents.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/fields.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js +78 -83
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -4
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.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/management/CompensationEditForm.js +45 -54
- package/dist/components/Contractor/Compensation/management/CompensationEditForm.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/contractorPaySchema.js +17 -22
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/contractorPaySchema.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/management/ManagementContractorList.js +1 -0
- package/dist/components/Contractor/ContractorList/management/ManagementContractorList.js.map +1 -1
- package/dist/components/Contractor/ContractorList/management/ManagementContractorListView.js +122 -113
- package/dist/components/Contractor/ContractorList/management/ManagementContractorListView.js.map +1 -1
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js +63 -54
- 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/PaymentMethod/onboarding/PaymentMethod.js +39 -48
- package/dist/components/Contractor/PaymentMethod/onboarding/PaymentMethod.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/ContractorProfile.js +76 -69
- package/dist/components/Contractor/Profile/onboarding/ContractorProfile.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/contractorDetailsSchema.js +27 -29
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +15 -13
- 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/Contractor/shared/hourlyRate.js +14 -0
- package/dist/components/Contractor/shared/hourlyRate.js.map +1 -0
- package/dist/components/Employee/Compensation/management/CompensationCard/CompensationCard.js +63 -63
- package/dist/components/Employee/Compensation/management/CompensationCard/CompensationCard.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/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.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/PaymentMethod/onboarding/ListView.js +65 -74
- package/dist/components/Employee/PaymentMethod/onboarding/ListView.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/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js +16 -16
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +84 -82
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/getDefaultWithholdingPayPeriod.js +8 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/getDefaultWithholdingPayPeriod.js.map +1 -0
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +97 -92
- 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 +18 -18
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +146 -134
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.module.scss.js +14 -12
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.module.scss.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +34 -33
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js +49 -48
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.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/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +0 -4
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js +51 -38
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js +121 -102
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.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/PayrollLanding/PayrollLanding.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js +79 -74
- 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/PayrollOverview.js +92 -83
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js +23 -27
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js +82 -75
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js.map +1 -1
- package/dist/components/Payroll/RropPayrollEditEmployee/RropPayrollEditEmployee.js +416 -0
- package/dist/components/Payroll/RropPayrollEditEmployee/RropPayrollEditEmployee.js.map +1 -0
- package/dist/components/Payroll/{UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.module.scss.js → RropPayrollEditEmployee/RropPayrollEditEmployee.module.scss.js} +1 -1
- package/dist/components/Payroll/RropPayrollEditEmployee/RropPayrollEditEmployee.module.scss.js.map +1 -0
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfiguration.js +97 -0
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfiguration.js.map +1 -0
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.js +106 -0
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.js.map +1 -0
- package/dist/components/Payroll/{TransitionCreation/TransitionCreationPresentation.module.scss.js → TransitionConfiguration/TransitionConfigurationPresentation.module.scss.js} +1 -1
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.module.scss.js.map +1 -0
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationTypes.js +10 -0
- package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationTypes.js.map +1 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js +86 -64
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js.map +1 -1
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +126 -77
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.module.scss.js +8 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.module.scss.js.map +1 -0
- package/dist/components/Payroll/helpers.js +1 -1
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/index.js +16 -20
- package/dist/components/Payroll/index.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 +2 -3
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/Payroll/useUnprocessedTransitionPayPeriods.js +11 -14
- package/dist/components/Payroll/useUnprocessedTransitionPayPeriods.js.map +1 -1
- package/dist/contexts/ApiProvider/ApiProvider.js +18 -17
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
- package/dist/contexts/ApiProvider/payScheduleCustomNameHook.js +31 -0
- package/dist/contexts/ApiProvider/payScheduleCustomNameHook.js.map +1 -0
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js.map +1 -1
- package/dist/contexts/FeaturesProvider/FeaturesProvider.js +14 -0
- package/dist/contexts/FeaturesProvider/FeaturesProvider.js.map +1 -0
- package/dist/contexts/FeaturesProvider/useFeature.js +7 -0
- package/dist/contexts/FeaturesProvider/useFeature.js.map +1 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +32 -30
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js.map +1 -1
- package/dist/i18n/I18n.js +2 -3
- package/dist/i18n/I18n.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/Contractor.Profile.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js +29 -23
- package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollHistory.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollLanding.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
- package/dist/i18n/en/{Payroll.UNSTABLE_PayrollEditEmployee.json.js → Payroll.RropPayrollEditEmployee.json.js} +42 -38
- package/dist/i18n/en/Payroll.RropPayrollEditEmployee.json.js.map +1 -0
- package/dist/i18n/en/Payroll.TransitionConfiguration.json.js +28 -0
- package/dist/i18n/en/Payroll.TransitionConfiguration.json.js.map +1 -0
- package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js +16 -12
- package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js.map +1 -1
- package/dist/i18n/en/common.json.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/partner-hook-utils/form/composeSubmitHandler.js +55 -48
- package/dist/partner-hook-utils/form/composeSubmitHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js +31 -29
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js.map +1 -1
- package/dist/shared/constants.js +7 -6
- package/dist/shared/constants.js.map +1 -1
- package/dist/src/components/Common/DataView/DataCards/DataCards.d.ts +3 -1
- package/dist/src/components/Common/DataView/DataTable/DataTable.d.ts +3 -1
- package/dist/src/components/Common/DataView/DataView.d.ts +2 -0
- package/dist/src/components/Common/DataView/getSortControls.d.ts +24 -0
- package/dist/src/components/Common/DataView/useDataView.d.ts +22 -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/Common/UI/Table/TableTypes.d.ts +71 -2
- package/dist/src/components/Company/PaySchedule/PaySchedule.d.ts +1 -9
- package/dist/src/components/Company/PaySchedule/PayScheduleComponents.d.ts +0 -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/fields.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.d.ts +4 -15
- package/dist/src/components/Contractor/ContractorList/management/ManagementContractorListView.d.ts +2 -2
- package/dist/src/components/Contractor/ContractorList/shared/index.d.ts +1 -1
- package/dist/src/components/Contractor/ContractorList/shared/useContractorList.d.ts +38 -0
- package/dist/src/components/Contractor/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Contractor/shared/hourlyRate.d.ts +23 -0
- package/dist/src/components/Employee/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Payroll/OffCycleTaxWithholdingTable/getDefaultWithholdingPayPeriod.d.ts +9 -0
- 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/TimeOffField.d.ts +3 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.d.ts +2 -0
- package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +8 -6
- package/dist/src/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.d.ts +0 -8
- package/dist/src/components/Payroll/PayrollFlow/PayrollFlow.d.ts +5 -3
- package/dist/src/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +2 -3
- package/dist/src/components/Payroll/PayrollFlow/payrollStateMachine.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollLanding/PayrollLanding.d.ts +18 -5
- package/dist/src/components/Payroll/PayrollList/PayrollList.d.ts +11 -5
- 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/{UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.d.ts → RropPayrollEditEmployee/RropPayrollEditEmployee.d.ts} +9 -5
- package/dist/src/components/Payroll/TransitionConfiguration/TransitionConfiguration.d.ts +55 -0
- package/dist/src/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.d.ts +9 -0
- package/dist/src/components/Payroll/TransitionConfiguration/TransitionConfigurationTypes.d.ts +52 -0
- package/dist/src/components/Payroll/TransitionConfiguration/index.d.ts +2 -0
- package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.d.ts +5 -2
- package/dist/src/components/Payroll/helpers.d.ts +2 -2
- package/dist/src/components/Payroll/index.d.ts +2 -6
- package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +2 -2
- package/dist/src/contexts/ApiProvider/payScheduleCustomNameHook.d.ts +14 -0
- package/dist/src/contexts/ApiProvider/payScheduleCustomNameHook.test.d.ts +1 -0
- package/dist/src/contexts/ComponentAdapter/componentAdapterTypes.d.ts +1 -1
- package/dist/src/contexts/FeaturesProvider/FeaturesProvider.d.ts +21 -0
- package/dist/src/contexts/FeaturesProvider/useFeature.d.ts +53 -0
- package/dist/src/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +3 -0
- package/dist/src/contexts/UnstableFeaturesProvider/useUnstableFeature.d.ts +38 -10
- package/dist/src/contexts/index.d.ts +1 -0
- package/dist/src/i18n/en/common.json.d.ts +5 -1
- package/dist/src/i18n/types.d.ts +195 -70
- package/dist/src/models/external.d.ts +63 -48
- package/dist/src/partner-hook-utils/form/fields/RadioGroupHookField.d.ts +9 -7
- package/dist/src/shared/constants.d.ts +5 -3
- package/dist/src/test-utils/renderWithProviders.d.ts +2 -0
- package/dist/style.css +1 -1
- package/docs/guides/endpoint-inventory.json +57 -40
- package/package.json +23 -22
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js +0 -29
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js.map +0 -1
- package/dist/components/Payroll/Transition/TransitionFlow.js +0 -60
- package/dist/components/Payroll/Transition/TransitionFlow.js.map +0 -1
- package/dist/components/Payroll/Transition/TransitionFlowComponents.js +0 -31
- package/dist/components/Payroll/Transition/TransitionFlowComponents.js.map +0 -1
- package/dist/components/Payroll/Transition/transitionStateMachine.js +0 -49
- package/dist/components/Payroll/Transition/transitionStateMachine.js.map +0 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js +0 -100
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js.map +0 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js +0 -110
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js.map +0 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.module.scss.js.map +0 -1
- package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.js +0 -21
- package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.js.map +0 -1
- package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js +0 -48
- package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js.map +0 -1
- package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js +0 -35
- package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js.map +0 -1
- package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js +0 -23
- package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js.map +0 -1
- package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js +0 -29
- package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js.map +0 -1
- package/dist/components/Payroll/UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.js +0 -411
- package/dist/components/Payroll/UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.js.map +0 -1
- package/dist/components/Payroll/UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.module.scss.js.map +0 -1
- package/dist/i18n/en/Payroll.Transition.json.js +0 -8
- package/dist/i18n/en/Payroll.Transition.json.js.map +0 -1
- package/dist/i18n/en/Payroll.TransitionCreation.json.js +0 -26
- package/dist/i18n/en/Payroll.TransitionCreation.json.js.map +0 -1
- package/dist/i18n/en/Payroll.UNSTABLE_PayrollEditEmployee.json.js.map +0 -1
- package/dist/src/components/Payroll/PayrollFlow/TransitionFlowContextual.d.ts +0 -7
- package/dist/src/components/Payroll/Transition/TransitionFlow.d.ts +0 -55
- package/dist/src/components/Payroll/Transition/TransitionFlowComponents.d.ts +0 -52
- package/dist/src/components/Payroll/Transition/index.d.ts +0 -2
- package/dist/src/components/Payroll/Transition/transitionStateMachine.d.ts +0 -29
- package/dist/src/components/Payroll/TransitionCreation/TransitionCreation.d.ts +0 -22
- package/dist/src/components/Payroll/TransitionCreation/TransitionCreationPresentation.d.ts +0 -9
- package/dist/src/components/Payroll/TransitionCreation/TransitionCreationTypes.d.ts +0 -57
- package/dist/src/components/Payroll/TransitionCreation/index.d.ts +0 -2
- package/dist/src/components/Payroll/TransitionPayroll/TransitionPayroll.d.ts +0 -55
- package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollComponents.d.ts +0 -24
- package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollTypes.d.ts +0 -23
- package/dist/src/components/Payroll/TransitionPayroll/index.d.ts +0 -2
- package/dist/src/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.d.ts +0 -15
- package/dist/src/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.d.ts +0 -28
- /package/dist/src/components/{Payroll/Transition/transitionStateMachine.test.d.ts → Common/DataView/getSortControls.test.d.ts} +0 -0
package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompensationForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsCreateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWages } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n createCompensationSchema,\n type CompensationOptionalFieldsToRequire,\n type CompensationFormData,\n type CompensationFormOutputs,\n} from './compensationSchema'\nimport {\n TitleField,\n FlsaStatusField,\n RateField,\n PaymentUnitField,\n AdjustForMinimumWageField,\n MinimumWageIdField,\n EffectiveDateField,\n} from './fields'\nimport type {\n TitleFieldProps,\n FlsaStatusFieldProps,\n RateFieldProps,\n PaymentUnitFieldProps,\n AdjustForMinimumWageFieldProps,\n MinimumWageIdFieldProps,\n EffectiveDateFieldProps,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { withFlags } from '@/partner-hook-utils/form/withFlags'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\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 { FlsaStatus, PAY_PERIODS, TIP_CREDITS_UNSUPPORTED_STATES } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { addDays, formatDateToStringDate } from '@/helpers/dateFormatting'\n\n/**\n * Optional values supplied to {@link useCompensationForm}'s `actions.onSubmit` at submit time.\n *\n * @remarks\n * Use these to override hook-construction props when an ID isn't known at\n * mount — most commonly the **onboarding stub-fill** chain, where `useJobForm`\n * creates the parent job and returns the auto-created stub compensation, and\n * the IDs and version are threaded into this hook's `onSubmit` to PUT the\n * stub.\n *\n * @public\n */\nexport interface CompensationSubmitOptions {\n /** Override jobId — required when creating a compensation if not configured at hook construction (e.g. when the parent job was just created in the same submit chain). */\n jobId?: string\n /** Override compensationId — when present, forces update (PUT) routing regardless of hook construction. */\n compensationId?: string\n /**\n * Compensation version for optimistic locking on PUT. Required when forcing\n * update routing post-create (e.g. updating the auto-created stub returned\n * from `POST /v1/employees/:id/jobs`). When omitted, the hook reads the\n * version from its cached `currentCompensation`.\n */\n compensationVersion?: string\n /**\n * Supply `effectiveDate` at submit time. When `withEffectiveDateField`\n * is `true`, this overrides the form's value. When `withEffectiveDateField`\n * is `false`, this is the only way to put `effective_date` on the wire —\n * the form value is not read in that mode (matching the options-only\n * convention of `useWorkAddressForm` / `useHomeAddressForm` / `useJobForm`).\n */\n effectiveDate?: string\n}\n\n/**\n * Configuration options for {@link useCompensationForm}.\n *\n * @remarks\n * Presence or absence of `compensationId` selects the API verb — see the\n * `compensationId` field description. `employeeId` is optional so the hook\n * can be composed alongside an employee-creation step. `jobId` is optional in\n * update mode (derived from the loaded compensation) and required in create\n * mode (scopes the POST); supply it at submit time via\n * {@link CompensationSubmitOptions.jobId} when the parent job is created in\n * the same submit chain.\n *\n * @public\n */\nexport interface UseCompensationFormProps {\n /** UUID of the employee whose compensation is being created or edited. Drives data fetching for derived helpers (jobs list, work address, minimum wages). May be omitted when composing alongside an employee-creation step. */\n employeeId?: string\n /** The parent job's UUID. Required in create mode (scopes `POST /v1/jobs/:jobId/compensations`). Optional in update mode — the parent job is derived from the loaded compensation. */\n jobId?: string\n /** Present → update mode (PUT /v1/compensations/:id). Omitted → create mode (POST /v1/jobs/:jobId/compensations). */\n compensationId?: string\n /** Override fields that are optional on a given mode to be required. See {@link CompensationOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update mode. */\n defaultValues?: Partial<CompensationFormData>\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.EffectiveDate` (becomes `undefined`) and\n * removes `effectiveDate` from schema validation. In this mode the hook\n * does not read any form value at submit time — `effective_date` is\n * omitted from the request body unless explicitly supplied via\n * {@link CompensationSubmitOptions.effectiveDate}. This matches the\n * options-only convention of other form hooks, and means the\n * `willDeleteSecondaryJobs` carve-out's form-state side effects do not\n * leak onto the wire (there is no field to render them in anyway).\n * Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useCompensationForm().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.FlsaStatus && <Fields.FlsaStatus ... />}`) before rendering.\n *\n * @public\n */\nexport interface CompensationFormFields {\n /** Bound to `title`. Title text input. Always available. Optional in both modes unless `optionalFieldsToRequire` requires it. */\n Title: ComponentType<TitleFieldProps>\n /** Bound to `flsaStatus`. FLSA classification select. `undefined` when the status is not user-editable (e.g. secondary jobs that must match the primary). */\n FlsaStatus: ComponentType<FlsaStatusFieldProps> | undefined\n /** Bound to `rate`. Compensation amount input. `undefined` for commission-only FLSA statuses, which don't accept a partner-supplied rate. */\n Rate: ComponentType<RateFieldProps> | undefined\n /** Bound to `paymentUnit`. Payment unit select. `undefined` for commission-only FLSA statuses (the hook forces `paymentUnit=Year`). */\n PaymentUnit: ComponentType<PaymentUnitFieldProps> | undefined\n /** Bound to `adjustForMinimumWage`. Minimum-wage adjustment checkbox. `undefined` unless `flsaStatus === Nonexempt`, the employee's work location has minimum wages, and the state supports tip credits. */\n AdjustForMinimumWage: ComponentType<AdjustForMinimumWageFieldProps> | undefined\n /** Bound to `minimumWageId`. Minimum-wage selection. `undefined` unless `Fields.AdjustForMinimumWage` is rendered and checked. */\n MinimumWageId: ComponentType<MinimumWageIdFieldProps> | undefined\n /** Bound to `effectiveDate`. Effective-date picker. `undefined` when `withEffectiveDateField: false`; supply the value via `CompensationSubmitOptions.effectiveDate` in that mode. */\n EffectiveDate: ComponentType<EffectiveDateFieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link useCompensationForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the compensation-specific `data`, `status`, `actions`, and `form.Fields`\n * shape. Static, entity-derived values live under `data.*`; reactive values\n * that flip with form input live under `status.*`.\n *\n * @public\n */\nexport interface UseCompensationFormReady extends BaseFormHookReady<\n CompensationFieldsMetadata,\n CompensationFormData,\n CompensationFormFields\n> {\n /** Compensation-specific data payload: the loaded compensation, the parent job, available minimum wages, and effective-date bounds. */\n data: {\n /** The compensation row loaded for update; `null` in create mode. */\n compensation: Compensation | null\n /** The parent job. In update mode it's derived from the loaded compensation; in create mode it's looked up by `jobId`. `null` if neither resolves. */\n currentJob: Job | null\n /** Minimum wages available at the employee's active work location. Empty when no location is set or no minimums are defined. */\n minimumWages: MinimumWage[]\n /** Lower bound for `effectiveDate` (typically the parent job's hire date). */\n minimumEffectiveDate: string | null\n /** Upper bound for `effectiveDate` — the next scheduled future compensation's effective date, when one exists. */\n maximumEffectiveDate: string | null\n /** True when at least one future-dated compensation already exists for this job. */\n hasPendingFutureCompensation: boolean\n }\n /** Submission state and reactive flags derived from current form input. `isPending` is `true` while a create/update mutation is in flight; `mode` reflects whether the next submit will create or update; the `show*Alert` flags drive FLSA-specific inline warnings. */\n status: {\n /** `true` while a create or update mutation is in flight. */\n isPending: boolean\n /** Reflects whether the next submit will POST a new compensation or PUT an existing one. */\n mode: 'create' | 'update'\n /**\n * True when submitting the form right now would delete the employee's\n * secondary jobs server-side (the \"carve-out\" branch). Reactive:\n * derived from the current `flsaStatus` form value, the loaded\n * compensation, and the other-jobs count, so this flips as you change\n * inputs.\n *\n * Conditions: update mode, the loaded compensation is Nonexempt, the\n * form's `flsaStatus` has been changed to a non-Nonexempt value, and\n * the employee has at least one secondary job.\n *\n * While this flag is true the hook also takes the `effectiveDate`\n * field over: it forces the form value to today (so submits route\n * through a PUT that immediately deletes secondaries) and exposes\n * `fieldsMetadata.effectiveDate.isDisabled = true` so `Fields.EffectiveDate`\n * renders as disabled. On revert (FLSA back to Nonexempt) the prior\n * `effectiveDate` is restored. Render an inline warning keyed off\n * this flag — no separate confirmation step is needed.\n */\n willDeleteSecondaryJobs: boolean\n /**\n * True when the current `flsaStatus` is `COMMISSION_ONLY_EXEMPT`\n * (Commission Only/No Overtime). Render the federal-minimum-pay\n * warning alert when this flag is true. While this flag is true,\n * `Fields.Rate` and `Fields.PaymentUnit` are also `undefined` (the\n * hook forces `rate=0`, `paymentUnit=YEAR` on the form values).\n */\n showCommissionFederalMinimumPayAlert: boolean\n /**\n * True when the current `flsaStatus` is `COMMISSION_ONLY_NONEXEMPT`\n * (Commission Only/Eligible for overtime). Render the local-minimum-wage\n * warning alert when this flag is true. While this flag is true,\n * `Fields.Rate` and `Fields.PaymentUnit` are also `undefined` (the\n * hook forces `rate=0`, `paymentUnit=YEAR` on the form values).\n */\n showCommissionMinimumWageAlert: boolean\n /**\n * True when the current `flsaStatus` is `OWNER` (Owner's draw). Render\n * an informational alert noting that the IRS requires S-corp owners to\n * pay themselves a reasonable salary for similar work before taking\n * distributions.\n */\n showOwnerSalaryAlert: boolean\n }\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 compensation. Resolves to `undefined` on validation failure or mutation error. Accepts {@link CompensationSubmitOptions} for threading IDs/version into the onboarding stub-fill chain. */\n onSubmit: (\n options?: CompensationSubmitOptions,\n ) => Promise<HookSubmitResult<Compensation> | undefined>\n }\n}\n\nfunction resolveCompAndJob(\n jobs: Job[] | undefined,\n compensationId: string | undefined,\n jobId: string | undefined,\n): { compensation: Compensation | null; job: Job | null } {\n if (!jobs) return { compensation: null, job: null }\n if (compensationId) {\n for (const job of jobs) {\n const compensation = job.compensations?.find(c => c.uuid === compensationId)\n if (compensation) return { compensation, job }\n }\n // If the comp isn't in any job's compensations list, still try to resolve\n // the job by jobId so callers can check job metadata (e.g. job.primary).\n const fallbackJob = jobId ? (jobs.find(j => j.uuid === jobId) ?? null) : null\n return { compensation: null, job: fallbackJob }\n }\n if (jobId) return { compensation: null, job: jobs.find(j => j.uuid === jobId) ?? null }\n return { compensation: null, job: null }\n}\n\nfunction findPrimaryFlsaStatus(jobs: Job[] | undefined): FlsaStatusType | null {\n if (!jobs) return null\n for (const job of jobs) {\n if (!job.primary) continue\n const compensation = job.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n if (compensation?.flsaStatus) return compensation.flsaStatus\n }\n return null\n}\n\nfunction findFutureCompensations(job: Job | null): Compensation[] {\n if (!job?.compensations) return []\n const today = todayISO()\n return job.compensations.filter(c => c.effectiveDate !== undefined && c.effectiveDate > today)\n}\n\nfunction earliestEffectiveDate(comps: Compensation[]): string | null {\n if (comps.length === 0) return null\n return comps.reduce<string | null>((min, c) => {\n const d = c.effectiveDate\n if (!d) return min\n if (!min || d < min) return d\n return min\n }, null)\n}\n\nconst flsaStatusEntries: FlsaStatusType[] = [\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n]\n\nconst flsaOptions = flsaStatusEntries.map(status => ({ value: status, label: status }))\n\nconst paymentUnitEntries: PaymentUnit[] = [\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n]\n\nconst paymentUnitOptions = paymentUnitEntries.map(unit => ({ value: unit, label: unit }))\n\nfunction todayISO(): string {\n return new Date().toISOString().split('T')[0]!\n}\n\n/** @internal */\nfunction buildCompensationFieldsMetadata(\n base: Record<keyof CompensationFormData, FieldMetadata>,\n {\n willDeleteSecondaryJobs,\n isCreateMode,\n isCommissionOnly,\n isOwner,\n isAdjustMinimumWageEnabled,\n effectiveDateMinDate,\n maximumEffectiveDate,\n minimumWageOptions,\n minimumWages,\n }: {\n willDeleteSecondaryJobs: boolean\n isCreateMode: boolean\n isCommissionOnly: boolean\n isOwner: boolean\n isAdjustMinimumWageEnabled: boolean\n effectiveDateMinDate: string | null\n maximumEffectiveDate: string | null\n minimumWageOptions: { value: string; label: string }[]\n minimumWages: MinimumWage[]\n },\n) {\n return {\n title: base.title,\n effectiveDate: withFlags(base.effectiveDate, {\n isDisabled: willDeleteSecondaryJobs && !isCreateMode,\n minDate: effectiveDateMinDate,\n maxDate: maximumEffectiveDate,\n }),\n flsaStatus: withOptions<FlsaStatusType>(base.flsaStatus, flsaOptions, flsaStatusEntries),\n rate: withFlags(base.rate, { isDisabled: isCommissionOnly }),\n paymentUnit: withOptions<PaymentUnit>(\n withFlags(base.paymentUnit, { isDisabled: isOwner || isCommissionOnly }),\n paymentUnitOptions,\n paymentUnitEntries,\n ),\n adjustForMinimumWage: withFlags(base.adjustForMinimumWage, {\n isDisabled: !isAdjustMinimumWageEnabled,\n }),\n minimumWageId: withOptions<MinimumWage>(base.minimumWageId, minimumWageOptions, minimumWages),\n } satisfies FieldsMetadata\n}\n\n/**\n * Headless hook for creating or updating a compensation row on a job — FLSA classification, pay rate, payment unit, effective date, and optional minimum-wage adjustment.\n *\n * @remarks\n * Companion hook to `useJobForm`. Jobs and their compensations are separate\n * entities in the Gusto API and this hook focuses exclusively on the\n * compensation side. Presence of `compensationId` selects the verb:\n *\n * | Hook config / submit options | Mode | API call |\n * | ---------------------------- | ---- | -------- |\n * | `{ jobId, compensationId }` | update | `PUT /v1/compensations/:compensationId` (with `version`) |\n * | `{ jobId }` (no `compensationId`) | create | `POST /v1/jobs/:jobId/compensations` |\n * | `{ employeeId }` + submit `{ jobId, compensationId, compensationVersion }` | update | `PUT /v1/compensations/:compensationId` (with the supplied `version`) |\n * | `{ employeeId }` + submit `{ jobId }` (no `compensationId`) | create | `POST /v1/jobs/:options.jobId/compensations` |\n *\n * Use the submit-options form for the **onboarding stub-fill** chain: after\n * `useJobForm.actions.onSubmit()` creates a job, capture the auto-created\n * compensation's UUID and version from the response, and pass them as\n * `{ jobId, compensationId, compensationVersion }` to this hook's `onSubmit`\n * to PUT the stub.\n *\n * The hook exposes several derived helpers for driving UX — static\n * entity-derived values under `data.*` (effective-date bounds, pending\n * future compensations) and reactive flags under `status.*` (the\n * `willDeleteSecondaryJobs` carve-out, plus FLSA-specific alerts for\n * commission-only and owner classifications). When\n * `willDeleteSecondaryJobs` is `true` in update mode, the hook also locks\n * the `effectiveDate` field (forces to today, renders disabled) until the\n * FLSA selection is reverted.\n *\n * @param input - {@link UseCompensationFormProps} — `employeeId`, `jobId`, `compensationId` (toggle create/update), required-field overrides, default values, and which fields the hook renders.\n * @returns A {@link HookLoadingResult} while data is loading, or a {@link UseCompensationFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useCompensationForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function CompensationForm({ employeeId, jobId }: { employeeId: string; jobId: string }) {\n * const comp = useCompensationForm({ employeeId, jobId })\n * if (comp.isLoading) return null\n *\n * const { Fields } = comp.form\n * return (\n * <form onSubmit={e => { e.preventDefault(); comp.actions.onSubmit() }}>\n * <SDKFormProvider formHookResult={comp}>\n * {Fields.FlsaStatus && <Fields.FlsaStatus label=\"Employee type\" />}\n * <Fields.Rate label=\"Compensation amount\" />\n * <Fields.PaymentUnit label=\"Payment unit\" />\n * {Fields.EffectiveDate && <Fields.EffectiveDate label=\"Effective date\" />}\n * </SDKFormProvider>\n * {comp.status.willDeleteSecondaryJobs && (\n * <p>Saving will remove this employee's secondary jobs.</p>\n * )}\n * <button type=\"submit\" disabled={comp.status.isPending}>Save</button>\n * </form>\n * )\n * }\n * ```\n */\nexport function useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withEffectiveDateField = true,\n}: UseCompensationFormProps): HookLoadingResult | UseCompensationFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n {\n employeeId: employeeId ?? '',\n // Fetch all effective-dated compensations when editing an existing one so\n // resolveCompAndJob can find the target comp (future-dated comps are\n // omitted from the default response, which only returns the current comp).\n include: compensationId\n ? GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations\n : undefined,\n },\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)\n const locationUuid = currentWorkAddress?.locationUuid\n const employee = employeeQuery.data?.employee\n\n const minWagesQuery = useLocationsGetMinimumWages(\n { locationUuid: locationUuid ?? '' },\n { enabled: !!locationUuid, staleTime: Infinity },\n )\n\n const minimumWages = minWagesQuery.data?.minimumWageList ?? []\n\n const { compensation: currentCompensation, job: currentJob } = resolveCompAndJob(\n employeeJobs,\n compensationId,\n jobId,\n )\n\n const otherJobsCount =\n employeeJobs && currentJob ? employeeJobs.filter(j => j.uuid !== currentJob.uuid).length : 0\n\n // Snapshot — written exactly once, on the first render where `employeeJobs`\n // is defined (i.e., the initial `getJobs` query has resolved) — capturing\n // whether the employee already had a primary job at that moment.\n //\n // Used to ignore the API-generated stub primary (FLSA Nonexempt, rate \"0.00\")\n // that briefly appears between the chained job POST and comp PUT during\n // onboarding: `getJobs` invalidates between the two mutations and\n // momentarily includes the stub, which would otherwise flip\n // `isAddingSecondaryJob` to true and hide `Fields.FlsaStatus` mid-submit.\n //\n // In steady-state flows (edit primary, edit secondary, add secondary), the\n // real primary already exists when the query first resolves, so the snapshot\n // is `true` and live `employeeJobs` continues to drive `primaryFlsaStatus`.\n // Recovery for the rare case where a partner mounts before any jobs exist\n // and a primary is created externally mid-form is to remount the hook\n // (e.g., via a `key` change).\n const hadPrimaryAtMountRef = useRef<boolean | null>(null)\n if (hadPrimaryAtMountRef.current === null && employeeJobs !== undefined) {\n hadPrimaryAtMountRef.current = employeeJobs.some(job => job.primary)\n }\n const hadPrimaryAtMount = hadPrimaryAtMountRef.current === true\n\n // FLSA status of the employee's primary job's current compensation, when one\n // exists. Used as a fallback default when adding a *secondary* job/comp so the\n // multi-job classification stays consistent with the primary by default — the\n // user can still override it (when allowed). Null when there was no primary\n // job at the moment the hook first observed `employeeJobs`, or when the\n // primary has no current compensation yet.\n const primaryFlsaStatus = hadPrimaryAtMount ? findPrimaryFlsaStatus(employeeJobs) : null\n\n const hireDate =\n currentJob?.hireDate ??\n // Secondary jobs being created (CompensationAddAnotherJobForm) have no hireDate until the\n // job POST completes. Fall back to the primary job's hireDate so the schema\n // can enforce EFFECTIVE_DATE_BEFORE_HIRE during that window.\n employeeJobs?.find(j => j.primary)?.hireDate ??\n null\n\n // In update mode, exclude the compensation being edited so it doesn't\n // bound `maximumEffectiveDate` to its own current date — that would prevent\n // the user from pushing the pending effective date further out.\n const futureCompensations = findFutureCompensations(currentJob).filter(\n c => c.uuid !== compensationId,\n )\n const hasPendingFutureCompensation = futureCompensations.length > 0\n const maximumEffectiveDate = earliestEffectiveDate(futureCompensations)\n\n const isCreateMode = !compensationId\n const mode = isCreateMode ? 'create' : 'update'\n // Adding a secondary job (the employee already has a primary). The Gusto API\n // only allows secondaries when the primary's current FLSA is Nonexempt, and\n // the secondary itself must match — so the FLSA field is not user-editable\n // in this branch. We force the form value to the primary's FLSA below and\n // hide `Fields.FlsaStatus`.\n // True when adding a brand-new secondary job (not when scheduling a future\n // comp for the primary). The distinction matters: for the primary's future\n // comp, FLSA should be editable; for a secondary, it must match the primary.\n const isAddingSecondaryJob =\n isCreateMode && primaryFlsaStatus === FlsaStatus.NONEXEMPT && currentJob?.primary !== true\n\n // Derive the effective-date floor internally so consumers don't need to wire\n // it up. Rules by mode and job type:\n // create (any job): tomorrow — new comp must be future-dated\n // update, primary: undefined — the carve-out (willDeleteSecondaryJobs) can\n // force effectiveDate to today on a disabled field; enforcing a floor here\n // would produce a spurious EFFECTIVE_DATE_BEFORE_MIN on submit.\n // update, secondary: tomorrow — must be in the future\n // The hire-date lower bound is handled separately in the schema via the\n // `hireDate` option (→ EFFECTIVE_DATE_BEFORE_HIRE), which fires alongside\n // this check so each violation gets its own error message.\n const internalMinEffectiveDate = useMemo(() => {\n if (!withEffectiveDateField) return undefined\n if (!isCreateMode && currentJob?.primary === true) return undefined\n\n return formatDateToStringDate(addDays(new Date(), 1)) ?? undefined\n }, [isCreateMode, currentJob?.primary, withEffectiveDateField])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createCompensationSchema({\n mode,\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate: internalMinEffectiveDate,\n withEffectiveDateField,\n }),\n [mode, optionalFieldsToRequire, hireDate, internalMinEffectiveDate, withEffectiveDateField],\n )\n\n const state = currentWorkAddress?.state\n\n // `flsaStatus` is intentionally allowed to be undefined so the field renders\n // an empty placeholder when nothing is provided — partners can choose to\n // seed it via `defaultValues.flsaStatus`. When a `compensation` is loaded we\n // seed from it; for a brand-new secondary job we inherit from the primary's\n // current compensation so multi-job classification stays consistent. The\n // schema enforces requiredness on submit in `create` mode (see\n // `requiredFieldsConfig` in compensationSchema.ts).\n //\n // `title` lives on compensation in the API — `job.title` is a denormalized\n // snapshot of the primary comp's title that can lag behind comp-level edits\n // on secondaries. Seed directly from the loaded compensation so editing in\n // place can't silently re-introduce a stale title from the job record.\n const resolvedDefaults: CompensationFormData = useMemo(\n () => ({\n title: currentCompensation?.title ?? partnerDefaults?.title ?? '',\n // When adding a secondary, the FLSA must match the primary's — force it\n // here (overriding any partner default) so the form submits the right\n // value even though `Fields.FlsaStatus` is hidden.\n flsaStatus: isAddingSecondaryJob\n ? primaryFlsaStatus\n : (currentCompensation?.flsaStatus ??\n partnerDefaults?.flsaStatus ??\n primaryFlsaStatus ??\n undefined),\n rate: Number(currentCompensation?.rate ?? partnerDefaults?.rate ?? 0),\n adjustForMinimumWage:\n currentCompensation?.adjustForMinimumWage ?? partnerDefaults?.adjustForMinimumWage ?? false,\n minimumWageId:\n currentCompensation?.minimumWages?.[0]?.uuid ?? partnerDefaults?.minimumWageId ?? '',\n paymentUnit:\n currentCompensation?.paymentUnit ?? partnerDefaults?.paymentUnit ?? PAY_PERIODS.HOUR,\n effectiveDate: currentCompensation?.effectiveDate ?? partnerDefaults?.effectiveDate ?? null,\n }),\n [currentCompensation, currentJob, partnerDefaults, primaryFlsaStatus, isAddingSecondaryJob],\n )\n\n const formMethods = useForm<CompensationFormData, unknown, CompensationFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const { control, getValues, setValue, clearErrors } = formMethods\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedAdjustForMinimumWage = useWatch({\n control,\n name: 'adjustForMinimumWage',\n })\n\n // Validation rules for `paymentUnit` and `rate` are FLSA-driven, so any\n // prior error on those fields is stale once FLSA changes. RHF doesn't clear\n // them on its own (`setValue` without `shouldValidate` skips the resolver,\n // and reValidate is per-field) — clear eagerly and let the next blur/submit\n // re-establish the error if it still applies.\n useEffect(() => {\n clearErrors(['paymentUnit', 'rate'])\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', PAY_PERIODS.PAYCHECK)\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', PAY_PERIODS.YEAR)\n setValue('rate', 0)\n } else {\n setValue('paymentUnit', resolvedDefaults.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, clearErrors, resolvedDefaults.paymentUnit])\n\n // The FLSA status that represents the employee's current classification.\n // In update mode this is the compensation being edited. In create mode\n // `currentCompensation` is null, so fall back to the job's active\n // compensation (identified by currentCompensationUuid) — this lets the\n // secondary-job warning fire even when scheduling a future-dated change.\n const currentJobActiveComp = currentJob\n ? currentJob.compensations?.find(c => c.uuid === currentJob.currentCompensationUuid)\n : undefined\n const effectiveBaseFlsaStatus =\n currentCompensation?.flsaStatus ?? currentJobActiveComp?.flsaStatus ?? null\n\n // True when the user is changing FLSA away from Nonexempt on a job that has\n // secondary jobs — those secondaries will be deleted by the API when the\n // new classification takes effect (immediately in update mode, at the chosen\n // effective date in create mode). Drives the warning and, in update mode\n // only, the effectiveDate-lock side effect below.\n const willDeleteSecondaryJobs =\n effectiveBaseFlsaStatus === FlsaStatus.NONEXEMPT &&\n watchedFlsaStatus !== undefined &&\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT &&\n otherJobsCount > 0\n\n // Carve-out UX — update mode only: while willDeleteSecondaryJobs is active\n // the server deletes secondaries immediately on PUT. Mirror this by forcing\n // `effectiveDate` to today and disabling the field. In create mode the\n // deletion happens at the chosen future date, so we show the warning but\n // leave the date field editable.\n const carveOutActiveRef = useRef(false)\n const priorEffectiveDateRef = useRef<string | null>(null)\n useEffect(() => {\n if (!isCreateMode && willDeleteSecondaryJobs && !carveOutActiveRef.current) {\n priorEffectiveDateRef.current = getValues('effectiveDate') ?? null\n setValue('effectiveDate', todayISO(), { shouldDirty: true, shouldValidate: false })\n carveOutActiveRef.current = true\n } else if (!isCreateMode && !willDeleteSecondaryJobs && carveOutActiveRef.current) {\n setValue('effectiveDate', priorEffectiveDateRef.current ?? null, {\n shouldDirty: true,\n shouldValidate: false,\n })\n priorEffectiveDateRef.current = null\n carveOutActiveRef.current = false\n }\n }, [isCreateMode, willDeleteSecondaryJobs, getValues, setValue])\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation()\n const createCompensationMutation = useJobsAndCompensationsCreateCompensationMutation()\n\n const isPending = updateCompensationMutation.isPending || createCompensationMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('CompensationForm')\n\n const queriesForErrors = employeeId\n ? [jobsQuery, addressesQuery, employeeQuery, minWagesQuery]\n : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const isCommissionOnly =\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n const isOwner = watchedFlsaStatus === FlsaStatus.OWNER\n\n // Hide `Fields.FlsaStatus` when the user has no meaningful choice:\n // - update mode editing a secondary whose comp is already Nonexempt\n // (must keep matching the primary), and\n // - create mode while adding a secondary (must inherit primary's FLSA).\n // The first job's create flow and primary-job edits keep the field exposed.\n const isFlsaSelectionEnabled =\n !isAddingSecondaryJob &&\n (watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary === true || isCreateMode)\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n // Min-wage adjustment is only valid for Nonexempt FLSA (and a state that\n // allows tip credit). When the gate flips off — typically because the user\n // changed FLSA away from Nonexempt — `Fields.AdjustForMinimumWage` and\n // `Fields.MinimumWageId` stop rendering, but the underlying form values\n // persist in react-hook-form state. That would leak an\n // `adjust_for_minimum_wage: true` + `minimum_wages: [...]` body on submit\n // (server rejects with \"Minimum wage adjustments only valid for\n // flsa_status: Nonexempt\"). Reset both values to safe defaults so the\n // submitted payload always matches what the user can actually see.\n useEffect(() => {\n if (isAdjustMinimumWageEnabled) return\n if (getValues('adjustForMinimumWage')) {\n setValue('adjustForMinimumWage', false, { shouldDirty: true, shouldValidate: false })\n }\n if (getValues('minimumWageId')) {\n setValue('minimumWageId', '', { shouldDirty: true, shouldValidate: false })\n }\n // Both fields stop rendering once the gate closes — clear errors so a\n // stale one doesn't silently fail the next submit with no visible UI to fix.\n clearErrors(['adjustForMinimumWage', 'minimumWageId'])\n }, [isAdjustMinimumWageEnabled, getValues, setValue, clearErrors])\n\n const minimumWageOptions = minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${wage.wage} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const effectiveDateMinDate = useMemo(\n () =>\n [internalMinEffectiveDate, hireDate]\n .filter((d): d is string => !!d)\n .reduce<string | null>((max, d) => (!max || d > max ? d : max), null),\n [internalMinEffectiveDate, hireDate],\n )\n const fieldsMetadata = buildCompensationFieldsMetadata(baseMetadata, {\n willDeleteSecondaryJobs,\n isCreateMode,\n isCommissionOnly,\n isOwner,\n isAdjustMinimumWageEnabled,\n effectiveDateMinDate,\n maximumEffectiveDate,\n minimumWageOptions,\n minimumWages,\n })\n\n const onSubmit = async (\n options?: CompensationSubmitOptions,\n ): Promise<HookSubmitResult<Compensation> | undefined> => {\n let submitResult: HookSubmitResult<Compensation> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: CompensationFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedJobId = options?.jobId ?? jobId\n const resolvedCompensationId = options?.compensationId ?? compensationId\n const resolvedMode = resolvedCompensationId ? 'update' : 'create'\n\n // When the field is rendered, the validated payload value wins\n // unless an explicit submit-time override is supplied. When the\n // field is hidden (`withEffectiveDateField: false`) we are\n // strictly options-only — matching `useWorkAddressForm` and the\n // hidden-field behavior of `useHomeAddressForm` / `useJobForm`.\n // The carve-out's form-state side effect (force value to today)\n // is therefore inert in the hidden-field path; partners who\n // need a specific date there must supply it via\n // `CompensationSubmitOptions.effectiveDate`.\n const resolvedEffectiveDate = withEffectiveDateField\n ? (options?.effectiveDate ?? payload.effectiveDate ?? undefined)\n : (options?.effectiveDate ?? undefined)\n\n const requestBodyBase = {\n rate: String(payload.rate),\n paymentUnit: payload.paymentUnit,\n flsaStatus: payload.flsaStatus,\n effectiveDate: resolvedEffectiveDate,\n title: payload.title || undefined,\n adjustForMinimumWage: payload.adjustForMinimumWage,\n minimumWages: payload.adjustForMinimumWage ? [{ uuid: payload.minimumWageId }] : [],\n }\n\n let result: Compensation | undefined\n\n if (resolvedMode === 'create') {\n if (!resolvedJobId) {\n throw new SDKInternalError(\n 'jobId is required to create a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n // Schema's `requiredFieldsConfig` guarantees `flsaStatus` is set\n // on create-mode submit; the runtime guard appeases the API\n // request-body type (which requires a non-undefined value on\n // POST, vs. the optional PUT body).\n if (!payload.flsaStatus) {\n throw new SDKInternalError('flsaStatus is required to create a compensation.')\n }\n const createResponse = await createCompensationMutation.mutateAsync({\n request: {\n jobId: resolvedJobId,\n compensationsRequestBody: { ...requestBodyBase, flsaStatus: payload.flsaStatus },\n },\n })\n result = createResponse.compensation\n if (!result) throw new SDKInternalError('Compensation creation failed')\n } else {\n if (!resolvedCompensationId) {\n throw new SDKInternalError(\n 'compensationId is required to update a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n const resolvedVersion =\n options?.compensationVersion ?? (currentCompensation?.version as string | undefined)\n if (!resolvedVersion) {\n throw new SDKInternalError(\n 'compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded.',\n )\n }\n const updateResponse = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: resolvedCompensationId,\n compensationsUpdateRequestBody: {\n version: resolvedVersion,\n ...requestBodyBase,\n },\n },\n })\n result = updateResponse.compensation\n if (!result) throw new SDKInternalError('Compensation update failed')\n }\n\n submitResult = { mode: resolvedMode, data: result }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading ||\n addressesQuery.isLoading ||\n employeeQuery.isLoading ||\n minWagesQuery.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 compensation: currentCompensation,\n currentJob,\n minimumWages,\n minimumEffectiveDate: effectiveDateMinDate,\n maximumEffectiveDate,\n hasPendingFutureCompensation,\n },\n status: {\n isPending,\n mode,\n willDeleteSecondaryJobs,\n showCommissionFederalMinimumPayAlert: watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT,\n showCommissionMinimumWageAlert: watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n showOwnerSalaryAlert: watchedFlsaStatus === FlsaStatus.OWNER,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: TitleField,\n FlsaStatus: isFlsaSelectionEnabled ? FlsaStatusField : undefined,\n Rate: isCommissionOnly ? undefined : RateField,\n PaymentUnit: isCommissionOnly ? undefined : PaymentUnitField,\n AdjustForMinimumWage: isAdjustMinimumWageEnabled ? AdjustForMinimumWageField : undefined,\n MinimumWageId:\n isAdjustMinimumWageEnabled && watchedAdjustForMinimumWage\n ? MinimumWageIdField\n : undefined,\n EffectiveDate: withEffectiveDateField ? EffectiveDateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link useCompensationForm} — either the loading state or the ready state.\n *\n * @remarks\n * Use this type when threading the hook result through helpers (e.g.\n * presentational components). Discriminate on `isLoading` to narrow to\n * {@link UseCompensationFormReady}.\n *\n * @public\n */\nexport type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady\n\n/**\n * Metadata for each {@link useCompensationForm} field, exposed on `form.fieldsMetadata`.\n *\n * @remarks\n * Includes per-field `isDisabled`, `isRequired`, and the dynamic option list\n * for select fields (`flsaStatus`, `paymentUnit`, `minimumWageId`).\n * `effectiveDate` additionally carries `minDate` / `maxDate` derived from\n * the parent job's hire date and any pending future compensation.\n *\n * @public\n */\nexport type CompensationFieldsMetadata = ReturnType<typeof buildCompensationFieldsMetadata>\n"],"names":["resolveCompAndJob","jobs","compensationId","jobId","job","compensation","c","j","findPrimaryFlsaStatus","findFutureCompensations","today","todayISO","earliestEffectiveDate","comps","min","d","flsaStatusEntries","FlsaStatus","flsaOptions","status","paymentUnitEntries","PAY_PERIODS","paymentUnitOptions","unit","buildCompensationFieldsMetadata","base","willDeleteSecondaryJobs","isCreateMode","isCommissionOnly","isOwner","isAdjustMinimumWageEnabled","effectiveDateMinDate","maximumEffectiveDate","minimumWageOptions","minimumWages","withFlags","withOptions","useCompensationForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withEffectiveDateField","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","locationUuid","employee","minWagesQuery","useLocationsGetMinimumWages","currentCompensation","currentJob","otherJobsCount","hadPrimaryAtMountRef","useRef","primaryFlsaStatus","hireDate","futureCompensations","hasPendingFutureCompensation","mode","isAddingSecondaryJob","internalMinEffectiveDate","useMemo","formatDateToStringDate","addDays","schema","metadataConfig","createCompensationSchema","state","resolvedDefaults","formMethods","useForm","zodResolver","control","getValues","setValue","clearErrors","watchedFlsaStatus","useWatch","watchedAdjustForMinimumWage","useEffect","currentJobActiveComp","carveOutActiveRef","priorEffectiveDateRef","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","createCompensationMutation","useJobsAndCompensationsCreateCompensationMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","isFlsaSelectionEnabled","TIP_CREDITS_UNSUPPORTED_STATES","wage","baseMetadata","useDeriveFieldsMetadata","max","fieldsMetadata","onSubmit","options","submitResult","resolve","data","payload","resolvedJobId","resolvedCompensationId","resolvedMode","resolvedEffectiveDate","requestBodyBase","result","SDKInternalError","resolvedVersion","isDataLoading","hookFormInternals","useHookFormInternals","TitleField","FlsaStatusField","RateField","PaymentUnitField","AdjustForMinimumWageField","MinimumWageIdField","EffectiveDateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6PA,SAASA,GACPC,GACAC,GACAC,GACwD;AACxD,MAAI,CAACF,EAAM,QAAO,EAAE,cAAc,MAAM,KAAK,KAAA;AAC7C,MAAIC,GAAgB;AAClB,eAAWE,KAAOH,GAAM;AACtB,YAAMI,IAAeD,EAAI,eAAe,KAAK,CAAAE,MAAKA,EAAE,SAASJ,CAAc;AAC3E,UAAIG,EAAc,QAAO,EAAE,cAAAA,GAAc,KAAAD,EAAA;AAAA,IAC3C;AAIA,WAAO,EAAE,cAAc,MAAM,KADTD,IAASF,EAAK,KAAK,OAAKM,EAAE,SAASJ,CAAK,KAAK,OAAQ,KACvC;AAAA,EACpC;AACA,SAAIA,IAAc,EAAE,cAAc,MAAM,KAAKF,EAAK,KAAK,CAAAM,MAAKA,EAAE,SAASJ,CAAK,KAAK,KAAA,IAC1E,EAAE,cAAc,MAAM,KAAK,KAAA;AACpC;AAEA,SAASK,GAAsBP,GAAgD;AAC7E,MAAI,CAACA,EAAM,QAAO;AAClB,aAAWG,KAAOH,GAAM;AACtB,QAAI,CAACG,EAAI,QAAS;AAClB,UAAMC,IAAeD,EAAI,eAAe,KAAK,OAAKE,EAAE,SAASF,EAAI,uBAAuB;AACxF,QAAIC,GAAc,WAAY,QAAOA,EAAa;AAAA,EACpD;AACA,SAAO;AACT;AAEA,SAASI,GAAwB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/E,eACErG,KAA8ByD,KAC1B6C,KACA;AAAA,QACN,eAAezF,IAAyB0F,KAAqB;AAAA,MAAA;AAAA,MAE/D,gBAAAxB;AAAA,MACA,mBAAAgB;AAAA,MACA,yBAAyBS,GAA8BxD,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useCompensationForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsCreateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWages } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n createCompensationSchema,\n type CompensationOptionalFieldsToRequire,\n type CompensationFormData,\n type CompensationFormOutputs,\n} from './compensationSchema'\nimport {\n TitleField,\n FlsaStatusField,\n RateField,\n PaymentUnitField,\n AdjustForMinimumWageField,\n MinimumWageIdField,\n EffectiveDateField,\n} from './fields'\nimport type {\n TitleFieldProps,\n FlsaStatusFieldProps,\n RateFieldProps,\n PaymentUnitFieldProps,\n AdjustForMinimumWageFieldProps,\n MinimumWageIdFieldProps,\n EffectiveDateFieldProps,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { withFlags } from '@/partner-hook-utils/form/withFlags'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\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 { FlsaStatus, PAY_PERIODS, TIP_CREDITS_UNSUPPORTED_STATES } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { addDays, formatDateToStringDate } from '@/helpers/dateFormatting'\n\n/**\n * Optional values supplied to {@link useCompensationForm}'s `actions.onSubmit` at submit time.\n *\n * @remarks\n * Use these to override hook-construction props when an ID isn't known at\n * mount — most commonly the **onboarding stub-fill** chain, where `useJobForm`\n * creates the parent job and returns the auto-created stub compensation, and\n * the IDs and version are threaded into this hook's `onSubmit` to PUT the\n * stub.\n *\n * @public\n */\nexport interface CompensationSubmitOptions {\n /** Override jobId — required when creating a compensation if not configured at hook construction (e.g. when the parent job was just created in the same submit chain). */\n jobId?: string\n /** Override compensationId — when present, forces update (PUT) routing regardless of hook construction. */\n compensationId?: string\n /**\n * Compensation version for optimistic locking on PUT. Required when forcing\n * update routing post-create (e.g. updating the auto-created stub returned\n * from `POST /v1/employees/:id/jobs`). When omitted, the hook reads the\n * version from its cached `currentCompensation`.\n */\n compensationVersion?: string\n /**\n * Supply `effectiveDate` at submit time. When `withEffectiveDateField`\n * is `true`, this overrides the form's value. When `withEffectiveDateField`\n * is `false`, this is the only way to put `effective_date` on the wire —\n * the form value is not read in that mode (matching the options-only\n * convention of `useWorkAddressForm` / `useHomeAddressForm` / `useJobForm`).\n */\n effectiveDate?: string\n}\n\n/**\n * Configuration options for {@link useCompensationForm}.\n *\n * @remarks\n * Presence or absence of `compensationId` selects the API verb — see the\n * `compensationId` field description. `employeeId` is optional so the hook\n * can be composed alongside an employee-creation step. `jobId` is optional in\n * update mode (derived from the loaded compensation) and required in create\n * mode (scopes the POST); supply it at submit time via\n * {@link CompensationSubmitOptions.jobId} when the parent job is created in\n * the same submit chain.\n *\n * @public\n */\nexport interface UseCompensationFormProps {\n /** UUID of the employee whose compensation is being created or edited. Drives data fetching for derived helpers (jobs list, work address, minimum wages). May be omitted when composing alongside an employee-creation step. */\n employeeId?: string\n /** The parent job's UUID. Required in create mode (scopes `POST /v1/jobs/:jobId/compensations`). Optional in update mode — the parent job is derived from the loaded compensation. */\n jobId?: string\n /** Present → update mode (PUT /v1/compensations/:id). Omitted → create mode (POST /v1/jobs/:jobId/compensations). */\n compensationId?: string\n /** Override fields that are optional on a given mode to be required. See {@link CompensationOptionalFieldsToRequire}. */\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update mode. */\n defaultValues?: Partial<CompensationFormData>\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.EffectiveDate` (becomes `undefined`) and\n * removes `effectiveDate` from schema validation. In this mode the hook\n * does not read any form value at submit time — `effective_date` is\n * omitted from the request body unless explicitly supplied via\n * {@link CompensationSubmitOptions.effectiveDate}. This matches the\n * options-only convention of other form hooks, and means the\n * `willDeleteSecondaryJobs` carve-out's form-state side effects do not\n * leak onto the wire (there is no field to render them in anyway).\n * Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `useCompensationForm().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.FlsaStatus && <Fields.FlsaStatus ... />}`) before rendering.\n *\n * @public\n */\nexport interface CompensationFormFields {\n /** Bound to `title`. Title text input. Always available. Optional in both modes unless `optionalFieldsToRequire` requires it. */\n Title: ComponentType<TitleFieldProps>\n /** Bound to `flsaStatus`. FLSA classification select. `undefined` when the status is not user-editable (e.g. secondary jobs that must match the primary). */\n FlsaStatus: ComponentType<FlsaStatusFieldProps> | undefined\n /** Bound to `rate`. Compensation amount input. `undefined` for commission-only FLSA statuses, which don't accept a partner-supplied rate. */\n Rate: ComponentType<RateFieldProps> | undefined\n /** Bound to `paymentUnit`. Payment unit select. `undefined` for commission-only FLSA statuses (the hook forces `paymentUnit=Year`). */\n PaymentUnit: ComponentType<PaymentUnitFieldProps> | undefined\n /** Bound to `adjustForMinimumWage`. Minimum-wage adjustment checkbox. `undefined` unless `flsaStatus === Nonexempt`, the employee's work location has minimum wages, and the state supports tip credits. */\n AdjustForMinimumWage: ComponentType<AdjustForMinimumWageFieldProps> | undefined\n /** Bound to `minimumWageId`. Minimum-wage selection. `undefined` unless `Fields.AdjustForMinimumWage` is rendered and checked. */\n MinimumWageId: ComponentType<MinimumWageIdFieldProps> | undefined\n /** Bound to `effectiveDate`. Effective-date picker. `undefined` when `withEffectiveDateField: false`; supply the value via `CompensationSubmitOptions.effectiveDate` in that mode. */\n EffectiveDate: ComponentType<EffectiveDateFieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link useCompensationForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the compensation-specific `data`, `status`, `actions`, and `form.Fields`\n * shape. Static, entity-derived values live under `data.*`; reactive values\n * that flip with form input live under `status.*`.\n *\n * @public\n */\nexport interface UseCompensationFormReady extends BaseFormHookReady<\n CompensationFieldsMetadata,\n CompensationFormData,\n CompensationFormFields\n> {\n /** Compensation-specific data payload: the loaded compensation, the parent job, available minimum wages, and effective-date bounds. */\n data: {\n /** The compensation row loaded for update; `null` in create mode. */\n compensation: Compensation | null\n /** The parent job. In update mode it's derived from the loaded compensation; in create mode it's looked up by `jobId`. `null` if neither resolves. */\n currentJob: Job | null\n /** Minimum wages available at the employee's active work location. Empty when no location is set or no minimums are defined. */\n minimumWages: MinimumWage[]\n /** Lower bound for `effectiveDate` (typically the parent job's hire date). */\n minimumEffectiveDate: string | null\n /** Upper bound for `effectiveDate` — the next scheduled future compensation's effective date, when one exists. */\n maximumEffectiveDate: string | null\n /** True when at least one future-dated compensation already exists for this job. */\n hasPendingFutureCompensation: boolean\n }\n /** Submission state and reactive flags derived from current form input. `isPending` is `true` while a create/update mutation is in flight; `mode` reflects whether the next submit will create or update; the `show*Alert` flags drive FLSA-specific inline warnings. */\n status: {\n /** `true` while a create or update mutation is in flight. */\n isPending: boolean\n /** Reflects whether the next submit will POST a new compensation or PUT an existing one. */\n mode: 'create' | 'update'\n /**\n * True when submitting the form right now would delete the employee's\n * secondary jobs server-side (the \"carve-out\" branch). Reactive:\n * derived from the current `flsaStatus` form value, the loaded\n * compensation, and the other-jobs count, so this flips as you change\n * inputs.\n *\n * Conditions: update mode, the loaded compensation is Nonexempt, the\n * form's `flsaStatus` has been changed to a non-Nonexempt value, and\n * the employee has at least one secondary job.\n *\n * While this flag is true the hook also takes the `effectiveDate`\n * field over: it forces the form value to today (so submits route\n * through a PUT that immediately deletes secondaries) and exposes\n * `fieldsMetadata.effectiveDate.isDisabled = true` so `Fields.EffectiveDate`\n * renders as disabled. On revert (FLSA back to Nonexempt) the prior\n * `effectiveDate` is restored. Render an inline warning keyed off\n * this flag — no separate confirmation step is needed.\n */\n willDeleteSecondaryJobs: boolean\n /**\n * True when the current `flsaStatus` is `COMMISSION_ONLY_EXEMPT`\n * (Commission Only/No Overtime). Render the federal-minimum-pay\n * warning alert when this flag is true. While this flag is true,\n * `Fields.Rate` and `Fields.PaymentUnit` are also `undefined` (the\n * hook forces `rate=0`, `paymentUnit=YEAR` on the form values).\n */\n showCommissionFederalMinimumPayAlert: boolean\n /**\n * True when the current `flsaStatus` is `COMMISSION_ONLY_NONEXEMPT`\n * (Commission Only/Eligible for overtime). Render the local-minimum-wage\n * warning alert when this flag is true. While this flag is true,\n * `Fields.Rate` and `Fields.PaymentUnit` are also `undefined` (the\n * hook forces `rate=0`, `paymentUnit=YEAR` on the form values).\n */\n showCommissionMinimumWageAlert: boolean\n /**\n * True when the current `flsaStatus` is `OWNER` (Owner's draw). Render\n * an informational alert noting that the IRS requires S-corp owners to\n * pay themselves a reasonable salary for similar work before taking\n * distributions.\n */\n showOwnerSalaryAlert: boolean\n }\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 compensation. Resolves to `undefined` on validation failure or mutation error. Accepts {@link CompensationSubmitOptions} for threading IDs/version into the onboarding stub-fill chain. */\n onSubmit: (\n options?: CompensationSubmitOptions,\n ) => Promise<HookSubmitResult<Compensation> | undefined>\n }\n}\n\nfunction resolveCompAndJob(\n jobs: Job[] | undefined,\n compensationId: string | undefined,\n jobId: string | undefined,\n): { compensation: Compensation | null; job: Job | null } {\n if (!jobs) return { compensation: null, job: null }\n if (compensationId) {\n for (const job of jobs) {\n const compensation = job.compensations?.find(c => c.uuid === compensationId)\n if (compensation) return { compensation, job }\n }\n // If the comp isn't in any job's compensations list, still try to resolve\n // the job by jobId so callers can check job metadata (e.g. job.primary).\n const fallbackJob = jobId ? (jobs.find(j => j.uuid === jobId) ?? null) : null\n return { compensation: null, job: fallbackJob }\n }\n if (jobId) return { compensation: null, job: jobs.find(j => j.uuid === jobId) ?? null }\n return { compensation: null, job: null }\n}\n\nfunction findPrimaryFlsaStatus(jobs: Job[] | undefined): FlsaStatusType | null {\n if (!jobs) return null\n for (const job of jobs) {\n if (!job.primary) continue\n const compensation = job.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n if (compensation?.flsaStatus) return compensation.flsaStatus\n }\n return null\n}\n\nfunction findFutureCompensations(job: Job | null): Compensation[] {\n if (!job?.compensations) return []\n const today = todayISO()\n return job.compensations.filter(c => c.effectiveDate !== undefined && c.effectiveDate > today)\n}\n\nfunction earliestEffectiveDate(comps: Compensation[]): string | null {\n if (comps.length === 0) return null\n return comps.reduce<string | null>((min, c) => {\n const d = c.effectiveDate\n if (!d) return min\n if (!min || d < min) return d\n return min\n }, null)\n}\n\nconst flsaStatusEntries: FlsaStatusType[] = [\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n]\n\nconst flsaOptions = flsaStatusEntries.map(status => ({ value: status, label: status }))\n\nconst paymentUnitEntries: PaymentUnit[] = [\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n]\n\nconst paymentUnitOptions = paymentUnitEntries.map(unit => ({ value: unit, label: unit }))\n\nfunction todayISO(): string {\n return new Date().toISOString().split('T')[0]!\n}\n\n/** @internal */\nfunction buildCompensationFieldsMetadata(\n base: Record<keyof CompensationFormData, FieldMetadata>,\n {\n willDeleteSecondaryJobs,\n isCreateMode,\n isCommissionOnly,\n isOwner,\n isAdjustMinimumWageEnabled,\n effectiveDateMinDate,\n maximumEffectiveDate,\n minimumWageOptions,\n minimumWages,\n }: {\n willDeleteSecondaryJobs: boolean\n isCreateMode: boolean\n isCommissionOnly: boolean\n isOwner: boolean\n isAdjustMinimumWageEnabled: boolean\n effectiveDateMinDate: string | null\n maximumEffectiveDate: string | null\n minimumWageOptions: { value: string; label: string }[]\n minimumWages: MinimumWage[]\n },\n) {\n return {\n title: base.title,\n effectiveDate: withFlags(base.effectiveDate, {\n isDisabled: willDeleteSecondaryJobs && !isCreateMode,\n minDate: effectiveDateMinDate,\n maxDate: maximumEffectiveDate,\n }),\n flsaStatus: withOptions<FlsaStatusType>(base.flsaStatus, flsaOptions, flsaStatusEntries),\n rate: withFlags(base.rate, { isDisabled: isCommissionOnly }),\n paymentUnit: withOptions<PaymentUnit>(\n withFlags(base.paymentUnit, { isDisabled: isOwner || isCommissionOnly }),\n paymentUnitOptions,\n paymentUnitEntries,\n ),\n adjustForMinimumWage: withFlags(base.adjustForMinimumWage, {\n isDisabled: !isAdjustMinimumWageEnabled,\n }),\n minimumWageId: withOptions<MinimumWage>(base.minimumWageId, minimumWageOptions, minimumWages),\n } satisfies FieldsMetadata\n}\n\n/**\n * Headless hook for creating or updating a compensation row on a job — FLSA classification, pay rate, payment unit, effective date, and optional minimum-wage adjustment.\n *\n * @remarks\n * Companion hook to `useJobForm`. Jobs and their compensations are separate\n * entities in the Gusto API and this hook focuses exclusively on the\n * compensation side. Presence of `compensationId` selects the verb:\n *\n * | Hook config / submit options | Mode | API call |\n * | ---------------------------- | ---- | -------- |\n * | `{ jobId, compensationId }` | update | `PUT /v1/compensations/:compensationId` (with `version`) |\n * | `{ jobId }` (no `compensationId`) | create | `POST /v1/jobs/:jobId/compensations` |\n * | `{ employeeId }` + submit `{ jobId, compensationId, compensationVersion }` | update | `PUT /v1/compensations/:compensationId` (with the supplied `version`) |\n * | `{ employeeId }` + submit `{ jobId }` (no `compensationId`) | create | `POST /v1/jobs/:options.jobId/compensations` |\n *\n * Use the submit-options form for the **onboarding stub-fill** chain: after\n * `useJobForm.actions.onSubmit()` creates a job, capture the auto-created\n * compensation's UUID and version from the response, and pass them as\n * `{ jobId, compensationId, compensationVersion }` to this hook's `onSubmit`\n * to PUT the stub.\n *\n * The hook exposes several derived helpers for driving UX — static\n * entity-derived values under `data.*` (effective-date bounds, pending\n * future compensations) and reactive flags under `status.*` (the\n * `willDeleteSecondaryJobs` carve-out, plus FLSA-specific alerts for\n * commission-only and owner classifications). When\n * `willDeleteSecondaryJobs` is `true` in update mode, the hook also locks\n * the `effectiveDate` field (forces to today, renders disabled) until the\n * FLSA selection is reverted.\n *\n * @param input - {@link UseCompensationFormProps} — `employeeId`, `jobId`, `compensationId` (toggle create/update), required-field overrides, default values, and which fields the hook renders.\n * @returns A {@link HookLoadingResult} while data is loading, or a {@link UseCompensationFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import { useCompensationForm, SDKFormProvider } from '@gusto/embedded-react-sdk'\n *\n * function CompensationForm({ employeeId, jobId }: { employeeId: string; jobId: string }) {\n * const comp = useCompensationForm({ employeeId, jobId })\n * if (comp.isLoading) return null\n *\n * const { Fields } = comp.form\n * return (\n * <form onSubmit={e => { e.preventDefault(); comp.actions.onSubmit() }}>\n * <SDKFormProvider formHookResult={comp}>\n * {Fields.FlsaStatus && <Fields.FlsaStatus label=\"Employee type\" />}\n * <Fields.Rate label=\"Compensation amount\" />\n * <Fields.PaymentUnit label=\"Payment unit\" />\n * {Fields.EffectiveDate && <Fields.EffectiveDate label=\"Effective date\" />}\n * </SDKFormProvider>\n * {comp.status.willDeleteSecondaryJobs && (\n * <p>Saving will remove this employee's secondary jobs.</p>\n * )}\n * <button type=\"submit\" disabled={comp.status.isPending}>Save</button>\n * </form>\n * )\n * }\n * ```\n */\nexport function useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withEffectiveDateField = true,\n}: UseCompensationFormProps): HookLoadingResult | UseCompensationFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n {\n employeeId: employeeId ?? '',\n // Fetch all effective-dated compensations when editing an existing one so\n // resolveCompAndJob can find the target comp (future-dated comps are\n // omitted from the default response, which only returns the current comp).\n include: compensationId\n ? GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations\n : undefined,\n },\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)\n const locationUuid = currentWorkAddress?.locationUuid\n const employee = employeeQuery.data?.employeeShow\n\n const minWagesQuery = useLocationsGetMinimumWages(\n { locationUuid: locationUuid ?? '' },\n { enabled: !!locationUuid, staleTime: Infinity },\n )\n\n const minimumWages = minWagesQuery.data?.minimumWageList ?? []\n\n const { compensation: currentCompensation, job: currentJob } = resolveCompAndJob(\n employeeJobs,\n compensationId,\n jobId,\n )\n\n const otherJobsCount =\n employeeJobs && currentJob ? employeeJobs.filter(j => j.uuid !== currentJob.uuid).length : 0\n\n // Snapshot — written exactly once, on the first render where `employeeJobs`\n // is defined (i.e., the initial `getJobs` query has resolved) — capturing\n // whether the employee already had a primary job at that moment.\n //\n // Used to ignore the API-generated stub primary (FLSA Nonexempt, rate \"0.00\")\n // that briefly appears between the chained job POST and comp PUT during\n // onboarding: `getJobs` invalidates between the two mutations and\n // momentarily includes the stub, which would otherwise flip\n // `isAddingSecondaryJob` to true and hide `Fields.FlsaStatus` mid-submit.\n //\n // In steady-state flows (edit primary, edit secondary, add secondary), the\n // real primary already exists when the query first resolves, so the snapshot\n // is `true` and live `employeeJobs` continues to drive `primaryFlsaStatus`.\n // Recovery for the rare case where a partner mounts before any jobs exist\n // and a primary is created externally mid-form is to remount the hook\n // (e.g., via a `key` change).\n const hadPrimaryAtMountRef = useRef<boolean | null>(null)\n if (hadPrimaryAtMountRef.current === null && employeeJobs !== undefined) {\n hadPrimaryAtMountRef.current = employeeJobs.some(job => job.primary)\n }\n const hadPrimaryAtMount = hadPrimaryAtMountRef.current === true\n\n // FLSA status of the employee's primary job's current compensation, when one\n // exists. Used as a fallback default when adding a *secondary* job/comp so the\n // multi-job classification stays consistent with the primary by default — the\n // user can still override it (when allowed). Null when there was no primary\n // job at the moment the hook first observed `employeeJobs`, or when the\n // primary has no current compensation yet.\n const primaryFlsaStatus = hadPrimaryAtMount ? findPrimaryFlsaStatus(employeeJobs) : null\n\n const hireDate =\n currentJob?.hireDate ??\n // Secondary jobs being created (CompensationAddAnotherJobForm) have no hireDate until the\n // job POST completes. Fall back to the primary job's hireDate so the schema\n // can enforce EFFECTIVE_DATE_BEFORE_HIRE during that window.\n employeeJobs?.find(j => j.primary)?.hireDate ??\n null\n\n // In update mode, exclude the compensation being edited so it doesn't\n // bound `maximumEffectiveDate` to its own current date — that would prevent\n // the user from pushing the pending effective date further out.\n const futureCompensations = findFutureCompensations(currentJob).filter(\n c => c.uuid !== compensationId,\n )\n const hasPendingFutureCompensation = futureCompensations.length > 0\n const maximumEffectiveDate = earliestEffectiveDate(futureCompensations)\n\n const isCreateMode = !compensationId\n const mode = isCreateMode ? 'create' : 'update'\n // Adding a secondary job (the employee already has a primary). The Gusto API\n // only allows secondaries when the primary's current FLSA is Nonexempt, and\n // the secondary itself must match — so the FLSA field is not user-editable\n // in this branch. We force the form value to the primary's FLSA below and\n // hide `Fields.FlsaStatus`.\n // True when adding a brand-new secondary job (not when scheduling a future\n // comp for the primary). The distinction matters: for the primary's future\n // comp, FLSA should be editable; for a secondary, it must match the primary.\n const isAddingSecondaryJob =\n isCreateMode && primaryFlsaStatus === FlsaStatus.NONEXEMPT && currentJob?.primary !== true\n\n // Derive the effective-date floor internally so consumers don't need to wire\n // it up. Rules by mode and job type:\n // create (any job): tomorrow — new comp must be future-dated\n // update, primary: undefined — the carve-out (willDeleteSecondaryJobs) can\n // force effectiveDate to today on a disabled field; enforcing a floor here\n // would produce a spurious EFFECTIVE_DATE_BEFORE_MIN on submit.\n // update, secondary: tomorrow — must be in the future\n // The hire-date lower bound is handled separately in the schema via the\n // `hireDate` option (→ EFFECTIVE_DATE_BEFORE_HIRE), which fires alongside\n // this check so each violation gets its own error message.\n const internalMinEffectiveDate = useMemo(() => {\n if (!withEffectiveDateField) return undefined\n if (!isCreateMode && currentJob?.primary === true) return undefined\n\n return formatDateToStringDate(addDays(new Date(), 1)) ?? undefined\n }, [isCreateMode, currentJob?.primary, withEffectiveDateField])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createCompensationSchema({\n mode,\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate: internalMinEffectiveDate,\n withEffectiveDateField,\n }),\n [mode, optionalFieldsToRequire, hireDate, internalMinEffectiveDate, withEffectiveDateField],\n )\n\n const state = currentWorkAddress?.state\n\n // `flsaStatus` is intentionally allowed to be undefined so the field renders\n // an empty placeholder when nothing is provided — partners can choose to\n // seed it via `defaultValues.flsaStatus`. When a `compensation` is loaded we\n // seed from it; for a brand-new secondary job we inherit from the primary's\n // current compensation so multi-job classification stays consistent. The\n // schema enforces requiredness on submit in `create` mode (see\n // `requiredFieldsConfig` in compensationSchema.ts).\n //\n // `title` lives on compensation in the API — `job.title` is a denormalized\n // snapshot of the primary comp's title that can lag behind comp-level edits\n // on secondaries. Seed directly from the loaded compensation so editing in\n // place can't silently re-introduce a stale title from the job record.\n const resolvedDefaults: CompensationFormData = useMemo(\n () => ({\n title: currentCompensation?.title ?? partnerDefaults?.title ?? '',\n // When adding a secondary, the FLSA must match the primary's — force it\n // here (overriding any partner default) so the form submits the right\n // value even though `Fields.FlsaStatus` is hidden.\n flsaStatus: isAddingSecondaryJob\n ? primaryFlsaStatus\n : (currentCompensation?.flsaStatus ??\n partnerDefaults?.flsaStatus ??\n primaryFlsaStatus ??\n undefined),\n rate: Number(currentCompensation?.rate ?? partnerDefaults?.rate ?? 0),\n adjustForMinimumWage:\n currentCompensation?.adjustForMinimumWage ?? partnerDefaults?.adjustForMinimumWage ?? false,\n minimumWageId:\n currentCompensation?.minimumWages?.[0]?.uuid ?? partnerDefaults?.minimumWageId ?? '',\n paymentUnit:\n currentCompensation?.paymentUnit ?? partnerDefaults?.paymentUnit ?? PAY_PERIODS.HOUR,\n effectiveDate: currentCompensation?.effectiveDate ?? partnerDefaults?.effectiveDate ?? null,\n }),\n [currentCompensation, currentJob, partnerDefaults, primaryFlsaStatus, isAddingSecondaryJob],\n )\n\n const formMethods = useForm<CompensationFormData, unknown, CompensationFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const { control, getValues, setValue, clearErrors } = formMethods\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedAdjustForMinimumWage = useWatch({\n control,\n name: 'adjustForMinimumWage',\n })\n\n // Validation rules for `paymentUnit` and `rate` are FLSA-driven, so any\n // prior error on those fields is stale once FLSA changes. RHF doesn't clear\n // them on its own (`setValue` without `shouldValidate` skips the resolver,\n // and reValidate is per-field) — clear eagerly and let the next blur/submit\n // re-establish the error if it still applies.\n useEffect(() => {\n clearErrors(['paymentUnit', 'rate'])\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', PAY_PERIODS.PAYCHECK)\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', PAY_PERIODS.YEAR)\n setValue('rate', 0)\n } else {\n setValue('paymentUnit', resolvedDefaults.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, clearErrors, resolvedDefaults.paymentUnit])\n\n // The FLSA status that represents the employee's current classification.\n // In update mode this is the compensation being edited. In create mode\n // `currentCompensation` is null, so fall back to the job's active\n // compensation (identified by currentCompensationUuid) — this lets the\n // secondary-job warning fire even when scheduling a future-dated change.\n const currentJobActiveComp = currentJob\n ? currentJob.compensations?.find(c => c.uuid === currentJob.currentCompensationUuid)\n : undefined\n const effectiveBaseFlsaStatus =\n currentCompensation?.flsaStatus ?? currentJobActiveComp?.flsaStatus ?? null\n\n // True when the user is changing FLSA away from Nonexempt on a job that has\n // secondary jobs — those secondaries will be deleted by the API when the\n // new classification takes effect (immediately in update mode, at the chosen\n // effective date in create mode). Drives the warning and, in update mode\n // only, the effectiveDate-lock side effect below.\n const willDeleteSecondaryJobs =\n effectiveBaseFlsaStatus === FlsaStatus.NONEXEMPT &&\n watchedFlsaStatus !== undefined &&\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT &&\n otherJobsCount > 0\n\n // Carve-out UX — update mode only: while willDeleteSecondaryJobs is active\n // the server deletes secondaries immediately on PUT. Mirror this by forcing\n // `effectiveDate` to today and disabling the field. In create mode the\n // deletion happens at the chosen future date, so we show the warning but\n // leave the date field editable.\n const carveOutActiveRef = useRef(false)\n const priorEffectiveDateRef = useRef<string | null>(null)\n useEffect(() => {\n if (!isCreateMode && willDeleteSecondaryJobs && !carveOutActiveRef.current) {\n priorEffectiveDateRef.current = getValues('effectiveDate') ?? null\n setValue('effectiveDate', todayISO(), { shouldDirty: true, shouldValidate: false })\n carveOutActiveRef.current = true\n } else if (!isCreateMode && !willDeleteSecondaryJobs && carveOutActiveRef.current) {\n setValue('effectiveDate', priorEffectiveDateRef.current ?? null, {\n shouldDirty: true,\n shouldValidate: false,\n })\n priorEffectiveDateRef.current = null\n carveOutActiveRef.current = false\n }\n }, [isCreateMode, willDeleteSecondaryJobs, getValues, setValue])\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation()\n const createCompensationMutation = useJobsAndCompensationsCreateCompensationMutation()\n\n const isPending = updateCompensationMutation.isPending || createCompensationMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('CompensationForm')\n\n const queriesForErrors = employeeId\n ? [jobsQuery, addressesQuery, employeeQuery, minWagesQuery]\n : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const isCommissionOnly =\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n const isOwner = watchedFlsaStatus === FlsaStatus.OWNER\n\n // Hide `Fields.FlsaStatus` when the user has no meaningful choice:\n // - update mode editing a secondary whose comp is already Nonexempt\n // (must keep matching the primary), and\n // - create mode while adding a secondary (must inherit primary's FLSA).\n // The first job's create flow and primary-job edits keep the field exposed.\n const isFlsaSelectionEnabled =\n !isAddingSecondaryJob &&\n (watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary === true || isCreateMode)\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n // Min-wage adjustment is only valid for Nonexempt FLSA (and a state that\n // allows tip credit). When the gate flips off — typically because the user\n // changed FLSA away from Nonexempt — `Fields.AdjustForMinimumWage` and\n // `Fields.MinimumWageId` stop rendering, but the underlying form values\n // persist in react-hook-form state. That would leak an\n // `adjust_for_minimum_wage: true` + `minimum_wages: [...]` body on submit\n // (server rejects with \"Minimum wage adjustments only valid for\n // flsa_status: Nonexempt\"). Reset both values to safe defaults so the\n // submitted payload always matches what the user can actually see.\n useEffect(() => {\n if (isAdjustMinimumWageEnabled) return\n if (getValues('adjustForMinimumWage')) {\n setValue('adjustForMinimumWage', false, { shouldDirty: true, shouldValidate: false })\n }\n if (getValues('minimumWageId')) {\n setValue('minimumWageId', '', { shouldDirty: true, shouldValidate: false })\n }\n // Both fields stop rendering once the gate closes — clear errors so a\n // stale one doesn't silently fail the next submit with no visible UI to fix.\n clearErrors(['adjustForMinimumWage', 'minimumWageId'])\n }, [isAdjustMinimumWageEnabled, getValues, setValue, clearErrors])\n\n const minimumWageOptions = minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${wage.wage} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const effectiveDateMinDate = useMemo(\n () =>\n [internalMinEffectiveDate, hireDate]\n .filter((d): d is string => !!d)\n .reduce<string | null>((max, d) => (!max || d > max ? d : max), null),\n [internalMinEffectiveDate, hireDate],\n )\n const fieldsMetadata = buildCompensationFieldsMetadata(baseMetadata, {\n willDeleteSecondaryJobs,\n isCreateMode,\n isCommissionOnly,\n isOwner,\n isAdjustMinimumWageEnabled,\n effectiveDateMinDate,\n maximumEffectiveDate,\n minimumWageOptions,\n minimumWages,\n })\n\n const onSubmit = async (\n options?: CompensationSubmitOptions,\n ): Promise<HookSubmitResult<Compensation> | undefined> => {\n let submitResult: HookSubmitResult<Compensation> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: CompensationFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedJobId = options?.jobId ?? jobId\n const resolvedCompensationId = options?.compensationId ?? compensationId\n const resolvedMode = resolvedCompensationId ? 'update' : 'create'\n\n // When the field is rendered, the validated payload value wins\n // unless an explicit submit-time override is supplied. When the\n // field is hidden (`withEffectiveDateField: false`) we are\n // strictly options-only — matching `useWorkAddressForm` and the\n // hidden-field behavior of `useHomeAddressForm` / `useJobForm`.\n // The carve-out's form-state side effect (force value to today)\n // is therefore inert in the hidden-field path; partners who\n // need a specific date there must supply it via\n // `CompensationSubmitOptions.effectiveDate`.\n const resolvedEffectiveDate = withEffectiveDateField\n ? (options?.effectiveDate ?? payload.effectiveDate ?? undefined)\n : (options?.effectiveDate ?? undefined)\n\n const requestBodyBase = {\n rate: String(payload.rate),\n paymentUnit: payload.paymentUnit,\n flsaStatus: payload.flsaStatus,\n effectiveDate: resolvedEffectiveDate,\n title: payload.title || undefined,\n adjustForMinimumWage: payload.adjustForMinimumWage,\n minimumWages: payload.adjustForMinimumWage ? [{ uuid: payload.minimumWageId }] : [],\n }\n\n let result: Compensation | undefined\n\n if (resolvedMode === 'create') {\n if (!resolvedJobId) {\n throw new SDKInternalError(\n 'jobId is required to create a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n // Schema's `requiredFieldsConfig` guarantees `flsaStatus` is set\n // on create-mode submit; the runtime guard appeases the API\n // request-body type (which requires a non-undefined value on\n // POST, vs. the optional PUT body).\n if (!payload.flsaStatus) {\n throw new SDKInternalError('flsaStatus is required to create a compensation.')\n }\n const createResponse = await createCompensationMutation.mutateAsync({\n request: {\n jobId: resolvedJobId,\n compensationsRequestBody: { ...requestBodyBase, flsaStatus: payload.flsaStatus },\n },\n })\n result = createResponse.compensation\n if (!result) throw new SDKInternalError('Compensation creation failed')\n } else {\n if (!resolvedCompensationId) {\n throw new SDKInternalError(\n 'compensationId is required to update a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n const resolvedVersion =\n options?.compensationVersion ?? (currentCompensation?.version as string | undefined)\n if (!resolvedVersion) {\n throw new SDKInternalError(\n 'compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded.',\n )\n }\n const updateResponse = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: resolvedCompensationId,\n compensationsUpdateRequestBody: {\n version: resolvedVersion,\n ...requestBodyBase,\n },\n },\n })\n result = updateResponse.compensation\n if (!result) throw new SDKInternalError('Compensation update failed')\n }\n\n submitResult = { mode: resolvedMode, data: result }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading ||\n addressesQuery.isLoading ||\n employeeQuery.isLoading ||\n minWagesQuery.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 compensation: currentCompensation,\n currentJob,\n minimumWages,\n minimumEffectiveDate: effectiveDateMinDate,\n maximumEffectiveDate,\n hasPendingFutureCompensation,\n },\n status: {\n isPending,\n mode,\n willDeleteSecondaryJobs,\n showCommissionFederalMinimumPayAlert: watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT,\n showCommissionMinimumWageAlert: watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n showOwnerSalaryAlert: watchedFlsaStatus === FlsaStatus.OWNER,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: TitleField,\n FlsaStatus: isFlsaSelectionEnabled ? FlsaStatusField : undefined,\n Rate: isCommissionOnly ? undefined : RateField,\n PaymentUnit: isCommissionOnly ? undefined : PaymentUnitField,\n AdjustForMinimumWage: isAdjustMinimumWageEnabled ? AdjustForMinimumWageField : undefined,\n MinimumWageId:\n isAdjustMinimumWageEnabled && watchedAdjustForMinimumWage\n ? MinimumWageIdField\n : undefined,\n EffectiveDate: withEffectiveDateField ? EffectiveDateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link useCompensationForm} — either the loading state or the ready state.\n *\n * @remarks\n * Use this type when threading the hook result through helpers (e.g.\n * presentational components). Discriminate on `isLoading` to narrow to\n * {@link UseCompensationFormReady}.\n *\n * @public\n */\nexport type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady\n\n/**\n * Metadata for each {@link useCompensationForm} field, exposed on `form.fieldsMetadata`.\n *\n * @remarks\n * Includes per-field `isDisabled`, `isRequired`, and the dynamic option list\n * for select fields (`flsaStatus`, `paymentUnit`, `minimumWageId`).\n * `effectiveDate` additionally carries `minDate` / `maxDate` derived from\n * the parent job's hire date and any pending future compensation.\n *\n * @public\n */\nexport type CompensationFieldsMetadata = ReturnType<typeof buildCompensationFieldsMetadata>\n"],"names":["resolveCompAndJob","jobs","compensationId","jobId","job","compensation","c","j","findPrimaryFlsaStatus","findFutureCompensations","today","todayISO","earliestEffectiveDate","comps","min","d","flsaStatusEntries","FlsaStatus","flsaOptions","status","paymentUnitEntries","PAY_PERIODS","paymentUnitOptions","unit","buildCompensationFieldsMetadata","base","willDeleteSecondaryJobs","isCreateMode","isCommissionOnly","isOwner","isAdjustMinimumWageEnabled","effectiveDateMinDate","maximumEffectiveDate","minimumWageOptions","minimumWages","withFlags","withOptions","useCompensationForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withEffectiveDateField","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","locationUuid","employee","minWagesQuery","useLocationsGetMinimumWages","currentCompensation","currentJob","otherJobsCount","hadPrimaryAtMountRef","useRef","primaryFlsaStatus","hireDate","futureCompensations","hasPendingFutureCompensation","mode","isAddingSecondaryJob","internalMinEffectiveDate","useMemo","formatDateToStringDate","addDays","schema","metadataConfig","createCompensationSchema","state","resolvedDefaults","formMethods","useForm","zodResolver","control","getValues","setValue","clearErrors","watchedFlsaStatus","useWatch","watchedAdjustForMinimumWage","useEffect","currentJobActiveComp","carveOutActiveRef","priorEffectiveDateRef","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","createCompensationMutation","useJobsAndCompensationsCreateCompensationMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","isFlsaSelectionEnabled","TIP_CREDITS_UNSUPPORTED_STATES","wage","baseMetadata","useDeriveFieldsMetadata","max","fieldsMetadata","onSubmit","options","submitResult","resolve","data","payload","resolvedJobId","resolvedCompensationId","resolvedMode","resolvedEffectiveDate","requestBodyBase","result","SDKInternalError","resolvedVersion","isDataLoading","hookFormInternals","useHookFormInternals","TitleField","FlsaStatusField","RateField","PaymentUnitField","AdjustForMinimumWageField","MinimumWageIdField","Effective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AA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMY,KAAgBtF,IAClBM,EAAU,aACVG,EAAe,aACfE,EAAc,aACdO,EAAc,YACd,IAEEqE,KAAoBC,GAAqBhD,CAAW;AAE1D,SAAI8C,MAAkBtF,MAAe,CAACa,KAAgB,CAACI,MAC9C,EAAE,WAAW,IAAe,eAAA8C,GAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,cAAc3C;AAAA,MACd,YAAAC;AAAA,MACA,cAAAzB;AAAA,MACA,sBAAsBH;AAAA,MACtB,sBAAAC;AAAA,MACA,8BAAAkC;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAA8B;AAAA,MACA,MAAA7B;AAAA,MACA,yBAAAzC;AAAA,MACA,sCAAsC2D,MAAsBpE,EAAW;AAAA,MACvE,gCAAgCoE,MAAsBpE,EAAW;AAAA,MACjE,sBAAsBoE,MAAsBpE,EAAW;AAAA,IAAA;AAAA,IAEzD,SAAS,EAAE,UAAA6F,GAAA;AAAA,IACX,eAAAT;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAO0B;AAAA,QACP,YAAYxB,KAAyByB,KAAkB;AAAA,QACvD,MAAMpG,IAAmB,SAAYqG;AAAA,QACrC,aAAarG,IAAmB,SAAYsG;AAAA,QAC5C,sBAAsBpG,IAA6BqG,KAA4B;AAAA,QAC/E,eACErG,KAA8ByD,KAC1B6C,KACA;AAAA,QACN,eAAezF,IAAyB0F,KAAqB;AAAA,MAAA;AAAA,MAE/D,gBAAAxB;AAAA,MACA,mBAAAgB;AAAA,MACA,yBAAyBS,GAA8BxD,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { useMemo as
|
|
1
|
+
import { useMemo as n, useCallback as P } from "react";
|
|
2
2
|
import { useEmployeesGet as J } from "@gusto/embedded-api/react-query/employeesGet";
|
|
3
3
|
import { useJobsAndCompensationsGetJobs as M } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
|
|
4
|
-
import { GetV1EmployeesEmployeeIdJobsQueryParamInclude as
|
|
5
|
-
import { useJobsAndCompensationsDeleteCompensationMutation as
|
|
6
|
-
import { getPendingCompensationChanges as
|
|
4
|
+
import { GetV1EmployeesEmployeeIdJobsQueryParamInclude as S } from "@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs";
|
|
5
|
+
import { useJobsAndCompensationsDeleteCompensationMutation as F } from "@gusto/embedded-api/react-query/jobsAndCompensationsDeleteCompensation";
|
|
6
|
+
import { getPendingCompensationChanges as I } from "../getPendingCompensationChanges.js";
|
|
7
7
|
import { derivePrimaryFlsaStatus as j } from "../derivePrimaryFlsaStatus.js";
|
|
8
8
|
import { useBaseSubmit as A } from "../../../../Base/useBaseSubmit.js";
|
|
9
9
|
import { composeErrorHandler as v } from "../../../../../partner-hook-utils/composeErrorHandler.js";
|
|
10
10
|
function B({
|
|
11
11
|
employeeId: i
|
|
12
12
|
}) {
|
|
13
|
-
const
|
|
14
|
-
{ employeeId: i, include:
|
|
13
|
+
const o = M(
|
|
14
|
+
{ employeeId: i, include: S.AllCompensations },
|
|
15
15
|
{ staleTime: 1 / 0 }
|
|
16
|
-
), s = J({ employeeId: i }, { staleTime: 1 / 0 }),
|
|
16
|
+
), s = J({ employeeId: i }, { staleTime: 1 / 0 }), t = F(), {
|
|
17
17
|
baseSubmitHandler: r,
|
|
18
18
|
error: p,
|
|
19
19
|
setError: c
|
|
20
|
-
} = A("Employee.Management.Compensation"), l = s.data?.
|
|
20
|
+
} = A("Employee.Management.Compensation"), l = s.data?.employeeShow, e = n(() => o.data?.jobs ?? [], [o.data?.jobs]), d = n(() => e.find((a) => a.primary === !0), [e]), g = n(() => j(e), [e]), y = e.length > 1, b = n(() => I(e), [e]), f = t.isPending ? t.variables.request.compensationId : null, C = P(
|
|
21
21
|
async (a) => {
|
|
22
22
|
let u;
|
|
23
|
-
return await r(a, async ({ compensationUuid:
|
|
24
|
-
u = { mode: "update", data: await
|
|
25
|
-
request: { compensationId:
|
|
23
|
+
return await r(a, async ({ compensationUuid: E }) => {
|
|
24
|
+
u = { mode: "update", data: await t.mutateAsync({
|
|
25
|
+
request: { compensationId: E }
|
|
26
26
|
}) };
|
|
27
27
|
}), u;
|
|
28
28
|
},
|
|
29
|
-
[r,
|
|
30
|
-
),
|
|
29
|
+
[r, t]
|
|
30
|
+
), h = o.isFetching || s.isFetching || t.isPending, m = v([o, s], {
|
|
31
31
|
submitError: p,
|
|
32
32
|
setSubmitError: c
|
|
33
33
|
});
|
|
34
|
-
return
|
|
34
|
+
return o.isLoading ? { isLoading: !0, errorHandling: m } : {
|
|
35
35
|
isLoading: !1,
|
|
36
36
|
data: {
|
|
37
37
|
jobs: e,
|
|
@@ -42,7 +42,7 @@ function B({
|
|
|
42
42
|
employeeFirstName: l?.firstName ?? void 0
|
|
43
43
|
},
|
|
44
44
|
status: {
|
|
45
|
-
isPending:
|
|
45
|
+
isPending: h,
|
|
46
46
|
cancellingCompensationUuid: f
|
|
47
47
|
},
|
|
48
48
|
actions: {
|
|
@@ -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;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;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,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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