@bunnyapp/components 1.0.68-beta.8 → 1.0.68

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
@@ -25,6 +25,24 @@ var pkg = require('pluralize');
25
25
 
26
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
27
 
28
+ function _interopNamespace(e) {
29
+ if (e && e.__esModule) return e;
30
+ var n = Object.create(null);
31
+ if (e) {
32
+ Object.keys(e).forEach(function (k) {
33
+ if (k !== 'default') {
34
+ var d = Object.getOwnPropertyDescriptor(e, k);
35
+ Object.defineProperty(n, k, d.get ? d : {
36
+ enumerable: true,
37
+ get: function () { return e[k]; }
38
+ });
39
+ }
40
+ });
41
+ }
42
+ n["default"] = e;
43
+ return Object.freeze(n);
44
+ }
45
+
28
46
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
29
47
  var theme__default = /*#__PURE__*/_interopDefaultLegacy(theme);
30
48
  var request__default = /*#__PURE__*/_interopDefaultLegacy(request);
@@ -156,7 +174,7 @@ var BrandContext = react.createContext({
156
174
  });
157
175
 
158
176
  // This will be replaced at build time by rollup-plugin-replace
159
- var PACKAGE_VERSION = '1.0.68-beta.8';
177
+ var PACKAGE_VERSION = '1.0.67';
160
178
  var createRequestHeaders = function (token) {
161
179
  var headers = common.createClientDevHeaders(token);
162
180
  // Add the components version header
@@ -391,19 +409,6 @@ function useToken() {
391
409
  }
392
410
 
393
411
  var LISENSE_KEY = 'eyJkYXRhIjoiZXlKMElqb2liM0puWVc1cGVtRjBhVzl1SWl3aVlYWjFJam94TnpneU5ETXhPVGs1TENKa2JTSTZJbUoxYm01NUxtTnZiU0lzSW00aU9pSmhOV1F5TWpKaFpXTTNOelF5TkdFNUlpd2laWGh3SWpveE56WTJORFEzT1RrNUxDSmtiWFFpT2lKM2FXeGtZMkZ5WkNKOSIsInNpZ25hdHVyZSI6ImdJWW5BYWp0WW1aSHV1b1RrTkZCZnRGYjEzUTJOZXZwQXlKRmszdy9STDNUa08rRXZYWlV0MDZxenBrZWdOK1A4TXlkbFY1aityemQvM1VpYlB5SW1VSzAweHZSVk5hS29EOXB0cVpkbjR5SWRRdE1pU1NjZ0J1K1RkM0NXM2FONVNrdlNJVDEyTGpBMnVVYll2RmJ6RFpMci9hODkwa05sT0NQZURoVjMyd0w3R0NrTnV2Z1MyZlk5Mis0L25FdUdvZXBZR0RPN0Ryb3NaOGVlbnJ6b1BsQ044T204eFlMNXJxdUkvS2xLVTVYaGN0allrdzBTR0FlL0pDR1dTN1dLTDAvYmFvbS9GS1ltNU91VmlzcmlDVlc2UXgvbzBnTGE4bUtXLytMb3pNaHdFemdtU2I2S0xERzZpTEVPL0czQ2pYN2p2dTU1NEc4OUx2aW1BaE5BQT09In0=';
394
- // Custom zoom layout component that uses useZoomContext
395
- var CustomZoomLayout = function () {
396
- // Consume from the controller provider
397
- var _a = react$1.useZoomContext(), currentZoom = _a.currentZoom, setZoomLevel = _a.setZoomLevel;
398
- var mountTimeRef = react.useRef(Date.now());
399
- // Set default zoom to 100% once the document is loaded
400
- react.useEffect(function () {
401
- if (currentZoom < 1 && Date.now() - mountTimeRef.current < 3000) {
402
- setZoomLevel(100);
403
- }
404
- }, [currentZoom, setZoomLevel]);
405
- return jsxRuntime.jsx(jsxRuntime.Fragment, {});
406
- };
407
412
  var DocumentTemplatePreview = function (_a) {
408
413
  var targetUrl = _a.targetUrl;
409
414
  var _b = react.useState(null), pdfUrl = _b[0], setPdfUrl = _b[1];
@@ -451,13 +456,13 @@ var DocumentTemplatePreview = function (_a) {
451
456
  if (!pdfUrl) {
452
457
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
453
458
  }
454
- return (jsxRuntime.jsx("div", __assign({ className: "bunny-rounded bunny-w-full bunny-overflow-hidden bunny-grow bunny-min-h-0" }, { children: jsxRuntime.jsx(react$1.RPConfig, __assign({ licenseKey: LISENSE_KEY }, { children: jsxRuntime.jsxs(react$1.RPProvider, __assign({ src: pdfUrl }, { children: [jsxRuntime.jsx(CustomZoomLayout, {}), jsxRuntime.jsx(react$1.RPDefaultLayout, __assign({ style: {
455
- width: '100%',
456
- height: '100%',
457
- }, slots: {
458
- openFileTool: false,
459
- downloadTool: false,
460
- } }, { children: jsxRuntime.jsx(react$1.RPPages, {}) }))] })) })) })));
459
+ return (jsxRuntime.jsx("div", __assign({ className: "bunny-rounded bunny-w-full bunny-overflow-hidden bunny-grow bunny-min-h-0" }, { children: jsxRuntime.jsx(react$1.RPConfig, __assign({ licenseKey: LISENSE_KEY }, { children: jsxRuntime.jsx(react$1.RPProvider, __assign({ src: pdfUrl }, { children: jsxRuntime.jsx(react$1.RPDefaultLayout, __assign({ style: {
460
+ width: '100%',
461
+ height: '100%',
462
+ }, slots: {
463
+ openFileTool: false,
464
+ downloadTool: false,
465
+ } }, { children: jsxRuntime.jsx(react$1.RPPages, {}) })) })) })) })));
461
466
  };
462
467
 
463
468
  var MarkupContainer = defaultStyled.div(templateObject_1$c || (templateObject_1$c = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
@@ -565,15 +570,11 @@ var usePaymentMethod = function (_a) {
565
570
  };
566
571
 
567
572
  var filterPaymentPlugins = function (plugins) {
568
- return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) { var _a, _b; return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'payment' && ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'valid'; });
569
- };
570
- var filterPaymentPluginsByEntity = function (plugins, selectedEntityId) {
571
573
  return plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (plugin) {
572
- var _a, _b;
573
- return selectedEntityId === undefined ||
574
- selectedEntityId === null ||
575
- ((_a = plugin.entities) === null || _a === void 0 ? void 0 : _a.includes(selectedEntityId)) ||
576
- ((_b = plugin.entities) === null || _b === void 0 ? void 0 : _b.length) === 0;
574
+ var _a, _b, _c, _d;
575
+ return ((_a = plugin.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'payment' &&
576
+ ((_b = plugin.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'valid' &&
577
+ ((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.length);
577
578
  });
578
579
  };
579
580
  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}";
@@ -602,18 +603,19 @@ var getPaymentPlugins = function (_a) {
602
603
  });
603
604
  };
604
605
  var usePaymentPlugins = function (_a) {
605
- var apiHost = _a.apiHost, token = _a.token, selectedEntityId = _a.selectedEntityId;
606
+ var apiHost = _a.apiHost, token = _a.token;
606
607
  var _b = reactQuery.useQuery({
607
608
  queryKey: ['paymentPlugins', token],
608
609
  queryFn: function () { return getPaymentPlugins({ apiHost: apiHost, token: token }); },
609
610
  staleTime: 5 * 60 * 1000, // Consider data fresh for 5 minutes
610
611
  }), paymentPlugins = _b.data, isFetched = _b.isFetched;
611
612
  var filteredPaymentPlugins = filterPaymentPlugins(paymentPlugins);
612
- var filteredPaymentPluginsByEntity = selectedEntityId
613
- ? filterPaymentPluginsByEntity(filteredPaymentPlugins, selectedEntityId)
614
- : filteredPaymentPlugins;
613
+ var paymentMethodAllowedPlugins = filteredPaymentPlugins === null || filteredPaymentPlugins === void 0 ? void 0 : filteredPaymentPlugins.filter(function (plugin) {
614
+ var _a, _b;
615
+ 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'); });
616
+ });
615
617
  return {
616
- paymentPlugins: filteredPaymentPluginsByEntity,
618
+ paymentPlugins: paymentMethodAllowedPlugins,
617
619
  isFetched: isFetched,
618
620
  };
619
621
  };
@@ -19086,7 +19088,7 @@ function useSetDefaultPaymentMethod(paymentPlugins, apiHost, token, accountId, o
19086
19088
  var showErrorNotification$1 = common.useErrorNotification();
19087
19089
  var PaymentForm = function (_a) {
19088
19090
  var _b;
19089
- var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, onPaymentHoldSuccess = _a.onPaymentHoldSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, onSetDefaultPaymentMethod = _a.onSetDefaultPaymentMethod, entityId = _a.entityId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, paymentHoldOptions = _a.paymentHoldOptions;
19091
+ var invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, onPaymentHoldSuccess = _a.onPaymentHoldSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, onRemovePaymentMethod = _a.onRemovePaymentMethod, onSetDefaultPaymentMethod = _a.onSetDefaultPaymentMethod, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, currencyIdFromProps = _a.currencyId, paymentHoldOptions = _a.paymentHoldOptions;
19090
19092
  // Local state
19091
19093
  var _c = react.useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
19092
19094
  // Simple hooks
@@ -19100,7 +19102,7 @@ var PaymentForm = function (_a) {
19100
19102
  apiHost: apiHost,
19101
19103
  }), storedPaymentMethods = _d.paymentMethods, defaultPaymentMethod = _d.defaultPaymentMethod, isPaymentMethodLoading = _d.isLoading;
19102
19104
  // Complex hooks
19103
- var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, selectedEntityId: entityId, token: token }).paymentPlugins;
19105
+ var paymentPlugins = usePaymentPlugins({ apiHost: apiHost, token: token }).paymentPlugins;
19104
19106
  var selectedPaymentMethodPlugin = react.useMemo(function () {
19105
19107
  return paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = defaultPaymentMethod === null || defaultPaymentMethod === void 0 ? void 0 : defaultPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
19106
19108
  }, [paymentPlugins, defaultPaymentMethod]);
@@ -19180,15 +19182,6 @@ function StripeWrapper(_a) {
19180
19182
  return (jsxRuntime.jsx(reactStripeJs.Elements, __assign({ options: options, stripe: stripe }, { children: children })));
19181
19183
  }
19182
19184
 
19183
- var useCurrentUserData = function () {
19184
- var queryClient = reactQuery.useQueryClient();
19185
- var token = useToken();
19186
- var currentUser = queryClient.getQueryData(common.QueryKeyFactory.default.currentUserKey(token));
19187
- if (!currentUser)
19188
- return {};
19189
- return currentUser;
19190
- };
19191
-
19192
19185
  function Invoice(_a) {
19193
19186
  var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, _b = _a.shadow, shadow = _b === void 0 ? 'shadow-md' : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c, onInvoiceLoaded = _a.onInvoiceLoaded;
19194
19187
  return (jsxRuntime.jsx(InvoiceQuoteContext.Provider, __assign({ value: {
@@ -19208,10 +19201,9 @@ function ActualInvoice() {
19208
19201
  // Context
19209
19202
  var queryClient = reactQuery.useQueryClient();
19210
19203
  var _a = react.useContext(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess, className = _a.className;
19211
- var _b = react.useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
19204
+ var _b = react.useContext(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired; _b.graphQLClient;
19212
19205
  var _c = react.useContext(InvoiceQuoteContext), hideDownloadButton = _c.hideDownloadButton, onInvoiceLoaded = _c.onInvoiceLoaded;
19213
19206
  var token = useToken();
19214
- var entityId = useCurrentUserData().entityId;
19215
19207
  // Hooks
19216
19208
  var showSuccessNotification = common.useSuccessNotification();
19217
19209
  var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
@@ -19247,7 +19239,7 @@ function ActualInvoice() {
19247
19239
  }, [formattedInvoice]);
19248
19240
  if (!formattedInvoice)
19249
19241
  return jsxRuntime.jsx(jsxRuntime.Fragment, {});
19250
- return (jsxRuntime.jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 bunny-overflow-hidden ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsxRuntime.jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
19242
+ return (jsxRuntime.jsx("div", __assign({ className: "bunny-invoice-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-6 bunny-overflow-hidden ".concat(isMobile ? 'bunny-flex-col bunny-w-full' : '', " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsxRuntime.jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
19251
19243
  }
19252
19244
 
19253
19245
  var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n quote {\n documentTemplateId\n documents { id filename size date url }\n firstInvoice {\n id\n state\n }\n payableId\n id\n payToAccept\n currentPaymentHold {\n createdAt\n expiresAt\n id\n updatedAt\n paymentMethod {\n accountId\n createdAt\n expirationDate\n failureCode\n id\n isDefault\n lastSuccess\n paymentType\n pluginId\n state\n updatedAt\n metadata {\n description\n expiration\n icon\n identifier\n issuer\n kind\n }\n }\n }\n }\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
@@ -19368,46 +19360,72 @@ var quoteAccept = function (_a) {
19368
19360
  };
19369
19361
  // export default quoteAccept;
19370
19362
  var useSendAcceptQuote = function (_a) {
19371
- var quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
19363
+ _a.onTokenExpired; var quoteId = _a.quoteId, apiHost = _a.apiHost, token = _a.token;
19372
19364
  // Hooks
19373
19365
  var graphQLMutation = common.useGraphQLmutation(function () {
19374
- console.log('navigate in useGraphQLmutation in useSendAcceptQuote is not yet implemented');
19375
- }, apiHost || '', function () {
19376
- console.log('onError in useGraphQLmutation in useSendAcceptQuote is not yet implemented');
19366
+ console.log("navigate in useGraphQLmutation in useSendAcceptQuote is not yet implemented");
19367
+ }, apiHost || "", function () {
19368
+ console.log("onError in useGraphQLmutation in useSendAcceptQuote is not yet implemented");
19377
19369
  });
19378
19370
  var signingPlugins = useSigningPlugins({ apiHost: apiHost, token: token });
19379
19371
  var queryClient = reactQuery.useQueryClient();
19380
- var showInfoNotification = common.useInfoNotification();
19381
19372
  // Local state
19382
19373
  var _b = react.useState(false), acceptBoxVisible = _b[0], setAcceptBoxVisible = _b[1];
19383
19374
  var _c = react.useState(false), isAccepting = _c[0], setIsAccepting = _c[1];
19384
19375
  // Pandadoc polling modal state
19385
19376
  var _d = react.useState(false), pandadocPollingModalVisible = _d[0], setPandadocPollingModalVisible = _d[1];
19386
19377
  var redirectForSigning = function () {
19387
- var mutation = "mutation quoteSigningUrlCreate($quoteId: ID) {\n quoteSigningUrlCreate(quoteId: $quoteId) {\n redirectUri\n pluginClientId\n pluginShortName\n message\n errors\n }\n }";
19378
+ var mutation = "mutation quoteSigningUrlCreate($quoteId: ID) {\n quoteSigningUrlCreate(quoteId: $quoteId) {\n redirectUri\n pluginClientId\n pluginShortName\n errors\n }\n }";
19388
19379
  var variables = {
19389
19380
  quoteId: quoteId,
19390
19381
  };
19391
19382
  graphQLMutation(mutation, variables, function (rsp) {
19392
19383
  if (rsp.errors)
19393
- console.log('rsp.errors', rsp.errors);
19384
+ console.log("rsp.errors", rsp.errors);
19394
19385
  else {
19395
- var _a = rsp.data.quoteSigningUrlCreate, redirectUri = _a.redirectUri, message = _a.message, pluginShortName = _a.pluginShortName;
19396
- if (redirectUri) {
19397
- // If redirectUri exists, redirect the browser
19398
- window.location.href = redirectUri;
19386
+ if (rsp.data.quoteSigningUrlCreate.pluginShortName === "dropbox_sign") {
19387
+ openDropboxSignModal(rsp.data.quoteSigningUrlCreate.pluginClientId, rsp.data.quoteSigningUrlCreate.redirectUri);
19399
19388
  }
19400
- else if (pluginShortName === 'pandadoc') {
19389
+ else if (rsp.data.quoteSigningUrlCreate.pluginShortName === "pandadoc") {
19401
19390
  setPandadocPollingModalVisible(true);
19402
19391
  }
19403
- else if (message) {
19404
- // If redirectUri is nil but message exists, display the message as notification
19405
- showInfoNotification(message, 'Signing Information');
19406
- setIsAccepting(false);
19392
+ else {
19393
+ window.location.href = rsp.data.quoteSigningUrlCreate.redirectUri;
19407
19394
  }
19408
19395
  }
19409
19396
  }, token);
19410
19397
  };
19398
+ var openDropboxSignModal = function (clientId, url) { return __awaiter(void 0, void 0, void 0, function () {
19399
+ var HelloSign, client;
19400
+ return __generator(this, function (_a) {
19401
+ switch (_a.label) {
19402
+ case 0:
19403
+ if (typeof window === "undefined") {
19404
+ return [2 /*return*/];
19405
+ }
19406
+ return [4 /*yield*/, Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('hellosign-embedded')); })];
19407
+ case 1:
19408
+ HelloSign = (_a.sent()).default;
19409
+ client = new HelloSign({
19410
+ clientId: clientId,
19411
+ });
19412
+ client.on("sign", function (data) {
19413
+ queryClient.refetchQueries({
19414
+ queryKey: common.QueryKeyFactory.default.createQuoteKey({
19415
+ id: quoteId,
19416
+ token: token,
19417
+ }),
19418
+ });
19419
+ });
19420
+ // Open the DropboxSign modal
19421
+ client.open(url, {
19422
+ clientId: clientId,
19423
+ skipDomainVerification: false, // Set true for development testing
19424
+ });
19425
+ return [2 /*return*/];
19426
+ }
19427
+ });
19428
+ }); };
19411
19429
  var _e = reactQuery.useMutation({
19412
19430
  mutationFn: function (changedFormItems) { return __awaiter(void 0, void 0, void 0, function () {
19413
19431
  return __generator(this, function (_a) {
@@ -19533,9 +19551,6 @@ var AcceptQuoteModal = function (_a) {
19533
19551
  var acceptBoxVisible = _a.acceptBoxVisible, formattedQuote = _a.formattedQuote, sendAccept = _a.sendAccept, setAcceptBoxVisible = _a.setAcceptBoxVisible, setIsAccepting = _a.setIsAccepting, isSendAcceptPending = _a.isSendAcceptPending;
19534
19552
  // Refs
19535
19553
  var firstInputRef = react.useRef(null);
19536
- var apiHost = react.useContext(BunnyContext).apiHost;
19537
- var token = useToken();
19538
- var signingPlugins = useSigningPlugins({ apiHost: apiHost, token: token });
19539
19554
  // Hooks
19540
19555
  var form = antd.Form.useForm()[0];
19541
19556
  useFocusFirstInput({ firstInputRef: firstInputRef, isVisible: acceptBoxVisible });
@@ -19544,7 +19559,7 @@ var AcceptQuoteModal = function (_a) {
19544
19559
  var createRules = function (required, title) {
19545
19560
  return required ? [{ required: true, message: "".concat(title, " is required") }] : [];
19546
19561
  };
19547
- return (jsxRuntime.jsx(StyledModal$1, __assign({ centered: true, okText: isSendAcceptPending ? 'Accepting...' : 'Accept', okButtonProps: {
19562
+ return (jsxRuntime.jsx(StyledModal$1, __assign({ centered: true, okText: isSendAcceptPending ? "Accepting..." : "Accept", okButtonProps: {
19548
19563
  loading: isSendAcceptPending,
19549
19564
  disabled: isSendAcceptPending,
19550
19565
  }, onCancel: function () {
@@ -19557,7 +19572,16 @@ var AcceptQuoteModal = function (_a) {
19557
19572
  sendAccept(changedFields);
19558
19573
  })
19559
19574
  .catch(function () { });
19560
- }, open: acceptBoxVisible, title: (signingPlugins === null || signingPlugins === void 0 ? void 0 : signingPlugins.length) ? 'Start signing' : 'Accept quote', width: 400 }, { children: jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Your name", name: "name", rules: createRules(true, 'Your name') }, { children: jsxRuntime.jsx(antd.Input, { autoFocus: true, ref: firstInputRef }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Your job title", name: "title", rules: createRules(true, 'Your job title') }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Purchase order number", name: "poNumber", rules: createRules(poNumberRequired, 'Purchase order number') }, { children: jsxRuntime.jsx(antd.Input, {}) })), taxNumberRequired && (jsxRuntime.jsx(antd.Form.Item, __assign({ name: "taxNumber", label: taxNumberLabel, rules: createRules(taxNumberRequired, taxNumberLabel) }, { children: jsxRuntime.jsx(antd.Input, {}) })))] })) })));
19575
+ }, open: acceptBoxVisible, title: "Accept quote", width: 400 }, { children: jsxRuntime.jsxs(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2", form: form, layout: "vertical" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Your name", name: "name", rules: createRules(true, "Your name") }, { children: jsxRuntime.jsx(antd.Input, { autoFocus: true, ref: firstInputRef }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Your job title", name: "title", rules: createRules(true, "Your job title") }, { children: jsxRuntime.jsx(antd.Input, {}) })), jsxRuntime.jsx(antd.Form.Item, __assign({ label: "Purchase order number", name: "poNumber", rules: createRules(poNumberRequired, "Purchase order number") }, { children: jsxRuntime.jsx(antd.Input, {}) })), taxNumberRequired && (jsxRuntime.jsx(antd.Form.Item, __assign({ name: "taxNumber", label: taxNumberLabel, rules: createRules(taxNumberRequired, taxNumberLabel) }, { children: jsxRuntime.jsx(antd.Input, {}) })))] })) })));
19576
+ };
19577
+
19578
+ var useCurrentUserData = function () {
19579
+ var queryClient = reactQuery.useQueryClient();
19580
+ var token = useToken();
19581
+ var currentUser = queryClient.getQueryData(common.QueryKeyFactory.default.currentUserKey(token));
19582
+ if (!currentUser)
19583
+ return {};
19584
+ return currentUser;
19561
19585
  };
19562
19586
 
19563
19587
  var Title$2 = antd.Typography.Title;
@@ -19566,10 +19590,10 @@ var PaymentHoldModal = function (_a) {
19566
19590
  var visible = _a.visible, setVisible = _a.setVisible, quote = _a.quote;
19567
19591
  var queryClient = reactQuery.useQueryClient();
19568
19592
  var token = useToken();
19569
- var entityId = useCurrentUserData().entityId;
19593
+ var account = useCurrentUserData().account;
19570
19594
  return (jsxRuntime.jsxs(StyledModal$1, __assign({ centered: true, onCancel: function () {
19571
19595
  setVisible(false);
19572
- }, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, quote: {
19596
+ }, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { country: account === null || account === void 0 ? void 0 : account.billingCountry, quote: {
19573
19597
  amount: quote.amount,
19574
19598
  currencyId: quote.currency,
19575
19599
  id: quote.quote.id,
@@ -19625,11 +19649,11 @@ function ActualQuote() {
19625
19649
  var _this = this;
19626
19650
  var _a, _b, _c, _d;
19627
19651
  // Context
19628
- var apiHost = react.useContext(BunnyContext).apiHost;
19652
+ var _e = react.useContext(BunnyContext), apiHost = _e.apiHost, onTokenExpired = _e.onTokenExpired;
19629
19653
  var token = useToken();
19630
- var _e = react.useContext(InvoiceQuoteContext), className = _e.className, id = _e.id, hideDownloadButton = _e.hideDownloadButton, onQuoteLoaded = _e.onQuoteLoaded;
19654
+ var _f = react.useContext(InvoiceQuoteContext), className = _f.className, id = _f.id, hideDownloadButton = _f.hideDownloadButton, onQuoteLoaded = _f.onQuoteLoaded;
19631
19655
  // Queries
19632
- var _f = reactQuery.useQuery({
19656
+ var _g = reactQuery.useQuery({
19633
19657
  queryKey: common.QueryKeyFactory.default.createQuoteKey({ id: id, token: token }),
19634
19658
  queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
19635
19659
  var error_1;
@@ -19648,14 +19672,15 @@ function ActualQuote() {
19648
19672
  });
19649
19673
  }); },
19650
19674
  placeholderData: reactQuery.keepPreviousData,
19651
- }), data = _f.data, isLoading = _f.isLoading;
19675
+ }), data = _g.data, isLoading = _g.isLoading;
19652
19676
  var formattedQuote = data;
19653
19677
  // Hooks
19654
- var _g = useSendAcceptQuote({
19678
+ var _h = useSendAcceptQuote({
19655
19679
  token: token,
19680
+ onTokenExpired: onTokenExpired,
19656
19681
  apiHost: apiHost,
19657
19682
  quoteId: id,
19658
- }), acceptBoxVisible = _g.acceptBoxVisible, isAccepting = _g.isAccepting, sendAccept = _g.sendAccept, setAcceptBoxVisible = _g.setAcceptBoxVisible, setIsAccepting = _g.setIsAccepting, startAcceptance = _g.startAcceptance, pandadocPollingModalVisible = _g.pandadocPollingModalVisible, setPandadocPollingModalVisible = _g.setPandadocPollingModalVisible, isSendAcceptPending = _g.isSendAcceptPending;
19683
+ }), acceptBoxVisible = _h.acceptBoxVisible, isAccepting = _h.isAccepting, sendAccept = _h.sendAccept, setAcceptBoxVisible = _h.setAcceptBoxVisible, setIsAccepting = _h.setIsAccepting, startAcceptance = _h.startAcceptance, pandadocPollingModalVisible = _h.pandadocPollingModalVisible, setPandadocPollingModalVisible = _h.setPandadocPollingModalVisible, isSendAcceptPending = _h.isSendAcceptPending;
19659
19684
  useSigningComplete({ data: formattedQuote, token: token });
19660
19685
  var isMobile = common.useIsMobile();
19661
19686
  var showErrorNotification = common.useErrorNotification();
@@ -19665,7 +19690,7 @@ function ActualQuote() {
19665
19690
  }
19666
19691
  }, [formattedQuote]);
19667
19692
  // Payment hold stuff here
19668
- var _h = useQuotePaymentHold(formattedQuote), paymentHoldModalVisible = _h.paymentHoldModalVisible, setPaymentHoldModalVisible = _h.setPaymentHoldModalVisible, shouldDoPaymentHold = _h.shouldDoPaymentHold, paymentHoldCompleted = _h.paymentHoldCompleted, paymentHold = _h.paymentHold;
19693
+ var _j = useQuotePaymentHold(formattedQuote), paymentHoldModalVisible = _j.paymentHoldModalVisible, setPaymentHoldModalVisible = _j.setPaymentHoldModalVisible, shouldDoPaymentHold = _j.shouldDoPaymentHold, paymentHoldCompleted = _j.paymentHoldCompleted, paymentHold = _j.paymentHold;
19669
19694
  var handleClickAccept = function () {
19670
19695
  if (shouldDoPaymentHold && !paymentHoldCompleted) {
19671
19696
  setPaymentHoldModalVisible(true);
@@ -19697,14 +19722,9 @@ function QuoteButtons(_a) {
19697
19722
  var entityBranding = react.useContext(BrandContext);
19698
19723
  var downloadFile = useDownloadFile(id);
19699
19724
  var isExpired = useIsExpired(formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.expiresAt);
19700
- var signingPlugins = useSigningPlugins({ apiHost: apiHost, token: token });
19701
19725
  return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
19702
19726
  color: entityBranding.secondaryColor,
19703
- } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$n, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(common.formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxRuntime.jsxs("div", __assign({ className: isMobile ? 'flex w-full justify-end gap-2' : 'flex items-center justify-end gap-2' }, { children: [paymentHold ? (jsxRuntime.jsx(PaymentHoldDisplay, { paymentHold: paymentHold, currency: formattedQuote.currency, amount: formattedQuote.amount })) : null, !isMobile && !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(icons.DownloadOutlined, {}), onClick: function () { return downloadFile(apiHost + '/api/pdf/quote', token); } }, { children: "Download" }))) : null, shouldDoPaymentHold && !paymentHoldCompleted ? (jsxRuntime.jsx(antd.Button, __assign({ disabled: isExpired, onClick: function () { return setPaymentHoldModalVisible(true); }, type: "primary" }, { children: "Pay to accept" }))) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isAccepted ? (jsxRuntime.jsx(antd.Button, __assign({ disabled: isExpired || isAccepting, onClick: handleClickAccept, type: "primary" }, { children: isExpired
19704
- ? 'Quote is expired'
19705
- : (signingPlugins === null || signingPlugins === void 0 ? void 0 : signingPlugins.length)
19706
- ? 'Start signing'
19707
- : 'Accept quote' }))) : null }))] })))] })));
19727
+ } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$n, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(common.formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxRuntime.jsxs("div", __assign({ className: isMobile ? 'flex w-full justify-end gap-2' : 'flex items-center justify-end gap-2' }, { children: [paymentHold ? (jsxRuntime.jsx(PaymentHoldDisplay, { paymentHold: paymentHold, currency: formattedQuote.currency, amount: formattedQuote.amount })) : null, !isMobile && !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(icons.DownloadOutlined, {}), onClick: function () { return downloadFile(apiHost + '/api/pdf/quote', token); } }, { children: "Download" }))) : null, shouldDoPaymentHold && !paymentHoldCompleted ? (jsxRuntime.jsx(antd.Button, __assign({ disabled: isExpired, onClick: function () { return setPaymentHoldModalVisible(true); }, type: "primary" }, { children: "Pay to accept" }))) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isAccepted ? (jsxRuntime.jsx(antd.Button, __assign({ disabled: isExpired || isAccepting, onClick: handleClickAccept, type: "primary" }, { children: isExpired ? 'Quote is expired' : 'Accept quote' }))) : null }))] })))] })));
19708
19728
  }
19709
19729
  function PaymentHoldDisplay(_a) {
19710
19730
  var _b, _c, _d, _e;
@@ -20169,9 +20189,9 @@ function QuotesWrapper() {
20169
20189
  return (jsxRuntime.jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
20170
20190
  }
20171
20191
 
20172
- var MUTATION$6 = function () { return "\nmutation AccountSignup (\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!,\n) {\n accountSignup(\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId,\n ) {\n errors\n quote {\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n }\n}"; };
20192
+ var MUTATION$6 = function () { return "\nmutation AccountSignup (\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!,\n $entityId: ID!\n) {\n accountSignup(\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId,\n entityId: $entityId\n ) {\n errors\n quote {\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n }\n}"; };
20173
20193
  var accountSignup = function (_a) {
20174
- var token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode;
20194
+ var token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode, entityId = _a.entityId;
20175
20195
  return __awaiter(void 0, void 0, void 0, function () {
20176
20196
  var vars, response, errors;
20177
20197
  var _b;
@@ -20185,6 +20205,7 @@ var accountSignup = function (_a) {
20185
20205
  pluginId: pluginId,
20186
20206
  paymentMethodId: paymentMethodId,
20187
20207
  priceListCode: priceListCode,
20208
+ entityId: entityId,
20188
20209
  };
20189
20210
  return [4 /*yield*/, gqlRequest({
20190
20211
  query: MUTATION$6(),
@@ -20203,9 +20224,9 @@ var accountSignup = function (_a) {
20203
20224
  });
20204
20225
  };
20205
20226
 
20206
- var MUTATION$5 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $priceListCode: String!,\n) {\n quoteAccountSignup(\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact,\n ) {\n account {\n id\n }\n quote {\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n tenant {\n code\n }\n portalSessionToken\n errors\n }\n}"; };
20227
+ var MUTATION$5 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $priceListCode: String!,\n $entityId: ID!\n) {\n quoteAccountSignup(\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact,\n entityId: $entityId\n ) {\n account {\n id\n }\n quote {\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n tenant {\n code\n }\n portalSessionToken\n errors\n }\n}"; };
20207
20228
  var quoteAccountSignup = function (_a) {
20208
- var token = _a.token, apiHost = _a.apiHost, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
20229
+ var token = _a.token, apiHost = _a.apiHost, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact, entityId = _a.entityId;
20209
20230
  return __awaiter(void 0, void 0, void 0, function () {
20210
20231
  var vars, response, errors;
20211
20232
  var _b;
@@ -20216,6 +20237,7 @@ var quoteAccountSignup = function (_a) {
20216
20237
  priceListCode: priceListCode,
20217
20238
  accountName: accountName,
20218
20239
  billingContact: billingContact,
20240
+ entityId: entityId,
20219
20241
  };
20220
20242
  return [4 /*yield*/, gqlRequest({
20221
20243
  query: MUTATION$5(),
@@ -20327,8 +20349,8 @@ var templateObject_1$6, templateObject_2$1;
20327
20349
  var Title$1 = antd.Typography.Title;
20328
20350
  function PaymentForms(_a) {
20329
20351
  var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction;
20330
- var entityId = useCurrentUserData().entityId;
20331
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment })] })) }));
20352
+ var account = useCurrentUserData().account;
20353
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx(PaymentForm, { country: account === null || account === void 0 ? void 0 : account.billingCountry, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment })] })) }));
20332
20354
  }
20333
20355
  function InitialSignupForm(_a) {
20334
20356
  var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting;
@@ -20360,7 +20382,7 @@ function PriceListDisplay(_a) {
20360
20382
 
20361
20383
  var showErrorNotification = common.useErrorNotification();
20362
20384
  function Signup(_a) {
20363
- var companyName = _a.companyName, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, couponCode = _a.couponCode, className = _a.className, _b = _a.shadow, shadow = _b === void 0 ? 'shadow-md' : _b, style = _a.style;
20385
+ var companyName = _a.companyName, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, couponCode = _a.couponCode, className = _a.className, _b = _a.shadow, shadow = _b === void 0 ? 'shadow-md' : _b, style = _a.style, entityId = _a.entityId;
20364
20386
  // Hooks
20365
20387
  var apiHost = react.useContext(BunnyContext).apiHost;
20366
20388
  var tokenFromContexts = useToken();
@@ -20446,6 +20468,7 @@ function Signup(_a) {
20446
20468
  lastName: formData.lastName,
20447
20469
  email: formData.email,
20448
20470
  },
20471
+ entityId: entityId,
20449
20472
  })];
20450
20473
  case 1:
20451
20474
  data_1 = _a.sent();
@@ -20505,6 +20528,7 @@ function Signup(_a) {
20505
20528
  pluginId: plugin === null || plugin === void 0 ? void 0 : plugin.id.toString(),
20506
20529
  priceListCode: priceListCode,
20507
20530
  accountId: accountId,
20531
+ entityId: entityId,
20508
20532
  })];
20509
20533
  case 1: return [2 /*return*/, _a.sent()];
20510
20534
  }
@@ -20762,7 +20786,6 @@ var QuoteCheckout = function (_a) {
20762
20786
  var isMobile = common.useIsMobile();
20763
20787
  var _b = react.useState(false), isSaving = _b[0], setIsSaving = _b[1];
20764
20788
  var paymentRequired = getQuoteAmountDue(quote) > 0;
20765
- var entityId = useCurrentUserData().entityId;
20766
20789
  var checkoutMutation = reactQuery.useMutation({
20767
20790
  mutationFn: function () { return __awaiter(void 0, void 0, void 0, function () {
20768
20791
  return __generator(this, function (_a) {
@@ -20792,7 +20815,7 @@ var QuoteCheckout = function (_a) {
20792
20815
  }
20793
20816
  if (taxationRequiredAccountFields)
20794
20817
  return (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsx(TaxationForm, { account: account, quote: quote }) })));
20795
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote })) : (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(isMobile ? 'bunny-shadow-padding-x' : '') }, { children: [jsxRuntime.jsx(antd.Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? 'Processing...' : 'Complete order' })), jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs bunny-text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
20818
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: paymentRequired ? (jsxRuntime.jsx(PaymentForm, { country: account === null || account === void 0 ? void 0 : account.billingCountry, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote })) : (jsxRuntime.jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-2 ".concat(isMobile ? 'bunny-shadow-padding-x' : '') }, { children: [jsxRuntime.jsx(antd.Button, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? 'Processing...' : 'Complete order' })), jsxRuntime.jsx("div", __assign({ className: "bunny-text-xs bunny-text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
20796
20819
  };
20797
20820
  var PaymentFormWrapper = function (_a) {
20798
20821
  var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
@@ -20812,7 +20835,6 @@ var Checkout = function (_a) {
20812
20835
  var onCancel = _a.onCancel, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, token = _a.token;
20813
20836
  var apiHost = react.useContext(BunnyContext).apiHost;
20814
20837
  var isMobile = common.useIsMobile();
20815
- var entityId = useCurrentUserData().entityId;
20816
20838
  var hasTaxPlugin = useHasTaxPlugin({
20817
20839
  apiHost: apiHost,
20818
20840
  token: token,
@@ -20884,7 +20906,7 @@ var Checkout = function (_a) {
20884
20906
  zIndex: 1001,
20885
20907
  } }, { children: jsxRuntime.jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-justify-end bunny-w-full" }, { children: jsxRuntime.jsx(icons.CloseOutlined, { className: "bunny-text-base bunny-shadow-padding-xb", onClick: onCancel }) })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-justify-end bunny-pt-4 bunny-gap-4 ".concat(isMobile ? 'bunny-flex-col' : 'bunny-shadow-padding-xb') }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsxRuntime.jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : '' })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsxRuntime.jsx(antd.Divider, { className: "bunny-h-full", type: "vertical" })), invoice ? (jsxRuntime.jsx("div", __assign({ className: "bunny-w-full bunny-pt-12" }, { children: jsxRuntime.jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: invoice }) }))) : quote ? (jsxRuntime.jsx(QuoteCheckout, { account: account, onFail: function (error) {
20886
20908
  onFail(error);
20887
- }, onSuccess: onSuccess, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
20909
+ }, onSuccess: onSuccess, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsxRuntime.jsx(PaymentForm, { onFail: function (error) {
20888
20910
  onFail(error);
20889
20911
  }, onPaymentSuccess: onSuccess }))] })), jsxRuntime.jsx(Footer, {})] })) })));
