@bunnyapp/components 1.1.0 → 1.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -154,7 +154,7 @@ var BrandContext = react.createContext({
154
154
  });
155
155
 
156
156
  // This will be replaced at build time by rollup-plugin-replace
157
- var PACKAGE_VERSION = '1.1.0-beta.5';
157
+ var PACKAGE_VERSION = '1.2.0-beta.1';
158
158
  var createRequestHeaders = function (token) {
159
159
  var headers = common.createClientDevHeaders(token);
160
160
  // Add the components version header
@@ -20438,13 +20438,42 @@ var useUpdateCoupons = function (_a) {
20438
20438
  };
20439
20439
  };
20440
20440
 
20441
- var useCurrentUserData = function () {
20442
- var queryClient = reactQuery.useQueryClient();
20443
- var token = useToken();
20444
- var currentUser = queryClient.getQueryData(common.QueryKeyFactory.default.currentUserKey(token));
20445
- if (!currentUser)
20446
- return {};
20447
- return currentUser;
20441
+ var CURRENT_USER_DATA_QUERY = "{\n company {\n name\n }\n currentUser {\n account {\n billingCountry\n currencyId\n }\n authObjectName\n payload {\n returnUrl\n }\n privacyUrl\n termsUrl\n entityId\n }\n }";
20442
+ var getCurrentUserData = function (_a) {
20443
+ var token = _a.token, apiHost = _a.apiHost;
20444
+ return __awaiter(void 0, void 0, void 0, function () {
20445
+ var response;
20446
+ var _b, _c, _d, _e, _f, _g, _h, _j;
20447
+ return __generator(this, function (_k) {
20448
+ switch (_k.label) {
20449
+ case 0: return [4 /*yield*/, common.gqlRequest({
20450
+ query: CURRENT_USER_DATA_QUERY,
20451
+ token: token,
20452
+ apiHost: apiHost,
20453
+ })];
20454
+ case 1:
20455
+ response = _k.sent();
20456
+ return [2 /*return*/, {
20457
+ authObjectName: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.authObjectName,
20458
+ account: (_c = response === null || response === void 0 ? void 0 : response.currentUser) === null || _c === void 0 ? void 0 : _c.account,
20459
+ companyName: (_d = response === null || response === void 0 ? void 0 : response.company) === null || _d === void 0 ? void 0 : _d.name,
20460
+ returnUrl: (_f = (_e = response === null || response === void 0 ? void 0 : response.currentUser) === null || _e === void 0 ? void 0 : _e.payload) === null || _f === void 0 ? void 0 : _f.returnUrl,
20461
+ privacyUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.privacyUrl,
20462
+ termsUrl: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.termsUrl,
20463
+ entityId: (_j = response === null || response === void 0 ? void 0 : response.currentUser) === null || _j === void 0 ? void 0 : _j.entityId,
20464
+ }];
20465
+ }
20466
+ });
20467
+ });
20468
+ };
20469
+
20470
+ var useCurrentUserData = function (token) {
20471
+ var apiHost = react.useContext(BunnyContext).apiHost;
20472
+ var currentUserData = reactQuery.useQuery({
20473
+ queryKey: common.QueryKeyFactory.default.currentUserKey(token),
20474
+ queryFn: function () { return getCurrentUserData({ token: token, apiHost: apiHost }); },
20475
+ }).data;
20476
+ return currentUserData || {};
20448
20477
  };
20449
20478
 
20450
20479
  var BunnyFooterIcon = function (_a) {
@@ -21727,7 +21756,7 @@ var PlanPickerCheckoutBar = function (_a) {
21727
21756
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
21728
21757
  var PRICE_LIST_CHANGE_OPTIONS_QUERY = "\n query priceListChangeOptions($subscriptionId: ID, $productId: ID) {\n priceListChangeOptions(subscriptionId: $subscriptionId, productId: $productId) {\n products {\n everythingInPlus\n id\n name\n plansToDisplay\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n priceLists {\n showPriceAsMonthly\n basePrice\n currencyId\n id\n monthlyBasePrice\n periodMonths\n plan {\n code\n contactUsLabel\n contactUsUrl\n description\n id\n name\n position\n pricingDescription\n pricingStyle\n planFeatures {\n featureId\n value\n feature {\n name\n }\n }\n }\n product {\n id\n }\n charges {\n featureAddon\n basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n priceList {\n id\n }\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
21729
21758
  var getPriceListChangeOptions = function (_a) {
21730
- var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
21759
+ var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription, accountCurrencyId = _a.accountCurrencyId;
21731
21760
  return __awaiter(void 0, void 0, void 0, function () {
21732
21761
  var response, priceListChangeOptions;
21733
21762
  return __generator(this, function (_b) {
@@ -21748,6 +21777,8 @@ var getPriceListChangeOptions = function (_a) {
21748
21777
  if (priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) {
21749
21778
  priceListChangeOptions.priceLists.sort(function (a, b) { return a.plan.position - b.plan.position; });
21750
21779
  }
21780
+ // Filter out price lists that don't have the same currency as the account
21781
+ priceListChangeOptions.priceLists = priceListChangeOptions.priceLists.filter(function (priceList) { return priceList.currencyId === accountCurrencyId; });
21751
21782
  return [2 /*return*/, priceListChangeOptions];
21752
21783
  }
21753
21784
  });
@@ -22519,6 +22550,7 @@ var PlanPicker = function () {
22519
22550
  var apiHost = react.useContext(BunnyContext).apiHost;
22520
22551
  var _b = react.useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, productId = _b.productId, upgradingSubscription = _b.upgradingSubscription;
22521
22552
  var _c = react.useContext(QuotePreviewContext), quotePreviewData = _c.quotePreviewData, setQuotePreviewData = _c.setQuotePreviewData;
22553
+ var account = useCurrentUserData(token).account;
22522
22554
  // Hooks
22523
22555
  var showInfoNotification = common.useInfoNotification();
22524
22556
  // Queries
@@ -22541,6 +22573,7 @@ var PlanPicker = function () {
22541
22573
  productId: productId,
22542
22574
  token: token,
22543
22575
  upgradingSubscription: upgradingSubscription,
22576
+ accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId,
22544
22577
  });
22545
22578
  },
22546
22579
  enabled: !areSubscriptionsLoading,
@@ -23124,10 +23157,13 @@ var SubscriptionsListContainer = function (_a) {
23124
23157
  var apiHost = react.useContext(BunnyContext).apiHost;
23125
23158
  var gap = react.useContext(SubscriptionsContext).gap;
23126
23159
  var token = useToken();
23160
+ var account = useCurrentUserData(token).account;
23127
23161
  // Queries
23128
23162
  var _c = reactQuery.useQuery({
23129
23163
  queryKey: common.QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
23130
- queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
23164
+ queryFn: function () {
23165
+ return getPriceListChangeOptions({ apiHost: apiHost, token: token, accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId });
23166
+ },
23131
23167
  enabled: Boolean(onChangePlanClick),
23132
23168
  }), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
23133
23169
  if (subscriptionsAreLoading ||
@@ -0,0 +1,13 @@
1
+ declare const getCurrentUserData: ({ token, apiHost }: {
2
+ token?: string | undefined;
3
+ apiHost: string;
4
+ }) => Promise<{
5
+ authObjectName: any;
6
+ account: any;
7
+ companyName: any;
8
+ returnUrl: any;
9
+ privacyUrl: any;
10
+ termsUrl: any;
11
+ entityId: any;
12
+ }>;
13
+ export default getCurrentUserData;
@@ -1,9 +1,10 @@
1
1
  import { Subscription } from '@bunnyapp/common';
2
- declare const getPriceListChangeOptions: ({ apiHost, isInPreviewMode, productId, token, upgradingSubscription, }: {
2
+ declare const getPriceListChangeOptions: ({ apiHost, isInPreviewMode, productId, token, upgradingSubscription, accountCurrencyId, }: {
3
3
  apiHost: string;
4
4
  isInPreviewMode?: boolean | undefined;
5
5
  productId?: string | undefined;
6
6
  token?: string | undefined;
7
7
  upgradingSubscription?: Subscription | undefined;
8
+ accountCurrencyId: string;
8
9
  }) => Promise<any>;
9
10
  export default getPriceListChangeOptions;
@@ -1,2 +1,11 @@
1
- declare const useCurrentUserData: () => any;
1
+ import { currentUser as CurrentUser } from '@bunnyapp/common';
2
+ declare const useCurrentUserData: (token?: string) => {
3
+ authObjectName: any;
4
+ account: any;
5
+ companyName: any;
6
+ returnUrl: any;
7
+ privacyUrl: any;
8
+ termsUrl: any;
9
+ entityId: any;
10
+ } | CurrentUser;
2
11
  export default useCurrentUserData;
package/dist/esm/index.js CHANGED
@@ -143,7 +143,7 @@ var BrandContext = createContext({
143
143
  });
144
144
 
145
145
  // This will be replaced at build time by rollup-plugin-replace
146
- var PACKAGE_VERSION = '1.1.0-beta.5';
146
+ var PACKAGE_VERSION = '1.2.0-beta.1';
147
147
  var createRequestHeaders = function (token) {
148
148
  var headers = createClientDevHeaders(token);
149
149
  // Add the components version header
@@ -20427,13 +20427,42 @@ var useUpdateCoupons = function (_a) {
20427
20427
  };
20428
20428
  };
20429
20429
 
20430
- var useCurrentUserData = function () {
20431
- var queryClient = useQueryClient();
20432
- var token = useToken();
20433
- var currentUser = queryClient.getQueryData(QueryKeyFactory.default.currentUserKey(token));
20434
- if (!currentUser)
20435
- return {};
20436
- return currentUser;
20430
+ var CURRENT_USER_DATA_QUERY = "{\n company {\n name\n }\n currentUser {\n account {\n billingCountry\n currencyId\n }\n authObjectName\n payload {\n returnUrl\n }\n privacyUrl\n termsUrl\n entityId\n }\n }";
20431
+ var getCurrentUserData = function (_a) {
20432
+ var token = _a.token, apiHost = _a.apiHost;
20433
+ return __awaiter(void 0, void 0, void 0, function () {
20434
+ var response;
20435
+ var _b, _c, _d, _e, _f, _g, _h, _j;
20436
+ return __generator(this, function (_k) {
20437
+ switch (_k.label) {
20438
+ case 0: return [4 /*yield*/, gqlRequest$1({
20439
+ query: CURRENT_USER_DATA_QUERY,
20440
+ token: token,
20441
+ apiHost: apiHost,
20442
+ })];
20443
+ case 1:
20444
+ response = _k.sent();
20445
+ return [2 /*return*/, {
20446
+ authObjectName: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.authObjectName,
20447
+ account: (_c = response === null || response === void 0 ? void 0 : response.currentUser) === null || _c === void 0 ? void 0 : _c.account,
20448
+ companyName: (_d = response === null || response === void 0 ? void 0 : response.company) === null || _d === void 0 ? void 0 : _d.name,
20449
+ returnUrl: (_f = (_e = response === null || response === void 0 ? void 0 : response.currentUser) === null || _e === void 0 ? void 0 : _e.payload) === null || _f === void 0 ? void 0 : _f.returnUrl,
20450
+ privacyUrl: (_g = response === null || response === void 0 ? void 0 : response.currentUser) === null || _g === void 0 ? void 0 : _g.privacyUrl,
20451
+ termsUrl: (_h = response === null || response === void 0 ? void 0 : response.currentUser) === null || _h === void 0 ? void 0 : _h.termsUrl,
20452
+ entityId: (_j = response === null || response === void 0 ? void 0 : response.currentUser) === null || _j === void 0 ? void 0 : _j.entityId,
20453
+ }];
20454
+ }
20455
+ });
20456
+ });
20457
+ };
20458
+
20459
+ var useCurrentUserData = function (token) {
20460
+ var apiHost = useContext(BunnyContext).apiHost;
20461
+ var currentUserData = useQuery({
20462
+ queryKey: QueryKeyFactory.default.currentUserKey(token),
20463
+ queryFn: function () { return getCurrentUserData({ token: token, apiHost: apiHost }); },
20464
+ }).data;
20465
+ return currentUserData || {};
20437
20466
  };
20438
20467
 
20439
20468
  var BunnyFooterIcon = function (_a) {
@@ -21716,7 +21745,7 @@ var PlanPickerCheckoutBar = function (_a) {
21716
21745
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
21717
21746
  var PRICE_LIST_CHANGE_OPTIONS_QUERY = "\n query priceListChangeOptions($subscriptionId: ID, $productId: ID) {\n priceListChangeOptions(subscriptionId: $subscriptionId, productId: $productId) {\n products {\n everythingInPlus\n id\n name\n plansToDisplay\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n priceLists {\n showPriceAsMonthly\n basePrice\n currencyId\n id\n monthlyBasePrice\n periodMonths\n plan {\n code\n contactUsLabel\n contactUsUrl\n description\n id\n name\n position\n pricingDescription\n pricingStyle\n planFeatures {\n featureId\n value\n feature {\n name\n }\n }\n }\n product {\n id\n }\n charges {\n featureAddon\n basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n priceList {\n id\n }\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
21718
21747
  var getPriceListChangeOptions = function (_a) {
21719
- var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
21748
+ var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription, accountCurrencyId = _a.accountCurrencyId;
21720
21749
  return __awaiter(void 0, void 0, void 0, function () {
21721
21750
  var response, priceListChangeOptions;
21722
21751
  return __generator(this, function (_b) {
@@ -21737,6 +21766,8 @@ var getPriceListChangeOptions = function (_a) {
21737
21766
  if (priceListChangeOptions === null || priceListChangeOptions === void 0 ? void 0 : priceListChangeOptions.priceLists) {
21738
21767
  priceListChangeOptions.priceLists.sort(function (a, b) { return a.plan.position - b.plan.position; });
21739
21768
  }
21769
+ // Filter out price lists that don't have the same currency as the account
21770
+ priceListChangeOptions.priceLists = priceListChangeOptions.priceLists.filter(function (priceList) { return priceList.currencyId === accountCurrencyId; });
21740
21771
  return [2 /*return*/, priceListChangeOptions];
21741
21772
  }
21742
21773
  });
@@ -22508,6 +22539,7 @@ var PlanPicker = function () {
22508
22539
  var apiHost = useContext(BunnyContext).apiHost;
22509
22540
  var _b = useContext(SubscriptionsContext), isInPreviewMode = _b.isInPreviewMode, productId = _b.productId, upgradingSubscription = _b.upgradingSubscription;
22510
22541
  var _c = useContext(QuotePreviewContext), quotePreviewData = _c.quotePreviewData, setQuotePreviewData = _c.setQuotePreviewData;
22542
+ var account = useCurrentUserData(token).account;
22511
22543
  // Hooks
22512
22544
  var showInfoNotification = useInfoNotification();
22513
22545
  // Queries
@@ -22530,6 +22562,7 @@ var PlanPicker = function () {
22530
22562
  productId: productId,
22531
22563
  token: token,
22532
22564
  upgradingSubscription: upgradingSubscription,
22565
+ accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId,
22533
22566
  });
22534
22567
  },
22535
22568
  enabled: !areSubscriptionsLoading,
@@ -23113,10 +23146,13 @@ var SubscriptionsListContainer = function (_a) {
23113
23146
  var apiHost = useContext(BunnyContext).apiHost;
23114
23147
  var gap = useContext(SubscriptionsContext).gap;
23115
23148
  var token = useToken();
23149
+ var account = useCurrentUserData(token).account;
23116
23150
  // Queries
23117
23151
  var _c = useQuery({
23118
23152
  queryKey: QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
23119
- queryFn: function () { return getPriceListChangeOptions({ apiHost: apiHost, token: token }); },
23153
+ queryFn: function () {
23154
+ return getPriceListChangeOptions({ apiHost: apiHost, token: token, accountCurrencyId: account === null || account === void 0 ? void 0 : account.currencyId });
23155
+ },
23120
23156
  enabled: Boolean(onChangePlanClick),
23121
23157
  }), priceListChangeOptions = _c.data, arePriceListChangeOptionsLoading = _c.isLoading;
23122
23158
  if (subscriptionsAreLoading ||
@@ -0,0 +1,13 @@
1
+ declare const getCurrentUserData: ({ token, apiHost }: {
2
+ token?: string | undefined;
3
+ apiHost: string;
4
+ }) => Promise<{
5
+ authObjectName: any;
6
+ account: any;
7
+ companyName: any;
8
+ returnUrl: any;
9
+ privacyUrl: any;
10
+ termsUrl: any;
11
+ entityId: any;
12
+ }>;
13
+ export default getCurrentUserData;
@@ -1,9 +1,10 @@
1
1
  import { Subscription } from '@bunnyapp/common';
2
- declare const getPriceListChangeOptions: ({ apiHost, isInPreviewMode, productId, token, upgradingSubscription, }: {
2
+ declare const getPriceListChangeOptions: ({ apiHost, isInPreviewMode, productId, token, upgradingSubscription, accountCurrencyId, }: {
3
3
  apiHost: string;
4
4
  isInPreviewMode?: boolean | undefined;
5
5
  productId?: string | undefined;
6
6
  token?: string | undefined;
7
7
  upgradingSubscription?: Subscription | undefined;
8
+ accountCurrencyId: string;
8
9
  }) => Promise<any>;
9
10
  export default getPriceListChangeOptions;
@@ -1,2 +1,11 @@
1
- declare const useCurrentUserData: () => any;
1
+ import { currentUser as CurrentUser } from '@bunnyapp/common';
2
+ declare const useCurrentUserData: (token?: string) => {
3
+ authObjectName: any;
4
+ account: any;
5
+ companyName: any;
6
+ returnUrl: any;
7
+ privacyUrl: any;
8
+ termsUrl: any;
9
+ entityId: any;
10
+ } | CurrentUser;
2
11
  export default useCurrentUserData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-beta.2",
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",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@ant-design/icons": "^5.6.1",
67
- "@bunnyapp/common": "^1.1.0",
67
+ "@bunnyapp/common": "^1.1.0-beta.4",
68
68
  "@fortawesome/fontawesome-svg-core": "^6.7.2",
69
69
  "@fortawesome/free-brands-svg-icons": "^6.7.2",
70
70
  "@fortawesome/free-regular-svg-icons": "^6.7.2",