@dmsi/wedgekit-react 0.0.98 → 0.0.100
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/dist/{chunk-Z7OYI7ZH.js → chunk-66CBCMDU.js} +3 -2
- package/dist/chunk-RVQEW4A4.js +96 -0
- package/dist/components/PaymentOnAccountModal.cjs +42 -5
- package/dist/components/PaymentOnAccountModal.js +6 -4
- package/dist/components/SelectPaymentMethod.cjs +3 -2
- package/dist/components/SelectPaymentMethod.js +1 -1
- package/dist/components/index.cjs +39 -4
- package/dist/components/index.js +3 -3
- package/package.json +1 -1
- package/src/components/DataGrid/PinnedColumns.tsx +1 -1
- package/src/components/PaymentOnAccountModal.tsx +50 -2
- package/src/components/SelectPaymentMethod.tsx +5 -2
- package/dist/chunk-A4XOUWM5.js +0 -57
|
@@ -47,13 +47,14 @@ function SelectPaymentMethod(props) {
|
|
|
47
47
|
setSelectedACHBankGuid,
|
|
48
48
|
customerBanks,
|
|
49
49
|
onPay,
|
|
50
|
-
isPayLoading
|
|
50
|
+
isPayLoading,
|
|
51
|
+
withCredits = false
|
|
51
52
|
} = props;
|
|
52
53
|
function handleToggle(method) {
|
|
53
54
|
onSelectMethod(method);
|
|
54
55
|
}
|
|
55
56
|
return /* @__PURE__ */ jsxs(Stack, { sizing: "layout-group", width: "full", minWidth: 400, children: [
|
|
56
|
-
!!(allCredits == null ? void 0 : allCredits.length) && /* @__PURE__ */ jsx(
|
|
57
|
+
!!(allCredits == null ? void 0 : allCredits.length) && withCredits && /* @__PURE__ */ jsx(
|
|
57
58
|
CreditsSelector,
|
|
58
59
|
{
|
|
59
60
|
selectedCredits: selectedCredits || [],
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SelectPaymentMethod
|
|
3
|
+
} from "./chunk-66CBCMDU.js";
|
|
4
|
+
import {
|
|
5
|
+
Modal
|
|
6
|
+
} from "./chunk-QIHDPSOM.js";
|
|
7
|
+
import {
|
|
8
|
+
Input
|
|
9
|
+
} from "./chunk-R5TLUWDD.js";
|
|
10
|
+
import {
|
|
11
|
+
formatCurrencyDisplay
|
|
12
|
+
} from "./chunk-5UH6QUFB.js";
|
|
13
|
+
import {
|
|
14
|
+
Stack
|
|
15
|
+
} from "./chunk-EO3JJWFW.js";
|
|
16
|
+
import {
|
|
17
|
+
Card
|
|
18
|
+
} from "./chunk-JOMM4KBH.js";
|
|
19
|
+
import {
|
|
20
|
+
Paragraph
|
|
21
|
+
} from "./chunk-VG4EPHJA.js";
|
|
22
|
+
import {
|
|
23
|
+
__spreadProps,
|
|
24
|
+
__spreadValues
|
|
25
|
+
} from "./chunk-ORMEWXMH.js";
|
|
26
|
+
|
|
27
|
+
// src/components/PaymentOnAccountModal.tsx
|
|
28
|
+
import { useEffect, useMemo, useState } from "react";
|
|
29
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
+
function PaymentOnAccountModal(props) {
|
|
31
|
+
const { isOpen, paymentProps, onClose } = props;
|
|
32
|
+
const [amount, setAmount] = useState(paymentProps.amountToPay);
|
|
33
|
+
const { creditCardSettings, selectedMethod } = paymentProps;
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setAmount(paymentProps.amountToPay);
|
|
36
|
+
}, [paymentProps.amountToPay]);
|
|
37
|
+
function handleAmountChange(event) {
|
|
38
|
+
const value = event.target.value.replace(/[^0-9.-]+/g, "");
|
|
39
|
+
setAmount(+value || 0);
|
|
40
|
+
}
|
|
41
|
+
const creditCardSurcharge = useMemo(() => {
|
|
42
|
+
const applySurcharge = (creditCardSettings == null ? void 0 : creditCardSettings.ApplySurcharge) || false;
|
|
43
|
+
if (!applySurcharge || selectedMethod !== "CCPayment") {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const surchargeType = creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisType;
|
|
47
|
+
const surchargeRate = (creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisAmount) || 0;
|
|
48
|
+
if (surchargeType === "Percent") {
|
|
49
|
+
return calculateSurcharge(amount, surchargeRate);
|
|
50
|
+
}
|
|
51
|
+
if (surchargeType === "Fixed") {
|
|
52
|
+
return surchargeRate;
|
|
53
|
+
}
|
|
54
|
+
return 0;
|
|
55
|
+
}, [creditCardSettings, amount, selectedMethod]);
|
|
56
|
+
return /* @__PURE__ */ jsx(Modal, { open: isOpen, onClose, title: "Payment on Account", children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout-group", width: "full", children: [
|
|
57
|
+
selectedMethod === "CCPayment" && /* @__PURE__ */ jsxs(Stack, { horizontal: true, justify: "between", items: "center", children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Paragraph, { children: "Surcharge" }),
|
|
59
|
+
/* @__PURE__ */ jsxs(Paragraph, { children: [
|
|
60
|
+
"$",
|
|
61
|
+
formatCurrencyDisplay(creditCardSurcharge.toFixed(2))
|
|
62
|
+
] })
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ jsx(Card, { className: "py-desktop-component-padding", children: /* @__PURE__ */ jsxs(Stack, { sizing: "component", justify: "between", items: "center", horizontal: true, children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Paragraph, { className: "w-full", children: "Amount to Pay" }),
|
|
66
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
67
|
+
Input,
|
|
68
|
+
{
|
|
69
|
+
type: "number",
|
|
70
|
+
placeholder: "$0.00",
|
|
71
|
+
align: "right",
|
|
72
|
+
value: amount === 0 ? "" : amount,
|
|
73
|
+
onChange: handleAmountChange,
|
|
74
|
+
before: "$"
|
|
75
|
+
}
|
|
76
|
+
) })
|
|
77
|
+
] }) }),
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
SelectPaymentMethod,
|
|
80
|
+
__spreadProps(__spreadValues({}, paymentProps), {
|
|
81
|
+
amountToPay: amount + creditCardSurcharge
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
] }) });
|
|
85
|
+
}
|
|
86
|
+
function calculateSurcharge(amountInDollars, surchargeRate) {
|
|
87
|
+
const amountInCents = amountInDollars * 100;
|
|
88
|
+
const surchargeInCents = amountInCents * surchargeRate / 100;
|
|
89
|
+
const roundedSurchargeInCents = Math.round(surchargeInCents);
|
|
90
|
+
return roundedSurchargeInCents / 100;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
PaymentOnAccountModal,
|
|
95
|
+
calculateSurcharge
|
|
96
|
+
};
|
|
@@ -59,7 +59,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
59
59
|
// src/components/PaymentOnAccountModal.tsx
|
|
60
60
|
var PaymentOnAccountModal_exports = {};
|
|
61
61
|
__export(PaymentOnAccountModal_exports, {
|
|
62
|
-
PaymentOnAccountModal: () => PaymentOnAccountModal
|
|
62
|
+
PaymentOnAccountModal: () => PaymentOnAccountModal,
|
|
63
|
+
calculateSurcharge: () => calculateSurcharge
|
|
63
64
|
});
|
|
64
65
|
module.exports = __toCommonJS(PaymentOnAccountModal_exports);
|
|
65
66
|
|
|
@@ -1915,13 +1916,14 @@ function SelectPaymentMethod(props) {
|
|
|
1915
1916
|
setSelectedACHBankGuid,
|
|
1916
1917
|
customerBanks,
|
|
1917
1918
|
onPay,
|
|
1918
|
-
isPayLoading
|
|
1919
|
+
isPayLoading,
|
|
1920
|
+
withCredits = false
|
|
1919
1921
|
} = props;
|
|
1920
1922
|
function handleToggle(method) {
|
|
1921
1923
|
onSelectMethod(method);
|
|
1922
1924
|
}
|
|
1923
1925
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Stack, { sizing: "layout-group", width: "full", minWidth: 400, children: [
|
|
1924
|
-
!!(allCredits == null ? void 0 : allCredits.length) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1926
|
+
!!(allCredits == null ? void 0 : allCredits.length) && withCredits && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1925
1927
|
CreditsSelector,
|
|
1926
1928
|
{
|
|
1927
1929
|
selectedCredits: selectedCredits || [],
|
|
@@ -2103,6 +2105,7 @@ var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
|
2103
2105
|
function PaymentOnAccountModal(props) {
|
|
2104
2106
|
const { isOpen, paymentProps, onClose } = props;
|
|
2105
2107
|
const [amount, setAmount] = (0, import_react8.useState)(paymentProps.amountToPay);
|
|
2108
|
+
const { creditCardSettings, selectedMethod } = paymentProps;
|
|
2106
2109
|
(0, import_react8.useEffect)(() => {
|
|
2107
2110
|
setAmount(paymentProps.amountToPay);
|
|
2108
2111
|
}, [paymentProps.amountToPay]);
|
|
@@ -2110,7 +2113,29 @@ function PaymentOnAccountModal(props) {
|
|
|
2110
2113
|
const value = event.target.value.replace(/[^0-9.-]+/g, "");
|
|
2111
2114
|
setAmount(+value || 0);
|
|
2112
2115
|
}
|
|
2116
|
+
const creditCardSurcharge = (0, import_react8.useMemo)(() => {
|
|
2117
|
+
const applySurcharge = (creditCardSettings == null ? void 0 : creditCardSettings.ApplySurcharge) || false;
|
|
2118
|
+
if (!applySurcharge || selectedMethod !== "CCPayment") {
|
|
2119
|
+
return 0;
|
|
2120
|
+
}
|
|
2121
|
+
const surchargeType = creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisType;
|
|
2122
|
+
const surchargeRate = (creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisAmount) || 0;
|
|
2123
|
+
if (surchargeType === "Percent") {
|
|
2124
|
+
return calculateSurcharge(amount, surchargeRate);
|
|
2125
|
+
}
|
|
2126
|
+
if (surchargeType === "Fixed") {
|
|
2127
|
+
return surchargeRate;
|
|
2128
|
+
}
|
|
2129
|
+
return 0;
|
|
2130
|
+
}, [creditCardSettings, amount, selectedMethod]);
|
|
2113
2131
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Modal, { open: isOpen, onClose, title: "Payment on Account", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Stack, { sizing: "layout-group", width: "full", children: [
|
|
2132
|
+
selectedMethod === "CCPayment" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Stack, { horizontal: true, justify: "between", items: "center", children: [
|
|
2133
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Paragraph, { children: "Surcharge" }),
|
|
2134
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Paragraph, { children: [
|
|
2135
|
+
"$",
|
|
2136
|
+
formatCurrencyDisplay(creditCardSurcharge.toFixed(2))
|
|
2137
|
+
] })
|
|
2138
|
+
] }),
|
|
2114
2139
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Card, { className: "py-desktop-component-padding", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Stack, { sizing: "component", justify: "between", items: "center", horizontal: true, children: [
|
|
2115
2140
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Paragraph, { className: "w-full", children: "Amount to Pay" }),
|
|
2116
2141
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
@@ -2125,10 +2150,22 @@ function PaymentOnAccountModal(props) {
|
|
|
2125
2150
|
}
|
|
2126
2151
|
) })
|
|
2127
2152
|
] }) }),
|
|
2128
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2153
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2154
|
+
SelectPaymentMethod,
|
|
2155
|
+
__spreadProps(__spreadValues({}, paymentProps), {
|
|
2156
|
+
amountToPay: amount + creditCardSurcharge
|
|
2157
|
+
})
|
|
2158
|
+
)
|
|
2129
2159
|
] }) });
|
|
2130
2160
|
}
|
|
2161
|
+
function calculateSurcharge(amountInDollars, surchargeRate) {
|
|
2162
|
+
const amountInCents = amountInDollars * 100;
|
|
2163
|
+
const surchargeInCents = amountInCents * surchargeRate / 100;
|
|
2164
|
+
const roundedSurchargeInCents = Math.round(surchargeInCents);
|
|
2165
|
+
return roundedSurchargeInCents / 100;
|
|
2166
|
+
}
|
|
2131
2167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2132
2168
|
0 && (module.exports = {
|
|
2133
|
-
PaymentOnAccountModal
|
|
2169
|
+
PaymentOnAccountModal,
|
|
2170
|
+
calculateSurcharge
|
|
2134
2171
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
PaymentOnAccountModal
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
PaymentOnAccountModal,
|
|
3
|
+
calculateSurcharge
|
|
4
|
+
} from "../chunk-RVQEW4A4.js";
|
|
5
|
+
import "../chunk-66CBCMDU.js";
|
|
5
6
|
import "../chunk-TTO4PL7Y.js";
|
|
6
7
|
import "../chunk-QIHDPSOM.js";
|
|
7
8
|
import "../chunk-4RJKB7LC.js";
|
|
@@ -27,5 +28,6 @@ import "../chunk-IGQVA7SC.js";
|
|
|
27
28
|
import "../chunk-RDLEIAQU.js";
|
|
28
29
|
import "../chunk-ORMEWXMH.js";
|
|
29
30
|
export {
|
|
30
|
-
PaymentOnAccountModal
|
|
31
|
+
PaymentOnAccountModal,
|
|
32
|
+
calculateSurcharge
|
|
31
33
|
};
|
|
@@ -984,13 +984,14 @@ function SelectPaymentMethod(props) {
|
|
|
984
984
|
setSelectedACHBankGuid,
|
|
985
985
|
customerBanks,
|
|
986
986
|
onPay,
|
|
987
|
-
isPayLoading
|
|
987
|
+
isPayLoading,
|
|
988
|
+
withCredits = false
|
|
988
989
|
} = props;
|
|
989
990
|
function handleToggle(method) {
|
|
990
991
|
onSelectMethod(method);
|
|
991
992
|
}
|
|
992
993
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Stack, { sizing: "layout-group", width: "full", minWidth: 400, children: [
|
|
993
|
-
!!(allCredits == null ? void 0 : allCredits.length) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
994
|
+
!!(allCredits == null ? void 0 : allCredits.length) && withCredits && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
994
995
|
CreditsSelector,
|
|
995
996
|
{
|
|
996
997
|
selectedCredits: selectedCredits || [],
|
|
@@ -2424,7 +2424,7 @@ function PinnedColumns(_a) {
|
|
|
2424
2424
|
"table",
|
|
2425
2425
|
{
|
|
2426
2426
|
className: (0, import_clsx12.default)(
|
|
2427
|
-
"flex flex-col min-h-min sticky z-20
|
|
2427
|
+
"flex flex-col min-h-min sticky z-20",
|
|
2428
2428
|
pinDirection === "left" ? "left-0" : "right-0"
|
|
2429
2429
|
),
|
|
2430
2430
|
children: [
|
|
@@ -4435,13 +4435,14 @@ function SelectPaymentMethod(props) {
|
|
|
4435
4435
|
setSelectedACHBankGuid,
|
|
4436
4436
|
customerBanks,
|
|
4437
4437
|
onPay,
|
|
4438
|
-
isPayLoading
|
|
4438
|
+
isPayLoading,
|
|
4439
|
+
withCredits = false
|
|
4439
4440
|
} = props;
|
|
4440
4441
|
function handleToggle(method) {
|
|
4441
4442
|
onSelectMethod(method);
|
|
4442
4443
|
}
|
|
4443
4444
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Stack, { sizing: "layout-group", width: "full", minWidth: 400, children: [
|
|
4444
|
-
!!(allCredits == null ? void 0 : allCredits.length) && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4445
|
+
!!(allCredits == null ? void 0 : allCredits.length) && withCredits && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4445
4446
|
CreditsSelector,
|
|
4446
4447
|
{
|
|
4447
4448
|
selectedCredits: selectedCredits || [],
|
|
@@ -4623,6 +4624,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
4623
4624
|
function PaymentOnAccountModal(props) {
|
|
4624
4625
|
const { isOpen, paymentProps, onClose } = props;
|
|
4625
4626
|
const [amount, setAmount] = (0, import_react21.useState)(paymentProps.amountToPay);
|
|
4627
|
+
const { creditCardSettings, selectedMethod } = paymentProps;
|
|
4626
4628
|
(0, import_react21.useEffect)(() => {
|
|
4627
4629
|
setAmount(paymentProps.amountToPay);
|
|
4628
4630
|
}, [paymentProps.amountToPay]);
|
|
@@ -4630,7 +4632,29 @@ function PaymentOnAccountModal(props) {
|
|
|
4630
4632
|
const value = event.target.value.replace(/[^0-9.-]+/g, "");
|
|
4631
4633
|
setAmount(+value || 0);
|
|
4632
4634
|
}
|
|
4635
|
+
const creditCardSurcharge = (0, import_react21.useMemo)(() => {
|
|
4636
|
+
const applySurcharge = (creditCardSettings == null ? void 0 : creditCardSettings.ApplySurcharge) || false;
|
|
4637
|
+
if (!applySurcharge || selectedMethod !== "CCPayment") {
|
|
4638
|
+
return 0;
|
|
4639
|
+
}
|
|
4640
|
+
const surchargeType = creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisType;
|
|
4641
|
+
const surchargeRate = (creditCardSettings == null ? void 0 : creditCardSettings.SurchargeBasisAmount) || 0;
|
|
4642
|
+
if (surchargeType === "Percent") {
|
|
4643
|
+
return calculateSurcharge(amount, surchargeRate);
|
|
4644
|
+
}
|
|
4645
|
+
if (surchargeType === "Fixed") {
|
|
4646
|
+
return surchargeRate;
|
|
4647
|
+
}
|
|
4648
|
+
return 0;
|
|
4649
|
+
}, [creditCardSettings, amount, selectedMethod]);
|
|
4633
4650
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Modal, { open: isOpen, onClose, title: "Payment on Account", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Stack, { sizing: "layout-group", width: "full", children: [
|
|
4651
|
+
selectedMethod === "CCPayment" && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Stack, { horizontal: true, justify: "between", items: "center", children: [
|
|
4652
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Paragraph, { children: "Surcharge" }),
|
|
4653
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Paragraph, { children: [
|
|
4654
|
+
"$",
|
|
4655
|
+
formatCurrencyDisplay(creditCardSurcharge.toFixed(2))
|
|
4656
|
+
] })
|
|
4657
|
+
] }),
|
|
4634
4658
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Card, { className: "py-desktop-component-padding", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Stack, { sizing: "component", justify: "between", items: "center", horizontal: true, children: [
|
|
4635
4659
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Paragraph, { className: "w-full", children: "Amount to Pay" }),
|
|
4636
4660
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
@@ -4645,9 +4669,20 @@ function PaymentOnAccountModal(props) {
|
|
|
4645
4669
|
}
|
|
4646
4670
|
) })
|
|
4647
4671
|
] }) }),
|
|
4648
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4672
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4673
|
+
SelectPaymentMethod,
|
|
4674
|
+
__spreadProps(__spreadValues({}, paymentProps), {
|
|
4675
|
+
amountToPay: amount + creditCardSurcharge
|
|
4676
|
+
})
|
|
4677
|
+
)
|
|
4649
4678
|
] }) });
|
|
4650
4679
|
}
|
|
4680
|
+
function calculateSurcharge(amountInDollars, surchargeRate) {
|
|
4681
|
+
const amountInCents = amountInDollars * 100;
|
|
4682
|
+
const surchargeInCents = amountInCents * surchargeRate / 100;
|
|
4683
|
+
const roundedSurchargeInCents = Math.round(surchargeInCents);
|
|
4684
|
+
return roundedSurchargeInCents / 100;
|
|
4685
|
+
}
|
|
4651
4686
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4652
4687
|
0 && (module.exports = {
|
|
4653
4688
|
Accordion,
|
package/dist/components/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "../chunk-Y4HUYAI5.js";
|
|
7
7
|
import {
|
|
8
8
|
PaymentOnAccountModal
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-RVQEW4A4.js";
|
|
10
|
+
import "../chunk-66CBCMDU.js";
|
|
11
11
|
import "../chunk-TTO4PL7Y.js";
|
|
12
12
|
import "../chunk-QIHDPSOM.js";
|
|
13
13
|
import "../chunk-4RJKB7LC.js";
|
|
@@ -403,7 +403,7 @@ function PinnedColumns(_a) {
|
|
|
403
403
|
"table",
|
|
404
404
|
{
|
|
405
405
|
className: clsx4(
|
|
406
|
-
"flex flex-col min-h-min sticky z-20
|
|
406
|
+
"flex flex-col min-h-min sticky z-20",
|
|
407
407
|
pinDirection === "left" ? "left-0" : "right-0"
|
|
408
408
|
),
|
|
409
409
|
children: [
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ export function PinnedColumns<TData>({
|
|
|
38
38
|
headerGroups[0]?.headers.length > 0 && (
|
|
39
39
|
<table
|
|
40
40
|
className={clsx(
|
|
41
|
-
"flex flex-col min-h-min sticky z-20
|
|
41
|
+
"flex flex-col min-h-min sticky z-20",
|
|
42
42
|
pinDirection === "left" ? "left-0" : "right-0",
|
|
43
43
|
)}
|
|
44
44
|
>
|
|
@@ -3,11 +3,12 @@ import { Stack } from "./Stack";
|
|
|
3
3
|
import { Paragraph } from "./Paragraph";
|
|
4
4
|
import { Input } from "./Input";
|
|
5
5
|
import { Card } from "./Card";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
6
|
+
import { useEffect, useMemo, useState } from "react";
|
|
7
7
|
import {
|
|
8
8
|
SelectPaymentMethod,
|
|
9
9
|
SelectPaymentMethodProps,
|
|
10
10
|
} from "./SelectPaymentMethod";
|
|
11
|
+
import { formatCurrencyDisplay } from "../utils/formatting";
|
|
11
12
|
|
|
12
13
|
type PaymentOnAccountModalProps = {
|
|
13
14
|
isOpen: boolean;
|
|
@@ -17,6 +18,14 @@ type PaymentOnAccountModalProps = {
|
|
|
17
18
|
export function PaymentOnAccountModal(props: PaymentOnAccountModalProps) {
|
|
18
19
|
const { isOpen, paymentProps, onClose } = props;
|
|
19
20
|
const [amount, setAmount] = useState<number>(paymentProps.amountToPay);
|
|
21
|
+
const { creditCardSettings, selectedMethod } =
|
|
22
|
+
paymentProps as typeof paymentProps & {
|
|
23
|
+
creditCardSettings: {
|
|
24
|
+
ApplySurcharge: boolean;
|
|
25
|
+
SurchargeBasisType: string;
|
|
26
|
+
SurchargeBasisAmount: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
20
29
|
|
|
21
30
|
useEffect(() => {
|
|
22
31
|
setAmount(paymentProps.amountToPay);
|
|
@@ -27,9 +36,34 @@ export function PaymentOnAccountModal(props: PaymentOnAccountModalProps) {
|
|
|
27
36
|
setAmount(+value || 0);
|
|
28
37
|
}
|
|
29
38
|
|
|
39
|
+
const creditCardSurcharge = useMemo(() => {
|
|
40
|
+
const applySurcharge = creditCardSettings?.ApplySurcharge || false;
|
|
41
|
+
if (!applySurcharge || selectedMethod !== "CCPayment") {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
const surchargeType = creditCardSettings?.SurchargeBasisType;
|
|
45
|
+
const surchargeRate = creditCardSettings?.SurchargeBasisAmount || 0;
|
|
46
|
+
|
|
47
|
+
if (surchargeType === "Percent") {
|
|
48
|
+
return calculateSurcharge(amount, surchargeRate);
|
|
49
|
+
}
|
|
50
|
+
if (surchargeType === "Fixed") {
|
|
51
|
+
return surchargeRate;
|
|
52
|
+
}
|
|
53
|
+
return 0;
|
|
54
|
+
}, [creditCardSettings, amount, selectedMethod]);
|
|
55
|
+
|
|
30
56
|
return (
|
|
31
57
|
<Modal open={isOpen} onClose={onClose} title="Payment on Account">
|
|
32
58
|
<Stack sizing="layout-group" width="full">
|
|
59
|
+
{selectedMethod === "CCPayment" && (
|
|
60
|
+
<Stack horizontal justify="between" items="center">
|
|
61
|
+
<Paragraph>Surcharge</Paragraph>
|
|
62
|
+
<Paragraph>
|
|
63
|
+
${formatCurrencyDisplay(creditCardSurcharge.toFixed(2))}
|
|
64
|
+
</Paragraph>
|
|
65
|
+
</Stack>
|
|
66
|
+
)}
|
|
33
67
|
<Card className="py-desktop-component-padding">
|
|
34
68
|
<Stack sizing="component" justify="between" items="center" horizontal>
|
|
35
69
|
<Paragraph className="w-full">Amount to Pay</Paragraph>
|
|
@@ -45,8 +79,22 @@ export function PaymentOnAccountModal(props: PaymentOnAccountModalProps) {
|
|
|
45
79
|
</div>
|
|
46
80
|
</Stack>
|
|
47
81
|
</Card>
|
|
48
|
-
<SelectPaymentMethod
|
|
82
|
+
<SelectPaymentMethod
|
|
83
|
+
{...paymentProps}
|
|
84
|
+
amountToPay={amount + creditCardSurcharge}
|
|
85
|
+
/>
|
|
49
86
|
</Stack>
|
|
50
87
|
</Modal>
|
|
51
88
|
);
|
|
52
89
|
}
|
|
90
|
+
|
|
91
|
+
export function calculateSurcharge(
|
|
92
|
+
amountInDollars: number,
|
|
93
|
+
surchargeRate: number,
|
|
94
|
+
): number {
|
|
95
|
+
const amountInCents = amountInDollars * 100;
|
|
96
|
+
const surchargeInCents = (amountInCents * surchargeRate) / 100;
|
|
97
|
+
const roundedSurchargeInCents = Math.round(surchargeInCents);
|
|
98
|
+
|
|
99
|
+
return roundedSurchargeInCents / 100;
|
|
100
|
+
}
|
|
@@ -32,9 +32,11 @@ export type SelectPaymentMethodProps = {
|
|
|
32
32
|
isPayLoading?: boolean;
|
|
33
33
|
selectedInvoices?: unknown[];
|
|
34
34
|
allInvoices?: unknown[];
|
|
35
|
+
creditCardSettings?: unknown;
|
|
36
|
+
withCredits?: boolean;
|
|
35
37
|
|
|
36
38
|
onSelectMethod: (method: PaymentMethodType | null) => void;
|
|
37
|
-
onPay
|
|
39
|
+
onPay: () => void;
|
|
38
40
|
setSelectedCredits?: React.Dispatch<React.SetStateAction<unknown[]>>;
|
|
39
41
|
setSelectedACHBankGuid?: (guid: string | null) => void;
|
|
40
42
|
};
|
|
@@ -51,6 +53,7 @@ export function SelectPaymentMethod(props: SelectPaymentMethodProps) {
|
|
|
51
53
|
customerBanks,
|
|
52
54
|
onPay,
|
|
53
55
|
isPayLoading,
|
|
56
|
+
withCredits = false,
|
|
54
57
|
} = props;
|
|
55
58
|
|
|
56
59
|
function handleToggle(method: PaymentMethodType | null) {
|
|
@@ -58,7 +61,7 @@ export function SelectPaymentMethod(props: SelectPaymentMethodProps) {
|
|
|
58
61
|
}
|
|
59
62
|
return (
|
|
60
63
|
<Stack sizing="layout-group" width="full" minWidth={400}>
|
|
61
|
-
{!!allCredits?.length && (
|
|
64
|
+
{!!allCredits?.length && withCredits && (
|
|
62
65
|
<CreditsSelector
|
|
63
66
|
selectedCredits={selectedCredits || []}
|
|
64
67
|
allCredits={allCredits || []}
|
package/dist/chunk-A4XOUWM5.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SelectPaymentMethod
|
|
3
|
-
} from "./chunk-Z7OYI7ZH.js";
|
|
4
|
-
import {
|
|
5
|
-
Modal
|
|
6
|
-
} from "./chunk-QIHDPSOM.js";
|
|
7
|
-
import {
|
|
8
|
-
Input
|
|
9
|
-
} from "./chunk-R5TLUWDD.js";
|
|
10
|
-
import {
|
|
11
|
-
Stack
|
|
12
|
-
} from "./chunk-EO3JJWFW.js";
|
|
13
|
-
import {
|
|
14
|
-
Card
|
|
15
|
-
} from "./chunk-JOMM4KBH.js";
|
|
16
|
-
import {
|
|
17
|
-
Paragraph
|
|
18
|
-
} from "./chunk-VG4EPHJA.js";
|
|
19
|
-
import {
|
|
20
|
-
__spreadValues
|
|
21
|
-
} from "./chunk-ORMEWXMH.js";
|
|
22
|
-
|
|
23
|
-
// src/components/PaymentOnAccountModal.tsx
|
|
24
|
-
import { useEffect, useState } from "react";
|
|
25
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
-
function PaymentOnAccountModal(props) {
|
|
27
|
-
const { isOpen, paymentProps, onClose } = props;
|
|
28
|
-
const [amount, setAmount] = useState(paymentProps.amountToPay);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
setAmount(paymentProps.amountToPay);
|
|
31
|
-
}, [paymentProps.amountToPay]);
|
|
32
|
-
function handleAmountChange(event) {
|
|
33
|
-
const value = event.target.value.replace(/[^0-9.-]+/g, "");
|
|
34
|
-
setAmount(+value || 0);
|
|
35
|
-
}
|
|
36
|
-
return /* @__PURE__ */ jsx(Modal, { open: isOpen, onClose, title: "Payment on Account", children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout-group", width: "full", children: [
|
|
37
|
-
/* @__PURE__ */ jsx(Card, { className: "py-desktop-component-padding", children: /* @__PURE__ */ jsxs(Stack, { sizing: "component", justify: "between", items: "center", horizontal: true, children: [
|
|
38
|
-
/* @__PURE__ */ jsx(Paragraph, { className: "w-full", children: "Amount to Pay" }),
|
|
39
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
40
|
-
Input,
|
|
41
|
-
{
|
|
42
|
-
type: "number",
|
|
43
|
-
placeholder: "$0.00",
|
|
44
|
-
align: "right",
|
|
45
|
-
value: amount === 0 ? "" : amount,
|
|
46
|
-
onChange: handleAmountChange,
|
|
47
|
-
before: "$"
|
|
48
|
-
}
|
|
49
|
-
) })
|
|
50
|
-
] }) }),
|
|
51
|
-
/* @__PURE__ */ jsx(SelectPaymentMethod, __spreadValues({}, paymentProps))
|
|
52
|
-
] }) });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
PaymentOnAccountModal
|
|
57
|
-
};
|