@bunnyapp/components 1.0.55 → 1.0.57

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.
Files changed (48) hide show
  1. package/dist/cjs/index.js +96 -60
  2. package/dist/cjs/src/components/BunnyProvider.d.ts +2 -2
  3. package/dist/cjs/src/components/Checkout/Checkout.d.ts +1 -1
  4. package/dist/cjs/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  5. package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +2 -1
  6. package/dist/cjs/src/components/PaymentForm/PaymentFormTypes.d.ts +1 -1
  7. package/dist/cjs/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
  8. package/dist/cjs/src/components/Subscriptions/SubscriptionRequests.d.ts +2 -2
  9. package/dist/cjs/src/graphql/QuoteRequests.d.ts +3 -3
  10. package/dist/cjs/src/graphql/mutations/quoteChargeCreate.d.ts +1 -1
  11. package/dist/cjs/src/graphql/mutations/quoteCompose.d.ts +1 -1
  12. package/dist/cjs/src/graphql/mutations/quoteRecalculateTaxes.d.ts +2 -2
  13. package/dist/cjs/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -1
  14. package/dist/cjs/src/graphql/queries/getTaxationRequiredAccountFields.d.ts +2 -2
  15. package/dist/cjs/src/hooks/quotes/useSendAcceptQuote.d.ts +1 -1
  16. package/dist/cjs/src/hooks/quotes/useSigningComplete.d.ts +1 -1
  17. package/dist/cjs/src/hooks/useHasTaxPlugin.d.ts +1 -1
  18. package/dist/cjs/src/hooks/usePaymentMethod.d.ts +1 -1
  19. package/dist/cjs/src/hooks/usePaymentPlugins.d.ts +1 -1
  20. package/dist/cjs/src/hooks/usePlugins.d.ts +2 -2
  21. package/dist/cjs/src/hooks/useSigningPlugins.d.ts +1 -1
  22. package/dist/cjs/src/hooks/useToken.d.ts +1 -1
  23. package/dist/cjs/src/utils/apiUtils.d.ts +1 -1
  24. package/dist/esm/index.js +97 -61
  25. package/dist/esm/src/components/BunnyProvider.d.ts +2 -2
  26. package/dist/esm/src/components/Checkout/Checkout.d.ts +1 -1
  27. package/dist/esm/src/components/Checkout/QuoteCheckout.d.ts +1 -1
  28. package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +2 -1
  29. package/dist/esm/src/components/PaymentForm/PaymentFormTypes.d.ts +1 -1
  30. package/dist/esm/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
  31. package/dist/esm/src/components/Subscriptions/SubscriptionRequests.d.ts +2 -2
  32. package/dist/esm/src/graphql/QuoteRequests.d.ts +3 -3
  33. package/dist/esm/src/graphql/mutations/quoteChargeCreate.d.ts +1 -1
  34. package/dist/esm/src/graphql/mutations/quoteCompose.d.ts +1 -1
  35. package/dist/esm/src/graphql/mutations/quoteRecalculateTaxes.d.ts +2 -2
  36. package/dist/esm/src/graphql/queries/getPriceListChangeOptions.d.ts +1 -1
  37. package/dist/esm/src/graphql/queries/getTaxationRequiredAccountFields.d.ts +2 -2
  38. package/dist/esm/src/hooks/quotes/useSendAcceptQuote.d.ts +1 -1
  39. package/dist/esm/src/hooks/quotes/useSigningComplete.d.ts +1 -1
  40. package/dist/esm/src/hooks/useHasTaxPlugin.d.ts +1 -1
  41. package/dist/esm/src/hooks/usePaymentMethod.d.ts +1 -1
  42. package/dist/esm/src/hooks/usePaymentPlugins.d.ts +1 -1
  43. package/dist/esm/src/hooks/usePlugins.d.ts +2 -2
  44. package/dist/esm/src/hooks/useSigningPlugins.d.ts +1 -1
  45. package/dist/esm/src/hooks/useToken.d.ts +1 -1
  46. package/dist/esm/src/utils/apiUtils.d.ts +1 -1
  47. package/dist/index.d.ts +3 -2
  48. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { Markup } from 'interweave';
4
4
  import { ConfigProvider, Button, Tag, Typography, Divider, Popconfirm, Input, Checkbox, Collapse, Skeleton, Modal, Form, Drawer, Card as Card$1, Image, Select, Tooltip, Radio, Space, Dropdown } from 'antd';
5
5
  import { DownloadOutlined, CreditCardOutlined, BankOutlined, SearchOutlined, CloseOutlined, CheckCircleFilled, ArrowLeftOutlined } from '@ant-design/icons';
6
6
  import styled from 'styled-components';
7
- import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, useAllErrorFormats, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useErrorNotification, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, sortSubscriptionCharges, Lists, SLATE_500, PRIMARY_COLOR, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, SubscriptionChargeKind } from '@bunnyapp/common';
7
+ import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, useAllErrorFormats, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useErrorNotification, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, getPlugins, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, sortSubscriptionCharges, Lists, SLATE_500, PRIMARY_COLOR, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, SubscriptionChargeKind } from '@bunnyapp/common';
8
8
  import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation } from '@tanstack/react-query';
