@bunnyapp/components 1.0.62-beta.4 → 1.0.62-beta.5
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 +65 -16
- package/dist/cjs/src/components/DocumentTemplatePreview.d.ts +4 -0
- package/dist/cjs/src/components/Invoice/InvoiceQuoteView.d.ts +2 -1
- package/dist/esm/index.js +67 -18
- package/dist/esm/src/components/DocumentTemplatePreview.d.ts +4 -0
- package/dist/esm/src/components/Invoice/InvoiceQuoteView.d.ts +2 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -173,7 +173,7 @@ var BrandContext = react.createContext({
|
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
// This will be replaced at build time by rollup-plugin-replace
|
|
176
|
-
var PACKAGE_VERSION = '1.0.62-beta.
|
|
176
|
+
var PACKAGE_VERSION = '1.0.62-beta.5';
|
|
177
177
|
var createRequestHeaders = function (token) {
|
|
178
178
|
var _a;
|
|
179
179
|
var bearerToken = token ? "Bearer ".concat(token) : null;
|
|
@@ -418,9 +418,59 @@ function useToken() {
|
|
|
418
418
|
return overrideToken || tokenFromContext;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
+
var DocumentTemplatePreview = function (_a) {
|
|
422
|
+
var targetUrl = _a.targetUrl;
|
|
423
|
+
var _b = react.useState(null), pdfUrl = _b[0], setPdfUrl = _b[1];
|
|
424
|
+
var queryClient = reactQuery.useQueryClient();
|
|
425
|
+
var queryKey = react.useMemo(function () { return ['documentTemplatePreview', targetUrl]; }, [targetUrl]);
|
|
426
|
+
// Clear previous data when component mounts or id changes
|
|
427
|
+
react.useEffect(function () {
|
|
428
|
+
// Remove any existing data for this query
|
|
429
|
+
queryClient.removeQueries({ queryKey: queryKey });
|
|
430
|
+
}, [queryClient, queryKey]);
|
|
431
|
+
var _c = reactQuery.useQuery({
|
|
432
|
+
queryKey: queryKey,
|
|
433
|
+
queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
434
|
+
var response, blob;
|
|
435
|
+
return __generator(this, function (_a) {
|
|
436
|
+
switch (_a.label) {
|
|
437
|
+
case 0: return [4 /*yield*/, fetch(targetUrl)];
|
|
438
|
+
case 1:
|
|
439
|
+
response = _a.sent();
|
|
440
|
+
if (!response.ok) {
|
|
441
|
+
throw new Error('Failed to fetch PDF');
|
|
442
|
+
}
|
|
443
|
+
return [4 /*yield*/, response.blob()];
|
|
444
|
+
case 2:
|
|
445
|
+
blob = _a.sent();
|
|
446
|
+
return [2 /*return*/, blob];
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}); },
|
|
450
|
+
enabled: !!targetUrl,
|
|
451
|
+
}), data = _c.data, isLoading = _c.isLoading;
|
|
452
|
+
react.useEffect(function () {
|
|
453
|
+
if (data) {
|
|
454
|
+
var url_1 = URL.createObjectURL(data);
|
|
455
|
+
setPdfUrl(url_1);
|
|
456
|
+
// Cleanup function to revoke the object URL
|
|
457
|
+
return function () {
|
|
458
|
+
URL.revokeObjectURL(url_1);
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
}, [data]);
|
|
462
|
+
if (isLoading) {
|
|
463
|
+
return (jsxRuntime.jsx("div", __assign({ className: "flex items-center justify-center h-96" }, { children: jsxRuntime.jsx(antd.Spin, {}) })));
|
|
464
|
+
}
|
|
465
|
+
if (!pdfUrl) {
|
|
466
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
467
|
+
}
|
|
468
|
+
return (jsxRuntime.jsx("div", __assign({ className: "document-template-preview max-w-[1280px] mx-auto bg-white rounded p-4" }, { children: jsxRuntime.jsx("iframe", { src: pdfUrl, width: "100%", height: "800px", style: { border: 'none' }, title: "Document Template Preview" }) })));
|
|
469
|
+
};
|
|
470
|
+
|
|
421
471
|
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"])));
|
|
422
472
|
var InvoiceQuoteView = function (_a) {
|
|
423
|
-
var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError;
|
|
473
|
+
var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError, targetUrl = _a.targetUrl;
|
|
424
474
|
var downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
|
|
425
475
|
var secondaryColor = react.useContext(BrandContext).secondaryColor;
|
|
426
476
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
@@ -432,9 +482,9 @@ var InvoiceQuoteView = function (_a) {
|
|
|
432
482
|
color: secondaryColor,
|
|
433
483
|
}, type: "link" }, { children: backButtonName || 'Back' }))) : null }), !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(icons.DownloadOutlined, {}), onClick: function () {
|
|
434
484
|
return downloadFile(apiHost + '/api/pdf/invoice/' + formattedInvoice.id, token);
|
|
435
|
-
} }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-w-full bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [jsxRuntime.jsx(interweave.Markup, { content: html }), children] }))) : (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-w-full bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
|
|
485
|
+
} }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-w-full bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [targetUrl ? (jsxRuntime.jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsxRuntime.jsx(interweave.Markup, { content: html })), children] }))) : (jsxRuntime.jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-w-full bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
|
|
436
486
|
minWidth: '750px',
|
|
437
|
-
} }, { children: [jsxRuntime.jsx(interweave.Markup, { content: html }), children] })))] })));
|
|
487
|
+
} }, { children: [targetUrl ? (jsxRuntime.jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsxRuntime.jsx(interweave.Markup, { content: html })), children] })))] })));
|
|
438
488
|
};
|
|
439
489
|
var templateObject_1$c;
|
|
440
490
|
|
|
@@ -19195,7 +19245,7 @@ function ActualInvoice() {
|
|
|
19195
19245
|
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 }) })))] })) })));
|
|
19196
19246
|
}
|
|
19197
19247
|
|
|
19198
|
-
var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n object {\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
|
|
19248
|
+
var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n object {\n documents { id filename size date url }\n documentTemplateId\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 }"; };
|
|
19199
19249
|
var getFormattedQuote = function (_a) {
|
|
19200
19250
|
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
19201
19251
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -19589,14 +19639,13 @@ var useQuotePaymentHold = function (formattedQuote) {
|
|
|
19589
19639
|
};
|
|
19590
19640
|
function ActualQuote() {
|
|
19591
19641
|
var _this = this;
|
|
19592
|
-
var _a, _b, _c;
|
|
19642
|
+
var _a, _b, _c, _d;
|
|
19593
19643
|
// Context
|
|
19594
|
-
var
|
|
19644
|
+
var _e = react.useContext(BunnyContext), apiHost = _e.apiHost, onTokenExpired = _e.onTokenExpired;
|
|
19595
19645
|
var token = useToken();
|
|
19596
|
-
react.useContext(
|
|
19597
|
-
var _e = react.useContext(InvoiceQuoteContext), className = _e.className, id = _e.id, hideDownloadButton = _e.hideDownloadButton, onQuoteLoaded = _e.onQuoteLoaded;
|
|
19646
|
+
var _f = react.useContext(InvoiceQuoteContext), className = _f.className, id = _f.id, hideDownloadButton = _f.hideDownloadButton, onQuoteLoaded = _f.onQuoteLoaded;
|
|
19598
19647
|
// Queries
|
|
19599
|
-
var
|
|
19648
|
+
var _g = reactQuery.useQuery({
|
|
19600
19649
|
queryKey: common.QueryKeyFactory.default.createQuoteKey({ id: id, token: token }),
|
|
19601
19650
|
queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
19602
19651
|
var error_1;
|
|
@@ -19615,15 +19664,16 @@ function ActualQuote() {
|
|
|
19615
19664
|
});
|
|
19616
19665
|
}); },
|
|
19617
19666
|
placeholderData: reactQuery.keepPreviousData,
|
|
19618
|
-
}), data =
|
|
19667
|
+
}), data = _g.data, isLoading = _g.isLoading;
|
|
19619
19668
|
var formattedQuote = data;
|
|
19669
|
+
console.log(data);
|
|
19620
19670
|
// Hooks
|
|
19621
|
-
var
|
|
19671
|
+
var _h = useSendAcceptQuote({
|
|
19622
19672
|
token: token,
|
|
19623
19673
|
onTokenExpired: onTokenExpired,
|
|
19624
19674
|
apiHost: apiHost,
|
|
19625
19675
|
quoteId: id,
|
|
19626
|
-
}), acceptBoxVisible =
|
|
19676
|
+
}), 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;
|
|
19627
19677
|
useSigningComplete({ data: formattedQuote, token: token });
|
|
19628
19678
|
var isMobile = common.useIsMobile();
|
|
19629
19679
|
var showErrorNotification = common.useErrorNotification();
|
|
@@ -19633,7 +19683,7 @@ function ActualQuote() {
|
|
|
19633
19683
|
}
|
|
19634
19684
|
}, [formattedQuote]);
|
|
19635
19685
|
// Payment hold stuff here
|
|
19636
|
-
var
|
|
19686
|
+
var _j = useQuotePaymentHold(formattedQuote), paymentHoldModalVisible = _j.paymentHoldModalVisible, setPaymentHoldModalVisible = _j.setPaymentHoldModalVisible, shouldDoPaymentHold = _j.shouldDoPaymentHold, paymentHoldCompleted = _j.paymentHoldCompleted, paymentHold = _j.paymentHold;
|
|
19637
19687
|
var handleClickAccept = function () {
|
|
19638
19688
|
if (shouldDoPaymentHold && !paymentHoldCompleted) {
|
|
19639
19689
|
setPaymentHoldModalVisible(true);
|
|
@@ -19651,7 +19701,7 @@ function ActualQuote() {
|
|
|
19651
19701
|
if ((firstInvoice === null || firstInvoice === void 0 ? void 0 : firstInvoice.state) === 'PAID' && paymentHoldCompleted) {
|
|
19652
19702
|
return jsxRuntime.jsx(Invoice, { id: firstInvoice.id });
|
|
19653
19703
|
}
|
|
19654
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsxRuntime.jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsxRuntime.jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html }, { children: ((
|
|
19704
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsxRuntime.jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsxRuntime.jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html, targetUrl: ((_b = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object) === null || _b === void 0 ? void 0 : _b.documentTemplateId) ? "".concat(apiHost, "/api/pdf/quote") : undefined }, { children: ((_d = (_c = formattedQuote.object) === null || _c === void 0 ? void 0 : _c.documents) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: formattedQuote.object.documents.map(function (doc, index) {
|
|
19655
19705
|
return (jsxRuntime.jsx(antd.Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
|
|
19656
19706
|
}) }))) : null }))] })), jsxRuntime.jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept, isSendAcceptPending: isSendAcceptPending }), jsxRuntime.jsx(PaymentHoldModal, { visible: paymentHoldModalVisible, setVisible: setPaymentHoldModalVisible, quote: formattedQuote }), jsxRuntime.jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
|
|
19657
19707
|
}
|
|
@@ -21237,7 +21287,6 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21237
21287
|
}) })), jsxRuntime.jsx(CheckoutBarSummarySection, { onClickCheckout: function () { return setPayModalVisible(true); }, open: payModalVisible, quote: quote, selectedPriceList: selectedPriceList, upgradingSubscription: upgradingSubscription, quotePreviewData: quotePreviewData }), jsxRuntime.jsx(Checkout, { isMobile: isMobile, onCancel: function () { return setPayModalVisible(false); }, onFail: onCheckoutFail, onSuccess: handleCheckoutSuccess, open: payModalVisible, quote: quote, selectedPriceList: selectedPriceList, storedPaymentMethod: defaultPaymentMethod, token: token })] })));
|
|
21238
21288
|
};
|
|
21239
21289
|
|
|
21240
|
-
console.log('PriceListChangeOptionsQuery');
|
|
21241
21290
|
// WARNING: There is a preview button on APP that will need to be changed if this query is changed
|
|
21242
21291
|
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 }";
|
|
21243
21292
|
var getPriceListChangeOptions = function (_a) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FormattedInvoice } from '@bunnyapp/common';
|
|
3
|
-
declare const InvoiceQuoteView: ({ children, formattedInvoice, html, backButtonName, onBackButtonClick, onDownloadError, }: {
|
|
3
|
+
declare const InvoiceQuoteView: ({ children, formattedInvoice, html, backButtonName, onBackButtonClick, onDownloadError, targetUrl, }: {
|
|
4
4
|
html: string;
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
formattedInvoice?: FormattedInvoice | undefined;
|
|
7
7
|
backButtonName?: string | undefined;
|
|
8
8
|
onBackButtonClick?: (() => void) | undefined;
|
|
9
9
|
onDownloadError?: (() => void) | undefined;
|
|
10
|
+
targetUrl?: string | undefined;
|
|
10
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export default InvoiceQuoteView;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx,
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { createContext, useEffect, useContext, useMemo, useState, useCallback, useRef } from 'react';
|
|
3
3
|
import { Markup } from 'interweave';
|
|
4
|
-
import { ConfigProvider, Button, Tag, Typography, Dropdown, Input, Checkbox, Skeleton, Collapse, Modal, Form, Tooltip, Drawer, Card as Card$1, Image, Divider, Select, Radio, Space, Popconfirm, Table } from 'antd';
|
|
4
|
+
import { ConfigProvider, Spin, Button, Tag, Typography, Dropdown, Input, Checkbox, Skeleton, Collapse, Modal, Form, Tooltip, Drawer, Card as Card$1, Image, Divider, Select, Radio, Space, Popconfirm, Table } from 'antd';
|
|
5
5
|
import { DownloadOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, SearchOutlined, CheckCircleFilled, CloseOutlined, ArrowLeftOutlined } from '@ant-design/icons';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory, useIsMobile, isColorTooDark, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, useErrorNotification, invokePlugin, useAllErrorFormats, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, request as request$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR as PRIMARY_COLOR$1, sortSubscriptionCharges, Lists, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, QuoteChangeKind, TAG_COLORS } from '@bunnyapp/common';
|
|
@@ -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.0.62-beta.
|
|
146
|
+
var PACKAGE_VERSION = '1.0.62-beta.5';
|
|
147
147
|
var createRequestHeaders = function (token) {
|
|
148
148
|
var _a;
|
|
149
149
|
var bearerToken = token ? "Bearer ".concat(token) : null;
|
|
@@ -388,9 +388,59 @@ function useToken() {
|
|
|
388
388
|
return overrideToken || tokenFromContext;
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
+
var DocumentTemplatePreview = function (_a) {
|
|
392
|
+
var targetUrl = _a.targetUrl;
|
|
393
|
+
var _b = useState(null), pdfUrl = _b[0], setPdfUrl = _b[1];
|
|
394
|
+
var queryClient = useQueryClient();
|
|
395
|
+
var queryKey = useMemo(function () { return ['documentTemplatePreview', targetUrl]; }, [targetUrl]);
|
|
396
|
+
// Clear previous data when component mounts or id changes
|
|
397
|
+
useEffect(function () {
|
|
398
|
+
// Remove any existing data for this query
|
|
399
|
+
queryClient.removeQueries({ queryKey: queryKey });
|
|
400
|
+
}, [queryClient, queryKey]);
|
|
401
|
+
var _c = useQuery({
|
|
402
|
+
queryKey: queryKey,
|
|
403
|
+
queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
404
|
+
var response, blob;
|
|
405
|
+
return __generator(this, function (_a) {
|
|
406
|
+
switch (_a.label) {
|
|
407
|
+
case 0: return [4 /*yield*/, fetch(targetUrl)];
|
|
408
|
+
case 1:
|
|
409
|
+
response = _a.sent();
|
|
410
|
+
if (!response.ok) {
|
|
411
|
+
throw new Error('Failed to fetch PDF');
|
|
412
|
+
}
|
|
413
|
+
return [4 /*yield*/, response.blob()];
|
|
414
|
+
case 2:
|
|
415
|
+
blob = _a.sent();
|
|
416
|
+
return [2 /*return*/, blob];
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}); },
|
|
420
|
+
enabled: !!targetUrl,
|
|
421
|
+
}), data = _c.data, isLoading = _c.isLoading;
|
|
422
|
+
useEffect(function () {
|
|
423
|
+
if (data) {
|
|
424
|
+
var url_1 = URL.createObjectURL(data);
|
|
425
|
+
setPdfUrl(url_1);
|
|
426
|
+
// Cleanup function to revoke the object URL
|
|
427
|
+
return function () {
|
|
428
|
+
URL.revokeObjectURL(url_1);
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
}, [data]);
|
|
432
|
+
if (isLoading) {
|
|
433
|
+
return (jsx("div", __assign({ className: "flex items-center justify-center h-96" }, { children: jsx(Spin, {}) })));
|
|
434
|
+
}
|
|
435
|
+
if (!pdfUrl) {
|
|
436
|
+
return jsx(Fragment, {});
|
|
437
|
+
}
|
|
438
|
+
return (jsx("div", __assign({ className: "document-template-preview max-w-[1280px] mx-auto bg-white rounded p-4" }, { children: jsx("iframe", { src: pdfUrl, width: "100%", height: "800px", style: { border: 'none' }, title: "Document Template Preview" }) })));
|
|
439
|
+
};
|
|
440
|
+
|
|
391
441
|
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"])));
|
|
392
442
|
var InvoiceQuoteView = function (_a) {
|
|
393
|
-
var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError;
|
|
443
|
+
var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError, targetUrl = _a.targetUrl;
|
|
394
444
|
var downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
|
|
395
445
|
var secondaryColor = useContext(BrandContext).secondaryColor;
|
|
396
446
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
@@ -402,9 +452,9 @@ var InvoiceQuoteView = function (_a) {
|
|
|
402
452
|
color: secondaryColor,
|
|
403
453
|
}, type: "link" }, { children: backButtonName || 'Back' }))) : null }), !hideDownloadButton ? (jsx(Button, __assign({ icon: jsx(DownloadOutlined, {}), onClick: function () {
|
|
404
454
|
return downloadFile(apiHost + '/api/pdf/invoice/' + formattedInvoice.id, token);
|
|
405
|
-
} }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-w-full bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [jsx(Markup, { content: html }), children] }))) : (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-w-full bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
|
|
455
|
+
} }, { children: "Download" }))) : null] }))) : null, isMobile ? (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-grow bunny-w-full bunny-shadow-padding-xb bunny-overflow-auto" }, { children: [targetUrl ? (jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsx(Markup, { content: html })), children] }))) : (jsxs(MarkupContainer, __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 bunny-p-4 bunny-w-full bunny-bg-white ".concat(shadow ? shadow : 'bunny-shadow-md', " bunny-rounded-md"), style: {
|
|
406
456
|
minWidth: '750px',
|
|
407
|
-
} }, { children: [jsx(Markup, { content: html }), children] })))] })));
|
|
457
|
+
} }, { children: [targetUrl ? (jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsx(Markup, { content: html })), children] })))] })));
|
|
408
458
|
};
|
|
409
459
|
var templateObject_1$c;
|
|
410
460
|
|
|
@@ -19165,7 +19215,7 @@ function ActualInvoice() {
|
|
|
19165
19215
|
return (jsx("div", __assign({ className: "bunny-invoice-container" }, { children: 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 ? (jsx("div", __assign({ className: "bunny-flex bunny-justify-center bunny-w-full" }, { children: jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "bunny-w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12') }, { children: jsx(PaymentForm, { onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice }) })))] })) })));
|
|
19166
19216
|
}
|
|
19167
19217
|
|
|
19168
|
-
var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n object {\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
|
|
19218
|
+
var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n object {\n documents { id filename size date url }\n documentTemplateId\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 }"; };
|
|
19169
19219
|
var getFormattedQuote = function (_a) {
|
|
19170
19220
|
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
19171
19221
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -19559,14 +19609,13 @@ var useQuotePaymentHold = function (formattedQuote) {
|
|
|
19559
19609
|
};
|
|
19560
19610
|
function ActualQuote() {
|
|
19561
19611
|
var _this = this;
|
|
19562
|
-
var _a, _b, _c;
|
|
19612
|
+
var _a, _b, _c, _d;
|
|
19563
19613
|
// Context
|
|
19564
|
-
var
|
|
19614
|
+
var _e = useContext(BunnyContext), apiHost = _e.apiHost, onTokenExpired = _e.onTokenExpired;
|
|
19565
19615
|
var token = useToken();
|
|
19566
|
-
useContext(
|
|
19567
|
-
var _e = useContext(InvoiceQuoteContext), className = _e.className, id = _e.id, hideDownloadButton = _e.hideDownloadButton, onQuoteLoaded = _e.onQuoteLoaded;
|
|
19616
|
+
var _f = useContext(InvoiceQuoteContext), className = _f.className, id = _f.id, hideDownloadButton = _f.hideDownloadButton, onQuoteLoaded = _f.onQuoteLoaded;
|
|
19568
19617
|
// Queries
|
|
19569
|
-
var
|
|
19618
|
+
var _g = useQuery({
|
|
19570
19619
|
queryKey: QueryKeyFactory.default.createQuoteKey({ id: id, token: token }),
|
|
19571
19620
|
queryFn: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
19572
19621
|
var error_1;
|
|
@@ -19585,15 +19634,16 @@ function ActualQuote() {
|
|
|
19585
19634
|
});
|
|
19586
19635
|
}); },
|
|
19587
19636
|
placeholderData: keepPreviousData,
|
|
19588
|
-
}), data =
|
|
19637
|
+
}), data = _g.data, isLoading = _g.isLoading;
|
|
19589
19638
|
var formattedQuote = data;
|
|
19639
|
+
console.log(data);
|
|
19590
19640
|
// Hooks
|
|
19591
|
-
var
|
|
19641
|
+
var _h = useSendAcceptQuote({
|
|
19592
19642
|
token: token,
|
|
19593
19643
|
onTokenExpired: onTokenExpired,
|
|
19594
19644
|
apiHost: apiHost,
|
|
19595
19645
|
quoteId: id,
|
|
19596
|
-
}), acceptBoxVisible =
|
|
19646
|
+
}), 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;
|
|
19597
19647
|
useSigningComplete({ data: formattedQuote, token: token });
|
|
19598
19648
|
var isMobile = useIsMobile();
|
|
19599
19649
|
var showErrorNotification = useErrorNotification();
|
|
@@ -19603,7 +19653,7 @@ function ActualQuote() {
|
|
|
19603
19653
|
}
|
|
19604
19654
|
}, [formattedQuote]);
|
|
19605
19655
|
// Payment hold stuff here
|
|
19606
|
-
var
|
|
19656
|
+
var _j = useQuotePaymentHold(formattedQuote), paymentHoldModalVisible = _j.paymentHoldModalVisible, setPaymentHoldModalVisible = _j.setPaymentHoldModalVisible, shouldDoPaymentHold = _j.shouldDoPaymentHold, paymentHoldCompleted = _j.paymentHoldCompleted, paymentHold = _j.paymentHold;
|
|
19607
19657
|
var handleClickAccept = function () {
|
|
19608
19658
|
if (shouldDoPaymentHold && !paymentHoldCompleted) {
|
|
19609
19659
|
setPaymentHoldModalVisible(true);
|
|
@@ -19621,7 +19671,7 @@ function ActualQuote() {
|
|
|
19621
19671
|
if ((firstInvoice === null || firstInvoice === void 0 ? void 0 : firstInvoice.state) === 'PAID' && paymentHoldCompleted) {
|
|
19622
19672
|
return jsx(Invoice, { id: firstInvoice.id });
|
|
19623
19673
|
}
|
|
19624
|
-
return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html }, { children: ((
|
|
19674
|
+
return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html, targetUrl: ((_b = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object) === null || _b === void 0 ? void 0 : _b.documentTemplateId) ? "".concat(apiHost, "/api/pdf/quote") : undefined }, { children: ((_d = (_c = formattedQuote.object) === null || _c === void 0 ? void 0 : _c.documents) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: formattedQuote.object.documents.map(function (doc, index) {
|
|
19625
19675
|
return (jsx(Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
|
|
19626
19676
|
}) }))) : null }))] })), jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept, isSendAcceptPending: isSendAcceptPending }), jsx(PaymentHoldModal, { visible: paymentHoldModalVisible, setVisible: setPaymentHoldModalVisible, quote: formattedQuote }), jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
|
|
19627
19677
|
}
|
|
@@ -21207,7 +21257,6 @@ var PlanPickerCheckoutBar = function (_a) {
|
|
|
21207
21257
|
}) })), jsx(CheckoutBarSummarySection, { onClickCheckout: function () { return setPayModalVisible(true); }, open: payModalVisible, quote: quote, selectedPriceList: selectedPriceList, upgradingSubscription: upgradingSubscription, quotePreviewData: quotePreviewData }), jsx(Checkout, { isMobile: isMobile, onCancel: function () { return setPayModalVisible(false); }, onFail: onCheckoutFail, onSuccess: handleCheckoutSuccess, open: payModalVisible, quote: quote, selectedPriceList: selectedPriceList, storedPaymentMethod: defaultPaymentMethod, token: token })] })));
|
|
21208
21258
|
};
|
|
21209
21259
|
|
|
21210
|
-
console.log('PriceListChangeOptionsQuery');
|
|
21211
21260
|
// WARNING: There is a preview button on APP that will need to be changed if this query is changed
|
|
21212
21261
|
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 }";
|
|
21213
21262
|
var getPriceListChangeOptions = function (_a) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FormattedInvoice } from '@bunnyapp/common';
|
|
3
|
-
declare const InvoiceQuoteView: ({ children, formattedInvoice, html, backButtonName, onBackButtonClick, onDownloadError, }: {
|
|
3
|
+
declare const InvoiceQuoteView: ({ children, formattedInvoice, html, backButtonName, onBackButtonClick, onDownloadError, targetUrl, }: {
|
|
4
4
|
html: string;
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
formattedInvoice?: FormattedInvoice | undefined;
|
|
7
7
|
backButtonName?: string | undefined;
|
|
8
8
|
onBackButtonClick?: (() => void) | undefined;
|
|
9
9
|
onDownloadError?: (() => void) | undefined;
|
|
10
|
+
targetUrl?: string | undefined;
|
|
10
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export default InvoiceQuoteView;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunnyapp/components",
|
|
3
|
-
"version": "1.0.62-beta.
|
|
3
|
+
"version": "1.0.62-beta.5",
|
|
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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@ant-design/icons": "^5.6.1",
|
|
68
|
-
"@bunnyapp/common": "^1.0.62-beta.
|
|
68
|
+
"@bunnyapp/common": "^1.0.62-beta.6",
|
|
69
69
|
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
70
70
|
"@fortawesome/free-brands-svg-icons": "^6.7.2",
|
|
71
71
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|