@bunnyapp/components 1.8.0-beta.12 → 1.8.0-beta.13
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/cjs/index.js
CHANGED
|
@@ -1283,7 +1283,7 @@ const DEFAULT_CONFIG = {
|
|
|
1283
1283
|
};
|
|
1284
1284
|
|
|
1285
1285
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1286
|
-
const PACKAGE_VERSION = '1.8.0-beta.
|
|
1286
|
+
const PACKAGE_VERSION = '1.8.0-beta.12';
|
|
1287
1287
|
const createRequestHeaders = (token) => {
|
|
1288
1288
|
const headers = createClientDevHeaders({ token });
|
|
1289
1289
|
// Add the components version header
|
|
@@ -20561,6 +20561,8 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
|
|
|
20561
20561
|
const invoice = readFragment(PaymentProvider_InvoiceFragment, maskedInvoice);
|
|
20562
20562
|
// State
|
|
20563
20563
|
const [isPaid, setIsPaid] = react.useState(false);
|
|
20564
|
+
const [isPaying, setIsPaying] = react.useState(false);
|
|
20565
|
+
const [isApprovingHold, setIsApprovingHold] = react.useState(false);
|
|
20564
20566
|
const getAmountDue = () => {
|
|
20565
20567
|
return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
|
|
20566
20568
|
};
|
|
@@ -20596,7 +20598,11 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
|
|
|
20596
20598
|
amountDue: amountDue !== null && amountDue !== void 0 ? amountDue : undefined,
|
|
20597
20599
|
formattedAmountDue: formattedAmountDueValue,
|
|
20598
20600
|
isPaid,
|
|
20599
|
-
setIsPaid
|
|
20601
|
+
setIsPaid,
|
|
20602
|
+
isPaying,
|
|
20603
|
+
setIsPaying,
|
|
20604
|
+
isApprovingHold,
|
|
20605
|
+
setIsApprovingHold,
|
|
20600
20606
|
}, children: children }));
|
|
20601
20607
|
}
|
|
20602
20608
|
|
|
@@ -21100,7 +21106,7 @@ function Pay(props = {}) {
|
|
|
21100
21106
|
const isMobile = useIsMobile();
|
|
21101
21107
|
const { onPaymentSuccess, onPaymentHoldSuccess, onSavePaymentMethod, paymentHoldPrecondition } = usePaymentFormCallbacks();
|
|
21102
21108
|
const selectedPlugin = useSelectedPlugin();
|
|
21103
|
-
const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid } = usePayable();
|
|
21109
|
+
const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid, setIsPaying, setIsApprovingHold } = usePayable();
|
|
21104
21110
|
const accountId = useAccountId();
|
|
21105
21111
|
const { defaultPaymentMethod } = usePaymentMethod({ accountId });
|
|
21106
21112
|
const [showPaymentDetailsForm, setShowPaymentDetailsForm] = useShowPaymentDetails();
|
|
@@ -21175,6 +21181,14 @@ function Pay(props = {}) {
|
|
|
21175
21181
|
return;
|
|
21176
21182
|
}
|
|
21177
21183
|
}
|
|
21184
|
+
react.useEffect(() => {
|
|
21185
|
+
setIsPaying(isPaying);
|
|
21186
|
+
return () => setIsPaying(false);
|
|
21187
|
+
}, [isPaying, setIsPaying]);
|
|
21188
|
+
react.useEffect(() => {
|
|
21189
|
+
setIsApprovingHold(isApprovingHold);
|
|
21190
|
+
return () => setIsApprovingHold(false);
|
|
21191
|
+
}, [isApprovingHold, setIsApprovingHold]);
|
|
21178
21192
|
return (jsxRuntime.jsx(antd.Button, { className: "bunny-w-full", disabled: isPaying || isApprovingHold || isSaving || disabled, loading: isPaying || isApprovingHold || isSaving, onClick: handlePayment, size: isMobile ? 'large' : 'middle', type: "primary", children: paymentButtonText }));
|
|
21179
21193
|
}
|
|
21180
21194
|
|
|
@@ -21331,6 +21345,7 @@ function PaymentMethodDetailsRoot(props = {}) {
|
|
|
21331
21345
|
const accountId = useAccountId();
|
|
21332
21346
|
const { paymentMethods } = usePaymentMethod({ accountId });
|
|
21333
21347
|
const { paymentPlugins } = usePaymentPlugins(accountId);
|
|
21348
|
+
const { isPaying, isApprovingHold } = usePayable();
|
|
21334
21349
|
function handleClickAddPaymentMethod() {
|
|
21335
21350
|
if ((paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.length) === 0) {
|
|
21336
21351
|
showErrorNotification$6('No payment plugins available', 'Error adding payment method');
|
|
@@ -21349,7 +21364,7 @@ function PaymentMethodDetailsRoot(props = {}) {
|
|
|
21349
21364
|
{
|
|
21350
21365
|
key: '1',
|
|
21351
21366
|
showArrow: false,
|
|
21352
|
-
label: !showPaymentMethodForm ? (jsxRuntime.jsx("div", { className: "bunny-pt-2", children: jsxRuntime.jsx(antd.Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", children: "Add payment method" }) })) : null,
|
|
21367
|
+
label: !showPaymentMethodForm ? (jsxRuntime.jsx("div", { className: "bunny-pt-2", children: jsxRuntime.jsx(antd.Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", disabled: isPaying || isApprovingHold, children: "Add payment method" }) })) : null,
|
|
21353
21368
|
children: (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-mt-2", children: [jsxRuntime.jsx(PaymentMethodSelector, {}), selectedPlugin && (jsxRuntime.jsx("div", { className: "bunny-flex bunny-flex-col", children: getPaymentMethodForm((_b = (_a = selectedPlugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) })), footer] })),
|
|
21354
21369
|
},
|
|
21355
21370
|
] }) }));
|
|
@@ -13,6 +13,10 @@ declare const PayableProvider: ({ value, children }: {
|
|
|
13
13
|
formattedAmountDue: string | undefined;
|
|
14
14
|
isPaid: boolean;
|
|
15
15
|
setIsPaid: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
|
+
isPaying: boolean;
|
|
17
|
+
setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
|
|
18
|
+
isApprovingHold: boolean;
|
|
19
|
+
setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
20
|
};
|
|
17
21
|
children?: import("react").ReactNode;
|
|
18
22
|
}) => import("react/jsx-runtime").JSX.Element, usePayable: () => {
|
|
@@ -27,6 +31,10 @@ declare const PayableProvider: ({ value, children }: {
|
|
|
27
31
|
formattedAmountDue: string | undefined;
|
|
28
32
|
isPaid: boolean;
|
|
29
33
|
setIsPaid: React.Dispatch<React.SetStateAction<boolean>>;
|
|
34
|
+
isPaying: boolean;
|
|
35
|
+
setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
|
|
36
|
+
isApprovingHold: boolean;
|
|
37
|
+
setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
|
|
30
38
|
};
|
|
31
39
|
export { PayableProvider, usePayable, };
|
|
32
40
|
export declare const PaymentProvider_QuoteFragment: import("gql.tada").TadaDocumentNode<{
|
package/dist/esm/index.js
CHANGED
|
@@ -1281,7 +1281,7 @@ const DEFAULT_CONFIG = {
|
|
|
1281
1281
|
};
|
|
1282
1282
|
|
|
1283
1283
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1284
|
-
const PACKAGE_VERSION = '1.8.0-beta.
|
|
1284
|
+
const PACKAGE_VERSION = '1.8.0-beta.12';
|
|
1285
1285
|
const createRequestHeaders = (token) => {
|
|
1286
1286
|
const headers = createClientDevHeaders({ token });
|
|
1287
1287
|
// Add the components version header
|
|
@@ -20559,6 +20559,8 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
|
|
|
20559
20559
|
const invoice = readFragment(PaymentProvider_InvoiceFragment, maskedInvoice);
|
|
20560
20560
|
// State
|
|
20561
20561
|
const [isPaid, setIsPaid] = useState(false);
|
|
20562
|
+
const [isPaying, setIsPaying] = useState(false);
|
|
20563
|
+
const [isApprovingHold, setIsApprovingHold] = useState(false);
|
|
20562
20564
|
const getAmountDue = () => {
|
|
20563
20565
|
return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
|
|
20564
20566
|
};
|
|
@@ -20594,7 +20596,11 @@ function PaymentProvider({ children, quote: maskedQuote, invoice: maskedInvoice,
|
|
|
20594
20596
|
amountDue: amountDue !== null && amountDue !== void 0 ? amountDue : undefined,
|
|
20595
20597
|
formattedAmountDue: formattedAmountDueValue,
|
|
20596
20598
|
isPaid,
|
|
20597
|
-
setIsPaid
|
|
20599
|
+
setIsPaid,
|
|
20600
|
+
isPaying,
|
|
20601
|
+
setIsPaying,
|
|
20602
|
+
isApprovingHold,
|
|
20603
|
+
setIsApprovingHold,
|
|
20598
20604
|
}, children: children }));
|
|
20599
20605
|
}
|
|
20600
20606
|
|
|
@@ -21098,7 +21104,7 @@ function Pay(props = {}) {
|
|
|
21098
21104
|
const isMobile = useIsMobile();
|
|
21099
21105
|
const { onPaymentSuccess, onPaymentHoldSuccess, onSavePaymentMethod, paymentHoldPrecondition } = usePaymentFormCallbacks();
|
|
21100
21106
|
const selectedPlugin = useSelectedPlugin();
|
|
21101
|
-
const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid } = usePayable();
|
|
21107
|
+
const { quoteId, invoiceId, paymentHold, paymentType, setIsPaid, setIsPaying, setIsApprovingHold } = usePayable();
|
|
21102
21108
|
const accountId = useAccountId();
|
|
21103
21109
|
const { defaultPaymentMethod } = usePaymentMethod({ accountId });
|
|
21104
21110
|
const [showPaymentDetailsForm, setShowPaymentDetailsForm] = useShowPaymentDetails();
|
|
@@ -21173,6 +21179,14 @@ function Pay(props = {}) {
|
|
|
21173
21179
|
return;
|
|
21174
21180
|
}
|
|
21175
21181
|
}
|
|
21182
|
+
useEffect(() => {
|
|
21183
|
+
setIsPaying(isPaying);
|
|
21184
|
+
return () => setIsPaying(false);
|
|
21185
|
+
}, [isPaying, setIsPaying]);
|
|
21186
|
+
useEffect(() => {
|
|
21187
|
+
setIsApprovingHold(isApprovingHold);
|
|
21188
|
+
return () => setIsApprovingHold(false);
|
|
21189
|
+
}, [isApprovingHold, setIsApprovingHold]);
|
|
21176
21190
|
return (jsx(Button, { className: "bunny-w-full", disabled: isPaying || isApprovingHold || isSaving || disabled, loading: isPaying || isApprovingHold || isSaving, onClick: handlePayment, size: isMobile ? 'large' : 'middle', type: "primary", children: paymentButtonText }));
|
|
21177
21191
|
}
|
|
21178
21192
|
|
|
@@ -21329,6 +21343,7 @@ function PaymentMethodDetailsRoot(props = {}) {
|
|
|
21329
21343
|
const accountId = useAccountId();
|
|
21330
21344
|
const { paymentMethods } = usePaymentMethod({ accountId });
|
|
21331
21345
|
const { paymentPlugins } = usePaymentPlugins(accountId);
|
|
21346
|
+
const { isPaying, isApprovingHold } = usePayable();
|
|
21332
21347
|
function handleClickAddPaymentMethod() {
|
|
21333
21348
|
if ((paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.length) === 0) {
|
|
21334
21349
|
showErrorNotification$6('No payment plugins available', 'Error adding payment method');
|
|
@@ -21347,7 +21362,7 @@ function PaymentMethodDetailsRoot(props = {}) {
|
|
|
21347
21362
|
{
|
|
21348
21363
|
key: '1',
|
|
21349
21364
|
showArrow: false,
|
|
21350
|
-
label: !showPaymentMethodForm ? (jsx("div", { className: "bunny-pt-2", children: jsx(Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", children: "Add payment method" }) })) : null,
|
|
21365
|
+
label: !showPaymentMethodForm ? (jsx("div", { className: "bunny-pt-2", children: jsx(Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", disabled: isPaying || isApprovingHold, children: "Add payment method" }) })) : null,
|
|
21351
21366
|
children: (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-mt-2", children: [jsx(PaymentMethodSelector, {}), selectedPlugin && (jsx("div", { className: "bunny-flex bunny-flex-col", children: getPaymentMethodForm((_b = (_a = selectedPlugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) })), footer] })),
|
|
21352
21367
|
},
|
|
21353
21368
|
] }) }));
|
|
@@ -13,6 +13,10 @@ declare const PayableProvider: ({ value, children }: {
|
|
|
13
13
|
formattedAmountDue: string | undefined;
|
|
14
14
|
isPaid: boolean;
|
|
15
15
|
setIsPaid: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
|
+
isPaying: boolean;
|
|
17
|
+
setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
|
|
18
|
+
isApprovingHold: boolean;
|
|
19
|
+
setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
20
|
};
|
|
17
21
|
children?: import("react").ReactNode;
|
|
18
22
|
}) => import("react/jsx-runtime").JSX.Element, usePayable: () => {
|
|
@@ -27,6 +31,10 @@ declare const PayableProvider: ({ value, children }: {
|
|
|
27
31
|
formattedAmountDue: string | undefined;
|
|
28
32
|
isPaid: boolean;
|
|
29
33
|
setIsPaid: React.Dispatch<React.SetStateAction<boolean>>;
|
|
34
|
+
isPaying: boolean;
|
|
35
|
+
setIsPaying: React.Dispatch<React.SetStateAction<boolean>>;
|
|
36
|
+
isApprovingHold: boolean;
|
|
37
|
+
setIsApprovingHold: React.Dispatch<React.SetStateAction<boolean>>;
|
|
30
38
|
};
|
|
31
39
|
export { PayableProvider, usePayable, };
|
|
32
40
|
export declare const PaymentProvider_QuoteFragment: import("gql.tada").TadaDocumentNode<{
|
package/package.json
CHANGED