9
9
  import theme from 'antd/lib/theme/index.js';
10
10
  import { RecoilRoot } from 'recoil';
@@ -141,7 +141,7 @@ var BrandContext = createContext({
141
141
  topNavImageUrl: DEFAULT_TOP_NAV_IMAGE_URL,
142
142
  });
143
143
 
144
- var MUTATION$9 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
144
+ var MUTATION$a = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
145
145
  var getBranding = function (_a) {
146
146
  var token = _a.token, apiHost = _a.apiHost;
147
147
  return __awaiter(void 0, void 0, void 0, function () {
@@ -149,7 +149,7 @@ var getBranding = function (_a) {
149
149
  return __generator(this, function (_b) {
150
150
  switch (_b.label) {
151
151
  case 0: return [4 /*yield*/, gqlRequest({
152
- query: MUTATION$9,
152
+ query: MUTATION$a,
153
153
  token: token,
154
154
  apiHost: apiHost,
155
155
  })];
@@ -438,28 +438,6 @@ var usePaymentMethod = function (_a) {
438
438
  return { data: data, isLoading: isLoading };
439
439
  };
440
440
 
441
- var usePlugins = function (_a) {
442
- var apiHost = _a.apiHost, token = _a.token;
443
- var response = useQuery({
444
- queryKey: QueryKeyFactory.default.pluginsKey(token),
445
- queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
446
- var plugins;
447
- return __generator(this, function (_a) {
448
- switch (_a.label) {
449
- case 0: return [4 /*yield*/, getPlugins({
450
- token: token,
451
- apiHost: apiHost,
452
- })];
453
- case 1:
454
- plugins = _a.sent();
455
- return [2 /*return*/, plugins];
456
- }
457
- });
458
- }); },
459
- });
460
- return response;
461
- };
462
-
463
441
  var filterPaymentPlugins = function (plugins) {
464
442
  return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
465
443
  var _a, _b, _c, _d;
@@ -468,19 +446,44 @@ var filterPaymentPlugins = function (plugins) {
468
446
  ((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.length);
469
447
  });
470
448
  };
449
+ var MUTATION$9 = "{\n paymentPlugins {\n enabled\n entities\n guid\n hidden\n id\n name\n status\n type\n webhookEnabled\n components\n }\n}";
450
+ var getPaymentPlugins = function (_a) {
451
+ var apiHost = _a.apiHost, token = _a.token;
452
+ return __awaiter(void 0, void 0, void 0, function () {
453
+ var response;
454
+ return __generator(this, function (_b) {
455
+ switch (_b.label) {
456
+ case 0:
457
+ _b.trys.push([0, 2, , 3]);
458
+ return [4 /*yield*/, gqlRequest({
459
+ query: MUTATION$9,
460
+ token: token,
461
+ apiHost: apiHost,
462
+ })];
463
+ case 1:
464
+ response = _b.sent();
465
+ return [2 /*return*/, (response === null || response === void 0 ? void 0 : response.paymentPlugins) || []];
466
+ case 2:
467
+ _b.sent();
468
+ return [2 /*return*/, []];
469
+ case 3: return [2 /*return*/];
470
+ }
471
+ });
472
+ });
473
+ };
471
474
  var usePaymentPlugins = function (_a) {
472
475
  var apiHost = _a.apiHost, token = _a.token;
473
- var _b = usePlugins({
474
- apiHost: apiHost,
475
- token: token,
476
- }), plugins = _b.data, isFetched = _b.isFetched;
477
- var paymentPlugins = filterPaymentPlugins(Array.isArray(plugins) ? plugins : []);
478
- var paymentMethodAllowedPlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.filter(function (plugin) {
476
+ var _b = useQuery({
477
+ queryKey: ["paymentPlugins", token],
478
+ queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token }); },
479
+ }), paymentPlugins = _b.data, isFetched = _b.isFetched;
480
+ var filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
481
+ var paymentMethodAllowedPlugins = filteredPaymentPlugins === null || filteredPaymentPlugins === void 0 ? void 0 : filteredPaymentPlugins.filter(function (plugin) {
479
482
  var _a, _b;
480
483
  return (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b.some(function (component) { var _a; return (_a = component === null || component === void 0 ? void 0 : component.scenarios) === null || _a === void 0 ? void 0 : _a.includes("admin-payment_method"); });
481
484
  });
482
485
  return {
483
- paymentPlugins: paymentPlugins,
486
+ paymentPlugins: filteredPaymentPlugins,
484
487
  paymentMethodAllowedPlugins: paymentMethodAllowedPlugins,
485
488
  isFetched: isFetched,
486
489
  };
@@ -1356,7 +1359,7 @@ var PaymentOptionContainer = defaultStyled.div(templateObject_1$9 || (templateOb
1356
1359
  });
1357
1360
  var templateObject_1$9;
1358
1361
 
1359
- function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1362
+ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId, onRemovePaymentMethod) {
1360
1363
  var _this = this;
1361
1364
  var queryClient = useQueryClient();
1362
1365
  var showErrorNotification = useErrorNotification();
@@ -1384,6 +1387,7 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1384
1387
  token: token,
1385
1388
  accountId: accountId,
1386
1389
  }), null);
1390
+ onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod();
1387
1391
  })