20890
20912
  };
@@ -21264,7 +21286,7 @@ var PlanPickerCheckoutBar = function (_a) {
21264
21286
  };
21265
21287
 
21266
21288
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
21267
- 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 basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
21289
+ 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 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 basePrice\n billingPeriod\n chargeType\n id\n name\n priceDecimals\n pricingModel\n quantityMax\n quantityMin\n selfServiceQuantity\n feature {\n name\n unitName\n }\n }\n }\n }\n }";
21268
21290
  var getPriceListChangeOptions = function (_a) {
21269
21291
  var apiHost = _a.apiHost, isInPreviewMode = _a.isInPreviewMode, productId = _a.productId, token = _a.token, upgradingSubscription = _a.upgradingSubscription;
21270
21292
  return __awaiter(void 0, void 0, void 0, function () {
@@ -21368,30 +21390,10 @@ var PriceListCardTitle = function (_a) {
21368
21390
  : " " }))), jsxRuntime.jsx("div", __assign({ className: "bunny-font-medium bunny-text-center ".concat(isMobile ? "bunny-text-slate-500" : "bunny-text-orange-600"), style: { fontSize: "20px" } }, { children: priceList.plan.name }))] })));
21369
21391
  };
21370
21392
 
21371
- var getPrice = function (priceList) {
21372
- if (priceList.showPriceAsMonthly) {
21373
- return priceList.monthlyBasePrice;
21374
- }
21375
- return priceList.basePrice;
21376
- };
21377
- var calculatePriceDecimals = function (priceList) {
21378
- if (priceList.plan.pricingStyle === common.PricingStyle.PRICED) {
21379
- var decimalPart = getPrice(priceList).toString().split('.')[1];
21380
- if (!decimalPart)
21381
- return 0;
21382
- // If decimal part consists only of zeros, return 0
21383
- if (parseInt(decimalPart) === 0) {
21384
- return 0;
21385
- }
21386
- return undefined;
21387
- }
21388
- return 0;
21389
- };
21390
21393
  var PriceListCardPrice = function (_a) {
21391
21394
  var priceList = _a.priceList;
21392
- var priceDecimals = calculatePriceDecimals(priceList);
21393
21395
  return (jsxRuntime.jsx("div", __assign({ className: "bunny-font-medium bunny-text-center bunny-text-gray-900", style: { fontSize: '32px' } }, { children: !priceList.plan.pricingStyle || priceList.plan.pricingStyle === common.PricingStyle.PRICED
21394
- ? common.formatCurrency(getPrice(priceList), priceList.currencyId, priceDecimals)
21396
+ ? common.formatCurrency(priceList.monthlyBasePrice, priceList.currencyId, 0)
21395
21397
  : priceList.plan.pricingStyle === common.PricingStyle.CONTACT_US
21396
21398
  ? ''
21397
21399
  : 'Free' })));
@@ -21430,9 +21432,7 @@ var PriceListCardPriceDescription = function (_a) {
21430
21432
  fontSize: isMobile ? '13px' : '12px',
21431
21433
  } }, { children: priceList.plan.pricingDescription && !isEmptyHtml(priceList.plan.pricingDescription) ? (jsxRuntime.jsx(interweave.Markup, { content: priceList.plan.pricingDescription })) : ("per ".concat((feature === null || feature === void 0 ? void 0 : feature.unitName) && !doesPlanHaveFlatFeeCharges
21432
21434
  ? "".concat(feature.unitName.toLowerCase(), " / ")
21433
- : '').concat(priceList.showPriceAsMonthly
21434
- ? 'month'
21435
- : common.PERIOD_LABELS[periodMonthsConverter(priceList.periodMonths)])) })), priceList.periodMonths > 1 && (jsxRuntime.jsxs(Text$b, __assign({ className: "bunny-text-center bunny-text-gray-900", style: { fontSize: isMobile ? '12px' : '11px' } }, { children: ["billed ", BillingPeriodConverter$1[periodMonthsConverter(priceList.periodMonths)]] })))] }));
21435
+ : '', "month")) })), priceList.periodMonths > 1 && (jsxRuntime.jsxs(Text$b, __assign({ className: "bunny-text-center bunny-text-gray-900", style: { fontSize: isMobile ? '12px' : '11px' } }, { children: ["billed ", BillingPeriodConverter$1[periodMonthsConverter(priceList.periodMonths)]] })))] }));
21436
21436
  };
