@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/cjs/index.js CHANGED
@@ -170,7 +170,7 @@ var BrandContext = react.createContext({
170
170
  topNavImageUrl: common.DEFAULT_TOP_NAV_IMAGE_URL,
171
171
  });
172
172
 
173
- var MUTATION$9 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
173
+ var MUTATION$a = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
174
174
  var getBranding = function (_a) {
175
175
  var token = _a.token, apiHost = _a.apiHost;
176
176
  return __awaiter(void 0, void 0, void 0, function () {
@@ -178,7 +178,7 @@ var getBranding = function (_a) {
178
178
  return __generator(this, function (_b) {
179
179
  switch (_b.label) {
180
180
  case 0: return [4 /*yield*/, common.gqlRequest({
181
- query: MUTATION$9,
181
+ query: MUTATION$a,
182
182
  token: token,
183
183
  apiHost: apiHost,
184
184
  })];
@@ -467,28 +467,6 @@ var usePaymentMethod = function (_a) {
467
467
  return { data: data, isLoading: isLoading };
468
468
  };
469
469
 
470
- var usePlugins = function (_a) {
471
- var apiHost = _a.apiHost, token = _a.token;
472
- var response = reactQuery.useQuery({
473
- queryKey: common.QueryKeyFactory.default.pluginsKey(token),
474
- queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
475
- var plugins;
476
- return __generator(this, function (_a) {
477
- switch (_a.label) {
478
- case 0: return [4 /*yield*/, common.getPlugins({
479
- token: token,
480
- apiHost: apiHost,
481
- })];
482
- case 1:
483
- plugins = _a.sent();
484
- return [2 /*return*/, plugins];
485
- }
486
- });
487
- }); },
488
- });
489
- return response;
490
- };
491
-
492
470
  var filterPaymentPlugins = function (plugins) {
493
471
  return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
494
472
  var _a, _b, _c, _d;
@@ -497,19 +475,44 @@ var filterPaymentPlugins = function (plugins) {
497
475
  ((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.length);
498
476
  });
499
477
  };
478
+ 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}";
479
+ var getPaymentPlugins = function (_a) {
480
+ var apiHost = _a.apiHost, token = _a.token;
481
+ return __awaiter(void 0, void 0, void 0, function () {
482
+ var response;
483
+ return __generator(this, function (_b) {
484
+ switch (_b.label) {
485
+ case 0:
486
+ _b.trys.push([0, 2, , 3]);
487
+ return [4 /*yield*/, common.gqlRequest({
488
+ query: MUTATION$9,
489
+ token: token,
490
+ apiHost: apiHost,
491
+ })];
492
+ case 1:
493
+ response = _b.sent();
494
+ return [2 /*return*/, (response === null || response === void 0 ? void 0 : response.paymentPlugins) || []];
495
+ case 2:
496
+ _b.sent();
497
+ return [2 /*return*/, []];
498
+ case 3: return [2 /*return*/];
499
+ }
500
+ });
501
+ });
502
+ };
500
503
  var usePaymentPlugins = function (_a) {
501
504
  var apiHost = _a.apiHost, token = _a.token;
502
- var _b = usePlugins({
503
- apiHost: apiHost,
504
- token: token,
505
- }), plugins = _b.data, isFetched = _b.isFetched;
506
- var paymentPlugins = filterPaymentPlugins(Array.isArray(plugins) ? plugins : []);
507
- var paymentMethodAllowedPlugins = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.filter(function (plugin) {
505
+ var _b = reactQuery.useQuery({
506
+ queryKey: ["paymentPlugins", token],
507
+ queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token }); },
508
+ }), paymentPlugins = _b.data, isFetched = _b.isFetched;
509
+ var filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
510
+ var paymentMethodAllowedPlugins = filteredPaymentPlugins === null || filteredPaymentPlugins === void 0 ? void 0 : filteredPaymentPlugins.filter(function (plugin) {
508
511
  var _a, _b;
509
512
  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"); });
510
513
  });
511
514
  return {
512
- paymentPlugins: paymentPlugins,
515
+ paymentPlugins: filteredPaymentPlugins,
513
516
  paymentMethodAllowedPlugins: paymentMethodAllowedPlugins,
514
517
  isFetched: isFetched,
515
518
  };
@@ -1385,7 +1388,7 @@ var PaymentOptionContainer = defaultStyled.div(templateObject_1$9 || (templateOb
1385
1388
  });
1386
1389
  var templateObject_1$9;
1387
1390
 
1388
- function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1391
+ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId, onRemovePaymentMethod) {
1389
1392
  var _this = this;
1390
1393
  var queryClient = reactQuery.useQueryClient();
1391
1394
  var showErrorNotification = common.useErrorNotification();
@@ -1413,6 +1416,7 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1413
1416
  token: token,
1414
1417
  accountId: accountId,
1415
1418
  }), null);
