@bunnyapp/components 1.0.26 → 1.0.27
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 +33 -61
- package/dist/cjs/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
- package/dist/cjs/src/hooks/usePaymentMethod.d.ts +1 -1
- package/dist/esm/index.js +40 -67
- package/dist/esm/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
- package/dist/esm/src/hooks/usePaymentMethod.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/src/graphql/graphqlUtil.d.ts +0 -10
- package/dist/esm/src/graphql/graphqlUtil.d.ts +0 -10
package/dist/cjs/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var common = require('@bunnyapp/common');
|
|
|
11
11
|
var reactQuery = require('@tanstack/react-query');
|
|
12
12
|
var theme = require('antd/lib/theme');
|
|
13
13
|
var recoil = require('recoil');
|
|
14
|
-
var
|
|
14
|
+
var graphqlRequest = import('graphql-request');
|
|
15
15
|
var reactStripeJs = require('@stripe/react-stripe-js');
|
|
16
16
|
var pure = require('@stripe/stripe-js/pure');
|
|
17
17
|
var lodash = require('lodash');
|
|
@@ -41,7 +41,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
41
41
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
42
42
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
43
43
|
var theme__default = /*#__PURE__*/_interopDefaultLegacy(theme);
|
|
44
|
-
var request__default = /*#__PURE__*/_interopDefaultLegacy(request);
|
|
45
44
|
|
|
46
45
|
function styleInject(css, ref) {
|
|
47
46
|
if ( ref === void 0 ) ref = {};
|
|
@@ -1618,7 +1617,7 @@ var getBranding = function (_a) {
|
|
|
1618
1617
|
};
|
|
1619
1618
|
|
|
1620
1619
|
var createGraphQLClient = function (token, apiHost) {
|
|
1621
|
-
return new
|
|
1620
|
+
return new graphqlRequest.GraphQLClient(apiHost + "/graphql", {
|
|
1622
1621
|
headers: {
|
|
1623
1622
|
Authorization: token,
|
|
1624
1623
|
},
|
|
@@ -1653,7 +1652,7 @@ function ContextualWrapper(_a) {
|
|
|
1653
1652
|
var _b = React.useState(false), interFontLoaded = _b[0], setInterFontLoaded = _b[1];
|
|
1654
1653
|
var _c = React.useContext(BunnyContext), apiHost = _c.apiHost, token = _c.token;
|
|
1655
1654
|
var branding = reactQuery.useQuery({
|
|
1656
|
-
queryKey: common.QueryKeyFactory.default.brandingKey,
|
|
1655
|
+
queryKey: common.QueryKeyFactory.default.brandingKey(token),
|
|
1657
1656
|
queryFn: function () { return getBranding({ token: token, apiHost: apiHost }); },
|
|
1658
1657
|
}).data;
|
|
1659
1658
|
var isMobile = common.useIsMobile();
|
|
@@ -1871,9 +1870,9 @@ function InvoicePDF(_a) {
|
|
|
1871
1870
|
}
|
|
1872
1871
|
|
|
1873
1872
|
var paymentMethodsQuery = "query paymentMethods ($filter: String, $first: Int, $sort: String) {\n paymentMethods (filter: $filter, first: $first, sort: $sort) {\n nodes {\n id\n disabled\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n }\n }\n }\n}";
|
|
1874
|
-
var usePaymentMethod = function (graphQLClient) {
|
|
1873
|
+
var usePaymentMethod = function (graphQLClient, entityId, token) {
|
|
1875
1874
|
var result = reactQuery.useQuery({
|
|
1876
|
-
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
|
|
1875
|
+
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
1877
1876
|
queryFn: function () {
|
|
1878
1877
|
return graphQLClient
|
|
1879
1878
|
.request(paymentMethodsQuery, {
|
|
@@ -1894,7 +1893,7 @@ var usePaymentMethod = function (graphQLClient) {
|
|
|
1894
1893
|
var usePlugins = function (_a) {
|
|
1895
1894
|
var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
|
|
1896
1895
|
var response = reactQuery.useQuery({
|
|
1897
|
-
queryKey: common.QueryKeyFactory.default.pluginsKey,
|
|
1896
|
+
queryKey: common.QueryKeyFactory.default.pluginsKey(token),
|
|
1898
1897
|
queryFn: function () {
|
|
1899
1898
|
var plugins = common.getPlugins({
|
|
1900
1899
|
entityId: entityId,
|
|
@@ -1939,34 +1938,6 @@ var getQuoteAmountDue = function (quote) {
|
|
|
1939
1938
|
return quote.amountDue;
|
|
1940
1939
|
};
|
|
1941
1940
|
|
|
1942
|
-
var DEFAULT_HEADERS = {
|
|
1943
|
-
"Content-type": "application/json; charset=utf-8",
|
|
1944
|
-
};
|
|
1945
|
-
// !!! Duplicated from @bunnyapp/common due to bug in signup. Uses BunnyProvider token instead of apiToken.
|
|
1946
|
-
var gqlRequest = function (_a) {
|
|
1947
|
-
var query = _a.query, _b = _a.vars, vars = _b === void 0 ? {} : _b, headers = _a.headers, token = _a.token, isInPreviewMode = _a.isInPreviewMode, apiHost = _a.apiHost;
|
|
1948
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
1949
|
-
var graphqlEndpoint, requestHeaders, authorizationHeader, error_1;
|
|
1950
|
-
return __generator(this, function (_c) {
|
|
1951
|
-
switch (_c.label) {
|
|
1952
|
-
case 0:
|
|
1953
|
-
_c.trys.push([0, 2, , 3]);
|
|
1954
|
-
graphqlEndpoint = common.DEFAULT_CONFIG.graphqlEndpoint;
|
|
1955
|
-
requestHeaders = headers || DEFAULT_HEADERS;
|
|
1956
|
-
authorizationHeader = "Bearer ".concat(token);
|
|
1957
|
-
if (!requestHeaders.Authorization && !isInPreviewMode)
|
|
1958
|
-
requestHeaders.Authorization = authorizationHeader;
|
|
1959
|
-
return [4 /*yield*/, request__default["default"]("".concat(apiHost).concat(graphqlEndpoint), query, vars, requestHeaders)];
|
|
1960
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
1961
|
-
case 2:
|
|
1962
|
-
error_1 = _c.sent();
|
|
1963
|
-
throw error_1;
|
|
1964
|
-
case 3: return [2 /*return*/];
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
});
|
|
1968
|
-
};
|
|
1969
|
-
|
|
1970
1941
|
var MUTATION$7 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
|
|
1971
1942
|
var checkout = function (_a) {
|
|
1972
1943
|
var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
|
|
@@ -1983,7 +1954,7 @@ var checkout = function (_a) {
|
|
|
1983
1954
|
if (paymentMethodData) {
|
|
1984
1955
|
mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
|
|
1985
1956
|
}
|
|
1986
|
-
return [4 /*yield*/, gqlRequest({
|
|
1957
|
+
return [4 /*yield*/, common.gqlRequest({
|
|
1987
1958
|
query: MUTATION$7,
|
|
1988
1959
|
token: token,
|
|
1989
1960
|
vars: mutationVars,
|
|
@@ -2575,7 +2546,7 @@ function useSave(_a) {
|
|
|
2575
2546
|
var save = function (_a) {
|
|
2576
2547
|
var plugin = _a.plugin;
|
|
2577
2548
|
return __awaiter(_this, void 0, void 0, function () {
|
|
2578
|
-
var submitError, response, clientSecret, intentResponse, paymentMethodId, paymentMethodResponse
|
|
2549
|
+
var submitError, response, clientSecret, intentResponse, paymentMethodId, paymentMethodResponse;
|
|
2579
2550
|
var _b, _c;
|
|
2580
2551
|
return __generator(this, function (_d) {
|
|
2581
2552
|
switch (_d.label) {
|
|
@@ -2636,8 +2607,9 @@ function useSave(_a) {
|
|
|
2636
2607
|
});
|
|
2637
2608
|
return [3 /*break*/, 7];
|
|
2638
2609
|
case 5:
|
|
2639
|
-
|
|
2640
|
-
console.error(
|
|
2610
|
+
_d.sent();
|
|
2611
|
+
// console.error(error);
|
|
2612
|
+
console.log("fancy error right here");
|
|
2641
2613
|
return [3 /*break*/, 7];
|
|
2642
2614
|
case 6:
|
|
2643
2615
|
setIsSaving(false);
|
|
@@ -2729,7 +2701,7 @@ var PaymentOptionContainer = styled__default["default"].div(templateObject_1$5 |
|
|
|
2729
2701
|
});
|
|
2730
2702
|
var templateObject_1$5;
|
|
2731
2703
|
|
|
2732
|
-
function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
|
|
2704
|
+
function useRemovePaymentMethod(paymentPlugins, token, apiHost, entityId, accountId) {
|
|
2733
2705
|
var _this = this;
|
|
2734
2706
|
var queryClient = reactQuery.useQueryClient();
|
|
2735
2707
|
var showErrorNotification = common.useErrorNotification();
|
|
@@ -2753,7 +2725,7 @@ function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
|
|
|
2753
2725
|
})
|
|
2754
2726
|
.then(function () {
|
|
2755
2727
|
showSuccessNotification("Payment method was removed", "Success");
|
|
2756
|
-
queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodKey, null);
|
|
2728
|
+
queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodKey(token, entityId), null);
|
|
2757
2729
|
})
|
|
2758
2730
|
.catch(function (error) {
|
|
2759
2731
|
showErrorNotification(error.message, "Error removing payment method");
|
|
@@ -2778,10 +2750,10 @@ var PaymentForm = function (_a) {
|
|
|
2778
2750
|
// Hooks
|
|
2779
2751
|
var apiHost = React.useContext(BunnyContext).apiHost;
|
|
2780
2752
|
var token = useToken();
|
|
2781
|
-
var storedPaymentMethod = usePaymentMethod(graphQLClient).data;
|
|
2753
|
+
var storedPaymentMethod = usePaymentMethod(graphQLClient, entityId, overrideToken || token).data;
|
|
2782
2754
|
var isPaymentMethodFetched = storedPaymentMethod !== undefined;
|
|
2783
2755
|
var _d = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: overrideToken || token }), paymentMethodAllowedPlugins = _d.paymentMethodAllowedPlugins, arePluginsFetched = _d.isFetched;
|
|
2784
|
-
var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], overrideToken || token, apiHost, accountId);
|
|
2756
|
+
var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], overrideToken || token, apiHost, entityId, accountId);
|
|
2785
2757
|
var queryClient = reactQuery.useQueryClient();
|
|
2786
2758
|
// Set default plugin
|
|
2787
2759
|
React.useEffect(function () {
|
|
@@ -2816,7 +2788,7 @@ var PaymentForm = function (_a) {
|
|
|
2816
2788
|
};
|
|
2817
2789
|
var handleSavePaymentMethod = function () {
|
|
2818
2790
|
queryClient.invalidateQueries({
|
|
2819
|
-
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
|
|
2791
|
+
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
2820
2792
|
});
|
|
2821
2793
|
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
|
|
2822
2794
|
setShowPaymentMethodForm(false);
|
|
@@ -2876,7 +2848,7 @@ function ActualInvoice() {
|
|
|
2876
2848
|
var isMobile = common.useIsMobile(isInvoicePayable ? common.BreakpointNumbers.lg : undefined);
|
|
2877
2849
|
var onSuccess = function () {
|
|
2878
2850
|
queryClient.invalidateQueries({
|
|
2879
|
-
queryKey: common.QueryKeyFactory.default.transactionsKey(),
|
|
2851
|
+
queryKey: common.QueryKeyFactory.default.transactionsKey(token),
|
|
2880
2852
|
});
|
|
2881
2853
|
queryClient.invalidateQueries({
|
|
2882
2854
|
queryKey: common.QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
|
|
@@ -3050,7 +3022,7 @@ var useSigningComplete = function (_a) {
|
|
|
3050
3022
|
React.useEffect(function () {
|
|
3051
3023
|
if (data && eventParam === "signing_complete") {
|
|
3052
3024
|
data.state = "ACCEPTED";
|
|
3053
|
-
queryClient.setQueryData(common.QueryKeyFactory.default.
|
|
3025
|
+
queryClient.setQueryData(common.QueryKeyFactory.default.createQuoteKey(token), data);
|
|
3054
3026
|
}
|
|
3055
3027
|
}, [data, eventParam, queryClient, token]);
|
|
3056
3028
|
};
|
|
@@ -3673,13 +3645,13 @@ var PaymentMethod = function (_a) {
|
|
|
3673
3645
|
var showSuccessNotification = common.useSuccessNotification();
|
|
3674
3646
|
var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
|
|
3675
3647
|
var isMobile = common.useIsMobile();
|
|
3676
|
-
var data = usePaymentMethod(graphQLClient).data;
|
|
3677
|
-
var onClickRemove = useRemovePaymentMethod(paymentPlugins || [], token, apiHost);
|
|
3648
|
+
var data = usePaymentMethod(graphQLClient, entityId, token).data;
|
|
3649
|
+
var onClickRemove = useRemovePaymentMethod(paymentPlugins || [], token, apiHost, entityId);
|
|
3678
3650
|
// Local state
|
|
3679
3651
|
var _e = React.useState(false), showModal = _e[0], setShowModal = _e[1];
|
|
3680
3652
|
var onSuccess = function () {
|
|
3681
3653
|
queryClient.invalidateQueries({
|
|
3682
|
-
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
|
|
3654
|
+
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
3683
3655
|
});
|
|
3684
3656
|
setShowModal(false);
|
|
3685
3657
|
showSuccessNotification("Your payment method has been saved");
|
|
@@ -3925,7 +3897,7 @@ var Checkout = function (_a) {
|
|
|
3925
3897
|
((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
|
|
3926
3898
|
}), account = _g.data, isLoadingAccount = _g.isLoading;
|
|
3927
3899
|
reactQuery.useQuery({
|
|
3928
|
-
queryKey: queryKeyFactory.createQuoteTaxCalculateKey(quote === null || quote === void 0 ? void 0 : quote.id),
|
|
3900
|
+
queryKey: queryKeyFactory.createQuoteTaxCalculateKey(token, quote === null || quote === void 0 ? void 0 : quote.id),
|
|
3929
3901
|
queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3930
3902
|
var updatedQuote;
|
|
3931
3903
|
return __generator(this, function (_a) {
|
|
@@ -3941,7 +3913,7 @@ var Checkout = function (_a) {
|
|
|
3941
3913
|
updatedQuote = _a.sent();
|
|
3942
3914
|
if (updatedQuote) {
|
|
3943
3915
|
queryClient.setQueryData(queryKeyFactory.createObjectKey("editingQuote", updatedQuote.id), updatedQuote);
|
|
3944
|
-
queryClient.setQueryData(queryKeyFactory.calculatedPricesKey(quantity, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
|
|
3916
|
+
queryClient.setQueryData(queryKeyFactory.calculatedPricesKey(token, quantity, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
|
|
3945
3917
|
}
|
|
3946
3918
|
_a.label = 2;
|
|
3947
3919
|
case 2: return [2 /*return*/, {}];
|
|
@@ -3985,7 +3957,7 @@ var accountSignup = function (_a) {
|
|
|
3985
3957
|
paymentMethodId: paymentMethodId,
|
|
3986
3958
|
priceListCode: priceListCode,
|
|
3987
3959
|
};
|
|
3988
|
-
return [4 /*yield*/, gqlRequest({
|
|
3960
|
+
return [4 /*yield*/, common.gqlRequest({
|
|
3989
3961
|
query: MUTATION$3(),
|
|
3990
3962
|
token: token,
|
|
3991
3963
|
vars: vars,
|
|
@@ -4017,7 +3989,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
4017
3989
|
accountName: accountName,
|
|
4018
3990
|
billingContact: billingContact,
|
|
4019
3991
|
};
|
|
4020
|
-
return [4 /*yield*/, gqlRequest({
|
|
3992
|
+
return [4 /*yield*/, common.gqlRequest({
|
|
4021
3993
|
query: MUTATION$2(),
|
|
4022
3994
|
token: token,
|
|
4023
3995
|
vars: vars,
|
|
@@ -4041,7 +4013,7 @@ var getPriceList = function (_a) {
|
|
|
4041
4013
|
var response;
|
|
4042
4014
|
return __generator(this, function (_b) {
|
|
4043
4015
|
switch (_b.label) {
|
|
4044
|
-
case 0: return [4 /*yield*/, gqlRequest({
|
|
4016
|
+
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
4045
4017
|
query: MUTATION$1(),
|
|
4046
4018
|
token: token,
|
|
4047
4019
|
vars: { code: code },
|
|
@@ -4105,7 +4077,7 @@ function Signup(_a) {
|
|
|
4105
4077
|
var _h = React.useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
|
|
4106
4078
|
var _j = React.useState(false), purchaseSucceeded = _j[0], setPurchaseSucceeded = _j[1];
|
|
4107
4079
|
var _k = React.useState(undefined), paymentMethodGraphQLClient = _k[0], setPaymentMethodGraphQLClient = _k[1];
|
|
4108
|
-
var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient).data;
|
|
4080
|
+
var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient, entityId, token).data;
|
|
4109
4081
|
var queryClient = reactQuery.useQueryClient();
|
|
4110
4082
|
// Queries
|
|
4111
4083
|
var priceListData = reactQuery.useQuery({
|
|
@@ -4140,7 +4112,7 @@ function Signup(_a) {
|
|
|
4140
4112
|
// We must invalidate the accountPaymentMethodKey query in order to clear payment methods from the provided api token,
|
|
4141
4113
|
// to instead use paymentMethods from portalSessionToken.
|
|
4142
4114
|
queryClient.invalidateQueries({
|
|
4143
|
-
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey,
|
|
4115
|
+
queryKey: common.QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
4144
4116
|
});
|
|
4145
4117
|
setProceedingToPayment(false);
|
|
4146
4118
|
setQuote(data.quote);
|
|
@@ -4806,12 +4778,12 @@ var Subscriptions = function (_a) {
|
|
|
4806
4778
|
var token = useToken();
|
|
4807
4779
|
// Queries
|
|
4808
4780
|
var _d = reactQuery.useQuery({
|
|
4809
|
-
queryKey: common.QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4781
|
+
queryKey: common.QueryKeyFactory.default.createTableKey(token, "subscriptions"),
|
|
4810
4782
|
queryFn: function () { return getSubscriptions({ entityId: entityId, token: token, apiHost: apiHost }); },
|
|
4811
4783
|
enabled: Boolean(entityId),
|
|
4812
4784
|
}), rawSubscriptions = _d.data, subscriptionsAreLoading = _d.isLoading;
|
|
4813
4785
|
var _e = reactQuery.useQuery({
|
|
4814
|
-
queryKey: common.QueryKeyFactory.default.planChangeOptionsKey(),
|
|
4786
|
+
queryKey: common.QueryKeyFactory.default.planChangeOptionsKey(token),
|
|
4815
4787
|
queryFn: function () { return getPlanChangeOptions({ token: token, apiHost: apiHost }); },
|
|
4816
4788
|
enabled: Boolean(onChangePlanClick),
|
|
4817
4789
|
}), planChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
|
|
@@ -4907,7 +4879,7 @@ var BillingDetails = function (_a) {
|
|
|
4907
4879
|
var values = antd.Form.useWatch([], form);
|
|
4908
4880
|
// Queries
|
|
4909
4881
|
var _g = reactQuery.useQuery({
|
|
4910
|
-
queryKey:
|
|
4882
|
+
queryKey: common.QueryKeyFactory.default.billingDetailsKey(token, entityId),
|
|
4911
4883
|
queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
|
|
4912
4884
|
}), billingDetails = _g.data, isLoadingBillingDetails = _g.isLoading;
|
|
4913
4885
|
var _h = reactQuery.useMutation({
|
|
@@ -4931,7 +4903,7 @@ var BillingDetails = function (_a) {
|
|
|
4931
4903
|
})];
|
|
4932
4904
|
case 1:
|
|
4933
4905
|
updatedBillingDetails = _a.sent();
|
|
4934
|
-
queryClient.setQueryData(
|
|
4906
|
+
queryClient.setQueryData(common.QueryKeyFactory.default.billingDetailsKey(token, entityId), function (old) {
|
|
4935
4907
|
return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
|
|
4936
4908
|
});
|
|
4937
4909
|
return [2 /*return*/, updatedBillingDetails];
|
|
@@ -4941,7 +4913,7 @@ var BillingDetails = function (_a) {
|
|
|
4941
4913
|
onSuccess: function () {
|
|
4942
4914
|
showSuccessNotification("Your account details have been saved");
|
|
4943
4915
|
queryClient.invalidateQueries({
|
|
4944
|
-
queryKey:
|
|
4916
|
+
queryKey: common.QueryKeyFactory.default.taxationRequiredAccountFieldsKey(token, entityId),
|
|
4945
4917
|
});
|
|
4946
4918
|
},
|
|
4947
4919
|
}), updateBillingDetails = _h.mutate, isUpdatingBillingDetails = _h.isPending;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginData } from "@bunnyapp/common";
|
|
2
|
-
declare function useRemovePaymentMethod(paymentPlugins: PluginData[], token: string, apiHost: string, accountId?: string): (data: any) => Promise<void>;
|
|
2
|
+
declare function useRemovePaymentMethod(paymentPlugins: PluginData[], token: string, apiHost: string, entityId: string, accountId?: string): (data: any) => Promise<void>;
|
|
3
3
|
export default useRemovePaymentMethod;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
export declare const usePaymentMethod: (graphQLClient: GraphQLClient) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<any, Error>;
|
|
2
|
+
export declare const usePaymentMethod: (graphQLClient: GraphQLClient, entityId: string, token: string) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<any, Error>;
|
package/dist/esm/index.js
CHANGED
|
@@ -4,11 +4,11 @@ import React__default, { createContext, useContext, useEffect, useState, useMemo
|
|
|
4
4
|
import { Markup } from 'interweave';
|
|
5
5
|
import { ConfigProvider, Button, Typography, Tag, Divider, Popconfirm, Input, Checkbox, Collapse, Modal, Form, Drawer, Card as Card$1, Select, Image, Dropdown, Skeleton } from 'antd';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest
|
|
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, Lists, getAccount, SubscriptionChargeKind, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, PricingModel, ChargeType } from '@bunnyapp/common';
|
|
8
8
|
import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation } from '@tanstack/react-query';
|
|
9
9
|
import theme from 'antd/lib/theme';
|
|
10
10
|
import { RecoilRoot } from 'recoil';
|
|
11
|
-
import
|
|
11
|
+
import { GraphQLClient } from 'graphql-request';
|
|
12
12
|
import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
|
|
13
13
|
import { loadStripe } from '@stripe/stripe-js/pure';
|
|
14
14
|
import { capitalize, startCase, cloneDeep, omit } from 'lodash';
|
|
@@ -1575,7 +1575,7 @@ var getBranding = function (_a) {
|
|
|
1575
1575
|
var response;
|
|
1576
1576
|
return __generator(this, function (_b) {
|
|
1577
1577
|
switch (_b.label) {
|
|
1578
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
1578
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
1579
1579
|
query: MUTATION$8,
|
|
1580
1580
|
token: token,
|
|
1581
1581
|
apiHost: apiHost,
|
|
@@ -1624,7 +1624,7 @@ function ContextualWrapper(_a) {
|
|
|
1624
1624
|
var _b = useState(false), interFontLoaded = _b[0], setInterFontLoaded = _b[1];
|
|
1625
1625
|
var _c = useContext(BunnyContext), apiHost = _c.apiHost, token = _c.token;
|
|
1626
1626
|
var branding = useQuery({
|
|
1627
|
-
queryKey: QueryKeyFactory.default.brandingKey,
|
|
1627
|
+
queryKey: QueryKeyFactory.default.brandingKey(token),
|
|
1628
1628
|
queryFn: function () { return getBranding({ token: token, apiHost: apiHost }); },
|
|
1629
1629
|
}).data;
|
|
1630
1630
|
var isMobile = useIsMobile();
|
|
@@ -1842,9 +1842,9 @@ function InvoicePDF(_a) {
|
|
|
1842
1842
|
}
|
|
1843
1843
|
|
|
1844
1844
|
var paymentMethodsQuery = "query paymentMethods ($filter: String, $first: Int, $sort: String) {\n paymentMethods (filter: $filter, first: $first, sort: $sort) {\n nodes {\n id\n disabled\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n }\n }\n }\n}";
|
|
1845
|
-
var usePaymentMethod = function (graphQLClient) {
|
|
1845
|
+
var usePaymentMethod = function (graphQLClient, entityId, token) {
|
|
1846
1846
|
var result = useQuery({
|
|
1847
|
-
queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
|
|
1847
|
+
queryKey: QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
1848
1848
|
queryFn: function () {
|
|
1849
1849
|
return graphQLClient
|
|
1850
1850
|
.request(paymentMethodsQuery, {
|
|
@@ -1865,7 +1865,7 @@ var usePaymentMethod = function (graphQLClient) {
|
|
|
1865
1865
|
var usePlugins = function (_a) {
|
|
1866
1866
|
var entityId = _a.entityId, apiHost = _a.apiHost, token = _a.token;
|
|
1867
1867
|
var response = useQuery({
|
|
1868
|
-
queryKey: QueryKeyFactory.default.pluginsKey,
|
|
1868
|
+
queryKey: QueryKeyFactory.default.pluginsKey(token),
|
|
1869
1869
|
queryFn: function () {
|
|
1870
1870
|
var plugins = getPlugins({
|
|
1871
1871
|
entityId: entityId,
|
|
@@ -1910,34 +1910,6 @@ var getQuoteAmountDue = function (quote) {
|
|
|
1910
1910
|
return quote.amountDue;
|
|
1911
1911
|
};
|
|
1912
1912
|
|
|
1913
|
-
var DEFAULT_HEADERS = {
|
|
1914
|
-
"Content-type": "application/json; charset=utf-8",
|
|
1915
|
-
};
|
|
1916
|
-
// !!! Duplicated from @bunnyapp/common due to bug in signup. Uses BunnyProvider token instead of apiToken.
|
|
1917
|
-
var gqlRequest = function (_a) {
|
|
1918
|
-
var query = _a.query, _b = _a.vars, vars = _b === void 0 ? {} : _b, headers = _a.headers, token = _a.token, isInPreviewMode = _a.isInPreviewMode, apiHost = _a.apiHost;
|
|
1919
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
1920
|
-
var graphqlEndpoint, requestHeaders, authorizationHeader, error_1;
|
|
1921
|
-
return __generator(this, function (_c) {
|
|
1922
|
-
switch (_c.label) {
|
|
1923
|
-
case 0:
|
|
1924
|
-
_c.trys.push([0, 2, , 3]);
|
|
1925
|
-
graphqlEndpoint = DEFAULT_CONFIG.graphqlEndpoint;
|
|
1926
|
-
requestHeaders = headers || DEFAULT_HEADERS;
|
|
1927
|
-
authorizationHeader = "Bearer ".concat(token);
|
|
1928
|
-
if (!requestHeaders.Authorization && !isInPreviewMode)
|
|
1929
|
-
requestHeaders.Authorization = authorizationHeader;
|
|
1930
|
-
return [4 /*yield*/, request("".concat(apiHost).concat(graphqlEndpoint), query, vars, requestHeaders)];
|
|
1931
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
1932
|
-
case 2:
|
|
1933
|
-
error_1 = _c.sent();
|
|
1934
|
-
throw error_1;
|
|
1935
|
-
case 3: return [2 /*return*/];
|
|
1936
|
-
}
|
|
1937
|
-
});
|
|
1938
|
-
});
|
|
1939
|
-
};
|
|
1940
|
-
|
|
1941
1913
|
var MUTATION$7 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
|
|
1942
1914
|
var checkout = function (_a) {
|
|
1943
1915
|
var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
|
|
@@ -2546,7 +2518,7 @@ function useSave(_a) {
|
|
|
2546
2518
|
var save = function (_a) {
|
|
2547
2519
|
var plugin = _a.plugin;
|
|
2548
2520
|
return __awaiter(_this, void 0, void 0, function () {
|
|
2549
|
-
var submitError, response, clientSecret, intentResponse, paymentMethodId, paymentMethodResponse
|
|
2521
|
+
var submitError, response, clientSecret, intentResponse, paymentMethodId, paymentMethodResponse;
|
|
2550
2522
|
var _b, _c;
|
|
2551
2523
|
return __generator(this, function (_d) {
|
|
2552
2524
|
switch (_d.label) {
|
|
@@ -2607,8 +2579,9 @@ function useSave(_a) {
|
|
|
2607
2579
|
});
|
|
2608
2580
|
return [3 /*break*/, 7];
|
|
2609
2581
|
case 5:
|
|
2610
|
-
|
|
2611
|
-
console.error(
|
|
2582
|
+
_d.sent();
|
|
2583
|
+
// console.error(error);
|
|
2584
|
+
console.log("fancy error right here");
|
|
2612
2585
|
return [3 /*break*/, 7];
|
|
2613
2586
|
case 6:
|
|
2614
2587
|
setIsSaving(false);
|
|
@@ -2700,7 +2673,7 @@ var PaymentOptionContainer = styled.div(templateObject_1$5 || (templateObject_1$
|
|
|
2700
2673
|
});
|
|
2701
2674
|
var templateObject_1$5;
|
|
2702
2675
|
|
|
2703
|
-
function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
|
|
2676
|
+
function useRemovePaymentMethod(paymentPlugins, token, apiHost, entityId, accountId) {
|
|
2704
2677
|
var _this = this;
|
|
2705
2678
|
var queryClient = useQueryClient();
|
|
2706
2679
|
var showErrorNotification = useErrorNotification();
|
|
@@ -2724,7 +2697,7 @@ function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
|
|
|
2724
2697
|
})
|
|
2725
2698
|
.then(function () {
|
|
2726
2699
|
showSuccessNotification("Payment method was removed", "Success");
|
|
2727
|
-
queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey, null);
|
|
2700
|
+
queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey(token, entityId), null);
|
|
2728
2701
|
})
|
|
2729
2702
|
.catch(function (error) {
|
|
2730
2703
|
showErrorNotification(error.message, "Error removing payment method");
|
|
@@ -2749,10 +2722,10 @@ var PaymentForm = function (_a) {
|
|
|
2749
2722
|
// Hooks
|
|
2750
2723
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
2751
2724
|
var token = useToken();
|
|
2752
|
-
var storedPaymentMethod = usePaymentMethod(graphQLClient).data;
|
|
2725
|
+
var storedPaymentMethod = usePaymentMethod(graphQLClient, entityId, overrideToken || token).data;
|
|
2753
2726
|
var isPaymentMethodFetched = storedPaymentMethod !== undefined;
|
|
2754
2727
|
var _d = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: overrideToken || token }), paymentMethodAllowedPlugins = _d.paymentMethodAllowedPlugins, arePluginsFetched = _d.isFetched;
|
|
2755
|
-
var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], overrideToken || token, apiHost, accountId);
|
|
2728
|
+
var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], overrideToken || token, apiHost, entityId, accountId);
|
|
2756
2729
|
var queryClient = useQueryClient();
|
|
2757
2730
|
// Set default plugin
|
|
2758
2731
|
useEffect(function () {
|
|
@@ -2787,7 +2760,7 @@ var PaymentForm = function (_a) {
|
|
|
2787
2760
|
};
|
|
2788
2761
|
var handleSavePaymentMethod = function () {
|
|
2789
2762
|
queryClient.invalidateQueries({
|
|
2790
|
-
queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
|
|
2763
|
+
queryKey: QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
2791
2764
|
});
|
|
2792
2765
|
onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
|
|
2793
2766
|
setShowPaymentMethodForm(false);
|
|
@@ -2847,7 +2820,7 @@ function ActualInvoice() {
|
|
|
2847
2820
|
var isMobile = useIsMobile(isInvoicePayable ? BreakpointNumbers.lg : undefined);
|
|
2848
2821
|
var onSuccess = function () {
|
|
2849
2822
|
queryClient.invalidateQueries({
|
|
2850
|
-
queryKey: QueryKeyFactory.default.transactionsKey(),
|
|
2823
|
+
queryKey: QueryKeyFactory.default.transactionsKey(token),
|
|
2851
2824
|
});
|
|
2852
2825
|
queryClient.invalidateQueries({
|
|
2853
2826
|
queryKey: QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
|
|
@@ -2874,7 +2847,7 @@ var getFormattedQuote = function (_a) {
|
|
|
2874
2847
|
var response;
|
|
2875
2848
|
return __generator(this, function (_b) {
|
|
2876
2849
|
switch (_b.label) {
|
|
2877
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
2850
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
2878
2851
|
query: MUTATION$6(),
|
|
2879
2852
|
token: token,
|
|
2880
2853
|
apiHost: apiHost,
|
|
@@ -3021,7 +2994,7 @@ var useSigningComplete = function (_a) {
|
|
|
3021
2994
|
useEffect(function () {
|
|
3022
2995
|
if (data && eventParam === "signing_complete") {
|
|
3023
2996
|
data.state = "ACCEPTED";
|
|
3024
|
-
queryClient.setQueryData(QueryKeyFactory.default.
|
|
2997
|
+
queryClient.setQueryData(QueryKeyFactory.default.createQuoteKey(token), data);
|
|
3025
2998
|
}
|
|
3026
2999
|
}, [data, eventParam, queryClient, token]);
|
|
3027
3000
|
};
|
|
@@ -3202,7 +3175,7 @@ var getQuotes = function (_a) {
|
|
|
3202
3175
|
var response;
|
|
3203
3176
|
return __generator(this, function (_b) {
|
|
3204
3177
|
switch (_b.label) {
|
|
3205
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
3178
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
3206
3179
|
query: QUOTES_QUERY(filter),
|
|
3207
3180
|
token: token,
|
|
3208
3181
|
vars: {},
|
|
@@ -3644,13 +3617,13 @@ var PaymentMethod = function (_a) {
|
|
|
3644
3617
|
var showSuccessNotification = useSuccessNotification();
|
|
3645
3618
|
var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
|
|
3646
3619
|
var isMobile = useIsMobile();
|
|
3647
|
-
var data = usePaymentMethod(graphQLClient).data;
|
|
3648
|
-
var onClickRemove = useRemovePaymentMethod(paymentPlugins || [], token, apiHost);
|
|
3620
|
+
var data = usePaymentMethod(graphQLClient, entityId, token).data;
|
|
3621
|
+
var onClickRemove = useRemovePaymentMethod(paymentPlugins || [], token, apiHost, entityId);
|
|
3649
3622
|
// Local state
|
|
3650
3623
|
var _e = useState(false), showModal = _e[0], setShowModal = _e[1];
|
|
3651
3624
|
var onSuccess = function () {
|
|
3652
3625
|
queryClient.invalidateQueries({
|
|
3653
|
-
queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
|
|
3626
|
+
queryKey: QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
3654
3627
|
});
|
|
3655
3628
|
setShowModal(false);
|
|
3656
3629
|
showSuccessNotification("Your payment method has been saved");
|
|
@@ -3695,7 +3668,7 @@ var quoteRecalculateTaxes = function (_a) {
|
|
|
3695
3668
|
switch (_d.label) {
|
|
3696
3669
|
case 0:
|
|
3697
3670
|
vars = { id: quoteId };
|
|
3698
|
-
return [4 /*yield*/, gqlRequest
|
|
3671
|
+
return [4 /*yield*/, gqlRequest({
|
|
3699
3672
|
query: QUOTE_RECALCULATE_TAXES,
|
|
3700
3673
|
token: token,
|
|
3701
3674
|
vars: vars,
|
|
@@ -3720,7 +3693,7 @@ var getTaxationRequiredAccountFields = function (_a) {
|
|
|
3720
3693
|
var _b, _c;
|
|
3721
3694
|
return __generator(this, function (_d) {
|
|
3722
3695
|
switch (_d.label) {
|
|
3723
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
3696
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
3724
3697
|
query: MUTATION$5,
|
|
3725
3698
|
token: token,
|
|
3726
3699
|
apiHost: apiHost,
|
|
@@ -3756,7 +3729,7 @@ var accountUpdate = function (_a) {
|
|
|
3756
3729
|
switch (_c.label) {
|
|
3757
3730
|
case 0:
|
|
3758
3731
|
vars = { id: accountId, attributes: attributes };
|
|
3759
|
-
return [4 /*yield*/, gqlRequest
|
|
3732
|
+
return [4 /*yield*/, gqlRequest({
|
|
3760
3733
|
query: MUTATION$4,
|
|
3761
3734
|
token: token,
|
|
3762
3735
|
vars: vars,
|
|
@@ -3896,7 +3869,7 @@ var Checkout = function (_a) {
|
|
|
3896
3869
|
((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
|
|
3897
3870
|
}), account = _g.data, isLoadingAccount = _g.isLoading;
|
|
3898
3871
|
useQuery({
|
|
3899
|
-
queryKey: queryKeyFactory.createQuoteTaxCalculateKey(quote === null || quote === void 0 ? void 0 : quote.id),
|
|
3872
|
+
queryKey: queryKeyFactory.createQuoteTaxCalculateKey(token, quote === null || quote === void 0 ? void 0 : quote.id),
|
|
3900
3873
|
queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3901
3874
|
var updatedQuote;
|
|
3902
3875
|
return __generator(this, function (_a) {
|
|
@@ -3912,7 +3885,7 @@ var Checkout = function (_a) {
|
|
|
3912
3885
|
updatedQuote = _a.sent();
|
|
3913
3886
|
if (updatedQuote) {
|
|
3914
3887
|
queryClient.setQueryData(queryKeyFactory.createObjectKey("editingQuote", updatedQuote.id), updatedQuote);
|
|
3915
|
-
queryClient.setQueryData(queryKeyFactory.calculatedPricesKey(quantity, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
|
|
3888
|
+
queryClient.setQueryData(queryKeyFactory.calculatedPricesKey(token, quantity, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
|
|
3916
3889
|
}
|
|
3917
3890
|
_a.label = 2;
|
|
3918
3891
|
case 2: return [2 /*return*/, {}];
|
|
@@ -4076,7 +4049,7 @@ function Signup(_a) {
|
|
|
4076
4049
|
var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
|
|
4077
4050
|
var _j = useState(false), purchaseSucceeded = _j[0], setPurchaseSucceeded = _j[1];
|
|
4078
4051
|
var _k = useState(undefined), paymentMethodGraphQLClient = _k[0], setPaymentMethodGraphQLClient = _k[1];
|
|
4079
|
-
var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient).data;
|
|
4052
|
+
var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient, entityId, token).data;
|
|
4080
4053
|
var queryClient = useQueryClient();
|
|
4081
4054
|
// Queries
|
|
4082
4055
|
var priceListData = useQuery({
|
|
@@ -4111,7 +4084,7 @@ function Signup(_a) {
|
|
|
4111
4084
|
// We must invalidate the accountPaymentMethodKey query in order to clear payment methods from the provided api token,
|
|
4112
4085
|
// to instead use paymentMethods from portalSessionToken.
|
|
4113
4086
|
queryClient.invalidateQueries({
|
|
4114
|
-
queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
|
|
4087
|
+
queryKey: QueryKeyFactory.default.accountPaymentMethodKey(token, entityId),
|
|
4115
4088
|
});
|
|
4116
4089
|
setProceedingToPayment(false);
|
|
4117
4090
|
setQuote(data.quote);
|
|
@@ -4183,7 +4156,7 @@ var getPlanChangeOptions = function (_a) {
|
|
|
4183
4156
|
var response, planChangeOptions;
|
|
4184
4157
|
return __generator(this, function (_b) {
|
|
4185
4158
|
switch (_b.label) {
|
|
4186
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
4159
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
4187
4160
|
isInPreviewMode: isInPreviewMode,
|
|
4188
4161
|
query: PLAN_CHANGE_OPTIONS_QUERY,
|
|
4189
4162
|
vars: { subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id },
|
|
@@ -4213,7 +4186,7 @@ var getSubscriptions = function (_a) {
|
|
|
4213
4186
|
var _b;
|
|
4214
4187
|
return __generator(this, function (_c) {
|
|
4215
4188
|
switch (_c.label) {
|
|
4216
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
4189
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
4217
4190
|
isInPreviewMode: isInPreviewMode,
|
|
4218
4191
|
query: SUBSCRIPTIONS_QUERY,
|
|
4219
4192
|
token: token,
|
|
@@ -4322,7 +4295,7 @@ var getFeatureUsage = function (_a) {
|
|
|
4322
4295
|
vars = {
|
|
4323
4296
|
id: subscriptionChargeId,
|
|
4324
4297
|
};
|
|
4325
|
-
return [4 /*yield*/, gqlRequest
|
|
4298
|
+
return [4 /*yield*/, gqlRequest({
|
|
4326
4299
|
query: FEATURE_USAGE_MUTATION,
|
|
4327
4300
|
token: token,
|
|
4328
4301
|
vars: vars,
|
|
@@ -4777,12 +4750,12 @@ var Subscriptions = function (_a) {
|
|
|
4777
4750
|
var token = useToken();
|
|
4778
4751
|
// Queries
|
|
4779
4752
|
var _d = useQuery({
|
|
4780
|
-
queryKey: QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4753
|
+
queryKey: QueryKeyFactory.default.createTableKey(token, "subscriptions"),
|
|
4781
4754
|
queryFn: function () { return getSubscriptions({ entityId: entityId, token: token, apiHost: apiHost }); },
|
|
4782
4755
|
enabled: Boolean(entityId),
|
|
4783
4756
|
}), rawSubscriptions = _d.data, subscriptionsAreLoading = _d.isLoading;
|
|
4784
4757
|
var _e = useQuery({
|
|
4785
|
-
queryKey: QueryKeyFactory.default.planChangeOptionsKey(),
|
|
4758
|
+
queryKey: QueryKeyFactory.default.planChangeOptionsKey(token),
|
|
4786
4759
|
queryFn: function () { return getPlanChangeOptions({ token: token, apiHost: apiHost }); },
|
|
4787
4760
|
enabled: Boolean(onChangePlanClick),
|
|
4788
4761
|
}), planChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
|
|
@@ -4812,7 +4785,7 @@ var billingDetailsUpdate = function (_a) {
|
|
|
4812
4785
|
switch (_c.label) {
|
|
4813
4786
|
case 0:
|
|
4814
4787
|
vars = { attributes: attributes };
|
|
4815
|
-
return [4 /*yield*/, gqlRequest
|
|
4788
|
+
return [4 /*yield*/, gqlRequest({
|
|
4816
4789
|
query: MUTATION,
|
|
4817
4790
|
token: token,
|
|
4818
4791
|
vars: vars,
|
|
@@ -4840,7 +4813,7 @@ var getBillingDetails = function (_a) {
|
|
|
4840
4813
|
var _b;
|
|
4841
4814
|
return __generator(this, function (_c) {
|
|
4842
4815
|
switch (_c.label) {
|
|
4843
|
-
case 0: return [4 /*yield*/, gqlRequest
|
|
4816
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
4844
4817
|
query: billingDetailsQuery(),
|
|
4845
4818
|
token: token,
|
|
4846
4819
|
apiHost: apiHost,
|
|
@@ -4878,7 +4851,7 @@ var BillingDetails = function (_a) {
|
|
|
4878
4851
|
var values = Form.useWatch([], form);
|
|
4879
4852
|
// Queries
|
|
4880
4853
|
var _g = useQuery({
|
|
4881
|
-
queryKey:
|
|
4854
|
+
queryKey: QueryKeyFactory.default.billingDetailsKey(token, entityId),
|
|
4882
4855
|
queryFn: function () { return getBillingDetails({ token: token, apiHost: apiHost }); },
|
|
4883
4856
|
}), billingDetails = _g.data, isLoadingBillingDetails = _g.isLoading;
|
|
4884
4857
|
var _h = useMutation({
|
|
@@ -4902,7 +4875,7 @@ var BillingDetails = function (_a) {
|
|
|
4902
4875
|
})];
|
|
4903
4876
|
case 1:
|
|
4904
4877
|
updatedBillingDetails = _a.sent();
|
|
4905
|
-
queryClient.setQueryData(
|
|
4878
|
+
queryClient.setQueryData(QueryKeyFactory.default.billingDetailsKey(token, entityId), function (old) {
|
|
4906
4879
|
return __assign(__assign({}, old), updatedBillingDetails.billingDetails);
|
|
4907
4880
|
});
|
|
4908
4881
|
return [2 /*return*/, updatedBillingDetails];
|
|
@@ -4912,7 +4885,7 @@ var BillingDetails = function (_a) {
|
|
|
4912
4885
|
onSuccess: function () {
|
|
4913
4886
|
showSuccessNotification("Your account details have been saved");
|
|
4914
4887
|
queryClient.invalidateQueries({
|
|
4915
|
-
queryKey:
|
|
4888
|
+
queryKey: QueryKeyFactory.default.taxationRequiredAccountFieldsKey(token, entityId),
|
|
4916
4889
|
});
|
|
4917
4890
|
},
|
|
4918
4891
|
}), updateBillingDetails = _h.mutate, isUpdatingBillingDetails = _h.isPending;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginData } from "@bunnyapp/common";
|
|
2
|
-
declare function useRemovePaymentMethod(paymentPlugins: PluginData[], token: string, apiHost: string, accountId?: string): (data: any) => Promise<void>;
|
|
2
|
+
declare function useRemovePaymentMethod(paymentPlugins: PluginData[], token: string, apiHost: string, entityId: string, accountId?: string): (data: any) => Promise<void>;
|
|
3
3
|
export default useRemovePaymentMethod;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GraphQLClient } from "graphql-request";
|
|
2
|
-
export declare const usePaymentMethod: (graphQLClient: GraphQLClient) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<any, Error>;
|
|
2
|
+
export declare const usePaymentMethod: (graphQLClient: GraphQLClient, entityId: string, token: string) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<any, Error>;
|
package/dist/index.d.ts
CHANGED
|
@@ -209,6 +209,6 @@ declare const BillingDetails: ({ entityId, isCardEnabled, shadow, className, hid
|
|
|
209
209
|
}) => boolean) | undefined;
|
|
210
210
|
}) => react_jsx_runtime.JSX.Element;
|
|
211
211
|
|
|
212
|
-
declare const usePaymentMethod: (graphQLClient: GraphQLClient) => _tanstack_react_query_build_legacy_types.UseQueryResult<any, Error>;
|
|
212
|
+
declare const usePaymentMethod: (graphQLClient: GraphQLClient, entityId: string, token: string) => _tanstack_react_query_build_legacy_types.UseQueryResult<any, Error>;
|
|
213
213
|
|
|
214
214
|
export { BillingDetails, BunnyProvider, Checkout, Invoice, PaymentMethod, Quote, Quotes, Signup, Subscriptions, Transactions, getQuoteAmountDue, usePaymentMethod };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunnyapp/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
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",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vite": "^5.4.11"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@bunnyapp/common": "^1.0.
|
|
65
|
+
"@bunnyapp/common": "^1.0.43",
|
|
66
66
|
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
67
67
|
"@fortawesome/free-brands-svg-icons": "^6.7.2",
|
|
68
68
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type gqlRequestOptions = {
|
|
2
|
-
query: string;
|
|
3
|
-
vars?: Record<string, any>;
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
token: string;
|
|
6
|
-
isInPreviewMode?: boolean;
|
|
7
|
-
apiHost: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const gqlRequest: ({ query, vars, headers, token, isInPreviewMode, apiHost, }: gqlRequestOptions) => Promise<unknown>;
|
|
10
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type gqlRequestOptions = {
|
|
2
|
-
query: string;
|
|
3
|
-
vars?: Record<string, any>;
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
token: string;
|
|
6
|
-
isInPreviewMode?: boolean;
|
|
7
|
-
apiHost: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const gqlRequest: ({ query, vars, headers, token, isInPreviewMode, apiHost, }: gqlRequestOptions) => Promise<unknown>;
|
|
10
|
-
export {};
|