@gusto/embedded-react-sdk 0.36.0 → 0.37.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/UNSTABLE_Hooks.d.ts +1 -1
- package/dist/UNSTABLE_Hooks.js +6 -6
- package/dist/components/Base/Base.d.ts +8 -10
- package/dist/components/Base/Base.js +121 -100
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/index.d.ts +1 -1
- package/dist/components/Base/useBase.d.ts +3 -7
- package/dist/components/Base/useBase.js.map +1 -1
- package/dist/components/Base/useBaseSubmit.d.ts +3 -5
- package/dist/components/Base/useBaseSubmit.js +27 -50
- package/dist/components/Base/useBaseSubmit.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +1 -1
- package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionList.module.scss.js +2 -2
- package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
- package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +6 -5
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +6 -8
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +5 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +6 -8
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +8 -10
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +6 -8
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +6 -8
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +6 -8
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +11 -13
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +9 -11
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.js +5 -4
- package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +6 -8
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +6 -8
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +6 -8
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +60 -60
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +10 -9
- package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +8 -10
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +6 -8
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +6 -8
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +7 -6
- package/dist/components/Contractor/Address/Form.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +8 -10
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +3 -2
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js.map +1 -1
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
- package/dist/components/Contractor/Profile/useContractorProfile.js +26 -28
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +13 -15
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +5 -7
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +5 -7
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
- package/dist/components/Employee/Deductions/IncludeDeductions/IncludeDeductions.js +3 -2
- package/dist/components/Employee/Deductions/IncludeDeductions/IncludeDeductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +6 -8
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +6 -8
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +6 -8
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalTaxes.js +42 -42
- package/dist/components/Employee/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +6 -8
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +8 -10
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +9 -8
- package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +15 -14
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/Profile.js +30 -29
- package/dist/components/Employee/Profile/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +6 -8
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/StateTaxes/StateTaxes.js +50 -50
- package/dist/components/Employee/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +6 -8
- package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +53 -53
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +6 -8
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.d.ts +11 -0
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +123 -0
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.d.ts +11 -0
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js +92 -0
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployeePresentation.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlow.d.ts +2 -0
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlow.js +30 -0
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlow.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlowComponents.d.ts +23 -0
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlowComponents.js +72 -0
- package/dist/components/Employee/Terminations/TerminationFlow/TerminationFlowComponents.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminationFlow/index.d.ts +3 -0
- package/dist/components/Employee/Terminations/TerminationFlow/terminationStateMachine.d.ts +7 -0
- package/dist/components/Employee/Terminations/TerminationFlow/terminationStateMachine.js +165 -0
- package/dist/components/Employee/Terminations/TerminationFlow/terminationStateMachine.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminationFlow/terminationStateMachine.test.d.ts +1 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.d.ts +9 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js +86 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummaryPresentation.d.ts +20 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummaryPresentation.js +103 -0
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummaryPresentation.js.map +1 -0
- package/dist/components/Employee/Terminations/TerminationsData.d.ts +6 -0
- package/dist/components/Employee/Terminations/index.d.ts +8 -0
- package/dist/components/Employee/Terminations/types.d.ts +1 -0
- package/dist/components/Employee/index.d.ts +7 -0
- package/dist/components/Employee/index.js +34 -28
- package/dist/components/Employee/index.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequests.js +31 -31
- package/dist/components/InformationRequests/InformationRequests.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js +41 -41
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetails.js.map +1 -1
- package/dist/components/Payroll/Dismissal/DismissalFlow.d.ts +2 -0
- package/dist/components/Payroll/Dismissal/DismissalFlow.js +32 -0
- package/dist/components/Payroll/Dismissal/DismissalFlow.js.map +1 -0
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.d.ts +16 -0
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.js +52 -0
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.js.map +1 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.d.ts +6 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js +69 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js.map +1 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelectionPresentation.d.ts +9 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelectionPresentation.js +53 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelectionPresentation.js.map +1 -0
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/index.d.ts +3 -0
- package/dist/components/Payroll/Dismissal/dismissalStateMachine.d.ts +6 -0
- package/dist/components/Payroll/Dismissal/dismissalStateMachine.js +51 -0
- package/dist/components/Payroll/Dismissal/dismissalStateMachine.js.map +1 -0
- package/dist/components/Payroll/Dismissal/dismissalStateMachine.test.d.ts +1 -0
- package/dist/components/Payroll/Dismissal/index.d.ts +3 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +3 -3
- package/dist/components/Payroll/OffCycle/OffCycleFlow.d.ts +1 -1
- package/dist/components/Payroll/OffCycle/OffCycleFlow.js +19 -18
- package/dist/components/Payroll/OffCycle/OffCycleFlow.js.map +1 -1
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.d.ts +3 -0
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +32 -24
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +45 -45
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +75 -66
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.module.scss.js +8 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +0 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.module.scss.js +4 -4
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.js +2 -2
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.js.map +1 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.d.ts +1 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.js +1 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +186 -159
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +3 -3
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +71 -70
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.d.ts +3 -2
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js +8 -8
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +5 -3
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +76 -70
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +47 -42
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +4 -2
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +225 -194
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/OffCycleFlowContextual.d.ts +1 -0
- package/dist/components/Payroll/PayrollFlow/OffCycleFlowContextual.js +12 -0
- package/dist/components/Payroll/PayrollFlow/OffCycleFlowContextual.js.map +1 -0
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +3 -0
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.d.ts +1 -0
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js +21 -0
- package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js.map +1 -0
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.d.ts +2 -0
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js +95 -64
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js +53 -47
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +8 -8
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +25 -23
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js +40 -32
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +110 -93
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.module.scss.js +12 -8
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.module.scss.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +3 -2
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/Transition/TransitionFlow.d.ts +2 -0
- package/dist/components/Payroll/Transition/TransitionFlow.js +38 -0
- package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -0
- package/dist/components/Payroll/Transition/TransitionFlowComponents.d.ts +19 -0
- package/dist/components/Payroll/Transition/TransitionFlowComponents.js +54 -0
- package/dist/components/Payroll/Transition/TransitionFlowComponents.js.map +1 -0
- package/dist/components/Payroll/Transition/index.d.ts +3 -0
- package/dist/components/Payroll/Transition/transitionStateMachine.d.ts +6 -0
- package/dist/components/Payroll/Transition/transitionStateMachine.js +58 -0
- package/dist/components/Payroll/Transition/transitionStateMachine.js.map +1 -0
- package/dist/components/Payroll/Transition/transitionStateMachine.test.d.ts +1 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.d.ts +2 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js +92 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreation.js.map +1 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.d.ts +2 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js +111 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js.map +1 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.module.scss.js +8 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.module.scss.js.map +1 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.d.ts +28 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.js +21 -0
- package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.js.map +1 -0
- package/dist/components/Payroll/TransitionCreation/index.d.ts +3 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.d.ts +8 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js +83 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js.map +1 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.d.ts +16 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +100 -0
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -0
- package/dist/components/Payroll/TransitionPayrollAlert/index.d.ts +2 -0
- package/dist/components/Payroll/helpers.d.ts +2 -1
- package/dist/components/Payroll/helpers.js +98 -87
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/index.d.ts +6 -0
- package/dist/components/Payroll/index.js +32 -26
- package/dist/components/Payroll/index.js.map +1 -1
- package/dist/components/Payroll/payrollTypes.d.ts +21 -0
- package/dist/components/Payroll/payrollTypes.js +27 -0
- package/dist/components/Payroll/payrollTypes.js.map +1 -0
- package/dist/components/Payroll/usePreparedPayrollData.js +5 -7
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataContext.d.ts +8 -0
- package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataContext.js +13 -0
- package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataContext.js.map +1 -0
- package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataProvider.d.ts +10 -0
- package/dist/components/UNSTABLE_Hooks/form/SDKFormProvider.d.ts +18 -0
- package/dist/components/UNSTABLE_Hooks/form/deriveFieldsMetadata.d.ts +3 -0
- package/dist/components/UNSTABLE_Hooks/form/deriveFieldsMetadata.test.d.ts +1 -0
- package/dist/components/UNSTABLE_Hooks/form/index.d.ts +9 -0
- package/dist/components/UNSTABLE_Hooks/form/types.d.ts +15 -0
- package/dist/components/UNSTABLE_Hooks/form/useFieldErrorMessage.d.ts +1 -0
- package/dist/components/UNSTABLE_Hooks/form/useFieldErrorMessage.js +15 -0
- package/dist/components/UNSTABLE_Hooks/form/useFieldErrorMessage.js.map +1 -0
- package/dist/components/UNSTABLE_Hooks/form/useFieldsMetadata.d.ts +4 -0
- package/dist/components/UNSTABLE_Hooks/form/useFieldsMetadata.js +9 -0
- package/dist/components/UNSTABLE_Hooks/form/useFieldsMetadata.js.map +1 -0
- package/dist/components/UNSTABLE_Hooks/form/withOptions.d.ts +5 -0
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/index.d.ts +3 -0
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/useCompensationForm.d.ts +16 -0
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/useCompensationForm.js +7 -0
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/useCompensationForm.js.map +1 -0
- package/dist/components/UNSTABLE_Hooks/index.d.ts +5 -0
- package/dist/components/UNSTABLE_Hooks/types.d.ts +46 -0
- package/dist/contexts/ApiProvider/ApiProvider.js +11 -11
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +43 -47
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ObservabilityProvider/index.d.ts +1 -1
- package/dist/contexts/ObservabilityProvider/sanitization.d.ts +0 -14
- package/dist/contexts/ObservabilityProvider/sanitization.js +51 -51
- package/dist/contexts/ObservabilityProvider/sanitization.js.map +1 -1
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.d.ts +0 -3
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js.map +1 -1
- package/dist/i18n/I18n.js +11 -11
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Employee.Terminations.TerminateEmployee.json.js +18 -0
- package/dist/i18n/en/Employee.Terminations.TerminateEmployee.json.js.map +1 -0
- package/dist/i18n/en/Employee.Terminations.TerminationFlow.json.js +12 -0
- package/dist/i18n/en/Employee.Terminations.TerminationFlow.json.js.map +1 -0
- package/dist/i18n/en/Employee.Terminations.TerminationSummary.json.js +20 -0
- package/dist/i18n/en/Employee.Terminations.TerminationSummary.json.js.map +1 -0
- package/dist/i18n/en/Payroll.Dismissal.json.js +22 -0
- package/dist/i18n/en/Payroll.Dismissal.json.js.map +1 -0
- package/dist/i18n/en/Payroll.OffCycleCreation.json.js +15 -11
- package/dist/i18n/en/Payroll.OffCycleCreation.json.js.map +1 -1
- package/dist/i18n/en/Payroll.OffCyclePayPeriodDateForm.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js +20 -18
- package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollList.json.js +20 -18
- package/dist/i18n/en/Payroll.PayrollList.json.js.map +1 -1
- package/dist/i18n/en/Payroll.Transition.json.js +8 -0
- package/dist/i18n/en/Payroll.Transition.json.js.map +1 -0
- package/dist/i18n/en/Payroll.TransitionCreation.json.js +26 -0
- package/dist/i18n/en/Payroll.TransitionCreation.json.js.map +1 -0
- package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js +18 -0
- package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js.map +1 -0
- package/dist/i18n/en/common.json.d.ts +2 -1
- package/dist/i18n/en/common.json.js +9 -9
- package/dist/index.d.ts +3 -2
- package/dist/index.js +14 -13
- package/dist/shared/constants.d.ts +32 -0
- package/dist/shared/constants.js +83 -65
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +163 -1
- package/dist/types/observability.d.ts +31 -65
- package/dist/types/sdkError.d.ts +91 -0
- package/dist/types/sdkError.js +95 -0
- package/dist/types/sdkError.js.map +1 -0
- package/dist/types/sdkError.test.d.ts +1 -0
- package/docs/reference/endpoint-inventory.json +120 -14
- package/package.json +13 -13
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfiguration.d.ts +0 -6
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfiguration.js +0 -70
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfiguration.js.map +0 -1
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfigurationContext.d.ts +0 -7
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfigurationContext.js +0 -6
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfigurationContext.js.map +0 -1
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfigurationProvider.d.ts +0 -9
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfigurationProvider.js +0 -40
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/PayrollConfigurationProvider.js.map +0 -1
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/index.d.ts +0 -5
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/usePayrollConfiguration.d.ts +0 -2
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/usePayrollConfiguration.js +0 -12
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/PayrollConfiguration/usePayrollConfiguration.js.map +0 -1
- package/dist/components/Payroll/UNSTABLE_PayrollHooks/index.d.ts +0 -2
- package/dist/contexts/ObservabilityProvider/observabilityUtils.d.ts +0 -5
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js +0 -45
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as t, jsxs as k, Fragment as
|
|
2
|
-
import { zodResolver as
|
|
1
|
+
import { jsx as t, jsxs as k, Fragment as fe } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver as Ee } from "@hookform/resolvers/zod";
|
|
3
3
|
import { useState as W, useRef as he, useEffect as Oe } from "react";
|
|
4
4
|
import { useForm as Se, useWatch as De, FormProvider as ge } from "react-hook-form";
|
|
5
5
|
import { useLocationsGetSuspense as Pe } from "@gusto/embedded-api/react-query/locationsGet";
|
|
6
6
|
import { useEmployeesCreateMutation as be } from "@gusto/embedded-api/react-query/employeesCreate";
|
|
7
7
|
import { useEmployeesGetSuspense as Ne } from "@gusto/embedded-api/react-query/employeesGet";
|
|
8
|
-
import { useEmployeeAddressesGetSuspense as
|
|
9
|
-
import { useEmployeeAddressesCreateMutation as
|
|
8
|
+
import { useEmployeeAddressesGetSuspense as Ie } from "@gusto/embedded-api/react-query/employeeAddressesGet";
|
|
9
|
+
import { useEmployeeAddressesCreateMutation as _e } from "@gusto/embedded-api/react-query/employeeAddressesCreate";
|
|
10
10
|
import { useEmployeeAddressesUpdateMutation as we } from "@gusto/embedded-api/react-query/employeeAddressesUpdate";
|
|
11
11
|
import { useEmployeeAddressesUpdateWorkAddressMutation as Me } from "@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress";
|
|
12
12
|
import { useEmployeesUpdateMutation as Be } from "@gusto/embedded-api/react-query/employeesUpdate";
|
|
@@ -30,15 +30,16 @@ import { useI18n as U, useComponentDictionary as Je } from "../../../i18n/I18n.j
|
|
|
30
30
|
import { EmployeeOnboardingStatus as i, EmployeeSelfOnboardingStatuses as Qe, componentEvents as d } from "../../../shared/constants.js";
|
|
31
31
|
import { useFlow as Xe } from "../../Flow/useFlow.js";
|
|
32
32
|
import { ensureRequired as Ze } from "../../../helpers/ensureRequired.js";
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
import { SDKInternalError as $e } from "../../../types/sdkError.js";
|
|
34
|
+
function er(r) {
|
|
35
|
+
return /* @__PURE__ */ t(je, { ...r, children: r.employeeId ? /* @__PURE__ */ t(rr, { ...r, employeeId: r.employeeId, children: r.children }) : /* @__PURE__ */ t(q, { ...r, children: r.children }) });
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function rr({ employeeId: r, ...m }) {
|
|
37
38
|
const {
|
|
38
39
|
data: { employee: p }
|
|
39
40
|
} = Ne({ employeeId: r }), {
|
|
40
41
|
data: { employeeAddressList: y }
|
|
41
|
-
} =
|
|
42
|
+
} = Ie({ employeeId: r }), {
|
|
42
43
|
data: { employeeWorkAddressesList: l }
|
|
43
44
|
} = Ce({ employeeId: r });
|
|
44
45
|
return /* @__PURE__ */ t(
|
|
@@ -66,11 +67,11 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
66
67
|
children: b,
|
|
67
68
|
className: F = "",
|
|
68
69
|
defaultValues: s
|
|
69
|
-
} = y, { onEvent: n, baseSubmitHandler: V } = Ke(), [Y, N] = W(T), [z,
|
|
70
|
+
} = y, { onEvent: n, baseSubmitHandler: V } = Ke(), [Y, N] = W(T), [z, I] = W(G), { data: x } = Pe({ companyId: l }), j = x.companyLocationsList, { mutateAsync: K, isPending: J } = be(), { mutateAsync: Q, isPending: X } = Be(), { mutateAsync: Z, isPending: $ } = Le(), { mutateAsync: ee, isPending: re } = Me(), { mutateAsync: te, isPending: oe } = _e(), { mutateAsync: se, isPending: ne } = we(), {
|
|
70
71
|
mutateAsync: de,
|
|
71
72
|
isPending: ie
|
|
72
|
-
} = Re(),
|
|
73
|
-
employee:
|
|
73
|
+
} = Re(), _ = { employee: u, workAddresses: P }, ae = Ye(H), me = _.workAddresses?.find((c) => c.active), e = he({
|
|
74
|
+
employee: _.employee,
|
|
74
75
|
homeAddress: ae,
|
|
75
76
|
workAddress: me
|
|
76
77
|
}), S = {
|
|
@@ -102,13 +103,13 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
102
103
|
ssn: ""
|
|
103
104
|
}, D = Se({
|
|
104
105
|
// @ts-expect-error: Zod 4 discriminated union intersection produces narrower types than NullableDatesMapper expects
|
|
105
|
-
resolver:
|
|
106
|
+
resolver: Ee((r ? Y : ve).and(z)),
|
|
106
107
|
defaultValues: r ? le : ue
|
|
107
108
|
}), { handleSubmit: ce } = D, A = De({ control: D.control, name: "selfOnboarding" });
|
|
108
109
|
Oe(() => {
|
|
109
110
|
if (r) {
|
|
110
111
|
const c = g(u);
|
|
111
|
-
N(A && !c ? ke : T),
|
|
112
|
+
N(A && !c ? ke : T), I(A && c ? qe : G);
|
|
112
113
|
}
|
|
113
114
|
}, [A, r, u?.onboardingStatus, u?.onboarded]);
|
|
114
115
|
const pe = async (c) => {
|
|
@@ -116,7 +117,7 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
116
117
|
const { workAddress: w, startDate: Ae, selfOnboarding: h, ...O } = a;
|
|
117
118
|
if (e.current.employee) {
|
|
118
119
|
if (r && (h && e.current.employee.onboardingStatus === i.ADMIN_ONBOARDING_INCOMPLETE || !h && e.current.employee.onboardingStatus === i.SELF_ONBOARDING_PENDING_INVITE)) {
|
|
119
|
-
const { employeeOnboardingStatus:
|
|
120
|
+
const { employeeOnboardingStatus: f } = await de({
|
|
120
121
|
request: {
|
|
121
122
|
employeeId: e.current.employee.uuid,
|
|
122
123
|
requestBody: {
|
|
@@ -126,8 +127,8 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
126
127
|
});
|
|
127
128
|
e.current.employee = {
|
|
128
129
|
...e.current.employee,
|
|
129
|
-
onboardingStatus:
|
|
130
|
-
}, n(d.EMPLOYEE_ONBOARDING_STATUS_UPDATED,
|
|
130
|
+
onboardingStatus: f.onboardingStatus
|
|
131
|
+
}, n(d.EMPLOYEE_ONBOARDING_STATUS_UPDATED, f);
|
|
131
132
|
}
|
|
132
133
|
const { employee: o } = await Q({
|
|
133
134
|
request: {
|
|
@@ -150,20 +151,20 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
150
151
|
e.current = { ...e.current, employee: o }, n(d.EMPLOYEE_CREATED, o);
|
|
151
152
|
}
|
|
152
153
|
if (typeof e.current.employee?.uuid != "string")
|
|
153
|
-
throw new
|
|
154
|
+
throw new $e("Employee id is not available");
|
|
154
155
|
const M = g(
|
|
155
156
|
e.current.employee
|
|
156
157
|
);
|
|
157
158
|
if ((!r || !A || M) && (!a.selfOnboarding || M) && "street1" in a && "city" in a && "state" in a && "zip" in a) {
|
|
158
|
-
const { street1: o, street2:
|
|
159
|
+
const { street1: o, street2: f, city: B, state: C, zip: L, courtesyWithholding: R } = a;
|
|
159
160
|
if (e.current.homeAddress) {
|
|
160
|
-
const { employeeAddress:
|
|
161
|
+
const { employeeAddress: E } = await se({
|
|
161
162
|
request: {
|
|
162
163
|
homeAddressUuid: e.current.homeAddress.uuid,
|
|
163
164
|
requestBody: {
|
|
164
165
|
version: e.current.homeAddress.version,
|
|
165
166
|
street1: o,
|
|
166
|
-
street2:
|
|
167
|
+
street2: f,
|
|
167
168
|
city: B,
|
|
168
169
|
state: C,
|
|
169
170
|
zip: L,
|
|
@@ -171,14 +172,14 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
});
|
|
174
|
-
e.current = { ...e.current, homeAddress:
|
|
175
|
+
e.current = { ...e.current, homeAddress: E }, n(d.EMPLOYEE_HOME_ADDRESS_UPDATED, E);
|
|
175
176
|
} else {
|
|
176
|
-
const { employeeAddress:
|
|
177
|
+
const { employeeAddress: E } = await te({
|
|
177
178
|
request: {
|
|
178
179
|
employeeId: e.current.employee.uuid,
|
|
179
180
|
requestBody: {
|
|
180
181
|
street1: o,
|
|
181
|
-
street2:
|
|
182
|
+
street2: f,
|
|
182
183
|
city: B,
|
|
183
184
|
state: C,
|
|
184
185
|
zip: L,
|
|
@@ -186,7 +187,7 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
});
|
|
189
|
-
e.current = { ...e.current, homeAddress:
|
|
190
|
+
e.current = { ...e.current, homeAddress: E }, n(d.EMPLOYEE_HOME_ADDRESS_CREATED, E);
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
if (r)
|
|
@@ -235,7 +236,7 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
235
236
|
hasCompletedSelfOnboarding: g(e.current.employee),
|
|
236
237
|
isPending: X || re || oe || ne || J || $ || ie
|
|
237
238
|
},
|
|
238
|
-
children: /* @__PURE__ */ t(ge, { ...D, children: /* @__PURE__ */ t(xe, { onSubmit: ce(pe), children: b || /* @__PURE__ */ k(
|
|
239
|
+
children: /* @__PURE__ */ t(ge, { ...D, children: /* @__PURE__ */ t(xe, { onSubmit: ce(pe), children: b || /* @__PURE__ */ k(fe, { children: [
|
|
239
240
|
/* @__PURE__ */ k(ze, { gridTemplateColumns: "1fr", gap: 24, children: [
|
|
240
241
|
/* @__PURE__ */ t(Ge, {}),
|
|
241
242
|
/* @__PURE__ */ t(We, {}),
|
|
@@ -247,10 +248,10 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
247
248
|
] }) }) })
|
|
248
249
|
}
|
|
249
250
|
) });
|
|
250
|
-
},
|
|
251
|
+
}, Wr = () => {
|
|
251
252
|
const { companyId: r, employeeId: m, onEvent: p, isAdmin: y, defaultValues: l, isSelfOnboardingEnabled: u } = Xe();
|
|
252
253
|
return /* @__PURE__ */ t(
|
|
253
|
-
|
|
254
|
+
er,
|
|
254
255
|
{
|
|
255
256
|
companyId: Ze(r),
|
|
256
257
|
employeeId: m,
|
|
@@ -262,7 +263,7 @@ const g = (r) => r?.onboarded || r?.onboardingStatus === i.ONBOARDING_COMPLETED
|
|
|
262
263
|
);
|
|
263
264
|
};
|
|
264
265
|
export {
|
|
265
|
-
|
|
266
|
-
|
|
266
|
+
er as Profile,
|
|
267
|
+
Wr as ProfileContextual
|
|
267
268
|
};
|
|
268
269
|
//# sourceMappingURL=Profile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Profile.js","sources":["../../../../src/components/Employee/Profile/Profile.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useRef, useState, useEffect } from 'react'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { useLocationsGetSuspense } from '@gusto/embedded-api/react-query/locationsGet'\nimport { useEmployeesCreateMutation } from '@gusto/embedded-api/react-query/employeesCreate'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { type Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useEmployeeAddressesGetSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGet'\nimport { type EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { useEmployeeAddressesCreateMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreate'\nimport { useEmployeeAddressesUpdateMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdate'\nimport { useEmployeeAddressesUpdateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress'\nimport { useEmployeesUpdateMutation } from '@gusto/embedded-api/react-query/employeesUpdate'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useEmployeeAddressesCreateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlowComponents'\nimport {\n AdminPersonalDetails,\n AdminPersonalDetailsSchema,\n AdminSelfOnboardingPersonalDetailsSchema,\n} from './AdminPersonalDetails'\nimport { SelfPersonalDetails, SelfPersonalDetailsSchema } from './SelfPersonalDetails'\nimport { type PersonalDetailsPayload, type PersonalDetailsInputs } from './PersonalDetailsInputs'\nimport { Head } from './Head'\nimport { Actions } from './Actions'\nimport {\n HomeAddress,\n HomeAddressSchema,\n HomeAddressSchemaWithCompletedOnboarding,\n type HomeAddressInputs,\n} from './HomeAddress'\nimport { WorkAddress } from './WorkAddress'\nimport { ProfileProvider } from './useProfile'\nimport { getEmployeeAddressForProfile } from './getEmployeeAddressForProfile'\nimport { Grid } from '@/components/Common/Grid/Grid'\nimport { Form } from '@/components/Common/Form'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n EmployeeOnboardingStatus,\n EmployeeSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport type { RequireAtLeastOne, WithRequired } from '@/types/Helpers'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nexport type ProfileDefaultValues = RequireAtLeastOne<{\n employee?: RequireAtLeastOne<{\n firstName?: string\n middleInitial?: string\n lastName?: string\n email?: string\n dateOfBirth?: string\n }>\n homeAddress?: RequireAtLeastOne<{\n street1?: string\n street2?: string\n city?: string\n state?: string\n zip?: string\n }>\n inviteEmployeeDefault?: boolean\n}>\ninterface ProfileProps extends CommonComponentInterface<'Employee.Profile'> {\n employeeId?: string\n companyId: string\n defaultValues?: ProfileDefaultValues\n isAdmin?: boolean\n isSelfOnboardingEnabled?: boolean\n}\n\ninterface ProfileConditionalProps {\n employee?: Employee\n homeAddresses?: EmployeeAddress[]\n workAddresses?: EmployeeWorkAddress[]\n}\n\nexport function Profile(props: ProfileProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n {props.employeeId ? (\n <RootWithEmployee {...props} employeeId={props.employeeId}>\n {props.children}\n </RootWithEmployee>\n ) : (\n <Root {...props}>{props.children}</Root>\n )}\n </BaseComponent>\n )\n}\n\n/**Accounting for conditional logic where employee data needs to be fetched only if employeeId is present */\nfunction RootWithEmployee({ employeeId, ...props }: WithRequired<ProfileProps, 'employeeId'>) {\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n const {\n data: { employeeAddressList },\n } = useEmployeeAddressesGetSuspense({ employeeId })\n const {\n data: { employeeWorkAddressesList },\n } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n return (\n <Root\n {...props}\n employee={employee}\n homeAddresses={employeeAddressList}\n workAddresses={employeeWorkAddressesList}\n />\n )\n}\n\nconst checkHasCompletedSelfOnboarding = (employee?: Employee) => {\n return (\n employee?.onboarded ||\n employee?.onboardingStatus === EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n employee?.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW ||\n employee?.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_COMPLETED_BY_EMPLOYEE\n )\n}\n\nconst Root = ({\n isAdmin = false,\n isSelfOnboardingEnabled = true,\n dictionary,\n ...props\n}: ProfileProps & ProfileConditionalProps) => {\n useI18n('Employee.Profile')\n useI18n('Employee.HomeAddress')\n useComponentDictionary('Employee.Profile', dictionary)\n const {\n companyId,\n employee,\n homeAddresses,\n workAddresses,\n children,\n className = '',\n defaultValues,\n } = props\n const { onEvent, baseSubmitHandler } = useBase()\n\n const [AdminSchema, setAdminSchema] = useState<\n typeof AdminPersonalDetailsSchema | typeof AdminSelfOnboardingPersonalDetailsSchema\n >(AdminPersonalDetailsSchema)\n\n const [AddressSchema, setAddressSchema] = useState<\n typeof HomeAddressSchema | typeof HomeAddressSchemaWithCompletedOnboarding\n >(HomeAddressSchema)\n\n const { data } = useLocationsGetSuspense({ companyId })\n const companyLocations = data.companyLocationsList!\n\n const { mutateAsync: createEmployee, isPending: isPendingCreateEmployee } =\n useEmployeesCreateMutation()\n const { mutateAsync: mutateEmployee, isPending: isPendingEmployeeUpdate } =\n useEmployeesUpdateMutation()\n\n const { mutateAsync: createEmployeeWorkAddress, isPending: isPendingCreateWA } =\n useEmployeeAddressesCreateWorkAddressMutation()\n const { mutateAsync: mutateEmployeeWorkAddress, isPending: isPendingWorkAddressUpdate } =\n useEmployeeAddressesUpdateWorkAddressMutation()\n\n const { mutateAsync: createEmployeeHomeAddress, isPending: isPendingAddHA } =\n useEmployeeAddressesCreateMutation()\n const { mutateAsync: mutateEmployeeHomeAddress, isPending: isPendingUpdateHA } =\n useEmployeeAddressesUpdateMutation()\n\n const {\n mutateAsync: updateEmployeeOnboardingStatus,\n isPending: isPendingUpdateOnboardingStatus,\n } = useEmployeesUpdateOnboardingStatusMutation()\n\n const existingData = { employee, workAddresses, homeAddresses }\n\n const currentHomeAddress = getEmployeeAddressForProfile(homeAddresses)\n\n const currentWorkAddress = existingData.workAddresses?.find(address => address.active)\n const mergedData = useRef({\n employee: existingData.employee,\n homeAddress: currentHomeAddress,\n workAddress: currentWorkAddress,\n })\n const initialValues = {\n firstName: mergedData.current.employee?.firstName ?? defaultValues?.employee?.firstName ?? '',\n middleInitial:\n mergedData.current.employee?.middleInitial ?? defaultValues?.employee?.middleInitial ?? '',\n lastName: mergedData.current.employee?.lastName ?? defaultValues?.employee?.lastName ?? '',\n workAddress: mergedData.current.workAddress?.locationUuid,\n startDate: mergedData.current.employee?.jobs?.[0]?.hireDate\n ? new Date(mergedData.current.employee.jobs[0].hireDate)\n : null, // By default employee response contains only current job - therefore jobs[0]\n email: mergedData.current.employee?.email ?? defaultValues?.employee?.email ?? '',\n dateOfBirth: mergedData.current.employee?.dateOfBirth\n ? new Date(mergedData.current.employee.dateOfBirth)\n : defaultValues?.employee?.dateOfBirth\n ? new Date(defaultValues.employee.dateOfBirth)\n : null,\n\n street1: mergedData.current.homeAddress?.street1 ?? defaultValues?.homeAddress?.street1 ?? '',\n street2: mergedData.current.homeAddress?.street2 ?? defaultValues?.homeAddress?.street2 ?? '',\n city: mergedData.current.homeAddress?.city ?? defaultValues?.homeAddress?.city ?? '',\n zip: mergedData.current.homeAddress?.zip ?? defaultValues?.homeAddress?.zip ?? '',\n state: mergedData.current.homeAddress?.state ?? defaultValues?.homeAddress?.state ?? '',\n courtesyWithholding: mergedData.current.homeAddress?.courtesyWithholding ?? false,\n }\n\n const adminDefaultValues =\n mergedData.current.employee?.onboarded ||\n mergedData.current.employee?.onboardingStatus ===\n EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n (mergedData.current.employee?.onboardingStatus !== undefined &&\n mergedData.current.employee.onboardingStatus !==\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE)\n ? { ...initialValues, enableSsn: false, selfOnboarding: true }\n : {\n ...initialValues,\n selfOnboarding: isSelfOnboardingEnabled\n ? mergedData.current.employee?.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n EmployeeSelfOnboardingStatuses.has(mergedData.current.employee.onboarding_status)\n : (defaultValues?.inviteEmployeeDefault ?? false)\n : false,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n } // In edit mode ssn is submitted only if it has been modified\n\n const selfDetaultValues = {\n ...initialValues,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n }\n\n const formMethods = useForm<\n PersonalDetailsInputs & HomeAddressInputs,\n unknown,\n PersonalDetailsPayload & HomeAddressInputs\n >({\n // @ts-expect-error: Zod 4 discriminated union intersection produces narrower types than NullableDatesMapper expects\n resolver: zodResolver((isAdmin ? AdminSchema : SelfPersonalDetailsSchema).and(AddressSchema)),\n defaultValues: isAdmin ? adminDefaultValues : selfDetaultValues,\n })\n\n const { handleSubmit } = formMethods\n const watchedSelfOnboarding = useWatch({ control: formMethods.control, name: 'selfOnboarding' })\n\n useEffect(() => {\n if (isAdmin) {\n const hasCompletedSelfOnboarding = checkHasCompletedSelfOnboarding(employee)\n\n if (watchedSelfOnboarding && !hasCompletedSelfOnboarding) {\n setAdminSchema(AdminSelfOnboardingPersonalDetailsSchema)\n } else {\n setAdminSchema(AdminPersonalDetailsSchema)\n }\n\n if (watchedSelfOnboarding && hasCompletedSelfOnboarding) {\n setAddressSchema(HomeAddressSchemaWithCompletedOnboarding)\n } else {\n setAddressSchema(HomeAddressSchema)\n }\n }\n }, [watchedSelfOnboarding, isAdmin, employee?.onboardingStatus, employee?.onboarded])\n\n const onSubmit: SubmitHandler<PersonalDetailsPayload & HomeAddressInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { workAddress, startDate, selfOnboarding, ...body } = payload\n //create or update employee\n if (!mergedData.current.employee) {\n const { employee: employeeData } = await createEmployee({\n request: {\n companyId,\n requestBody: {\n ...body,\n selfOnboarding,\n dateOfBirth: body.dateOfBirth ? new RFCDate(body.dateOfBirth) : undefined,\n },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_CREATED, employeeData)\n } else {\n // Updating self-onboarding status\n if (\n isAdmin &&\n ((selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE) ||\n (!selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE))\n ) {\n const { employeeOnboardingStatus } = await updateEmployeeOnboardingStatus({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n onboardingStatus: selfOnboarding\n ? EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n },\n },\n })\n mergedData.current.employee = {\n ...mergedData.current.employee,\n onboardingStatus: employeeOnboardingStatus!\n .onboardingStatus as (typeof EmployeeOnboardingStatus)[keyof typeof EmployeeOnboardingStatus],\n }\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, employeeOnboardingStatus)\n }\n const { employee: employeeData } = await mutateEmployee({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: { ...body, version: mergedData.current.employee.version as string },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_UPDATED, employeeData)\n }\n if (typeof mergedData.current.employee?.uuid !== 'string') {\n throw new Error('Employee id is not available')\n }\n\n const hasCompletedSelfOnboarding = checkHasCompletedSelfOnboarding(\n mergedData.current.employee,\n )\n\n //create or update home address - only if not intended for self onboarding or after self onboarding is completed\n if (!isAdmin || !watchedSelfOnboarding || hasCompletedSelfOnboarding) {\n //typeguard: in this scenario payload will contain address information\n if (!payload.selfOnboarding || hasCompletedSelfOnboarding) {\n if ('street1' in payload && 'city' in payload && 'state' in payload && 'zip' in payload) {\n const { street1, street2, city, state, zip, courtesyWithholding } = payload\n if (!mergedData.current.homeAddress) {\n // Creating home address - for new employee effective_date is the same as work start date\n const { employeeAddress } = await createEmployeeHomeAddress({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_CREATED, employeeAddress)\n } else {\n const { employeeAddress } = await mutateEmployeeHomeAddress({\n request: {\n homeAddressUuid: mergedData.current.homeAddress.uuid,\n requestBody: {\n version: mergedData.current.homeAddress.version,\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_UPDATED, employeeAddress)\n }\n }\n }\n }\n\n if (isAdmin) {\n //create or update workaddress\n if (!mergedData.current.workAddress) {\n const { employeeWorkAddress } = await createEmployeeWorkAddress({\n request: {\n employeeId: mergedData.current.employee?.uuid as string,\n requestBody: {\n locationUuid: workAddress,\n effectiveDate: new RFCDate(payload.startDate || new Date()),\n },\n },\n })\n\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_CREATED, employeeWorkAddress)\n } else {\n //effective_date is excluded from update operation since it cannot be changed on initial work address\n const { employeeWorkAddress } = await mutateEmployeeWorkAddress({\n request: {\n workAddressUuid: mergedData.current.workAddress.uuid,\n requestBody: {\n version: mergedData.current.workAddress.version,\n locationUuid: workAddress,\n },\n },\n })\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_UPDATED, employeeWorkAddress)\n }\n }\n\n onEvent(componentEvents.EMPLOYEE_PROFILE_DONE, {\n ...mergedData.current.employee,\n startDate,\n })\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <ProfileProvider\n value={{\n companyLocations,\n workAddresses,\n employee: mergedData.current.employee ?? undefined,\n isSelfOnboardingIntended: watchedSelfOnboarding,\n handleCancel,\n isAdmin,\n isSelfOnboardingEnabled,\n hasCompletedSelfOnboarding: checkHasCompletedSelfOnboarding(mergedData.current.employee),\n isPending:\n isPendingEmployeeUpdate ||\n isPendingWorkAddressUpdate ||\n isPendingAddHA ||\n isPendingUpdateHA ||\n isPendingCreateEmployee ||\n isPendingCreateWA ||\n isPendingUpdateOnboardingStatus,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <Grid gridTemplateColumns=\"1fr\" gap={24}>\n <Head />\n <AdminPersonalDetails />\n <SelfPersonalDetails />\n <HomeAddress />\n <WorkAddress />\n </Grid>\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </ProfileProvider>\n </section>\n )\n}\n\nexport const ProfileContextual = () => {\n const { companyId, employeeId, onEvent, isAdmin, defaultValues, isSelfOnboardingEnabled } =\n useFlow<OnboardingContextInterface>()\n\n return (\n <Profile\n companyId={ensureRequired(companyId)}\n employeeId={employeeId}\n onEvent={onEvent}\n isAdmin={isAdmin}\n defaultValues={defaultValues?.profile}\n isSelfOnboardingEnabled={isSelfOnboardingEnabled}\n />\n )\n}\n"],"names":["Profile","props","jsx","BaseComponent","RootWithEmployee","Root","employeeId","employee","useEmployeesGetSuspense","employeeAddressList","useEmployeeAddressesGetSuspense","employeeWorkAddressesList","useEmployeeAddressesGetWorkAddressesSuspense","checkHasCompletedSelfOnboarding","EmployeeOnboardingStatus","isAdmin","isSelfOnboardingEnabled","dictionary","useI18n","useComponentDictionary","companyId","homeAddresses","workAddresses","children","className","defaultValues","onEvent","baseSubmitHandler","useBase","AdminSchema","setAdminSchema","useState","AdminPersonalDetailsSchema","AddressSchema","setAddressSchema","HomeAddressSchema","data","useLocationsGetSuspense","companyLocations","createEmployee","isPendingCreateEmployee","useEmployeesCreateMutation","mutateEmployee","isPendingEmployeeUpdate","useEmployeesUpdateMutation","createEmployeeWorkAddress","isPendingCreateWA","useEmployeeAddressesCreateWorkAddressMutation","mutateEmployeeWorkAddress","isPendingWorkAddressUpdate","useEmployeeAddressesUpdateWorkAddressMutation","createEmployeeHomeAddress","isPendingAddHA","useEmployeeAddressesCreateMutation","mutateEmployeeHomeAddress","isPendingUpdateHA","useEmployeeAddressesUpdateMutation","updateEmployeeOnboardingStatus","isPendingUpdateOnboardingStatus","useEmployeesUpdateOnboardingStatusMutation","existingData","currentHomeAddress","getEmployeeAddressForProfile","currentWorkAddress","address","mergedData","useRef","initialValues","adminDefaultValues","EmployeeSelfOnboardingStatuses","selfDetaultValues","formMethods","useForm","zodResolver","SelfPersonalDetailsSchema","handleSubmit","watchedSelfOnboarding","useWatch","useEffect","hasCompletedSelfOnboarding","AdminSelfOnboardingPersonalDetailsSchema","HomeAddressSchemaWithCompletedOnboarding","onSubmit","payload","workAddress","startDate","selfOnboarding","body","employeeOnboardingStatus","componentEvents","employeeData","RFCDate","street1","street2","city","state","zip","courtesyWithholding","employeeAddress","employeeWorkAddress","handleCancel","ProfileProvider","FormProvider","Form","jsxs","Fragment","Grid","Head","AdminPersonalDetails","SelfPersonalDetails","HomeAddress","WorkAddress","Actions","ProfileContextual","useFlow","ensureRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFO,SAASA,GAAQC,GAA8C;AACpE,SACE,gBAAAC,EAACC,MAAe,GAAGF,GAChB,YAAM,aACL,gBAAAC,EAACE,IAAA,EAAkB,GAAGH,GAAO,YAAYA,EAAM,YAC5C,UAAAA,EAAM,UACT,IAEA,gBAAAC,EAACG,KAAM,GAAGJ,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CAErC;AAEJ;AAGA,SAASG,GAAiB,EAAE,YAAAE,GAAY,GAAGL,KAAmD;AAC5F,QAAM;AAAA,IACJ,MAAM,EAAE,UAAAM,EAAA;AAAA,EAAS,IACfC,GAAwB,EAAE,YAAAF,GAAY,GACpC;AAAA,IACJ,MAAM,EAAE,qBAAAG,EAAA;AAAA,EAAoB,IAC1BC,GAAgC,EAAE,YAAAJ,GAAY,GAC5C;AAAA,IACJ,MAAM,EAAE,2BAAAK,EAAA;AAAA,EAA0B,IAChCC,GAA6C,EAAE,YAAAN,GAAY;AAC/D,SACE,gBAAAJ;AAAA,IAACG;AAAA,IAAA;AAAA,MACE,GAAGJ;AAAA,MACJ,UAAAM;AAAA,MACA,eAAeE;AAAA,MACf,eAAeE;AAAA,IAAA;AAAA,EAAA;AAGrB;AAEA,MAAME,IAAkC,CAACN,MAErCA,GAAU,aACVA,GAAU,qBAAqBO,EAAyB,wBACxDP,GAAU,qBAAqBO,EAAyB,yCACxDP,GAAU,qBAAqBO,EAAyB,uCAItDT,IAAO,CAAC;AAA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,GAChB,UAAA,gBAAArE,EAACqG,IAAA,EAAK,UAAU5B,GAAaO,EAAQ,GAClC,UAAA3D,KAGC,gBAAAiF,EAAAC,IAAA,EACE,UAAA;AAAA,QAAA,gBAAAD,EAACE,IAAA,EAAK,qBAAoB,OAAM,KAAK,IACnC,UAAA;AAAA,UAAA,gBAAAxG,EAACyG,IAAA,EAAK;AAAA,4BACLC,IAAA,EAAqB;AAAA,4BACrBC,IAAA,EAAoB;AAAA,4BACpBC,IAAA,EAAY;AAAA,4BACZC,IAAA,CAAA,CAAY;AAAA,QAAA,GACf;AAAA,0BACCC,IAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,GAEJ,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ,GAEaC,KAAoB,MAAM;AACrC,QAAM,EAAE,WAAA7F,GAAW,YAAAd,GAAY,SAAAoB,GAAS,SAAAX,GAAS,eAAAU,GAAe,yBAAAT,EAAA,IAC9DkG,GAAA;AAEF,SACE,gBAAAhH;AAAA,IAACF;AAAA,IAAA;AAAA,MACC,WAAWmH,GAAe/F,CAAS;AAAA,MACnC,YAAAd;AAAA,MACA,SAAAoB;AAAA,MACA,SAAAX;AAAA,MACA,eAAeU,GAAe;AAAA,MAC9B,yBAAAT;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"Profile.js","sources":["../../../../src/components/Employee/Profile/Profile.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useRef, useState, useEffect } from 'react'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { useLocationsGetSuspense } from '@gusto/embedded-api/react-query/locationsGet'\nimport { useEmployeesCreateMutation } from '@gusto/embedded-api/react-query/employeesCreate'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { type Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useEmployeeAddressesGetSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGet'\nimport { type EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { useEmployeeAddressesCreateMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreate'\nimport { useEmployeeAddressesUpdateMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdate'\nimport { useEmployeeAddressesUpdateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress'\nimport { useEmployeesUpdateMutation } from '@gusto/embedded-api/react-query/employeesUpdate'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useEmployeeAddressesCreateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlowComponents'\nimport {\n AdminPersonalDetails,\n AdminPersonalDetailsSchema,\n AdminSelfOnboardingPersonalDetailsSchema,\n} from './AdminPersonalDetails'\nimport { SelfPersonalDetails, SelfPersonalDetailsSchema } from './SelfPersonalDetails'\nimport { type PersonalDetailsPayload, type PersonalDetailsInputs } from './PersonalDetailsInputs'\nimport { Head } from './Head'\nimport { Actions } from './Actions'\nimport {\n HomeAddress,\n HomeAddressSchema,\n HomeAddressSchemaWithCompletedOnboarding,\n type HomeAddressInputs,\n} from './HomeAddress'\nimport { WorkAddress } from './WorkAddress'\nimport { ProfileProvider } from './useProfile'\nimport { getEmployeeAddressForProfile } from './getEmployeeAddressForProfile'\nimport { Grid } from '@/components/Common/Grid/Grid'\nimport { Form } from '@/components/Common/Form'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n EmployeeOnboardingStatus,\n EmployeeSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport type { RequireAtLeastOne, WithRequired } from '@/types/Helpers'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { SDKInternalError } from '@/types/sdkError'\n\nexport type ProfileDefaultValues = RequireAtLeastOne<{\n employee?: RequireAtLeastOne<{\n firstName?: string\n middleInitial?: string\n lastName?: string\n email?: string\n dateOfBirth?: string\n }>\n homeAddress?: RequireAtLeastOne<{\n street1?: string\n street2?: string\n city?: string\n state?: string\n zip?: string\n }>\n inviteEmployeeDefault?: boolean\n}>\ninterface ProfileProps extends CommonComponentInterface<'Employee.Profile'> {\n employeeId?: string\n companyId: string\n defaultValues?: ProfileDefaultValues\n isAdmin?: boolean\n isSelfOnboardingEnabled?: boolean\n}\n\ninterface ProfileConditionalProps {\n employee?: Employee\n homeAddresses?: EmployeeAddress[]\n workAddresses?: EmployeeWorkAddress[]\n}\n\nexport function Profile(props: ProfileProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n {props.employeeId ? (\n <RootWithEmployee {...props} employeeId={props.employeeId}>\n {props.children}\n </RootWithEmployee>\n ) : (\n <Root {...props}>{props.children}</Root>\n )}\n </BaseComponent>\n )\n}\n\n/**Accounting for conditional logic where employee data needs to be fetched only if employeeId is present */\nfunction RootWithEmployee({ employeeId, ...props }: WithRequired<ProfileProps, 'employeeId'>) {\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n const {\n data: { employeeAddressList },\n } = useEmployeeAddressesGetSuspense({ employeeId })\n const {\n data: { employeeWorkAddressesList },\n } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n return (\n <Root\n {...props}\n employee={employee}\n homeAddresses={employeeAddressList}\n workAddresses={employeeWorkAddressesList}\n />\n )\n}\n\nconst checkHasCompletedSelfOnboarding = (employee?: Employee) => {\n return (\n employee?.onboarded ||\n employee?.onboardingStatus === EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n employee?.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW ||\n employee?.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_COMPLETED_BY_EMPLOYEE\n )\n}\n\nconst Root = ({\n isAdmin = false,\n isSelfOnboardingEnabled = true,\n dictionary,\n ...props\n}: ProfileProps & ProfileConditionalProps) => {\n useI18n('Employee.Profile')\n useI18n('Employee.HomeAddress')\n useComponentDictionary('Employee.Profile', dictionary)\n const {\n companyId,\n employee,\n homeAddresses,\n workAddresses,\n children,\n className = '',\n defaultValues,\n } = props\n const { onEvent, baseSubmitHandler } = useBase()\n\n const [AdminSchema, setAdminSchema] = useState<\n typeof AdminPersonalDetailsSchema | typeof AdminSelfOnboardingPersonalDetailsSchema\n >(AdminPersonalDetailsSchema)\n\n const [AddressSchema, setAddressSchema] = useState<\n typeof HomeAddressSchema | typeof HomeAddressSchemaWithCompletedOnboarding\n >(HomeAddressSchema)\n\n const { data } = useLocationsGetSuspense({ companyId })\n const companyLocations = data.companyLocationsList!\n\n const { mutateAsync: createEmployee, isPending: isPendingCreateEmployee } =\n useEmployeesCreateMutation()\n const { mutateAsync: mutateEmployee, isPending: isPendingEmployeeUpdate } =\n useEmployeesUpdateMutation()\n\n const { mutateAsync: createEmployeeWorkAddress, isPending: isPendingCreateWA } =\n useEmployeeAddressesCreateWorkAddressMutation()\n const { mutateAsync: mutateEmployeeWorkAddress, isPending: isPendingWorkAddressUpdate } =\n useEmployeeAddressesUpdateWorkAddressMutation()\n\n const { mutateAsync: createEmployeeHomeAddress, isPending: isPendingAddHA } =\n useEmployeeAddressesCreateMutation()\n const { mutateAsync: mutateEmployeeHomeAddress, isPending: isPendingUpdateHA } =\n useEmployeeAddressesUpdateMutation()\n\n const {\n mutateAsync: updateEmployeeOnboardingStatus,\n isPending: isPendingUpdateOnboardingStatus,\n } = useEmployeesUpdateOnboardingStatusMutation()\n\n const existingData = { employee, workAddresses, homeAddresses }\n\n const currentHomeAddress = getEmployeeAddressForProfile(homeAddresses)\n\n const currentWorkAddress = existingData.workAddresses?.find(address => address.active)\n const mergedData = useRef({\n employee: existingData.employee,\n homeAddress: currentHomeAddress,\n workAddress: currentWorkAddress,\n })\n const initialValues = {\n firstName: mergedData.current.employee?.firstName ?? defaultValues?.employee?.firstName ?? '',\n middleInitial:\n mergedData.current.employee?.middleInitial ?? defaultValues?.employee?.middleInitial ?? '',\n lastName: mergedData.current.employee?.lastName ?? defaultValues?.employee?.lastName ?? '',\n workAddress: mergedData.current.workAddress?.locationUuid,\n startDate: mergedData.current.employee?.jobs?.[0]?.hireDate\n ? new Date(mergedData.current.employee.jobs[0].hireDate)\n : null, // By default employee response contains only current job - therefore jobs[0]\n email: mergedData.current.employee?.email ?? defaultValues?.employee?.email ?? '',\n dateOfBirth: mergedData.current.employee?.dateOfBirth\n ? new Date(mergedData.current.employee.dateOfBirth)\n : defaultValues?.employee?.dateOfBirth\n ? new Date(defaultValues.employee.dateOfBirth)\n : null,\n\n street1: mergedData.current.homeAddress?.street1 ?? defaultValues?.homeAddress?.street1 ?? '',\n street2: mergedData.current.homeAddress?.street2 ?? defaultValues?.homeAddress?.street2 ?? '',\n city: mergedData.current.homeAddress?.city ?? defaultValues?.homeAddress?.city ?? '',\n zip: mergedData.current.homeAddress?.zip ?? defaultValues?.homeAddress?.zip ?? '',\n state: mergedData.current.homeAddress?.state ?? defaultValues?.homeAddress?.state ?? '',\n courtesyWithholding: mergedData.current.homeAddress?.courtesyWithholding ?? false,\n }\n\n const adminDefaultValues =\n mergedData.current.employee?.onboarded ||\n mergedData.current.employee?.onboardingStatus ===\n EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n (mergedData.current.employee?.onboardingStatus !== undefined &&\n mergedData.current.employee.onboardingStatus !==\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE)\n ? { ...initialValues, enableSsn: false, selfOnboarding: true }\n : {\n ...initialValues,\n selfOnboarding: isSelfOnboardingEnabled\n ? mergedData.current.employee?.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n EmployeeSelfOnboardingStatuses.has(mergedData.current.employee.onboarding_status)\n : (defaultValues?.inviteEmployeeDefault ?? false)\n : false,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n } // In edit mode ssn is submitted only if it has been modified\n\n const selfDetaultValues = {\n ...initialValues,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n }\n\n const formMethods = useForm<\n PersonalDetailsInputs & HomeAddressInputs,\n unknown,\n PersonalDetailsPayload & HomeAddressInputs\n >({\n // @ts-expect-error: Zod 4 discriminated union intersection produces narrower types than NullableDatesMapper expects\n resolver: zodResolver((isAdmin ? AdminSchema : SelfPersonalDetailsSchema).and(AddressSchema)),\n defaultValues: isAdmin ? adminDefaultValues : selfDetaultValues,\n })\n\n const { handleSubmit } = formMethods\n const watchedSelfOnboarding = useWatch({ control: formMethods.control, name: 'selfOnboarding' })\n\n useEffect(() => {\n if (isAdmin) {\n const hasCompletedSelfOnboarding = checkHasCompletedSelfOnboarding(employee)\n\n if (watchedSelfOnboarding && !hasCompletedSelfOnboarding) {\n setAdminSchema(AdminSelfOnboardingPersonalDetailsSchema)\n } else {\n setAdminSchema(AdminPersonalDetailsSchema)\n }\n\n if (watchedSelfOnboarding && hasCompletedSelfOnboarding) {\n setAddressSchema(HomeAddressSchemaWithCompletedOnboarding)\n } else {\n setAddressSchema(HomeAddressSchema)\n }\n }\n }, [watchedSelfOnboarding, isAdmin, employee?.onboardingStatus, employee?.onboarded])\n\n const onSubmit: SubmitHandler<PersonalDetailsPayload & HomeAddressInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { workAddress, startDate, selfOnboarding, ...body } = payload\n //create or update employee\n if (!mergedData.current.employee) {\n const { employee: employeeData } = await createEmployee({\n request: {\n companyId,\n requestBody: {\n ...body,\n selfOnboarding,\n dateOfBirth: body.dateOfBirth ? new RFCDate(body.dateOfBirth) : undefined,\n },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_CREATED, employeeData)\n } else {\n // Updating self-onboarding status\n if (\n isAdmin &&\n ((selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE) ||\n (!selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE))\n ) {\n const { employeeOnboardingStatus } = await updateEmployeeOnboardingStatus({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n onboardingStatus: selfOnboarding\n ? EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n },\n },\n })\n mergedData.current.employee = {\n ...mergedData.current.employee,\n onboardingStatus: employeeOnboardingStatus!\n .onboardingStatus as (typeof EmployeeOnboardingStatus)[keyof typeof EmployeeOnboardingStatus],\n }\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, employeeOnboardingStatus)\n }\n const { employee: employeeData } = await mutateEmployee({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: { ...body, version: mergedData.current.employee.version as string },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_UPDATED, employeeData)\n }\n if (typeof mergedData.current.employee?.uuid !== 'string') {\n throw new SDKInternalError('Employee id is not available')\n }\n\n const hasCompletedSelfOnboarding = checkHasCompletedSelfOnboarding(\n mergedData.current.employee,\n )\n\n //create or update home address - only if not intended for self onboarding or after self onboarding is completed\n if (!isAdmin || !watchedSelfOnboarding || hasCompletedSelfOnboarding) {\n //typeguard: in this scenario payload will contain address information\n if (!payload.selfOnboarding || hasCompletedSelfOnboarding) {\n if ('street1' in payload && 'city' in payload && 'state' in payload && 'zip' in payload) {\n const { street1, street2, city, state, zip, courtesyWithholding } = payload\n if (!mergedData.current.homeAddress) {\n // Creating home address - for new employee effective_date is the same as work start date\n const { employeeAddress } = await createEmployeeHomeAddress({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_CREATED, employeeAddress)\n } else {\n const { employeeAddress } = await mutateEmployeeHomeAddress({\n request: {\n homeAddressUuid: mergedData.current.homeAddress.uuid,\n requestBody: {\n version: mergedData.current.homeAddress.version,\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_UPDATED, employeeAddress)\n }\n }\n }\n }\n\n if (isAdmin) {\n //create or update workaddress\n if (!mergedData.current.workAddress) {\n const { employeeWorkAddress } = await createEmployeeWorkAddress({\n request: {\n employeeId: mergedData.current.employee?.uuid as string,\n requestBody: {\n locationUuid: workAddress,\n effectiveDate: new RFCDate(payload.startDate || new Date()),\n },\n },\n })\n\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_CREATED, employeeWorkAddress)\n } else {\n //effective_date is excluded from update operation since it cannot be changed on initial work address\n const { employeeWorkAddress } = await mutateEmployeeWorkAddress({\n request: {\n workAddressUuid: mergedData.current.workAddress.uuid,\n requestBody: {\n version: mergedData.current.workAddress.version,\n locationUuid: workAddress,\n },\n },\n })\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_UPDATED, employeeWorkAddress)\n }\n }\n\n onEvent(componentEvents.EMPLOYEE_PROFILE_DONE, {\n ...mergedData.current.employee,\n startDate,\n })\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <ProfileProvider\n value={{\n companyLocations,\n workAddresses,\n employee: mergedData.current.employee ?? undefined,\n isSelfOnboardingIntended: watchedSelfOnboarding,\n handleCancel,\n isAdmin,\n isSelfOnboardingEnabled,\n hasCompletedSelfOnboarding: checkHasCompletedSelfOnboarding(mergedData.current.employee),\n isPending:\n isPendingEmployeeUpdate ||\n isPendingWorkAddressUpdate ||\n isPendingAddHA ||\n isPendingUpdateHA ||\n isPendingCreateEmployee ||\n isPendingCreateWA ||\n isPendingUpdateOnboardingStatus,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <Grid gridTemplateColumns=\"1fr\" gap={24}>\n <Head />\n <AdminPersonalDetails />\n <SelfPersonalDetails />\n <HomeAddress />\n <WorkAddress />\n </Grid>\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </ProfileProvider>\n </section>\n )\n}\n\nexport const ProfileContextual = () => {\n const { companyId, employeeId, onEvent, isAdmin, defaultValues, isSelfOnboardingEnabled } =\n useFlow<OnboardingContextInterface>()\n\n return (\n <Profile\n companyId={ensureRequired(companyId)}\n employeeId={employeeId}\n onEvent={onEvent}\n isAdmin={isAdmin}\n defaultValues={defaultValues?.profile}\n isSelfOnboardingEnabled={isSelfOnboardingEnabled}\n />\n )\n}\n"],"names":["Profile","props","jsx","BaseComponent","RootWithEmployee","Root","employeeId","employee","useEmployeesGetSuspense","employeeAddressList","useEmployeeAddressesGetSuspense","employeeWorkAddressesList","useEmployeeAddressesGetWorkAddressesSuspense","checkHasCompletedSelfOnboarding","EmployeeOnboardingStatus","isAdmin","isSelfOnboardingEnabled","dictionary","useI18n","useComponentDictionary","companyId","homeAddresses","workAddresses","children","className","defaultValues","onEvent","baseSubmitHandler","useBase","AdminSchema","setAdminSchema","useState","AdminPersonalDetailsSchema","AddressSchema","setAddressSchema","HomeAddressSchema","data","useLocationsGetSuspense","companyLocations","createEmployee","isPendingCreateEmployee","useEmployeesCreateMutation","mutateEmployee","isPendingEmployeeUpdate","useEmployeesUpdateMutation","createEmployeeWorkAddress","isPendingCreateWA","useEmployeeAddressesCreateWorkAddressMutation","mutateEmployeeWorkAddress","isPendingWorkAddressUpdate","useEmployeeAddressesUpdateWorkAddressMutation","createEmployeeHomeAddress","isPendingAddHA","useEmployeeAddressesCreateMutation","mutateEmployeeHomeAddress","isPendingUpdateHA","useEmployeeAddressesUpdateMutation","updateEmployeeOnboardingStatus","isPendingUpdateOnboardingStatus","useEmployeesUpdateOnboardingStatusMutation","existingData","currentHomeAddress","getEmployeeAddressForProfile","currentWorkAddress","address","mergedData","useRef","initialValues","adminDefaultValues","EmployeeSelfOnboardingStatuses","selfDetaultValues","formMethods","useForm","zodResolver","SelfPersonalDetailsSchema","handleSubmit","watchedSelfOnboarding","useWatch","useEffect","hasCompletedSelfOnboarding","AdminSelfOnboardingPersonalDetailsSchema","HomeAddressSchemaWithCompletedOnboarding","onSubmit","payload","workAddress","startDate","selfOnboarding","body","employeeOnboardingStatus","componentEvents","employeeData","RFCDate","SDKInternalError","street1","street2","city","state","zip","courtesyWithholding","employeeAddress","employeeWorkAddress","handleCancel","ProfileProvider","FormProvider","Form","jsxs","Fragment","Grid","Head","AdminPersonalDetails","SelfPersonalDetails","HomeAddress","WorkAddress","Actions","ProfileContextual","useFlow","ensureRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFO,SAASA,GAAQC,GAA8C;AACpE,SACE,gBAAAC,EAACC,MAAe,GAAGF,GAChB,YAAM,aACL,gBAAAC,EAACE,IAAA,EAAkB,GAAGH,GAAO,YAAYA,EAAM,YAC5C,UAAAA,EAAM,UACT,IAEA,gBAAAC,EAACG,KAAM,GAAGJ,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CAErC;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BAAAT,EAAA,IAC9DmG,GAAA;AAEF,SACE,gBAAAjH;AAAA,IAACF;AAAA,IAAA;AAAA,MACC,WAAWoH,GAAehG,CAAS;AAAA,MACnC,YAAAd;AAAA,MACA,SAAAoB;AAAA,MACA,SAAAX;AAAA,MACA,eAAeU,GAAe;AAAA,MAC9B,yBAAAT;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -2,20 +2,18 @@ import "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import "react-error-boundary";
|
|
4
4
|
import "react-i18next";
|
|
5
|
-
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
6
|
-
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
7
5
|
import "@tanstack/react-query";
|
|
8
6
|
import "../../Base/useBase.js";
|
|
9
7
|
import "../../../shared/constants.js";
|
|
10
8
|
import "classnames";
|
|
11
9
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
14
|
-
import "
|
|
10
|
+
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
11
|
+
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
12
|
+
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
15
13
|
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
16
|
-
const [
|
|
14
|
+
const [d, s] = o("ProfileContext");
|
|
17
15
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
s as ProfileProvider,
|
|
17
|
+
d as useProfile
|
|
20
18
|
};
|
|
21
19
|
//# sourceMappingURL=useProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProfile.js","sources":["../../../../src/components/Employee/Profile/useProfile.ts"],"sourcesContent":["import type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { createCompoundContext } from '@/components/Base'\n\n//Interface for context passed down to component slots\ntype ProfileContextType = {\n companyLocations: Location[]\n workAddresses?: EmployeeWorkAddress[]\n employee?: Employee\n isSelfOnboardingIntended?: boolean\n isPending: boolean\n isAdmin: boolean\n handleCancel: () => void\n isSelfOnboardingEnabled: boolean\n hasCompletedSelfOnboarding: boolean\n}\n\nconst [useProfile, ProfileProvider] = createCompoundContext<ProfileContextType>('ProfileContext')\nexport { useProfile, ProfileProvider }\n"],"names":["useProfile","ProfileProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useProfile.js","sources":["../../../../src/components/Employee/Profile/useProfile.ts"],"sourcesContent":["import type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { createCompoundContext } from '@/components/Base'\n\n//Interface for context passed down to component slots\ntype ProfileContextType = {\n companyLocations: Location[]\n workAddresses?: EmployeeWorkAddress[]\n employee?: Employee\n isSelfOnboardingIntended?: boolean\n isPending: boolean\n isAdmin: boolean\n handleCancel: () => void\n isSelfOnboardingEnabled: boolean\n hasCompletedSelfOnboarding: boolean\n}\n\nconst [useProfile, ProfileProvider] = createCompoundContext<ProfileContextType>('ProfileContext')\nexport { useProfile, ProfileProvider }\n"],"names":["useProfile","ProfileProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,CAACA,GAAYC,CAAe,IAAIC,EAA0C,gBAAgB;"}
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { zodResolver as
|
|
1
|
+
import { jsx as s, jsxs as O, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver as U } from "@hookform/resolvers/zod";
|
|
3
3
|
import { useForm as C, FormProvider as L } from "react-hook-form";
|
|
4
4
|
import { useEffect as R } from "react";
|
|
5
5
|
import { useEmployeeTaxSetupGetStateTaxesSuspense as M } from "@gusto/embedded-api/react-query/employeeTaxSetupGetStateTaxes";
|
|
6
|
-
import { useEmployeeTaxSetupUpdateStateTaxesMutation as
|
|
7
|
-
import { StateFormSchema as
|
|
6
|
+
import { useEmployeeTaxSetupUpdateStateTaxesMutation as V } from "@gusto/embedded-api/react-query/employeeTaxSetupUpdateStateTaxes";
|
|
7
|
+
import { StateFormSchema as I, StateForm as j } from "./StateForm.js";
|
|
8
8
|
import { Actions as z } from "./Actions.js";
|
|
9
9
|
import { StateTaxesProvider as X } from "./useStateTaxes.js";
|
|
10
10
|
import { BaseComponent as B } from "../../Base/Base.js";
|
|
11
11
|
import { useBase as H } from "../../Base/useBase.js";
|
|
12
|
-
import { useI18n as
|
|
12
|
+
import { useI18n as Q, useComponentDictionary as Y } from "../../../i18n/I18n.js";
|
|
13
13
|
import { componentEvents as x } from "../../../shared/constants.js";
|
|
14
|
-
import { Form as
|
|
15
|
-
import { snakeCaseToCamelCase as F, normalizeErrorKeyForForm as
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
return /* @__PURE__ */
|
|
14
|
+
import { Form as G } from "../../Common/Form/Form.js";
|
|
15
|
+
import { snakeCaseToCamelCase as F, normalizeErrorKeyForForm as K } from "../../../helpers/formattedStrings.js";
|
|
16
|
+
const q = "2010-01-01";
|
|
17
|
+
function de(u) {
|
|
18
|
+
return /* @__PURE__ */ s(B, { ...u, children: /* @__PURE__ */ s(J, { ...u }) });
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
const { employeeId: c, className: h, children: y, isAdmin: S = !1, dictionary: A } = u, { onEvent: T,
|
|
22
|
-
|
|
23
|
-
const { data:
|
|
20
|
+
const J = (u) => {
|
|
21
|
+
const { employeeId: c, className: h, children: y, isAdmin: S = !1, dictionary: A } = u, { onEvent: T, error: D, baseSubmitHandler: _ } = H();
|
|
22
|
+
Q("Employee.StateTaxes"), Y("Employee.StateTaxes", A);
|
|
23
|
+
const { data: g } = M({
|
|
24
24
|
employeeUuid: c
|
|
25
|
-
}), d =
|
|
26
|
-
states: d.reduce((
|
|
27
|
-
const n = m.answers[0]?.value,
|
|
28
|
-
if (
|
|
29
|
-
|
|
25
|
+
}), d = g.employeeStateTaxesList, { mutateAsync: w, isPending: b } = V(), k = {
|
|
26
|
+
states: d.reduce((r, a) => (a.state && (r[a.state] = a.questions?.reduce((t, m) => {
|
|
27
|
+
const n = m.answers[0]?.value, o = F(m.key), l = m.inputQuestionFormat.type.toLowerCase() === "date";
|
|
28
|
+
if (o === "fileNewHireReport")
|
|
29
|
+
t[o] = typeof n > "u" ? !0 : n;
|
|
30
30
|
else if (l && typeof n == "string") {
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const e = n.trim();
|
|
32
|
+
t[o] = e === "" ? void 0 : new Date(e);
|
|
33
33
|
} else
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
}, {})),
|
|
34
|
+
t[o] = n;
|
|
35
|
+
return t;
|
|
36
|
+
}, {})), r), {})
|
|
37
37
|
}, E = C({
|
|
38
|
-
resolver:
|
|
38
|
+
resolver: U(I),
|
|
39
39
|
defaultValues: k
|
|
40
|
-
}), { handleSubmit: N, setError: v } = E;
|
|
40
|
+
}), { handleSubmit: N, setError: v } = E, p = D?.fieldErrors;
|
|
41
41
|
return R(() => {
|
|
42
|
-
p && p.length > 0 && p.forEach((
|
|
43
|
-
const a =
|
|
44
|
-
v(a, { type: "custom", message:
|
|
42
|
+
p && p.length > 0 && p.forEach((r) => {
|
|
43
|
+
const a = K(r.field);
|
|
44
|
+
v(a, { type: "custom", message: r.message });
|
|
45
45
|
});
|
|
46
|
-
}, [p, v]), /* @__PURE__ */
|
|
46
|
+
}, [p, v]), /* @__PURE__ */ s("section", { className: h, children: /* @__PURE__ */ s(
|
|
47
47
|
X,
|
|
48
48
|
{
|
|
49
49
|
value: {
|
|
50
50
|
employeeStateTaxes: d,
|
|
51
51
|
isAdmin: S,
|
|
52
|
-
isPending:
|
|
52
|
+
isPending: b
|
|
53
53
|
},
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
-
await
|
|
56
|
-
const { states:
|
|
57
|
-
if (
|
|
54
|
+
children: /* @__PURE__ */ s(L, { ...E, children: /* @__PURE__ */ s(G, { onSubmit: N(async (r) => {
|
|
55
|
+
await _(r, async (a) => {
|
|
56
|
+
const { states: t } = a;
|
|
57
|
+
if (t && Object.keys(t).length > 0) {
|
|
58
58
|
const m = [];
|
|
59
|
-
for (const
|
|
60
|
-
const l =
|
|
61
|
-
l &&
|
|
59
|
+
for (const o of d) {
|
|
60
|
+
const l = o.state;
|
|
61
|
+
l && o.questions !== void 0 && m.push({
|
|
62
62
|
state: l,
|
|
63
|
-
questions:
|
|
64
|
-
if (
|
|
63
|
+
questions: o.questions.map((e) => {
|
|
64
|
+
if (e.isQuestionForAdminOnly && !S)
|
|
65
65
|
return null;
|
|
66
|
-
const i =
|
|
66
|
+
const i = t[l]?.[F(e.key)];
|
|
67
67
|
let f;
|
|
68
68
|
return i == null || typeof i == "number" && isNaN(i) ? f = "" : i instanceof Date ? f = isNaN(i.getTime()) ? "" : i.toISOString().split("T")[0] ?? "" : f = i, {
|
|
69
|
-
key:
|
|
69
|
+
key: e.key,
|
|
70
70
|
answers: [
|
|
71
71
|
{
|
|
72
|
-
validFrom:
|
|
73
|
-
validUpTo:
|
|
72
|
+
validFrom: e.answers[0]?.validFrom ?? q,
|
|
73
|
+
validUpTo: e.answers[0]?.validUpTo ?? null,
|
|
74
74
|
value: f
|
|
75
75
|
}
|
|
76
76
|
]
|
|
77
77
|
};
|
|
78
|
-
}).filter((
|
|
78
|
+
}).filter((e) => e !== null)
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
const n = await
|
|
81
|
+
const n = await w({
|
|
82
82
|
request: { employeeUuid: c, employeeStateTaxesRequest: { states: m } }
|
|
83
83
|
});
|
|
84
84
|
T(x.EMPLOYEE_STATE_TAXES_UPDATED, n);
|
|
85
85
|
}
|
|
86
86
|
T(x.EMPLOYEE_STATE_TAXES_DONE);
|
|
87
87
|
});
|
|
88
|
-
}), children: y || /* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
88
|
+
}), children: y || /* @__PURE__ */ O(P, { children: [
|
|
89
|
+
/* @__PURE__ */ s(j, {}),
|
|
90
|
+
/* @__PURE__ */ s(z, {})
|
|
91
91
|
] }) }) })
|
|
92
92
|
}
|
|
93
93
|
) });
|
|
94
94
|
};
|
|
95
95
|
export {
|
|
96
|
-
|
|
96
|
+
de as StateTaxes
|
|
97
97
|
};
|
|
98
98
|
//# sourceMappingURL=StateTaxes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTaxes.js","sources":["../../../../src/components/Employee/StateTaxes/StateTaxes.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useEffect } from 'react'\nimport { useEmployeeTaxSetupGetStateTaxesSuspense } from '@gusto/embedded-api/react-query/employeeTaxSetupGetStateTaxes'\nimport { useEmployeeTaxSetupUpdateStateTaxesMutation } from '@gusto/embedded-api/react-query/employeeTaxSetupUpdateStateTaxes'\nimport { StateForm } from './StateForm'\nimport { StateFormSchema, type StateFormPayload } from './StateForm'\nimport { Actions } from './Actions'\nimport { StateTaxesProvider } from './useStateTaxes'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { snakeCaseToCamelCase, normalizeErrorKeyForForm } from '@/helpers/formattedStrings'\n\nconst DEFAULT_TAX_VALID_FROM = '2010-01-01'\n\ninterface StateTaxesProps extends CommonComponentInterface<'Employee.StateTaxes'> {\n employeeId: string\n isAdmin?: boolean\n}\n\nexport function StateTaxes(props: StateTaxesProps & BaseComponentInterface) {\n return (\n <BaseComponent<'Employee.StateTaxes'> {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nconst Root = (props: StateTaxesProps) => {\n const { employeeId, className, children, isAdmin = false, dictionary } = props\n const { onEvent, fieldErrors, baseSubmitHandler } = useBase()\n useI18n('Employee.StateTaxes')\n useComponentDictionary('Employee.StateTaxes', dictionary)\n\n const { data: stateData } = useEmployeeTaxSetupGetStateTaxesSuspense({\n employeeUuid: employeeId,\n })\n const employeeStateTaxes = stateData.employeeStateTaxesList!\n const { mutateAsync: updateStateTaxes, isPending } = useEmployeeTaxSetupUpdateStateTaxesMutation()\n\n const defaultValues = {\n states: employeeStateTaxes.reduce((acc: Record<string, unknown>, state) => {\n if (state.state) {\n acc[state.state] = state.questions?.reduce((acc: Record<string, unknown>, question) => {\n const value = question.answers[0]?.value\n const key = snakeCaseToCamelCase(question.key)\n const isDateField = question.inputQuestionFormat.type.toLowerCase() === 'date'\n\n if (key === 'fileNewHireReport') {\n acc[key] = typeof value === 'undefined' ? true : value\n } else if (isDateField && typeof value === 'string') {\n const trimmedValue = value.trim()\n acc[key] = trimmedValue === '' ? undefined : new Date(trimmedValue)\n } else {\n acc[key] = value\n }\n return acc\n }, {})\n }\n return acc\n }, {}),\n }\n\n const formMethods = useForm<Record<string, unknown>, unknown, StateFormPayload>({\n resolver: zodResolver(StateFormSchema),\n defaultValues,\n })\n const { handleSubmit, setError: _setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors && fieldErrors.length > 0) {\n fieldErrors.forEach(msgObject => {\n const key = normalizeErrorKeyForForm(msgObject.errorKey)\n const message = typeof msgObject.message === 'string' ? msgObject.message : 'Unknown error'\n _setError(key, { type: 'custom', message })\n })\n }\n }, [fieldErrors, _setError])\n\n const onSubmit: SubmitHandler<StateFormPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { states: statesPayload } = payload\n\n if (statesPayload && Object.keys(statesPayload).length > 0) {\n const states = []\n\n for (const state of employeeStateTaxes) {\n const stateName = state.state\n\n if (stateName && state.questions !== undefined) {\n states.push({\n state: stateName,\n questions: state.questions\n .map(question => {\n if (question.isQuestionForAdminOnly && !isAdmin) {\n return null\n }\n const formValue = statesPayload[stateName]?.[snakeCaseToCamelCase(question.key)]\n\n let serializedValue: string | number | boolean\n if (formValue == null || (typeof formValue === 'number' && isNaN(formValue))) {\n serializedValue = ''\n } else if (formValue instanceof Date) {\n serializedValue = isNaN(formValue.getTime())\n ? ''\n : (formValue.toISOString().split('T')[0] ?? '')\n } else {\n serializedValue = formValue as string | number | boolean\n }\n\n return {\n key: question.key,\n answers: [\n {\n validFrom: question.answers[0]?.validFrom ?? DEFAULT_TAX_VALID_FROM,\n validUpTo: question.answers[0]?.validUpTo ?? null,\n value: serializedValue,\n },\n ],\n }\n })\n .filter(q => q !== null),\n })\n }\n }\n\n const stateTaxesResponse = await updateStateTaxes({\n request: { employeeUuid: employeeId, employeeStateTaxesRequest: { states } },\n })\n onEvent(componentEvents.EMPLOYEE_STATE_TAXES_UPDATED, stateTaxesResponse)\n }\n\n onEvent(componentEvents.EMPLOYEE_STATE_TAXES_DONE)\n })\n }\n\n return (\n <section className={className}>\n <StateTaxesProvider\n value={{\n employeeStateTaxes,\n isAdmin: isAdmin,\n isPending,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <StateForm />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </StateTaxesProvider>\n </section>\n )\n}\n"],"names":["DEFAULT_TAX_VALID_FROM","StateTaxes","props","jsx","BaseComponent","Root","employeeId","className","children","isAdmin","dictionary","onEvent","fieldErrors","baseSubmitHandler","useBase","useI18n","useComponentDictionary","stateData","useEmployeeTaxSetupGetStateTaxesSuspense","employeeStateTaxes","updateStateTaxes","isPending","useEmployeeTaxSetupUpdateStateTaxesMutation","defaultValues","acc","state","question","value","key","snakeCaseToCamelCase","isDateField","trimmedValue","formMethods","useForm","zodResolver","StateFormSchema","handleSubmit","_setError","useEffect","msgObject","normalizeErrorKeyForForm","message","StateTaxesProvider","FormProvider","Form","data","payload","statesPayload","states","stateName","formValue","serializedValue","q","stateTaxesResponse","componentEvents","jsxs","Fragment","StateForm","Actions"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAMA,IAAyB;AAOxB,SAASC,GAAWC,GAAiD;AAC1E,SACE,gBAAAC,EAACC,KAAsC,GAAGF,GACxC,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAEA,MAAMG,IAAO,CAACH,MAA2B;AACvC,QAAM,EAAE,YAAAI,GAAY,WAAAC,GAAW,UAAAC,GAAU,SAAAC,IAAU,IAAO,YAAAC,MAAeR,GACnE,EAAE,SAAAS,GAAS,aAAAC,GAAa,mBAAAC,EAAA,IAAsBC,EAAA;AACpD,EAAAC,EAAQ,qBAAqB,GAC7BC,EAAuB,uBAAuBN,CAAU;AAExD,QAAM,EAAE,MAAMO,EAAA,IAAcC,EAAyC;AAAA,IACnE,cAAcZ;AAAA,EAAA,CACf,GACKa,IAAqBF,EAAU,wBAC/B,EAAE,aAAaG,GAAkB,WAAAC,EAAA,IAAcC,EAAA,GAE/CC,IAAgB;AAAA,IACpB,QAAQJ,EAAmB,OAAO,CAACK,GAA8BC,OAC3DA,EAAM,UACRD,EAAIC,EAAM,KAAK,IAAIA,EAAM,WAAW,OAAO,CAACD,GAA8BE,MAAa;AACrF,YAAMC,IAAQD,EAAS,QAAQ,CAAC,GAAG,OAC7BE,IAAMC,EAAqBH,EAAS,GAAG,GACvCI,IAAcJ,EAAS,oBAAoB,KAAK,kBAAkB;AAExE,UAAIE,MAAQ;AACVJ,QAAAA,EAAII,CAAG,IAAI,OAAOD,IAAU,MAAc,KAAOA;AAAA,eACxCG,KAAe,OAAOH,KAAU,UAAU;AACnD,cAAMI,IAAeJ,EAAM,KAAA;AAC3BH,QAAAA,EAAII,CAAG,IAAIG,MAAiB,KAAK,SAAY,IA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AC,MAAY;AACf,sBAAIA,EAAS,0BAA0B,CAACjB;AACtC,2BAAO;AAET,wBAAMyC,IAAYH,EAAcE,CAAS,IAAIpB,EAAqBH,EAAS,GAAG,CAAC;AAE/E,sBAAIyB;AACJ,yBAAID,KAAa,QAAS,OAAOA,KAAc,YAAY,MAAMA,CAAS,IACxEC,IAAkB,KACTD,aAAqB,OAC9BC,IAAkB,MAAMD,EAAU,QAAA,CAAS,IACvC,KACCA,EAAU,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC,KAAK,KAE9CC,IAAkBD,GAGb;AAAA,oBACL,KAAKxB,EAAS;AAAA,oBACd,SAAS;AAAA,sBACP;AAAA,wBACE,WAAWA,EAAS,QAAQ,CAAC,GAAG,aAAa1B;AAAA,wBAC7C,WAAW0B,EAAS,QAAQ,CAAC,GAAG,aAAa;AAAA,wBAC7C,OAAOyB;AAAA,sBAAA;AAAA,oBACT;AAAA,kBACF;AAAA,gBAEJ,CAAC,EACA,OAAO,CAAAC,MAAKA,MAAM,IAAI;AAAA,cAAA,CAC1B;AAAA,YAEL;AAEA,kBAAMC,IAAqB,MAAMjC,EAAiB;AAAA,cAChD,SAAS,EAAE,cAAcd,GAAY,2BAA2B,EAAE,QAAA0C,IAAO;AAAA,YAAE,CAC5E;AACD,YAAArC,EAAQ2C,EAAgB,8BAA8BD,CAAkB;AAAA,UAC1E;AAEA,UAAA1C,EAAQ2C,EAAgB,yBAAyB;AAAA,QACnD,CAAC;AAAA,MACH,CAY6C,GAClC,UAAA9C,KAGC,gBAAA+C,EAAAC,GAAA,EACE,UAAA;AAAA,QAAA,gBAAArD,EAACsD,GAAA,EAAU;AAAA,0BACVC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,GAEJ,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"StateTaxes.js","sources":["../../../../src/components/Employee/StateTaxes/StateTaxes.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useEffect } from 'react'\nimport { useEmployeeTaxSetupGetStateTaxesSuspense } from '@gusto/embedded-api/react-query/employeeTaxSetupGetStateTaxes'\nimport { useEmployeeTaxSetupUpdateStateTaxesMutation } from '@gusto/embedded-api/react-query/employeeTaxSetupUpdateStateTaxes'\nimport { StateForm } from './StateForm'\nimport { StateFormSchema, type StateFormPayload } from './StateForm'\nimport { Actions } from './Actions'\nimport { StateTaxesProvider } from './useStateTaxes'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { snakeCaseToCamelCase, normalizeErrorKeyForForm } from '@/helpers/formattedStrings'\n\nconst DEFAULT_TAX_VALID_FROM = '2010-01-01'\n\ninterface StateTaxesProps extends CommonComponentInterface<'Employee.StateTaxes'> {\n employeeId: string\n isAdmin?: boolean\n}\n\nexport function StateTaxes(props: StateTaxesProps & BaseComponentInterface) {\n return (\n <BaseComponent<'Employee.StateTaxes'> {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nconst Root = (props: StateTaxesProps) => {\n const { employeeId, className, children, isAdmin = false, dictionary } = props\n const { onEvent, error, baseSubmitHandler } = useBase()\n useI18n('Employee.StateTaxes')\n useComponentDictionary('Employee.StateTaxes', dictionary)\n\n const { data: stateData } = useEmployeeTaxSetupGetStateTaxesSuspense({\n employeeUuid: employeeId,\n })\n const employeeStateTaxes = stateData.employeeStateTaxesList!\n const { mutateAsync: updateStateTaxes, isPending } = useEmployeeTaxSetupUpdateStateTaxesMutation()\n\n const defaultValues = {\n states: employeeStateTaxes.reduce((acc: Record<string, unknown>, state) => {\n if (state.state) {\n acc[state.state] = state.questions?.reduce((acc: Record<string, unknown>, question) => {\n const value = question.answers[0]?.value\n const key = snakeCaseToCamelCase(question.key)\n const isDateField = question.inputQuestionFormat.type.toLowerCase() === 'date'\n\n if (key === 'fileNewHireReport') {\n acc[key] = typeof value === 'undefined' ? true : value\n } else if (isDateField && typeof value === 'string') {\n const trimmedValue = value.trim()\n acc[key] = trimmedValue === '' ? undefined : new Date(trimmedValue)\n } else {\n acc[key] = value\n }\n return acc\n }, {})\n }\n return acc\n }, {}),\n }\n\n const formMethods = useForm<Record<string, unknown>, unknown, StateFormPayload>({\n resolver: zodResolver(StateFormSchema),\n defaultValues,\n })\n const { handleSubmit, setError: _setError } = formMethods\n\n const fieldErrors = error?.fieldErrors\n useEffect(() => {\n if (fieldErrors && fieldErrors.length > 0) {\n fieldErrors.forEach(fieldError => {\n const key = normalizeErrorKeyForForm(fieldError.field)\n _setError(key, { type: 'custom', message: fieldError.message })\n })\n }\n }, [fieldErrors, _setError])\n\n const onSubmit: SubmitHandler<StateFormPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { states: statesPayload } = payload\n\n if (statesPayload && Object.keys(statesPayload).length > 0) {\n const states = []\n\n for (const state of employeeStateTaxes) {\n const stateName = state.state\n\n if (stateName && state.questions !== undefined) {\n states.push({\n state: stateName,\n questions: state.questions\n .map(question => {\n if (question.isQuestionForAdminOnly && !isAdmin) {\n return null\n }\n const formValue = statesPayload[stateName]?.[snakeCaseToCamelCase(question.key)]\n\n let serializedValue: string | number | boolean\n if (formValue == null || (typeof formValue === 'number' && isNaN(formValue))) {\n serializedValue = ''\n } else if (formValue instanceof Date) {\n serializedValue = isNaN(formValue.getTime())\n ? ''\n : (formValue.toISOString().split('T')[0] ?? '')\n } else {\n serializedValue = formValue as string | number | boolean\n }\n\n return {\n key: question.key,\n answers: [\n {\n validFrom: question.answers[0]?.validFrom ?? DEFAULT_TAX_VALID_FROM,\n validUpTo: question.answers[0]?.validUpTo ?? null,\n value: serializedValue,\n },\n ],\n }\n })\n .filter(q => q !== null),\n })\n }\n }\n\n const stateTaxesResponse = await updateStateTaxes({\n request: { employeeUuid: employeeId, employeeStateTaxesRequest: { states } },\n })\n onEvent(componentEvents.EMPLOYEE_STATE_TAXES_UPDATED, stateTaxesResponse)\n }\n\n onEvent(componentEvents.EMPLOYEE_STATE_TAXES_DONE)\n })\n }\n\n return (\n <section className={className}>\n <StateTaxesProvider\n value={{\n employeeStateTaxes,\n isAdmin: isAdmin,\n isPending,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <StateForm />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </StateTaxesProvider>\n </section>\n )\n}\n"],"names":["DEFAULT_TAX_VALID_FROM","StateTaxes","props","jsx","BaseComponent","Root","employeeId","className","children","isAdmin","dictionary","onEvent","error","baseSubmitHandler","useBase","useI18n","useComponentDictionary","stateData","useEmployeeTaxSetupGetStateTaxesSuspense","employeeStateTaxes","updateStateTaxes","isPending","useEmployeeTaxSetupUpdateStateTaxesMutation","defaultValues","acc","state","question","value","key","snakeCaseToCamelCase","isDateField","trimmedValue","formMethods","useForm","zodResolver","StateFormSchema","handleSubmit","_setError","fieldErrors","useEffect","fieldError","normalizeErrorKeyForForm","StateTaxesProvider","FormProvider","Form","data","payload","statesPayload","states","stateName","formValue","serializedValue","q","stateTaxesResponse","componentEvents","jsxs","Fragment","StateForm","Actions"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAMA,IAAyB;AAOxB,SAASC,GAAWC,GAAiD;AAC1E,SACE,gBAAAC,EAACC,KAAsC,GAAGF,GACxC,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAEA,MAAMG,IAAO,CAACH,MAA2B;AACvC,QAAM,EAAE,YAAAI,GAAY,WAAAC,GAAW,UAAAC,GAAU,SAAAC,IAAU,IAAO,YAAAC,MAAeR,GACnE,EAAE,SAAAS,GAAS,OAAAC,GAAO,mBAAAC,EAAA,IAAsBC,EAAA;AAC9C,EAAAC,E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AAAA,gBAEJ,CAAC,EACA,OAAO,CAAAC,MAAKA,MAAM,IAAI;AAAA,cAAA,CAC1B;AAAA,YAEL;AAEA,kBAAMC,IAAqB,MAAMjC,EAAiB;AAAA,cAChD,SAAS,EAAE,cAAcd,GAAY,2BAA2B,EAAE,QAAA0C,IAAO;AAAA,YAAE,CAC5E;AACD,YAAArC,EAAQ2C,EAAgB,8BAA8BD,CAAkB;AAAA,UAC1E;AAEA,UAAA1C,EAAQ2C,EAAgB,yBAAyB;AAAA,QACnD,CAAC;AAAA,MACH,CAY6C,GAClC,UAAA9C,KAGC,gBAAA+C,EAAAC,GAAA,EACE,UAAA;AAAA,QAAA,gBAAArD,EAACsD,GAAA,EAAU;AAAA,0BACVC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,GAEJ,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -2,20 +2,18 @@ import "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import "react-error-boundary";
|
|
4
4
|
import "react-i18next";
|
|
5
|
-
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
6
|
-
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
7
5
|
import "@tanstack/react-query";
|
|
8
6
|
import "../../Base/useBase.js";
|
|
9
7
|
import "../../../shared/constants.js";
|
|
10
8
|
import "classnames";
|
|
11
9
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
14
|
-
import "
|
|
10
|
+
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
11
|
+
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
12
|
+
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
15
13
|
import { createCompoundContext as t } from "../../Base/createCompoundContext.js";
|
|
16
|
-
const [
|
|
14
|
+
const [c, d] = t("StateTaxesContext");
|
|
17
15
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
d as StateTaxesProvider,
|
|
17
|
+
c as useStateTaxes
|
|
20
18
|
};
|
|
21
19
|
//# sourceMappingURL=useStateTaxes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStateTaxes.js","sources":["../../../../src/components/Employee/StateTaxes/useStateTaxes.ts"],"sourcesContent":["import type { EmployeeStateTaxesList } from '@gusto/embedded-api/models/components/employeestatetaxeslist'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesContextType = {\n employeeStateTaxes: EmployeeStateTaxesList[]\n isPending: boolean\n isAdmin: boolean\n}\n\nconst [useStateTaxes, StateTaxesProvider] =\n createCompoundContext<StateTaxesContextType>('StateTaxesContext')\nexport { useStateTaxes, StateTaxesProvider }\n"],"names":["useStateTaxes","StateTaxesProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStateTaxes.js","sources":["../../../../src/components/Employee/StateTaxes/useStateTaxes.ts"],"sourcesContent":["import type { EmployeeStateTaxesList } from '@gusto/embedded-api/models/components/employeestatetaxeslist'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesContextType = {\n employeeStateTaxes: EmployeeStateTaxesList[]\n isPending: boolean\n isAdmin: boolean\n}\n\nconst [useStateTaxes, StateTaxesProvider] =\n createCompoundContext<StateTaxesContextType>('StateTaxesContext')\nexport { useStateTaxes, StateTaxesProvider }\n"],"names":["useStateTaxes","StateTaxesProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AASA,MAAM,CAACA,GAAeC,CAAkB,IACtCC,EAA6C,mBAAmB;"}
|