1419
+ onRemovePaymentMethod === null || onRemovePaymentMethod === void 0 ? void 0 : onRemovePaymentMethod();
1416
1420
  })
1417
1421
  .catch(function (error) {
1418
1422
  showErrorNotification(error.message, "Error removing payment method");
@@ -1430,7 +1434,7 @@ function useRemovePaymentMethod(paymentPlugins, apiHost, token, accountId) {
1430
1434
  var Panel = antd.Collapse.Panel;
1431
1435
  var PaymentForm = function (_a) {
1432
1436
  var _b;
1433
- 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;
1437
+ 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;
1434
1438
  // Local state
1435
1439
  var _d = react.useState(), selectedPaymentMethod = _d[0], setSelectedPaymentMethod = _d[1];
1436
1440
  var _e = react.useState(false), showPaymentMethodForm = _e[0], setShowPaymentMethodForm = _e[1];
@@ -1455,7 +1459,7 @@ var PaymentForm = function (_a) {
1455
1459
  }
1456
1460
  return allPaymentMethodAllowedPlugins;
1457
1461
  }, [allPaymentMethodAllowedPlugins, allPaymentPlugins, useAllPaymentPlugins]);
1458
- var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId);
1462
+ var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], apiHost, token, accountId, onRemovePaymentMethod);
1459
1463
  var queryClient = reactQuery.useQueryClient();
1460
1464
  // Set default plugin
1461
1465
  react.useEffect(function () {
@@ -1603,6 +1607,28 @@ var getFormattedQuote = function (_a) {
1603
1607
  });
1604
1608
  };
1605
1609
 
