@gusto/embedded-react-sdk 0.31.1 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/dist/assets/icons/icon-arrow-right.svg.js +10 -0
- package/dist/assets/icons/icon-arrow-right.svg.js.map +1 -0
- package/dist/components/Base/Base.js +46 -45
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/useBase.d.ts +2 -3
- package/dist/components/Base/useBase.js.map +1 -1
- package/dist/components/Base/useBaseSubmit.js +32 -19
- package/dist/components/Base/useBaseSubmit.js.map +1 -1
- package/dist/components/Common/DataView/DataView.js +1 -1
- package/dist/components/Common/DocumentList/DocumentList.js +1 -1
- package/dist/components/Common/DocumentViewer/DocumentViewer.js +1 -1
- package/dist/components/Common/FlowBreadcrumbs/FlowBreadcrumbs.js +1 -1
- package/dist/components/Common/MultiSelectComboBox/MultiSelectComboBox.d.ts +2 -0
- package/dist/components/Common/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +16 -0
- package/dist/components/Common/MultiSelectComboBox/index.d.ts +3 -0
- package/dist/components/Common/RequirementsList/RequirementsList.js +1 -1
- package/dist/components/Common/RequirementsList/RequirementsList.js.map +1 -1
- package/dist/components/Common/RequirementsList/RequirementsList.module.scss.js +1 -1
- package/dist/components/Common/SignatureForm/SignatureForm.js +3 -2
- package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +4 -3
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +7 -6
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Common/UI/Badge/Badge.js +39 -8
- package/dist/components/Common/UI/Badge/Badge.js.map +1 -1
- package/dist/components/Common/UI/Badge/Badge.module.scss.js +8 -4
- package/dist/components/Common/UI/Badge/Badge.module.scss.js.map +1 -1
- package/dist/components/Common/UI/Badge/BadgeTypes.d.ts +12 -0
- package/dist/components/Common/UI/Badge/BadgeTypes.js.map +1 -1
- package/dist/components/Common/UI/Box/Box.d.ts +2 -0
- package/dist/components/Common/UI/Box/Box.js +13 -0
- package/dist/components/Common/UI/Box/Box.js.map +1 -0
- package/dist/components/Common/UI/Box/Box.module.scss.js +12 -0
- package/dist/components/Common/UI/Box/Box.module.scss.js.map +1 -0
- package/dist/components/Common/UI/Box/BoxTypes.d.ts +15 -0
- package/dist/components/Common/UI/Box/index.d.ts +2 -0
- package/dist/components/Common/UI/Dialog/Dialog.js +1 -1
- package/dist/components/Common/UI/Input/InputTypes.d.ts +1 -1
- package/dist/components/Common/UI/Input/InputTypes.js.map +1 -1
- package/dist/components/Common/UI/List/List.module.scss.js +1 -1
- package/dist/components/Common/UI/Modal/Modal.js +1 -1
- package/dist/components/Common/UI/Tabs/Tabs.js +1 -1
- package/dist/components/Common/UI/TextInput/TextInput.js +30 -28
- package/dist/components/Common/UI/TextInput/TextInput.js.map +1 -1
- package/dist/components/Common/UI/TextInput/TextInputTypes.d.ts +1 -1
- package/dist/components/Common/UI/TextInput/TextInputTypes.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.js +3 -2
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +3 -2
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +3 -2
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js.map +1 -1
- 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 +2 -2
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +3 -2
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.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 +2 -2
- package/dist/components/Company/AssignSignatory/TitleSelect.js +5 -5
- package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +2 -2
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +9 -8
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +5 -4
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +2 -2
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +3 -2
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +7 -6
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +5 -4
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +3 -2
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js +9 -8
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +2 -2
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +3 -2
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +2 -2
- package/dist/components/Company/FederalTaxes/Actions.js +7 -6
- package/dist/components/Company/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.js +3 -2
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +3 -2
- package/dist/components/Company/FederalTaxes/Form.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +2 -2
- package/dist/components/Company/Industry/Actions.js +8 -7
- package/dist/components/Company/Industry/Actions.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +2 -2
- package/dist/components/Company/Industry/Edit.js +3 -2
- package/dist/components/Company/Industry/Edit.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +7 -6
- package/dist/components/Company/Locations/LocationForm/Actions.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/LocationForm.js +3 -2
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +2 -2
- package/dist/components/Company/Locations/LocationsList/Actions.js +3 -2
- package/dist/components/Company/Locations/LocationsList/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +7 -6
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.js +3 -2
- package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +2 -2
- package/dist/components/Company/OnboardingOverview/Completed.js +11 -10
- package/dist/components/Company/OnboardingOverview/Completed.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js +38 -26
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js +7 -6
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +2 -2
- package/dist/components/Company/PaySchedule/PaySchedule.js +24 -21
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +3 -2
- package/dist/components/Company/PaySchedule/_parts/Actions.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/_parts/Head.js +9 -8
- package/dist/components/Company/PaySchedule/_parts/Head.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.js +6 -5
- package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +2 -2
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +3 -2
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +40 -46
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +2 -2
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +3 -2
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +3 -2
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +2 -2
- package/dist/components/Company/index.js +20 -20
- package/dist/components/Contractor/Address/Address.js +6 -6
- package/dist/components/Contractor/Address/Address.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 +2 -2
- package/dist/components/Contractor/ContractorList/index.js +16 -15
- package/dist/components/Contractor/ContractorList/index.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +14 -13
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +11 -10
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +3 -2
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +3 -2
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +151 -116
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.d.ts +4 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js +55 -50
- package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentFormSchema.d.ts +84 -0
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentFormSchema.js +23 -0
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentFormSchema.js.map +1 -0
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.d.ts +3 -31
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +61 -66
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/FastAchSubmissionBlockerBanner.d.ts +2 -1
- package/dist/components/Contractor/Payments/CreatePayment/FastAchSubmissionBlockerBanner.js +21 -22
- package/dist/components/Contractor/Payments/CreatePayment/FastAchSubmissionBlockerBanner.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.d.ts +2 -1
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js +32 -29
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js +0 -1
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js +3 -2
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatementPresentation.js +3 -2
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatementPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js +3 -2
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js +27 -27
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js.map +1 -1
- package/dist/components/Contractor/Profile/useContractorProfile.js +2 -2
- package/dist/components/Contractor/Submit/Submit.js +20 -19
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +13 -12
- package/dist/components/Employee/Compensation/Actions.js.map +1 -1
- package/dist/components/Employee/Compensation/Edit.js +3 -2
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Compensation/List.js +23 -22
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +2 -2
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +2 -2
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +2 -2
- package/dist/components/Employee/Deductions/DeductionsList/DeductionsList.js +7 -6
- package/dist/components/Employee/Deductions/DeductionsList/DeductionsList.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/Deductions/stateMachine.js +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +9 -8
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js +24 -22
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js +3 -2
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.d.ts +1 -0
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +2 -2
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentSigner.js +9 -9
- package/dist/components/Employee/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +46 -41
- package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.js +150 -111
- package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +3 -2
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +2 -2
- package/dist/components/Employee/DocumentSigner/documentSignerStateMachine.d.ts +1 -0
- package/dist/components/Employee/DocumentSigner/documentSignerStateMachine.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/stateMachine.js +34 -22
- package/dist/components/Employee/DocumentSigner/stateMachine.js.map +1 -1
- package/dist/components/Employee/EmployeeDocuments/EmployeeDocumentsPresentation.js +3 -2
- package/dist/components/Employee/EmployeeDocuments/EmployeeDocumentsPresentation.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +7 -6
- package/dist/components/Employee/EmployeeList/Actions.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Head.js +6 -5
- package/dist/components/Employee/EmployeeList/Head.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +3 -2
- package/dist/components/Employee/EmployeeList/List.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +2 -2
- package/dist/components/Employee/FederalTaxes/Actions.js +6 -5
- package/dist/components/Employee/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalForm.js +5 -4
- package/dist/components/Employee/FederalTaxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalTaxes.js +16 -15
- package/dist/components/Employee/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +2 -2
- package/dist/components/Employee/Landing/Landing.js +50 -44
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Actions.js +6 -5
- package/dist/components/Employee/PaymentMethod/Actions.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +3 -2
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +3 -2
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +6 -5
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +3 -2
- package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +2 -2
- package/dist/components/Employee/Profile/Actions.js +6 -5
- package/dist/components/Employee/Profile/Actions.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +8 -7
- package/dist/components/Employee/Profile/AdminPersonalDetails.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 +9 -8
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +2 -2
- package/dist/components/Employee/StateTaxes/Actions.js +6 -5
- package/dist/components/Employee/StateTaxes/Actions.js.map +1 -1
- package/dist/components/Employee/StateTaxes/StateTaxes.js +29 -29
- package/dist/components/Employee/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +2 -2
- package/dist/components/Employee/Taxes/Actions.js +7 -6
- package/dist/components/Employee/Taxes/Actions.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +7 -6
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +19 -19
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +2 -2
- package/dist/components/Employee/index.js +22 -22
- package/dist/components/Flow/Flow.js +8 -7
- package/dist/components/Flow/Flow.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js +1 -0
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.d.ts +0 -1
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js +32 -37
- package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequests.d.ts +1 -2
- package/dist/components/InformationRequests/InformationRequests.js +36 -43
- package/dist/components/InformationRequests/InformationRequests.js.map +1 -1
- package/dist/components/InformationRequests/index.js +4 -4
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +1 -0
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js.map +1 -1
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +23 -21
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.d.ts +2 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +79 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +2 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +46 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +14 -0
- package/dist/components/Payroll/OffCycleCreation/index.d.ts +3 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.d.ts +2 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.js +44 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.js.map +1 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/index.d.ts +3 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/types.d.ts +10 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.d.ts +1 -2
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +37 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js.map +1 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.module.scss.js +12 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.d.ts +0 -4
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.js +48 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.js.map +1 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.js +18 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.js.map +1 -0
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelection.js +26 -27
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelection.js.map +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.d.ts +3 -3
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +17 -16
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.d.ts +2 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModalTypes.d.ts +8 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/index.d.ts +3 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.d.ts +2 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.d.ts +17 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/index.d.ts +3 -0
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.d.ts +3 -8
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.js +37 -35
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.js.map +1 -1
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +16 -24
- package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
- package/dist/components/Payroll/PayrollBlocker/payrollHelpers.d.ts +2 -0
- package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js +30 -24
- package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js.map +1 -1
- package/dist/components/Payroll/PayrollBlocker/payrollHelpers.test.d.ts +1 -0
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +12 -8
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +42 -41
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +4 -3
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +6 -5
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +38 -35
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +1 -0
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +16 -15
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +32 -32
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +19 -18
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +70 -67
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +2 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +39 -36
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchSubmissionBlockerBanner.d.ts +2 -1
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchSubmissionBlockerBanner.js +18 -19
- package/dist/components/Payroll/PayrollOverview/SubmissionBlockers/FastAchSubmissionBlockerBanner.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesList/RecoveryCasesList.js +3 -2
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesList/RecoveryCasesList.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesResubmit/RecoveryCasesResubmit.js +7 -6
- package/dist/components/Payroll/RecoveryCases/RecoveryCasesResubmit/RecoveryCasesResubmit.js.map +1 -1
- package/dist/components/Payroll/RecoveryCases/useRecoveryCaseErrorCode.js +4 -3
- package/dist/components/Payroll/RecoveryCases/useRecoveryCaseErrorCode.js.map +1 -1
- package/dist/components/Payroll/index.d.ts +4 -0
- package/dist/components/Payroll/index.js +22 -18
- package/dist/components/Payroll/index.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +2 -2
- package/dist/contexts/ComponentAdapter/adapters/defaultComponentAdapter.js +48 -46
- package/dist/contexts/ComponentAdapter/adapters/defaultComponentAdapter.js.map +1 -1
- package/dist/contexts/ComponentAdapter/componentAdapterTypes.d.ts +1 -0
- package/dist/contexts/ComponentAdapter/useComponentContext.d.ts +2 -0
- package/dist/contexts/ComponentAdapter/useComponentContext.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +3 -2
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ThemeProvider/theme.d.ts +1 -0
- package/dist/contexts/ThemeProvider/theme.js +1 -0
- package/dist/contexts/ThemeProvider/theme.js.map +1 -1
- package/dist/helpers/apiErrorToList.js +14 -8
- package/dist/helpers/apiErrorToList.js.map +1 -1
- package/dist/helpers/dateFormatting.js +61 -45
- package/dist/helpers/dateFormatting.js.map +1 -1
- package/dist/helpers/formattedStrings.d.ts +1 -0
- package/dist/helpers/formattedStrings.js +21 -20
- package/dist/helpers/formattedStrings.js.map +1 -1
- package/dist/hooks/useOverflowDetection/useOverflowDetection.js +5 -6
- package/dist/i18n/I18n.js +7 -7
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Contractor.Payments.CreatePayment.json.js +12 -12
- package/dist/i18n/en/Employee.EmployeeDocuments.json.js +1 -1
- package/dist/i18n/en/Employee.I9SignatureForm.json.js +83 -65
- package/dist/i18n/en/Employee.I9SignatureForm.json.js.map +1 -1
- package/dist/i18n/en/Employee.Landing.json.js +7 -9
- package/dist/i18n/en/Employee.Landing.json.js.map +1 -1
- package/dist/i18n/en/Payroll.OffCycleCreation.json.js +14 -0
- package/dist/i18n/en/Payroll.OffCycleCreation.json.js.map +1 -0
- package/dist/i18n/en/Payroll.OffCycleDeductionsSetting.json.js +12 -0
- package/dist/i18n/en/Payroll.OffCycleDeductionsSetting.json.js.map +1 -0
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js +18 -0
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js.map +1 -0
- package/dist/i18n/en/Payroll.PayrollBlocker.json.js +21 -19
- package/dist/i18n/en/Payroll.PayrollBlocker.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +1 -1
- package/dist/i18n/en/common.json.d.ts +4 -1
- package/dist/i18n/en/common.json.js +5 -5
- package/dist/shared/constants.d.ts +4 -0
- package/dist/shared/constants.js +6 -4
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +79 -2
- package/docs/reference/endpoint-inventory.json +1706 -0
- package/package.json +29 -13
- package/dist/components/Employee/Landing/Landing.module.scss.js +0 -8
- package/dist/components/Employee/Landing/Landing.module.scss.js.map +0 -1
|
@@ -7,8 +7,8 @@ import { useEmployeeTaxSetupGetFederalTaxesSuspense as B } from "@gusto/embedded
|
|
|
7
7
|
import { useEmployeeTaxSetupUpdateFederalTaxesMutation as H } from "@gusto/embedded-api/react-query/employeeTaxSetupUpdateFederalTaxes";
|
|
8
8
|
import { useEmployeeTaxSetupGetStateTaxesSuspense as Y } from "@gusto/embedded-api/react-query/employeeTaxSetupGetStateTaxes";
|
|
9
9
|
import { useEmployeeTaxSetupUpdateStateTaxesMutation as j } from "@gusto/embedded-api/react-query/employeeTaxSetupUpdateStateTaxes";
|
|
10
|
-
import { Actions as
|
|
11
|
-
import { FederalFormSchema as
|
|
10
|
+
import { Actions as z } from "./Actions.js";
|
|
11
|
+
import { FederalFormSchema as G, FederalForm as K } from "./FederalForm.js";
|
|
12
12
|
import { FederalHead as Q } from "./FederalHead.js";
|
|
13
13
|
import { StateFormSchema as Z, StateForm as $ } from "./StateForm.js";
|
|
14
14
|
import { TaxesProvider as ee } from "./useTaxes.js";
|
|
@@ -17,14 +17,14 @@ import { useBase as oe } from "../../Base/useBase.js";
|
|
|
17
17
|
import "../../Flow/useFlow.js";
|
|
18
18
|
import { useI18n as ae, useComponentDictionary as se } from "../../../i18n/I18n.js";
|
|
19
19
|
import { componentEvents as T } from "../../../shared/constants.js";
|
|
20
|
-
import { snakeCaseToCamelCase as A } from "../../../helpers/formattedStrings.js";
|
|
21
|
-
import { Form as
|
|
22
|
-
const
|
|
23
|
-
function
|
|
24
|
-
return /* @__PURE__ */ o(te, { ...i, children: /* @__PURE__ */ o(
|
|
20
|
+
import { snakeCaseToCamelCase as A, normalizeErrorKeyForForm as ne } from "../../../helpers/formattedStrings.js";
|
|
21
|
+
import { Form as re } from "../../Common/Form/Form.js";
|
|
22
|
+
const ie = "2010-01-01";
|
|
23
|
+
function Ue(i) {
|
|
24
|
+
return /* @__PURE__ */ o(te, { ...i, children: /* @__PURE__ */ o(le, { ...i, children: i.children }) });
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
const { employeeId: m, className:
|
|
26
|
+
const le = (i) => {
|
|
27
|
+
const { employeeId: m, className: v, children: S, isAdmin: E = !1, dictionary: D } = i, { onEvent: c, fieldErrors: u, baseSubmitHandler: _ } = oe();
|
|
28
28
|
ae("Employee.Taxes"), se("Employee.Taxes", D);
|
|
29
29
|
const { data: b } = B({
|
|
30
30
|
employeeUuid: m
|
|
@@ -49,15 +49,15 @@ const ie = (i) => {
|
|
|
49
49
|
additionalWithholding: e.additionalWithholding,
|
|
50
50
|
states: x
|
|
51
51
|
}, g = V({
|
|
52
|
-
resolver: J(
|
|
52
|
+
resolver: J(G.and(Z)),
|
|
53
53
|
defaultValues: I
|
|
54
54
|
}), { handleSubmit: L, setError: w } = g;
|
|
55
55
|
return q(() => {
|
|
56
56
|
u && u.length > 0 && u.forEach((a) => {
|
|
57
|
-
const s = a.errorKey
|
|
57
|
+
const s = ne(a.errorKey);
|
|
58
58
|
w(s, { type: "custom", message: a.message });
|
|
59
59
|
});
|
|
60
|
-
}, [u, w]), /* @__PURE__ */ o("section", { className:
|
|
60
|
+
}, [u, w]), /* @__PURE__ */ o("section", { className: v, children: /* @__PURE__ */ o(
|
|
61
61
|
ee,
|
|
62
62
|
{
|
|
63
63
|
value: {
|
|
@@ -65,7 +65,7 @@ const ie = (i) => {
|
|
|
65
65
|
isAdmin: E,
|
|
66
66
|
isPending: W || R
|
|
67
67
|
},
|
|
68
|
-
children: /* @__PURE__ */ o(X, { ...g, children: /* @__PURE__ */ o(
|
|
68
|
+
children: /* @__PURE__ */ o(X, { ...g, children: /* @__PURE__ */ o(re, { onSubmit: L(async (a) => {
|
|
69
69
|
await _(a, async (s) => {
|
|
70
70
|
const { states: n, ...t } = s, l = t.w4DataType === "rev_2020_w4" ? {
|
|
71
71
|
filingStatus: t.filingStatus,
|
|
@@ -89,10 +89,10 @@ const ie = (i) => {
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
if (c(T.EMPLOYEE_FEDERAL_TAXES_UPDATED, d), n && Object.keys(n).length > 0) {
|
|
92
|
-
const
|
|
92
|
+
const F = [];
|
|
93
93
|
for (const h of f) {
|
|
94
94
|
const y = h.state;
|
|
95
|
-
y && h.questions !== void 0 &&
|
|
95
|
+
y && h.questions !== void 0 && F.push({
|
|
96
96
|
state: y,
|
|
97
97
|
questions: h.questions.map((r) => {
|
|
98
98
|
if (r.isQuestionForAdminOnly && !E)
|
|
@@ -102,7 +102,7 @@ const ie = (i) => {
|
|
|
102
102
|
key: r.key,
|
|
103
103
|
answers: [
|
|
104
104
|
{
|
|
105
|
-
validFrom: r.answers[0]?.validFrom ??
|
|
105
|
+
validFrom: r.answers[0]?.validFrom ?? ie,
|
|
106
106
|
validUpTo: r.answers[0]?.validUpTo ?? null,
|
|
107
107
|
value: p == null || typeof p == "number" && isNaN(p) ? "" : p
|
|
108
108
|
}
|
|
@@ -112,7 +112,7 @@ const ie = (i) => {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
const M = await N({
|
|
115
|
-
request: { employeeUuid: m, employeeStateTaxesRequest: { states:
|
|
115
|
+
request: { employeeUuid: m, employeeStateTaxesRequest: { states: F } }
|
|
116
116
|
});
|
|
117
117
|
c(T.EMPLOYEE_STATE_TAXES_UPDATED, M);
|
|
118
118
|
}
|
|
@@ -122,12 +122,12 @@ const ie = (i) => {
|
|
|
122
122
|
/* @__PURE__ */ o(Q, {}),
|
|
123
123
|
/* @__PURE__ */ o(K, {}),
|
|
124
124
|
/* @__PURE__ */ o($, {}),
|
|
125
|
-
/* @__PURE__ */ o(
|
|
125
|
+
/* @__PURE__ */ o(z, {})
|
|
126
126
|
] }) }) })
|
|
127
127
|
}
|
|
128
128
|
) });
|
|
129
129
|
};
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
Ue as Taxes
|
|
132
132
|
};
|
|
133
133
|
//# sourceMappingURL=Taxes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Taxes.js","sources":["../../../../src/components/Employee/Taxes/Taxes.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { useEffect } from 'react'\nimport { useEmployeeTaxSetupGetFederalTaxesSuspense } from '@gusto/embedded-api/react-query/employeeTaxSetupGetFederalTaxes'\nimport { useEmployeeTaxSetupUpdateFederalTaxesMutation } from '@gusto/embedded-api/react-query/employeeTaxSetupUpdateFederalTaxes'\nimport { useEmployeeTaxSetupGetStateTaxesSuspense } from '@gusto/embedded-api/react-query/employeeTaxSetupGetStateTaxes'\nimport { useEmployeeTaxSetupUpdateStateTaxesMutation } from '@gusto/embedded-api/react-query/employeeTaxSetupUpdateStateTaxes'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlowComponents'\nimport { Actions } from './Actions'\nimport {\n FederalForm,\n FederalFormSchema,\n type FederalFormInputs,\n type FederalFormPayload,\n} from './FederalForm'\nimport { FederalHead } from './FederalHead'\nimport { StateForm, StateFormSchema, type StateFormPayload } from './StateForm'\nimport { TaxesProvider } from './useTaxes'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nconst DEFAULT_TAX_VALID_FROM = '2010-01-01'\n\ninterface TaxesProps extends CommonComponentInterface<'Employee.Taxes'> {\n employeeId: string\n isAdmin?: boolean\n}\n\n/**\n * @deprecated The Taxes component has been deprecated and will be removed in a future release.\n * The component has been split into separate components for state and federal. Use Employee.FederalTaxes\n * and Employee.StateTaxes components instead.\n */\nexport function Taxes(props: TaxesProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = (props: TaxesProps) => {\n const { employeeId, className, children, isAdmin = false, dictionary } = props\n const { onEvent, fieldErrors, baseSubmitHandler } = useBase()\n useI18n('Employee.Taxes')\n useComponentDictionary('Employee.Taxes', dictionary)\n\n const { data: fedData } = useEmployeeTaxSetupGetFederalTaxesSuspense({\n employeeUuid: employeeId,\n })\n const employeeFederalTax = fedData.employeeFederalTax!\n\n const { mutateAsync: updateFederalTaxes, isPending: isPendingFederalTaxes } =\n useEmployeeTaxSetupUpdateFederalTaxesMutation()\n\n const { data: stateData } = useEmployeeTaxSetupGetStateTaxesSuspense({\n employeeUuid: employeeId,\n })\n const employeeStateTaxes = stateData.employeeStateTaxesList!\n const { mutateAsync: updateStateTaxes, isPending: isPendingStateTaxes } =\n useEmployeeTaxSetupUpdateStateTaxesMutation()\n\n const isRev2020 = employeeFederalTax.w4DataType === 'rev_2020_w4'\n\n const statesDefaultValues = 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 if (key === 'fileNewHireReport') {\n acc[key] = typeof value === 'undefined' ? true : value\n } else {\n acc[key] = value\n }\n return acc\n }, {})\n }\n return acc\n }, {})\n\n const defaultValues: FederalFormInputs & { states: typeof statesDefaultValues } = isRev2020\n ? {\n w4DataType: 'rev_2020_w4',\n filingStatus: employeeFederalTax.filingStatus ?? '',\n twoJobs: employeeFederalTax.twoJobs ? 'true' : 'false',\n deductions: employeeFederalTax.deductions ? Number(employeeFederalTax.deductions) : 0,\n dependentsAmount: employeeFederalTax.dependentsAmount\n ? Number(employeeFederalTax.dependentsAmount)\n : 0,\n otherIncome: employeeFederalTax.otherIncome ? Number(employeeFederalTax.otherIncome) : 0,\n extraWithholding: employeeFederalTax.extraWithholding\n ? Number(employeeFederalTax.extraWithholding)\n : 0,\n states: statesDefaultValues,\n }\n : {\n w4DataType: 'pre_2020_w4',\n filingStatus: employeeFederalTax.filingStatus ?? '',\n federalWithholdingAllowance: employeeFederalTax.federalWithholdingAllowance ?? 0,\n additionalWithholding: employeeFederalTax.additionalWithholding,\n states: statesDefaultValues,\n }\n\n const formMethods = useForm<FederalFormInputs, unknown, FederalFormPayload & StateFormPayload>({\n resolver: zodResolver(FederalFormSchema.and(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 = msgObject.errorKey.replace('.value', '')\n _setError(key as keyof FederalFormInputs, { type: 'custom', message: msgObject.message })\n })\n }\n }, [fieldErrors, _setError])\n\n const onSubmit: SubmitHandler<FederalFormPayload & StateFormPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { states: statesPayload, ...federalPayload } = payload\n\n const requestBody =\n federalPayload.w4DataType === 'rev_2020_w4'\n ? {\n filingStatus: federalPayload.filingStatus,\n twoJobs: federalPayload.twoJobs === 'true',\n dependentsAmount: federalPayload.dependentsAmount,\n otherIncome: federalPayload.otherIncome,\n deductions: federalPayload.deductions,\n extraWithholding: federalPayload.extraWithholding,\n w4DataType: federalPayload.w4DataType,\n version: employeeFederalTax.version,\n }\n : {\n filingStatus: federalPayload.filingStatus,\n federalWithholdingAllowance: federalPayload.federalWithholdingAllowance,\n additionalWithholding: federalPayload.additionalWithholding,\n w4DataType: federalPayload.w4DataType,\n version: employeeFederalTax.version,\n }\n\n const federalTaxesResponse = await updateFederalTaxes({\n request: {\n employeeUuid: employeeId,\n requestBody,\n },\n })\n onEvent(componentEvents.EMPLOYEE_FEDERAL_TAXES_UPDATED, federalTaxesResponse)\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 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:\n formValue == null || (typeof formValue === 'number' && isNaN(formValue))\n ? ''\n : (formValue as string | number | boolean),\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_TAXES_DONE)\n })\n }\n\n return (\n <section className={className}>\n <TaxesProvider\n value={{\n employeeStateTaxes,\n isAdmin: isAdmin,\n isPending: isPendingFederalTaxes || isPendingStateTaxes,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <FederalHead />\n <FederalForm />\n <StateForm />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </TaxesProvider>\n </section>\n )\n}\n\nexport const TaxesContextual = () => {\n const { employeeId, onEvent, isAdmin } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation()\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'EmployeeTaxes',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <Taxes employeeId={employeeId} onEvent={onEvent} isAdmin={isAdmin ?? false} />\n}\n"],"names":["DEFAULT_TAX_VALID_FROM","Taxes","props","jsx","BaseComponent","Root","employeeId","className","children","isAdmin","dictionary","onEvent","fieldErrors","baseSubmitHandler","useBase","useI18n","useComponentDictionary","fedData","useEmployeeTaxSetupGetFederalTaxesSuspense","employeeFederalTax","updateFederalTaxes","isPendingFederalTaxes","useEmployeeTaxSetupUpdateFederalTaxesMutation","stateData","useEmployeeTaxSetupGetStateTaxesSuspense","employeeStateTaxes","updateStateTaxes","isPendingStateTaxes","useEmployeeTaxSetupUpdateStateTaxesMutation","isRev2020","statesDefaultValues","acc","state","question","value","key","snakeCaseToCamelCase","defaultValues","formMethods","useForm","zodResolver","FederalFormSchema","StateFormSchema","handleSubmit","_setError","useEffect","msgObject","TaxesProvider","FormProvider","Form","data","payload","statesPayload","federalPayload","requestBody","federalTaxesResponse","componentEvents","states","stateName","formValue","q","stateTaxesResponse","jsxs","Fragment","FederalHead","FederalForm","StateForm","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,KAAyB;AAYxB,SAASC,GAAMC,GAA4C;AAChE,SACE,gBAAAC,EAACC,IAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,KAAO,CAACH,MAAsB;AAClC,QAAM,EAAE,YAAAI,GAAY,WAAAC,GAAW,UAAAC,GAAU,SAAAC,IAAU,IAAO,YAAAC,MAAeR,GACnE,EAAE,SAAAS,GAAS,aAAAC,GAAa,mBAAAC,EAAA,IAAsBC,GAAA;AACpD,EAAAC,GAAQ,gBAAgB,GACxBC,GAAuB,kBAAkBN,CAAU;AAEnD,QAAM,EAAE,MAAMO,EAAA,IAAYC,EAA2C;AAAA,IACnE,cAAcZ;AAAA,EAAA,CACf,GACKa,IAAqBF,EAAQ,oBAE7B,EAAE,aAAaG,GAAoB,WAAWC,EAAA,IAClDC,EAAA,GAEI,EAAE,MAAMC,EAAA,IAAcC,EAAyC;AAAA,IACnE,cAAclB;AAAA,EAAA,CACf,GACKmB,IAAqBF,EAAU,wBAC/B,EAAE,aAAaG,GAAkB,WAAWC,EAAA,IAChDC,EAAA,GAEIC,IAAYV,EAAmB,eAAe,eAE9CW,IAAsBL,EAAmB,OAAO,CAACM,GAA8BC,OAC/EA,EAAM,UACRD,EAAIC,EAAM,KAAK,IAAIA,EAAM,WAAW,O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W1B,EAAM,UACd,IAAI,CAAAC,MAAY;AACf,sBAAIA,EAAS,0BAA0B,CAACxB;AACtC,2BAAO;AAET,wBAAMkD,IAAYP,EAAcM,CAAS,IAAItB,EAAqBH,EAAS,GAAG,CAAC;AAC/E,yBAAO;AAAA,oBACL,KAAKA,EAAS;AAAA,oBACd,SAAS;AAAA,sBACP;AAAA,wBACE,WAAWA,EAAS,QAAQ,CAAC,GAAG,aAAajC;AAAA,wBAC7C,WAAWiC,EAAS,QAAQ,CAAC,GAAG,aAAa;AAAA,wBAC7C,OACE0B,KAAa,QAAS,OAAOA,KAAc,YAAY,MAAMA,CAAS,IAClE,KACCA;AAAA,sBAAA;AAAA,oBACT;AAAA,kBACF;AAAA,gBAEJ,CAAC,EACA,OAAO,CAAAC,MAAKA,MAAM,IAAI;AAAA,cAAA,CAC1B;AAAA,YAEL;AAEA,kBAAMC,IAAqB,MAAMnC,EAAiB;AAAA,cAChD,SAAS,EAAE,cAAcpB,GAAY,2BAA2B,EAAE,QAAAmD,IAAO;AAAA,YAAE,CAC5E;AACD,YAAA9C,EAAQ6C,EAAgB,8BAA8BK,CAAkB;AAAA,UAC1E;AAEA,UAAAlD,EAAQ6C,EAAgB,mBAAmB;AAAA,QAC7C,CAAC;AAAA,MACH,CAY6C,GAClC,UAAAhD,KAGC,gBAAAsD,EAAAC,GAAA,EACE,UAAA;AAAA,QAAA,gBAAA5D,EAAC6D,GAAA,EAAY;AAAA,0BACZC,GAAA,EAAY;AAAA,0BACZC,GAAA,EAAU;AAAA,0BACVC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,GAEJ,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Taxes.js","sources":["../../../../src/components/Employee/Taxes/Taxes.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { useEffect } from 'react'\nimport { useEmployeeTaxSetupGetFederalTaxesSuspense } from '@gusto/embedded-api/react-query/employeeTaxSetupGetFederalTaxes'\nimport { useEmployeeTaxSetupUpdateFederalTaxesMutation } from '@gusto/embedded-api/react-query/employeeTaxSetupUpdateFederalTaxes'\nimport { useEmployeeTaxSetupGetStateTaxesSuspense } from '@gusto/embedded-api/react-query/employeeTaxSetupGetStateTaxes'\nimport { useEmployeeTaxSetupUpdateStateTaxesMutation } from '@gusto/embedded-api/react-query/employeeTaxSetupUpdateStateTaxes'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlowComponents'\nimport { Actions } from './Actions'\nimport {\n FederalForm,\n FederalFormSchema,\n type FederalFormInputs,\n type FederalFormPayload,\n} from './FederalForm'\nimport { FederalHead } from './FederalHead'\nimport { StateForm, StateFormSchema, type StateFormPayload } from './StateForm'\nimport { TaxesProvider } from './useTaxes'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { snakeCaseToCamelCase, normalizeErrorKeyForForm } from '@/helpers/formattedStrings'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nconst DEFAULT_TAX_VALID_FROM = '2010-01-01'\n\ninterface TaxesProps extends CommonComponentInterface<'Employee.Taxes'> {\n employeeId: string\n isAdmin?: boolean\n}\n\n/**\n * @deprecated The Taxes component has been deprecated and will be removed in a future release.\n * The component has been split into separate components for state and federal. Use Employee.FederalTaxes\n * and Employee.StateTaxes components instead.\n */\nexport function Taxes(props: TaxesProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = (props: TaxesProps) => {\n const { employeeId, className, children, isAdmin = false, dictionary } = props\n const { onEvent, fieldErrors, baseSubmitHandler } = useBase()\n useI18n('Employee.Taxes')\n useComponentDictionary('Employee.Taxes', dictionary)\n\n const { data: fedData } = useEmployeeTaxSetupGetFederalTaxesSuspense({\n employeeUuid: employeeId,\n })\n const employeeFederalTax = fedData.employeeFederalTax!\n\n const { mutateAsync: updateFederalTaxes, isPending: isPendingFederalTaxes } =\n useEmployeeTaxSetupUpdateFederalTaxesMutation()\n\n const { data: stateData } = useEmployeeTaxSetupGetStateTaxesSuspense({\n employeeUuid: employeeId,\n })\n const employeeStateTaxes = stateData.employeeStateTaxesList!\n const { mutateAsync: updateStateTaxes, isPending: isPendingStateTaxes } =\n useEmployeeTaxSetupUpdateStateTaxesMutation()\n\n const isRev2020 = employeeFederalTax.w4DataType === 'rev_2020_w4'\n\n const statesDefaultValues = 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 if (key === 'fileNewHireReport') {\n acc[key] = typeof value === 'undefined' ? true : value\n } else {\n acc[key] = value\n }\n return acc\n }, {})\n }\n return acc\n }, {})\n\n const defaultValues: FederalFormInputs & { states: typeof statesDefaultValues } = isRev2020\n ? {\n w4DataType: 'rev_2020_w4',\n filingStatus: employeeFederalTax.filingStatus ?? '',\n twoJobs: employeeFederalTax.twoJobs ? 'true' : 'false',\n deductions: employeeFederalTax.deductions ? Number(employeeFederalTax.deductions) : 0,\n dependentsAmount: employeeFederalTax.dependentsAmount\n ? Number(employeeFederalTax.dependentsAmount)\n : 0,\n otherIncome: employeeFederalTax.otherIncome ? Number(employeeFederalTax.otherIncome) : 0,\n extraWithholding: employeeFederalTax.extraWithholding\n ? Number(employeeFederalTax.extraWithholding)\n : 0,\n states: statesDefaultValues,\n }\n : {\n w4DataType: 'pre_2020_w4',\n filingStatus: employeeFederalTax.filingStatus ?? '',\n federalWithholdingAllowance: employeeFederalTax.federalWithholdingAllowance ?? 0,\n additionalWithholding: employeeFederalTax.additionalWithholding,\n states: statesDefaultValues,\n }\n\n const formMethods = useForm<FederalFormInputs, unknown, FederalFormPayload & StateFormPayload>({\n resolver: zodResolver(FederalFormSchema.and(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 _setError(key as keyof FederalFormInputs, { type: 'custom', message: msgObject.message })\n })\n }\n }, [fieldErrors, _setError])\n\n const onSubmit: SubmitHandler<FederalFormPayload & StateFormPayload> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { states: statesPayload, ...federalPayload } = payload\n\n const requestBody =\n federalPayload.w4DataType === 'rev_2020_w4'\n ? {\n filingStatus: federalPayload.filingStatus,\n twoJobs: federalPayload.twoJobs === 'true',\n dependentsAmount: federalPayload.dependentsAmount,\n otherIncome: federalPayload.otherIncome,\n deductions: federalPayload.deductions,\n extraWithholding: federalPayload.extraWithholding,\n w4DataType: federalPayload.w4DataType,\n version: employeeFederalTax.version,\n }\n : {\n filingStatus: federalPayload.filingStatus,\n federalWithholdingAllowance: federalPayload.federalWithholdingAllowance,\n additionalWithholding: federalPayload.additionalWithholding,\n w4DataType: federalPayload.w4DataType,\n version: employeeFederalTax.version,\n }\n\n const federalTaxesResponse = await updateFederalTaxes({\n request: {\n employeeUuid: employeeId,\n requestBody,\n },\n })\n onEvent(componentEvents.EMPLOYEE_FEDERAL_TAXES_UPDATED, federalTaxesResponse)\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 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:\n formValue == null || (typeof formValue === 'number' && isNaN(formValue))\n ? ''\n : (formValue as string | number | boolean),\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_TAXES_DONE)\n })\n }\n\n return (\n <section className={className}>\n <TaxesProvider\n value={{\n employeeStateTaxes,\n isAdmin: isAdmin,\n isPending: isPendingFederalTaxes || isPendingStateTaxes,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <FederalHead />\n <FederalForm />\n <StateForm />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </TaxesProvider>\n </section>\n )\n}\n\nexport const TaxesContextual = () => {\n const { employeeId, onEvent, isAdmin } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation()\n if (!employeeId) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'EmployeeTaxes',\n param: 'employeeId',\n provider: 'FlowProvider',\n }),\n )\n }\n return <Taxes employeeId={employeeId} onEvent={onEvent} isAdmin={isAdmin ?? false} />\n}\n"],"names":["DEFAULT_TAX_VALID_FROM","Taxes","props","jsx","BaseComponent","Root","employeeId","className","children","isAdmin","dictionary","onEvent","fieldErrors","baseSubmitHandler","useBase","useI18n","useComponentDictionary","fedData","useEmployeeTaxSetupGetFederalTaxesSuspense","employeeFederalTax","updateFederalTaxes","isPendingFederalTaxes","useEmployeeTaxSetupUpdateFederalTaxesMutation","stateData","useEmployeeTaxSetupGetStateTaxesSuspense","employeeStateTaxes","updateStateTaxes","isPendingStateTaxes","useEmployeeTaxSetupUpdateStateTaxesMutation","isRev2020","statesDefaultValues","acc","state","question","value","key","snakeCaseToCamelCase","defaultValues","formMethods","useForm","zodResolver","FederalFormSchema","StateFormSchema","handleSubmit","_setError","useEffect","msgObject","normalizeErrorKeyForForm","TaxesProvider","FormProvider","Form","data","payload","statesPayload","federalPayload","requestBody","federalTaxesResponse","componentEvents","states","stateName","formValue","q","stateTaxesResponse","jsxs","Fragment","FederalHead","FederalForm","StateForm","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,KAAyB;AAYxB,SAASC,GAAMC,GAA4C;AAChE,SACE,gBAAAC,EAACC,IAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,KAAO,CAACH,MAAsB;AAClC,QAAM,EAAE,YAAAI,GAAY,WAAAC,GAAW,UAAAC,GAAU,SAAAC,IAAU,IAAO,YAAAC,MAAeR,GACnE,EAAE,SAAAS,GAAS,aAAAC,GAAa,mBAAAC,EAAA,IAAsBC,GAAA;AACpD,EAAAC,GAAQ,gBAAgB,GACxBC,GAAuB,kBAAkBN,CAAU;AAEnD,QAAM,EAAE,MAAMO,EAAA,IAAYC,EAA2C;AAAA,IACnE,cAAcZ;AAAA,EAAA,CACf,GACKa,IAAqBF,EAAQ,oBAE7B,EAAE,aAAaG,GAAoB,WAAWC,EAAA,IAClDC,EAAA,GAEI,EAAE,MAAMC,EAAA,IAAcC,EAAyC;AAAA,IACnE,cAAclB;AAAA,EAAA,CACf,GACKmB,IAAqBF,EAAU,wBAC/B,EAAE,aAAaG,GAAkB,WAAWC,EAAA,IAChDC,EAAA,GAEIC,IAAYV,EAAmB,eAAe,eAE9CW,IAAsBL,EAAmB,OAAO,CAACM,GAA8BC,OAC/EA,EAAM,UACRD,EAAIC,EAAM,KAAK,IAAIA,EAAM,WAAW,OAAO,CAACD,GAA8BE,MAAa;AACrF,UAAMC,IAAQD,EAAS,QA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,CAACxB;AACtC,2BAAO;AAET,wBAAMmD,IAAYP,EAAcM,CAAS,IAAIvB,EAAqBH,EAAS,GAAG,CAAC;AAC/E,yBAAO;AAAA,oBACL,KAAKA,EAAS;AAAA,oBACd,SAAS;AAAA,sBACP;AAAA,wBACE,WAAWA,EAAS,QAAQ,CAAC,GAAG,aAAajC;AAAA,wBAC7C,WAAWiC,EAAS,QAAQ,CAAC,GAAG,aAAa;AAAA,wBAC7C,OACE2B,KAAa,QAAS,OAAOA,KAAc,YAAY,MAAMA,CAAS,IAClE,KACCA;AAAA,sBAAA;AAAA,oBACT;AAAA,kBACF;AAAA,gBAEJ,CAAC,EACA,OAAO,CAAAC,MAAKA,MAAM,IAAI;AAAA,cAAA,CAC1B;AAAA,YAEL;AAEA,kBAAMC,IAAqB,MAAMpC,EAAiB;AAAA,cAChD,SAAS,EAAE,cAAcpB,GAAY,2BAA2B,EAAE,QAAAoD,IAAO;AAAA,YAAE,CAC5E;AACD,YAAA/C,EAAQ8C,EAAgB,8BAA8BK,CAAkB;AAAA,UAC1E;AAEA,UAAAnD,EAAQ8C,EAAgB,mBAAmB;AAAA,QAC7C,CAAC;AAAA,MACH,CAY6C,GAClC,UAAAjD,KAGC,gBAAAuD,EAAAC,GAAA,EACE,UAAA;AAAA,QAAA,gBAAA7D,EAAC8D,GAAA,EAAY;AAAA,0BACZC,GAAA,EAAY;AAAA,0BACZC,GAAA,EAAU;AAAA,0BACVC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,GAEJ,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -2,13 +2,13 @@ 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/
|
|
5
|
+
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
6
6
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
7
7
|
import "@tanstack/react-query";
|
|
8
8
|
import "../../Base/useBase.js";
|
|
9
9
|
import "../../../shared/constants.js";
|
|
10
|
+
import "classnames";
|
|
10
11
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
11
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
12
12
|
import "dompurify";
|
|
13
13
|
import "../../../contexts/LocaleProvider/useLocale.js";
|
|
14
14
|
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { EmployeeList as e } from "./EmployeeList/EmployeeList.js";
|
|
2
2
|
import { OnboardingFlow as m } from "./OnboardingFlow/OnboardingFlow.js";
|
|
3
3
|
import { SelfOnboardingFlow as x } from "./SelfOnboardingFlow/SelfOnboardingFlow.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
4
|
+
import { Compensation as n } from "./Compensation/Compensation.js";
|
|
5
|
+
import { Deductions as a } from "./Deductions/Deductions.js";
|
|
6
|
+
import { DocumentSigner as d } from "./DocumentSigner/DocumentSigner.js";
|
|
7
|
+
import { EmployeeDocuments as g } from "./EmployeeDocuments/EmployeeDocuments.js";
|
|
8
|
+
import { EmploymentEligibility as b } from "./DocumentSigner/EmploymentEligibility/EmploymentEligibility.js";
|
|
9
|
+
import { FederalTaxes as E } from "./FederalTaxes/FederalTaxes.js";
|
|
10
|
+
import { Landing as c } from "./Landing/Landing.js";
|
|
11
|
+
import { OnboardingSummary as F } from "./OnboardingSummary/OnboardingSummary.js";
|
|
12
|
+
import { PaymentMethod as T } from "./PaymentMethod/PaymentMethod.js";
|
|
13
|
+
import { Profile as L } from "./Profile/Profile.js";
|
|
14
|
+
import { StateTaxes as h } from "./StateTaxes/StateTaxes.js";
|
|
15
15
|
import { Taxes as M } from "./Taxes/Taxes.js";
|
|
16
16
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
n as Compensation,
|
|
18
|
+
a as Deductions,
|
|
19
|
+
d as DocumentSigner,
|
|
20
|
+
g as EmployeeDocuments,
|
|
21
21
|
e as EmployeeList,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
b as EmploymentEligibility,
|
|
23
|
+
E as FederalTaxes,
|
|
24
|
+
c as Landing,
|
|
25
25
|
m as OnboardingFlow,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
F as OnboardingSummary,
|
|
27
|
+
T as PaymentMethod,
|
|
28
|
+
L as Profile,
|
|
29
29
|
x as SelfOnboardingFlow,
|
|
30
|
-
|
|
30
|
+
h as StateTaxes,
|
|
31
31
|
M as Taxes
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,15 +3,16 @@ import { useMachine as v } from "react-robot";
|
|
|
3
3
|
import { useTranslation as w } from "react-i18next";
|
|
4
4
|
import { FlowBreadcrumbs as F } from "../Common/FlowBreadcrumbs/FlowBreadcrumbs.js";
|
|
5
5
|
import { Flex as s, FlexItem as d } from "../Common/Flex/Flex.js";
|
|
6
|
+
import "classnames";
|
|
6
7
|
import { useComponentContext as j } from "../../contexts/ComponentAdapter/useComponentContext.js";
|
|
7
8
|
import "react";
|
|
8
9
|
import { FlowContext as E } from "./useFlow.js";
|
|
9
|
-
const
|
|
10
|
+
const k = ({
|
|
10
11
|
onEvent: x,
|
|
11
12
|
machine: f
|
|
12
13
|
}) => {
|
|
13
14
|
const b = j(), { t: g } = w(), [r, h, c] = v(f, {
|
|
14
|
-
onEvent:
|
|
15
|
+
onEvent: i,
|
|
15
16
|
component: null,
|
|
16
17
|
progressBarCta: null
|
|
17
18
|
}), {
|
|
@@ -21,9 +22,9 @@ const M = ({
|
|
|
21
22
|
currentBreadcrumbId: n,
|
|
22
23
|
breadcrumbs: B = {}
|
|
23
24
|
} = r.context;
|
|
24
|
-
function
|
|
25
|
-
const p = { type:
|
|
26
|
-
c.child ? c.child.send(p) : C(p), x(
|
|
25
|
+
function i(m, a) {
|
|
26
|
+
const p = { type: m, payload: a }, C = h;
|
|
27
|
+
c.child ? c.child.send(p) : C(p), x(m, a);
|
|
27
28
|
}
|
|
28
29
|
return /* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(
|
|
29
30
|
E.Provider,
|
|
@@ -47,7 +48,7 @@ const M = ({
|
|
|
47
48
|
{
|
|
48
49
|
breadcrumbs: n ? B[n] ?? [] : [],
|
|
49
50
|
currentBreadcrumbId: n,
|
|
50
|
-
onEvent:
|
|
51
|
+
onEvent: i
|
|
51
52
|
}
|
|
52
53
|
) }),
|
|
53
54
|
/* @__PURE__ */ e(d, { children: r.context.progressBarCta && /* @__PURE__ */ e(r.context.progressBarCta, {}) })
|
|
@@ -58,6 +59,6 @@ const M = ({
|
|
|
58
59
|
) });
|
|
59
60
|
};
|
|
60
61
|
export {
|
|
61
|
-
|
|
62
|
+
k as Flow
|
|
62
63
|
};
|
|
63
64
|
//# sourceMappingURL=Flow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flow.js","sources":["../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useMachine } from 'react-robot'\nimport { type Machine, type SendFunction } from 'robot3'\nimport { useTranslation } from 'react-i18next'\nimport type { OnEventType } from '../Base/useBase'\nimport { FlowBreadcrumbs } from '../Common/FlowBreadcrumbs/FlowBreadcrumbs'\nimport { Flex } from '../Common/Flex'\nimport { FlexItem } from '../Common'\nimport type { FlowContextInterface } from './useFlow'\nimport { FlowContext } from './useFlow'\nimport { type EventType } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ntype FlowProps<M extends Machine> = {\n machine: M\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport const Flow = <M extends Machine<object, FlowContextInterface>>({\n onEvent,\n machine,\n}: FlowProps<M>) => {\n const Components = useComponentContext()\n const { t } = useTranslation()\n const [current, send, service] = useMachine(machine, {\n onEvent: handleEvent,\n component: null,\n progressBarCta: null,\n })\n\n const {\n progressBarType = null,\n totalSteps = null,\n currentStep = null,\n currentBreadcrumbId,\n breadcrumbs = {},\n } = current.context\n\n function handleEvent(type: EventType, data: unknown): void {\n const event = { type, payload: data }\n const sendFn = send as SendFunction<string>\n //When dealing with nested state machine, correct machine needs to recieve an event\n if (service.child) {\n ;(service.child.send as SendFunction<string>)(event)\n } else {\n sendFn(event)\n }\n // Pass event upstream - onEvent can be optional on Flow component\n onEvent(type, data)\n }\n\n return (\n <Flex>\n <FlowContext.Provider\n value={{\n ...current.context,\n }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {progressBarType === 'progress' && currentStep && totalSteps && (\n <Components.ProgressBar\n totalSteps={totalSteps}\n currentStep={currentStep}\n label={t('progressBarLabel', { totalSteps, currentStep })}\n cta={current.context.progressBarCta}\n />\n )}\n {progressBarType === 'breadcrumbs' && (\n <Flex flexDirection=\"row\" justifyContent=\"space-between\" alignItems=\"center\">\n <FlexItem flexGrow={1}>\n <FlowBreadcrumbs\n breadcrumbs={currentBreadcrumbId ? (breadcrumbs[currentBreadcrumbId] ?? []) : []}\n currentBreadcrumbId={currentBreadcrumbId}\n onEvent={handleEvent}\n />\n </FlexItem>\n <FlexItem>\n {current.context.progressBarCta && <current.context.progressBarCta />}\n </FlexItem>\n </Flex>\n )}\n {current.context.component && <current.context.component />}\n </Flex>\n </FlowContext.Provider>\n </Flex>\n )\n}\n"],"names":["Flow","onEvent","machine","Components","useComponentContext","t","useTranslation","current","send","service","useMachine","handleEvent","progressBarType","totalSteps","currentStep","currentBreadcrumbId","breadcrumbs","type","data","event","sendFn","Flex","jsx","FlowContext","jsxs","FlexItem","FlowBreadcrumbs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Flow.js","sources":["../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useMachine } from 'react-robot'\nimport { type Machine, type SendFunction } from 'robot3'\nimport { useTranslation } from 'react-i18next'\nimport type { OnEventType } from '../Base/useBase'\nimport { FlowBreadcrumbs } from '../Common/FlowBreadcrumbs/FlowBreadcrumbs'\nimport { Flex } from '../Common/Flex'\nimport { FlexItem } from '../Common'\nimport type { FlowContextInterface } from './useFlow'\nimport { FlowContext } from './useFlow'\nimport { type EventType } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ntype FlowProps<M extends Machine> = {\n machine: M\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport const Flow = <M extends Machine<object, FlowContextInterface>>({\n onEvent,\n machine,\n}: FlowProps<M>) => {\n const Components = useComponentContext()\n const { t } = useTranslation()\n const [current, send, service] = useMachine(machine, {\n onEvent: handleEvent,\n component: null,\n progressBarCta: null,\n })\n\n const {\n progressBarType = null,\n totalSteps = null,\n currentStep = null,\n currentBreadcrumbId,\n breadcrumbs = {},\n } = current.context\n\n function handleEvent(type: EventType, data: unknown): void {\n const event = { type, payload: data }\n const sendFn = send as SendFunction<string>\n //When dealing with nested state machine, correct machine needs to recieve an event\n if (service.child) {\n ;(service.child.send as SendFunction<string>)(event)\n } else {\n sendFn(event)\n }\n // Pass event upstream - onEvent can be optional on Flow component\n onEvent(type, data)\n }\n\n return (\n <Flex>\n <FlowContext.Provider\n value={{\n ...current.context,\n }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {progressBarType === 'progress' && currentStep && totalSteps && (\n <Components.ProgressBar\n totalSteps={totalSteps}\n currentStep={currentStep}\n label={t('progressBarLabel', { totalSteps, currentStep })}\n cta={current.context.progressBarCta}\n />\n )}\n {progressBarType === 'breadcrumbs' && (\n <Flex flexDirection=\"row\" justifyContent=\"space-between\" alignItems=\"center\">\n <FlexItem flexGrow={1}>\n <FlowBreadcrumbs\n breadcrumbs={currentBreadcrumbId ? (breadcrumbs[currentBreadcrumbId] ?? []) : []}\n currentBreadcrumbId={currentBreadcrumbId}\n onEvent={handleEvent}\n />\n </FlexItem>\n <FlexItem>\n {current.context.progressBarCta && <current.context.progressBarCta />}\n </FlexItem>\n </Flex>\n )}\n {current.context.component && <current.context.component />}\n </Flex>\n </FlowContext.Provider>\n </Flex>\n )\n}\n"],"names":["Flow","onEvent","machine","Components","useComponentContext","t","useTranslation","current","send","service","useMachine","handleEvent","progressBarType","totalSteps","currentStep","currentBreadcrumbId","breadcrumbs","type","data","event","sendFn","Flex","jsx","FlowContext","jsxs","FlexItem","FlowBreadcrumbs"],"mappings":";;;;;;;;;AAiBO,MAAMA,IAAO,CAAkD;AAAA,EACpE,SAAAC;AAAA,EACA,SAAAC;AACF,MAAoB;AAClB,QAAMC,IAAaC,EAAA,GACb,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACR,CAACC,GAASC,GAAMC,CAAO,IAAIC,EAAWR,GAAS;AAAA,IACnD,SAASS;AAAA,IACT,WAAW;AAAA,IACX,gBAAgB;AAAA,EAAA,CACjB,GAEK;AAAA,IACJ,iBAAAC,IAAkB;AAAA,IAClB,YAAAC,IAAa;AAAA,IACb,aAAAC,IAAc;AAAA,IACd,qBAAAC;AAAA,IACA,aAAAC,IAAc,CAAA;AAAA,EAAC,IACbT,EAAQ;AAEZ,WAASI,EAAYM,GAAiBC,GAAqB;AACzD,UAAMC,IAAQ,EAAE,MAAAF,GAAM,SAASC,EAAA,GACzBE,IAASZ;AAEf,IAAIC,EAAQ,QACRA,EAAQ,MAAM,KAA8BU,CAAK,IAEnDC,EAAOD,CAAK,GAGdlB,EAAQgB,GAAMC,CAAI;AAAA,EACpB;AAEA,2BACGG,GAAA,EACC,UAAA,gBAAAC;AAAA,IAACC,EAAY;AAAA,IAAZ;AAAA,MACC,OAAO;AAAA,QACL,GAAGhB,EAAQ;AAAA,MAAA;AAAA,MAGb,UAAA,gBAAAiB,EAACH,GAAA,EAAK,eAAc,UAAS,KAAK,IAC/B,UAAA;AAAA,QAAAT,MAAoB,cAAcE,KAAeD,KAChD,gBAAAS;AAAA,UAACnB,EAAW;AAAA,UAAX;AAAA,YACC,YAAAU;AAAA,YACA,aAAAC;AAAA,YACA,OAAOT,EAAE,oBAAoB,EAAE,YAAAQ,GAAY,aAAAC,GAAa;AAAA,YACxD,KAAKP,EAAQ,QAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,QAGxBK,MAAoB,iBACnB,gBAAAY,EAACH,GAAA,EAAK,eAAc,OAAM,gBAAe,iBAAgB,YAAW,UAClE,UAAA;AAAA,UAAA,gBAAAC,EAACG,GAAA,EAAS,UAAU,GAClB,UAAA,gBAAAH;AAAA,YAACI;AAAA,YAAA;AAAA,cACC,aAAaX,IAAuBC,EAAYD,CAAmB,KAAK,CAAA,IAAM,CAAA;AAAA,cAC9E,qBAAAA;AAAA,cACA,SAASJ;AAAA,YAAA;AAAA,UAAA,GAEb;AAAA,UACA,gBAAAW,EAACG,GAAA,EACE,UAAAlB,EAAQ,QAAQ,oCAAmBA,EAAQ,QAAQ,gBAAhB,CAAA,CAA+B,EAAA,CACrE;AAAA,QAAA,GACF;AAAA,QAEDA,EAAQ,QAAQ,+BAAcA,EAAQ,QAAQ,WAAhB,CAAA,CAA0B;AAAA,MAAA,EAAA,CAC3D;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js
CHANGED
|
@@ -13,6 +13,7 @@ import r from "./InformationRequestForm.module.scss.js";
|
|
|
13
13
|
import { BaseComponent as $ } from "../../Base/Base.js";
|
|
14
14
|
import { useBase as J } from "../../Base/useBase.js";
|
|
15
15
|
import { Flex as y } from "../../Common/Flex/Flex.js";
|
|
16
|
+
import "classnames";
|
|
16
17
|
import { useComponentContext as _ } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
18
|
import "react";
|
|
18
19
|
import { FileInputField as X } from "../../Common/Fields/FileInputField/FileInputField.js";
|
package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InformationRequestForm.js","sources":["../../../../src/components/InformationRequests/InformationRequestForm/InformationRequestForm.tsx"],"sourcesContent":["import DOMPurify from 'dompurify'\nimport { useTranslation } from 'react-i18next'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { z } from 'zod'\nimport { useIsMutating } from '@tanstack/react-query'\nimport { useInformationRequestsGetInformationRequestsSuspense } from '@gusto/embedded-api/react-query/informationRequestsGetInformationRequests'\nimport {\n useInformationRequestsSubmitMutation,\n mutationKeyInformationRequestsSubmit,\n} from '@gusto/embedded-api/react-query/informationRequestsSubmit'\nimport type { RequiredQuestions } from '@gusto/embedded-api/models/components/informationrequest'\nimport { ResponseType } from '@gusto/embedded-api/models/components/informationrequest'\nimport { ResponseType as SubmitResponseType } from '@gusto/embedded-api/models/operations/submitinformationrequest'\nimport type { InformationRequestsContextInterface } from '../InformationRequestsComponents'\nimport styles from './InformationRequestForm.module.scss'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Flex, TextInputField } from '@/components/Common'\nimport { FileInputField } from '@/components/Common/Fields/FileInputField'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { informationRequestEvents, type EventType } from '@/shared/constants'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nconst INFORMATION_REQUEST_FORM_ID = 'gusto-sdk-information-request-form'\nconst ACCEPTED_FILE_TYPES = ['image/jpeg', 'image/png', 'application/pdf']\nconst dompurifyConfig = {\n ALLOWED_TAGS: ['a', 'b', 'strong'],\n ALLOWED_ATTR: ['target', 'href', 'rel'],\n}\n\nconst InformationRequestFormSchema = z.record(\n z.string(),\n z.union([z.string().min(1), z.instanceof(File)]),\n)\n\ntype InformationRequestFormValues = z.infer<typeof InformationRequestFormSchema>\n\ninterface InformationRequestFormProps extends BaseComponentInterface<'InformationRequests.InformationRequestForm'> {\n companyId: string\n requestId: string\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function InformationRequestForm(props: InformationRequestFormProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst convertFileToDataUrl = (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => {\n resolve(reader.result as string)\n }\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n}\n\nconst SUPPORTED_RESPONSE_TYPES: ResponseType[] = [ResponseType.Text, ResponseType.Document]\n\nfunction hasUnsupportedQuestionTypes(questions: RequiredQuestions[]) {\n return questions.some(\n question => question.responseType && !SUPPORTED_RESPONSE_TYPES.includes(question.responseType),\n )\n}\n\nfunction hasPersonaQuestionType(questions: RequiredQuestions[]) {\n return questions.some(question => question.responseType === ResponseType.Persona)\n}\n\nfunction Root({ companyId, requestId, dictionary }: InformationRequestFormProps) {\n useComponentDictionary('InformationRequests.InformationRequestForm', dictionary)\n useI18n('InformationRequests.InformationRequestForm')\n const { t } = useTranslation('InformationRequests.InformationRequestForm')\n const { Alert, Heading, Text } = useComponentContext()\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n\n const informationRequest = data.informationRequestList?.find(req => req.uuid === requestId)\n const requiredQuestions = informationRequest?.requiredQuestions ?? []\n const isBlockingPayroll = informationRequest?.blockingPayroll ?? false\n const hasUnsupportedTypes = hasUnsupportedQuestionTypes(requiredQuestions)\n const hasPersonaType = hasPersonaQuestionType(requiredQuestions)\n\n const { mutateAsync: submitInformationRequest } = useInformationRequestsSubmitMutation()\n\n const defaultValues: Record<string, string | File | undefined> = {}\n const questionUuids: string[] = []\n\n requiredQuestions.forEach(question => {\n if (!question.questionUuid || !question.responseType) return\n\n if (question.responseType === ResponseType.Text) {\n questionUuids.push(question.questionUuid)\n defaultValues[question.questionUuid] = ''\n } else if (question.responseType === ResponseType.Document) {\n questionUuids.push(question.questionUuid)\n defaultValues[question.questionUuid] = undefined\n }\n })\n\n const formMethods = useForm<InformationRequestFormValues>({\n resolver: zodResolver(InformationRequestFormSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InformationRequestFormValues) => {\n await baseSubmitHandler(formData, async () => {\n const questionResponses = await Promise.all(\n questionUuids.map(async uuid => {\n const value = formData[uuid]\n\n if (typeof value === 'string') {\n return {\n questionUuid: uuid,\n responseType: SubmitResponseType.Text,\n textResponse: value,\n }\n }\n\n if (value instanceof File) {\n const fileResponse = await convertFileToDataUrl(value)\n return {\n questionUuid: uuid,\n responseType: SubmitResponseType.Document,\n fileResponse,\n fileName: value.name,\n }\n }\n\n return null\n }),\n )\n\n const validResponses = questionResponses.filter(response => response !== null)\n\n const response = await submitInformationRequest({\n request: {\n informationRequestUuid: requestId,\n requestBody: {\n requiredQuestions: validResponses,\n },\n },\n })\n\n onEvent(informationRequestEvents.INFORMATION_REQUEST_FORM_DONE, response.informationRequest)\n })\n }\n\n const renderQuestion = (question: RequiredQuestions) => {\n if (!question.questionUuid || !question.responseType) return null\n\n const fieldName = question.questionUuid\n const isDocumentType = question.responseType === ResponseType.Document\n const isTextType = question.responseType === ResponseType.Text\n\n return (\n <div key={fieldName} className={styles.questionCard}>\n <div className={styles.questionDescription}>\n <Text weight=\"medium\">\n {isDocumentType ? t('questionTypes.document') : t('questionTypes.answer')}\n </Text>\n <Text>\n {/* SECURITY: XSS mitigated via DOMPurify with strict allowlist. Pattern matches TaxInputs.tsx */}\n <span\n dangerouslySetInnerHTML={{\n __html: DOMPurify.sanitize(question.questionText ?? '', dompurifyConfig),\n }}\n />\n </Text>\n </div>\n\n <hr className={styles.divider} />\n\n {isTextType && (\n <div className={styles.textInputWrapper}>\n <TextInputField\n name={fieldName}\n label={t('fields.textAnswer.label')}\n placeholder={t('fields.textAnswer.placeholder')}\n isRequired\n errorMessage={t('validation.required')}\n />\n </div>\n )}\n\n {isDocumentType && (\n <div className={styles.fileInputWrapper}>\n <FileInputField\n name={fieldName}\n label={t('fields.fileUpload.label')}\n accept={ACCEPTED_FILE_TYPES}\n isRequired\n errorMessage={t('validation.required')}\n />\n </div>\n )}\n </div>\n )\n }\n\n const unsupportedPlaceholder = (\n <div className={styles.questionCard}>\n <div className={styles.questionDescription}>\n <Text weight=\"medium\">\n {t(hasPersonaType ? 'unsupported.persona.title' : 'unsupported.generic.title')}\n </Text>\n <Text>\n {t(\n hasPersonaType ? 'unsupported.persona.description' : 'unsupported.generic.description',\n )}\n </Text>\n </div>\n\n <hr className={styles.divider} />\n\n <div className={styles.contactSupport}>\n <Text variant=\"supporting\">{t('unsupported.contactSupport')}</Text>\n </div>\n </div>\n )\n\n return (\n <div className={styles.root}>\n <Flex flexDirection=\"column\" gap={16}>\n <Heading as=\"h2\">{t('title')}</Heading>\n\n {isBlockingPayroll && (\n <Alert status=\"error\" label={t('blockingAlert.title')} disableScrollIntoView>\n {t('blockingAlert.description')}\n </Alert>\n )}\n\n {hasUnsupportedTypes ? (\n unsupportedPlaceholder\n ) : (\n <FormProvider {...formMethods}>\n <Form id={INFORMATION_REQUEST_FORM_ID} onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={16}>\n {requiredQuestions.map(renderQuestion)}\n </Flex>\n </Form>\n </FormProvider>\n )}\n </Flex>\n </div>\n )\n}\n\nconst Footer = ({ onEvent }: { onEvent: OnEventType<EventType, unknown> }) => {\n useI18n('InformationRequests.InformationRequestForm')\n const { t } = useTranslation('InformationRequests.InformationRequestForm')\n const { Button } = useComponentContext()\n const { companyId, selectedRequestId } = useFlow<InformationRequestsContextInterface>()\n\n const { data } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n\n const informationRequest = data.informationRequestList?.find(\n req => req.uuid === selectedRequestId,\n )\n const requiredQuestions = informationRequest?.requiredQuestions ?? []\n const hasUnsupportedTypes = hasUnsupportedQuestionTypes(requiredQuestions)\n\n const isMutating = useIsMutating({\n mutationKey: mutationKeyInformationRequestsSubmit(),\n })\n const isPending = isMutating > 0\n\n const handleCancel = () => {\n onEvent(informationRequestEvents.INFORMATION_REQUEST_FORM_CANCEL)\n }\n\n if (hasUnsupportedTypes) {\n return (\n <Flex justifyContent=\"flex-end\" gap={12}>\n <Button variant=\"secondary\" onClick={handleCancel}>\n {t('cta.close')}\n </Button>\n </Flex>\n )\n }\n\n return (\n <Flex justifyContent=\"flex-end\" gap={12}>\n <Button variant=\"secondary\" onClick={handleCancel} isDisabled={isPending}>\n {t('cta.cancel')}\n </Button>\n <Button\n variant=\"primary\"\n type=\"submit\"\n form={INFORMATION_REQUEST_FORM_ID}\n isLoading={isPending}\n >\n {t('cta.submit')}\n </Button>\n </Flex>\n )\n}\n\nInformationRequestForm.Footer = Footer\n"],"names":["INFORMATION_REQUEST_FORM_ID","ACCEPTED_FILE_TYPES","dompurifyConfig","InformationRequestFormSchema","z","InformationRequestForm","props","jsx","BaseComponent","Root","convertFileToDataUrl","file","resolve","reject","reader","SUPPORTED_RESPONSE_TYPES","ResponseType","hasUnsupportedQuestionTypes","questions","question","hasPersonaQuestionType","companyId","requestId","dictionary","useComponentDictionary","useI18n","t","useTranslation","Alert","Heading","Text","useComponentContext","onEvent","baseSubmitHandler","useBase","data","useInformationRequestsGetInformationRequestsSuspense","informationRequest","req","requiredQuestions","isBlockingPayroll","hasUnsupportedTypes","hasPersonaType","submitInformationRequest","useInformationRequestsSubmitMutation","defaultValues","questionUuids","formMethods","useForm","zodResolver","onSubmit","formData","validResponses","uuid","value","SubmitResponseType","fileResponse","response","informationRequestEvents","renderQuestion","fieldName","isDocumentType","isTextType","jsxs","styles","DOMPurify","TextInputField","FileInputField","unsupportedPlaceholder","Flex","FormProvider","Form","Footer","Button","selectedRequestId","useFlow","isPending","useIsMutating","mutationKeyIn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M,GAClC,UAAArD,EAAE,WAAW,GAChB,GACF,IAKF,gBAAAqC,EAACM,GAAA,EAAK,gBAAe,YAAW,KAAK,IACnC,UAAA;AAAA,IAAA,gBAAA9D,EAACkE,GAAA,EAAO,SAAQ,aAAY,SAASM,GAAc,YAAYH,GAC5D,UAAAlD,EAAE,YAAY,EAAA,CACjB;AAAA,IACA,gBAAAnB;AAAA,MAACkE;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,MAAMzE;AAAA,QACN,WAAW4E;AAAA,QAEV,YAAE,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAEAvE,GAAuB,SAASmE;"}
|
|
1
|
+
{"version":3,"file":"InformationRequestForm.js","sources":["../../../../src/components/InformationRequests/InformationRequestForm/InformationRequestForm.tsx"],"sourcesContent":["import DOMPurify from 'dompurify'\nimport { useTranslation } from 'react-i18next'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { z } from 'zod'\nimport { useIsMutating } from '@tanstack/react-query'\nimport { useInformationRequestsGetInformationRequestsSuspense } from '@gusto/embedded-api/react-query/informationRequestsGetInformationRequests'\nimport {\n useInformationRequestsSubmitMutation,\n mutationKeyInformationRequestsSubmit,\n} from '@gusto/embedded-api/react-query/informationRequestsSubmit'\nimport type { RequiredQuestions } from '@gusto/embedded-api/models/components/informationrequest'\nimport { ResponseType } from '@gusto/embedded-api/models/components/informationrequest'\nimport { ResponseType as SubmitResponseType } from '@gusto/embedded-api/models/operations/submitinformationrequest'\nimport type { InformationRequestsContextInterface } from '../InformationRequestsComponents'\nimport styles from './InformationRequestForm.module.scss'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Flex, TextInputField } from '@/components/Common'\nimport { FileInputField } from '@/components/Common/Fields/FileInputField'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { informationRequestEvents, type EventType } from '@/shared/constants'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nconst INFORMATION_REQUEST_FORM_ID = 'gusto-sdk-information-request-form'\nconst ACCEPTED_FILE_TYPES = ['image/jpeg', 'image/png', 'application/pdf']\nconst dompurifyConfig = {\n ALLOWED_TAGS: ['a', 'b', 'strong'],\n ALLOWED_ATTR: ['target', 'href', 'rel'],\n}\n\nconst InformationRequestFormSchema = z.record(\n z.string(),\n z.union([z.string().min(1), z.instanceof(File)]),\n)\n\ntype InformationRequestFormValues = z.infer<typeof InformationRequestFormSchema>\n\ninterface InformationRequestFormProps extends BaseComponentInterface<'InformationRequests.InformationRequestForm'> {\n companyId: string\n requestId: string\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function InformationRequestForm(props: InformationRequestFormProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst convertFileToDataUrl = (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => {\n resolve(reader.result as string)\n }\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n}\n\nconst SUPPORTED_RESPONSE_TYPES: ResponseType[] = [ResponseType.Text, ResponseType.Document]\n\nfunction hasUnsupportedQuestionTypes(questions: RequiredQuestions[]) {\n return questions.some(\n question => question.responseType && !SUPPORTED_RESPONSE_TYPES.includes(question.responseType),\n )\n}\n\nfunction hasPersonaQuestionType(questions: RequiredQuestions[]) {\n return questions.some(question => question.responseType === ResponseType.Persona)\n}\n\nfunction Root({ companyId, requestId, dictionary }: InformationRequestFormProps) {\n useComponentDictionary('InformationRequests.InformationRequestForm', dictionary)\n useI18n('InformationRequests.InformationRequestForm')\n const { t } = useTranslation('InformationRequests.InformationRequestForm')\n const { Alert, Heading, Text } = useComponentContext()\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n\n const informationRequest = data.informationRequestList?.find(req => req.uuid === requestId)\n const requiredQuestions = informationRequest?.requiredQuestions ?? []\n const isBlockingPayroll = informationRequest?.blockingPayroll ?? false\n const hasUnsupportedTypes = hasUnsupportedQuestionTypes(requiredQuestions)\n const hasPersonaType = hasPersonaQuestionType(requiredQuestions)\n\n const { mutateAsync: submitInformationRequest } = useInformationRequestsSubmitMutation()\n\n const defaultValues: Record<string, string | File | undefined> = {}\n const questionUuids: string[] = []\n\n requiredQuestions.forEach(question => {\n if (!question.questionUuid || !question.responseType) return\n\n if (question.responseType === ResponseType.Text) {\n questionUuids.push(question.questionUuid)\n defaultValues[question.questionUuid] = ''\n } else if (question.responseType === ResponseType.Document) {\n questionUuids.push(question.questionUuid)\n defaultValues[question.questionUuid] = undefined\n }\n })\n\n const formMethods = useForm<InformationRequestFormValues>({\n resolver: zodResolver(InformationRequestFormSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InformationRequestFormValues) => {\n await baseSubmitHandler(formData, async () => {\n const questionResponses = await Promise.all(\n questionUuids.map(async uuid => {\n const value = formData[uuid]\n\n if (typeof value === 'string') {\n return {\n questionUuid: uuid,\n responseType: SubmitResponseType.Text,\n textResponse: value,\n }\n }\n\n if (value instanceof File) {\n const fileResponse = await convertFileToDataUrl(value)\n return {\n questionUuid: uuid,\n responseType: SubmitResponseType.Document,\n fileResponse,\n fileName: value.name,\n }\n }\n\n return null\n }),\n )\n\n const validResponses = questionResponses.filter(response => response !== null)\n\n const response = await submitInformationRequest({\n request: {\n informationRequestUuid: requestId,\n requestBody: {\n requiredQuestions: validResponses,\n },\n },\n })\n\n onEvent(informationRequestEvents.INFORMATION_REQUEST_FORM_DONE, response.informationRequest)\n })\n }\n\n const renderQuestion = (question: RequiredQuestions) => {\n if (!question.questionUuid || !question.responseType) return null\n\n const fieldName = question.questionUuid\n const isDocumentType = question.responseType === ResponseType.Document\n const isTextType = question.responseType === ResponseType.Text\n\n return (\n <div key={fieldName} className={styles.questionCard}>\n <div className={styles.questionDescription}>\n <Text weight=\"medium\">\n {isDocumentType ? t('questionTypes.document') : t('questionTypes.answer')}\n </Text>\n <Text>\n {/* SECURITY: XSS mitigated via DOMPurify with strict allowlist. Pattern matches TaxInputs.tsx */}\n <span\n dangerouslySetInnerHTML={{\n __html: DOMPurify.sanitize(question.questionText ?? '', dompurifyConfig),\n }}\n />\n </Text>\n </div>\n\n <hr className={styles.divider} />\n\n {isTextType && (\n <div className={styles.textInputWrapper}>\n <TextInputField\n name={fieldName}\n label={t('fields.textAnswer.label')}\n placeholder={t('fields.textAnswer.placeholder')}\n isRequired\n errorMessage={t('validation.required')}\n />\n </div>\n )}\n\n {isDocumentType && (\n <div className={styles.fileInputWrapper}>\n <FileInputField\n name={fieldName}\n label={t('fields.fileUpload.label')}\n accept={ACCEPTED_FILE_TYPES}\n isRequired\n errorMessage={t('validation.required')}\n />\n </div>\n )}\n </div>\n )\n }\n\n const unsupportedPlaceholder = (\n <div className={styles.questionCard}>\n <div className={styles.questionDescription}>\n <Text weight=\"medium\">\n {t(hasPersonaType ? 'unsupported.persona.title' : 'unsupported.generic.title')}\n </Text>\n <Text>\n {t(\n hasPersonaType ? 'unsupported.persona.description' : 'unsupported.generic.description',\n )}\n </Text>\n </div>\n\n <hr className={styles.divider} />\n\n <div className={styles.contactSupport}>\n <Text variant=\"supporting\">{t('unsupported.contactSupport')}</Text>\n </div>\n </div>\n )\n\n return (\n <div className={styles.root}>\n <Flex flexDirection=\"column\" gap={16}>\n <Heading as=\"h2\">{t('title')}</Heading>\n\n {isBlockingPayroll && (\n <Alert status=\"error\" label={t('blockingAlert.title')} disableScrollIntoView>\n {t('blockingAlert.description')}\n </Alert>\n )}\n\n {hasUnsupportedTypes ? (\n unsupportedPlaceholder\n ) : (\n <FormProvider {...formMethods}>\n <Form id={INFORMATION_REQUEST_FORM_ID} onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={16}>\n {requiredQuestions.map(renderQuestion)}\n </Flex>\n </Form>\n </FormProvider>\n )}\n </Flex>\n </div>\n )\n}\n\nconst Footer = ({ onEvent }: { onEvent: OnEventType<EventType, unknown> }) => {\n useI18n('InformationRequests.InformationRequestForm')\n const { t } = useTranslation('InformationRequests.InformationRequestForm')\n const { Button } = useComponentContext()\n const { companyId, selectedRequestId } = useFlow<InformationRequestsContextInterface>()\n\n const { data } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n\n const informationRequest = data.informationRequestList?.find(\n req => req.uuid === selectedRequestId,\n )\n const requiredQuestions = informationRequest?.requiredQuestions ?? []\n const hasUnsupportedTypes = hasUnsupportedQuestionTypes(requiredQuestions)\n\n const isMutating = useIsMutating({\n mutationKey: mutationKeyInformationRequestsSubmit(),\n })\n const isPending = isMutating > 0\n\n const handleCancel = () => {\n onEvent(informationRequestEvents.INFORMATION_REQUEST_FORM_CANCEL)\n }\n\n if (hasUnsupportedTypes) {\n return (\n <Flex justifyContent=\"flex-end\" gap={12}>\n <Button variant=\"secondary\" onClick={handleCancel}>\n {t('cta.close')}\n </Button>\n </Flex>\n )\n }\n\n return (\n <Flex justifyContent=\"flex-end\" gap={12}>\n <Button variant=\"secondary\" onClick={handleCancel} isDisabled={isPending}>\n {t('cta.cancel')}\n </Button>\n <Button\n variant=\"primary\"\n type=\"submit\"\n form={INFORMATION_REQUEST_FORM_ID}\n isLoading={isPending}\n >\n {t('cta.submit')}\n </Button>\n </Flex>\n )\n}\n\nInformationRequestForm.Footer = Footer\n"],"names":["INFORMATION_REQUEST_FORM_ID","ACCEPTED_FILE_TYPES","dompurifyConfig","InformationRequestFormSchema","z","InformationRequestForm","props","jsx","BaseComponent","Root","convertFileToDataUrl","file","resolve","reject","reader","SUPPORTED_RESPONSE_TYPES","ResponseType","hasUnsupportedQuestionTypes","questions","question","hasPersonaQuestionType","companyId","requestId","dictionary","useComponentDictionary","useI18n","t","useTranslation","Alert","Heading","Text","useComponentContext","onEvent","baseSubmitHandler","useBase","data","useInformationRequestsGetInformationRequestsSuspense","informationRequest","req","requiredQuestions","isBlockingPayroll","hasUnsupportedTypes","hasPersonaType","submitInformationRequest","useInformationRequestsSubmitMutation","defaultValues","questionUuids","formMethods","useForm","zodResolver","onSubmit","formData","validResponses","uuid","value","SubmitResponseType","fileResponse","response","informationRequestEvents","renderQuestion","fieldName","isDocumentType","isTextType","jsxs","styles","DOMPurify","TextInputField","FileInputField","unsupportedPlaceholder","Flex","FormProvider","Form","Footer","Button","selectedRequestId","useFlow","isPending","useIsMutating","mutationKeyInformationRequestsSubmit","handleCancel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,IAA8B,sCAC9BC,KAAsB,CAAC,cAAc,aAAa,iBAAiB,GACnEC,KAAkB;AAAA,EACtB,cAAc,CAAC,KAAK,KAAK,QAAQ;AAAA,EACjC,cAAc,CAAC,UAAU,QAAQ,KAAK;AACxC,GAEMC,KAA+BC,EAAE;AAAA,EACrCA,EAAE,OAAA;AAAA,EACFA,EAAE,MAAM,CAACA,EAAE,OAAA,EAAS,IAAI,CAAC,GAAGA,EAAE,WAAW,IAAI,CAAC,CAAC;AACjD;AAUO,SAASC,GAAuBC,GAAoC;AACzE,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMI,KAAuB,CAACC,MACrB,IAAI,QAAgB,CAACC,GAASC,MAAW;AAC9C,QAAMC,IAAS,IAAI,WAAA;AACnB,EAAAA,EAAO,SAAS,MAAM;AACpB,IAAAF,EAAQE,EAAO,MAAgB;AAAA,EACjC,GACAA,EAAO,UAAUD,GACjBC,EAAO,cAAcH,CAAI;AAC3B,CAAC,GAGGI,KAA2C,CAACC,EAAa,MAAMA,EAAa,QAAQ;AAE1F,SAASC,EAA4BC,GAAgC;AACnE,S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D,CAAAG,MAAOA,EAAI,SAASoC;AAAA,EAAA,GAEwB,qBAAqB,CAAA,GAC7DjC,IAAsBxB,EAA4BsB,CAAiB,GAKnEqC,IAHaC,EAAc;AAAA,IAC/B,aAAaC,EAAA;AAAA,EAAqC,CACnD,IAC8B,GAEzBC,IAAe,MAAM;AACzB,IAAA/C,EAAQ0B,EAAyB,+BAA+B;AAAA,EAClE;AAEA,SAAIjB,IAEA,gBAAAlC,EAAC8D,GAAA,EAAK,gBAAe,YAAW,KAAK,IACnC,UAAA,gBAAA9D,EAACkE,GAAA,EAAO,SAAQ,aAAY,SAASM,GAClC,UAAArD,EAAE,WAAW,GAChB,GACF,IAKF,gBAAAqC,EAACM,GAAA,EAAK,gBAAe,YAAW,KAAK,IACnC,UAAA;AAAA,IAAA,gBAAA9D,EAACkE,GAAA,EAAO,SAAQ,aAAY,SAASM,GAAc,YAAYH,GAC5D,UAAAlD,EAAE,YAAY,EAAA,CACjB;AAAA,IACA,gBAAAnB;AAAA,MAACkE;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,MAAMzE;AAAA,QACN,WAAW4E;AAAA,QAEV,YAAE,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EACjB,GACF;AAEJ;AAEAvE,GAAuB,SAASmE;"}
|
package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BaseComponentInterface } from '../../Base';
|
|
2
2
|
interface InformationRequestListProps extends BaseComponentInterface<'InformationRequests.InformationRequestList'> {
|
|
3
3
|
companyId: string;
|
|
4
|
-
filterByPayrollBlocking?: boolean;
|
|
5
4
|
onEvent: BaseComponentInterface['onEvent'];
|
|
6
5
|
}
|
|
7
6
|
export declare function InformationRequestList(props: InformationRequestListProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
import { jsx as n, jsxs as a } from "react/jsx-runtime";
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import { useInformationRequestsGetInformationRequestsSuspense as
|
|
2
|
+
import { useTranslation as b } from "react-i18next";
|
|
3
|
+
import { useInformationRequestsGetInformationRequestsSuspense as P } from "@gusto/embedded-api/react-query/informationRequestsGetInformationRequests";
|
|
4
4
|
import { InformationRequestStatus as s, InformationRequestType as i } from "@gusto/embedded-api/models/components/informationrequest";
|
|
5
|
-
import { BaseComponent as
|
|
5
|
+
import { BaseComponent as w } from "../../Base/Base.js";
|
|
6
6
|
import "../../Base/useBase.js";
|
|
7
|
-
import { useComponentContext as
|
|
8
|
-
import { useComponentDictionary as
|
|
9
|
-
import { DataView as
|
|
10
|
-
import { useDataView as
|
|
7
|
+
import { useComponentContext as x } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
8
|
+
import { useComponentDictionary as S, useI18n as T } from "../../../i18n/I18n.js";
|
|
9
|
+
import { DataView as D } from "../../Common/DataView/DataView.js";
|
|
10
|
+
import { useDataView as k } from "../../Common/DataView/useDataView.js";
|
|
11
11
|
import { FlexItem as E, Flex as u } from "../../Common/Flex/Flex.js";
|
|
12
|
-
import
|
|
12
|
+
import "classnames";
|
|
13
|
+
import { EmptyData as v } from "../../Common/EmptyData/EmptyData.js";
|
|
13
14
|
import "react";
|
|
14
|
-
import { informationRequestEvents as
|
|
15
|
-
function W(
|
|
16
|
-
return /* @__PURE__ */ n(
|
|
15
|
+
import { informationRequestEvents as B } from "../../../shared/constants.js";
|
|
16
|
+
function W(o) {
|
|
17
|
+
return /* @__PURE__ */ n(w, { ...o, children: /* @__PURE__ */ n(C, { ...o, children: o.children }) });
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const { t } = P("InformationRequests.InformationRequestList"), { Heading: R, Text: l, Button: g, Badge: c } = S(), { data: h } = w({
|
|
26
|
-
companyUuid: r
|
|
27
|
-
}), p = (h.informationRequestList ?? []).filter((e) => {
|
|
28
|
-
const o = e.status !== s.Approved;
|
|
29
|
-
return m ? e.blockingPayroll && o : o;
|
|
30
|
-
}), I = (e) => {
|
|
19
|
+
function C({ companyId: o, dictionary: d, onEvent: f }) {
|
|
20
|
+
S("InformationRequests.InformationRequestList", d), T("InformationRequests.InformationRequestList");
|
|
21
|
+
const { t } = b("InformationRequests.InformationRequestList"), { Heading: y, Text: m, Button: R, Badge: l } = x(), { data: g } = P({
|
|
22
|
+
companyUuid: o
|
|
23
|
+
}), c = (g.informationRequestList ?? []).filter(
|
|
24
|
+
(e) => e.status !== s.Approved
|
|
25
|
+
), h = (e) => {
|
|
31
26
|
switch (e) {
|
|
32
27
|
case i.CompanyOnboarding:
|
|
33
28
|
return t("types.companyOnboarding");
|
|
@@ -49,33 +44,33 @@ function A({
|
|
|
49
44
|
default:
|
|
50
45
|
return null;
|
|
51
46
|
}
|
|
52
|
-
},
|
|
53
|
-
data:
|
|
54
|
-
emptyState: () => /* @__PURE__ */ n(
|
|
47
|
+
}, I = k({
|
|
48
|
+
data: c,
|
|
49
|
+
emptyState: () => /* @__PURE__ */ n(v, { title: t("emptyTableTitle"), description: t("emptyTableDescription") }),
|
|
55
50
|
columns: [
|
|
56
51
|
{
|
|
57
52
|
key: "type",
|
|
58
53
|
title: t("columns.type"),
|
|
59
|
-
render: (e) => /* @__PURE__ */ n(E, { flexGrow: 1, children: /* @__PURE__ */ n(
|
|
54
|
+
render: (e) => /* @__PURE__ */ n(E, { flexGrow: 1, children: /* @__PURE__ */ n(m, { weight: "medium", children: h(e.type) }) })
|
|
60
55
|
},
|
|
61
56
|
{
|
|
62
57
|
key: "status",
|
|
63
58
|
title: t("columns.status"),
|
|
64
59
|
render: (e) => {
|
|
65
|
-
const
|
|
66
|
-
return !
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const r = q(e.status), p = e.blockingPayroll;
|
|
61
|
+
return !r && !p ? null : /* @__PURE__ */ a(u, { gap: 8, alignItems: "center", children: [
|
|
62
|
+
r && /* @__PURE__ */ n(l, { status: r.badgeStatus, children: r.label }),
|
|
63
|
+
p && /* @__PURE__ */ n(l, { status: "error", children: t("status.payrollBlocking") })
|
|
69
64
|
] });
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
67
|
],
|
|
73
68
|
itemMenu: (e) => e.status === s.PendingResponse ? /* @__PURE__ */ n(
|
|
74
|
-
|
|
69
|
+
R,
|
|
75
70
|
{
|
|
76
71
|
variant: "secondary",
|
|
77
72
|
onClick: () => {
|
|
78
|
-
|
|
73
|
+
f(B.INFORMATION_REQUEST_RESPOND, {
|
|
79
74
|
requestId: e.uuid
|
|
80
75
|
});
|
|
81
76
|
},
|
|
@@ -85,10 +80,10 @@ function A({
|
|
|
85
80
|
});
|
|
86
81
|
return /* @__PURE__ */ a(u, { flexDirection: "column", gap: 20, children: [
|
|
87
82
|
/* @__PURE__ */ a(u, { flexDirection: "column", gap: 2, children: [
|
|
88
|
-
/* @__PURE__ */ n(
|
|
89
|
-
|
|
83
|
+
/* @__PURE__ */ n(y, { as: "h2", styledAs: "h4", children: t("title") }),
|
|
84
|
+
c.length > 0 && /* @__PURE__ */ n(m, { children: t("description") })
|
|
90
85
|
] }),
|
|
91
|
-
/* @__PURE__ */ n(
|
|
86
|
+
/* @__PURE__ */ n(D, { ...I, label: t("title") })
|
|
92
87
|
] });
|
|
93
88
|
}
|
|
94
89
|
export {
|
package/dist/components/InformationRequests/InformationRequestList/InformationRequestList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InformationRequestList.js","sources":["../../../../src/components/InformationRequests/InformationRequestList/InformationRequestList.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useInformationRequestsGetInformationRequestsSuspense } from '@gusto/embedded-api/react-query/informationRequestsGetInformationRequests'\nimport type { InformationRequest } from '@gusto/embedded-api/models/components/informationrequest'\nimport {\n InformationRequestStatus,\n InformationRequestType,\n} from '@gusto/embedded-api/models/components/informationrequest'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { DataView } from '@/components/Common/DataView/DataView'\nimport { useDataView } from '@/components/Common/DataView/useDataView'\nimport { EmptyData, Flex, FlexItem } from '@/components/Common'\nimport { informationRequestEvents } from '@/shared/constants'\nimport type { BadgeProps } from '@/components/Common/UI/Badge/BadgeTypes'\n\ninterface InformationRequestListProps extends BaseComponentInterface<'InformationRequests.InformationRequestList'> {\n companyId: string\n
|
|
1
|
+
{"version":3,"file":"InformationRequestList.js","sources":["../../../../src/components/InformationRequests/InformationRequestList/InformationRequestList.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useInformationRequestsGetInformationRequestsSuspense } from '@gusto/embedded-api/react-query/informationRequestsGetInformationRequests'\nimport type { InformationRequest } from '@gusto/embedded-api/models/components/informationrequest'\nimport {\n InformationRequestStatus,\n InformationRequestType,\n} from '@gusto/embedded-api/models/components/informationrequest'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { DataView } from '@/components/Common/DataView/DataView'\nimport { useDataView } from '@/components/Common/DataView/useDataView'\nimport { EmptyData, Flex, FlexItem } from '@/components/Common'\nimport { informationRequestEvents } from '@/shared/constants'\nimport type { BadgeProps } from '@/components/Common/UI/Badge/BadgeTypes'\n\ninterface InformationRequestListProps extends BaseComponentInterface<'InformationRequests.InformationRequestList'> {\n companyId: string\n onEvent: BaseComponentInterface['onEvent']\n}\n\nexport function InformationRequestList(props: InformationRequestListProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\ntype StatusMapping = {\n label: string\n badgeStatus: BadgeProps['status']\n} | null\n\nfunction Root({ companyId, dictionary, onEvent }: InformationRequestListProps) {\n useComponentDictionary('InformationRequests.InformationRequestList', dictionary)\n useI18n('InformationRequests.InformationRequestList')\n const { t } = useTranslation('InformationRequests.InformationRequestList')\n const { Heading, Text, Button, Badge } = useComponentContext()\n\n const { data } = useInformationRequestsGetInformationRequestsSuspense({\n companyUuid: companyId,\n })\n\n const informationRequests = data.informationRequestList ?? []\n\n const visibleRequests = informationRequests.filter(\n request => request.status !== InformationRequestStatus.Approved,\n )\n\n const getTypeLabel = (type: InformationRequest['type']): string => {\n switch (type) {\n case InformationRequestType.CompanyOnboarding:\n return t('types.companyOnboarding')\n case InformationRequestType.AccountProtection:\n return t('types.accountProtection')\n case InformationRequestType.PaymentRequest:\n return t('types.paymentRequest')\n case InformationRequestType.PaymentError:\n return t('types.paymentError')\n default:\n return t('types.unknown')\n }\n }\n\n const getStatusMapping = (status: InformationRequest['status']): StatusMapping => {\n switch (status) {\n case InformationRequestStatus.PendingResponse:\n return { label: t('status.incomplete'), badgeStatus: 'info' }\n case InformationRequestStatus.PendingReview:\n return { label: t('status.underReview'), badgeStatus: 'warning' }\n default:\n return null\n }\n }\n\n const dataViewProps = useDataView({\n data: visibleRequests,\n emptyState: () => (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')} />\n ),\n columns: [\n {\n key: 'type',\n title: t('columns.type'),\n render: request => (\n <FlexItem flexGrow={1}>\n <Text weight=\"medium\">{getTypeLabel(request.type)}</Text>\n </FlexItem>\n ),\n },\n {\n key: 'status',\n title: t('columns.status'),\n render: request => {\n const statusMapping = getStatusMapping(request.status)\n const showPayrollBlockingBadge = request.blockingPayroll\n\n if (!statusMapping && !showPayrollBlockingBadge) {\n return null\n }\n\n return (\n <Flex gap={8} alignItems=\"center\">\n {statusMapping && (\n <Badge status={statusMapping.badgeStatus}>{statusMapping.label}</Badge>\n )}\n {showPayrollBlockingBadge && (\n <Badge status=\"error\">{t('status.payrollBlocking')}</Badge>\n )}\n </Flex>\n )\n },\n },\n ],\n itemMenu: request => {\n const isPendingResponse = request.status === InformationRequestStatus.PendingResponse\n if (!isPendingResponse) {\n return null\n }\n return (\n <Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(informationRequestEvents.INFORMATION_REQUEST_RESPOND, {\n requestId: request.uuid,\n })\n }}\n >\n {t('cta.respond')}\n </Button>\n )\n },\n })\n\n return (\n <Flex flexDirection=\"column\" gap={20}>\n <Flex flexDirection=\"column\" gap={2}>\n <Heading as=\"h2\" styledAs=\"h4\">\n {t('title')}\n </Heading>\n {visibleRequests.length > 0 && <Text>{t('description')}</Text>}\n </Flex>\n\n <DataView {...dataViewProps} label={t('title')} />\n </Flex>\n )\n}\n"],"names":["InformationRequestList","props","jsx","BaseComponent","Root","companyId","dictionary","onEvent","useComponentDictionary","useI18n","useTranslation","Heading","Text","Button","Badge","useComponentContext","data","useInformationRequestsGetInformationRequestsSuspense","visibleRequests","request","InformationRequestStatus","getTypeLabel","type","InformationRequestType","getStatusMapping","status","dataViewProps","useDataView","EmptyData","FlexItem","statusMapping","showPayrollBlockingBadge","jsxs","Flex","informationRequestEvents","DataView"],"mappings":";;;;;;;;;;;;;;;AAqBO,SAASA,EAAuBC,GAAoC;AACzE,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAOA,SAASG,EAAK,EAAE,WAAAC,GAAW,YAAAC,GAAY,SAAAC,KAAwC;AAC7E,EAAAC,EAAuB,8CAA8CF,CAAU,GAC/EG,EAAQ,4CAA4C;AACpD,QAAM,EAAE,EAAA,IAAMC,EAAe,4CAA4C,GACnE,EAAE,SAAAC,GAAS,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,EAAA,IAAUC,EAAA,GAEnC,EAAE,MAAAC,EAAA,IAASC,EAAqD;AAAA,IACpE,aAAaZ;AAAA,EAAA,CACd,GAIKa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