@gusto/embedded-react-sdk 0.34.0 → 0.35.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/components/Base/Base.d.ts +6 -2
- package/dist/components/Base/Base.js +105 -59
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/useBase.d.ts +1 -0
- package/dist/components/Base/useBase.js.map +1 -1
- package/dist/components/Base/useBaseSubmit.d.ts +1 -1
- package/dist/components/Base/useBaseSubmit.js +60 -33
- package/dist/components/Base/useBaseSubmit.js.map +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.js +15 -13
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.js.map +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenuTypes.d.ts +1 -0
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +1 -1
- package/dist/components/Common/UI/Menu/Menu.js +26 -25
- package/dist/components/Common/UI/Menu/Menu.js.map +1 -1
- package/dist/components/Common/UI/Menu/Menu.module.scss.js +7 -7
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +5 -0
- package/dist/components/Common/UI/Menu/MenuTypes.js +4 -3
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/Table/Table.module.scss.js +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +12 -12
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.js +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +15 -15
- package/dist/components/Company/PaySchedule/usePaySchedule.js +5 -6
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +1 -1
- package/dist/components/Contractor/Address/useAddress.js +5 -6
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +2 -2
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +119 -113
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +10 -10
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
- package/dist/components/Employee/Compensation/Edit.js +70 -70
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +9 -10
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +10 -11
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +10 -11
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +18 -18
- package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.js +7 -7
- package/dist/components/Employee/DocumentSigner/SignatureForm/Form.js +5 -5
- package/dist/components/Employee/DocumentSigner/SignatureForm/Form.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/Preview.js +8 -8
- package/dist/components/Employee/DocumentSigner/SignatureForm/Preview.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +3 -4
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalForm.js +7 -7
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +3 -4
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +2 -2
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +8 -8
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +5 -6
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +2 -2
- package/dist/components/Employee/Profile/useProfile.js +3 -4
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/StateTaxes/StateTaxes.js +69 -61
- package/dist/components/Employee/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +3 -4
- package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +7 -7
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js +10 -10
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +9 -9
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.d.ts +2 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +101 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js +16 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js.map +1 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModalTypes.d.ts +7 -0
- package/dist/components/Payroll/GrossUpModal/index.d.ts +3 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +86 -67
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +83 -49
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +6 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +102 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.module.scss.js +14 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js +52 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js +16 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.d.ts +12 -2
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js +15 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/index.d.ts +2 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +212 -120
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +3 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +76 -64
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.d.ts +2 -0
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js +11 -0
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js.map +1 -0
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +67 -57
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +36 -36
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +6 -6
- package/dist/components/Payroll/usePreparedPayrollData.js +44 -44
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +2 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +58 -39
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.js +6 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.d.ts +7 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.js +11 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/index.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js +45 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/sanitization.d.ts +19 -0
- package/dist/contexts/ObservabilityProvider/sanitization.js +95 -0
- package/dist/contexts/ObservabilityProvider/sanitization.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/sanitization.test.d.ts +1 -0
- package/dist/contexts/ObservabilityProvider/useObservability.d.ts +2 -0
- package/dist/contexts/ObservabilityProvider/useObservability.js +11 -0
- package/dist/contexts/ObservabilityProvider/useObservability.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.d.ts +8 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js +28 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js.map +1 -0
- package/dist/contexts/index.d.ts +2 -0
- package/dist/helpers/formattedStrings.js +12 -13
- package/dist/helpers/formattedStrings.js.map +1 -1
- package/dist/helpers/rem.d.ts +7 -3
- package/dist/helpers/rem.js +14 -10
- package/dist/helpers/rem.js.map +1 -1
- package/dist/helpers/rem.test.d.ts +1 -0
- package/dist/helpers/retryAsync.d.ts +7 -0
- package/dist/helpers/retryAsync.js +18 -0
- package/dist/helpers/retryAsync.js.map +1 -0
- package/dist/i18n/I18n.js +15 -15
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.PaySchedule.json.js +1 -1
- package/dist/i18n/en/Payroll.GrossUpModal.json.js +24 -0
- package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -0
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js +13 -11
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -13
- package/dist/index.js.map +1 -1
- package/dist/shared/constants.d.ts +5 -0
- package/dist/shared/constants.js +11 -8
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +26 -1
- package/dist/types/observability.d.ts +145 -0
- package/docs/reference/endpoint-inventory.json +10 -1
- package/package.json +21 -21
|
@@ -9,16 +9,16 @@ import u from "./PayrollEditEmployeePresentation.module.scss.js";
|
|
|
9
9
|
import { TimeOffField as ne } from "./TimeOffField.js";
|
|
10
10
|
import { Flex as x } from "../../Common/Flex/Flex.js";
|
|
11
11
|
import { Grid as P } from "../../Common/Grid/Grid.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import Oe from "
|
|
12
|
+
import { useComponentContext as re } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
+
import { useI18n as oe } from "../../../i18n/I18n.js";
|
|
14
|
+
import { Form as ie } from "../../Common/Form/Form.js";
|
|
15
|
+
import { firstLastName as se, formatNumberAsCurrency as ae } from "../../../helpers/formattedStrings.js";
|
|
16
|
+
import { getAdditionalEarningsCompensations as me, getReimbursementCompensation as le, calculateGrossPay as G } from "../helpers.js";
|
|
17
|
+
import { HOURS_COMPENSATION_NAMES as k, EXCLUDED_ADDITIONAL_EARNINGS as de, COMPENSATION_NAME_DOUBLE_OVERTIME as ue, COMPENSATION_NAME_OVERTIME as ce, COMPENSATION_NAME_REGULAR_HOURS as pe, COMPENSATION_NAME_REIMBURSEMENT as fe, COMPENSATION_NAME_CASH_TIPS as he, COMPENSATION_NAME_COMMISSION as Ce, COMPENSATION_NAME_CORRECTION_PAYMENT as Ne, COMPENSATION_NAME_PAYCHECK_TIPS as Ee, COMPENSATION_NAME_BONUS as ge } from "../../../shared/constants.js";
|
|
18
|
+
import be from "../../../hooks/useContainerBreakpoints/useContainerBreakpoints.js";
|
|
19
|
+
import { TextInputField as Me } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
20
|
+
import { NumberInputField as w } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
21
|
+
import { RadioGroupField as Oe } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
22
22
|
const Te = m.object({
|
|
23
23
|
hourlyCompensations: m.record(m.string(), m.record(m.string(), m.string().optional())),
|
|
24
24
|
timeOffCompensations: m.record(m.string(), m.string().optional()),
|
|
@@ -72,22 +72,22 @@ const Te = m.object({
|
|
|
72
72
|
withReimbursements: M = !0,
|
|
73
73
|
hasDirectDepositSetup: $ = !0
|
|
74
74
|
}) => {
|
|
75
|
-
const { Button: v, Heading: c, Text: B } =
|
|
76
|
-
|
|
77
|
-
const f = l.jobs?.find((e) => e.primary), O = f ? [f] : [], F = Z(null), p =
|
|
75
|
+
const { Button: v, Heading: c, Text: B } = re(), { t } = ee("Payroll.PayrollEditEmployee");
|
|
76
|
+
oe("Payroll.PayrollEditEmployee");
|
|
77
|
+
const f = l.jobs?.find((e) => e.primary), O = f ? [f] : [], F = Z(null), p = be({
|
|
78
78
|
ref: F
|
|
79
79
|
}).includes("small");
|
|
80
80
|
i?.hourlyCompensations?.forEach((e) => {
|
|
81
81
|
const n = l.jobs?.find((s) => s.uuid === e.jobUuid);
|
|
82
82
|
n && !O.find((s) => s.uuid === n.uuid) && O.push(n);
|
|
83
83
|
});
|
|
84
|
-
const A = (i?.paidTimeOff || []).filter((e) => e.name), _ =
|
|
84
|
+
const A = (i?.paidTimeOff || []).filter((e) => e.name), _ = me({
|
|
85
85
|
flsaStatus: f?.compensations?.[0]?.flsaStatus,
|
|
86
86
|
existingFixedCompensations: i?.fixedCompensations || [],
|
|
87
87
|
primaryJobUuid: f?.uuid,
|
|
88
88
|
fixedCompensationTypes: b,
|
|
89
|
-
excludedTypes:
|
|
90
|
-
}), N = M ?
|
|
89
|
+
excludedTypes: de
|
|
90
|
+
}), N = M ? le(
|
|
91
91
|
i?.fixedCompensations || [],
|
|
92
92
|
b,
|
|
93
93
|
f?.uuid
|
|
@@ -95,28 +95,28 @@ const Te = m.object({
|
|
|
95
95
|
(s) => s.jobUuid === e && s.name?.toLowerCase() === n.toLowerCase()
|
|
96
96
|
), q = (e) => {
|
|
97
97
|
switch (e) {
|
|
98
|
-
case
|
|
98
|
+
case pe:
|
|
99
99
|
return t("compensationNames.regularHours");
|
|
100
|
-
case
|
|
100
|
+
case ce:
|
|
101
101
|
return t("compensationNames.overtime");
|
|
102
|
-
case
|
|
102
|
+
case ue:
|
|
103
103
|
return t("compensationNames.doubleOvertime");
|
|
104
104
|
default:
|
|
105
105
|
return e;
|
|
106
106
|
}
|
|
107
107
|
}, j = (e) => {
|
|
108
108
|
switch (e) {
|
|
109
|
-
case
|
|
109
|
+
case ge:
|
|
110
110
|
return t("fixedCompensationNames.bonus");
|
|
111
|
-
case
|
|
111
|
+
case Ee:
|
|
112
112
|
return t("fixedCompensationNames.paycheckTips");
|
|
113
|
-
case
|
|
113
|
+
case Ne:
|
|
114
114
|
return t("fixedCompensationNames.correctionPayment");
|
|
115
|
-
case
|
|
115
|
+
case Ce:
|
|
116
116
|
return t("fixedCompensationNames.commission");
|
|
117
|
-
case
|
|
117
|
+
case he:
|
|
118
118
|
return t("fixedCompensationNames.cashTips");
|
|
119
|
-
case
|
|
119
|
+
case fe:
|
|
120
120
|
return t("fixedCompensationNames.reimbursement");
|
|
121
121
|
default:
|
|
122
122
|
return e;
|
|
@@ -125,7 +125,7 @@ const Te = m.object({
|
|
|
125
125
|
hourlyCompensations: (() => {
|
|
126
126
|
const e = {};
|
|
127
127
|
return O.forEach((n) => {
|
|
128
|
-
|
|
128
|
+
k.forEach((s) => {
|
|
129
129
|
const h = R(n.uuid, s);
|
|
130
130
|
h && (e[n.uuid] || (e[n.uuid] = {}), e[n.uuid][h.name] = h.hours ? parseFloat(h.hours).toString() : "");
|
|
131
131
|
});
|
|
@@ -166,7 +166,7 @@ const Te = m.object({
|
|
|
166
166
|
(i?.paidTimeOff || []).filter((h) => h.name),
|
|
167
167
|
f?.uuid
|
|
168
168
|
);
|
|
169
|
-
return
|
|
169
|
+
return G(
|
|
170
170
|
s,
|
|
171
171
|
l,
|
|
172
172
|
o,
|
|
@@ -174,7 +174,7 @@ const Te = m.object({
|
|
|
174
174
|
C
|
|
175
175
|
);
|
|
176
176
|
} catch {
|
|
177
|
-
return i ?
|
|
177
|
+
return i ? G(
|
|
178
178
|
i,
|
|
179
179
|
l,
|
|
180
180
|
o,
|
|
@@ -190,7 +190,7 @@ const Te = m.object({
|
|
|
190
190
|
o,
|
|
191
191
|
d,
|
|
192
192
|
C
|
|
193
|
-
]), W =
|
|
193
|
+
]), W = se({
|
|
194
194
|
first_name: l.firstName,
|
|
195
195
|
last_name: l.lastName
|
|
196
196
|
}), Y = (e) => {
|
|
@@ -201,7 +201,7 @@ const Te = m.object({
|
|
|
201
201
|
f?.uuid
|
|
202
202
|
);
|
|
203
203
|
E(n);
|
|
204
|
-
}, L =
|
|
204
|
+
}, L = ae(z || 0), U = /* @__PURE__ */ a(
|
|
205
205
|
x,
|
|
206
206
|
{
|
|
207
207
|
flexDirection: p ? "row" : "column",
|
|
@@ -240,19 +240,19 @@ const Te = m.object({
|
|
|
240
240
|
}
|
|
241
241
|
),
|
|
242
242
|
/* @__PURE__ */ a(Q, { ...I, children: [
|
|
243
|
-
/* @__PURE__ */ a(
|
|
243
|
+
/* @__PURE__ */ a(ie, { children: [
|
|
244
244
|
O.length > 0 && /* @__PURE__ */ a("div", { className: u.fieldGroup, children: [
|
|
245
245
|
/* @__PURE__ */ r(c, { as: "h3", children: t("regularHoursTitle") }),
|
|
246
246
|
O.map((e) => /* @__PURE__ */ a(x, { flexDirection: "column", gap: 8, children: [
|
|
247
247
|
O.length > 1 && /* @__PURE__ */ r(c, { as: "h4", children: e.title }),
|
|
248
|
-
/* @__PURE__ */ r(P, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children:
|
|
248
|
+
/* @__PURE__ */ r(P, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: k.map((n) => {
|
|
249
249
|
const s = R(
|
|
250
250
|
e.uuid,
|
|
251
251
|
n
|
|
252
252
|
);
|
|
253
253
|
if (s)
|
|
254
254
|
return /* @__PURE__ */ r(
|
|
255
|
-
|
|
255
|
+
Me,
|
|
256
256
|
{
|
|
257
257
|
type: "number",
|
|
258
258
|
min: 0,
|
|
@@ -285,7 +285,7 @@ const Te = m.object({
|
|
|
285
285
|
gridTemplateColumns: { base: "1fr", small: [320, 320], large: [320, 320, 320] },
|
|
286
286
|
gap: 20,
|
|
287
287
|
children: _.map((e) => /* @__PURE__ */ r(
|
|
288
|
-
|
|
288
|
+
w,
|
|
289
289
|
{
|
|
290
290
|
format: "currency",
|
|
291
291
|
min: 0,
|
|
@@ -301,7 +301,7 @@ const Te = m.object({
|
|
|
301
301
|
N && /* @__PURE__ */ a("div", { className: u.fieldGroup, children: [
|
|
302
302
|
/* @__PURE__ */ r(c, { as: "h4", children: t("reimbursementTitle") }),
|
|
303
303
|
/* @__PURE__ */ r(P, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: /* @__PURE__ */ r(
|
|
304
|
-
|
|
304
|
+
w,
|
|
305
305
|
{
|
|
306
306
|
format: "currency",
|
|
307
307
|
min: 0,
|
|
@@ -314,7 +314,7 @@ const Te = m.object({
|
|
|
314
314
|
$ && /* @__PURE__ */ a("div", { className: u.fieldGroup, children: [
|
|
315
315
|
/* @__PURE__ */ r(c, { as: "h4", children: t("paymentMethodTitle") }),
|
|
316
316
|
/* @__PURE__ */ r(
|
|
317
|
-
|
|
317
|
+
Oe,
|
|
318
318
|
{
|
|
319
319
|
name: "paymentMethod",
|
|
320
320
|
isRequired: !0,
|
|
@@ -5,23 +5,23 @@ import { useTranslation as c } from "react-i18next";
|
|
|
5
5
|
import { Flex as y } from "../../Common/Flex/Flex.js";
|
|
6
6
|
import "classnames";
|
|
7
7
|
import "../../../shared/constants.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { useComponentContext as x } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
9
|
+
import { useI18n as h } from "../../../i18n/I18n.js";
|
|
10
|
+
import { TextInputField as B } from "../../Common/Fields/TextInputField/TextInputField.js";
|
|
11
11
|
const P = ({
|
|
12
12
|
accrualBalance: e,
|
|
13
13
|
accrualMethod: o,
|
|
14
14
|
hoursUsed: r,
|
|
15
15
|
id: t
|
|
16
16
|
}) => {
|
|
17
|
-
const { Text: n } =
|
|
17
|
+
const { Text: n } = x(), { t: i } = c("Payroll.PayrollEditEmployee");
|
|
18
18
|
if (o === "unlimited")
|
|
19
19
|
return null;
|
|
20
20
|
const a = parseFloat(e) - r;
|
|
21
21
|
return /* @__PURE__ */ l(n, { size: "sm", variant: "supporting", "aria-live": "polite", "aria-atomic": !0, id: t, children: i("timeOffBalance.remaining", { balance: a.toFixed(1) }) });
|
|
22
22
|
}, U = ({ timeOff: e, employee: o }) => {
|
|
23
23
|
const { t: r } = c("Payroll.PayrollEditEmployee");
|
|
24
|
-
|
|
24
|
+
h("Payroll.PayrollEditEmployee");
|
|
25
25
|
const { control: t } = d(), n = p(), i = f({
|
|
26
26
|
control: t,
|
|
27
27
|
name: `timeOffCompensations.${e.name}`
|
|
@@ -31,7 +31,7 @@ const P = ({
|
|
|
31
31
|
const m = parseFloat(i || "0"), a = o.eligiblePaidTimeOff?.find((s) => s.name === e.name);
|
|
32
32
|
return /* @__PURE__ */ u(y, { flexDirection: "column", gap: 4, children: [
|
|
33
33
|
/* @__PURE__ */ l(
|
|
34
|
-
|
|
34
|
+
B,
|
|
35
35
|
{
|
|
36
36
|
name: `timeOffCompensations.${e.name}`,
|
|
37
37
|
type: "number",
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { usePayrollsPrepareMutation as
|
|
3
|
-
import { usePaySchedulesGet as
|
|
1
|
+
import { useState as b, useRef as y, useMemo as M, useCallback as m, useEffect as _ } from "react";
|
|
2
|
+
import { usePayrollsPrepareMutation as L } from "@gusto/embedded-api/react-query/payrollsPrepare";
|
|
3
|
+
import { usePaySchedulesGet as D } from "@gusto/embedded-api/react-query/paySchedulesGet";
|
|
4
|
+
import { UnprocessableEntityErrorObject as T } from "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
4
5
|
import "react/jsx-runtime";
|
|
5
6
|
import "react-error-boundary";
|
|
6
7
|
import "react-i18next";
|
|
7
8
|
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
8
9
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
9
10
|
import "@tanstack/react-query";
|
|
10
|
-
import { useBase as
|
|
11
|
+
import { useBase as j } from "../Base/useBase.js";
|
|
11
12
|
import "../../shared/constants.js";
|
|
12
13
|
import "classnames";
|
|
13
14
|
import "../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
15
|
import "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
16
|
import "dompurify";
|
|
16
|
-
import "../../
|
|
17
|
-
const
|
|
18
|
-
companyId:
|
|
19
|
-
payrollId:
|
|
17
|
+
import { retryAsync as x } from "../../helpers/retryAsync.js";
|
|
18
|
+
const q = 4, v = 1500, w = (e) => e instanceof T ? Array.isArray(e.errors) && e.errors.some((r) => r.category === "invalid_operation") : !1, W = ({
|
|
19
|
+
companyId: e,
|
|
20
|
+
payrollId: r,
|
|
20
21
|
employeeUuids: a,
|
|
21
22
|
sortBy: n,
|
|
22
23
|
onDataReady: l
|
|
23
24
|
}) => {
|
|
24
|
-
const { mutateAsync:
|
|
25
|
+
const { mutateAsync: c, isPending: p } = L(), [o, f] = b(), t = y(!1), u = y(!1), { baseSubmitHandler: d } = j(), h = M(() => a?.join(",") ?? "", [a]), { data: S, isLoading: E } = D(
|
|
25
26
|
{
|
|
26
|
-
companyId:
|
|
27
|
-
payScheduleId:
|
|
27
|
+
companyId: e,
|
|
28
|
+
payScheduleId: o?.payPeriod?.payScheduleUuid || ""
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
|
-
enabled: !!
|
|
31
|
+
enabled: !!o?.payPeriod?.payScheduleUuid
|
|
31
32
|
}
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
employeeUuids: a
|
|
41
|
-
}
|
|
33
|
+
), P = m(async () => {
|
|
34
|
+
const i = await c({
|
|
35
|
+
request: {
|
|
36
|
+
companyId: e,
|
|
37
|
+
payrollId: r,
|
|
38
|
+
sortBy: n,
|
|
39
|
+
requestBody: {
|
|
40
|
+
employeeUuids: a
|
|
42
41
|
}
|
|
43
|
-
}
|
|
44
|
-
m(o.payrollPrepared), o.payrollPrepared && (e.current = !0, l?.(o.payrollPrepared));
|
|
42
|
+
}
|
|
45
43
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
f(i.payrollPrepared), i.payrollPrepared && (t.current = !0, l?.(i.payrollPrepared));
|
|
45
|
+
}, [e, r, c, h, n, l]), s = m(async () => {
|
|
46
|
+
await d(
|
|
47
|
+
null,
|
|
48
|
+
() => x(P, {
|
|
49
|
+
maxAttempts: q,
|
|
50
|
+
delayMs: v,
|
|
51
|
+
shouldRetry: w
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
}, [d, P]);
|
|
55
|
+
_(() => {
|
|
56
|
+
u.current || (u.current = !0, s());
|
|
57
|
+
}, [s]);
|
|
58
|
+
const g = p && !t.current, A = p && t.current, R = g || E;
|
|
59
59
|
return {
|
|
60
|
-
handlePreparePayroll:
|
|
61
|
-
preparedPayroll:
|
|
62
|
-
paySchedule:
|
|
63
|
-
isLoading:
|
|
64
|
-
isPaginating:
|
|
65
|
-
hasInitialData:
|
|
60
|
+
handlePreparePayroll: s,
|
|
61
|
+
preparedPayroll: o,
|
|
62
|
+
paySchedule: S?.payScheduleObject,
|
|
63
|
+
isLoading: R,
|
|
64
|
+
isPaginating: A,
|
|
65
|
+
hasInitialData: t.current
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
export {
|
|
69
|
-
|
|
69
|
+
W as usePreparedPayrollData
|
|
70
70
|
};
|
|
71
71
|
//# sourceMappingURL=usePreparedPayrollData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payroll'\nimport type { PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { QueryParamSortBy } from '@gusto/embedded-api/models/operations/putv1companiescompanyidpayrollspayrollidprepare'\nimport { useBase } from '../Base'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: QueryParamSortBy\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleObject | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const
|
|
1
|
+
{"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payroll'\nimport type { PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { QueryParamSortBy } from '@gusto/embedded-api/models/operations/putv1companiescompanyidpayrollspayrollidprepare'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: QueryParamSortBy\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleObject | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityErrorObject)) return false\n return Array.isArray(error.errors) && error.errors.some(e => e.category === 'invalid_operation')\n}\n\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [companyId, payrollId, preparePayroll, employeeUuidsKey, sortBy, onDataReady])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleObject,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityErrorObject","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChB,MAAM,QAAQD,EAAM,MAAM,KAAKA,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADhC,IAIpDC,IAAyB,CAAC;AAAA,EACrC,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AACF,MAAkE;AAChE,QAAM,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAC9CC,EAAA,GACI,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxCC,IAAoBC,EAAO,EAAK,GAChCC,IAAcD,EAAO,EAAK,GAC1B,EAAE,mBAAAE,EAAA,IAAsBC,EAAA,GAExBC,IAAmBC,EAAQ,MAAMf,GAAe,KAAK,GAAG,KAAK,IAAI,CAACA,CAAa,CAAC,GAEhF,EAAE,MAAMgB,GAAiB,WAAWC,MAAyBC;AAAA,IACjE;AAAA,MACE,WAAApB;AAAA,MACA,eAAeQ,GAAiB,WAAW,mBAAmB;AAAA,IAAA;AAAA,IAEhE;AAAA,MACE,SAAS,CAAC,CAACA,GAAiB,WAAW;AAAA,IAAA;AAAA,EACzC,GAGIa,IAAiBC,EAAY,YAAY;AAC7C,UAAMC,IAAS,MAAMlB,EAAe;AAAA,MAClC,SAAS;AAAA,QACP,WAAAL;AAAA,QACA,WAAAC;AAAA,QACA,QAAAE;AAAA,QACA,aAAa;AAAA,UACX,eAAAD;AAAA,QAAA;AAAA,MACF;AAAA,IACF,CACD;AACD,IAAAO,EAAmBc,EAAO,eAAe,GACrCA,EAAO,oBACTZ,EAAkB,UAAU,IAC5BP,IAAcmB,EAAO,eAAe;AAAA,EAExC,GAAG,CAACvB,GAAWC,GAAWI,GAAgBW,GAAkBb,GAAQC,CAAW,CAAC,GAE1EoB,IAAuBF,EAAY,YAAY;AACnD,UAAMR;AAAA,MAAkB;AAAA,MAAM,MAC5BW,EAAWJ,GAAgB;AAAA,QACzB,aAAa5B;AAAA,QACb,SAASC;AAAA,QACT,aAAaC;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,EAEL,GAAG,CAACmB,GAAmBO,CAAc,CAAC;AAEtC,EAAAK,EAAU,MAAM;AACd,IAAIb,EAAY,YAChBA,EAAY,UAAU,IACjBW,EAAA;AAAA,EACP,GAAG,CAACA,CAAoB,CAAC;AAEzB,QAAMG,IAAmBrB,KAA2B,CAACK,EAAkB,SACjEiB,IAAetB,KAA2BK,EAAkB,SAC5DkB,IAAYF,KAAoBR;AAEtC,SAAO;AAAA,IACL,sBAAAK;AAAA,IACA,iBAAAhB;AAAA,IACA,aAAaU,GAAiB;AAAA,IAC9B,WAAAW;AAAA,IACA,cAAAD;AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
|
|
@@ -5,10 +5,12 @@ import { LoadingIndicatorContextProps } from '../LoadingIndicatorProvider/useLoa
|
|
|
5
5
|
import { GustoSDKTheme } from '../ThemeProvider/theme';
|
|
6
6
|
import { ResourceDictionary } from '../../types/Helpers';
|
|
7
7
|
import { SDKHooks } from '../../types/hooks';
|
|
8
|
+
import { ObservabilityHook } from '../../types/observability';
|
|
8
9
|
export interface APIConfig {
|
|
9
10
|
baseUrl: string;
|
|
10
11
|
headers?: HeadersInit;
|
|
11
12
|
hooks?: SDKHooks;
|
|
13
|
+
observability?: ObservabilityHook;
|
|
12
14
|
}
|
|
13
15
|
export interface GustoProviderProps {
|
|
14
16
|
config: APIConfig;
|
|
@@ -1,57 +1,76 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { ErrorBoundary as
|
|
3
|
-
import { I18nextProvider as
|
|
4
|
-
import { useEffect as
|
|
5
|
-
import { ComponentsProvider as
|
|
6
|
-
import { ApiProvider as
|
|
7
|
-
import { LoadingIndicatorProvider as
|
|
8
|
-
import {
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { ErrorBoundary as y } from "react-error-boundary";
|
|
3
|
+
import { I18nextProvider as E } from "react-i18next";
|
|
4
|
+
import { useEffect as g, useMemo as k } from "react";
|
|
5
|
+
import { ComponentsProvider as P } from "../ComponentAdapter/ComponentsProvider.js";
|
|
6
|
+
import { ApiProvider as x } from "../ApiProvider/ApiProvider.js";
|
|
7
|
+
import { LoadingIndicatorProvider as C } from "../LoadingIndicatorProvider/LoadingIndicatorProvider.js";
|
|
8
|
+
import { ObservabilityProvider as I } from "../ObservabilityProvider/ObservabilityProvider.js";
|
|
9
|
+
import { sanitizeError as L } from "../ObservabilityProvider/sanitization.js";
|
|
10
|
+
import { SDKI18next as s } from "./SDKI18next.js";
|
|
9
11
|
import "../../shared/constants.js";
|
|
10
12
|
import "classnames";
|
|
11
|
-
import { InternalError as
|
|
13
|
+
import { InternalError as S } from "../../components/Common/InternalError/InternalError.js";
|
|
12
14
|
import "../ComponentAdapter/useComponentContext.js";
|
|
13
|
-
import { LocaleProvider as
|
|
14
|
-
import "../
|
|
15
|
-
|
|
16
|
-
const z = (a) => {
|
|
15
|
+
import { LocaleProvider as U } from "../LocaleProvider/LocaleProvider.js";
|
|
16
|
+
import { ThemeProvider as z } from "../ThemeProvider/ThemeProvider.js";
|
|
17
|
+
const N = (m) => {
|
|
17
18
|
const {
|
|
18
|
-
children:
|
|
19
|
-
config:
|
|
20
|
-
dictionary:
|
|
21
|
-
lng:
|
|
22
|
-
locale:
|
|
23
|
-
currency:
|
|
19
|
+
children: c,
|
|
20
|
+
config: r,
|
|
21
|
+
dictionary: n,
|
|
22
|
+
lng: a = "en",
|
|
23
|
+
locale: l = "en-US",
|
|
24
|
+
currency: d = "USD",
|
|
24
25
|
theme: p,
|
|
25
|
-
components:
|
|
26
|
-
LoaderComponent:
|
|
26
|
+
components: f,
|
|
27
|
+
LoaderComponent: v,
|
|
27
28
|
queryClient: u
|
|
28
|
-
} =
|
|
29
|
-
if (
|
|
30
|
-
for (const
|
|
31
|
-
const i =
|
|
32
|
-
for (const
|
|
33
|
-
|
|
29
|
+
} = m;
|
|
30
|
+
if (n)
|
|
31
|
+
for (const e in n) {
|
|
32
|
+
const i = e;
|
|
33
|
+
for (const t in n[i])
|
|
34
|
+
s.addResourceBundle(
|
|
34
35
|
i,
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
t,
|
|
37
|
+
n[i][t],
|
|
37
38
|
!0,
|
|
38
39
|
!0
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
(async () => await
|
|
43
|
-
}, [
|
|
44
|
-
|
|
42
|
+
g(() => {
|
|
43
|
+
(async () => await s.changeLanguage(a))();
|
|
44
|
+
}, [a]);
|
|
45
|
+
const b = k(() => {
|
|
46
|
+
if (r.observability?.onError)
|
|
47
|
+
return (e, i) => {
|
|
48
|
+
if (!r.observability?.onError) return;
|
|
49
|
+
const t = {
|
|
50
|
+
type: "internal_error",
|
|
51
|
+
message: e instanceof Error ? e.message : "Unknown error",
|
|
52
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
53
|
+
context: {
|
|
54
|
+
componentStack: i.componentStack ?? void 0
|
|
55
|
+
},
|
|
56
|
+
originalError: e,
|
|
57
|
+
timestamp: Date.now()
|
|
58
|
+
}, h = L(t, r.observability.sanitization);
|
|
59
|
+
r.observability.onError(h);
|
|
60
|
+
};
|
|
61
|
+
}, [r.observability]);
|
|
62
|
+
return /* @__PURE__ */ o(P, { value: f, children: /* @__PURE__ */ o(C, { value: v, children: /* @__PURE__ */ o(I, { observability: r.observability, children: /* @__PURE__ */ o(y, { FallbackComponent: S, onError: b, children: /* @__PURE__ */ o(z, { theme: p, children: /* @__PURE__ */ o(U, { locale: l, currency: d, children: /* @__PURE__ */ o(E, { i18n: s, children: /* @__PURE__ */ o(
|
|
63
|
+
x,
|
|
45
64
|
{
|
|
46
|
-
url:
|
|
47
|
-
headers:
|
|
48
|
-
hooks:
|
|
65
|
+
url: r.baseUrl,
|
|
66
|
+
headers: r.headers,
|
|
67
|
+
hooks: r.hooks,
|
|
49
68
|
queryClient: u,
|
|
50
|
-
children:
|
|
69
|
+
children: c
|
|
51
70
|
}
|
|
52
|
-
) },
|
|
71
|
+
) }, a) }) }) }) }) }) });
|
|
53
72
|
};
|
|
54
73
|
export {
|
|
55
|
-
|
|
74
|
+
N as GustoProviderCustomUIAdapter
|
|
56
75
|
};
|
|
57
76
|
//# sourceMappingURL=GustoProviderCustomUIAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GustoProviderCustomUIAdapter.js","sources":["../../../src/contexts/GustoProvider/GustoProviderCustomUIAdapter.tsx"],"sourcesContent":["import type React from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { I18nextProvider } from 'react-i18next'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { useEffect } from 'react'\nimport { ComponentsProvider } from '../ComponentAdapter/ComponentsProvider'\nimport type { ComponentsContextType } from '../ComponentAdapter/useComponentContext'\nimport { ApiProvider } from '../ApiProvider/ApiProvider'\nimport { LoadingIndicatorProvider } from '../LoadingIndicatorProvider/LoadingIndicatorProvider'\nimport type { LoadingIndicatorContextProps } from '../LoadingIndicatorProvider/useLoadingIndicator'\nimport { SDKI18next } from './SDKI18next'\nimport { InternalError } from '@/components/Common'\nimport { LocaleProvider } from '@/contexts/LocaleProvider'\nimport { ThemeProvider } from '@/contexts/ThemeProvider'\nimport type { GustoSDKTheme } from '@/contexts/ThemeProvider/theme'\nimport type { ResourceDictionary, SupportedLanguages } from '@/types/Helpers'\nimport type { SDKHooks } from '@/types/hooks'\n\nexport interface APIConfig {\n baseUrl: string\n headers?: HeadersInit\n hooks?: SDKHooks\n}\n\nexport interface GustoProviderProps {\n config: APIConfig\n dictionary?: ResourceDictionary\n lng?: string\n locale?: string\n currency?: string\n theme?: GustoSDKTheme\n queryClient?: QueryClient\n components: ComponentsContextType\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n}\n\nexport interface GustoProviderCustomUIAdapterProps extends GustoProviderProps {\n children?: React.ReactNode\n}\n\n/**\n * A provider that accepts UI component adapters through the components prop\n */\nconst GustoProviderCustomUIAdapter: React.FC<GustoProviderCustomUIAdapterProps> = props => {\n const {\n children,\n config,\n dictionary,\n lng = 'en',\n locale = 'en-US',\n currency = 'USD',\n theme,\n components,\n LoaderComponent,\n queryClient,\n } = props\n\n // Handle dictionary resources\n if (dictionary) {\n for (const language in dictionary) {\n const lang = language as SupportedLanguages\n for (const ns in dictionary[lang]) {\n // Adding resources overrides to i18next instance - initial load will override common namespace and add component specific dictionaries provided by partners\n SDKI18next.addResourceBundle(\n lang,\n ns,\n (dictionary[lang] as Record<string, unknown>)[ns],\n true,\n true,\n )\n }\n }\n }\n\n // Handle language change\n useEffect(() => {\n void (async () => {\n await SDKI18next.changeLanguage(lng)\n })()\n }, [lng])\n\n return (\n <ComponentsProvider value={components}>\n <LoadingIndicatorProvider value={LoaderComponent}>\n <ErrorBoundary FallbackComponent={InternalError}>\n
|
|
1
|
+
{"version":3,"file":"GustoProviderCustomUIAdapter.js","sources":["../../../src/contexts/GustoProvider/GustoProviderCustomUIAdapter.tsx"],"sourcesContent":["import type React from 'react'\nimport type { ErrorInfo } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { I18nextProvider } from 'react-i18next'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { useEffect, useMemo } from 'react'\nimport { ComponentsProvider } from '../ComponentAdapter/ComponentsProvider'\nimport type { ComponentsContextType } from '../ComponentAdapter/useComponentContext'\nimport { ApiProvider } from '../ApiProvider/ApiProvider'\nimport { LoadingIndicatorProvider } from '../LoadingIndicatorProvider/LoadingIndicatorProvider'\nimport type { LoadingIndicatorContextProps } from '../LoadingIndicatorProvider/useLoadingIndicator'\nimport { ObservabilityProvider } from '../ObservabilityProvider'\nimport { sanitizeError } from '../ObservabilityProvider/sanitization'\nimport { SDKI18next } from './SDKI18next'\nimport { InternalError } from '@/components/Common'\nimport { LocaleProvider } from '@/contexts/LocaleProvider'\nimport { ThemeProvider } from '@/contexts/ThemeProvider'\nimport type { GustoSDKTheme } from '@/contexts/ThemeProvider/theme'\nimport type { ResourceDictionary, SupportedLanguages } from '@/types/Helpers'\nimport type { SDKHooks } from '@/types/hooks'\nimport type { ObservabilityHook } from '@/types/observability'\n\nexport interface APIConfig {\n baseUrl: string\n headers?: HeadersInit\n hooks?: SDKHooks\n observability?: ObservabilityHook\n}\n\nexport interface GustoProviderProps {\n config: APIConfig\n dictionary?: ResourceDictionary\n lng?: string\n locale?: string\n currency?: string\n theme?: GustoSDKTheme\n queryClient?: QueryClient\n components: ComponentsContextType\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n}\n\nexport interface GustoProviderCustomUIAdapterProps extends GustoProviderProps {\n children?: React.ReactNode\n}\n\n/**\n * A provider that accepts UI component adapters through the components prop\n */\nconst GustoProviderCustomUIAdapter: React.FC<GustoProviderCustomUIAdapterProps> = props => {\n const {\n children,\n config,\n dictionary,\n lng = 'en',\n locale = 'en-US',\n currency = 'USD',\n theme,\n components,\n LoaderComponent,\n queryClient,\n } = props\n\n // Handle dictionary resources\n if (dictionary) {\n for (const language in dictionary) {\n const lang = language as SupportedLanguages\n for (const ns in dictionary[lang]) {\n // Adding resources overrides to i18next instance - initial load will override common namespace and add component specific dictionaries provided by partners\n SDKI18next.addResourceBundle(\n lang,\n ns,\n (dictionary[lang] as Record<string, unknown>)[ns],\n true,\n true,\n )\n }\n }\n }\n\n // Handle language change\n useEffect(() => {\n void (async () => {\n await SDKI18next.changeLanguage(lng)\n })()\n }, [lng])\n\n // Create sanitized error handler that respects sanitization config\n const handleTopLevelError = useMemo(() => {\n if (!config.observability?.onError) return undefined\n\n return (error: unknown, errorInfo: ErrorInfo) => {\n if (!config.observability?.onError) return\n\n const unsanitizedError = {\n type: 'internal_error' as const,\n message: error instanceof Error ? error.message : 'Unknown error',\n stack: error instanceof Error ? error.stack : undefined,\n context: {\n componentStack: errorInfo.componentStack ?? undefined,\n },\n originalError: error,\n timestamp: Date.now(),\n }\n\n // Apply sanitization with the same config used for other errors\n const sanitizedError = sanitizeError(unsanitizedError, config.observability.sanitization)\n\n config.observability.onError(sanitizedError)\n }\n }, [config.observability])\n return (\n <ComponentsProvider value={components}>\n <LoadingIndicatorProvider value={LoaderComponent}>\n <ObservabilityProvider observability={config.observability}>\n <ErrorBoundary FallbackComponent={InternalError} onError={handleTopLevelError}>\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={locale} currency={currency}>\n <I18nextProvider i18n={SDKI18next} key={lng}>\n <ApiProvider\n url={config.baseUrl}\n headers={config.headers}\n hooks={config.hooks}\n queryClient={queryClient}\n >\n {children}\n </ApiProvider>\n </I18nextProvider>\n </LocaleProvider>\n </ThemeProvider>\n </ErrorBoundary>\n </ObservabilityProvider>\n </LoadingIndicatorProvider>\n </ComponentsProvider>\n )\n}\n\nexport { GustoProviderCustomUIAdapter }\n"],"names":["GustoProviderCustomUIAdapter","props","children","config","dictionary","lng","locale","currency","theme","components","LoaderComponent","queryClient","language","lang","ns","SDKI18next","useEffect","handleTopLevelError","useMemo","error","errorInfo","unsanitizedError","sanitizedError","sanitizeError","jsx","ComponentsProvider","LoadingIndicatorProvider","ObservabilityProvider","ErrorBoundary","InternalError","ThemeProvider","LocaleProvider","I18nextProvider","ApiProvider"],"mappings":";;;;;;;;;;;;;;;;AAgDA,MAAMA,IAA4E,CAAAC,MAAS;AACzF,QAAM;AAAA,IACJ,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,KAAAC,IAAM;AAAA,IACN,QAAAC,IAAS;AAAA,IACT,UAAAC,IAAW;AAAA,IACX,OAAAC;AAAA,IACA,YAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAC;AAAA,EAAA,IACEV;AAGJ,MAAIG;AACF,eAAWQ,KAAYR,GAAY;AACjC,YAAMS,IAAOD;AACb,iBAAWE,KAAMV,EAAWS,CAAI;AAE9B,QAAAE,EAAW;AAAA,UACTF;AAAA,UACAC;AAAA,UACCV,EAAWS,CAAI,EAA8BC,CAAE;AAAA,UAChD;AAAA,UACA;AAAA,QAAA;AAAA,IAGN;AAIF,EAAAE,EAAU,MAAM;AACd,KAAM,YACJ,MAAMD,EAAW,eAAeV,CAAG;AAAA,EAEvC,GAAG,CAACA,CAAG,CAAC;AAGR,QAAMY,IAAsBC,EAAQ,MAAM;AACxC,QAAKf,EAAO,eAAe;AAE3B,aAAO,CAACgB,GAAgBC,MAAyB;AAC/C,YAAI,CAACjB,EAAO,eAAe,QAAS;AAEpC,cAAMkB,IAAmB;AAAA,UACvB,MAAM;AAAA,UACN,SAASF,aAAiB,QAAQA,EAAM,UAAU;AAAA,UAClD,OAAOA,aAAiB,QAAQA,EAAM,QAAQ;AAAA,UAC9C,SAAS;AAAA,YACP,gBAAgBC,EAAU,kBAAkB;AAAA,UAAA;AAAA,UAE9C,eAAeD;AAAA,UACf,WAAW,KAAK,IAAA;AAAA,QAAI,GAIhBG,IAAiBC,EAAcF,GAAkBlB,EAAO,cAAc,YAAY;AAExF,QAAAA,EAAO,cAAc,QAAQmB,CAAc;AAAA,MAC7C;AAAA,EACF,GAAG,CAACnB,EAAO,aAAa,CAAC;AACzB,SACE,gBAAAqB,EAACC,GAAA,EAAmB,OAAOhB,GACzB,UAAA,gBAAAe,EAACE,GAAA,EAAyB,OAAOhB,GAC/B,UAAA,gBAAAc,EAACG,GAAA,EAAsB,eAAexB,EAAO,eAC3C,UAAA,gBAAAqB,EAACI,GAAA,EAAc,mBAAmBC,GAAe,SAASZ,GACxD,UAAA,gBAAAO,EAACM,GAAA,EAAc,OAAAtB,GACb,UAAA,gBAAAgB,EAACO,GAAA,EAAe,QAAAzB,GAAgB,UAAAC,GAC9B,UAAA,gBAAAiB,EAACQ,GAAA,EAAgB,MAAMjB,GACrB,UAAA,gBAAAS;AAAA,IAACS;AAAA,IAAA;AAAA,MACC,KAAK9B,EAAO;AAAA,MACZ,SAASA,EAAO;AAAA,MAChB,OAAOA,EAAO;AAAA,MACd,aAAAQ;AAAA,MAEC,UAAAT;AAAA,IAAA;AAAA,EAAA,KAPmCG,CASxC,GACF,GACF,EAAA,CACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservabilityContext.js","sources":["../../../src/contexts/ObservabilityProvider/ObservabilityContext.ts"],"sourcesContent":["import { createContext } from 'react'\nimport type { ObservabilityHook } from '@/types/observability'\n\nexport interface ObservabilityContextValue {\n observability: ObservabilityHook | undefined\n}\n\nexport const ObservabilityContext = createContext<ObservabilityContextValue | undefined>(undefined)\n"],"names":["ObservabilityContext","createContext"],"mappings":";AAOO,MAAMA,IAAuBC,EAAqD,MAAS;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ObservabilityHook } from '../../types/observability';
|
|
3
|
+
export interface ObservabilityProviderProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
observability?: ObservabilityHook;
|
|
6
|
+
}
|
|
7
|
+
export declare const ObservabilityProvider: ({ children, observability }: ObservabilityProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as i } from "react";
|
|
3
|
+
import { ObservabilityContext as m } from "./ObservabilityContext.js";
|
|
4
|
+
const v = ({ children: o, observability: r }) => {
|
|
5
|
+
const t = i(() => ({ observability: r }), [r]);
|
|
6
|
+
return /* @__PURE__ */ e(m.Provider, { value: t, children: o });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
v as ObservabilityProvider
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=ObservabilityProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservabilityProvider.js","sources":["../../../src/contexts/ObservabilityProvider/ObservabilityProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { ObservabilityContext } from './ObservabilityContext'\nimport type { ObservabilityHook } from '@/types/observability'\n\nexport interface ObservabilityProviderProps {\n children: ReactNode\n observability?: ObservabilityHook\n}\n\nexport const ObservabilityProvider = ({ children, observability }: ObservabilityProviderProps) => {\n const value = useMemo(() => ({ observability }), [observability])\n\n return <ObservabilityContext.Provider value={value}>{children}</ObservabilityContext.Provider>\n}\n"],"names":["ObservabilityProvider","children","observability","value","useMemo","jsx","ObservabilityContext"],"mappings":";;;AAUO,MAAMA,IAAwB,CAAC,EAAE,UAAAC,GAAU,eAAAC,QAAgD;AAChG,QAAMC,IAAQC,EAAQ,OAAO,EAAE,eAAAF,MAAkB,CAACA,CAAa,CAAC;AAEhE,SAAO,gBAAAG,EAACC,EAAqB,UAArB,EAA8B,OAAAH,GAAe,UAAAF,EAAA,CAAS;AAChE;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./types/i18next.d.ts"
|
|
2
|
+
export { ObservabilityProvider } from './ObservabilityProvider';
|
|
3
|
+
export { useObservability } from './useObservability';
|
|
4
|
+
export { createObservabilityError } from './observabilityUtils';
|
|
5
|
+
export type { ObservabilityProviderProps } from './ObservabilityProvider';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ObservabilityError, ObservabilityErrorType } from '../../types/observability';
|
|
2
|
+
/**
|
|
3
|
+
* Converts SDK errors into structured ObservabilityError objects
|
|
4
|
+
*/
|
|
5
|
+
export declare function createObservabilityError(error: unknown, type?: ObservabilityErrorType): ObservabilityError | null;
|