1388
1392
  .catch(function (error) {
1389
1393
  showErrorNotification(error.message, "Error removing payment method");
@@ -1401,7 +1405,7 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1401
1405
  var Panel = Collapse.Panel;
1402
1406
  var PaymentForm = function (_a) {
1403
1407
  var _b;
1404
- var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, overrideToken = _a.overrideToken, graphQLClient = _a.graphQLClient, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, customPaymentForms = _a.customPaymentForms, _c = _a.useAllPaymentPlugins, useAllPaymentPlugins = _c === void 0 ? false : _c;
1408
+ var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, overrideToken = _a.overrideToken, graphQLClient = _a.graphQLClient, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, customPaymentForms = _a.customPaymentForms, _c = _a.useAllPaymentPlugins, useAllPaymentPlugins = _c === void 0 ? false : _c;
1405
1409
  // Local state
1406
1410
  var _d = useState(), selectedPaymentMethod = _d[0], setSelectedPaymentMethod = _d[1];
1407
1411
  var _e = useState(false), showPaymentMethodForm = _e[0], setShowPaymentMethodForm = _e[1];
@@ -1426,7 +1430,7 @@ var PaymentForm = function (_a) {
1426
1430
  }
1427
1431
  return allPaymentMethodAllowedPlugins;
1428
1432
  }, [allPaymentMethodAllowedPlugins, allPaymentPlugins, useAllPaymentPlugins]);
1429
- var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId);
1433
+ var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId, onRemovePaymentMethod);
1430
1434
  var queryClient = useQueryClient();
1431
1435
  // Set default plugin
1432
1436
  useEffect(function () {
@@ -1574,6 +1578,28 @@ var getFormattedQuote = function (_a) {
1574
1578
  });
1575
1579
  };
1576
1580
 
