@gusto/embedded-react-sdk 0.55.0 → 0.55.2
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 +36 -0
- package/dist/components/Common/TaxInputs/TaxInputs.js +65 -64
- package/dist/components/Common/TaxInputs/TaxInputs.js.map +1 -1
- package/dist/components/Common/UI/Select/Select.module.scss.js +5 -5
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.d.ts +4 -2
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +148 -117
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js +56 -55
- package/dist/components/Contractor/Payments/CreatePayment/PreviewPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePaymentFlow/CreatePaymentFlow.d.ts +1 -1
- package/dist/components/Contractor/Payments/CreatePaymentFlow/CreatePaymentFlow.js +15 -12
- package/dist/components/Contractor/Payments/CreatePaymentFlow/CreatePaymentFlow.js.map +1 -1
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/HistoricalPaymentFlow.d.ts +69 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/HistoricalPaymentFlow.js +48 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/HistoricalPaymentFlow.js.map +1 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/HistoricalPaymentFlowComponents.d.ts +20 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/HistoricalPaymentFlowComponents.js +25 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/HistoricalPaymentFlowComponents.js.map +1 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/historicalPaymentMachine.d.ts +20 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/historicalPaymentMachine.js +24 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/historicalPaymentMachine.js.map +1 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentFlow/index.d.ts +2 -0
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +16 -15
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.d.ts +2 -0
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js +36 -23
- package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.d.ts +10 -8
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js +46 -25
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js +53 -52
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistoryPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatementPresentation.js +37 -47
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatementPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js +47 -44
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.d.ts +2 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js +65 -53
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.module.scss.js +6 -4
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.module.scss.js.map +1 -1
- package/dist/components/Contractor/Payments/ViewPaymentFlow/ViewPaymentFlow.d.ts +1 -1
- package/dist/components/Contractor/Payments/ViewPaymentFlow/ViewPaymentFlow.js +22 -19
- package/dist/components/Contractor/Payments/ViewPaymentFlow/ViewPaymentFlow.js.map +1 -1
- package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/PaymentSummaryBlock.d.ts +2 -8
- package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/PaymentSummaryBlock.js +43 -42
- package/dist/components/Contractor/Payments/shared/PaymentSummaryBlock/PaymentSummaryBlock.js.map +1 -1
- package/dist/components/Contractor/Payments/shared/paymentAmounts.d.ts +32 -0
- package/dist/components/Contractor/Payments/shared/paymentAmounts.js +11 -0
- package/dist/components/Contractor/Payments/shared/paymentAmounts.js.map +1 -0
- package/dist/components/Contractor/Payments/shared/paymentAmounts.test.d.ts +1 -0
- package/dist/components/Contractor/Payments/shared/usePaymentAmountsEditor.d.ts +13 -4
- package/dist/components/Contractor/Payments/shared/usePaymentAmountsEditor.js +43 -38
- package/dist/components/Contractor/Payments/shared/usePaymentAmountsEditor.js.map +1 -1
- package/dist/components/Contractor/exports/contractorManagement.d.ts +1 -0
- package/dist/components/Contractor/exports/contractorManagement.js +34 -32
- package/dist/components/Contractor/exports/contractorManagement.js.map +1 -1
- package/dist/components/Contractor/shared/SelectContractors/SelectContractors.d.ts +6 -1
- package/dist/components/Contractor/shared/SelectContractors/SelectContractors.js +13 -12
- package/dist/components/Contractor/shared/SelectContractors/SelectContractors.js.map +1 -1
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.d.ts +5 -1
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js +34 -32
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.d.ts +7 -0
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +191 -153
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +1 -0
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +87 -81
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +1 -0
- package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +73 -48
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.d.ts +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.js +22 -20
- package/dist/components/Payroll/PayrollFlow/PayrollFlow.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +3 -0
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js +22 -20
- package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollLanding/PayrollLanding.d.ts +2 -0
- package/dist/components/Payroll/PayrollLanding/PayrollLanding.js +34 -26
- package/dist/components/Payroll/PayrollLanding/PayrollLanding.js.map +1 -1
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.d.ts +4 -0
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +51 -43
- package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.d.ts +2 -0
- package/dist/components/Payroll/PayrollList/PayrollList.js +48 -47
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +44 -43
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.d.ts +7 -0
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +115 -112
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +2 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +94 -103
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceipts.js +22 -16
- package/dist/components/Payroll/PayrollReceipts/PayrollReceipts.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js +58 -49
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/PrintChecks/PrintChecks.d.ts +21 -0
- package/dist/components/Payroll/PrintChecks/PrintChecks.js +68 -0
- package/dist/components/Payroll/PrintChecks/PrintChecks.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksBanner/PrintChecksBanner.d.ts +9 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksBanner/PrintChecksBanner.js +34 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksBanner/PrintChecksBanner.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksBanner/index.d.ts +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksComponents.d.ts +48 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksComponents.js +26 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksComponents.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksFailure/PrintChecksFailure.d.ts +14 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksFailure/PrintChecksFailure.js +47 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksFailure/PrintChecksFailure.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksFailure/index.d.ts +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.d.ts +16 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js +144 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/index.d.ts +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksSummary/PrintChecksSummary.d.ts +14 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksSummary/PrintChecksSummary.js +39 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksSummary/PrintChecksSummary.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/PrintChecksSummary/index.d.ts +1 -0
- package/dist/components/Payroll/PrintChecks/index.d.ts +2 -0
- package/dist/components/Payroll/PrintChecks/printChecksStateMachine.d.ts +33 -0
- package/dist/components/Payroll/PrintChecks/printChecksStateMachine.js +93 -0
- package/dist/components/Payroll/PrintChecks/printChecksStateMachine.js.map +1 -0
- package/dist/components/Payroll/PrintChecks/types.d.ts +14 -0
- package/dist/components/Payroll/index.d.ts +2 -0
- package/dist/components/Payroll/index.js +26 -24
- package/dist/components/Payroll/index.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +6 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +36 -34
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/UnstableFeaturesProvider/UnstableFeaturesProvider.d.ts +22 -0
- package/dist/contexts/UnstableFeaturesProvider/UnstableFeaturesProvider.js +14 -0
- package/dist/contexts/UnstableFeaturesProvider/UnstableFeaturesProvider.js.map +1 -0
- package/dist/contexts/UnstableFeaturesProvider/WithUnstableFeature.d.ts +19 -0
- package/dist/contexts/UnstableFeaturesProvider/WithUnstableFeature.js +8 -0
- package/dist/contexts/UnstableFeaturesProvider/WithUnstableFeature.js.map +1 -0
- package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.d.ts +41 -0
- package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js +14 -0
- package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js.map +1 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/i18n/I18n.js +4 -0
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Contractor.Payments.CreateHistoricalPayment.json.js +34 -32
- package/dist/i18n/en/Contractor.Payments.CreateHistoricalPayment.json.js.map +1 -1
- package/dist/i18n/en/Contractor.Payments.PaymentsList.json.js +20 -18
- package/dist/i18n/en/Contractor.Payments.PaymentsList.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +9 -9
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +38 -38
- package/dist/i18n/en/Payroll.PayrollReceipts.json.js +2 -2
- package/dist/i18n/en/Payroll.PrintChecksBanner.json.js +14 -0
- package/dist/i18n/en/Payroll.PrintChecksBanner.json.js.map +1 -0
- package/dist/i18n/en/Payroll.PrintChecksFailure.json.js +12 -0
- package/dist/i18n/en/Payroll.PrintChecksFailure.json.js.map +1 -0
- package/dist/i18n/en/Payroll.PrintChecksForm.json.js +28 -0
- package/dist/i18n/en/Payroll.PrintChecksForm.json.js.map +1 -0
- package/dist/i18n/en/Payroll.PrintChecksSummary.json.js +14 -0
- package/dist/i18n/en/Payroll.PrintChecksSummary.json.js.map +1 -0
- package/dist/i18n/en/common.json.d.ts +0 -21
- package/dist/i18n/types.d.ts +75 -9
- package/dist/models/external.d.ts +3 -0
- package/dist/partner-hook-utils/form/buildFormSchema.js +60 -54
- package/dist/partner-hook-utils/form/buildFormSchema.js.map +1 -1
- package/dist/shared/constants.d.ts +30 -0
- package/dist/shared/constants.js +62 -50
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/test-utils/renderWithProviders.d.ts +4 -1
- package/dist/test-utils/tableQueries.d.ts +9 -0
- package/docs/guides/endpoint-inventory.json +33 -0
- package/package.json +18 -18
package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js
CHANGED
|
@@ -1,175 +1,206 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useContractorsListSuspense as
|
|
3
|
-
import { useContractorPaymentGroupsPreviewMutation as
|
|
4
|
-
import { useContractorPaymentGroupsCreateMutation as
|
|
5
|
-
import { RFCDate as
|
|
6
|
-
import { useMemo as
|
|
7
|
-
import { useTranslation as
|
|
8
|
-
import { usePaymentAmountsEditor as
|
|
9
|
-
import { getHistoricalPaymentCheckDateBounds as
|
|
10
|
-
import { useCreateHistoricalPaymentDictionary as
|
|
11
|
-
import { formatDateToStringDate as
|
|
12
|
-
import { Flex as
|
|
13
|
-
import { ActionsLayout as
|
|
14
|
-
import { BaseComponent as
|
|
15
|
-
import { useBase as
|
|
16
|
-
import { useComponentContext as
|
|
17
|
-
import { useI18n as
|
|
18
|
-
import { useDateFormatter as
|
|
19
|
-
import { componentEvents as
|
|
20
|
-
import { SelectContractors as
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { useContractorsListSuspense as W } from "@gusto/embedded-api/react-query/contractorsList";
|
|
3
|
+
import { useContractorPaymentGroupsPreviewMutation as K } from "@gusto/embedded-api/react-query/contractorPaymentGroupsPreview";
|
|
4
|
+
import { useContractorPaymentGroupsCreateMutation as V } from "@gusto/embedded-api/react-query/contractorPaymentGroupsCreate";
|
|
5
|
+
import { RFCDate as x } from "@gusto/embedded-api/types/rfcdate";
|
|
6
|
+
import { useMemo as z, useState as d } from "react";
|
|
7
|
+
import { useTranslation as _ } from "react-i18next";
|
|
8
|
+
import { usePaymentAmountsEditor as J } from "../shared/usePaymentAmountsEditor.js";
|
|
9
|
+
import { getHistoricalPaymentCheckDateBounds as Q } from "../shared/historicalPaymentDateBounds.js";
|
|
10
|
+
import { useCreateHistoricalPaymentDictionary as X, useCreateHistoricalPaymentReviewDictionary as Z } from "./useFormDictionary.js";
|
|
11
|
+
import { formatDateToStringDate as $ } from "../../../../helpers/dateFormatting.js";
|
|
12
|
+
import { Flex as s, FlexItem as tt } from "../../../Common/Flex/Flex.js";
|
|
13
|
+
import { ActionsLayout as et } from "../../../Common/ActionsLayout/ActionsLayout.js";
|
|
14
|
+
import { BaseComponent as nt } from "../../../Base/Base.js";
|
|
15
|
+
import { useBase as rt } from "../../../Base/useBase.js";
|
|
16
|
+
import { useComponentContext as O } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
|
+
import { useI18n as ot, useComponentDictionary as at } from "../../../../i18n/I18n.js";
|
|
18
|
+
import { useDateFormatter as it } from "../../../../hooks/useDateFormatter.js";
|
|
19
|
+
import { componentEvents as D } from "../../../../shared/constants.js";
|
|
20
|
+
import { SelectContractors as ct } from "../../shared/SelectContractors/SelectContractors.js";
|
|
21
|
+
import st from "../../../../assets/icons/caret-left.svg.js";
|
|
22
|
+
import { useUnstableFeature as lt } from "../../../../contexts/UnstableFeaturesProvider/useUnstableFeature.js";
|
|
23
|
+
import { PaymentSummaryBlock as ut } from "../shared/PaymentSummaryBlock/PaymentSummaryBlock.js";
|
|
24
|
+
import { SetPaymentAmounts as mt } from "../shared/SetPaymentAmounts/SetPaymentAmounts.js";
|
|
25
|
+
const L = ["Historical Payment"];
|
|
26
|
+
function Nt(r) {
|
|
27
|
+
return /* @__PURE__ */ t(nt, { ...r, componentName: "Contractor.Payments.CreateHistoricalPayment", children: /* @__PURE__ */ t(dt, { ...r }) });
|
|
26
28
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
const { t: e } =
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
year:
|
|
33
|
-
allowedYear:
|
|
29
|
+
function dt({ companyId: r, dictionary: C, onEvent: u }) {
|
|
30
|
+
lt("historicalPayments", { throwIfDisabled: !0 }), ot("Contractor.Payments.CreateHistoricalPayment"), at("Contractor.Payments.CreateHistoricalPayment", C);
|
|
31
|
+
const { t: e } = _("Contractor.Payments.CreateHistoricalPayment"), { Heading: S, Text: E, Button: o, DatePicker: T } = O(), { minDate: l, maxDate: y } = z(() => Q(), []), [a, g] = d(null), [p, H] = d([]), [h, v] = d(null), [P, f] = d(void 0);
|
|
32
|
+
let i = null;
|
|
33
|
+
a !== null && a > y ? i = e("select.dateInFutureError") : a !== null && a < l && (i = e("select.dateTooEarlyError", {
|
|
34
|
+
year: a.getFullYear(),
|
|
35
|
+
allowedYear: l.getFullYear()
|
|
34
36
|
}));
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const A = p.length > 0 && a !== null && i === null, w = () => {
|
|
38
|
+
if (!A) return;
|
|
39
|
+
const m = $(a);
|
|
40
|
+
m && v({ contractorIds: p, checkDate: m });
|
|
39
41
|
};
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
+
return h ? /* @__PURE__ */ t(
|
|
43
|
+
Ct,
|
|
42
44
|
{
|
|
43
|
-
companyId:
|
|
44
|
-
contractorIds:
|
|
45
|
-
checkDate:
|
|
46
|
-
onEvent:
|
|
45
|
+
companyId: r,
|
|
46
|
+
contractorIds: h.contractorIds,
|
|
47
|
+
checkDate: h.checkDate,
|
|
48
|
+
onEvent: u,
|
|
49
|
+
preservedContractorPayments: P,
|
|
50
|
+
onBack: (m) => {
|
|
51
|
+
f(m), v(null);
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
|
-
) : /* @__PURE__ */
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
/* @__PURE__ */ t(
|
|
51
|
-
/* @__PURE__ */ t(
|
|
54
|
+
) : /* @__PURE__ */ c(s, { flexDirection: "column", gap: 32, children: [
|
|
55
|
+
/* @__PURE__ */ c(s, { flexDirection: "column", gap: 4, children: [
|
|
56
|
+
/* @__PURE__ */ t(S, { as: "h2", children: e("select.heading") }),
|
|
57
|
+
/* @__PURE__ */ t(E, { variant: "supporting", children: e("select.subtitle") })
|
|
52
58
|
] }),
|
|
53
59
|
/* @__PURE__ */ t(
|
|
54
|
-
|
|
60
|
+
T,
|
|
55
61
|
{
|
|
56
62
|
label: e("select.dateLabel"),
|
|
57
63
|
isRequired: !0,
|
|
58
|
-
value:
|
|
59
|
-
onChange:
|
|
60
|
-
minDate:
|
|
61
|
-
maxDate:
|
|
62
|
-
isInvalid:
|
|
63
|
-
errorMessage:
|
|
64
|
+
value: a,
|
|
65
|
+
onChange: g,
|
|
66
|
+
minDate: l,
|
|
67
|
+
maxDate: y,
|
|
68
|
+
isInvalid: i !== null,
|
|
69
|
+
errorMessage: i ?? void 0
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ t(
|
|
73
|
+
ct,
|
|
74
|
+
{
|
|
75
|
+
companyId: r,
|
|
76
|
+
onSelectionChange: H,
|
|
77
|
+
initialSelectedIds: p
|
|
64
78
|
}
|
|
65
79
|
),
|
|
66
|
-
/* @__PURE__ */ t(
|
|
67
|
-
/* @__PURE__ */ t(Z, { children: /* @__PURE__ */ t(u, { onClick: g, variant: "primary", isDisabled: !T, children: e("select.continueButton") }) })
|
|
80
|
+
/* @__PURE__ */ t(et, { children: /* @__PURE__ */ t(o, { onClick: w, variant: "primary", isDisabled: !A, children: e("select.continueButton") }) })
|
|
68
81
|
] });
|
|
69
82
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
function Ct({
|
|
84
|
+
companyId: r,
|
|
85
|
+
contractorIds: C,
|
|
86
|
+
checkDate: u,
|
|
87
|
+
onEvent: e,
|
|
88
|
+
preservedContractorPayments: S,
|
|
89
|
+
onBack: E
|
|
90
|
+
}) {
|
|
91
|
+
const { t: o } = _("Contractor.Payments.CreateHistoricalPayment"), { Heading: T, Text: l, Button: y, Alert: a } = O(), { baseSubmitHandler: g } = rt(), { formatLongWithYear: p } = it(), H = X(), h = Z(), { data: v } = W({ companyUuid: r }), P = (v.contractors ?? []).filter(
|
|
92
|
+
(n) => C.includes(n.uuid)
|
|
93
|
+
), { virtualContractorPayments: f, totals: i, editModal: A } = J({
|
|
94
|
+
contractors: P,
|
|
95
|
+
allowedPaymentMethods: L,
|
|
96
|
+
preservedContractorPayments: S,
|
|
76
97
|
onEditOpen: () => {
|
|
77
|
-
e(
|
|
98
|
+
e(D.CONTRACTOR_HISTORICAL_PAYMENT_EDIT);
|
|
78
99
|
},
|
|
79
100
|
onEditSave: (n) => {
|
|
80
|
-
e(
|
|
101
|
+
e(D.CONTRACTOR_HISTORICAL_PAYMENT_UPDATE, n);
|
|
81
102
|
}
|
|
82
|
-
}),
|
|
83
|
-
|
|
84
|
-
const n = await
|
|
103
|
+
}), w = i.total > 0, { mutateAsync: m, isPending: N } = K(), { mutateAsync: Y, isPending: G } = V(), [k, B] = d(null), [I, F] = d(!1), b = () => f.filter((n) => n.isTouched).map(({ isTouched: n, ...R }) => R), q = async () => {
|
|
104
|
+
w && await g(null, async () => {
|
|
105
|
+
const n = await m({
|
|
85
106
|
request: {
|
|
86
|
-
companyId:
|
|
107
|
+
companyId: r,
|
|
87
108
|
requestBody: {
|
|
88
|
-
checkDate: new
|
|
89
|
-
contractorPayments:
|
|
109
|
+
checkDate: new x(u),
|
|
110
|
+
contractorPayments: b()
|
|
90
111
|
}
|
|
91
112
|
}
|
|
92
113
|
});
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
B(n.contractorPaymentGroupPreview || null), e(
|
|
115
|
+
D.CONTRACTOR_HISTORICAL_PAYMENT_PREVIEW,
|
|
95
116
|
n.contractorPaymentGroupPreview
|
|
96
117
|
);
|
|
97
118
|
});
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
const n =
|
|
102
|
-
!n ||
|
|
103
|
-
const
|
|
119
|
+
}, j = () => {
|
|
120
|
+
B(null), e(D.CONTRACTOR_HISTORICAL_PAYMENT_BACK_TO_EDIT);
|
|
121
|
+
}, U = async () => {
|
|
122
|
+
const n = k?.creationToken;
|
|
123
|
+
!n || I || await g(null, async () => {
|
|
124
|
+
const R = await Y({
|
|
104
125
|
request: {
|
|
105
|
-
companyId:
|
|
126
|
+
companyId: r,
|
|
106
127
|
requestBody: {
|
|
107
|
-
checkDate: new
|
|
128
|
+
checkDate: new x(u),
|
|
108
129
|
creationToken: n,
|
|
109
|
-
contractorPayments:
|
|
130
|
+
contractorPayments: b()
|
|
110
131
|
}
|
|
111
132
|
}
|
|
112
133
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
R.contractorPaymentGroup && (F(!0), e(
|
|
135
|
+
D.CONTRACTOR_HISTORICAL_PAYMENT_CREATED,
|
|
136
|
+
R.contractorPaymentGroup
|
|
116
137
|
));
|
|
117
138
|
});
|
|
118
139
|
};
|
|
119
|
-
return
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/* @__PURE__ */ t(
|
|
124
|
-
|
|
140
|
+
return k ? /* @__PURE__ */ c(s, { flexDirection: "column", gap: 32, children: [
|
|
141
|
+
!I && /* @__PURE__ */ t(M, { onClick: j }),
|
|
142
|
+
/* @__PURE__ */ c(s, { justifyContent: "space-between", alignItems: "flex-start", gap: 16, children: [
|
|
143
|
+
/* @__PURE__ */ c(s, { flexDirection: "column", gap: 4, children: [
|
|
144
|
+
/* @__PURE__ */ t(T, { as: "h2", children: o("review.title") }),
|
|
145
|
+
/* @__PURE__ */ t(l, { variant: "supporting", children: o("review.subtitle", {
|
|
146
|
+
checkDate: p(k.checkDate ?? "")
|
|
125
147
|
}) })
|
|
126
148
|
] }),
|
|
127
|
-
!
|
|
128
|
-
/* @__PURE__ */ t(m, { onClick: G, variant: "secondary", children: r("review.editButton") }),
|
|
129
|
-
/* @__PURE__ */ t(m, { onClick: F, variant: "primary", isLoading: L, children: r("review.submitButton") })
|
|
130
|
-
] })
|
|
149
|
+
!I && /* @__PURE__ */ t(y, { onClick: U, variant: "primary", isLoading: G, children: o("review.submitButton") })
|
|
131
150
|
] }),
|
|
132
|
-
|
|
151
|
+
I && /* @__PURE__ */ t(a, { status: "success", label: o("review.successTitle"), children: /* @__PURE__ */ t(l, { children: o("review.successMessage") }) }),
|
|
133
152
|
/* @__PURE__ */ t(
|
|
134
|
-
|
|
153
|
+
ut,
|
|
135
154
|
{
|
|
136
|
-
contractorPaymentGroup:
|
|
137
|
-
contractors:
|
|
155
|
+
contractorPaymentGroup: k,
|
|
156
|
+
contractors: P,
|
|
138
157
|
showDebitColumns: !1,
|
|
139
|
-
dictionary:
|
|
158
|
+
dictionary: h
|
|
140
159
|
}
|
|
141
160
|
)
|
|
142
|
-
] }) : /* @__PURE__ */
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
] }) : /* @__PURE__ */ c(s, { flexDirection: "column", gap: 32, children: [
|
|
162
|
+
/* @__PURE__ */ t(
|
|
163
|
+
M,
|
|
164
|
+
{
|
|
165
|
+
onClick: () => {
|
|
166
|
+
E(f);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ c(s, { justifyContent: "flex-end", gap: 16, children: [
|
|
171
|
+
/* @__PURE__ */ c(s, { flexDirection: "column", gap: 4, children: [
|
|
172
|
+
/* @__PURE__ */ t(T, { as: "h2", children: o("amounts.heading") }),
|
|
173
|
+
/* @__PURE__ */ t(l, { variant: "supporting", children: o("amounts.subtitle") })
|
|
147
174
|
] }),
|
|
148
|
-
/* @__PURE__ */ t(
|
|
149
|
-
|
|
175
|
+
/* @__PURE__ */ t(tt, { children: /* @__PURE__ */ t(
|
|
176
|
+
y,
|
|
150
177
|
{
|
|
151
|
-
onClick:
|
|
178
|
+
onClick: q,
|
|
152
179
|
variant: "primary",
|
|
153
|
-
isDisabled: !
|
|
154
|
-
isLoading:
|
|
155
|
-
children:
|
|
180
|
+
isDisabled: !w,
|
|
181
|
+
isLoading: N,
|
|
182
|
+
children: o("amounts.continueButton")
|
|
156
183
|
}
|
|
157
184
|
) })
|
|
158
185
|
] }),
|
|
159
186
|
/* @__PURE__ */ t(
|
|
160
|
-
|
|
187
|
+
mt,
|
|
161
188
|
{
|
|
162
|
-
contractors:
|
|
163
|
-
contractorPayments:
|
|
164
|
-
totals:
|
|
165
|
-
allowedPaymentMethods:
|
|
166
|
-
editModal:
|
|
167
|
-
dictionary:
|
|
189
|
+
contractors: P,
|
|
190
|
+
contractorPayments: f,
|
|
191
|
+
totals: i,
|
|
192
|
+
allowedPaymentMethods: L,
|
|
193
|
+
editModal: A,
|
|
194
|
+
dictionary: H
|
|
168
195
|
}
|
|
169
196
|
)
|
|
170
197
|
] });
|
|
171
198
|
}
|
|
199
|
+
function M({ onClick: r }) {
|
|
200
|
+
const { t: C } = _("Contractor.Payments.CreateHistoricalPayment"), { Button: u } = O();
|
|
201
|
+
return /* @__PURE__ */ t(u, { variant: "secondary", icon: /* @__PURE__ */ t(st, { "aria-hidden": "true" }), onClick: r, children: C("backButton") });
|
|
202
|
+
}
|
|
172
203
|
export {
|
|
173
|
-
|
|
204
|
+
Nt as CreateHistoricalPayment
|
|
174
205
|
};
|
|
175
206
|
//# sourceMappingURL=CreateHistoricalPayment.js.map
|
package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateHistoricalPayment.js","sources":["../../../../../src/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.tsx"],"sourcesContent":["import { useContractorsListSuspense } from '@gusto/embedded-api/react-query/contractorsList'\nimport { useContractorPaymentGroupsPreviewMutation } from '@gusto/embedded-api/react-query/contractorPaymentGroupsPreview'\nimport { useContractorPaymentGroupsCreateMutation } from '@gusto/embedded-api/react-query/contractorPaymentGroupsCreate'\nimport type { ContractorPaymentGroupPreview } from '@gusto/embedded-api/models/components/contractorpaymentgrouppreview'\nimport type { PostV1CompaniesCompanyIdContractorPaymentGroupsPaymentMethod as ContractorPaymentMethod } from '@gusto/embedded-api/models/operations/postv1companiescompanyidcontractorpaymentgroups'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useMemo, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { usePaymentAmountsEditor } from '../shared/usePaymentAmountsEditor'\nimport { SetPaymentAmounts } from '../shared/SetPaymentAmounts'\nimport { PaymentSummaryBlock } from '../shared/PaymentSummaryBlock'\nimport { getHistoricalPaymentCheckDateBounds } from '../shared/historicalPaymentDateBounds'\nimport {\n useCreateHistoricalPaymentDictionary,\n useCreateHistoricalPaymentReviewDictionary,\n} from './useFormDictionary'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { ActionsLayout, Flex, FlexItem } from '@/components/Common'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport { componentEvents } from '@/shared/constants'\nimport { SelectContractors } from '@/components/Contractor/shared/SelectContractors/SelectContractors'\n\nconst ALLOWED_PAYMENT_METHODS: ContractorPaymentMethod[] = ['Historical Payment']\n\n/**\n * Props for {@link CreateHistoricalPayment}.\n *\n * @alpha\n */\nexport interface CreateHistoricalPaymentProps extends BaseComponentInterface<'Contractor.Payments.CreateHistoricalPayment'> {\n /** UUID of the company recording the historical payment. */\n companyId: string\n}\n\n/**\n * Records a historical contractor payment — one that already happened outside Gusto and does not\n * move money — by picking a paid date and the contractors being paid, entering hours, wages,\n * bonuses, and reimbursements for them, then reviewing and submitting.\n *\n * @remarks\n * Every contractor payment is fixed to the `Historical Payment` payment method, so there is no\n * payment method choice or debit information to review.\n * Continue on the contractor-selection step is disabled until the paid date is valid and at least\n * one contractor is selected. Continue on the amounts step is disabled until at least one selected\n * contractor has a payment total greater than zero, and swaps the amounts grid for an in-place\n * review (mirroring `CreatePayment`'s preview step); Edit returns to the grid without losing\n * entered amounts, and Submit creates the contractor payment group. Once creation succeeds, the\n * Edit and Submit buttons are replaced with a success message, since the creation token has been\n * consumed and the host is expected to navigate away (e.g. to `HistoricalPaymentSummary`).\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/historicalPayments/edit` | The edit modal was opened for a contractor. | — |\n * | `contractor/historicalPayments/update` | A contractor's payment values were updated locally. | The updated form values (hours, wage, bonus, reimbursement, payment method, etc.). |\n * | `contractor/historicalPayments/preview` | The preview API call succeeded. | The contractor payment group preview response. |\n * | `contractor/historicalPayments/backToEdit` | The user returned from preview to continue editing. | — |\n * | `contractor/historicalPayments/created` | The payment group was successfully created. | The created contractor payment group response. |\n *\n * @param props - See {@link CreateHistoricalPaymentProps}.\n * @returns The rendered contractor-selection screen, the payment-amounts entry screen, or its\n * in-place review.\n * @alpha\n */\nexport function CreateHistoricalPayment(props: CreateHistoricalPaymentProps) {\n return (\n <BaseComponent {...props} componentName=\"Contractor.Payments.CreateHistoricalPayment\">\n <Root {...props} />\n </BaseComponent>\n )\n}\n\ninterface ContractorSelection {\n contractorIds: string[]\n checkDate: string\n}\n\nfunction Root({ companyId, dictionary, onEvent }: CreateHistoricalPaymentProps) {\n useI18n('Contractor.Payments.CreateHistoricalPayment')\n useComponentDictionary('Contractor.Payments.CreateHistoricalPayment', dictionary)\n const { t } = useTranslation('Contractor.Payments.CreateHistoricalPayment')\n const { Heading, Text, Button, DatePicker } = useComponentContext()\n\n const { minDate, maxDate } = useMemo(() => getHistoricalPaymentCheckDateBounds(), [])\n const [checkDate, setCheckDate] = useState<Date | null>(null)\n const [selectedIds, setSelectedIds] = useState<string[]>([])\n const [selection, setSelection] = useState<ContractorSelection | null>(null)\n\n let dateError: string | null = null\n if (checkDate !== null && checkDate > maxDate) {\n dateError = t('select.dateInFutureError')\n } else if (checkDate !== null && checkDate < minDate) {\n dateError = t('select.dateTooEarlyError', {\n year: checkDate.getFullYear(),\n allowedYear: minDate.getFullYear(),\n })\n }\n\n const canContinue = selectedIds.length > 0 && checkDate !== null && dateError === null\n\n const handleContinue = () => {\n if (!canContinue) return\n const checkDateString = formatDateToStringDate(checkDate)\n if (!checkDateString) return\n setSelection({ contractorIds: selectedIds, checkDate: checkDateString })\n }\n\n if (!selection) {\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Flex flexDirection=\"column\" gap={4}>\n <Heading as=\"h2\">{t('select.heading')}</Heading>\n <Text variant=\"supporting\">{t('select.subtitle')}</Text>\n </Flex>\n\n <DatePicker\n label={t('select.dateLabel')}\n isRequired\n value={checkDate}\n onChange={setCheckDate}\n minDate={minDate}\n maxDate={maxDate}\n isInvalid={dateError !== null}\n errorMessage={dateError ?? undefined}\n />\n\n <SelectContractors companyId={companyId} onSelectionChange={setSelectedIds} />\n\n <ActionsLayout>\n <Button onClick={handleContinue} variant=\"primary\" isDisabled={!canContinue}>\n {t('select.continueButton')}\n </Button>\n </ActionsLayout>\n </Flex>\n )\n }\n\n return (\n <AmountsAndReview\n companyId={companyId}\n contractorIds={selection.contractorIds}\n checkDate={selection.checkDate}\n onEvent={onEvent}\n />\n )\n}\n\ninterface AmountsAndReviewProps {\n companyId: string\n contractorIds: string[]\n checkDate: string\n onEvent: CreateHistoricalPaymentProps['onEvent']\n}\n\nfunction AmountsAndReview({ companyId, contractorIds, checkDate, onEvent }: AmountsAndReviewProps) {\n const { t } = useTranslation('Contractor.Payments.CreateHistoricalPayment')\n const { Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const { formatLongWithYear } = useDateFormatter()\n const paymentAmountsDictionary = useCreateHistoricalPaymentDictionary()\n const reviewDictionary = useCreateHistoricalPaymentReviewDictionary()\n\n const { data: contractorList } = useContractorsListSuspense({ companyUuid: companyId })\n const contractors = (contractorList.contractors ?? []).filter(contractor =>\n contractorIds.includes(contractor.uuid),\n )\n\n const { virtualContractorPayments, totals, editModal } = usePaymentAmountsEditor({\n contractors,\n allowedPaymentMethods: ALLOWED_PAYMENT_METHODS,\n onEditOpen: () => {\n onEvent(componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_EDIT)\n },\n onEditSave: data => {\n onEvent(componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_UPDATE, data)\n },\n })\n\n const canContinue = totals.total > 0\n\n const { mutateAsync: previewContractorPaymentGroup, isPending: isPreviewing } =\n useContractorPaymentGroupsPreviewMutation()\n const { mutateAsync: createContractorPaymentGroup, isPending: isCreating } =\n useContractorPaymentGroupsCreateMutation()\n\n const [previewData, setPreviewData] = useState<ContractorPaymentGroupPreview | null>(null)\n const [isCreated, setIsCreated] = useState(false)\n\n const touchedContractorPayments = () =>\n virtualContractorPayments\n .filter(payment => payment.isTouched)\n .map(({ isTouched: _isTouched, ...rest }) => rest)\n\n const handleContinue = async () => {\n if (!canContinue) return\n\n await baseSubmitHandler(null, async () => {\n const response = await previewContractorPaymentGroup({\n request: {\n companyId,\n requestBody: {\n checkDate: new RFCDate(checkDate),\n contractorPayments: touchedContractorPayments(),\n },\n },\n })\n setPreviewData(response.contractorPaymentGroupPreview || null)\n onEvent(\n componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_PREVIEW,\n response.contractorPaymentGroupPreview,\n )\n })\n }\n\n const handleBackToEdit = () => {\n setPreviewData(null)\n onEvent(componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_BACK_TO_EDIT)\n }\n\n const handleSubmit = async () => {\n const creationToken = previewData?.creationToken\n if (!creationToken || isCreated) return\n\n await baseSubmitHandler(null, async () => {\n const response = await createContractorPaymentGroup({\n request: {\n companyId,\n requestBody: {\n checkDate: new RFCDate(checkDate),\n creationToken,\n contractorPayments: touchedContractorPayments(),\n },\n },\n })\n\n if (!response.contractorPaymentGroup) return\n\n setIsCreated(true)\n onEvent(\n componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_CREATED,\n response.contractorPaymentGroup,\n )\n })\n }\n\n if (previewData) {\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Flex justifyContent=\"space-between\" alignItems=\"flex-start\" gap={16}>\n <Flex flexDirection=\"column\" gap={4}>\n <Heading as=\"h2\">{t('review.title')}</Heading>\n <Text variant=\"supporting\">\n {t('review.subtitle', {\n checkDate: formatLongWithYear(previewData.checkDate ?? ''),\n })}\n </Text>\n </Flex>\n {!isCreated && (\n <Flex justifyContent=\"flex-end\" gap={16}>\n <Button onClick={handleBackToEdit} variant=\"secondary\">\n {t('review.editButton')}\n </Button>\n <Button onClick={handleSubmit} variant=\"primary\" isLoading={isCreating}>\n {t('review.submitButton')}\n </Button>\n </Flex>\n )}\n </Flex>\n\n {isCreated && (\n <Alert status=\"success\" label={t('review.successTitle')}>\n <Text>{t('review.successMessage')}</Text>\n </Alert>\n )}\n\n <PaymentSummaryBlock\n contractorPaymentGroup={previewData}\n contractors={contractors}\n showDebitColumns={false}\n dictionary={reviewDictionary}\n />\n </Flex>\n )\n }\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Flex justifyContent=\"flex-end\" gap={16}>\n <Flex flexDirection=\"column\" gap={4}>\n <Heading as=\"h2\">{t('amounts.heading')}</Heading>\n <Text variant=\"supporting\">{t('amounts.subtitle')}</Text>\n </Flex>\n <FlexItem>\n <Button\n onClick={handleContinue}\n variant=\"primary\"\n isDisabled={!canContinue}\n isLoading={isPreviewing}\n >\n {t('amounts.continueButton')}\n </Button>\n </FlexItem>\n </Flex>\n\n <SetPaymentAmounts\n contractors={contractors}\n contractorPayments={virtualContractorPayments}\n totals={totals}\n allowedPaymentMethods={ALLOWED_PAYMENT_METHODS}\n editModal={editModal}\n dictionary={paymentAmountsDictionary}\n />\n </Flex>\n )\n}\n"],"names":["ALLOWED_PAYMENT_METHODS","CreateHistoricalPayment","props","jsx","BaseComponent","Root","companyId","dictionary","onEvent","useI18n","useComponentDictionary","t","useTranslation","Heading","Text","Button","DatePicker","useComponentContext","minDate","maxDate","useMemo","getHistoricalPaymentCheckDateBounds","checkDate","setCheckDate","useState","selectedIds","setSelectedIds","selection","setSelection","dateError","canContinue","handleContinue","checkDateString","formatDateToStringDate","AmountsAndReview","jsxs","Flex","SelectContractors","ActionsLayout","contractorIds","Alert","baseSubmitHandler","useBase","formatLongWithYear","useDateFormatter","paymentAmountsDictionary","useCreateHistoricalPaymentDictionary","reviewDictionary","useCreateHistoricalPaymentReviewDictionary","contractorList","useContractorsListSuspense","contractors","contractor","virtualContractorPayments","totals","editModal","usePaymentAmountsEditor","componentEvents","data","previewContractorPaymentGroup","isPreviewing","useContractorPaymentGroupsPreviewMutation","createContractorPaymentGroup","isCreating","useContractorPaymentGroupsCreateMutation","previewData","setPreviewData","isCreated","setIsCreated","touchedContractorPayments","payment","_isTouched","rest","response","RFCDate","handleBackToEdit","handleSubmit","creationToken","PaymentSummaryBlock","FlexItem","SetPaymentAmounts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,IAAqD,CAAC,oBAAoB;AA0CzE,SAASC,GAAwBC,GAAqC;AAC3E,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GAAO,eAAc,+CACtC,UAAA,gBAAAC,EAACE,IAAA,EAAM,GAAGH,EAAA,CAAO,EAAA,CACnB;AAEJ;AAOA,SAASG,GAAK,EAAE,WAAAC,GAAW,YAAAC,GAAY,SAAAC,KAAyC;AAC9E,EAAAC,GAAQ,6CAA6C,GACrDC,GAAuB,+CAA+CH,CAAU;AAChF,QAAM,EAAE,GAAAI,EAAA,IAAMC,EAAe,6CAA6C,GACpE,EAAE,SAAAC,GAAS,MAAAC,GAAM,QAAAC,GAAQ,YAAAC,EAAA,IAAeC,EAAA,GAExC,EAAE,SAAAC,GAAS,SAAAC,EAAA,IAAYC,EAAQ,MAAMC,EAAA,GAAuC,EAAE,GAC9E,CAACC,GAAWC,CAAY,IAAIC,EAAsB,IAAI,GACtD,CAACC,GAAaC,CAAc,IAAIF,EAAmB,CAAA,CAAE,GACrD,CAACG,GAAWC,CAAY,IAAIJ,EAAqC,IAAI;AAE3E,MAAIK,IAA2B;AAC/B,EAAIP,MAAc,QAAQA,IAAYH,IACpCU,IAAYlB,EAAE,0BAA0B,IAC/BW,MAAc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ACCoE,GAAA,EACC,UAAA,gBAAA5E;AAAA,QAACY;AAAA,QAAA;AAAA,UACC,SAASgB;AAAA,UACT,SAAQ;AAAA,UACR,YAAY,CAACD;AAAA,UACb,WAAW8B;AAAA,UAEV,YAAE,wBAAwB;AAAA,QAAA;AAAA,MAAA,EAC7B,CACF;AAAA,IAAA,GACF;AAAA,IAEA,gBAAAzD;AAAA,MAAC6E;AAAA,MAAA;AAAA,QACC,aAAA7B;AAAA,QACA,oBAAoBE;AAAA,QACpB,QAAAC;AAAA,QACA,uBAAuBtD;AAAA,QACvB,WAAAuD;AAAA,QACA,YAAYV;AAAA,MAAA;AAAA,IAAA;AAAA,EACd,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"CreateHistoricalPayment.js","sources":["../../../../../src/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.tsx"],"sourcesContent":["import { useContractorsListSuspense } from '@gusto/embedded-api/react-query/contractorsList'\nimport { useContractorPaymentGroupsPreviewMutation } from '@gusto/embedded-api/react-query/contractorPaymentGroupsPreview'\nimport { useContractorPaymentGroupsCreateMutation } from '@gusto/embedded-api/react-query/contractorPaymentGroupsCreate'\nimport type { ContractorPaymentGroupPreview } from '@gusto/embedded-api/models/components/contractorpaymentgrouppreview'\nimport type { PostV1CompaniesCompanyIdContractorPaymentGroupsPaymentMethod as ContractorPaymentMethod } from '@gusto/embedded-api/models/operations/postv1companiescompanyidcontractorpaymentgroups'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useMemo, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport {\n usePaymentAmountsEditor,\n type VirtualContractorPayment,\n} from '../shared/usePaymentAmountsEditor'\nimport { SetPaymentAmounts } from '../shared/SetPaymentAmounts'\nimport { PaymentSummaryBlock } from '../shared/PaymentSummaryBlock'\nimport { getHistoricalPaymentCheckDateBounds } from '../shared/historicalPaymentDateBounds'\nimport {\n useCreateHistoricalPaymentDictionary,\n useCreateHistoricalPaymentReviewDictionary,\n} from './useFormDictionary'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { ActionsLayout, Flex, FlexItem } from '@/components/Common'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport { componentEvents } from '@/shared/constants'\nimport { SelectContractors } from '@/components/Contractor/shared/SelectContractors/SelectContractors'\nimport CaretLeftIcon from '@/assets/icons/caret-left.svg?react'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\nconst ALLOWED_PAYMENT_METHODS: ContractorPaymentMethod[] = ['Historical Payment']\n\n/**\n * Props for {@link CreateHistoricalPayment}.\n *\n * @alpha\n */\nexport interface CreateHistoricalPaymentProps extends BaseComponentInterface<'Contractor.Payments.CreateHistoricalPayment'> {\n /** UUID of the company recording the historical payment. */\n companyId: string\n}\n\n/**\n * Records a historical contractor payment — one that already happened outside Gusto and does not\n * move money — by picking a paid date and the contractors being paid, entering hours, wages,\n * bonuses, and reimbursements for them, then reviewing and submitting.\n *\n * @remarks\n * Every contractor payment is fixed to the `Historical Payment` payment method, so there is no\n * payment method choice or debit information to review.\n * Continue on the contractor-selection step is disabled until the paid date is valid and at least\n * one contractor is selected. Continue on the amounts step is disabled until at least one selected\n * contractor has a payment total greater than zero, and swaps the amounts grid for an in-place\n * review (mirroring `CreatePayment`'s preview step); Back returns to the grid without losing\n * entered amounts, and Submit creates the contractor payment group. Once creation succeeds, the\n * Back and Submit buttons are replaced with a success message, since the creation token has been\n * consumed and the host is expected to navigate away (e.g. to `HistoricalPaymentSummary`).\n * The amounts step also has its own Back button, returning to contractor selection without losing\n * the selected paid date, contractors, or any amounts already entered.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/historicalPayments/edit` | The edit modal was opened for a contractor. | — |\n * | `contractor/historicalPayments/update` | A contractor's payment values were updated locally. | The updated form values (hours, wage, bonus, reimbursement, payment method, etc.). |\n * | `contractor/historicalPayments/preview` | The preview API call succeeded. | The contractor payment group preview response. |\n * | `contractor/historicalPayments/backToEdit` | The user returned from preview to continue editing. | — |\n * | `contractor/historicalPayments/created` | The payment group was successfully created. | The created contractor payment group response. |\n *\n * @param props - See {@link CreateHistoricalPaymentProps}.\n * @returns The rendered contractor-selection screen, the payment-amounts entry screen, or its\n * in-place review.\n * @alpha\n */\nexport function CreateHistoricalPayment(props: CreateHistoricalPaymentProps) {\n return (\n <BaseComponent {...props} componentName=\"Contractor.Payments.CreateHistoricalPayment\">\n <Root {...props} />\n </BaseComponent>\n )\n}\n\ninterface ContractorSelection {\n contractorIds: string[]\n checkDate: string\n}\n\nfunction Root({ companyId, dictionary, onEvent }: CreateHistoricalPaymentProps) {\n useUnstableFeature('historicalPayments', { throwIfDisabled: true })\n useI18n('Contractor.Payments.CreateHistoricalPayment')\n useComponentDictionary('Contractor.Payments.CreateHistoricalPayment', dictionary)\n const { t } = useTranslation('Contractor.Payments.CreateHistoricalPayment')\n const { Heading, Text, Button, DatePicker } = useComponentContext()\n\n const { minDate, maxDate } = useMemo(() => getHistoricalPaymentCheckDateBounds(), [])\n const [checkDate, setCheckDate] = useState<Date | null>(null)\n const [selectedIds, setSelectedIds] = useState<string[]>([])\n const [selection, setSelection] = useState<ContractorSelection | null>(null)\n const [savedContractorPayments, setSavedContractorPayments] = useState<\n VirtualContractorPayment[] | undefined\n >(undefined)\n\n let dateError: string | null = null\n if (checkDate !== null && checkDate > maxDate) {\n dateError = t('select.dateInFutureError')\n } else if (checkDate !== null && checkDate < minDate) {\n dateError = t('select.dateTooEarlyError', {\n year: checkDate.getFullYear(),\n allowedYear: minDate.getFullYear(),\n })\n }\n\n const canContinue = selectedIds.length > 0 && checkDate !== null && dateError === null\n\n const handleContinue = () => {\n if (!canContinue) return\n const checkDateString = formatDateToStringDate(checkDate)\n if (!checkDateString) return\n setSelection({ contractorIds: selectedIds, checkDate: checkDateString })\n }\n\n if (!selection) {\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Flex flexDirection=\"column\" gap={4}>\n <Heading as=\"h2\">{t('select.heading')}</Heading>\n <Text variant=\"supporting\">{t('select.subtitle')}</Text>\n </Flex>\n\n <DatePicker\n label={t('select.dateLabel')}\n isRequired\n value={checkDate}\n onChange={setCheckDate}\n minDate={minDate}\n maxDate={maxDate}\n isInvalid={dateError !== null}\n errorMessage={dateError ?? undefined}\n />\n\n <SelectContractors\n companyId={companyId}\n onSelectionChange={setSelectedIds}\n initialSelectedIds={selectedIds}\n />\n\n <ActionsLayout>\n <Button onClick={handleContinue} variant=\"primary\" isDisabled={!canContinue}>\n {t('select.continueButton')}\n </Button>\n </ActionsLayout>\n </Flex>\n )\n }\n\n return (\n <AmountsAndReview\n companyId={companyId}\n contractorIds={selection.contractorIds}\n checkDate={selection.checkDate}\n onEvent={onEvent}\n preservedContractorPayments={savedContractorPayments}\n onBack={payments => {\n setSavedContractorPayments(payments)\n setSelection(null)\n }}\n />\n )\n}\n\ninterface AmountsAndReviewProps {\n companyId: string\n contractorIds: string[]\n checkDate: string\n onEvent: CreateHistoricalPaymentProps['onEvent']\n preservedContractorPayments?: VirtualContractorPayment[]\n onBack: (payments: VirtualContractorPayment[]) => void\n}\n\nfunction AmountsAndReview({\n companyId,\n contractorIds,\n checkDate,\n onEvent,\n preservedContractorPayments,\n onBack,\n}: AmountsAndReviewProps) {\n const { t } = useTranslation('Contractor.Payments.CreateHistoricalPayment')\n const { Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const { formatLongWithYear } = useDateFormatter()\n const paymentAmountsDictionary = useCreateHistoricalPaymentDictionary()\n const reviewDictionary = useCreateHistoricalPaymentReviewDictionary()\n\n const { data: contractorList } = useContractorsListSuspense({ companyUuid: companyId })\n const contractors = (contractorList.contractors ?? []).filter(contractor =>\n contractorIds.includes(contractor.uuid),\n )\n\n const { virtualContractorPayments, totals, editModal } = usePaymentAmountsEditor({\n contractors,\n allowedPaymentMethods: ALLOWED_PAYMENT_METHODS,\n preservedContractorPayments,\n onEditOpen: () => {\n onEvent(componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_EDIT)\n },\n onEditSave: data => {\n onEvent(componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_UPDATE, data)\n },\n })\n\n const canContinue = totals.total > 0\n\n const { mutateAsync: previewContractorPaymentGroup, isPending: isPreviewing } =\n useContractorPaymentGroupsPreviewMutation()\n const { mutateAsync: createContractorPaymentGroup, isPending: isCreating } =\n useContractorPaymentGroupsCreateMutation()\n\n const [previewData, setPreviewData] = useState<ContractorPaymentGroupPreview | null>(null)\n const [isCreated, setIsCreated] = useState(false)\n\n const touchedContractorPayments = () =>\n virtualContractorPayments\n .filter(payment => payment.isTouched)\n .map(({ isTouched: _isTouched, ...rest }) => rest)\n\n const handleContinue = async () => {\n if (!canContinue) return\n\n await baseSubmitHandler(null, async () => {\n const response = await previewContractorPaymentGroup({\n request: {\n companyId,\n requestBody: {\n checkDate: new RFCDate(checkDate),\n contractorPayments: touchedContractorPayments(),\n },\n },\n })\n setPreviewData(response.contractorPaymentGroupPreview || null)\n onEvent(\n componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_PREVIEW,\n response.contractorPaymentGroupPreview,\n )\n })\n }\n\n const handleBackToEdit = () => {\n setPreviewData(null)\n onEvent(componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_BACK_TO_EDIT)\n }\n\n const handleSubmit = async () => {\n const creationToken = previewData?.creationToken\n if (!creationToken || isCreated) return\n\n await baseSubmitHandler(null, async () => {\n const response = await createContractorPaymentGroup({\n request: {\n companyId,\n requestBody: {\n checkDate: new RFCDate(checkDate),\n creationToken,\n contractorPayments: touchedContractorPayments(),\n },\n },\n })\n\n if (!response.contractorPaymentGroup) return\n\n setIsCreated(true)\n onEvent(\n componentEvents.CONTRACTOR_HISTORICAL_PAYMENT_CREATED,\n response.contractorPaymentGroup,\n )\n })\n }\n\n if (previewData) {\n return (\n <Flex flexDirection=\"column\" gap={32}>\n {!isCreated && <BackButton onClick={handleBackToEdit} />}\n\n <Flex justifyContent=\"space-between\" alignItems=\"flex-start\" gap={16}>\n <Flex flexDirection=\"column\" gap={4}>\n <Heading as=\"h2\">{t('review.title')}</Heading>\n <Text variant=\"supporting\">\n {t('review.subtitle', {\n checkDate: formatLongWithYear(previewData.checkDate ?? ''),\n })}\n </Text>\n </Flex>\n {!isCreated && (\n <Button onClick={handleSubmit} variant=\"primary\" isLoading={isCreating}>\n {t('review.submitButton')}\n </Button>\n )}\n </Flex>\n\n {isCreated && (\n <Alert status=\"success\" label={t('review.successTitle')}>\n <Text>{t('review.successMessage')}</Text>\n </Alert>\n )}\n\n <PaymentSummaryBlock\n contractorPaymentGroup={previewData}\n contractors={contractors}\n showDebitColumns={false}\n dictionary={reviewDictionary}\n />\n </Flex>\n )\n }\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <BackButton\n onClick={() => {\n onBack(virtualContractorPayments)\n }}\n />\n\n <Flex justifyContent=\"flex-end\" gap={16}>\n <Flex flexDirection=\"column\" gap={4}>\n <Heading as=\"h2\">{t('amounts.heading')}</Heading>\n <Text variant=\"supporting\">{t('amounts.subtitle')}</Text>\n </Flex>\n <FlexItem>\n <Button\n onClick={handleContinue}\n variant=\"primary\"\n isDisabled={!canContinue}\n isLoading={isPreviewing}\n >\n {t('amounts.continueButton')}\n </Button>\n </FlexItem>\n </Flex>\n\n <SetPaymentAmounts\n contractors={contractors}\n contractorPayments={virtualContractorPayments}\n totals={totals}\n allowedPaymentMethods={ALLOWED_PAYMENT_METHODS}\n editModal={editModal}\n dictionary={paymentAmountsDictionary}\n />\n </Flex>\n )\n}\n\nfunction BackButton({ onClick }: { onClick: () => void }) {\n const { t } = useTranslation('Contractor.Payments.CreateHistoricalPayment')\n const { Button } = useComponentContext()\n\n return (\n <Button variant=\"secondary\" icon={<CaretLeftIcon aria-hidden=\"true\" />} onClick={onClick}>\n {t('backButton')}\n </Button>\n )\n}\n"],"names":["ALLOWED_PAYMENT_METHODS","CreateHistoricalPayment","props","jsx","BaseComponent","Root","companyId","dictionary","onEvent","useUnstableFeature","useI18n","useComponentDictionary","t","useTranslation","Heading","Text","Button","DatePicker","useComponentContext","minDate","maxDate","useMemo","getHistoricalPaymentCheckDateBounds","checkDate","setCheckDate","useState","selectedIds","setSelectedIds","selection","setSelection","savedContractorPayments","setSavedContractorPayments","dateError","canContinue","handleContinue","checkDateString","formatDateToStringDate","AmountsAndReview","payments","jsxs","Flex","SelectContractors","ActionsLayout","contractorIds","preservedContractorPayments","onBack","Alert","baseSubmitHandler","useBase","formatLongWithYear","useDateFormatter","paymentAmountsDictionary","useCreateHistoricalPaymentDictionary","reviewDictionary","useCreateHistoricalPaymentReviewDictionary","contractorList","useContractorsListSuspense","contractors","contractor","virtualContractorPayments","totals","editModal","usePaymentAmountsEditor","componentEvents","data","previewContractorPaymentGroup","isPreviewing","useContractorPaymentGroupsPreviewMutation","createContractorPaymentGroup","isCreating","useContractorPaymentGroupsCreateMutation","previewData","setPreviewData","isCreated","setIsCreated","touchedContractorPayments","payment","_isTouched","rest","response","RFCDate","handleBackToEdit","handleSubmit","creationToken","BackButton","PaymentSummaryBlock","FlexItem","SetPaymentAmounts","onClick","CaretLeftIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,IAAqD,CAAC,oBAAoB;AA4CzE,SAASC,GAAwBC,GAAqC;AAC3E,SACE,gBAAAC,EAACC,IAAA,EAAe,GAAGF,GAAO,eAAc,+CACtC,UAAA,gBAAAC,EAACE,IAAA,EAAM,GAAGH,EAAA,CAAO,EAAA,CACnB;AAEJ;AAOA,SAASG,GAAK,EAAE,WAAAC,GAAW,YAAAC,GAAY,SAAAC,KAAyC;AAC9E,EAAAC,GAAmB,sBAAsB,EAAE,iBAAiB,GAAA,CAAM,GAClEC,GAAQ,6CAA6C,GACrDC,G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