@gusto/embedded-react-sdk 0.37.0-rc.2 → 0.37.0-rc.4
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/README.md +3 -0
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +8 -7
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +5 -4
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/Common/UI/DatePicker/DatePicker.js +88 -69
- package/dist/components/Common/UI/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/Common/UI/DatePicker/DatePickerTypes.d.ts +13 -0
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +7 -6
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +9 -8
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +7 -6
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +4 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +6 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +6 -6
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +4 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +7 -6
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +8 -7
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +6 -5
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +7 -6
- package/dist/components/Company/FederalTaxes/Actions.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +6 -5
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Actions.js +6 -5
- package/dist/components/Company/Industry/Actions.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +7 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Industry/Edit.js +11 -10
- package/dist/components/Company/Industry/Edit.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +3 -2
- package/dist/components/Company/Locations/LocationForm/Actions.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +4 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- 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/useLocationsList.js +4 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +4 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +60 -58
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +11 -10
- package/dist/components/Company/PaySchedule/_parts/Actions.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +40 -37
- package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.d.ts +1 -0
- package/dist/components/Company/PaySchedule/usePaySchedule.js +6 -5
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +6 -5
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +7 -6
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +6 -5
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +4 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +4 -4
- package/dist/components/Contractor/Address/useAddress.js +6 -5
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +3 -2
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +1 -1
- package/dist/components/Contractor/Profile/useContractorProfile.js +3 -2
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +1 -1
- package/dist/components/Employee/Compensation/List.js +6 -5
- package/dist/components/Employee/Compensation/List.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +3 -2
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +5 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +4 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +5 -4
- package/dist/components/Employee/EmployeeList/Actions.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +10 -10
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +4 -3
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/Actions.js +3 -2
- 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/useFederalTaxes.js +4 -3
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.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/BankAccountsList.js +4 -4
- package/dist/components/Employee/PaymentMethod/Split.js +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +6 -5
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/Actions.js +7 -6
- package/dist/components/Employee/Profile/Actions.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +5 -4
- package/dist/components/Employee/Profile/AdminPersonalDetails.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 +4 -3
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/StateTaxes/Actions.js +7 -6
- package/dist/components/Employee/StateTaxes/Actions.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +4 -3
- package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
- package/dist/components/Employee/Taxes/Actions.js +8 -7
- package/dist/components/Employee/Taxes/Actions.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +5 -4
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +4 -3
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +48 -48
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.js +15 -14
- package/dist/components/Payroll/Dismissal/DismissalFlowComponents.js.map +1 -1
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js +44 -46
- package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +3 -2
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js +4 -4
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +25 -23
- package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +11 -10
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +1 -0
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +3 -2
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +105 -106
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +54 -54
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +2 -1
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js +29 -27
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/index.d.ts +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.d.ts +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +60 -60
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollExecutionFlowContextual.js +22 -20
- package/dist/components/Payroll/PayrollFlow/PayrollExecutionFlowContextual.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +143 -143
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +44 -55
- package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
- package/dist/components/Payroll/helpers.d.ts +1 -0
- package/dist/components/Payroll/helpers.js +71 -69
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +3 -2
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.js +9 -8
- package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.js +12 -11
- package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.js +3 -2
- package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.js +8 -7
- package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.js +9 -8
- package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.js +13 -12
- package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/CompensationForm.js +4 -4
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.d.ts +4 -4
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.js +86 -89
- package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.js.map +1 -1
- package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/EmployeeDetailsForm.js +1 -1
- package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/WorkAddressForm.js +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +3 -2
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/i18n/en/Company.PaySchedule.json.js +6 -6
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +38 -34
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +62 -58
- package/dist/i18n/en/Payroll.PayrollOverview.json.js.map +1 -1
- package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js +8 -8
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +6 -1
- package/docs/reference/endpoint-inventory.json +9 -0
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as S } from "@tanstack/react-query";
|
|
3
3
|
import { useEmployeesGetSuspense as Y } from "@gusto/embedded-api/react-query/employeesGet";
|
|
4
4
|
import { useEmployeeEmploymentsGetTerminationsSuspense as q, invalidateAllEmployeeEmploymentsGetTerminations as I } from "@gusto/embedded-api/react-query/employeeEmploymentsGetTerminations";
|
|
@@ -8,7 +8,7 @@ import { usePayrollsCreateOffCycleMutation as G } from "@gusto/embedded-api/reac
|
|
|
8
8
|
import { usePaySchedulesGetUnprocessedTerminationPeriods as k, invalidateAllPaySchedulesGetUnprocessedTerminationPeriods as x } from "@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods";
|
|
9
9
|
import { invalidateAllPayrollsList as W } from "@gusto/embedded-api/react-query/payrollsList";
|
|
10
10
|
import { OffCycleReason as F } from "@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls";
|
|
11
|
-
import { RFCDate as
|
|
11
|
+
import { RFCDate as p } from "@gusto/embedded-api/types/rfcdate";
|
|
12
12
|
import { TerminateEmployeePresentation as H } from "./TerminateEmployeePresentation.js";
|
|
13
13
|
import { BaseComponent as j } from "../../../Base/Base.js";
|
|
14
14
|
import { useBase as Q } from "../../../Base/useBase.js";
|
|
@@ -16,93 +16,93 @@ import { componentEvents as n } from "../../../../shared/constants.js";
|
|
|
16
16
|
import { useComponentDictionary as V, useI18n as z } from "../../../../i18n/I18n.js";
|
|
17
17
|
import { firstLastName as J } from "../../../../helpers/formattedStrings.js";
|
|
18
18
|
function Te(e) {
|
|
19
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ y(j, { ...e, children: /* @__PURE__ */ y(K, { ...e, children: e.children }) });
|
|
20
20
|
}
|
|
21
|
-
const K = ({ employeeId: e, companyId:
|
|
22
|
-
V("Employee.Terminations.TerminateEmployee",
|
|
23
|
-
const c = S(), { onEvent: i, baseSubmitHandler:
|
|
24
|
-
data: { employee:
|
|
25
|
-
} = Y({ employeeId: e }), { data:
|
|
26
|
-
if (
|
|
21
|
+
const K = ({ employeeId: e, companyId: f, dictionary: D }) => {
|
|
22
|
+
V("Employee.Terminations.TerminateEmployee", D), z("Employee.Terminations.TerminateEmployee");
|
|
23
|
+
const c = S(), { onEvent: i, baseSubmitHandler: C } = Q(), {
|
|
24
|
+
data: { employee: u }
|
|
25
|
+
} = Y({ employeeId: e }), { data: r } = q({ employeeId: e });
|
|
26
|
+
if (u?.terminated && r.terminationList?.[0])
|
|
27
27
|
return i(n.EMPLOYEE_TERMINATION_VIEW_SUMMARY, {
|
|
28
28
|
employeeId: e,
|
|
29
|
-
effectiveDate:
|
|
30
|
-
termination:
|
|
29
|
+
effectiveDate: r.terminationList[0].effectiveDate,
|
|
30
|
+
termination: r.terminationList[0]
|
|
31
31
|
}), null;
|
|
32
|
-
const { mutateAsync:
|
|
33
|
-
{ companyId:
|
|
32
|
+
const { mutateAsync: O, isPending: A } = b(), { mutateAsync: L, isPending: h } = B(), { mutateAsync: N, isPending: M } = G(), { refetch: _ } = k(
|
|
33
|
+
{ companyId: f },
|
|
34
34
|
{ enabled: !1 }
|
|
35
|
-
),
|
|
36
|
-
first_name:
|
|
37
|
-
last_name:
|
|
38
|
-
}),
|
|
39
|
-
return /* @__PURE__ */
|
|
35
|
+
), R = J({
|
|
36
|
+
first_name: u?.firstName,
|
|
37
|
+
last_name: u?.lastName
|
|
38
|
+
}), s = r.terminationList?.[0];
|
|
39
|
+
return /* @__PURE__ */ y(
|
|
40
40
|
H,
|
|
41
41
|
{
|
|
42
|
-
employeeName:
|
|
43
|
-
existingTermination:
|
|
44
|
-
onSubmit: async (
|
|
45
|
-
const { lastDayOfWork:
|
|
46
|
-
await
|
|
47
|
-
const
|
|
42
|
+
employeeName: R,
|
|
43
|
+
existingTermination: s,
|
|
44
|
+
onSubmit: async (g) => {
|
|
45
|
+
const { lastDayOfWork: U, payrollOption: o } = g, m = U.toISOString().split("T")[0];
|
|
46
|
+
await C({ effectiveDate: m, payrollOption: o }, async () => {
|
|
47
|
+
const l = o === "dismissalPayroll", d = s ? await L({
|
|
48
48
|
request: {
|
|
49
49
|
employeeId: e,
|
|
50
50
|
requestBody: {
|
|
51
|
-
version:
|
|
52
|
-
effectiveDate:
|
|
53
|
-
runTerminationPayroll:
|
|
51
|
+
version: s.version,
|
|
52
|
+
effectiveDate: m,
|
|
53
|
+
runTerminationPayroll: l
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
}) : await
|
|
56
|
+
}) : await O({
|
|
57
57
|
request: {
|
|
58
58
|
employeeId: e,
|
|
59
59
|
requestBody: {
|
|
60
|
-
effectiveDate:
|
|
61
|
-
runTerminationPayroll:
|
|
60
|
+
effectiveDate: m,
|
|
61
|
+
runTerminationPayroll: l
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
await I(c);
|
|
66
66
|
let T;
|
|
67
|
-
if (
|
|
67
|
+
if (l)
|
|
68
68
|
try {
|
|
69
|
-
const { data:
|
|
69
|
+
const { data: E } = await _(), w = E?.unprocessedTerminationPayPeriodList?.filter(
|
|
70
70
|
(t) => t.employeeUuid === e
|
|
71
|
-
) ?? [],
|
|
72
|
-
for (const t of
|
|
71
|
+
) ?? [], a = [];
|
|
72
|
+
for (const t of w)
|
|
73
73
|
if (t.startDate && t.endDate) {
|
|
74
|
-
const
|
|
74
|
+
const P = await N({
|
|
75
75
|
request: {
|
|
76
|
-
companyId:
|
|
76
|
+
companyId: f,
|
|
77
77
|
requestBody: {
|
|
78
78
|
offCycle: !0,
|
|
79
79
|
offCycleReason: F.DismissedEmployee,
|
|
80
|
-
startDate: new
|
|
81
|
-
endDate: new
|
|
80
|
+
startDate: new p(t.startDate),
|
|
81
|
+
endDate: new p(t.endDate),
|
|
82
82
|
employeeUuids: [e],
|
|
83
|
-
checkDate: t.checkDate ? new
|
|
83
|
+
checkDate: t.checkDate ? new p(t.checkDate) : void 0
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
P.payrollUnprocessed && a.push(P.payrollUnprocessed);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
payrolls:
|
|
89
|
+
a.length > 0 && (T = a[0]?.payrollUuid ?? a[0]?.uuid, await W(c), await x(c), i(n.EMPLOYEE_TERMINATION_PAYROLL_CREATED, {
|
|
90
|
+
payrolls: a
|
|
91
91
|
}));
|
|
92
|
-
} catch (
|
|
92
|
+
} catch (E) {
|
|
93
93
|
i(n.EMPLOYEE_TERMINATION_PAYROLL_FAILED, {
|
|
94
|
-
error:
|
|
94
|
+
error: E,
|
|
95
95
|
employeeId: e
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
const v =
|
|
98
|
+
const v = s ? n.EMPLOYEE_TERMINATION_UPDATED : n.EMPLOYEE_TERMINATION_CREATED;
|
|
99
99
|
i(v, {
|
|
100
100
|
termination: d.termination,
|
|
101
101
|
payrollOption: o,
|
|
102
|
-
runTerminationPayroll:
|
|
102
|
+
runTerminationPayroll: l
|
|
103
103
|
}), i(n.EMPLOYEE_TERMINATION_DONE, {
|
|
104
104
|
employeeId: e,
|
|
105
|
-
effectiveDate:
|
|
105
|
+
effectiveDate: m,
|
|
106
106
|
payrollOption: o,
|
|
107
107
|
payrollUuid: T,
|
|
108
108
|
termination: d.termination,
|
|
@@ -113,7 +113,7 @@ const K = ({ employeeId: e, companyId: p, dictionary: P }) => {
|
|
|
113
113
|
onCancel: () => {
|
|
114
114
|
i(n.CANCEL);
|
|
115
115
|
},
|
|
116
|
-
isLoading:
|
|
116
|
+
isLoading: A || h || M
|
|
117
117
|
}
|
|
118
118
|
);
|
|
119
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminateEmployee.js","sources":["../../../../../src/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.tsx"],"sourcesContent":["import { useQueryClient } from '@tanstack/react-query'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n useEmployeeEmploymentsGetTerminationsSuspense,\n invalidateAllEmployeeEmploymentsGetTerminations,\n} from '@gusto/embedded-api/react-query/employeeEmploymentsGetTerminations'\nimport { useEmployeeEmploymentsCreateTerminationMutation } from '@gusto/embedded-api/react-query/employeeEmploymentsCreateTermination'\nimport { useEmployeeEmploymentsUpdateTerminationMutation } from '@gusto/embedded-api/react-query/employeeEmploymentsUpdateTermination'\nimport { usePayrollsCreateOffCycleMutation } from '@gusto/embedded-api/react-query/payrollsCreateOffCycle'\nimport {\n usePaySchedulesGetUnprocessedTerminationPeriods,\n invalidateAllPaySchedulesGetUnprocessedTerminationPeriods,\n} from '@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods'\nimport { invalidateAllPayrollsList } from '@gusto/embedded-api/react-query/payrollsList'\nimport { OffCycleReason } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport type { PayrollOption } from '../types'\nimport { TerminateEmployeePresentation } from './TerminateEmployeePresentation'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { componentEvents } from '@/shared/constants'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\nexport interface TerminateEmployeeProps extends BaseComponentInterface<'Employee.Terminations.TerminateEmployee'> {\n employeeId: string\n companyId: string\n}\n\nexport interface TerminateEmployeeFormData {\n lastDayOfWork: Date\n payrollOption: PayrollOption\n}\n\nexport function TerminateEmployee(props: TerminateEmployeeProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, companyId, dictionary }: TerminateEmployeeProps) => {\n useComponentDictionary('Employee.Terminations.TerminateEmployee', dictionary)\n useI18n('Employee.Terminations.TerminateEmployee')\n\n const queryClient = useQueryClient()\n const { onEvent, baseSubmitHandler } = useBase()\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n const { data: terminationsData } = useEmployeeEmploymentsGetTerminationsSuspense({ employeeId })\n\n // If employee is already terminated, redirect to summary with existing termination data\n // Don't pass payrollOption to avoid showing the success alert\n if (employee?.terminated && terminationsData.terminationList?.[0]) {\n onEvent(componentEvents.EMPLOYEE_TERMINATION_VIEW_SUMMARY, {\n employeeId,\n effectiveDate: terminationsData.terminationList[0].effectiveDate!,\n termination: terminationsData.terminationList[0],\n })\n return null\n }\n\n const { mutateAsync: createTermination, isPending: isCreatingTermination } =\n useEmployeeEmploymentsCreateTerminationMutation()\n\n const { mutateAsync: updateTermination, isPending: isUpdatingTermination } =\n useEmployeeEmploymentsUpdateTerminationMutation()\n\n const { mutateAsync: createOffCyclePayroll, isPending: isCreatingPayroll } =\n usePayrollsCreateOffCycleMutation()\n\n const { refetch: fetchTerminationPeriods } = usePaySchedulesGetUnprocessedTerminationPeriods(\n { companyId },\n { enabled: false },\n )\n\n const employeeName = firstLastName({\n first_name: employee?.firstName,\n last_name: employee?.lastName,\n })\n\n const existingTermination = terminationsData.terminationList?.[0]\n\n const handleSubmit = async (formData: TerminateEmployeeFormData) => {\n const { lastDayOfWork, payrollOption } = formData\n const effectiveDate = lastDayOfWork.toISOString().split('T')[0]!\n\n await baseSubmitHandler({ effectiveDate, payrollOption }, async () => {\n const runTerminationPayroll = payrollOption === 'dismissalPayroll'\n\n const result = existingTermination\n ? await updateTermination({\n request: {\n employeeId,\n requestBody: {\n version: existingTermination.version!,\n effectiveDate,\n runTerminationPayroll,\n },\n },\n })\n : await createTermination({\n request: {\n employeeId,\n requestBody: {\n effectiveDate,\n runTerminationPayroll,\n },\n },\n })\n\n await invalidateAllEmployeeEmploymentsGetTerminations(queryClient)\n\n let firstPayrollUuid: string | undefined\n\n if (runTerminationPayroll) {\n try {\n const { data: terminationPeriodsData } = await fetchTerminationPeriods()\n\n const employeePeriods =\n terminationPeriodsData?.unprocessedTerminationPayPeriodList?.filter(\n period => period.employeeUuid === employeeId,\n ) ?? []\n\n const createdPayrolls = []\n\n for (const terminationPeriod of employeePeriods) {\n if (terminationPeriod.startDate && terminationPeriod.endDate) {\n const payrollResult = await createOffCyclePayroll({\n request: {\n companyId,\n requestBody: {\n offCycle: true,\n offCycleReason: OffCycleReason.DismissedEmployee,\n startDate: new RFCDate(terminationPeriod.startDate),\n endDate: new RFCDate(terminationPeriod.endDate),\n employeeUuids: [employeeId],\n checkDate: terminationPeriod.checkDate\n ? new RFCDate(terminationPeriod.checkDate)\n : undefined,\n },\n },\n })\n\n createdPayrolls.push(payrollResult.payrollUnprocessed)\n }\n }\n\n if (createdPayrolls.length > 0) {\n firstPayrollUuid = createdPayrolls[0]?.payrollUuid\n\n await invalidateAllPayrollsList(queryClient)\n await invalidateAllPaySchedulesGetUnprocessedTerminationPeriods(queryClient)\n\n onEvent(componentEvents.EMPLOYEE_TERMINATION_PAYROLL_CREATED, {\n payrolls: createdPayrolls,\n })\n }\n } catch (payrollError) {\n onEvent(componentEvents.EMPLOYEE_TERMINATION_PAYROLL_FAILED, {\n error: payrollError,\n employeeId,\n })\n }\n }\n\n const eventType = existingTermination\n ? componentEvents.EMPLOYEE_TERMINATION_UPDATED\n : componentEvents.EMPLOYEE_TERMINATION_CREATED\n\n onEvent(eventType, {\n termination: result.termination,\n payrollOption,\n runTerminationPayroll,\n })\n\n onEvent(componentEvents.EMPLOYEE_TERMINATION_DONE, {\n employeeId,\n effectiveDate,\n payrollOption,\n payrollUuid: firstPayrollUuid,\n termination: result.termination,\n ...(payrollOption === 'anotherWay' && { manualHandling: true }),\n })\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n const isPending = isCreatingTermination || isUpdatingTermination || isCreatingPayroll\n\n return (\n <TerminateEmployeePresentation\n employeeName={employeeName}\n existingTermination={existingTermination}\n onSubmit={handleSubmit}\n onCancel={handleCancel}\n isLoading={isPending}\n />\n )\n}\n"],"names":["TerminateEmployee","props","jsx","BaseComponent","Root","employeeId","companyId","dictionary","useComponentDictionary","useI18n","queryClient","useQueryClient","onEvent","baseSubmitHandler","useBase","employee","useEmployeesGetSuspense","terminationsData","useEmployeeEmploymentsGetTerminationsSuspense","componentEvents","createTermination","isCreatingTermination","useEmployeeEmploymentsCreateTerminationMutation","updateTermination","isUpdatingTermination","useEmployeeEmploymentsUpdateTerminationMutation","createOffCyclePayroll","isCreatingPayroll","usePayrollsCreateOffCycleMutation","fetchTerminationPeriods","usePaySchedulesGetUnprocessedTerminationPeriods","employeeName","firstLastName","existingTermination","TerminateEmployeePresentation","formData","lastDayOfWork","payrollOption","effectiveDate","runTerminationPayroll","result","invalidateAllEmployeeEmploymentsGetTerminations","firstPayrollUuid","terminationPeriodsData","employeePeriods","period","createdPayrolls","terminationPeriod","payrollResult","OffCycleReason","RFCDate","invalidateAllPayrollsList","invalidateAllPaySchedulesGetUnprocessedTerminationPeriods","payrollError","eventType"],"mappings":";;;;;;;;;;;;;;;;;AAmCO,SAASA,GAAkBC,GAA+B;AAC/D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,G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B,KAAKE,EAAc,kBAAkB;AAAA,gBACvD;AAGF,cAAIF,EAAgB,SAAS,MAC3BJ,IAAmBI,EAAgB,CAAC,GAAG,aAEvC,MAAMK,EAA0BzC,CAAW,GAC3C,MAAM0C,EAA0D1C,CAAW,GAE3EE,EAAQO,EAAgB,sCAAsC;AAAA,gBAC5D,UAAU2B;AAAA,cAAA,CACX;AAAA,YAEL,SAASO,GAAc;AACrB,cAAAzC,EAAQO,EAAgB,qCAAqC;AAAA,gBAC3D,OAAOkC;AAAA,gBACP,YAAAhD;AAAA,cAAA,CACD;AAAA,YACH;AAGF,gBAAMiD,IAAYrB,IACdd,EAAgB,+BAChBA,EAAgB;AAEpB,UAAAP,EAAQ0C,GAAW;AAAA,YACjB,aAAad,EAAO;AAAA,YACpB,eAAAH;AAAA,YACA,uBAAAE;AAAA,UAAA,CACD,GAED3B,EAAQO,EAAgB,2BAA2B;AAAA,YACjD,YAAAd;AAAA,YACA,eAAAiC;AAAA,YACA,eAAAD;AAAA,YACA,aAAaK;AAAA,YACb,aAAaF,EAAO;AAAA,YACpB,GAAIH,MAAkB,gBAAgB,EAAE,gBAAgB,GAAA;AAAA,UAAK,CAC9D;AAAA,QACH,CAAC;AAAA,MACH;AAAA,MAaI,UAXiB,MAAM;AACzB,QAAAzB,EAAQO,EAAgB,MAAM;AAAA,MAChC;AAAA,MAUI,WARcE,KAAyBG,KAAyBG;AAAA,IAQrD;AAAA,EAAA;AAGjB;"}
|
|
1
|
+
{"version":3,"file":"TerminateEmployee.js","sources":["../../../../../src/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.tsx"],"sourcesContent":["import { useQueryClient } from '@tanstack/react-query'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n useEmployeeEmploymentsGetTerminationsSuspense,\n invalidateAllEmployeeEmploymentsGetTerminations,\n} from '@gusto/embedded-api/react-query/employeeEmploymentsGetTerminations'\nimport { useEmployeeEmploymentsCreateTerminationMutation } from '@gusto/embedded-api/react-query/employeeEmploymentsCreateTermination'\nimport { useEmployeeEmploymentsUpdateTerminationMutation } from '@gusto/embedded-api/react-query/employeeEmploymentsUpdateTermination'\nimport { usePayrollsCreateOffCycleMutation } from '@gusto/embedded-api/react-query/payrollsCreateOffCycle'\nimport {\n usePaySchedulesGetUnprocessedTerminationPeriods,\n invalidateAllPaySchedulesGetUnprocessedTerminationPeriods,\n} from '@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods'\nimport { invalidateAllPayrollsList } from '@gusto/embedded-api/react-query/payrollsList'\nimport { OffCycleReason } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport type { PayrollOption } from '../types'\nimport { TerminateEmployeePresentation } from './TerminateEmployeePresentation'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { componentEvents } from '@/shared/constants'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\nexport interface TerminateEmployeeProps extends BaseComponentInterface<'Employee.Terminations.TerminateEmployee'> {\n employeeId: string\n companyId: string\n}\n\nexport interface TerminateEmployeeFormData {\n lastDayOfWork: Date\n payrollOption: PayrollOption\n}\n\nexport function TerminateEmployee(props: TerminateEmployeeProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ employeeId, companyId, dictionary }: TerminateEmployeeProps) => {\n useComponentDictionary('Employee.Terminations.TerminateEmployee', dictionary)\n useI18n('Employee.Terminations.TerminateEmployee')\n\n const queryClient = useQueryClient()\n const { onEvent, baseSubmitHandler } = useBase()\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n const { data: terminationsData } = useEmployeeEmploymentsGetTerminationsSuspense({ employeeId })\n\n // If employee is already terminated, redirect to summary with existing termination data\n // Don't pass payrollOption to avoid showing the success alert\n if (employee?.terminated && terminationsData.terminationList?.[0]) {\n onEvent(componentEvents.EMPLOYEE_TERMINATION_VIEW_SUMMARY, {\n employeeId,\n effectiveDate: terminationsData.terminationList[0].effectiveDate!,\n termination: terminationsData.terminationList[0],\n })\n return null\n }\n\n const { mutateAsync: createTermination, isPending: isCreatingTermination } =\n useEmployeeEmploymentsCreateTerminationMutation()\n\n const { mutateAsync: updateTermination, isPending: isUpdatingTermination } =\n useEmployeeEmploymentsUpdateTerminationMutation()\n\n const { mutateAsync: createOffCyclePayroll, isPending: isCreatingPayroll } =\n usePayrollsCreateOffCycleMutation()\n\n const { refetch: fetchTerminationPeriods } = usePaySchedulesGetUnprocessedTerminationPeriods(\n { companyId },\n { enabled: false },\n )\n\n const employeeName = firstLastName({\n first_name: employee?.firstName,\n last_name: employee?.lastName,\n })\n\n const existingTermination = terminationsData.terminationList?.[0]\n\n const handleSubmit = async (formData: TerminateEmployeeFormData) => {\n const { lastDayOfWork, payrollOption } = formData\n const effectiveDate = lastDayOfWork.toISOString().split('T')[0]!\n\n await baseSubmitHandler({ effectiveDate, payrollOption }, async () => {\n const runTerminationPayroll = payrollOption === 'dismissalPayroll'\n\n const result = existingTermination\n ? await updateTermination({\n request: {\n employeeId,\n requestBody: {\n version: existingTermination.version!,\n effectiveDate,\n runTerminationPayroll,\n },\n },\n })\n : await createTermination({\n request: {\n employeeId,\n requestBody: {\n effectiveDate,\n runTerminationPayroll,\n },\n },\n })\n\n await invalidateAllEmployeeEmploymentsGetTerminations(queryClient)\n\n let firstPayrollUuid: string | undefined\n\n if (runTerminationPayroll) {\n try {\n const { data: terminationPeriodsData } = await fetchTerminationPeriods()\n\n const employeePeriods =\n terminationPeriodsData?.unprocessedTerminationPayPeriodList?.filter(\n period => period.employeeUuid === employeeId,\n ) ?? []\n\n const createdPayrolls = []\n\n for (const terminationPeriod of employeePeriods) {\n if (terminationPeriod.startDate && terminationPeriod.endDate) {\n const payrollResult = await createOffCyclePayroll({\n request: {\n companyId,\n requestBody: {\n offCycle: true,\n offCycleReason: OffCycleReason.DismissedEmployee,\n startDate: new RFCDate(terminationPeriod.startDate),\n endDate: new RFCDate(terminationPeriod.endDate),\n employeeUuids: [employeeId],\n checkDate: terminationPeriod.checkDate\n ? new RFCDate(terminationPeriod.checkDate)\n : undefined,\n },\n },\n })\n\n if (payrollResult.payrollUnprocessed) {\n createdPayrolls.push(payrollResult.payrollUnprocessed)\n }\n }\n }\n\n if (createdPayrolls.length > 0) {\n firstPayrollUuid = createdPayrolls[0]?.payrollUuid ?? createdPayrolls[0]?.uuid\n\n await invalidateAllPayrollsList(queryClient)\n await invalidateAllPaySchedulesGetUnprocessedTerminationPeriods(queryClient)\n\n onEvent(componentEvents.EMPLOYEE_TERMINATION_PAYROLL_CREATED, {\n payrolls: createdPayrolls,\n })\n }\n } catch (payrollError) {\n onEvent(componentEvents.EMPLOYEE_TERMINATION_PAYROLL_FAILED, {\n error: payrollError,\n employeeId,\n })\n }\n }\n\n const eventType = existingTermination\n ? componentEvents.EMPLOYEE_TERMINATION_UPDATED\n : componentEvents.EMPLOYEE_TERMINATION_CREATED\n\n onEvent(eventType, {\n termination: result.termination,\n payrollOption,\n runTerminationPayroll,\n })\n\n onEvent(componentEvents.EMPLOYEE_TERMINATION_DONE, {\n employeeId,\n effectiveDate,\n payrollOption,\n payrollUuid: firstPayrollUuid,\n termination: result.termination,\n ...(payrollOption === 'anotherWay' && { manualHandling: true }),\n })\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n const isPending = isCreatingTermination || isUpdatingTermination || isCreatingPayroll\n\n return (\n <TerminateEmployeePresentation\n employeeName={employeeName}\n existingTermination={existingTermination}\n onSubmit={handleSubmit}\n onCancel={handleCancel}\n isLoading={isPending}\n />\n )\n}\n"],"names":["TerminateEmployee","props","jsx","BaseComponent","Root","employeeId","companyId","dictionary","useComponentDictionary","useI18n","queryClient","useQueryClient","onEvent","baseSubmitHandler","useBase","employee","useEmployeesGetSuspense","terminationsData","useEmployeeEmploymentsGetTerminationsSuspense","componentEvents","createTermination","isCreatingTermination","useEmployeeEmploymentsCreateTerminationMutation","updateTermination","isUpdatingTermination","useEmployeeEmploymentsUpdateTerminationMutation","createOffCyclePayroll","isCreatingPayroll","usePayrollsCreateOffCycleMutation","fetchTerminationPeriods","usePaySchedulesGetUnprocessedTerminationPeriods","employeeName","firstLastName","existingTermination","TerminateEmployeePresentation","formData","lastDayOfWork","payrollOption","effectiveDate","runTerminationPayroll","result","invalidateAllEmployeeEmploymentsGetTerminations","firstPayrollUuid","terminationPeriodsData","employeePeriods","period","createdPayrolls","terminationPeriod","payrollResult","OffCycleReason","RFCDate","invalidateAllPayrollsList","invalidateAllPaySchedulesGetUnprocessedTerminationPeriods","payrollError","eventType"],"mappings":";;;;;;;;;;;;;;;;;AAmCO,SAASA,GAAkBC,GAA+B;AAC/D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,YAAAC,GAAY,WAAAC,GAAW,YAAAC,QAAyC;AAC9E,EAAAC,EAAuB,2CAA2CD,CAAU,GAC5EE,EAAQ,yCAAyC;AAEjD,QAAMC,IAAcC,EAAA,GACd,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GAEjC;AAAA,IACJ,MAAM,EAAE,UAAAC,EAAA;AAAA,EAAS,IACfC,EAAwB,EAAE,YAAAX,GAAY,GAEpC,EAAE,MAAMY,EAAA,IAAqBC,EAA8C,EAAE,YAAAb,GAAY;AAI/F,MAAIU,GAAU,cAAcE,EAAiB,kBAAkB,CAAC;AAC9D,WAAAL,EAAQO,EAAgB,mCAAmC;AAAA,MACzD,YAAAd;AAAA,MACA,eAAeY,EAAiB,gBAAgB,CAAC,EAAE;AAAA,MACnD,aAAaA,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ACA,eAAAiC;AAAA,YACA,eAAAD;AAAA,YACA,aAAaK;AAAA,YACb,aAAaF,EAAO;AAAA,YACpB,GAAIH,MAAkB,gBAAgB,EAAE,gBAAgB,GAAA;AAAA,UAAK,CAC9D;AAAA,QACH,CAAC;AAAA,MACH;AAAA,MAaI,UAXiB,MAAM;AACzB,QAAAzB,EAAQO,EAAgB,MAAM;AAAA,MAChC;AAAA,MAUI,WARcE,KAAyBG,KAAyBG;AAAA,IAQrD;AAAA,EAAA;AAGjB;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { usePayrollsGetSuspense as
|
|
4
|
-
import { PayrollExecutionFlow as
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as u } from "react";
|
|
3
|
+
import { usePayrollsGetSuspense as d } from "@gusto/embedded-api/react-query/payrollsGet";
|
|
4
|
+
import { PayrollExecutionFlow as p } from "../PayrollExecutionFlow/PayrollExecutionFlow.js";
|
|
5
5
|
import { DismissalPayPeriodSelection as y } from "./DismissalPayPeriodSelection/DismissalPayPeriodSelection.js";
|
|
6
6
|
import { useFlow as a } from "../../Flow/useFlow.js";
|
|
7
7
|
import { ensureRequired as s } from "../../../helpers/ensureRequired.js";
|
|
8
|
-
import { BaseComponent as
|
|
8
|
+
import { BaseComponent as P } from "../../Base/Base.js";
|
|
9
9
|
function h() {
|
|
10
10
|
const { companyId: o, employeeId: e, onEvent: r } = a();
|
|
11
|
-
return /* @__PURE__ */
|
|
11
|
+
return /* @__PURE__ */ t(
|
|
12
12
|
y,
|
|
13
13
|
{
|
|
14
14
|
companyId: s(o),
|
|
@@ -18,9 +18,9 @@ function h() {
|
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
function w() {
|
|
21
|
-
const { companyId: o, payrollUuid: e, onEvent: r, breadcrumbs: n } = a(),
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
|
|
21
|
+
const { companyId: o, payrollUuid: e, onEvent: r, breadcrumbs: n } = a(), i = n?.payPeriodSelection?.[0], m = u(() => i ? [i] : void 0, [i]), l = s(o), c = s(e);
|
|
22
|
+
return /* @__PURE__ */ t(P, { onEvent: r, children: /* @__PURE__ */ t(
|
|
23
|
+
f,
|
|
24
24
|
{
|
|
25
25
|
companyId: l,
|
|
26
26
|
payrollId: c,
|
|
@@ -29,18 +29,19 @@ function w() {
|
|
|
29
29
|
}
|
|
30
30
|
) });
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function f({
|
|
33
33
|
companyId: o,
|
|
34
34
|
payrollId: e,
|
|
35
35
|
...r
|
|
36
36
|
}) {
|
|
37
|
-
const { data: n } =
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
-
|
|
37
|
+
const { data: n } = d({ companyId: o, payrollId: e }), i = n.payrollShow?.payPeriod;
|
|
38
|
+
return /* @__PURE__ */ t(
|
|
39
|
+
p,
|
|
40
40
|
{
|
|
41
41
|
companyId: o,
|
|
42
42
|
payrollId: e,
|
|
43
|
-
initialPayPeriod:
|
|
43
|
+
initialPayPeriod: i,
|
|
44
|
+
isDismissalPayroll: !0,
|
|
44
45
|
...r
|
|
45
46
|
}
|
|
46
47
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DismissalFlowComponents.js","sources":["../../../../src/components/Payroll/Dismissal/DismissalFlowComponents.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport {\n PayrollExecutionFlow,\n type PayrollExecutionFlowProps,\n} from '../PayrollExecutionFlow/PayrollExecutionFlow'\nimport { DismissalPayPeriodSelection } from './DismissalPayPeriodSelection/DismissalPayPeriodSelection'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { EventType } from '@/shared/constants'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { BaseComponent } from '@/components/Base/Base'\n\nexport interface DismissalFlowContextInterface extends FlowContextInterface {\n companyId: string\n employeeId?: string\n payrollUuid?: string\n}\n\nexport interface DismissalFlowProps {\n companyId: string\n employeeId?: string\n onEvent: OnEventType<EventType, unknown>\n payrollId?: string\n}\n\nexport function DismissalPayPeriodSelectionContextual() {\n const { companyId, employeeId, onEvent } = useFlow<DismissalFlowContextInterface>()\n return (\n <DismissalPayPeriodSelection\n companyId={ensureRequired(companyId)}\n employeeId={employeeId}\n onEvent={onEvent}\n />\n )\n}\n\nexport function DismissalExecutionContextual() {\n const { companyId, payrollUuid, onEvent, breadcrumbs } = useFlow<DismissalFlowContextInterface>()\n\n const payPeriodSelectionBreadcrumb = breadcrumbs?.['payPeriodSelection']?.[0]\n const prefixBreadcrumbs = useMemo(() => {\n return payPeriodSelectionBreadcrumb ? [payPeriodSelectionBreadcrumb] : undefined\n }, [payPeriodSelectionBreadcrumb])\n\n const resolvedCompanyId = ensureRequired(companyId)\n const resolvedPayrollId = ensureRequired(payrollUuid)\n\n return (\n <BaseComponent onEvent={onEvent}>\n <DismissalExecutionWithData\n companyId={resolvedCompanyId}\n payrollId={resolvedPayrollId}\n onEvent={onEvent}\n prefixBreadcrumbs={prefixBreadcrumbs}\n />\n </BaseComponent>\n )\n}\n\ntype DismissalExecutionWithDataProps = Pick<\n PayrollExecutionFlowProps,\n 'companyId' | 'payrollId' | 'onEvent' | 'prefixBreadcrumbs'\n>\n\nfunction DismissalExecutionWithData({\n companyId,\n payrollId,\n ...rest\n}: DismissalExecutionWithDataProps) {\n const { data } = usePayrollsGetSuspense({ companyId, payrollId })\n const initialPayPeriod = data.payrollShow?.payPeriod\n\n return (\n <PayrollExecutionFlow\n companyId={companyId}\n payrollId={payrollId}\n initialPayPeriod={initialPayPeriod}\n {...rest}\n />\n )\n}\n"],"names":["DismissalPayPeriodSelectionContextual","companyId","employeeId","onEvent","useFlow","jsx","DismissalPayPeriodSelection","ensureRequired","DismissalExecutionContextual","payrollUuid","breadcrumbs","payPeriodSelectionBreadcrumb","prefixBreadcrumbs","useMemo","resolvedCompanyId","resolvedPayrollId","BaseComponent","DismissalExecutionWithData","payrollId","rest","data","usePayrollsGetSuspense","initialPayPeriod","PayrollExecutionFlow"],"mappings":";;;;;;;;AA0BO,SAASA,IAAwC;AACtD,QAAM,EAAE,WAAAC,GAAW,YAAAC,GAAY,SAAAC,EAAA,IAAYC,EAAA;AAC3C,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAeN,CAAS;AAAA,MACnC,YAAAC;AAAA,MACA,SAAAC;AAAA,IAAA;AAAA,EAAA;AAGN;AAEO,SAASK,IAA+B;AAC7C,QAAM,EAAE,WAAAP,GAAW,aAAAQ,GAAa,SAAAN,GAAS,aAAAO,EAAA,IAAgBN,EAAA,GAEnDO,IAA+BD,GAAc,qBAAwB,CAAC,GACtEE,IAAoBC,EAAQ,MACzBF,IAA+B,CAACA,CAA4B,IAAI,QACtE,CAACA,CAA4B,CAAC,GAE3BG,IAAoBP,EAAeN,CAAS,GAC5Cc,IAAoBR,EAAeE,CAAW;AAEpD,SACE,gBAAAJ,EAACW,KAAc,SAAAb,GACb,UAAA,gBAAAE;AAAA,IAACY;AAAA,IAAA;AAAA,MACC,WAAWH;AAAA,MACX,WAAWC;AAAA,MACX,SAAAZ;AAAA,MACA,mBAAAS;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAOA,SAASK,EAA2B;AAAA,EAClC,WAAAhB;AAAA,EACA,WAAAiB;AAAA,EACA,GAAGC;AACL,GAAoC;AAClC,QAAM,EAAE,MAAAC,EAAA,IAASC,EAAuB,EAAE,WAAApB,GAAW,WAAAiB,GAAW,GAC1DI,IAAmBF,EAAK,aAAa;AAE3C,SACE,gBAAAf;AAAA,IAACkB;AAAA,IAAA;AAAA,MACC,WAAAtB;AAAA,MACA,WAAAiB;AAAA,MACA,kBAAAI;AAAA,
|
|
1
|
+
{"version":3,"file":"DismissalFlowComponents.js","sources":["../../../../src/components/Payroll/Dismissal/DismissalFlowComponents.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport {\n PayrollExecutionFlow,\n type PayrollExecutionFlowProps,\n} from '../PayrollExecutionFlow/PayrollExecutionFlow'\nimport { DismissalPayPeriodSelection } from './DismissalPayPeriodSelection/DismissalPayPeriodSelection'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport type { EventType } from '@/shared/constants'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { BaseComponent } from '@/components/Base/Base'\n\nexport interface DismissalFlowContextInterface extends FlowContextInterface {\n companyId: string\n employeeId?: string\n payrollUuid?: string\n}\n\nexport interface DismissalFlowProps {\n companyId: string\n employeeId?: string\n onEvent: OnEventType<EventType, unknown>\n payrollId?: string\n}\n\nexport function DismissalPayPeriodSelectionContextual() {\n const { companyId, employeeId, onEvent } = useFlow<DismissalFlowContextInterface>()\n return (\n <DismissalPayPeriodSelection\n companyId={ensureRequired(companyId)}\n employeeId={employeeId}\n onEvent={onEvent}\n />\n )\n}\n\nexport function DismissalExecutionContextual() {\n const { companyId, payrollUuid, onEvent, breadcrumbs } = useFlow<DismissalFlowContextInterface>()\n\n const payPeriodSelectionBreadcrumb = breadcrumbs?.['payPeriodSelection']?.[0]\n const prefixBreadcrumbs = useMemo(() => {\n return payPeriodSelectionBreadcrumb ? [payPeriodSelectionBreadcrumb] : undefined\n }, [payPeriodSelectionBreadcrumb])\n\n const resolvedCompanyId = ensureRequired(companyId)\n const resolvedPayrollId = ensureRequired(payrollUuid)\n\n return (\n <BaseComponent onEvent={onEvent}>\n <DismissalExecutionWithData\n companyId={resolvedCompanyId}\n payrollId={resolvedPayrollId}\n onEvent={onEvent}\n prefixBreadcrumbs={prefixBreadcrumbs}\n />\n </BaseComponent>\n )\n}\n\ntype DismissalExecutionWithDataProps = Pick<\n PayrollExecutionFlowProps,\n 'companyId' | 'payrollId' | 'onEvent' | 'prefixBreadcrumbs'\n>\n\nfunction DismissalExecutionWithData({\n companyId,\n payrollId,\n ...rest\n}: DismissalExecutionWithDataProps) {\n const { data } = usePayrollsGetSuspense({ companyId, payrollId })\n const initialPayPeriod = data.payrollShow?.payPeriod\n\n return (\n <PayrollExecutionFlow\n companyId={companyId}\n payrollId={payrollId}\n initialPayPeriod={initialPayPeriod}\n isDismissalPayroll\n {...rest}\n />\n )\n}\n"],"names":["DismissalPayPeriodSelectionContextual","companyId","employeeId","onEvent","useFlow","jsx","DismissalPayPeriodSelection","ensureRequired","DismissalExecutionContextual","payrollUuid","breadcrumbs","payPeriodSelectionBreadcrumb","prefixBreadcrumbs","useMemo","resolvedCompanyId","resolvedPayrollId","BaseComponent","DismissalExecutionWithData","payrollId","rest","data","usePayrollsGetSuspense","initialPayPeriod","PayrollExecutionFlow"],"mappings":";;;;;;;;AA0BO,SAASA,IAAwC;AACtD,QAAM,EAAE,WAAAC,GAAW,YAAAC,GAAY,SAAAC,EAAA,IAAYC,EAAA;AAC3C,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAeN,CAAS;AAAA,MACnC,YAAAC;AAAA,MACA,SAAAC;AAAA,IAAA;AAAA,EAAA;AAGN;AAEO,SAASK,IAA+B;AAC7C,QAAM,EAAE,WAAAP,GAAW,aAAAQ,GAAa,SAAAN,GAAS,aAAAO,EAAA,IAAgBN,EAAA,GAEnDO,IAA+BD,GAAc,qBAAwB,CAAC,GACtEE,IAAoBC,EAAQ,MACzBF,IAA+B,CAACA,CAA4B,IAAI,QACtE,CAACA,CAA4B,CAAC,GAE3BG,IAAoBP,EAAeN,CAAS,GAC5Cc,IAAoBR,EAAeE,CAAW;AAEpD,SACE,gBAAAJ,EAACW,KAAc,SAAAb,GACb,UAAA,gBAAAE;AAAA,IAACY;AAAA,IAAA;AAAA,MACC,WAAWH;AAAA,MACX,WAAWC;AAAA,MACX,SAAAZ;AAAA,MACA,mBAAAS;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAOA,SAASK,EAA2B;AAAA,EAClC,WAAAhB;AAAA,EACA,WAAAiB;AAAA,EACA,GAAGC;AACL,GAAoC;AAClC,QAAM,EAAE,MAAAC,EAAA,IAASC,EAAuB,EAAE,WAAApB,GAAW,WAAAiB,GAAW,GAC1DI,IAAmBF,EAAK,aAAa;AAE3C,SACE,gBAAAf;AAAA,IAACkB;AAAA,IAAA;AAAA,MACC,WAAAtB;AAAA,MACA,WAAAiB;AAAA,MACA,kBAAAI;AAAA,MACA,oBAAkB;AAAA,MACjB,GAAGH;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js
CHANGED
|
@@ -1,73 +1,71 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense as
|
|
4
|
-
import { usePayrollsCreateOffCycleMutation as
|
|
5
|
-
import { OffCycleReason as
|
|
6
|
-
import { RFCDate as
|
|
7
|
-
import { useTranslation as
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as A, useMemo as y, useState as O } from "react";
|
|
3
|
+
import { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense as b } from "@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods";
|
|
4
|
+
import { usePayrollsCreateOffCycleMutation as g } from "@gusto/embedded-api/react-query/payrollsCreateOffCycle";
|
|
5
|
+
import { OffCycleReason as L } from "@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls";
|
|
6
|
+
import { RFCDate as D } from "@gusto/embedded-api/types/rfcdate";
|
|
7
|
+
import { useTranslation as T } from "react-i18next";
|
|
8
8
|
import { DismissalPayPeriodSelectionPresentation as K } from "./DismissalPayPeriodSelectionPresentation.js";
|
|
9
|
-
import { BaseComponent as
|
|
10
|
-
import { useBase as
|
|
11
|
-
import { componentEvents as
|
|
12
|
-
import { SDKInternalError as
|
|
13
|
-
import { useComponentDictionary as
|
|
14
|
-
import { formatPayPeriodRange as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return /* @__PURE__ */ f($, { ...t, children: /* @__PURE__ */ f(I, { ...t }) });
|
|
9
|
+
import { BaseComponent as M } from "../../../Base/Base.js";
|
|
10
|
+
import { useBase as $ } from "../../../Base/useBase.js";
|
|
11
|
+
import { componentEvents as p } from "../../../../shared/constants.js";
|
|
12
|
+
import { SDKInternalError as u } from "../../../../types/sdkError.js";
|
|
13
|
+
import { useComponentDictionary as q, useI18n as x } from "../../../../i18n/I18n.js";
|
|
14
|
+
import { formatPayPeriodRange as N } from "../../../../helpers/dateFormatting.js";
|
|
15
|
+
function oe(t) {
|
|
16
|
+
return /* @__PURE__ */ d(M, { ...t, children: /* @__PURE__ */ d(Y, { ...t }) });
|
|
18
17
|
}
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
const { t: i } =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
const m =
|
|
18
|
+
const S = (t) => `${t.startDate}__${t.endDate}`;
|
|
19
|
+
function Y({ companyId: t, employeeId: r, payrollId: n, dictionary: E }) {
|
|
20
|
+
q("Payroll.Dismissal", E), x("Payroll.Dismissal");
|
|
21
|
+
const { t: i } = T("Payroll.Dismissal"), { onEvent: l, baseSubmitHandler: C } = $(), { data: f } = b({ companyId: t }), { mutateAsync: w, isPending: U } = g(), v = !!n && !!r;
|
|
22
|
+
A(() => {
|
|
23
|
+
n && r && l(p.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: n });
|
|
24
|
+
}, [n, r, l]);
|
|
25
|
+
const m = y(() => (f.unprocessedTerminationPayPeriodList ?? []).filter((o) => !r || o.employeeUuid === r).filter(
|
|
27
26
|
(o) => !!o.startDate && !!o.endDate && !!o.employeeUuid
|
|
28
|
-
), [
|
|
29
|
-
const o =
|
|
27
|
+
), [f, r]), c = y(() => m.map((e) => {
|
|
28
|
+
const o = N(e.startDate, e.endDate), a = e.employeeName ? `${o} (${e.employeeName})` : o;
|
|
30
29
|
return {
|
|
31
|
-
value:
|
|
32
|
-
label:
|
|
30
|
+
value: S(e),
|
|
31
|
+
label: a
|
|
33
32
|
};
|
|
34
|
-
}), [m]),
|
|
33
|
+
}), [m]), h = c.length === 1 ? c[0].value : void 0, [s, B] = O(h), R = async () => {
|
|
35
34
|
await C({ selectedPeriodKey: s }, async () => {
|
|
36
35
|
if (s === void 0)
|
|
37
|
-
throw new
|
|
38
|
-
const e = m.find((
|
|
36
|
+
throw new u(i("errors.noPayPeriodSelected"));
|
|
37
|
+
const e = m.find((_) => S(_) === s);
|
|
39
38
|
if (!e)
|
|
40
|
-
throw new
|
|
41
|
-
const o =
|
|
39
|
+
throw new u(i("errors.invalidPayPeriod"));
|
|
40
|
+
const o = r ?? e.employeeUuid, a = await w({
|
|
42
41
|
request: {
|
|
43
42
|
companyId: t,
|
|
44
43
|
requestBody: {
|
|
45
44
|
offCycle: !0,
|
|
46
|
-
offCycleReason:
|
|
47
|
-
startDate: new
|
|
48
|
-
endDate: new
|
|
49
|
-
employeeUuids: [o]
|
|
50
|
-
checkDate: u
|
|
45
|
+
offCycleReason: L.DismissedEmployee,
|
|
46
|
+
startDate: new D(e.startDate),
|
|
47
|
+
endDate: new D(e.endDate),
|
|
48
|
+
employeeUuids: [o]
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
}),
|
|
54
|
-
if (!
|
|
55
|
-
throw new
|
|
56
|
-
l(
|
|
51
|
+
}), P = a.payrollUnprocessed?.payrollUuid ?? a.payrollUnprocessed?.uuid;
|
|
52
|
+
if (!P)
|
|
53
|
+
throw new u(i("errors.missingPayrollId"));
|
|
54
|
+
l(p.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: P });
|
|
57
55
|
});
|
|
58
56
|
};
|
|
59
|
-
return
|
|
57
|
+
return v ? null : /* @__PURE__ */ d(
|
|
60
58
|
K,
|
|
61
59
|
{
|
|
62
60
|
payPeriodOptions: c,
|
|
63
61
|
selectedPeriodKey: s,
|
|
64
62
|
onSelectPeriod: B,
|
|
65
|
-
onSubmit:
|
|
66
|
-
isPending:
|
|
63
|
+
onSubmit: R,
|
|
64
|
+
isPending: U
|
|
67
65
|
}
|
|
68
66
|
);
|
|
69
67
|
}
|
|
70
68
|
export {
|
|
71
|
-
|
|
69
|
+
oe as DismissalPayPeriodSelection
|
|
72
70
|
};
|
|
73
71
|
//# sourceMappingURL=DismissalPayPeriodSelection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DismissalPayPeriodSelection.js","sources":["../../../../../src/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods'\nimport { usePayrollsCreateOffCycleMutation } from '@gusto/embedded-api/react-query/payrollsCreateOffCycle'\nimport type { UnprocessedTerminationPayPeriod } from '@gusto/embedded-api/models/components/unprocessedterminationpayperiod'\nimport { OffCycleReason } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useTranslation } from 'react-i18next'\nimport { DismissalPayPeriodSelectionPresentation } from './DismissalPayPeriodSelectionPresentation'\nimport { BaseComponent } from '@/components/Base/Base'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { componentEvents } from '@/shared/constants'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport {
|
|
1
|
+
{"version":3,"file":"DismissalPayPeriodSelection.js","sources":["../../../../../src/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { usePaySchedulesGetUnprocessedTerminationPeriodsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetUnprocessedTerminationPeriods'\nimport { usePayrollsCreateOffCycleMutation } from '@gusto/embedded-api/react-query/payrollsCreateOffCycle'\nimport type { UnprocessedTerminationPayPeriod } from '@gusto/embedded-api/models/components/unprocessedterminationpayperiod'\nimport { OffCycleReason } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useTranslation } from 'react-i18next'\nimport { DismissalPayPeriodSelectionPresentation } from './DismissalPayPeriodSelectionPresentation'\nimport { BaseComponent } from '@/components/Base/Base'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { componentEvents } from '@/shared/constants'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { formatPayPeriodRange } from '@/helpers/dateFormatting'\nimport type { SelectOption } from '@/components/Common/UI/Select/SelectTypes'\n\nexport interface DismissalPayPeriodSelectionProps extends BaseComponentInterface<'Payroll.Dismissal'> {\n companyId: string\n employeeId?: string\n payrollId?: string\n}\n\nexport function DismissalPayPeriodSelection(props: DismissalPayPeriodSelectionProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\ntype RequiredPayPeriod = UnprocessedTerminationPayPeriod &\n Required<Pick<UnprocessedTerminationPayPeriod, 'startDate' | 'endDate' | 'employeeUuid'>>\n\nconst payPeriodKey = (period: RequiredPayPeriod) => `${period.startDate}__${period.endDate}`\n\nfunction Root({ companyId, employeeId, payrollId, dictionary }: DismissalPayPeriodSelectionProps) {\n useComponentDictionary('Payroll.Dismissal', dictionary)\n useI18n('Payroll.Dismissal')\n const { t } = useTranslation('Payroll.Dismissal')\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data } = usePaySchedulesGetUnprocessedTerminationPeriodsSuspense({ companyId })\n const { mutateAsync: createOffCyclePayroll, isPending } = usePayrollsCreateOffCycleMutation()\n\n const shouldAutoAdvance = Boolean(payrollId) && Boolean(employeeId)\n\n useEffect(() => {\n if (payrollId && employeeId) {\n onEvent(componentEvents.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid: payrollId })\n }\n }, [payrollId, employeeId, onEvent])\n\n const employeePayPeriods: RequiredPayPeriod[] = useMemo(() => {\n const allPeriods = data.unprocessedTerminationPayPeriodList ?? []\n return allPeriods\n .filter(period => !employeeId || period.employeeUuid === employeeId)\n .filter(\n (period): period is RequiredPayPeriod =>\n Boolean(period.startDate) && Boolean(period.endDate) && Boolean(period.employeeUuid),\n )\n }, [data, employeeId])\n\n const payPeriodOptions: SelectOption[] = useMemo(() => {\n return employeePayPeriods.map(period => {\n const dateRange = formatPayPeriodRange(period.startDate, period.endDate)\n const label = period.employeeName ? `${dateRange} (${period.employeeName})` : dateRange\n return {\n value: payPeriodKey(period),\n label,\n }\n })\n }, [employeePayPeriods])\n\n const initialSelection = payPeriodOptions.length === 1 ? payPeriodOptions[0]!.value : undefined\n const [selectedPeriodKey, setSelectedPeriodKey] = useState(initialSelection)\n\n const handleSubmit = async () => {\n await baseSubmitHandler({ selectedPeriodKey }, async () => {\n if (selectedPeriodKey === undefined) {\n throw new SDKInternalError(t('errors.noPayPeriodSelected'))\n }\n\n const period = employeePayPeriods.find(p => payPeriodKey(p) === selectedPeriodKey)\n if (!period) {\n throw new SDKInternalError(t('errors.invalidPayPeriod'))\n }\n\n const resolvedEmployeeId = employeeId ?? period.employeeUuid\n\n const response = await createOffCyclePayroll({\n request: {\n companyId,\n requestBody: {\n offCycle: true,\n offCycleReason: OffCycleReason.DismissedEmployee,\n startDate: new RFCDate(period.startDate),\n endDate: new RFCDate(period.endDate),\n employeeUuids: [resolvedEmployeeId],\n },\n },\n })\n\n const payrollUuid =\n response.payrollUnprocessed?.payrollUuid ?? response.payrollUnprocessed?.uuid\n\n if (!payrollUuid) {\n throw new SDKInternalError(t('errors.missingPayrollId'))\n }\n\n onEvent(componentEvents.DISMISSAL_PAY_PERIOD_SELECTED, { payrollUuid })\n })\n }\n\n if (shouldAutoAdvance) {\n return null\n }\n\n return (\n <DismissalPayPeriodSelectionPresentation\n payPeriodOptions={payPeriodOptions}\n selectedPeriodKey={selectedPeriodKey}\n onSelectPeriod={setSelectedPeriodKey}\n onSubmit={handleSubmit}\n isPending={isPending}\n />\n )\n}\n"],"names":["DismissalPayPeriodSelection","props","jsx","BaseComponent","Root","payPeriodKey","period","companyId","employeeId","payrollId","dictionary","useComponentDictionary","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","data","usePaySchedulesGetUnprocessedTerminationPeriodsSuspense","createOffCyclePayroll","isPending","usePayrollsCreateOffCycleMutation","shouldAutoAdvance","useEffect","componentEvents","employeePayPeriods","useMemo","payPeriodOptions","dateRange","formatPayPeriodRange","label","initialSelection","selectedPeriodKey","setSelectedPeriodKey","useState","handleSubmit","SDKInternalError","p","resolvedEmployeeId","response","OffCycleReason","RFCDate","payrollUuid","DismissalPayPeriodSelectionPresentation"],"mappings":";;;;;;;;;;;;;;AAuBO,SAASA,GAA4BC,GAAyC;AACnF,SACE,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAKA,MAAMI,IAAe,CAACC,MAA8B,GAAGA,EAAO,SAAS,KAAKA,EAAO,OAAO;AAE1F,SAASF,EAAK,EAAE,WAAAG,GAAW,YAAAC,GAAY,WAAAC,GAAW,YAAAC,KAAgD;AAChG,EAAAC,EAAuB,qBAAqBD,CAAU,GACtDE,EAAQ,mBAAmB;AAC3B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,mBAAmB,GAC1C,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GAEjC,EAAE,MAAA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D,YAAM0B,IAAqB/B,KAAcF,EAAO,cAE1CkC,IAAW,MAAMpB,EAAsB;AAAA,QAC3C,SAAS;AAAA,UACP,WAAAb;AAAA,UACA,aAAa;AAAA,YACX,UAAU;AAAA,YACV,gBAAgBkC,EAAe;AAAA,YAC/B,WAAW,IAAIC,EAAQpC,EAAO,SAAS;AAAA,YACvC,SAAS,IAAIoC,EAAQpC,EAAO,OAAO;AAAA,YACnC,eAAe,CAACiC,CAAkB;AAAA,UAAA;AAAA,QACpC;AAAA,MACF,CACD,GAEKI,IACJH,EAAS,oBAAoB,eAAeA,EAAS,oBAAoB;AAE3E,UAAI,CAACG;AACH,cAAM,IAAIN,EAAiBxB,EAAE,yBAAyB,CAAC;AAGzD,MAAAE,EAAQU,EAAgB,+BAA+B,EAAE,aAAAkB,EAAA,CAAa;AAAA,IACxE,CAAC;AAAA,EACH;AAEA,SAAIpB,IACK,OAIP,gBAAArB;AAAA,IAAC0C;AAAA,IAAA;AAAA,MACC,kBAAAhB;AAAA,MACA,mBAAAK;AAAA,MACA,gBAAgBC;AAAA,MAChB,UAAUE;AAAA,MACV,WAAAf;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -18,12 +18,13 @@ import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
|
18
18
|
import { formatNumberAsCurrency as L } from "../../../helpers/formattedStrings.js";
|
|
19
19
|
import "../../../shared/constants.js";
|
|
20
20
|
import { useComponentContext as V } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
21
|
+
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
21
22
|
import { useI18n as E } from "../../../i18n/I18n.js";
|
|
22
23
|
import { NumberInputField as T } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
23
24
|
const q = w.object({
|
|
24
25
|
netPay: w.number().positive()
|
|
25
26
|
});
|
|
26
|
-
function
|
|
27
|
+
function fe({ isOpen: n, onCalculateGrossUp: P, onApply: A, onCancel: u }) {
|
|
27
28
|
E("Payroll.GrossUpModal");
|
|
28
29
|
const { t: r } = k("Payroll.GrossUpModal"), { Modal: N, Heading: d, Text: p, Button: i, Alert: f } = V(), { baseSubmitHandler: y } = H(), x = R(null), [l, c] = o(null), [h, m] = o(null), [g, b] = o(!1), [F, C] = o(!1), s = U({
|
|
29
30
|
resolver: z(q),
|
|
@@ -109,6 +110,6 @@ function pe({ isOpen: n, onCalculateGrossUp: P, onApply: A, onCancel: u }) {
|
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
112
|
export {
|
|
112
|
-
|
|
113
|
+
fe as GrossUpModal
|
|
113
114
|
};
|
|
114
115
|
//# sourceMappingURL=GrossUpModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrossUpModal.js","sources":["../../../../src/components/Payroll/GrossUpModal/GrossUpModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { GrossUpModalProps } from './GrossUpModalTypes'\nimport styles from './GrossUpModal.module.scss'\nimport { ActionsLayout, Flex, NumberInputField } from '@/components/Common'\nimport { useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\n\nconst GrossUpFormSchema = z.object({\n netPay: z.number().positive(),\n})\n\ntype GrossUpFormValues = z.infer<typeof GrossUpFormSchema>\n\nexport function GrossUpModal({ isOpen, onCalculateGrossUp, onApply, onCancel }: GrossUpModalProps) {\n useI18n('Payroll.GrossUpModal')\n const { t } = useTranslation('Payroll.GrossUpModal')\n const { Modal, Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const modalContainerRef = useRef<HTMLDivElement>(null)\n\n const [calculatedGrossUp, setCalculatedGrossUp] = useState<string | null>(null)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const [isCalculating, setIsCalculating] = useState(false)\n const [isApplying, setIsApplying] = useState(false)\n\n const formHandlers = useForm<GrossUpFormValues>({\n resolver: zodResolver(GrossUpFormSchema),\n defaultValues: { netPay: 0 },\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset({ netPay: 0 })\n setCalculatedGrossUp(null)\n setErrorMessage(null)\n }\n }, [isOpen, formHandlers.reset])\n\n const handleCalculate = async (data: GrossUpFormValues) => {\n setErrorMessage(null)\n setCalculatedGrossUp(null)\n setIsCalculating(true)\n\n await baseSubmitHandler(null, async () => {\n try {\n const result = await onCalculateGrossUp(data.netPay)\n\n if (result) {\n setCalculatedGrossUp(result)\n } else {\n setErrorMessage(t('errorMessage'))\n }\n } finally {\n setIsCalculating(false)\n }\n })\n }\n\n const handleApply = async () => {\n if (calculatedGrossUp) {\n setIsApplying(true)\n await baseSubmitHandler(null, async () => {\n try {\n await onApply(calculatedGrossUp)\n } finally {\n setIsApplying(false)\n }\n })\n }\n }\n\n return (\n <Modal\n isOpen={isOpen}\n onClose={onCancel}\n containerRef={modalContainerRef}\n footer={\n <ActionsLayout>\n <Button\n variant=\"primary\"\n isDisabled={!calculatedGrossUp}\n onClick={handleApply}\n isLoading={isApplying}\n >\n {t('applyCta')}\n </Button>\n <Button variant=\"secondary\" onClick={onCancel}>\n {t('cancelCta')}\n </Button>\n </ActionsLayout>\n }\n >\n <FormProvider {...formHandlers}>\n <div className={styles.header}>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('title')}\n </Heading>\n <Text variant=\"supporting\" as=\"p\">\n {t('description')}\n </Text>\n </div>\n\n <div className={styles.content}>\n {errorMessage && (\n <div className={styles.alert}>\n <Alert label={errorMessage} status=\"error\" disableScrollIntoView />\n </div>\n )}\n\n <div className={styles.alert}>\n <Alert label={t('warning')} status=\"warning\" disableScrollIntoView />\n </div>\n\n <Flex flexDirection=\"row\" gap={8}>\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isDisabled={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {isCalculating ? t('calculatingCta') : t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp && (\n <>\n <div className={styles.result}>\n <Text size=\"sm\" variant=\"supporting\" weight=\"semibold\">\n {t('grossPayResult')}\n </Text>\n <Heading as=\"h3\">{formatNumberAsCurrency(parseFloat(calculatedGrossUp))}</Heading>\n </div>\n </>\n )}\n </div>\n </FormProvider>\n </Modal>\n )\n}\n"],"names":["GrossUpFormSchema","z","GrossUpModal","isOpen","onCalculateGrossUp","onApply","onCancel","useI18n","t","useTranslation","Modal","Heading","Text","Button","Alert","useComponentContext","baseSubmitHandler","useBase","modalContainerRef","useRef","calculatedGrossUp","setCalculatedGrossUp","useState","errorMessage","setErrorMessage","isCalculating","setIsCalculating","isApplying","setIsApplying","formHandlers","useForm","zodResolver","useEffect","handleCalculate","data","result","jsx","ActionsLayout","jsxs","FormProvider","styles","Flex","NumberInputField","Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"GrossUpModal.js","sources":["../../../../src/components/Payroll/GrossUpModal/GrossUpModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { GrossUpModalProps } from './GrossUpModalTypes'\nimport styles from './GrossUpModal.module.scss'\nimport { ActionsLayout, Flex, NumberInputField } from '@/components/Common'\nimport { useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\n\nconst GrossUpFormSchema = z.object({\n netPay: z.number().positive(),\n})\n\ntype GrossUpFormValues = z.infer<typeof GrossUpFormSchema>\n\nexport function GrossUpModal({ isOpen, onCalculateGrossUp, onApply, onCancel }: GrossUpModalProps) {\n useI18n('Payroll.GrossUpModal')\n const { t } = useTranslation('Payroll.GrossUpModal')\n const { Modal, Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const modalContainerRef = useRef<HTMLDivElement>(null)\n\n const [calculatedGrossUp, setCalculatedGrossUp] = useState<string | null>(null)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const [isCalculating, setIsCalculating] = useState(false)\n const [isApplying, setIsApplying] = useState(false)\n\n const formHandlers = useForm<GrossUpFormValues>({\n resolver: zodResolver(GrossUpFormSchema),\n defaultValues: { netPay: 0 },\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset({ netPay: 0 })\n setCalculatedGrossUp(null)\n setErrorMessage(null)\n }\n }, [isOpen, formHandlers.reset])\n\n const handleCalculate = async (data: GrossUpFormValues) => {\n setErrorMessage(null)\n setCalculatedGrossUp(null)\n setIsCalculating(true)\n\n await baseSubmitHandler(null, async () => {\n try {\n const result = await onCalculateGrossUp(data.netPay)\n\n if (result) {\n setCalculatedGrossUp(result)\n } else {\n setErrorMessage(t('errorMessage'))\n }\n } finally {\n setIsCalculating(false)\n }\n })\n }\n\n const handleApply = async () => {\n if (calculatedGrossUp) {\n setIsApplying(true)\n await baseSubmitHandler(null, async () => {\n try {\n await onApply(calculatedGrossUp)\n } finally {\n setIsApplying(false)\n }\n })\n }\n }\n\n return (\n <Modal\n isOpen={isOpen}\n onClose={onCancel}\n containerRef={modalContainerRef}\n footer={\n <ActionsLayout>\n <Button\n variant=\"primary\"\n isDisabled={!calculatedGrossUp}\n onClick={handleApply}\n isLoading={isApplying}\n >\n {t('applyCta')}\n </Button>\n <Button variant=\"secondary\" onClick={onCancel}>\n {t('cancelCta')}\n </Button>\n </ActionsLayout>\n }\n >\n <FormProvider {...formHandlers}>\n <div className={styles.header}>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('title')}\n </Heading>\n <Text variant=\"supporting\" as=\"p\">\n {t('description')}\n </Text>\n </div>\n\n <div className={styles.content}>\n {errorMessage && (\n <div className={styles.alert}>\n <Alert label={errorMessage} status=\"error\" disableScrollIntoView />\n </div>\n )}\n\n <div className={styles.alert}>\n <Alert label={t('warning')} status=\"warning\" disableScrollIntoView />\n </div>\n\n <Flex flexDirection=\"row\" gap={8}>\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isDisabled={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {isCalculating ? t('calculatingCta') : t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp && (\n <>\n <div className={styles.result}>\n <Text size=\"sm\" variant=\"supporting\" weight=\"semibold\">\n {t('grossPayResult')}\n </Text>\n <Heading as=\"h3\">{formatNumberAsCurrency(parseFloat(calculatedGrossUp))}</Heading>\n </div>\n </>\n )}\n </div>\n </FormProvider>\n </Modal>\n )\n}\n"],"names":["GrossUpFormSchema","z","GrossUpModal","isOpen","onCalculateGrossUp","onApply","onCancel","useI18n","t","useTranslation","Modal","Heading","Text","Button","Alert","useComponentContext","baseSubmitHandler","useBase","modalContainerRef","useRef","calculatedGrossUp","setCalculatedGrossUp","useState","errorMessage","setErrorMessage","isCalculating","setIsCalculating","isApplying","setIsApplying","formHandlers","useForm","zodResolver","useEffect","handleCalculate","data","result","jsx","ActionsLayout","jsxs","FormProvider","styles","Flex","NumberInputField","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACjC,QAAQA,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC;AAIM,SAASC,GAAa,EAAE,QAAAC,GAAQ,oBAAAC,GAAoB,SAAAC,GAAS,UAAAC,KAA+B;AACjG,EAAAC,EAAQ,sBAAsB;AAC9B,QAAM,E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,MAAK;AAAA,gBACL,OAAOlC,EAAE,aAAa;AAAA,gBACtB,QAAO;AAAA,gBACP,KAAK;AAAA,gBACL,YAAU;AAAA,cAAA;AAAA,YAAA;AAAA,YAEZ,gBAAA4B;AAAA,cAACvB;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,WAAW2B,EAAO;AAAA,gBAClB,YAAYf;AAAA,gBACZ,SAASI,EAAa,aAAaI,CAAe;AAAA,gBAEjD,UAAgBzB,EAAhBiB,IAAkB,mBAAsB,cAAN;AAAA,cAAoB;AAAA,YAAA;AAAA,UACzD,GACF;AAAA,UAECL,KACC,gBAAAgB,EAAAO,GAAA,EACE,UAAA,gBAAAL,EAAC,OAAA,EAAI,WAAWE,EAAO,QACrB,UAAA;AAAA,YAAA,gBAAAJ,EAACxB,GAAA,EAAK,MAAK,MAAK,SAAQ,cAAa,QAAO,YACzC,UAAAJ,EAAE,gBAAgB,EAAA,CACrB;AAAA,YACA,gBAAA4B,EAACzB,KAAQ,IAAG,MAAM,YAAuB,WAAWS,CAAiB,CAAC,EAAA,CAAE;AAAA,UAAA,EAAA,CAC1E,EAAA,CACF;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const t = "
|
|
1
|
+
const t = "_content_wjov6_1", e = "_header_wjov6_8", o = "_alert_wjov6_14", c = "_calculateButton_wjov6_18", n = "_result_wjov6_25", _ = {
|
|
2
2
|
content: t,
|
|
3
3
|
header: e,
|
|
4
|
-
alert:
|
|
4
|
+
alert: o,
|
|
5
5
|
calculateButton: c,
|
|
6
6
|
result: n
|
|
7
7
|
};
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
o as alert,
|
|
10
10
|
c as calculateButton,
|
|
11
11
|
t as content,
|
|
12
|
-
|
|
12
|
+
_ as default,
|
|
13
13
|
e as header,
|
|
14
14
|
n as result
|
|
15
15
|
};
|