21437
21437
 
21438
21438
  var CheckIcon = function (_a) {
@@ -21470,11 +21470,11 @@ var PriceListCardMobile = function (_a) {
21470
21470
  if (!disableOnClick)
21471
21471
  onClick(priceList);
21472
21472
  }, style: {
21473
- minWidth: '220px',
21473
+ minWidth: "220px",
21474
21474
  borderColor: isSelected ? brandColor : common.SLATE_200,
21475
21475
  } }, { children: [isSelected && (jsxRuntime.jsx("div", __assign({ className: "bunny-absolute", style: {
21476
- top: '10px',
21477
- right: '10px',
21476
+ top: "10px",
21477
+ right: "10px",
21478
21478
  } }, { children: jsxRuntime.jsx(CheckIcon, { backgroundColor: brandColor, size: "20px" }) }))), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-center bunny-grow bunny-gap-2" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-center bunny-gap-2" }, { children: [jsxRuntime.jsx(PriceListCardTitle, { isPriceListCurrentSubscription: isPriceListCurrentSubscription, priceList: priceList, trialRemainingDays: trialRemainingDays }), jsxRuntime.jsx(PriceListCardDescription, { description: description })] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-center bunny-gap-2" }, { children: [jsxRuntime.jsx(PriceListCardPrice, { priceList: priceList }), jsxRuntime.jsx(PriceListCardPriceDescription, { feature: feature, priceList: priceList })] })), jsxRuntime.jsx(PriceListCardButton, { disableOnClick: disableOnClick, isPriceListCurrentSubscription: isPriceListCurrentSubscription, isSelected: isSelected, priceList: priceList, subscriptionPlan: subscriptionPlan })] }))] })));
21479
21479
  };
21480
21480
 
@@ -23293,8 +23293,8 @@ var PaymentFormSection = function (_a) {
23293
23293
  var onTokenExpired = react.useContext(BunnyContext).onTokenExpired;
23294
23294
  var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
23295
23295
  var showSuccessNotification = common.useSuccessNotification();
23296
- var entityId = useCurrentUserData().entityId;
23297
- return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
23296
+ useCurrentUserData().account;
23297
+ return (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile || hideBillingDetailsForm ? 'bunny-w-full' : 'bunny-w-1/2 bunny-pt-4', " bunny-flex bunny-justify-center") }, { children: jsxRuntime.jsx(PaymentForm, { onFail: function (error) {
23298
23298
  handleAllErrorFormats(error);
23299
23299
  }, onSavePaymentMethod: function () {
23300
23300
  showSuccessNotification('Your payment method has been saved');
@@ -1,5 +1,5 @@
1
1
  import { FormattedInvoice, PluginData, Quote } from '@bunnyapp/common';
2
- export declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, onPaymentHoldSuccess, quote, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, entityId, overrideToken, customCheckoutFunction, currencyId: currencyIdFromProps, paymentHoldOptions, }: {
2
+ export declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, onPaymentHoldSuccess, quote, accountId, onSavePaymentMethod, onRemovePaymentMethod, onSetDefaultPaymentMethod, overrideToken, customCheckoutFunction, currencyId: currencyIdFromProps, paymentHoldOptions, }: {
3
3
  invoice?: FormattedInvoice | undefined;
4
4
  quote?: Quote | undefined;
5
5
  onFail: (error: any) => void;
@@ -9,7 +9,6 @@ export declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, onPaymen
9
9
  onRemovePaymentMethod?: (() => void) | undefined;
10
10
  onSetDefaultPaymentMethod?: (() => void) | undefined;
11
11
  accountId?: string | undefined;
12
- entityId?: string | undefined;
13
12
  overrideToken?: string | undefined;
14
13
  customCheckoutFunction?: ((plugin: PluginData | undefined) => Promise<any>) | undefined;
15
14
  currencyId?: string | undefined;
@@ -1,4 +1,4 @@
1
- import { FormattedQuote } from '@bunnyapp/common';
1
+ import { FormattedQuote } from "@bunnyapp/common";
2
2
  declare const AcceptQuoteModal: ({ acceptBoxVisible, formattedQuote, sendAccept, setAcceptBoxVisible, setIsAccepting, isSendAcceptPending, }: {
3
3
  acceptBoxVisible: boolean;
4
4
  formattedQuote: FormattedQuote;