1610
+ var usePlugins = function (_a) {
1611
+ var apiHost = _a.apiHost, token = _a.token;
1612
+ var response = reactQuery.useQuery({
1613
+ queryKey: common.QueryKeyFactory.default.pluginsKey(token || ""),
1614
+ queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
1615
+ var plugins;
1616
+ return __generator(this, function (_a) {
1617
+ switch (_a.label) {
1618
+ case 0: return [4 /*yield*/, common.getPlugins({
1619
+ token: token,
1620
+ apiHost: apiHost,
1621
+ })];
1622
+ case 1:
1623
+ plugins = _a.sent();
1624
+ return [2 /*return*/, plugins];
1625
+ }
1626
+ });
1627
+ }); },
1628
+ });
1629
+ return response;
1630
+ };
1631
+
1606
1632
  var filterSigningPlugins = function (plugins) {
1607
1633
  return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
1608
1634
  var _a, _b;
@@ -19923,18 +19949,20 @@ function Signup(_a) {
19923
19949
  }
19924
19950
 
19925
19951
  var createRequestHeaders = function (token) {
19926
- var bearerToken = "Bearer ".concat(token);
19952
+ var bearerToken = token ? "Bearer ".concat(token) : null;
19927
19953
  var headers = {
19928
19954
  "Content-type": "application/json; charset=utf-8",
19929
19955
  };
19930
- headers["Authorization"] = bearerToken;
19956
+ if (bearerToken) {
19957
+ headers["Authorization"] = bearerToken;
19958
+ }
19931
19959
  return headers;
19932
19960
  };
19933
19961
  var getGraphQLBaseURL = function (apiHost) {
19934
19962
  return "".concat(apiHost, "/graphql");
19935
19963
  };
19936
19964
  var useGraphQLRequest = function () {
19937
- return function (query, token, apiHost, variables) { return __awaiter(void 0, void 0, void 0, function () {
19965
+ return function (query, apiHost, token, variables) { return __awaiter(void 0, void 0, void 0, function () {
19938
19966
  var error_1;
19939
19967
  return __generator(this, function (_a) {
19940
19968
  switch (_a.label) {
@@ -19953,11 +19981,11 @@ var useGraphQLRequest = function () {
19953
19981
 
19954
19982
  var useCreateSubscriptionQuote = function () {
19955
19983
  var graphQLRequest = useGraphQLRequest();
19956
- return function (subscriptionIds, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
19984
+ return function (subscriptionIds, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19957
19985
  var data;
19958
19986
  return __generator(this, function (_a) {
19959
19987
  switch (_a.label) {
19960
- 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, {
19988
+ 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, {
19961
19989
  subscriptionIds: subscriptionIds,
19962
19990
  })];
19963
19991
  case 1:
@@ -19969,11 +19997,11 @@ var useCreateSubscriptionQuote = function () {
19969
19997
  };
19970
19998
  var useQuoteChangeUpdate = function () {
19971
19999
  var graphQLRequest = useGraphQLRequest();
19972
- return function (charges, quoteChangeId, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
20000
+ return function (charges, quoteChangeId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19973
20001
  var response;
19974
20002
  return __generator(this, function (_a) {
19975
20003
  switch (_a.label) {
19976
- 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 })];
20004
+ 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 })];
19977
20005
  case 1:
19978
20006
  response = _a.sent();
19979
20007
  return [2 /*return*/, response];
@@ -19983,11 +20011,11 @@ var useQuoteChangeUpdate = function () {
19983
20011
  };
19984
20012
  var useQuoteDelete = function () {
19985
20013
  var graphQLRequest = useGraphQLRequest();
19986
- return function (quoteId, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
20014
+ return function (quoteId, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19987
20015
  var response;
19988
20016
  return __generator(this, function (_a) {
19989
20017
  switch (_a.label) {
19990
- case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteDelete($id: ID!) {\n quoteDelete(id: $id) {\n errors\n }\n }", token, apiHost, { id: quoteId })];
20018
+ case 0: return [4 /*yield*/, graphQLRequest("mutation QuoteDelete($id: ID!) {\n quoteDelete(id: $id) {\n errors\n }\n }", apiHost, token, { id: quoteId })];
19991
20019
  case 1:
19992
20020
  response = _a.sent();
19993
20021
  return [2 /*return*/, response];
@@ -20073,7 +20101,7 @@ var quoteCompose = function (_a) {
20073
20101
 
20074
20102
  var QUOTE_RECALCULATE_TAXES = "\n mutation QuoteRecalculateTaxes($id: ID!) {\n quoteRecalculateTaxes(id: $id) {\n ".concat(QUOTE_FIELDS, "\n errors\n }\n }\n");
20075
20103
  var quoteRecalculateTaxes = function (_a) {
20076
- var quoteId = _a.quoteId, token = _a.token, apiHost = _a.apiHost;
20104
+ var quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
20077
20105
  return __awaiter(void 0, void 0, void 0, function () {
20078
20106
  var vars, response, errors;
20079
20107
  var _b, _c;
@@ -20100,7 +20128,7 @@ var quoteRecalculateTaxes = function (_a) {
20100
20128
 
20101
20129
  var MUTATION$2 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
20102
20130
  var getTaxationRequiredAccountFields = function (_a) {
20103
- var token = _a.token, apiHost = _a.apiHost;
20131
+ var apiHost = _a.apiHost, token = _a.token;
20104
20132
  return __awaiter(void 0, void 0, void 0, function () {
20105
20133
  var response;
20106
20134
  var _b, _c;
@@ -20296,14 +20324,14 @@ var Checkout = function (_a) {
20296
20324
  // Queries
20297
20325
  var _f = reactQuery.useQuery({
20298
20326
  queryKey: ["getTaxationRequiredAccountFields", token],
20299
- queryFn: function () { return getTaxationRequiredAccountFields({ token: token, apiHost: apiHost }); },
20327
+ queryFn: function () { return getTaxationRequiredAccountFields({ apiHost: apiHost, token: token }); },
20300
20328
  enabled: Boolean(quote),
20301
20329
  staleTime: 0,
20302
20330
  }), taxationRequiredAccountFields = _f.data, isLoadingTaxationRequiredAccountFields = _f.isLoading;
20303
20331
  var _g = reactQuery.useQuery({
20304
20332
  queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
20305
20333
  queryFn: function () {
20306
- return (quote === null || quote === void 0 ? void 0 : quote.accountId) && common.getAccount({ id: quote.accountId, token: token, apiHost: apiHost });
20334
+ return (quote === null || quote === void 0 ? void 0 : quote.accountId) && common.getAccount({ id: quote.accountId, apiHost: apiHost, token: token });
20307
20335
  },
20308
20336
  enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
20309
20337
  ((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
@@ -20321,8 +20349,8 @@ var Checkout = function (_a) {
20321
20349
  if (!quote) return [3 /*break*/, 2];
20322
20350
  return [4 /*yield*/, quoteRecalculateTaxes({
20323
20351
  quoteId: quote.id,
20324
- token: token,
20325
20352
  apiHost: apiHost,
20353
+ token: token,
20326
20354
  })];
20327
20355
  case 1:
20328
20356
  updatedQuote = _a.sent();
@@ -21452,12 +21480,12 @@ var PlanManager = function (_a) {
21452
21480
 
21453
21481
  var useCancelSubscription = function () {
21454
21482
  var graphQLRequest = useGraphQLRequest();
21455
- return function (subscriptionIds, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
21483
+ return function (subscriptionIds, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
21456
21484
  var data;
21457
21485
  var _a;
21458
21486
  return __generator(this, function (_b) {
21459
21487
  switch (_b.label) {
21460
- 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 })];
21488
+ 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 })];
21461
21489
  case 1:
21462
21490
  data = _b.sent();
21463
21491
  return [2 /*return*/, (_a = data === null || data === void 0 ? void 0 : data.subscriptions) === null || _a === void 0 ? void 0 : _a.nodes];
@@ -21914,7 +21942,7 @@ var SubscriptionsListContainer = function (_a) {
21914
21942
  // Queries
21915
21943
  var _c = reactQuery.useQuery({
21916
21944
  queryKey: common.QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
21917
- queryFn: function () { return getPriceListChangeOptions({ token: token, apiHost: apiHost }); },
21945
+ queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
21918
21946
  enabled: Boolean(onChangePlanClick),
21919
21947
  }), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
21920
21948
  if (subscriptionsAreLoading ||
@@ -21962,14 +21990,17 @@ var QuantityInput = function (_a) {
21962
21990
  (updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
21963
21991
  // If the subscription is not self-service, we disable the quantity input
21964
21992
  !charge.selfServiceQuantity;
21965
- var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? "" : editedSubscription.quantity;
21993
+ var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined
21994
+ ? ""
21995
+ : editedSubscription.quantity;
21966
21996
  // Mutations
21967
21997
  var createCharge = reactQuery.useMutation({
21968
21998
  mutationFn: quoteChargeCreate,
21969
21999
  onSuccess: function (response) {
21970
22000
  var _a, _b, _c, _d, _e, _f, _g, _h;
21971
22001
  if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
21972
- 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()) === common.SubscriptionState.TRIAL;
22002
+ 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()) ===
22003
+ common.SubscriptionState.TRIAL;
21973
22004
  setEditingQuoteData({
21974
22005
  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,
21975
22006
  isTrial: isTrial,
@@ -21986,12 +22017,15 @@ var QuantityInput = function (_a) {
21986
22017
  }).mutate;
21987
22018
  var createQuote = reactQuery.useMutation({
21988
22019
  mutationFn: function (subscriptionIds) {
21989
- return createSubscriptionQuote(subscriptionIds, token, apiHost);
22020
+ return createSubscriptionQuote(subscriptionIds, apiHost, token);
21990
22021
  },
21991
22022
  onSuccess: function (subscriptionUpdateData) {
21992
22023
  var _a, _b;
21993
22024
  var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
21994
- var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
22025
+ var quoteChange = quote.quoteChanges.find(function (quoteChange) {
22026
+ return quoteChange.priceList.id ===
22027
+ (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id);
22028
+ });
21995
22029
  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); });
21996
22030
  if (subscriptionCharge && quoteChange && editedSubscription) {
21997
22031
  createCharge({
@@ -22009,12 +22043,13 @@ var QuantityInput = function (_a) {
22009
22043
  var updateQuote = reactQuery.useMutation({
22010
22044
  mutationFn: function (_a) {
22011
22045
  var charges = _a.charges, quoteChangeId = _a.quoteChangeId;
22012
- return quoteChangeUpdate(charges, quoteChangeId, token, apiHost);
22046
+ return quoteChangeUpdate(charges, quoteChangeId, apiHost, token);
22013
22047
  },
22014
22048
  onSuccess: function (response) {
22015
22049
  var _a, _b, _c, _d, _e, _f;
22016
22050
  if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
22017
- 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()) === common.SubscriptionState.TRIAL;
22051
+ 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()) ===
22052
+ common.SubscriptionState.TRIAL;
22018
22053
  setEditingQuoteData({
22019
22054
  id: (_d = (_c = response.quoteChangeUpdate) === null || _c === void 0 ? void 0 : _c.quoteChange) === null || _d === void 0 ? void 0 : _d.quoteId,
22020
22055
  isTrial: isTrial,
@@ -22031,7 +22066,8 @@ var QuantityInput = function (_a) {
22031
22066
  });
22032
22067
  // Handlers
22033
22068
  var isQuantityLowerThanOriginal = function (quantity) {
22034
- return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined && editedSubscription.quantity <= quantity;
22069
+ return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined &&
22070
+ editedSubscription.quantity <= quantity;
22035
22071
  };
22036
22072
  var onChangeQuantity = function (chargeIndex, value, priceListChargeId, subscription, subscriptionIndex) {
22037
22073
  var quantity = isNaN(parseInt(value)) ? 0 : parseInt(value);
@@ -22312,7 +22348,7 @@ var Subscriptions = function (_a) {
22312
22348
  // Mutations
22313
22349
  var subscriptionCancel = reactQuery.useMutation({
22314
22350
  mutationFn: function (subscription) {
22315
- return cancelSubscription([subscription.id], token, apiHost);
22351
+ return cancelSubscription([subscription.id], apiHost, token);
22316
22352
  },
22317
22353
  onSuccess: function () {
22318
22354
  queryClient.invalidateQueries({
@@ -22363,7 +22399,7 @@ var Subscriptions = function (_a) {
22363
22399
  };
22364
22400
  var onClose = function () {
22365
22401
  if (editingQuoteData) {
22366
- quoteDelete(editingQuoteData.id, token, apiHost);
22402
+ quoteDelete(editingQuoteData.id, apiHost, token);
22367
22403
  setEditingQuoteData(undefined);
22368
22404
  }
22369
22405
  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>;