1581
+ var usePlugins = function (_a) {
1582
+ var apiHost = _a.apiHost, token = _a.token;
1583
+ var response = useQuery({
1584
+ queryKey: QueryKeyFactory.default.pluginsKey(token || ""),
1585
+ queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
1586
+ var plugins;
1587
+ return __generator(this, function (_a) {
1588
+ switch (_a.label) {
1589
+ case 0: return [4 /*yield*/, getPlugins({
1590
+ token: token,
1591
+ apiHost: apiHost,
1592
+ })];
1593
+ case 1:
1594
+ plugins = _a.sent();
1595
+ return [2 /*return*/, plugins];
1596
+ }
1597
+ });
1598
+ }); },
1599
+ });
1600
+ return response;
1601
+ };
1602
+
1577
1603
  var filterSigningPlugins = function (plugins) {
1578
1604
  return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
1579
1605
  var _a, _b;
@@ -19894,18 +19920,20 @@ function Signup(_a) {
19894
19920
  }
19895
19921
 
19896
19922
  var createRequestHeaders = function (token) {
19897
- var bearerToken = "Bearer ".concat(token);
19923
+ var bearerToken = token ? "Bearer ".concat(token) : null;
19898
19924
  var headers = {
19899
19925
  "Content-type": "application/json; charset=utf-8",
19900
19926
  };
19901
- headers["Authorization"] = bearerToken;
19927
+ if (bearerToken) {
19928
+ headers["Authorization"] = bearerToken;
19929
+ }
19902
19930
  return headers;
19903
19931
  };
19904
19932
  var getGraphQLBaseURL = function (apiHost) {
19905
19933
  return "".concat(apiHost, "/graphql");
19906
19934
  };
19907
19935
  var useGraphQLRequest = function () {
19908
- return function (query, token, apiHost, variables) { return __awaiter(void 0, void 0, void 0, function () {
19936
+ return function (query, apiHost, token, variables) { return __awaiter(void 0, void 0, void 0, function () {
19909
19937
  var error_1;
19910
19938
  return __generator(this, function (_a) {
19911
19939
  switch (_a.label) {
@@ -19924,11 +19952,11 @@ var useGraphQLRequest = function () {
19924
19952
 
19925
19953
  var useCreateSubscriptionQuote = function () {
19926
19954
  var graphQLRequest = useGraphQLRequest();
19927
- return function (subscriptionIds, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19955
+ return function (subscriptionIds, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19928
19956
  var data;
19929
19957
  return __generator(this, function (_a) {
19930
19958
  switch (_a.label) {
19931
- case 0: return [4 /*yield*/, graphQLRequest("\n mutation quoteSubscriptionUpdate(\n $subscriptionIds: [ID!]!,\n ) {\n quoteSubscriptionUpdate(\n subscriptionIds: $subscriptionIds,\n ) {\n quote {\n id\n quoteChanges {\n id\n priceList {\n id\n }\n subscription {\n charges {\n startDate\n endDate\n id\n priceListCharge {\n id\n }\n }\n }\n }\n }\n }\n }\n ", token, apiHost, {
19959
+ case 0: return [4 /*yield*/, graphQLRequest("\n mutation quoteSubscriptionUpdate(\n $subscriptionIds: [ID!]!,\n ) {\n quoteSubscriptionUpdate(\n subscriptionIds: $subscriptionIds,\n ) {\n quote {\n id\n quoteChanges {\n id\n priceList {\n id\n }\n subscription {\n charges {\n startDate\n endDate\n id\n priceListCharge {\n id\n }\n }\n }\n }\n }\n }\n }\n ", apiHost, token, {
19932
19960
  subscriptionIds: subscriptionIds,
19933
19961
  })];
19934
19962
  case 1:
@@ -19940,11 +19968,11 @@ var useCreateSubscriptionQuote = function () {
19940
19968
  };
19941
19969
  var useQuoteChangeUpdate = function () {
19942
19970
  var graphQLRequest = useGraphQLRequest();
19943
- return function (charges, quoteChangeId, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19971
+ return function (charges, quoteChangeId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19944
19972
  var response;
19945
19973
  return __generator(this, function (_a) {
19946
19974
  switch (_a.label) {
19947
- case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteChangeUpdate($charges:[QuoteChargeAttributes!], $id:ID!) {\n quoteChangeUpdate(id:$id, charges:$charges) {\n quoteChange { id quoteId }\n errors\n }\n }", token, apiHost, { charges: charges, id: quoteChangeId })];
19975
+ case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteChangeUpdate($charges:[QuoteChargeAttributes!], $id:ID!) {\n quoteChangeUpdate(id:$id, charges:$charges) {\n quoteChange { id quoteId }\n errors\n }\n }", apiHost, token, { charges: charges, id: quoteChangeId })];
19948
19976
  case 1:
19949
19977
  response = _a.sent();
19950
19978
  return [2 /*return*/, response];
@@ -19954,11 +19982,11 @@ var useQuoteChangeUpdate = function () {
19954
19982
  };
19955
19983
  var useQuoteDelete = function () {
19956
19984
  var graphQLRequest = useGraphQLRequest();
19957
- return function (quoteId, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19985
+ return function (quoteId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19958
19986
  var response;
19959
19987
  return __generator(this, function (_a) {
19960
19988
  switch (_a.label) {
19961
- case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteDelete($id: ID!) {\n quoteDelete(id: $id) {\n errors\n }\n }", token, apiHost, { id: quoteId })];
19989
+ case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteDelete($id: ID!) {\n quoteDelete(id: $id) {\n errors\n }\n }", apiHost, token, { id: quoteId })];
19962
19990
  case 1:
19963
19991
  response = _a.sent();
19964
19992
  return [2 /*return*/, response];
@@ -20044,7 +20072,7 @@ var quoteCompose = function (_a) {
20044
20072
 
20045
20073
  var QUOTE_RECALCULATE_TAXES = "\n mutation QuoteRecalculateTaxes($id: ID!) {\n quoteRecalculateTaxes(id: $id) {\n ".concat(QUOTE_FIELDS, "\n errors\n }\n }\n");
20046
20074
  var quoteRecalculateTaxes = function (_a) {
20047
- var quoteId = _a.quoteId, token = _a.token, apiHost = _a.apiHost;
20075
+ var quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
20048
20076
  return __awaiter(void 0, void 0, void 0, function () {
20049
20077
  var vars, response, errors;
20050
20078
  var _b, _c;
@@ -20071,7 +20099,7 @@ var quoteRecalculateTaxes = function (_a) {
20071
20099
 
20072
20100
  var MUTATION$2 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
20073
20101
  var getTaxationRequiredAccountFields = function (_a) {
20074
- var token = _a.token, apiHost = _a.apiHost;
20102
+ var apiHost = _a.apiHost, token = _a.token;
20075
20103
  return __awaiter(void 0, void 0, void 0, function () {
20076
20104
  var response;
20077
20105
  var _b, _c;
@@ -20267,14 +20295,14 @@ var Checkout = function (_a) {
20267
20295
  // Queries
20268
20296
  var _f = useQuery({
20269
20297
  queryKey: ["getTaxationRequiredAccountFields", token],
20270
- queryFn: function () { return getTaxationRequiredAccountFields({ token: token, apiHost: apiHost }); },
20298
+ queryFn: function () { return getTaxationRequiredAccountFields({ apiHost: apiHost, token: token }); },
20271
20299
  enabled: Boolean(quote),
20272
20300
  staleTime: 0,
20273
20301
  }), taxationRequiredAccountFields = _f.data, isLoadingTaxationRequiredAccountFields = _f.isLoading;
20274
20302
  var _g = useQuery({
20275
20303
  queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
20276
20304
  queryFn: function () {
20277
- return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, token: token, apiHost: apiHost });
20305
+ return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, apiHost: apiHost, token: token });
20278
20306
  },
20279
20307
  enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
20280
20308
  ((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
@@ -20292,8 +20320,8 @@ var Checkout = function (_a) {
20292
20320
  if (!quote) return [3 /*break*/, 2];
20293
20321
  return [4 /*yield*/, quoteRecalculateTaxes({
20294
20322
  quoteId: quote.id,
20295
- token: token,
20296
20323
  apiHost: apiHost,
20324
+ token: token,
20297
20325
  })];
20298
20326
  case 1:
20299
20327
  updatedQuote = _a.sent();
@@ -21423,12 +21451,12 @@ var PlanManager = function (_a) {
21423
21451
 
21424
21452
  var useCancelSubscription = function () {
21425
21453
  var graphQLRequest = useGraphQLRequest();
21426
- return function (subscriptionIds, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
21454
+ return function (subscriptionIds, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
21427
21455
  var data;
21428
21456
  var _a;
21429
21457
  return __generator(this, function (_b) {
21430
21458
  switch (_b.label) {
21431
- case 0: return [4 /*yield*/, graphQLRequest("\n mutation SubscriptionCancel($subscriptionIds: [ID!]!) {\n subscriptionCancel(ids: $subscriptionIds) {\n subscriptions {\n accountId\n state\n }\n }\n }", token, apiHost, { subscriptionIds: subscriptionIds })];
21459
+ case 0: return [4 /*yield*/, graphQLRequest("\n mutation SubscriptionCancel($subscriptionIds: [ID!]!) {\n subscriptionCancel(ids: $subscriptionIds) {\n subscriptions {\n accountId\n state\n }\n }\n }", apiHost, token, { subscriptionIds: subscriptionIds })];
21432
21460
  case 1:
21433
21461
  data = _b.sent();
21434
21462
  return [2 /*return*/, (_a = data === null || data === void 0 ? void 0 : data.subscriptions) === null || _a === void 0 ? void 0 : _a.nodes];
@@ -21885,7 +21913,7 @@ var SubscriptionsListContainer = function (_a) {
21885
21913
  // Queries
21886
21914
  var _c = useQuery({
21887
21915
  queryKey: QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
21888
- queryFn: function () { return getPriceListChangeOptions({ token: token, apiHost: apiHost }); },
21916
+ queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
21889
21917
  enabled: Boolean(onChangePlanClick),
21890
21918
  }), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
21891
21919
  if (subscriptionsAreLoading ||
@@ -21933,14 +21961,17 @@ var QuantityInput = function (_a) {
21933
21961
  (updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
21934
21962
  // If the subscription is not self-service, we disable the quantity input
21935
21963
  !charge.selfServiceQuantity;
21936
- var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? "" : editedSubscription.quantity;
21964
+ var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined
21965
+ ? ""
21966
+ : editedSubscription.quantity;
21937
21967
  // Mutations
21938
21968
  var createCharge = useMutation({
21939
21969
  mutationFn: quoteChargeCreate,
21940
21970
  onSuccess: function (response) {
21941
21971
  var _a, _b, _c, _d, _e, _f, _g, _h;
21942
21972
  if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
21943
- var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
21973
+ var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
21974
+ SubscriptionState$2.TRIAL;
21944
21975
  setEditingQuoteData({
21945
21976
  id: (_e = (_d = (_c = response.quoteChargeCreate) === null || _c === void 0 ? void 0 : _c.quoteCharge) === null || _d === void 0 ? void 0 : _d.quoteChange) === null || _e === void 0 ? void 0 : _e.quoteId,
21946
21977
  isTrial: isTrial,
@@ -21957,12 +21988,15 @@ var QuantityInput = function (_a) {
21957
21988
  }).mutate;
21958
21989
  var createQuote = useMutation({
21959
21990
  mutationFn: function (subscriptionIds) {
21960
- return createSubscriptionQuote(subscriptionIds, token, apiHost);
21991
+ return createSubscriptionQuote(subscriptionIds, apiHost, token);
21961
21992
  },
21962
21993
  onSuccess: function (subscriptionUpdateData) {
21963
21994
  var _a, _b;
21964
21995
  var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
21965
- var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
21996
+ var quoteChange = quote.quoteChanges.find(function (quoteChange) {
21997
+ return quoteChange.priceList.id ===
21998
+ (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id);
21999
+ });
21966
22000
  var subscriptionCharge = (_b = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.subscription) === null || _b === void 0 ? void 0 : _b.charges.find(function (charge) { var _a; return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceListCharge) === null || _a === void 0 ? void 0 : _a.id) === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.chargeId); });
21967
22001
  if (subscriptionCharge && quoteChange && editedSubscription) {
21968
22002
  createCharge({
@@ -21980,12 +22014,13 @@ var QuantityInput = function (_a) {
21980
22014
  var updateQuote = useMutation({
21981
22015
  mutationFn: function (_a) {
21982
22016
  var charges = _a.charges, quoteChangeId = _a.quoteChangeId;
21983
- return quoteChangeUpdate(charges, quoteChangeId, token, apiHost);
22017
+ return quoteChangeUpdate(charges, quoteChangeId, apiHost, token);
21984
22018
  },
21985
22019
  onSuccess: function (response) {
21986
22020
  var _a, _b, _c, _d, _e, _f;
21987
22021
  if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
21988
- var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
22022
+ var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
22023
+ SubscriptionState$2.TRIAL;
21989
22024
  setEditingQuoteData({
21990
22025
  id: (_d = (_c = response.quoteChangeUpdate) === null || _c === void 0 ? void 0 : _c.quoteChange) === null || _d === void 0 ? void 0 : _d.quoteId,
21991
22026
  isTrial: isTrial,
@@ -22002,7 +22037,8 @@ var QuantityInput = function (_a) {
22002
22037
  });
22003
22038
  // Handlers
22004
22039
  var isQuantityLowerThanOriginal = function (quantity) {
22005
- return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined && editedSubscription.quantity <= quantity;
22040
+ return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined &&
22041
+ editedSubscription.quantity <= quantity;
22006
22042
  };
22007
22043
  var onChangeQuantity = function (chargeIndex, value, priceListChargeId, subscription, subscriptionIndex) {
22008
22044
  var quantity = isNaN(parseInt(value)) ? 0 : parseInt(value);
@@ -22283,7 +22319,7 @@ var Subscriptions = function (_a) {
22283
22319
  // Mutations
22284
22320
  var subscriptionCancel = useMutation({
22285
22321
  mutationFn: function (subscription) {
22286
- return cancelSubscription([subscription.id], token, apiHost);
22322
+ return cancelSubscription([subscription.id], apiHost, token);
22287
22323
  },
22288
22324
  onSuccess: function () {
22289
22325
  queryClient.invalidateQueries({
@@ -22334,7 +22370,7 @@ var Subscriptions = function (_a) {
22334
22370
  };
22335
22371
  var onClose = function () {
22336
22372
  if (editingQuoteData) {
22337
- quoteDelete(editingQuoteData.id, token, apiHost);
22373
+ quoteDelete(editingQuoteData.id, apiHost, token);
22338
22374
  setEditingQuoteData(undefined);
22339
22375
  }
22340
22376
  if (updatingChargeQuantityId) {
@@ -5,7 +5,7 @@ import { GraphQLClient } from "graphql-request";
5
5
  export type BunnyContextValues = {
6
6
  apiHost: string;
7
7
  graphQLClient: GraphQLClient;
8
- token: string;
8
+ token?: string;
9
9
  displayPayButtonNameAnyways?: boolean;
10
10
  darkMode?: boolean;
11
11
  onTokenExpired?: () => void;
@@ -16,7 +16,7 @@ declare function BunnyProvider({ children, darkMode, queryClient, apiHost, token
16
16
  darkMode?: boolean;
17
17
  queryClient?: QueryClient;
18
18
  apiHost: string;
19
- token: string;
19
+ token?: string;
20
20
  onTokenExpired?: () => void;
21
21
  configProviderProps?: ThemeConfig | undefined;
22
22
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { PaymentMethod } from "@bunnyapp/common";
2
2
  import { CheckoutProps } from "../PaymentForm/PaymentFormTypes";
3
3
  interface CheckoutComponentProps extends CheckoutProps {
4
4
  isMobile: boolean;
5
- token: string;
5
+ token?: string;
6
6
  storedPaymentMethod?: PaymentMethod;
7
7
  quantity?: number;
8
8
  }
@@ -4,7 +4,7 @@ interface QuoteCheckoutProps extends InvoiceQuoteParentProps {
4
4
  account: Account;
5
5
  quote: Quote;
6
6
  taxationRequiredAccountFields?: TaxationRequiredAccountFields | null;
7
- token: string;
7
+ token?: string;
8
8
  storedPaymentMethod?: PaymentMethod;
9
9
  }
10
10
  declare const QuoteCheckout: ({ account, onSuccess, onFail, quote, taxationRequiredAccountFields, }: QuoteCheckoutProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { FormattedInvoice, PluginData, Quote } from "@bunnyapp/common";
3
3
  import { GraphQLClient } from "graphql-request";
4
- export declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, quote, accountId, onSavePaymentMethod, overrideToken, graphQLClient, customCheckoutFunction, currencyId: currencyIdFromProps, customPaymentForms, useAllPaymentPlugins, }: {
4
+ export declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, quote, accountId, onSavePaymentMethod, onRemovePaymentMethod, overrideToken, graphQLClient, customCheckoutFunction, currencyId: currencyIdFromProps, customPaymentForms, useAllPaymentPlugins, }: {
5
5
  invoice?: FormattedInvoice | undefined;
6
6
  quote?: Quote | undefined;
7
7
  onFail: (error: any) => void;
8
8
  onPaymentSuccess?: (() => void) | undefined;
9
9
  onSavePaymentMethod?: (() => void) | undefined;
10
+ onRemovePaymentMethod?: (() => void) | undefined;
10
11
  accountId?: string | undefined;
11
12
  overrideToken?: string | undefined;
12
13
  graphQLClient: GraphQLClient;
@@ -20,5 +20,5 @@ export type CheckoutProps = {
20
20
  open: boolean;
21
21
  quote?: Quote;
22
22
  selectedPriceList?: PriceList;
23
- token: string;
23
+ token?: string;
24
24
  };
@@ -1,3 +1,3 @@
1
1
  import { PluginData } from "@bunnyapp/common";
2
- declare function useRemovePaymentMethod(paymentPlugins: PluginData[], apiHost: string, token: string, accountId?: string): (data: any) => Promise<void>;
2
+ declare function useRemovePaymentMethod(paymentPlugins: PluginData[], apiHost: string, token?: string, accountId?: string, onRemovePaymentMethod?: () => void): (data: any) => Promise<void>;
3
3
  export default useRemovePaymentMethod;
@@ -1,2 +1,2 @@
1
- export declare const useCancelSubscription: () => (subscriptionIds: string[], token: string, apiHost: string) => Promise<any>;
2
- export declare const useSubscriptionTrialConvert: (handlePortalErrors: (errors: any) => void, apiHost: string) => (subscriptionId: string, token: string, paymentId?: string) => Promise<any>;
1
+ export declare const useCancelSubscription: () => (subscriptionIds: string[], apiHost: string, token?: string) => Promise<any>;
2
+ export declare const useSubscriptionTrialConvert: (handlePortalErrors: (errors: any) => void, apiHost: string) => (subscriptionId: string, token?: string, paymentId?: string) => Promise<any>;
@@ -1,6 +1,6 @@
1
- export declare const useCreateSubscriptionQuote: () => (subscriptionIds: string[], token: string, apiHost: string) => Promise<unknown>;
1
+ export declare const useCreateSubscriptionQuote: () => (subscriptionIds: string[], apiHost: string, token?: string) => Promise<unknown>;
2
2
  export declare const useQuoteChangeUpdate: () => (charges: {
3
3
  id: string;
4
4
  quantity: number;
5
- }[], quoteChangeId: string, token: string, apiHost: string) => Promise<unknown>;
6
- export declare const useQuoteDelete: () => (quoteId: string, token: string, apiHost: string) => Promise<unknown>;
5
+ }[], quoteChangeId: string, apiHost: string, token?: string) => Promise<unknown>;
6
+ export declare const useQuoteDelete: () => (quoteId: string, apiHost: string, token?: string) => Promise<unknown>;
@@ -7,7 +7,7 @@ type QuoteChangeCreateChargeProps = {
7
7
  quoteChangeId: string;
8
8
  startDate: string;
9
9
  subscriptionChargeId?: string;
10
- token: string;
10
+ token?: string;
11
11
  };
12
12
  declare const quoteChargeCreate: ({ endDate, price, priceListChargeId, quantity, quoteChangeId, startDate, subscriptionChargeId, token, apiHost, }: QuoteChangeCreateChargeProps) => Promise<unknown>;
13
13
  export default quoteChargeCreate;
@@ -6,7 +6,7 @@ type Options = {
6
6
  subscriptionId?: string;
7
7
  quantity?: number;
8
8
  accountId?: string;
9
- token: string;
9
+ token?: string;
10
10
  apiHost: string;
11
11
  };
12
12
  declare const quoteCompose: ({ quoteId, priceListId, subscriptionId, quantity, accountId, token, apiHost, }: Options) => Promise<Quote>;
@@ -1,6 +1,6 @@
1
- declare const quoteRecalculateTaxes: ({ quoteId, token, apiHost, }: {
1
+ declare const quoteRecalculateTaxes: ({ quoteId, apiHost, token, }: {
2
2
  quoteId: string;
3
- token: string;
4
3
  apiHost: string;
4
+ token?: string | undefined;
5
5
  }) => Promise<any>;
6
6
  export default quoteRecalculateTaxes;
@@ -3,7 +3,7 @@ declare const getPriceListChangeOptions: ({ apiHost, isInPreviewMode, productId,
3
3
  apiHost: string;
4
4
  isInPreviewMode?: boolean | undefined;
5
5
  productId?: string | undefined;
6
- token: string;
6
+ token?: string | undefined;
7
7
  upgradingSubscription?: Subscription | undefined;
8
8
  }) => Promise<any>;
9
9
  export default getPriceListChangeOptions;
@@ -1,6 +1,6 @@
1
1
  import { TaxationRequiredAccountFields } from "@bunnyapp/common";
2
- declare const getTaxationRequiredAccountFields: ({ token, apiHost, }: {
3
- token: string;
2
+ declare const getTaxationRequiredAccountFields: ({ apiHost, token, }: {
4
3
  apiHost: string;
4
+ token?: string | undefined;
5
5
  }) => Promise<TaxationRequiredAccountFields | null>;
6
6
  export default getTaxationRequiredAccountFields;
@@ -3,7 +3,7 @@ declare const useSendAcceptQuote: ({ onTokenExpired, quoteId, apiHost, token, }:
3
3
  onTokenExpired?: (() => void) | undefined;
4
4
  quoteId?: string | undefined;
5
5
  apiHost: string;
6
- token: string;
6
+ token?: string | undefined;
7
7
  }) => {
8
8
  acceptBoxVisible: boolean;
9
9
  isAccepting: boolean;
@@ -1,5 +1,5 @@
1
1
  declare const useSigningComplete: ({ data, token }: {
2
2
  data: any;
3
- token: string;
3
+ token?: string | undefined;
4
4
  }) => void;
5
5
  export default useSigningComplete;
@@ -1,5 +1,5 @@
1
1
  declare const useHasTaxPlugin: ({ apiHost, token, }: {
2
2
  apiHost: string;
3
- token: string;
3
+ token?: string | undefined;
4
4
  }) => boolean;
5
5
  export default useHasTaxPlugin;
@@ -2,7 +2,7 @@ import { GraphQLClient } from "graphql-request";
2
2
  export declare const usePaymentMethod: ({ accountId, graphQLClient, token, }: {
3
3
  accountId?: string | undefined;
4
4
  graphQLClient: GraphQLClient;
5
- token: string;
5
+ token?: string | undefined;
6
6
  }) => {
7
7
  data: any;
8
8
  isLoading: boolean;
@@ -1,7 +1,7 @@
1
1
  import { PluginData } from "@bunnyapp/common";
2
2
  export declare const usePaymentPlugins: ({ apiHost, token, }: {
3
3
  apiHost: string;
4
- token: string;
4
+ token?: string | undefined;
5
5
  }) => {
6
6
  paymentPlugins: PluginData[] | undefined;
7
7
  paymentMethodAllowedPlugins: PluginData[] | undefined;
@@ -1,5 +1,5 @@
1
- declare const usePlugins: ({ apiHost, token }: {
1
+ declare const usePlugins: ({ apiHost, token, }: {
2
2
  apiHost: string;
3
- token: string;
3
+ token?: string | undefined;
4
4
  }) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<any, Error>;
5
5
  export default usePlugins;
@@ -1,5 +1,5 @@
1
1
  import { PluginData } from "@bunnyapp/common";
2
2
  export declare const useSigningPlugins: ({ apiHost, token, }: {
3
3
  apiHost: string;
4
- token: string;
4
+ token?: string | undefined;
5
5
  }) => PluginData[] | undefined;
@@ -1,2 +1,2 @@
1
- declare function useToken(): string;
1
+ declare function useToken(): string | undefined;
2
2
  export default useToken;
@@ -1,2 +1,2 @@
1
1
  export declare const getGraphQLBaseURL: (apiHost: string) => string;
2
- export declare const useGraphQLRequest: () => (query: string, token: string, apiHost: string, variables?: any) => Promise<unknown>;
2
+ export declare const useGraphQLRequest: () => (query: string, apiHost: string, token?: string, variables?: any) => Promise<unknown>;
package/dist/index.d.ts CHANGED
@@ -79,12 +79,13 @@ declare const PaymentMethod: ({ className, shadow, cardEnabled, useModal, }: {
79
79
  useModal?: boolean | undefined;
80
80
  }) => react_jsx_runtime.JSX.Element;
81
81
 
82
- declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, quote, accountId, onSavePaymentMethod, overrideToken, graphQLClient, customCheckoutFunction, currencyId: currencyIdFromProps, customPaymentForms, useAllPaymentPlugins, }: {
82
+ declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, quote, accountId, onSavePaymentMethod, onRemovePaymentMethod, overrideToken, graphQLClient, customCheckoutFunction, currencyId: currencyIdFromProps, customPaymentForms, useAllPaymentPlugins, }: {
83
83
  invoice?: FormattedInvoice | undefined;
84
84
  quote?: Quote$1 | undefined;
85
85
  onFail: (error: any) => void;
86
86
  onPaymentSuccess?: (() => void) | undefined;
87
87
  onSavePaymentMethod?: (() => void) | undefined;
88
+ onRemovePaymentMethod?: (() => void) | undefined;
88
89
  accountId?: string | undefined;
89
90
  overrideToken?: string | undefined;
90
91
  graphQLClient: GraphQLClient;
@@ -118,7 +119,7 @@ declare function BunnyProvider({ children, darkMode, queryClient, apiHost, token
118
119
  darkMode?: boolean;
119
120
  queryClient?: QueryClient;
120
121
  apiHost: string;
121
- token: string;
122
+ token?: string;
122
123
  onTokenExpired?: () => void;
123
124
  configProviderProps?: ThemeConfig | undefined;
124
125
  }): react_jsx_runtime.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
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",