@bunnyapp/components 1.7.0-beta.21 → 1.7.0-beta.22

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.7.0-beta.20';
1286
+ const PACKAGE_VERSION = '1.7.0-beta.21';
1287
1287
  const createRequestHeaders = (token) => {
1288
1288
  const headers = createClientDevHeaders({ token });
1289
1289
  // Add the components version header
@@ -20196,8 +20196,9 @@ const getQuoteAmountDue_QuoteFragment = t(`
20196
20196
  }
20197
20197
  `, []);
20198
20198
  const getQuoteAmountDue = (maskedQuote) => {
20199
+ var _a;
20199
20200
  const quote = readFragment(getQuoteAmountDue_QuoteFragment, maskedQuote);
20200
- return quote.amountDue || quote.amount;
20201
+ return (_a = quote.amountDue) !== null && _a !== void 0 ? _a : quote.amount;
20201
20202
  };
20202
20203
 
20203
20204
  const { useToken: useAntdToken$1 } = antd.theme;
@@ -20487,10 +20488,14 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
20487
20488
  const token = useToken();
20488
20489
  // State
20489
20490
  const [isPaid, setIsPaid] = react.useState(false);
20491
+ const getAmountDue = () => {
20492
+ return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
20493
+ };
20490
20494
  const formattedAmountDue = () => {
20491
- const amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
20492
- const currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
20493
- return amountDue && currencyId ? formatCurrency(amountDue, currencyId).toString() : undefined;
20495
+ var _a;
20496
+ const amountDue = getAmountDue();
20497
+ const currencyId = (_a = quote === null || quote === void 0 ? void 0 : quote.currencyId) !== null && _a !== void 0 ? _a : invoice === null || invoice === void 0 ? void 0 : invoice.currencyId;
20498
+ return amountDue !== undefined && currencyId !== undefined ? formatCurrency(amountDue, currencyId).toString() : undefined;
20494
20499
  };
20495
20500
  // Validation checks
20496
20501
  if (quote !== undefined && invoice !== undefined) {
@@ -20606,7 +20611,7 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
20606
20611
  isApprovingHoldDemoPay ||
20607
20612
  isApprovingHoldStripe,
20608
20613
  isPaid,
20609
- paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : PaymentType.PAY,
20614
+ paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : getAmountDue() === 0 ? PaymentType.CHECKOUT_NO_PAYMENT : PaymentType.PAY,
20610
20615
  formattedAmountDue: formattedAmountDue(),
20611
20616
  };
20612
20617
  };
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.7.0-beta.20';
1284
+ const PACKAGE_VERSION = '1.7.0-beta.21';
1285
1285
  const createRequestHeaders = (token) => {
1286
1286
  const headers = createClientDevHeaders({ token });
1287
1287
  // Add the components version header
@@ -20194,8 +20194,9 @@ const getQuoteAmountDue_QuoteFragment = t(`
20194
20194
  }
20195
20195
  `, []);
20196
20196
  const getQuoteAmountDue = (maskedQuote) => {
20197
+ var _a;
20197
20198
  const quote = readFragment(getQuoteAmountDue_QuoteFragment, maskedQuote);
20198
- return quote.amountDue || quote.amount;
20199
+ return (_a = quote.amountDue) !== null && _a !== void 0 ? _a : quote.amount;
20199
20200
  };
20200
20201
 
20201
20202
  const { useToken: useAntdToken$1 } = theme;
@@ -20485,10 +20486,14 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
20485
20486
  const token = useToken();
20486
20487
  // State
20487
20488
  const [isPaid, setIsPaid] = useState(false);
20489
+ const getAmountDue = () => {
20490
+ return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
20491
+ };
20488
20492
  const formattedAmountDue = () => {
20489
- const amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
20490
- const currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
20491
- return amountDue && currencyId ? formatCurrency(amountDue, currencyId).toString() : undefined;
20493
+ var _a;
20494
+ const amountDue = getAmountDue();
20495
+ const currencyId = (_a = quote === null || quote === void 0 ? void 0 : quote.currencyId) !== null && _a !== void 0 ? _a : invoice === null || invoice === void 0 ? void 0 : invoice.currencyId;
20496
+ return amountDue !== undefined && currencyId !== undefined ? formatCurrency(amountDue, currencyId).toString() : undefined;
20492
20497
  };
20493
20498
  // Validation checks
20494
20499
  if (quote !== undefined && invoice !== undefined) {
@@ -20604,7 +20609,7 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
20604
20609
  isApprovingHoldDemoPay ||
20605
20610
  isApprovingHoldStripe,
20606
20611
  isPaid,
20607
- paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : PaymentType.PAY,
20612
+ paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : getAmountDue() === 0 ? PaymentType.CHECKOUT_NO_PAYMENT : PaymentType.PAY,
20608
20613
  formattedAmountDue: formattedAmountDue(),
20609
20614
  };
20610
20615
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.7.0-beta.21",
3
+ "version": "1.7.0-beta.22",
4
4
  "description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",