@bunnyapp/components 1.0.19 → 1.0.21
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 +285 -468
- package/dist/cjs/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
- package/dist/cjs/src/components/Quote/Quote.stories.d.ts +15 -15
- package/dist/cjs/src/components/Subscriptions/Subscriptions.d.ts +11 -5
- package/dist/cjs/src/components/Subscriptions/SubscriptionsContext.d.ts +1 -4
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/SubscriptionCardActions.d.ts +3 -3
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/SubscriptionCardHeader.d.ts +3 -3
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/SubscriptionsList.d.ts +4 -5
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/subscriptionCardDesktop/SubscriptionCardDesktop.d.ts +3 -3
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/subscriptionCardMobile/SubscriptionCardMobile.d.ts +2 -5
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +0 -3
- package/dist/cjs/src/components/Transactions/Transactions.d.ts +4 -1
- package/dist/cjs/src/components/Transactions/TransactionsListContext.d.ts +3 -1
- package/dist/cjs/src/components/Transactions/transactionsList/TransactionsListDesktop.d.ts +2 -2
- package/dist/cjs/src/components/Transactions/transactionsList/TransactionsListMobile.d.ts +1 -1
- package/dist/cjs/src/components/Transactions/transactionsList/utils.d.ts +3 -0
- package/dist/cjs/src/graphql/queries/getSubscriptions.d.ts +2 -2
- package/dist/esm/index.js +287 -470
- package/dist/esm/src/components/PaymentForm/useRemovePaymentMethod.d.ts +1 -1
- package/dist/esm/src/components/Quote/Quote.stories.d.ts +15 -15
- package/dist/esm/src/components/Subscriptions/Subscriptions.d.ts +11 -5
- package/dist/esm/src/components/Subscriptions/SubscriptionsContext.d.ts +1 -4
- package/dist/esm/src/components/Subscriptions/subscriptionsList/SubscriptionCardActions.d.ts +3 -3
- package/dist/esm/src/components/Subscriptions/subscriptionsList/SubscriptionCardHeader.d.ts +3 -3
- package/dist/esm/src/components/Subscriptions/subscriptionsList/SubscriptionsList.d.ts +4 -5
- package/dist/esm/src/components/Subscriptions/subscriptionsList/subscriptionCardDesktop/SubscriptionCardDesktop.d.ts +3 -3
- package/dist/esm/src/components/Subscriptions/subscriptionsList/subscriptionCardMobile/SubscriptionCardMobile.d.ts +2 -5
- package/dist/esm/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts +0 -3
- package/dist/esm/src/components/Transactions/Transactions.d.ts +4 -1
- package/dist/esm/src/components/Transactions/TransactionsListContext.d.ts +3 -1
- package/dist/esm/src/components/Transactions/transactionsList/TransactionsListDesktop.d.ts +2 -2
- package/dist/esm/src/components/Transactions/transactionsList/TransactionsListMobile.d.ts +1 -1
- package/dist/esm/src/components/Transactions/transactionsList/utils.d.ts +3 -0
- package/dist/esm/src/graphql/queries/getSubscriptions.d.ts +2 -2
- package/dist/index.d.ts +16 -7
- package/package.json +2 -2
- package/dist/cjs/src/components/PageHeaderWithActions.d.ts +0 -7
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/ChangeQuantitiesButton.d.ts +0 -5
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/HideExpiredToggle.d.ts +0 -7
- package/dist/cjs/src/components/Subscriptions/subscriptionsList/SubscriptionsNavigation.d.ts +0 -8
- package/dist/cjs/src/graphql/queries/getQuote.d.ts +0 -7
- package/dist/esm/src/components/PageHeaderWithActions.d.ts +0 -7
- package/dist/esm/src/components/Subscriptions/subscriptionsList/ChangeQuantitiesButton.d.ts +0 -5
- package/dist/esm/src/components/Subscriptions/subscriptionsList/HideExpiredToggle.d.ts +0 -7
- package/dist/esm/src/components/Subscriptions/subscriptionsList/SubscriptionsNavigation.d.ts +0 -8
- package/dist/esm/src/graphql/queries/getQuote.d.ts +0 -7
package/dist/cjs/index.js
CHANGED
|
@@ -1598,7 +1598,7 @@ var BrandContext = React.createContext({
|
|
|
1598
1598
|
topNavImageUrl: common.DEFAULT_TOP_NAV_IMAGE_URL,
|
|
1599
1599
|
});
|
|
1600
1600
|
|
|
1601
|
-
var MUTATION$
|
|
1601
|
+
var MUTATION$8 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
|
|
1602
1602
|
var getBranding = function (_a) {
|
|
1603
1603
|
var token = _a.token, apiHost = _a.apiHost;
|
|
1604
1604
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1606,7 +1606,7 @@ var getBranding = function (_a) {
|
|
|
1606
1606
|
return __generator(this, function (_b) {
|
|
1607
1607
|
switch (_b.label) {
|
|
1608
1608
|
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
1609
|
-
query: MUTATION$
|
|
1609
|
+
query: MUTATION$8,
|
|
1610
1610
|
token: token,
|
|
1611
1611
|
apiHost: apiHost,
|
|
1612
1612
|
})];
|
|
@@ -1800,7 +1800,7 @@ function useToken() {
|
|
|
1800
1800
|
return overrideToken || tokenFromContext;
|
|
1801
1801
|
}
|
|
1802
1802
|
|
|
1803
|
-
var MarkupContainer = styled__default["default"].div(templateObject_1$
|
|
1803
|
+
var MarkupContainer = styled__default["default"].div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
|
|
1804
1804
|
var InvoiceQuoteView = function (_a) {
|
|
1805
1805
|
var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError;
|
|
1806
1806
|
var downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
|
|
@@ -1818,7 +1818,7 @@ var InvoiceQuoteView = function (_a) {
|
|
|
1818
1818
|
minWidth: "750px",
|
|
1819
1819
|
} }, { children: [jsxRuntime.jsx(interweave.Markup, { content: html }), children] })))] })));
|
|
1820
1820
|
};
|
|
1821
|
-
var templateObject_1$
|
|
1821
|
+
var templateObject_1$7;
|
|
1822
1822
|
|
|
1823
1823
|
var quoteMetaDescription = function (vendorName) {
|
|
1824
1824
|
return "View this quote on the ".concat(vendorName, " customer portal. Powered by Bunny");
|
|
@@ -1976,7 +1976,7 @@ var gqlRequest = function (_a) {
|
|
|
1976
1976
|
});
|
|
1977
1977
|
};
|
|
1978
1978
|
|
|
1979
|
-
var MUTATION$
|
|
1979
|
+
var MUTATION$7 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
|
|
1980
1980
|
var checkout = function (_a) {
|
|
1981
1981
|
var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
|
|
1982
1982
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1993,7 +1993,7 @@ var checkout = function (_a) {
|
|
|
1993
1993
|
mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
|
|
1994
1994
|
}
|
|
1995
1995
|
return [4 /*yield*/, gqlRequest({
|
|
1996
|
-
query: MUTATION$
|
|
1996
|
+
query: MUTATION$7,
|
|
1997
1997
|
token: token,
|
|
1998
1998
|
vars: mutationVars,
|
|
1999
1999
|
apiHost: apiHost,
|
|
@@ -2196,13 +2196,13 @@ var PlusIcon = function (_a) {
|
|
|
2196
2196
|
return (jsxRuntime.jsxs("svg", __assign({ width: "14", height: "15", viewBox: "0 0 14 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsx("path", { d: "M2.9165 7.5H11.0832", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M7 3.41663V11.5833", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
2197
2197
|
};
|
|
2198
2198
|
|
|
2199
|
-
var Text$
|
|
2199
|
+
var Text$e = antd.Typography.Text;
|
|
2200
2200
|
var CreditCard = function (_a) {
|
|
2201
2201
|
var _b;
|
|
2202
2202
|
var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, _d = _a.cardEnabled, cardEnabled = _d === void 0 ? true : _d;
|
|
2203
2203
|
var isMobile = common.useIsMobile();
|
|
2204
2204
|
var Wrapper = cardEnabled ? Card : "div";
|
|
2205
|
-
return (jsxRuntime.jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Text$
|
|
2205
|
+
return (jsxRuntime.jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Text$e, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier })] })), jsxRuntime.jsx(antd.Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsxRuntime.jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(antd.Divider, {}), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsxRuntime.jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsxRuntime.jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
|
|
2206
2206
|
};
|
|
2207
2207
|
var MiniCreditCard = function (_a) {
|
|
2208
2208
|
var _b;
|
|
@@ -2214,7 +2214,7 @@ var MiniCreditCard = function (_a) {
|
|
|
2214
2214
|
var backgroundColor = React.useMemo(function () {
|
|
2215
2215
|
return darkMode ? "var(--row-background-alternate)" : "bg-slate-50";
|
|
2216
2216
|
}, [darkMode]);
|
|
2217
|
-
return (jsxRuntime.jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4 space-between w-full" }, { children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Text$
|
|
2217
|
+
return (jsxRuntime.jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4 space-between w-full" }, { children: [jsxRuntime.jsx(CardImage, { paymentMethodData: paymentMethodData }), jsxRuntime.jsx(Text$e, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier }), jsxRuntime.jsx(antd.Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })) })), !hideRemoveButton && (jsxRuntime.jsx(antd.Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxRuntime.jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsxRuntime.jsx(CreditCardOutlined$1, {}), jsxRuntime.jsx(Text$e, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsxRuntime.jsx(antd.Button, { disabled: true, type: "link" })] }))) })));
|
|
2218
2218
|
};
|
|
2219
2219
|
var CardImage = function (_a) {
|
|
2220
2220
|
var _b, _c;
|
|
@@ -2233,7 +2233,7 @@ var CardImage = function (_a) {
|
|
|
2233
2233
|
};
|
|
2234
2234
|
var CardAttribute = function (_a) {
|
|
2235
2235
|
var title = _a.title, value = _a.value;
|
|
2236
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsxRuntime.jsx(Text$
|
|
2236
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsxRuntime.jsx(Text$e, { children: value })] })));
|
|
2237
2237
|
};
|
|
2238
2238
|
var CardActions = function (_a) {
|
|
2239
2239
|
var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
|
|
@@ -2243,7 +2243,7 @@ var CardActions = function (_a) {
|
|
|
2243
2243
|
var EmptyCard = function (_a) {
|
|
2244
2244
|
var onClick = _a.onClick, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, _c = _a.cardEnabled, cardEnabled = _c === void 0 ? true : _c;
|
|
2245
2245
|
var brandColor = React.useContext(BrandContext).brandColor;
|
|
2246
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer ".concat(cardEnabled ? "bg-white ".concat(shadow, " rounded-md") : ""), onClick: onClick }, { children: [jsxRuntime.jsx(LargeCardIcon, {}), jsxRuntime.jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsxRuntime.jsx(antd.Button, __assign({ type: "link" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsxRuntime.jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
|
|
2246
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer ".concat(cardEnabled ? "bg-white ".concat(shadow, " rounded-md") : ""), onClick: onClick }, { children: [jsxRuntime.jsx(LargeCardIcon, {}), jsxRuntime.jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsxRuntime.jsx(antd.Button, __assign({ type: "link", id: "openAddPaymentMethodDrawer" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsxRuntime.jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
|
|
2247
2247
|
};
|
|
2248
2248
|
var isExpired = function (paymentMethodData) {
|
|
2249
2249
|
var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
|
|
@@ -2331,7 +2331,7 @@ var DemoPayCardCvc = function (_a) {
|
|
|
2331
2331
|
var cvc = event.target.value.replace(/\D/g, "");
|
|
2332
2332
|
onChange(cvc);
|
|
2333
2333
|
};
|
|
2334
|
-
return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: value, maxLength: 3, placeholder: placeholder || "CVC" }) })));
|
|
2334
|
+
return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { name: "cvc", autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: value, maxLength: 3, placeholder: placeholder || "CVC" }) })));
|
|
2335
2335
|
};
|
|
2336
2336
|
|
|
2337
2337
|
var CARD_NUMBER_MAX_LENGTH = 19; // Why 19 instead of 16? Because we add spaces
|
|
@@ -2348,7 +2348,7 @@ var DemoPayCardNumber = function (_a) {
|
|
|
2348
2348
|
var number = event.target.value.replace(/\s/g, "");
|
|
2349
2349
|
onChange(number);
|
|
2350
2350
|
};
|
|
2351
|
-
return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { autoFocus: autoFocus, maxLength: CARD_NUMBER_MAX_LENGTH, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, placeholder: placeholder || "Card Number", value: formatCardNumber(value) }) })));
|
|
2351
|
+
return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { name: "cardNumber", autoFocus: autoFocus, maxLength: CARD_NUMBER_MAX_LENGTH, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, placeholder: placeholder || "Card Number", value: formatCardNumber(value) }) })));
|
|
2352
2352
|
};
|
|
2353
2353
|
|
|
2354
2354
|
var DemoPayExpiry = function (_a) {
|
|
@@ -2361,7 +2361,7 @@ var DemoPayExpiry = function (_a) {
|
|
|
2361
2361
|
var expiry = event.target.value.replace(/\D/g, "");
|
|
2362
2362
|
onChange(expiry);
|
|
2363
2363
|
};
|
|
2364
|
-
return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: formatCardExpiry(value), maxLength: 5, placeholder: placeholder || "MM/YY" }) })));
|
|
2364
|
+
return (jsxRuntime.jsx("div", __assign({ className: "grow" }, { children: jsxRuntime.jsx(antd.Input, { name: "expiry", autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: formatCardExpiry(value), maxLength: 5, placeholder: placeholder || "MM/YY" }) })));
|
|
2365
2365
|
};
|
|
2366
2366
|
|
|
2367
2367
|
function useSave$1(_a) {
|
|
@@ -2414,7 +2414,7 @@ function useSave$1(_a) {
|
|
|
2414
2414
|
return { save: save, isSaving: isSaving };
|
|
2415
2415
|
}
|
|
2416
2416
|
|
|
2417
|
-
var Text$
|
|
2417
|
+
var Text$d = antd.Typography.Text;
|
|
2418
2418
|
var TEST_CARD = "4242424242424242";
|
|
2419
2419
|
var DemoPayForm = function (_a) {
|
|
2420
2420
|
var onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod, plugin = _a.plugin;
|
|
@@ -2475,16 +2475,16 @@ var DemoPayForm = function (_a) {
|
|
|
2475
2475
|
var onCardCvcChange = function (cvc) {
|
|
2476
2476
|
setCardDetails(__assign(__assign({}, cardDetails), { cvc: cvc }));
|
|
2477
2477
|
};
|
|
2478
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsxRuntime.jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsxRuntime.jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsxRuntime.jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsxRuntime.jsx(Text$
|
|
2478
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsxRuntime.jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsxRuntime.jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsxRuntime.jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsxRuntime.jsx(Text$d, __assign({ className: "text-xs" }, { children: "DemoPay is for testing only." })), jsxRuntime.jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
|
|
2479
2479
|
};
|
|
2480
|
-
var StyledInputs = styled__default["default"].div(templateObject_1$
|
|
2480
|
+
var StyledInputs = styled__default["default"].div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"], ["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"])), function (_a) {
|
|
2481
2481
|
var darkMode = _a.darkMode;
|
|
2482
2482
|
return darkMode ? "var(--row-background-dark)" : "white";
|
|
2483
2483
|
}, function (_a) {
|
|
2484
2484
|
var darkMode = _a.darkMode;
|
|
2485
2485
|
return darkMode ? common.GRAY_500 : common.GRAY_200;
|
|
2486
2486
|
});
|
|
2487
|
-
var templateObject_1$
|
|
2487
|
+
var templateObject_1$6;
|
|
2488
2488
|
|
|
2489
2489
|
var createPaymentMethod = function (_a) {
|
|
2490
2490
|
var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
|
|
@@ -2713,7 +2713,7 @@ var CardIcon = function () {
|
|
|
2713
2713
|
return (jsxRuntime.jsxs("svg", __assign({ width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxRuntime.jsx("path", { d: "M15 3.75H3C2.17157 3.75 1.5 4.42157 1.5 5.25V12.75C1.5 13.5784 2.17157 14.25 3 14.25H15C15.8284 14.25 16.5 13.5784 16.5 12.75V5.25C16.5 4.42157 15.8284 3.75 15 3.75Z", stroke: common.SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M1.5 7.5H16.5", stroke: common.SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
2714
2714
|
};
|
|
2715
2715
|
|
|
2716
|
-
var Text$
|
|
2716
|
+
var Text$c = antd.Typography.Text;
|
|
2717
2717
|
var PaymentMethodSelector = function (_a) {
|
|
2718
2718
|
var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, value = _a.value;
|
|
2719
2719
|
return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsxRuntime.jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentPlugin: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
|
|
@@ -2726,9 +2726,9 @@ var PaymentOption = function (_a) {
|
|
|
2726
2726
|
var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
|
|
2727
2727
|
return (jsxRuntime.jsxs(PaymentOptionContainer, __assign({ "$brandColor": brandColor, "$selected": selected, className: "flex justify-between items-center w-full cursor-pointer py-2 px-4 rounded border-solid ".concat(darkMode
|
|
2728
2728
|
? "var(--row-background-dark) border-gray-500"
|
|
2729
|
-
: "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsxRuntime.jsx(Text$
|
|
2729
|
+
: "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsxRuntime.jsx(antd.Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsxRuntime.jsx(Text$c, { children: name })] })), isAch ? (jsxRuntime.jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsxRuntime.jsx(CardIcon, {})) : (jsxRuntime.jsx(CardIcon, {}))] })));
|
|
2730
2730
|
};
|
|
2731
|
-
var PaymentOptionContainer = styled__default["default"].div(templateObject_1$
|
|
2731
|
+
var PaymentOptionContainer = styled__default["default"].div(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"], ["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"])), function (_a) {
|
|
2732
2732
|
var $brandColor = _a.$brandColor, $selected = _a.$selected;
|
|
2733
2733
|
return $selected &&
|
|
2734
2734
|
"\n border-color: ".concat($brandColor, ";\n ");
|
|
@@ -2736,34 +2736,44 @@ var PaymentOptionContainer = styled__default["default"].div(templateObject_1$6 |
|
|
|
2736
2736
|
var $brandColor = _a.$brandColor;
|
|
2737
2737
|
return $brandColor;
|
|
2738
2738
|
});
|
|
2739
|
-
var templateObject_1$
|
|
2739
|
+
var templateObject_1$5;
|
|
2740
2740
|
|
|
2741
2741
|
function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
|
|
2742
|
+
var _this = this;
|
|
2742
2743
|
var queryClient = reactQuery.useQueryClient();
|
|
2743
2744
|
var showErrorNotification = common.useErrorNotification();
|
|
2744
2745
|
var showSuccessNotification = common.useSuccessNotification();
|
|
2745
|
-
var removePaymentMethod = React.useCallback(function (data) {
|
|
2746
|
-
var plugin
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2746
|
+
var removePaymentMethod = React.useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
2747
|
+
var plugin;
|
|
2748
|
+
return __generator(this, function (_a) {
|
|
2749
|
+
switch (_a.label) {
|
|
2750
|
+
case 0:
|
|
2751
|
+
plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (paymentPlugin) { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
|
|
2752
|
+
if (!(data && plugin)) return [3 /*break*/, 2];
|
|
2753
|
+
return [4 /*yield*/, common.invokePlugin({
|
|
2754
|
+
plugin: plugin,
|
|
2755
|
+
method: "remove_payment_method",
|
|
2756
|
+
payload: {
|
|
2757
|
+
payment_method_id: data.id,
|
|
2758
|
+
account_id: accountId,
|
|
2759
|
+
},
|
|
2760
|
+
token: token,
|
|
2761
|
+
apiHost: apiHost,
|
|
2762
|
+
})
|
|
2763
|
+
.then(function () {
|
|
2764
|
+
showSuccessNotification("Payment method was removed", "Success");
|
|
2765
|
+
queryClient.setQueryData(common.QueryKeyFactory.default.accountPaymentMethodKey, null);
|
|
2766
|
+
})
|
|
2767
|
+
.catch(function (error) {
|
|
2768
|
+
showErrorNotification(error.message, "Error removing payment method");
|
|
2769
|
+
})];
|
|
2770
|
+
case 1:
|
|
2771
|
+
_a.sent();
|
|
2772
|
+
_a.label = 2;
|
|
2773
|
+
case 2: return [2 /*return*/];
|
|
2774
|
+
}
|
|
2775
|
+
});
|
|
2776
|
+
}); }, [paymentPlugins, token, apiHost, queryClient]);
|
|
2767
2777
|
return removePaymentMethod;
|
|
2768
2778
|
}
|
|
2769
2779
|
|
|
@@ -2830,7 +2840,7 @@ var PaymentForm = function (_a) {
|
|
|
2830
2840
|
//if not paying and payment method is saved, show Collapse
|
|
2831
2841
|
jsxRuntime.jsx(antd.Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsxRuntime.jsx(Panel, __assign({ header: jsxRuntime.jsx(jsxRuntime.Fragment, { children: !showPaymentMethodForm ? (jsxRuntime.jsx("div", __assign({ className: "pt-2" }, { children: jsxRuntime.jsxs(antd.Button, __assign({ onClick: function () {
|
|
2832
2842
|
setShowPaymentMethodForm(true);
|
|
2833
|
-
}, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsxRuntime.jsx("div", { children: selectedPaymentMethod ? (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsxRuntime.jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsxRuntime.jsx("div", __assign({ className: "flex flex-col" }, { children: jsxRuntime.jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsxRuntime.jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
|
|
2843
|
+
}, type: "default", className: "w-full", id: "addPaymentMethod" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsxRuntime.jsx("div", { children: selectedPaymentMethod ? (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsxRuntime.jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsxRuntime.jsx("div", __assign({ className: "flex flex-col" }, { children: jsxRuntime.jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsxRuntime.jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
|
|
2834
2844
|
};
|
|
2835
2845
|
function StripeWrapper(_a) {
|
|
2836
2846
|
var children = _a.children, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
|
|
@@ -2864,17 +2874,14 @@ function ActualInvoice() {
|
|
|
2864
2874
|
var showSuccessNotification = common.useSuccessNotification();
|
|
2865
2875
|
var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
|
|
2866
2876
|
// Queries
|
|
2867
|
-
var
|
|
2877
|
+
var formattedInvoice = reactQuery.useQuery({
|
|
2868
2878
|
queryKey: common.QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
|
|
2869
2879
|
queryFn: function () { return common.getFormattedInvoice({ id: id, token: token, apiHost: apiHost }); },
|
|
2870
|
-
})
|
|
2880
|
+
}).data;
|
|
2871
2881
|
// Derived state
|
|
2872
2882
|
var isInvoicePayable = common.PAYABLE_INVOICE_STATES.includes((formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.state) || "");
|
|
2873
2883
|
// Local state
|
|
2874
2884
|
var isMobile = common.useIsMobile(isInvoicePayable ? common.BreakpointNumbers.lg : undefined);
|
|
2875
|
-
if (error) {
|
|
2876
|
-
return jsxRuntime.jsxs("div", { children: ["Error loading invoice: ", error.message] });
|
|
2877
|
-
}
|
|
2878
2885
|
if (!formattedInvoice)
|
|
2879
2886
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
2880
2887
|
var onSuccess = function () {
|
|
@@ -2895,7 +2902,7 @@ function ActualInvoice() {
|
|
|
2895
2902
|
}) }), jsxRuntime.jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxRuntime.jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsxRuntime.jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsxRuntime.jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost, token: token }) }))) : (invoiceQuoteViewComponent || (jsxRuntime.jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsxRuntime.jsx("div", __assign({ className: "w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? "" : "pt-12") }, { children: jsxRuntime.jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice, graphQLClient: graphQLClient }) })))] }))] }));
|
|
2896
2903
|
}
|
|
2897
2904
|
|
|
2898
|
-
var MUTATION$
|
|
2905
|
+
var MUTATION$6 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n object { documents { id filename size date url } }\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 }"; };
|
|
2899
2906
|
var getFormattedQuote = function (_a) {
|
|
2900
2907
|
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
2901
2908
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2903,7 +2910,7 @@ var getFormattedQuote = function (_a) {
|
|
|
2903
2910
|
return __generator(this, function (_b) {
|
|
2904
2911
|
switch (_b.label) {
|
|
2905
2912
|
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
2906
|
-
query: MUTATION$
|
|
2913
|
+
query: MUTATION$6(),
|
|
2907
2914
|
token: token,
|
|
2908
2915
|
apiHost: apiHost,
|
|
2909
2916
|
vars: { id: id },
|
|
@@ -2957,24 +2964,18 @@ var useSendAcceptQuote = function (_a) {
|
|
|
2957
2964
|
if (rsp.errors)
|
|
2958
2965
|
console.log("rsp.errors", rsp.errors);
|
|
2959
2966
|
else {
|
|
2960
|
-
console.log("rsp.data.quoteSigningUrlCreate.pluginShortName === 'pandadoc'", rsp.data.quoteSigningUrlCreate.pluginShortName === "pandadoc");
|
|
2961
|
-
console.log("rsp", rsp);
|
|
2962
2967
|
if (rsp.data.quoteSigningUrlCreate.pluginShortName === "dropbox_sign") {
|
|
2963
2968
|
openDropboxSignModal(rsp.data.quoteSigningUrlCreate.pluginClientId, rsp.data.quoteSigningUrlCreate.redirectUri);
|
|
2964
|
-
console.log("dropbox sign is not implemented");
|
|
2965
2969
|
}
|
|
2966
2970
|
else if (rsp.data.quoteSigningUrlCreate.pluginShortName === "pandadoc") {
|
|
2967
2971
|
setPandadocPollingModalVisible(true);
|
|
2968
|
-
console.log("setPandadocPollingModalVisible");
|
|
2969
2972
|
}
|
|
2970
2973
|
else {
|
|
2971
2974
|
window.location.href = rsp.data.quoteSigningUrlCreate.redirectUri;
|
|
2972
|
-
console.log("window.location.href", rsp.data.quoteSigningUrlCreate.redirectUri);
|
|
2973
2975
|
}
|
|
2974
2976
|
}
|
|
2975
2977
|
});
|
|
2976
2978
|
};
|
|
2977
|
-
// TODO: Fix hellosign-embedded window is undefined bug
|
|
2978
2979
|
var openDropboxSignModal = function (clientId, url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2979
2980
|
var HelloSign, client;
|
|
2980
2981
|
return __generator(this, function (_a) {
|
|
@@ -2990,7 +2991,12 @@ var useSendAcceptQuote = function (_a) {
|
|
|
2990
2991
|
clientId: clientId,
|
|
2991
2992
|
});
|
|
2992
2993
|
client.on("sign", function (data) {
|
|
2993
|
-
|
|
2994
|
+
queryClient.refetchQueries({
|
|
2995
|
+
queryKey: common.QueryKeyFactory.default.createQuoteKey(token, quoteId),
|
|
2996
|
+
});
|
|
2997
|
+
queryClient.refetchQueries({
|
|
2998
|
+
queryKey: common.QueryKeyFactory.default.createQuoteKey(token),
|
|
2999
|
+
});
|
|
2994
3000
|
});
|
|
2995
3001
|
// Open the DropboxSign modal
|
|
2996
3002
|
client.open(url, {
|
|
@@ -3001,7 +3007,6 @@ var useSendAcceptQuote = function (_a) {
|
|
|
3001
3007
|
}
|
|
3002
3008
|
});
|
|
3003
3009
|
}); };
|
|
3004
|
-
// TODO: update useing fetch
|
|
3005
3010
|
var sendAccept = function (changedFormItems) {
|
|
3006
3011
|
var mutation = "mutation quoteAccept($name: String!, $title: String!, $poNumber: String, $taxNumber: String, $quoteId: ID) {\n quoteAccept(name: $name, title: $title, poNumber: $poNumber, taxNumber: $taxNumber, quoteId: $quoteId) {\n errors\n }\n }";
|
|
3007
3012
|
var variables = __assign(__assign({}, changedFormItems), { quoteId: quoteId });
|
|
@@ -3010,6 +3015,9 @@ var useSendAcceptQuote = function (_a) {
|
|
|
3010
3015
|
handleAllErrorFormats(rsp.errors);
|
|
3011
3016
|
else {
|
|
3012
3017
|
setAcceptBoxVisible(false);
|
|
3018
|
+
queryClient.invalidateQueries({
|
|
3019
|
+
queryKey: common.QueryKeyFactory.default.createQuoteKey(token, quoteId),
|
|
3020
|
+
});
|
|
3013
3021
|
queryClient.invalidateQueries({
|
|
3014
3022
|
queryKey: common.QueryKeyFactory.default.createQuoteKey(token),
|
|
3015
3023
|
});
|
|
@@ -3101,11 +3109,11 @@ var PandadocPollingModal = function (_a) {
|
|
|
3101
3109
|
return (jsxRuntime.jsxs(antd.Modal, __assign({ title: "Uploading quote to Pandadoc", open: isVisible, closable: false, footer: null }, { children: [jsxRuntime.jsxs("div", __assign({ className: "py-4 text-center" }, { children: ["This may take a few seconds", ".".repeat(numberOfPolls)] })), jsxRuntime.jsx("div", __assign({ className: "text-center" }, { children: infoMessage }))] })));
|
|
3102
3110
|
};
|
|
3103
3111
|
|
|
3104
|
-
var ModalOverrideBrandStylings = styled__default["default"](antd.Modal)(templateObject_1$
|
|
3112
|
+
var ModalOverrideBrandStylings = styled__default["default"](antd.Modal)(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n .ant-modal-content {\n border-radius: 0.75rem;\n overflow: hidden;\n padding: 0 !important;\n }\n .ant-modal-title {\n font-family: ", ";\n }\n .ant-modal-header {\n border-bottom: none;\n padding: 1.5rem 1.5rem 0;\n margin: 0 !important;\n }\n .ant-modal-body {\n padding: 1rem 1.5rem 1.5rem;\n }\n .ant-modal-footer {\n border-top: none;\n padding: 0 1.5rem 1.5rem;\n margin: 0 !important;\n }\n"], ["\n .ant-modal-content {\n border-radius: 0.75rem;\n overflow: hidden;\n padding: 0 !important;\n }\n .ant-modal-title {\n font-family: ", ";\n }\n .ant-modal-header {\n border-bottom: none;\n padding: 1.5rem 1.5rem 0;\n margin: 0 !important;\n }\n .ant-modal-body {\n padding: 1rem 1.5rem 1.5rem;\n }\n .ant-modal-footer {\n border-top: none;\n padding: 0 1.5rem 1.5rem;\n margin: 0 !important;\n }\n"])), common.MARK_PRO);
|
|
3105
3113
|
var StyledModal$1 = function (props) {
|
|
3106
3114
|
return jsxRuntime.jsx(ModalOverrideBrandStylings, __assign({ closable: false }, props));
|
|
3107
3115
|
};
|
|
3108
|
-
var templateObject_1$
|
|
3116
|
+
var templateObject_1$4;
|
|
3109
3117
|
|
|
3110
3118
|
var useFocusFirstInput = function (_a) {
|
|
3111
3119
|
var firstInputRef = _a.firstInputRef, isVisible = _a.isVisible;
|
|
@@ -3146,9 +3154,9 @@ var DOCUMENT_NAME;
|
|
|
3146
3154
|
DOCUMENT_NAME["QUOTE"] = "quote";
|
|
3147
3155
|
})(DOCUMENT_NAME || (DOCUMENT_NAME = {}));
|
|
3148
3156
|
|
|
3149
|
-
var Text$
|
|
3157
|
+
var Text$b = antd.Typography.Text;
|
|
3150
3158
|
var documentName = DOCUMENT_NAME.QUOTE;
|
|
3151
|
-
styled__default["default"].div(templateObject_1$
|
|
3159
|
+
styled__default["default"].div(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
|
|
3152
3160
|
function Quote(_a) {
|
|
3153
3161
|
var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, onInvoiceDownloadError = _a.onInvoiceDownloadError, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, className = _a.className, _c = _a.hideDownloadButton, hideDownloadButton = _c === void 0 ? false : _c;
|
|
3154
3162
|
return (jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(InvoiceQuoteContext.Provider, __assign({ value: {
|
|
@@ -3216,7 +3224,7 @@ function ActualQuote(_a) {
|
|
|
3216
3224
|
documentName: documentName,
|
|
3217
3225
|
}) }), jsxRuntime.jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedQuote.vendorName) })] }), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-4 ".concat(isMobile ? "w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
|
|
3218
3226
|
color: entityBranding.secondaryColor,
|
|
3219
|
-
} }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$
|
|
3227
|
+
} }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsxRuntime.jsx(Text$b, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(common.formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxRuntime.jsxs("div", __assign({ className: isMobile
|
|
3220
3228
|
? "flex w-full justify-end gap-2"
|
|
3221
3229
|
: "flex items-center justify-end gap-2" }, { children: [!isMobile && !hideDownloadButton ? (jsxRuntime.jsx(antd.Button, __assign({ icon: jsxRuntime.jsx(DownloadOutlined$1, {}), onClick: function () {
|
|
3222
3230
|
return downloadFile(apiHost + "/api/pdf/quote", token);
|
|
@@ -3224,7 +3232,7 @@ function ActualQuote(_a) {
|
|
|
3224
3232
|
return (jsxRuntime.jsx(antd.Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
|
|
3225
3233
|
}) }))) : null }))] })), jsxRuntime.jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept }), jsxRuntime.jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
|
|
3226
3234
|
}
|
|
3227
|
-
var templateObject_1$
|
|
3235
|
+
var templateObject_1$3;
|
|
3228
3236
|
|
|
3229
3237
|
var QUOTES_QUERY = function (filter) { return "\n query quotes {\n quotes ".concat(filter ? "(".concat(filter, ")") : "", " {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n nodes {\n id\n name\n account {\n name\n id\n }\n applicationDate\n state\n createdAt\n expiresAt\n currencyId\n amount\n number\n }\n }\n }"); };
|
|
3230
3238
|
var getQuotes = function (_a) {
|
|
@@ -3247,7 +3255,7 @@ var getQuotes = function (_a) {
|
|
|
3247
3255
|
});
|
|
3248
3256
|
};
|
|
3249
3257
|
|
|
3250
|
-
var transactionMutation = function (filter) { return "\nquery transactions {\n transactions ".concat(filter ? "(".concat(filter, ")") : "", " {\n nodes {\n amount\n createdAt\n currencyId\n description\n id\n kind\n state\n transactionableId\n transactionable {\n ...on Payment { amount }\n ...on Invoice { amount number }\n }\n }\n }\n}"); };
|
|
3258
|
+
var transactionMutation = function (filter) { return "\nquery transactions {\n transactions ".concat(filter ? "(".concat(filter, ")") : "", " {\n nodes {\n amount\n createdAt\n currencyId\n description\n id\n kind\n state\n transactionableId\n transactionable {\n ...on Payment { amount }\n ...on Invoice { amount number dueAt issuedAt isLegacy }\n ...on CreditNote { amount number dueAt issuedAt }\n }\n }\n }\n}"); };
|
|
3251
3259
|
var getTransactions = function (filter, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3252
3260
|
var response, _a, data, errors;
|
|
3253
3261
|
return __generator(this, function (_b) {
|
|
@@ -3311,10 +3319,10 @@ var getColor = function (state) {
|
|
|
3311
3319
|
}
|
|
3312
3320
|
};
|
|
3313
3321
|
|
|
3314
|
-
var Text$
|
|
3322
|
+
var Text$a = antd.Typography.Text;
|
|
3315
3323
|
var TransactionDate = function (_a) {
|
|
3316
3324
|
var date = _a.date;
|
|
3317
|
-
return jsxRuntime.jsx(Text$
|
|
3325
|
+
return jsxRuntime.jsx(Text$a, __assign({ className: "text-sm" }, { children: common.formatDate(date) }));
|
|
3318
3326
|
};
|
|
3319
3327
|
|
|
3320
3328
|
// TODO: delete
|
|
@@ -3345,13 +3353,13 @@ var TransactionGridCell = styled__default["default"].div.withConfig({
|
|
|
3345
3353
|
shouldForwardProp: function (prop) {
|
|
3346
3354
|
return !["gridColumn", "padding", "right"].includes(prop);
|
|
3347
3355
|
},
|
|
3348
|
-
})(templateObject_1$
|
|
3349
|
-
var templateObject_1$
|
|
3356
|
+
})(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: ", ";\n\n text-align: ", ";\n white-space: nowrap;\n font-size: 14px;\n color: ", ";\n\n background-color: inherit;\n\n padding: 1rem;\n min-width: 48px;\n"], ["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: ", ";\n\n text-align: ", ";\n white-space: nowrap;\n font-size: 14px;\n color: ", ";\n\n background-color: inherit;\n\n padding: 1rem;\n min-width: 48px;\n"])), function (props) { return props.gridColumn && "grid-column: ".concat(props.gridColumn, ";"); }, function (props) { return (props.right ? "flex-end" : "flex-start"); }, function (props) { return (props.right ? "right" : "left"); }, common.SLATE_600);
|
|
3357
|
+
var templateObject_1$2;
|
|
3350
3358
|
|
|
3351
|
-
var Text$
|
|
3359
|
+
var Text$9 = antd.Typography.Text;
|
|
3352
3360
|
var TransactionsEmptyState = function () {
|
|
3353
3361
|
var noTransactionsMessage = React.useContext(TransactionsListContext).noTransactionsMessage;
|
|
3354
|
-
return (jsxRuntime.jsx(Text$
|
|
3362
|
+
return (jsxRuntime.jsx(Text$9, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
|
|
3355
3363
|
};
|
|
3356
3364
|
|
|
3357
3365
|
var isInvoice = function (transaction) {
|
|
@@ -3368,11 +3376,27 @@ var TransactionRowTitle = function (_a) {
|
|
|
3368
3376
|
return (jsxRuntime.jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
|
|
3369
3377
|
};
|
|
3370
3378
|
|
|
3371
|
-
|
|
3379
|
+
function transactionDateToDisplay(transaction, transactionDateType) {
|
|
3380
|
+
var _a, _b;
|
|
3381
|
+
if (transaction.kind === "PAYMENT") {
|
|
3382
|
+
return transaction.createdAt;
|
|
3383
|
+
}
|
|
3384
|
+
else if (transactionDateType === "dueAt") {
|
|
3385
|
+
return (_a = transaction.transactionable) === null || _a === void 0 ? void 0 : _a.dueAt;
|
|
3386
|
+
}
|
|
3387
|
+
else if (transactionDateType === "issuedAt") {
|
|
3388
|
+
return (_b = transaction.transactionable) === null || _b === void 0 ? void 0 : _b.issuedAt;
|
|
3389
|
+
}
|
|
3390
|
+
else {
|
|
3391
|
+
return transaction.createdAt;
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
var Text$8 = antd.Typography.Text;
|
|
3372
3396
|
var TransactionsListDesktop = function (_a) {
|
|
3373
3397
|
var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
|
|
3374
|
-
var
|
|
3375
|
-
var
|
|
3398
|
+
var _b = React.useContext(TransactionsListContext), columns = _b.columns, transactionDateType = _b.transactionDateType;
|
|
3399
|
+
var _c = React.useContext(BunnyContext), apiHost = _c.apiHost, darkMode = _c.darkMode;
|
|
3376
3400
|
var token = useToken();
|
|
3377
3401
|
var showAmount = columns.includes("amount");
|
|
3378
3402
|
var showDateAndTitle = columns.includes("date-and-title");
|
|
@@ -3380,24 +3404,27 @@ var TransactionsListDesktop = function (_a) {
|
|
|
3380
3404
|
var showState = columns.includes("state");
|
|
3381
3405
|
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
3382
3406
|
return jsxRuntime.jsx(TransactionsEmptyState, {});
|
|
3383
|
-
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3407
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3408
|
+
var _a;
|
|
3409
|
+
var isClickable = onTransactionClick !== undefined;
|
|
3410
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
3411
|
+
onTransactionClick === null || onTransactionClick === void 0 ? void 0 : onTransactionClick(transaction);
|
|
3412
|
+
}, style: {
|
|
3413
|
+
backgroundColor: index % 2 === 0
|
|
3414
|
+
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
3415
|
+
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
3416
|
+
} }, { children: [!showDateAndTitle &&
|
|
3417
|
+
!showState &&
|
|
3418
|
+
!showAmount &&
|
|
3419
|
+
!showDownload && (jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsx(Text$8, { children: "No columns selected" }) })), showDateAndTitle && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TransactionGridCell, __assign({ right: false }, { children: jsxRuntime.jsx(TransactionDate, { date: transactionDateToDisplay(transaction, transactionDateType) }) })), jsxRuntime.jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsxRuntime.jsx(Text$8, { children: lodash.capitalize(transaction.kind.toLowerCase()) }), jsxRuntime.jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })), showState ? (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(StateTag, { state: transaction.state }) }))) : null, showAmount && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(Text$8, { children: common.formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
|
|
3420
|
+
}) }));
|
|
3394
3421
|
};
|
|
3395
3422
|
|
|
3396
|
-
var Text$
|
|
3423
|
+
var Text$7 = antd.Typography.Text;
|
|
3397
3424
|
var TransactionsListMobile = function (_a) {
|
|
3398
3425
|
var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
|
|
3399
|
-
var
|
|
3400
|
-
var
|
|
3426
|
+
var _b = React.useContext(TransactionsListContext), columns = _b.columns, transactionDateType = _b.transactionDateType;
|
|
3427
|
+
var _c = React.useContext(BunnyContext), apiHost = _c.apiHost, darkMode = _c.darkMode;
|
|
3401
3428
|
var token = useToken();
|
|
3402
3429
|
var showAmount = columns.includes("amount");
|
|
3403
3430
|
var showDateAndTitle = columns.includes("date-and-title");
|
|
@@ -3405,19 +3432,20 @@ var TransactionsListMobile = function (_a) {
|
|
|
3405
3432
|
var showState = columns.includes("state");
|
|
3406
3433
|
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
3407
3434
|
return jsxRuntime.jsx(TransactionsEmptyState, {});
|
|
3408
|
-
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3435
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3436
|
+
var isClickable = transaction.kind === "INVOICE";
|
|
3437
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
3438
|
+
onTransactionClick(transaction);
|
|
3439
|
+
}, style: {
|
|
3440
|
+
backgroundColor: index % 2 === 0
|
|
3441
|
+
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
3442
|
+
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
3443
|
+
} }, { children: [jsxRuntime.jsx(TransactionGridCell, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Text$7, { children: lodash.capitalize(transaction.kind.toLowerCase()) }), jsxRuntime.jsx(TransactionRowTitle, { transaction: transaction })] })), showState && jsxRuntime.jsx(StateTag, { state: transaction.state })] })), jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxRuntime.jsx(TransactionDate, { date: transactionDateToDisplay(transaction, transactionDateType) })), showAmount && showDateAndTitle && jsxRuntime.jsx(Text$7, { children: "\u00B7" }), showAmount && (jsxRuntime.jsx(Text$7, { children: common.formatCurrency(transaction.transactionable.amount ||
|
|
3444
|
+
transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsxRuntime.jsx(TransactionGridCell, __assign({ right: true }, { children: jsxRuntime.jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })))] }), index));
|
|
3445
|
+
}) }));
|
|
3418
3446
|
};
|
|
3419
3447
|
|
|
3420
|
-
var Text$
|
|
3448
|
+
var Text$6 = antd.Typography.Text;
|
|
3421
3449
|
var DISPLAY_WIDTH = 1200;
|
|
3422
3450
|
function Transactions(_a) {
|
|
3423
3451
|
var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.title, title = _d === void 0 ? "Past transactions" : _d, _e = _a.columns, columns = _e === void 0 ? ["date-and-title", "state", "amount", "download"] : _e, className = _a.className, _f = _a.shadow, shadow = _f === void 0 ? "shadow-md" : _f, searchBarClassName = _a.searchBarClassName, _g = _a.useModal, useModal = _g === void 0 ? false : _g, onTransactionClick = _a.onTransactionClick, _h = _a.suppressTransactionDisplay, suppressTransactionDisplay = _h === void 0 ? false : _h, _j = _a.kindsToShow, kindsToShow = _j === void 0 ? [
|
|
@@ -3427,7 +3455,7 @@ function Transactions(_a) {
|
|
|
3427
3455
|
common.TransactionKind.WRITE_OFF,
|
|
3428
3456
|
] : _j, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId, filterTransactions = _a.filterTransactions, _k = _a.sortTransactions, sortTransactions = _k === void 0 ? function (a, b) {
|
|
3429
3457
|
return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
|
3430
|
-
} : _k;
|
|
3458
|
+
} : _k, _l = _a.transactionDateType, transactionDateType = _l === void 0 ? "createdAt" : _l;
|
|
3431
3459
|
var contextValues = {
|
|
3432
3460
|
showSearchBar: showSearchBar,
|
|
3433
3461
|
showTitle: showTitle,
|
|
@@ -3447,11 +3475,12 @@ function Transactions(_a) {
|
|
|
3447
3475
|
entityId: entityId,
|
|
3448
3476
|
filterTransactions: filterTransactions,
|
|
3449
3477
|
sortTransactions: sortTransactions,
|
|
3478
|
+
transactionDateType: transactionDateType,
|
|
3450
3479
|
};
|
|
3451
3480
|
var apiHost = React.useContext(BunnyContext).apiHost;
|
|
3452
3481
|
var token = useToken();
|
|
3453
3482
|
// Local state
|
|
3454
|
-
var
|
|
3483
|
+
var _m = React.useState(""), search = _m[0], setSearch = _m[1];
|
|
3455
3484
|
var filterValue = filter ||
|
|
3456
3485
|
(search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
|
|
3457
3486
|
// Queries
|
|
@@ -3465,7 +3494,7 @@ function Transactions(_a) {
|
|
|
3465
3494
|
function TransactionsDisplay(_a) {
|
|
3466
3495
|
var _b, _c;
|
|
3467
3496
|
var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search;
|
|
3468
|
-
var _d = React.useContext(TransactionsListContext), showSearchBar = _d.showSearchBar, showTitle = _d.showTitle, title = _d.title, transactionComponent = _d.transactionComponent, useModal = _d.useModal, suppressTransactionDisplay = _d.suppressTransactionDisplay, className = _d.className, shadow = _d.shadow, searchBarClassName = _d.searchBarClassName, style = _d.style, onTransactionClick = _d.onTransactionClick, entityId = _d.entityId, onTransactionDisplayClose = _d.onTransactionDisplayClose, kindsToShow = _d.kindsToShow, filterTransactions = _d.filterTransactions, sortTransactions = _d.sortTransactions;
|
|
3497
|
+
var _d = React.useContext(TransactionsListContext), showSearchBar = _d.showSearchBar, showTitle = _d.showTitle, title = _d.title, transactionComponent = _d.transactionComponent, useModal = _d.useModal, suppressTransactionDisplay = _d.suppressTransactionDisplay, className = _d.className, shadow = _d.shadow, searchBarClassName = _d.searchBarClassName, style = _d.style, onTransactionClick = _d.onTransactionClick, entityId = _d.entityId, onTransactionDisplayClose = _d.onTransactionDisplayClose, kindsToShow = _d.kindsToShow, filterTransactions = _d.filterTransactions, sortTransactions = _d.sortTransactions; _d.transactionDateType;
|
|
3469
3498
|
var columns = React.useContext(TransactionsListContext).columns;
|
|
3470
3499
|
var darkMode = React.useContext(BunnyContext).darkMode;
|
|
3471
3500
|
var secondaryColor = React.useContext(BrandContext).secondaryColor;
|
|
@@ -3526,7 +3555,7 @@ function TransactionsDisplay(_a) {
|
|
|
3526
3555
|
onTransactionDisplayClose === null || onTransactionDisplayClose === void 0 ? void 0 : onTransactionDisplayClose(selectedTransaction);
|
|
3527
3556
|
setDrawerOpen(false);
|
|
3528
3557
|
}
|
|
3529
|
-
return (jsxRuntime.jsxs("div", __assign({ style: style }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsxRuntime.jsx(Text$
|
|
3558
|
+
return (jsxRuntime.jsxs("div", __assign({ style: style }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsxRuntime.jsx(Text$6, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title }))) : (jsxRuntime.jsx("div", {}) // Empty div so justify-between works
|
|
3530
3559
|
), showSearchBar && (jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "") }, { children: jsxRuntime.jsx(antd.Input, { className: searchBarClassName
|
|
3531
3560
|
? searchBarClassName
|
|
3532
3561
|
: "border border-slate-200", onChange: function (e) {
|
|
@@ -3539,13 +3568,7 @@ function TransactionsDisplay(_a) {
|
|
|
3539
3568
|
}, value: search }) })))] }))) : null, jsxRuntime.jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat(shadow), style: {
|
|
3540
3569
|
gridTemplateColumns: gridTemplateColumns(),
|
|
3541
3570
|
backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
|
|
3542
|
-
} }, { children: isMobile ? (jsxRuntime.jsx(jsxRuntime.
|
|
3543
|
-
transactions: updatedTransactions,
|
|
3544
|
-
onTransactionClick: handleTransactionClick,
|
|
3545
|
-
}) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: TransactionsListDesktop({
|
|
3546
|
-
transactions: updatedTransactions,
|
|
3547
|
-
onTransactionClick: handleTransactionClick,
|
|
3548
|
-
}) })) }))] })), useModal ? (jsxRuntime.jsx(antd.Modal, __assign({ title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsxRuntime.jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsxRuntime.jsx(antd.Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsxRuntime.jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxRuntime.jsxs(antd.Card, __assign({ className: "shadow-md" }, { children: [jsxRuntime.jsx(antd.Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Amount:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: common.formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Description:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Kind:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "State:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
|
|
3571
|
+
} }, { children: isMobile ? (jsxRuntime.jsx(TransactionsListMobile, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) : (jsxRuntime.jsx(TransactionsListDesktop, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) }))] })), useModal ? (jsxRuntime.jsx(antd.Modal, __assign({ title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsxRuntime.jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsxRuntime.jsx(antd.Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsxRuntime.jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxRuntime.jsxs(antd.Card, __assign({ className: "shadow-md" }, { children: [jsxRuntime.jsx(antd.Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Amount:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: common.formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Description:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Kind:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "State:" }), " ", jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
|
|
3549
3572
|
}
|
|
3550
3573
|
|
|
3551
3574
|
function Quotes(_a) {
|
|
@@ -3578,6 +3601,7 @@ function Quotes(_a) {
|
|
|
3578
3601
|
sortTransactions: sort,
|
|
3579
3602
|
downloadTransactionLink: function (id) { return "".concat(apiHost, "/api/pdf/quote/").concat(id); },
|
|
3580
3603
|
entityId: entityId,
|
|
3604
|
+
transactionDateType: "createdAt", // Required for the transactions list, but doesn't affect quotes
|
|
3581
3605
|
};
|
|
3582
3606
|
function quoteStateRenderer(state) {
|
|
3583
3607
|
var getColor = function (state) {
|
|
@@ -3643,10 +3667,10 @@ function QuotesWrapper() {
|
|
|
3643
3667
|
return (jsxRuntime.jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
|
|
3644
3668
|
}
|
|
3645
3669
|
|
|
3646
|
-
var Text$
|
|
3670
|
+
var Text$5 = antd.Typography.Text;
|
|
3647
3671
|
var DrawerHeader = function (_a) {
|
|
3648
3672
|
var description = _a.description, onClose = _a.onClose, title = _a.title;
|
|
3649
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsxRuntime.jsx(Text$
|
|
3673
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsxRuntime.jsx(Text$5, __assign({ className: "text-xl", style: { fontWeight: 400 } }, { children: title })), jsxRuntime.jsx("button", __assign({ onClick: onClose, className: "ant-drawer-close" }, { children: jsxRuntime.jsx(CloseOutlined$1, {}) }))] })), description && jsxRuntime.jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
|
|
3650
3674
|
};
|
|
3651
3675
|
|
|
3652
3676
|
var PaymentMethod = function (_a) {
|
|
@@ -3672,7 +3696,16 @@ var PaymentMethod = function (_a) {
|
|
|
3672
3696
|
};
|
|
3673
3697
|
if (data === undefined)
|
|
3674
3698
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
3675
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "".concat(className) }, { children: [data ? (jsxRuntime.jsx(CreditCard, { onClickRemove: function () { return
|
|
3699
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "".concat(className) }, { children: [data ? (jsxRuntime.jsx(CreditCard, { onClickRemove: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3700
|
+
return __generator(this, function (_a) {
|
|
3701
|
+
switch (_a.label) {
|
|
3702
|
+
case 0: return [4 /*yield*/, onClickRemove(data)];
|
|
3703
|
+
case 1:
|
|
3704
|
+
_a.sent();
|
|
3705
|
+
return [2 /*return*/];
|
|
3706
|
+
}
|
|
3707
|
+
});
|
|
3708
|
+
}); }, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data, shadow: shadow, cardEnabled: cardEnabled })) : (jsxRuntime.jsx(EmptyCard, { onClick: function () { return setShowModal(true); }, shadow: shadow, cardEnabled: cardEnabled })), jsxRuntime.jsx(antd.Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
|
|
3676
3709
|
body: isMobile
|
|
3677
3710
|
? {
|
|
3678
3711
|
padding: "1rem 0 0",
|
|
@@ -3718,7 +3751,7 @@ var quoteRecalculateTaxes = function (_a) {
|
|
|
3718
3751
|
});
|
|
3719
3752
|
};
|
|
3720
3753
|
|
|
3721
|
-
var MUTATION$
|
|
3754
|
+
var MUTATION$5 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
|
|
3722
3755
|
var getTaxationRequiredAccountFields = function (_a) {
|
|
3723
3756
|
var token = _a.token, apiHost = _a.apiHost;
|
|
3724
3757
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3727,7 +3760,7 @@ var getTaxationRequiredAccountFields = function (_a) {
|
|
|
3727
3760
|
return __generator(this, function (_d) {
|
|
3728
3761
|
switch (_d.label) {
|
|
3729
3762
|
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
3730
|
-
query: MUTATION$
|
|
3763
|
+
query: MUTATION$5,
|
|
3731
3764
|
token: token,
|
|
3732
3765
|
apiHost: apiHost,
|
|
3733
3766
|
})];
|
|
@@ -3752,7 +3785,7 @@ var useHasTaxPlugin = function (_a) {
|
|
|
3752
3785
|
return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
|
|
3753
3786
|
};
|
|
3754
3787
|
|
|
3755
|
-
var MUTATION$
|
|
3788
|
+
var MUTATION$4 = "\nmutation accountUpdate(\n $id: ID!,\n $attributes: AccountAttributes!) {\n accountUpdate(\n id: $id,\n attributes: $attributes\n ) {\n account {\n id\n billingCountry\n billingState\n billingStreet\n billingCity\n billingZip\n name\n }\n errors\n }\n }\n";
|
|
3756
3789
|
var accountUpdate = function (_a) {
|
|
3757
3790
|
var accountId = _a.accountId, attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
|
|
3758
3791
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3763,7 +3796,7 @@ var accountUpdate = function (_a) {
|
|
|
3763
3796
|
case 0:
|
|
3764
3797
|
vars = { id: accountId, attributes: attributes };
|
|
3765
3798
|
return [4 /*yield*/, common.gqlRequest({
|
|
3766
|
-
query: MUTATION$
|
|
3799
|
+
query: MUTATION$4,
|
|
3767
3800
|
token: token,
|
|
3768
3801
|
vars: vars,
|
|
3769
3802
|
apiHost: apiHost,
|
|
@@ -3944,7 +3977,7 @@ var Checkout = function (_a) {
|
|
|
3944
3977
|
}, onPaymentSuccess: onSuccess, graphQLClient: graphQLClient }))] }))] })) })));
|
|
3945
3978
|
};
|
|
3946
3979
|
|
|
3947
|
-
var MUTATION$
|
|
3980
|
+
var MUTATION$3 = function () { return "\nmutation AccountSignup (\n $entityId: ID!,\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!\n) {\n accountSignup(\n entityId: $entityId,\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId\n ) {\n errors\n quote {\n acceptedByName\n acceptedByTitle\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}"; };
|
|
3948
3981
|
var accountSignup = function (_a) {
|
|
3949
3982
|
var token = _a.token, apiHost = _a.apiHost, entityId = _a.entityId, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode;
|
|
3950
3983
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3963,7 +3996,7 @@ var accountSignup = function (_a) {
|
|
|
3963
3996
|
priceListCode: priceListCode,
|
|
3964
3997
|
};
|
|
3965
3998
|
return [4 /*yield*/, gqlRequest({
|
|
3966
|
-
query: MUTATION$
|
|
3999
|
+
query: MUTATION$3(),
|
|
3967
4000
|
token: token,
|
|
3968
4001
|
vars: vars,
|
|
3969
4002
|
apiHost: apiHost,
|
|
@@ -3979,7 +4012,7 @@ var accountSignup = function (_a) {
|
|
|
3979
4012
|
});
|
|
3980
4013
|
};
|
|
3981
4014
|
|
|
3982
|
-
var MUTATION$
|
|
4015
|
+
var MUTATION$2 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $entityId: ID!,\n $priceListCode: String!\n) {\n quoteAccountSignup(\n entityId: $entityId,\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact\n ) {\n account {\n id\n }\n quote {\n acceptedByName\n acceptedByTitle\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}"; };
|
|
3983
4016
|
var quoteAccountSignup = function (_a) {
|
|
3984
4017
|
var token = _a.token, apiHost = _a.apiHost, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
|
|
3985
4018
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3995,7 +4028,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3995
4028
|
billingContact: billingContact,
|
|
3996
4029
|
};
|
|
3997
4030
|
return [4 /*yield*/, gqlRequest({
|
|
3998
|
-
query: MUTATION$
|
|
4031
|
+
query: MUTATION$2(),
|
|
3999
4032
|
token: token,
|
|
4000
4033
|
vars: vars,
|
|
4001
4034
|
apiHost: apiHost,
|
|
@@ -4011,7 +4044,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
4011
4044
|
});
|
|
4012
4045
|
};
|
|
4013
4046
|
|
|
4014
|
-
var MUTATION$
|
|
4047
|
+
var MUTATION$1 = function () { return "\nquery PriceList($code: String!) {\n priceList (code: $code) {\n basePrice\n code\n createdAt\n currencyId\n id\n isVisible\n name\n periodMonths\n planId\n priceDescription\n productId\n sku\n trialAllowed\n trialLengthDays\n updatedAt\n }\n}"; };
|
|
4015
4048
|
var getPriceList = function (_a) {
|
|
4016
4049
|
var token = _a.token, code = _a.code, apiHost = _a.apiHost;
|
|
4017
4050
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -4019,7 +4052,7 @@ var getPriceList = function (_a) {
|
|
|
4019
4052
|
return __generator(this, function (_b) {
|
|
4020
4053
|
switch (_b.label) {
|
|
4021
4054
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
4022
|
-
query: MUTATION$
|
|
4055
|
+
query: MUTATION$1(),
|
|
4023
4056
|
token: token,
|
|
4024
4057
|
vars: { code: code },
|
|
4025
4058
|
apiHost: apiHost,
|
|
@@ -4053,19 +4086,19 @@ function InitialSignupForm(_a) {
|
|
|
4053
4086
|
] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Account name" }) }))] })), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
|
|
4054
4087
|
}
|
|
4055
4088
|
|
|
4056
|
-
var Title = antd.Typography.Title, Text$
|
|
4089
|
+
var Title = antd.Typography.Title, Text$4 = antd.Typography.Text;
|
|
4057
4090
|
function PaymentSuccessDisplay(_a) {
|
|
4058
4091
|
var amountPaid = _a.amountPaid, className = _a.className, companyName = _a.companyName, returnUrl = _a.returnUrl, style = _a.style;
|
|
4059
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsxRuntime.jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxRuntime.jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", common.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxRuntime.jsxs(Text$
|
|
4092
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsxRuntime.jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxRuntime.jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", common.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxRuntime.jsxs(Text$4, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
|
|
4060
4093
|
}
|
|
4061
4094
|
|
|
4062
|
-
var Text$
|
|
4095
|
+
var Text$3 = antd.Typography.Text;
|
|
4063
4096
|
function PriceListDisplay(_a) {
|
|
4064
4097
|
var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
|
|
4065
4098
|
if (!priceListData)
|
|
4066
4099
|
return null;
|
|
4067
4100
|
console.log("topNavImageUrl", topNavImageUrl);
|
|
4068
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsxRuntime.jsx(antd.Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsx(Text$
|
|
4101
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsxRuntime.jsx(antd.Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsx(Text$3, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxRuntime.jsxs(Text$3, __assign({ className: "font-bold text-xl" }, { children: [common.formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), priceListData.trialAllowed ? (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxRuntime.jsxs(Text$3, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsxRuntime.jsx(Text$3, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))) : null] })) })) }));
|
|
4069
4102
|
}
|
|
4070
4103
|
|
|
4071
4104
|
var showErrorNotification = common.useErrorNotification();
|
|
@@ -4181,60 +4214,9 @@ function Signup(_a) {
|
|
|
4181
4214
|
: "w-1/2 items-center justify-center my-12") }, { children: jsxRuntime.jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2") }, { children: jsxRuntime.jsx(PaymentForms, { entityId: entityId, quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction }) })) }))] }))) })));
|
|
4182
4215
|
}
|
|
4183
4216
|
|
|
4184
|
-
|
|
4185
|
-
var PLAN_CHANGE_OPTIONS_QUERY = "\n query planChangeOptions($subscriptionId: ID) {\n planChangeOptions(subscriptionId: $subscriptionId) {\n products {\n everythingInPlus\n id\n name\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n plans {\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 priceLists {\n basePrice\n id\n currencyId\n periodMonths\n plan {\n id\n position\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 productId\n }\n }\n }";
|
|
4186
|
-
var getPlanChangeOptions = function (_a) {
|
|
4187
|
-
var isInPreviewMode = _a.isInPreviewMode, token = _a.token, upgradingSubscription = _a.upgradingSubscription, apiHost = _a.apiHost;
|
|
4188
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4189
|
-
var response, planChangeOptions;
|
|
4190
|
-
return __generator(this, function (_b) {
|
|
4191
|
-
switch (_b.label) {
|
|
4192
|
-
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
4193
|
-
isInPreviewMode: isInPreviewMode,
|
|
4194
|
-
query: PLAN_CHANGE_OPTIONS_QUERY,
|
|
4195
|
-
vars: { subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id },
|
|
4196
|
-
token: token,
|
|
4197
|
-
apiHost: apiHost,
|
|
4198
|
-
})];
|
|
4199
|
-
case 1:
|
|
4200
|
-
response = _b.sent();
|
|
4201
|
-
planChangeOptions = response.planChangeOptions;
|
|
4202
|
-
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.errors)
|
|
4203
|
-
throw planChangeOptions.errors;
|
|
4204
|
-
// Sort planChangeOptions.plans by position
|
|
4205
|
-
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.plans) {
|
|
4206
|
-
planChangeOptions.plans.sort(function (a, b) { return a.position - b.position; });
|
|
4207
|
-
}
|
|
4208
|
-
return [2 /*return*/, planChangeOptions];
|
|
4209
|
-
}
|
|
4210
|
-
});
|
|
4211
|
-
});
|
|
4212
|
-
};
|
|
4213
|
-
|
|
4214
|
-
var QUOTE_QUERY = function () { return "\n query quote($id: ID) {\n quote(id: $id) {\n accountId\n amount\n amountDue\n smallUnitAmountDue\n currencyId\n formattedQuote {\n html\n }\n id\n payableId\n periodAmount\n subtotal\n taxAmount\n amountsByPeriod {\n amount\n startDate\n }\n quoteChanges {\n currencyId\n id\n charges {\n amountsByPeriod {\n amount\n startDate\n }\n amount\n billingPeriod\n currencyId\n feature {\n unitName\n }\n id\n name\n priceListCharge {\n id\n }\n quantity\n }\n priceList {\n id\n plan {\n name\n }\n product {\n name\n }\n }\n\n }\n }\n }"; };
|
|
4215
|
-
var getQuote = function (_a) {
|
|
4216
|
-
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
4217
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4218
|
-
var response;
|
|
4219
|
-
return __generator(this, function (_b) {
|
|
4220
|
-
switch (_b.label) {
|
|
4221
|
-
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
4222
|
-
query: QUOTE_QUERY(),
|
|
4223
|
-
token: token,
|
|
4224
|
-
vars: { id: id },
|
|
4225
|
-
apiHost: apiHost,
|
|
4226
|
-
})];
|
|
4227
|
-
case 1:
|
|
4228
|
-
response = _b.sent();
|
|
4229
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quote];
|
|
4230
|
-
}
|
|
4231
|
-
});
|
|
4232
|
-
});
|
|
4233
|
-
};
|
|
4234
|
-
|
|
4235
|
-
var SUBSCRIPTIONS_QUERY = "query subscriptions {\n subscriptions {\n nodes {\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList { id periodMonths }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n charges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n }\n amount\n billingPeriod\n chargeType\n discount\n discountedPrice\n endDate\n expired\n feature { name }\n id\n isRamp\n name\n periodPrice\n price\n priceDecimals\n priceListChargeId\n priceTiers { starts price }\n pricingModel\n quantity\n selfServiceQuantity\n startDate\n trial\n }\n }\n }\n }";
|
|
4217
|
+
var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n nodes {\n cancellationDate\n currencyId\n endDate\n evergreen\n id\n period\n plan { id name selfServiceBuy selfServiceCancel selfServiceRenew }\n priceList { id periodMonths }\n product { id name showProductNameOnLineItem }\n startDate\n state\n trialEndDate\n trialPeriod\n trialStartDate\n charges {\n priceListCharge {\n priceListChargeTiers {\n price\n starts\n }\n }\n amount\n billingPeriod\n chargeType\n discount\n discountedPrice\n endDate\n expired\n feature { name }\n id\n isRamp\n kind\n name\n periodPrice\n price\n priceDecimals\n priceListChargeId\n priceTiers { starts price }\n pricingModel\n quantity\n selfServiceQuantity\n startDate\n trial\n }\n }\n }\n }";
|
|
4236
4218
|
var getSubscriptions = function (_a) {
|
|
4237
|
-
var
|
|
4219
|
+
var apiHost = _a.apiHost, entityId = _a.entityId, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
4238
4220
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
4239
4221
|
var response;
|
|
4240
4222
|
var _b;
|
|
@@ -4260,44 +4242,56 @@ var useSubscriptions = function (_a) {
|
|
|
4260
4242
|
return React.useMemo(function () {
|
|
4261
4243
|
var combinedSubscriptions = data === null || data === void 0 ? void 0 : data.map(function (subscription) {
|
|
4262
4244
|
var _a;
|
|
4263
|
-
var
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4245
|
+
var orderedSubscriptionCharges = subscription.charges.sort(function (a, b) {
|
|
4246
|
+
if (a.priceListChargeId !== b.priceListChargeId) {
|
|
4247
|
+
return a.priceListChargeId.localeCompare(b.priceListChargeId);
|
|
4248
|
+
}
|
|
4249
|
+
if (a.kind === common.SubscriptionChargeKind.DISCOUNT &&
|
|
4250
|
+
b.kind !== common.SubscriptionChargeKind.DISCOUNT) {
|
|
4251
|
+
return 1;
|
|
4252
|
+
}
|
|
4253
|
+
if (a.kind !== common.SubscriptionChargeKind.DISCOUNT &&
|
|
4254
|
+
b.kind === common.SubscriptionChargeKind.DISCOUNT) {
|
|
4255
|
+
return -1;
|
|
4256
|
+
}
|
|
4257
|
+
return (a.endDate.localeCompare(b.endDate) ||
|
|
4258
|
+
a.startDate.localeCompare(b.startDate));
|
|
4268
4259
|
});
|
|
4269
|
-
var isTrial = ((_a =
|
|
4260
|
+
var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
4270
4261
|
var combinedSubscriptionCharges = [];
|
|
4271
4262
|
var aggregationCharge;
|
|
4272
4263
|
for (var index = 0; index < orderedSubscriptionCharges.length; index++) {
|
|
4273
4264
|
var charge = orderedSubscriptionCharges[index];
|
|
4274
4265
|
var nextCharge = orderedSubscriptionCharges[index + 1];
|
|
4275
|
-
// Initialize aggregationCharge if it is not already set
|
|
4276
4266
|
if (!aggregationCharge)
|
|
4277
4267
|
aggregationCharge = charge;
|
|
4278
|
-
// If the next charge
|
|
4268
|
+
// If the next charge is the same priceListChargeId and endDate, aggregate the quantities
|
|
4279
4269
|
if (nextCharge &&
|
|
4280
4270
|
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
4281
|
-
charge.endDate === nextCharge.endDate
|
|
4271
|
+
charge.endDate === nextCharge.endDate &&
|
|
4272
|
+
charge.startDate === nextCharge.startDate &&
|
|
4273
|
+
charge.kind === nextCharge.kind) {
|
|
4282
4274
|
aggregationCharge.quantity += nextCharge.quantity;
|
|
4275
|
+
// If the next charge is different, push the aggregationCharge to the combinedSubscriptionCharges
|
|
4283
4276
|
}
|
|
4284
|
-
// If the next charge exists, has the same priceListChargeId but different endDate, and matches the trial state, push the current aggregationCharge and reset it
|
|
4285
4277
|
else if (nextCharge &&
|
|
4286
4278
|
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
4287
|
-
charge.endDate !== nextCharge.endDate
|
|
4279
|
+
(charge.endDate !== nextCharge.endDate ||
|
|
4280
|
+
charge.startDate !== nextCharge.startDate) &&
|
|
4281
|
+
charge.kind === nextCharge.kind &&
|
|
4288
4282
|
(!isTrial || charge.trial) &&
|
|
4289
4283
|
(isTrial || !charge.trial)) {
|
|
4284
|
+
nextCharge.name = "";
|
|
4290
4285
|
combinedSubscriptionCharges.push(aggregationCharge);
|
|
4291
4286
|
aggregationCharge = undefined;
|
|
4292
4287
|
}
|
|
4293
|
-
// If the next charge does not match the above conditions, push the current aggregationCharge and reset it
|
|
4294
4288
|
else {
|
|
4295
4289
|
combinedSubscriptionCharges.push(aggregationCharge);
|
|
4296
4290
|
aggregationCharge = undefined;
|
|
4297
4291
|
}
|
|
4298
4292
|
}
|
|
4299
|
-
|
|
4300
|
-
return
|
|
4293
|
+
subscription.charges = combinedSubscriptionCharges;
|
|
4294
|
+
return subscription;
|
|
4301
4295
|
});
|
|
4302
4296
|
var subscriptionOrder = Object.values(common.SubscriptionState);
|
|
4303
4297
|
combinedSubscriptions === null || combinedSubscriptions === void 0 ? void 0 : combinedSubscriptions.sort(function (a, b) {
|
|
@@ -4312,38 +4306,6 @@ var ErrorView = function (_a) {
|
|
|
4312
4306
|
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full", style: { marginTop: "80px" } }, { children: [jsxRuntime.jsx("div", __assign({ style: { fontSize: "32px" } }, { children: message })), children] })));
|
|
4313
4307
|
};
|
|
4314
4308
|
|
|
4315
|
-
var Text$4 = antd.Typography.Text;
|
|
4316
|
-
var PageHeaderWithActions = function (_a) {
|
|
4317
|
-
var children = _a.children, title = _a.title, className = _a.className;
|
|
4318
|
-
var isMobile = common.useIsMobile();
|
|
4319
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex pb-4 shadow-padding-x ".concat(className, " ").concat(isMobile ? "flex-col gap-2" : "items-center justify-between h-8") }, { children: [jsxRuntime.jsx(PageSubTitle, { title: title }), children] })));
|
|
4320
|
-
};
|
|
4321
|
-
var PageSubTitle = function (_a) {
|
|
4322
|
-
var title = _a.title;
|
|
4323
|
-
var secondaryColor = React.useContext(BrandContext).secondaryColor;
|
|
4324
|
-
var darkMode = React.useContext(BunnyContext).darkMode;
|
|
4325
|
-
return (jsxRuntime.jsx(Text$4, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
|
|
4326
|
-
};
|
|
4327
|
-
|
|
4328
|
-
var Text$3 = antd.Typography.Text;
|
|
4329
|
-
var HideExpiredToggle = function (_a) {
|
|
4330
|
-
var hideExpired = _a.hideExpired, setHideExpired = _a.setHideExpired, subscriptions = _a.subscriptions;
|
|
4331
|
-
var isMobile = common.useIsMobile();
|
|
4332
|
-
var secondaryColor = React.useContext(BrandContext).secondaryColor;
|
|
4333
|
-
var hasExpiredOrCanceledSubscriptions = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
4334
|
-
var _a, _b;
|
|
4335
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
|
|
4336
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED;
|
|
4337
|
-
});
|
|
4338
|
-
if (!hasExpiredOrCanceledSubscriptions)
|
|
4339
|
-
return null;
|
|
4340
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-4 pl-4" }, { children: [!isMobile && jsxRuntime.jsx(antd.Divider, { className: "h-5", type: "vertical" }), jsxRuntime.jsx(StyledCheckbox, { children: jsxRuntime.jsx(antd.Checkbox, __assign({ checked: hideExpired, onChange: function (e) { return setHideExpired(e.target.checked); }, style: {
|
|
4341
|
-
color: secondaryColor,
|
|
4342
|
-
} }, { children: jsxRuntime.jsx(Text$3, { children: isMobile ? "Hide inactive" : "Hide inactive subscriptions" }) })) })] })));
|
|
4343
|
-
};
|
|
4344
|
-
var StyledCheckbox = styled__default["default"].div(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n .ant-checkbox-wrapper span {\n padding-inline-end: 0 !important;\n }\n"], ["\n .ant-checkbox-wrapper span {\n padding-inline-end: 0 !important;\n }\n"])));
|
|
4345
|
-
var templateObject_1$2;
|
|
4346
|
-
|
|
4347
4309
|
var SubscriptionState;
|
|
4348
4310
|
(function (SubscriptionState) {
|
|
4349
4311
|
SubscriptionState["ACTIVE"] = "ACTIVE";
|
|
@@ -4541,57 +4503,6 @@ var templateObject_1;
|
|
|
4541
4503
|
|
|
4542
4504
|
var SubscriptionsContext = React.createContext({});
|
|
4543
4505
|
|
|
4544
|
-
var MUTATION$1 = "\nmutation quoteSubscriptionReinstate($ids: [ID!]!) {\n quoteSubscriptionReinstate(ids: $ids) {\n quote {\n id\n uuid\n accountId\n dealId\n name\n amount\n taxAmount\n discount\n netPaymentDays\n acceptedByName\n acceptedByTitle\n state\n billingDay\n evergreen\n requiresApproval\n isPendingApprovalRequest\n poNumber\n kind\n currencyId\n ownerId\n contactId\n quoteChanges {\n id\n priceListId\n charges {\n id\n pricingModel\n chargeType\n billingPeriod\n price\n priceDecimals\n tieredAveragePrice\n quantity\n quantityMin\n quantityMax\n discount\n amount\n prorationRate\n name\n invoiceLineText\n createdAt\n updatedAt\n startDate\n endDate\n billingPeriodAmounts { id amount prorationRate }\n currencyId\n couponId\n feature { id name code isUnit unitName }\n priceTiers { starts price }\n }\n }\n expiresAt\n createdAt\n updatedAt\n startDate\n endDate\n invoiceUntil\n applicationDate\n applied\n endDateOptions {\n endDate\n label\n }\n invoiceUntilOptions {\n endDate\n label\n }\n notes\n message\n amountsByPeriod {\n id\n name\n amount\n }\n subtotal\n credits\n discountValue\n }\n }\n}\n";
|
|
4545
|
-
var getGuoteSubscriptionReinstate = function (_a) {
|
|
4546
|
-
var ids = _a.ids, token = _a.token, apiHost = _a.apiHost;
|
|
4547
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4548
|
-
var vars, response, _b, errors, quote;
|
|
4549
|
-
return __generator(this, function (_c) {
|
|
4550
|
-
switch (_c.label) {
|
|
4551
|
-
case 0:
|
|
4552
|
-
vars = { ids: ids };
|
|
4553
|
-
return [4 /*yield*/, common.gqlRequest({
|
|
4554
|
-
query: MUTATION$1,
|
|
4555
|
-
token: token,
|
|
4556
|
-
vars: vars,
|
|
4557
|
-
apiHost: apiHost,
|
|
4558
|
-
})];
|
|
4559
|
-
case 1:
|
|
4560
|
-
response = _c.sent();
|
|
4561
|
-
_b = response === null || response === void 0 ? void 0 : response.quoteSubscriptionReinstate, errors = _b.errors, quote = _b.quote;
|
|
4562
|
-
if (errors)
|
|
4563
|
-
throw errors;
|
|
4564
|
-
return [2 /*return*/, quote];
|
|
4565
|
-
}
|
|
4566
|
-
});
|
|
4567
|
-
});
|
|
4568
|
-
};
|
|
4569
|
-
|
|
4570
|
-
// import { EditingSubscriptionType } from "../../../features/quantityChangeDrawer/QuantityInput";
|
|
4571
|
-
var canShowQuantitiesInput = function (charge, subscription) {
|
|
4572
|
-
// Check if the subscription is active, pending, or in trial,
|
|
4573
|
-
// the pricing model is not flat,
|
|
4574
|
-
// and if it's not a trial, also check if the current charge is the last one in the subscription.
|
|
4575
|
-
var _a, _b, _c;
|
|
4576
|
-
var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.ACTIVE;
|
|
4577
|
-
var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.PENDING;
|
|
4578
|
-
var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
4579
|
-
var isFlatPricing = charge.pricingModel === "FLAT";
|
|
4580
|
-
var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
|
|
4581
|
-
!isFlatPricing &&
|
|
4582
|
-
charge.selfServiceQuantity &&
|
|
4583
|
-
!charge.expired;
|
|
4584
|
-
// Now you can use the value of shouldProcessCharge to determine whether to process the charge.
|
|
4585
|
-
return shouldProcessCharge;
|
|
4586
|
-
};
|
|
4587
|
-
var canShowChangeQuantities = function (_a) {
|
|
4588
|
-
var subscriptions = _a.subscriptions;
|
|
4589
|
-
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
4590
|
-
return subscription.charges.some(function (charge, chargeIndex) {
|
|
4591
|
-
return canShowQuantitiesInput(charge, subscription);
|
|
4592
|
-
});
|
|
4593
|
-
});
|
|
4594
|
-
};
|
|
4595
4506
|
var isSubscriptionNotActive = function (subscription) {
|
|
4596
4507
|
var _a, _b;
|
|
4597
4508
|
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
|
|
@@ -4605,69 +4516,13 @@ var canShowSubscriptionActions = function (subscription) {
|
|
|
4605
4516
|
|
|
4606
4517
|
var SubscriptionCardActions = function (_a) {
|
|
4607
4518
|
var _b, _c;
|
|
4608
|
-
var
|
|
4609
|
-
// Context
|
|
4610
|
-
var apiHost = React.useContext(BunnyContext).apiHost;
|
|
4611
|
-
var token = useToken();
|
|
4612
|
-
var _d = React.useContext(SubscriptionsContext), onChangePlanClick = _d.onChangePlanClick, onClickUpgrade = _d.onClickUpgrade, isTempViewOnly = _d.isTempViewOnly;
|
|
4613
|
-
// Hooks
|
|
4614
|
-
common.useSuccessNotification();
|
|
4615
|
-
// const cancelSubscription = useCancelSubscription();
|
|
4616
|
-
reactQuery.useQueryClient();
|
|
4617
|
-
// const navigate = usePortalNavigate();
|
|
4618
|
-
// const handleUpgradingSubscriptionChange =
|
|
4619
|
-
// useHandleUpgradingSubscriptionChange();
|
|
4519
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscription = _a.subscription;
|
|
4620
4520
|
// Derived state
|
|
4621
4521
|
var canShowCancelButton = subscription.plan.selfServiceCancel;
|
|
4622
4522
|
var productPlans = (_b = planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.plans) === null || _b === void 0 ? void 0 : _b.filter(function (plan) { var _a; return ((_a = plan.priceLists) === null || _a === void 0 ? void 0 : _a.length) > 0 && plan.productId === subscription.product.id; });
|
|
4623
4523
|
var canShowChangePlanButton = ((productPlans === null || productPlans === void 0 ? void 0 : productPlans.length) || 0) > 0;
|
|
4624
|
-
// Mutations
|
|
4625
|
-
// const subscriptionCancel = useMutation({
|
|
4626
|
-
// mutationFn: () => cancelSubscription([subscription.id], token),
|
|
4627
|
-
// onSuccess: () => {
|
|
4628
|
-
// queryClient.invalidateQueries({
|
|
4629
|
-
// queryKey: QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4630
|
-
// });
|
|
4631
|
-
// showSuccessNotification("Subscription canceled");
|
|
4632
|
-
// },
|
|
4633
|
-
// });
|
|
4634
|
-
reactQuery.useMutation({
|
|
4635
|
-
mutationFn: function () {
|
|
4636
|
-
return getGuoteSubscriptionReinstate({
|
|
4637
|
-
ids: [subscription.id],
|
|
4638
|
-
token: token,
|
|
4639
|
-
apiHost: apiHost,
|
|
4640
|
-
});
|
|
4641
|
-
},
|
|
4642
|
-
onSuccess: function (quote) {
|
|
4643
|
-
setEditingQuoteData({ id: quote.id, isTrial: false });
|
|
4644
|
-
setPayModalVisible(true);
|
|
4645
|
-
},
|
|
4646
|
-
});
|
|
4647
|
-
// Handlers
|
|
4648
|
-
var handleChangePlanClick = function () {
|
|
4649
|
-
// handleUpgradingSubscriptionChange({
|
|
4650
|
-
// subscription,
|
|
4651
|
-
// });
|
|
4652
|
-
console.log("handleChangePlanClick handleUpgradingSubscriptionChange not implemented");
|
|
4653
|
-
// navigate("plan-manager", {
|
|
4654
|
-
// subscriptionUpgradeId: subscription.id,
|
|
4655
|
-
// });
|
|
4656
|
-
onChangePlanClick();
|
|
4657
|
-
};
|
|
4658
4524
|
return (canShowChangePlanButton || canShowCancelButton) &&
|
|
4659
|
-
canShowSubscriptionActions(subscription) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4660
|
-
// onConfirm={() => subscriptionCancel.mutate()}
|
|
4661
|
-
title: "Cancel subscription" }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "p-0", type: "link" }, { children: "Cancel subscription" })) }))), !isTempViewOnly && canShowChangePlanButton && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return handleChangePlanClick(); }, type: "primary" }, { children: "Change plan" })))] })) : ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isTempViewOnly && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () {
|
|
4662
|
-
// handleUpgradingSubscriptionChange({
|
|
4663
|
-
// subscription,
|
|
4664
|
-
// });
|
|
4665
|
-
console.log("onClickUpgrade handleUpgradingSubscriptionChange not implemented");
|
|
4666
|
-
// navigate("plan-manager", {
|
|
4667
|
-
// subscriptionUpgradeId: subscription.id,
|
|
4668
|
-
// });
|
|
4669
|
-
onClickUpgrade();
|
|
4670
|
-
}, type: "primary" }, { children: "Upgrade" }))) })) : null;
|
|
4525
|
+
canShowSubscriptionActions(subscription) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [canShowCancelButton && (jsxRuntime.jsx(antd.Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsxRuntime.jsx(antd.Button, __assign({ className: "p-0", type: "link" }, { children: "Cancel subscription" })) }))), canShowChangePlanButton && (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: "primary" }, { children: "Change plan" })))] })) : ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === common.SubscriptionState.TRIAL ? (jsxRuntime.jsx(antd.Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: "primary" }, { children: "Upgrade" }))) : null;
|
|
4671
4526
|
};
|
|
4672
4527
|
|
|
4673
4528
|
var Text$2 = antd.Typography.Text;
|
|
@@ -4689,7 +4544,7 @@ var getSubscriptionStatusText = function (subscription) {
|
|
|
4689
4544
|
};
|
|
4690
4545
|
var SubscriptionCardHeader = function (_a) {
|
|
4691
4546
|
var _b, _c, _d, _e, _f;
|
|
4692
|
-
var
|
|
4547
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscription = _a.subscription;
|
|
4693
4548
|
var darkMode = React.useContext(BunnyContext).darkMode;
|
|
4694
4549
|
var brandColor = React.useContext(BrandContext).brandColor;
|
|
4695
4550
|
var isMobile = common.useIsMobile();
|
|
@@ -4698,7 +4553,10 @@ var SubscriptionCardHeader = function (_a) {
|
|
|
4698
4553
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
4699
4554
|
return (jsxRuntime.jsxs("div", __assign({ className: "flex items-center justify-between", style: {
|
|
4700
4555
|
backgroundColor: darkMode ? "var(--row-background-dark)" : "",
|
|
4701
|
-
} }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsxRuntime.jsx("div", __assign({ className: "font-medium", style: { fontSize: "11px", color: brandColor } }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxRuntime.jsxs("div", __assign({ className: "flex grow items-center gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && (jsxRuntime.jsx(Text$2, __assign({ className: "text-lg" }, { children: subscription.plan.name }))), jsxRuntime.jsxs(antd.Tag, __assign({ className: "ant-tag-".concat(common.TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()]) }, { children: [lodash.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft, " days left)") : ""] }))] }))] })), jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-6" }, { children: [jsxRuntime.jsx(Text$2, __assign({ className: "grow text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile &&
|
|
4556
|
+
} }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [((_c = subscription === null || subscription === void 0 ? void 0 : subscription.product) === null || _c === void 0 ? void 0 : _c.name) && (jsxRuntime.jsx("div", __assign({ className: "font-medium", style: { fontSize: "11px", color: brandColor } }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), jsxRuntime.jsxs("div", __assign({ className: "flex grow items-center gap-2" }, { children: [((_e = subscription === null || subscription === void 0 ? void 0 : subscription.plan) === null || _e === void 0 ? void 0 : _e.name) && (jsxRuntime.jsx(Text$2, __assign({ className: "text-lg" }, { children: subscription.plan.name }))), jsxRuntime.jsxs(antd.Tag, __assign({ className: "ant-tag-".concat(common.TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()]) }, { children: [lodash.capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft, " days left)") : ""] }))] }))] })), jsxRuntime.jsxs("div", __assign({ className: "flex items-center gap-6" }, { children: [jsxRuntime.jsx(Text$2, __assign({ className: "grow text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile &&
|
|
4557
|
+
planChangeOptions &&
|
|
4558
|
+
onChangePlanClick &&
|
|
4559
|
+
onCancelSubscriptionClick && (jsxRuntime.jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscription: subscription }))] }))] })));
|
|
4702
4560
|
};
|
|
4703
4561
|
|
|
4704
4562
|
var BillingPeriodConverter;
|
|
@@ -4711,16 +4569,23 @@ var BillingPeriodConverter;
|
|
|
4711
4569
|
})(BillingPeriodConverter || (BillingPeriodConverter = {}));
|
|
4712
4570
|
var SubscriptionChargeTotal = function (_a) {
|
|
4713
4571
|
var charge = _a.charge, subscription = _a.subscription;
|
|
4572
|
+
var billingPeriod = charge.billingPeriod && BillingPeriodConverter[charge.billingPeriod];
|
|
4714
4573
|
var isMobile = common.useIsMobile();
|
|
4715
|
-
|
|
4574
|
+
var currencyId = subscription.currencyId;
|
|
4575
|
+
var formattedDiscountedPrice = common.formatCurrency(charge.price, currencyId);
|
|
4576
|
+
var formattedPeriodPrice = common.formatCurrency(charge.periodPrice, currencyId);
|
|
4577
|
+
return (jsxRuntime.jsx("div", __assign({ className: "flex gap-1 ".concat(isMobile ? "flex-col" : "") }, { children: charge.kind === common.SubscriptionChargeKind.DISCOUNT
|
|
4578
|
+
? "-".concat(formattedDiscountedPrice, " ").concat(billingPeriod)
|
|
4579
|
+
: "".concat(formattedPeriodPrice, " ").concat(billingPeriod) })));
|
|
4716
4580
|
};
|
|
4717
4581
|
|
|
4718
4582
|
var SubscriptionChargeUnitPrice = function (_a) {
|
|
4719
|
-
var _b, _c;
|
|
4720
4583
|
var charge = _a.charge, subscription = _a.subscription;
|
|
4721
4584
|
var darkMode = React.useContext(BunnyContext).darkMode;
|
|
4722
|
-
var
|
|
4723
|
-
|
|
4585
|
+
var _b = React.useState(false), showPriceTiers = _b[0], setShowPriceTiers = _b[1];
|
|
4586
|
+
var displayPriceTiers = (charge === null || charge === void 0 ? void 0 : charge.priceTiers) && charge.pricingModel === common.PricingModel.TIERED;
|
|
4587
|
+
var isDiscount = (charge === null || charge === void 0 ? void 0 : charge.kind) === common.SubscriptionChargeKind.DISCOUNT;
|
|
4588
|
+
if (displayPriceTiers)
|
|
4724
4589
|
return (jsxRuntime.jsx(antd.Dropdown, __assign({ dropdownRender: function () {
|
|
4725
4590
|
var _a, _b;
|
|
4726
4591
|
return (jsxRuntime.jsx("div", __assign({ className: "flex flex-col rounded border border-solid border-slate-200 p-2", style: {
|
|
@@ -4734,9 +4599,11 @@ var SubscriptionChargeUnitPrice = function (_a) {
|
|
|
4734
4599
|
: "∞";
|
|
4735
4600
|
return (jsxRuntime.jsxs("div", __assign({ className: "contents" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "whitespace-nowrap" }, { children: [tier.starts.toLocaleString(), " - ", ends.toLocaleString(), " ", ":"] })), jsxRuntime.jsx("div", __assign({ className: "whitespace-nowrap text-right" }, { children: common.formatCurrency(tier.price, subscription.currencyId, charge.priceDecimals) }))] }), index));
|
|
4736
4601
|
}) })) })));
|
|
4737
|
-
}, onOpenChange: setShowPriceTiers, open: showPriceTiers, trigger: ["click"] }, { children: jsxRuntime.jsx("div", __assign({ className: "cursor-pointer underline", onClick: function () { return setShowPriceTiers(!showPriceTiers); } }, { children: showPriceTiers ? "
|
|
4738
|
-
|
|
4739
|
-
|
|
4602
|
+
}, onOpenChange: setShowPriceTiers, open: showPriceTiers, trigger: ["click"] }, { children: jsxRuntime.jsx("div", __assign({ className: "cursor-pointer underline", onClick: function () { return setShowPriceTiers(!showPriceTiers); } }, { children: showPriceTiers ? "Hide tiers" : "Show tiers" })) })));
|
|
4603
|
+
else if (isDiscount)
|
|
4604
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["-", common.formatCurrency(charge.discountedPrice, subscription.currencyId)] }));
|
|
4605
|
+
else
|
|
4606
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: common.formatCurrency(charge.discountedPrice, subscription.currencyId) }));
|
|
4740
4607
|
};
|
|
4741
4608
|
|
|
4742
4609
|
var SubscriptionCardColumnHeaders = function (_a) {
|
|
@@ -4750,7 +4617,7 @@ var SubscriptionsListCell = function (_a) {
|
|
|
4750
4617
|
return (jsxRuntime.jsx(Text$1, __assign({ className: "flex items-center text-sm whitespace-nowrap ".concat(className), style: __assign({ gridColumn: gridColumn, textAlign: right ? "right" : "left", justifyContent: right ? "flex-end" : "flex-start" }, style) }, { children: children })));
|
|
4751
4618
|
};
|
|
4752
4619
|
|
|
4753
|
-
var
|
|
4620
|
+
var CARD_COLUMNS = [
|
|
4754
4621
|
{
|
|
4755
4622
|
title: "CHARGE",
|
|
4756
4623
|
width: "minmax(min-content, 26%)",
|
|
@@ -4774,22 +4641,21 @@ var createCardColumns = function () { return [
|
|
|
4774
4641
|
title: "TOTAL",
|
|
4775
4642
|
width: "minmax(min-content, 18%)",
|
|
4776
4643
|
},
|
|
4777
|
-
];
|
|
4644
|
+
];
|
|
4778
4645
|
var SubscriptionCardDesktop = function (_a) {
|
|
4779
4646
|
var _b;
|
|
4780
|
-
var
|
|
4647
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscription = _a.subscription;
|
|
4781
4648
|
var shadow = React.useContext(SubscriptionsContext).shadow;
|
|
4782
4649
|
// Derived state
|
|
4783
4650
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$1.TRIAL;
|
|
4784
|
-
|
|
4785
|
-
return (jsxRuntime.jsxs(Card, __assign({ className: "p-4 ".concat(shadow ? "shadow-".concat(shadow) : "") }, { children: [jsxRuntime.jsx(SubscriptionCardHeader, { planChangeOptions: planChangeOptions, setEditingQuoteData: setEditingQuoteData, setPayModalVisible: setPayModalVisible, subscription: subscription }), jsxRuntime.jsx(antd.Divider, { className: "my-4", style: {
|
|
4651
|
+
return (jsxRuntime.jsxs(Card, __assign({ className: "p-4 ".concat(shadow ? "shadow-".concat(shadow) : "") }, { children: [jsxRuntime.jsx(SubscriptionCardHeader, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscription: subscription }), jsxRuntime.jsx(antd.Divider, { className: "my-4", style: {
|
|
4786
4652
|
gridColumn: "1 / 5",
|
|
4787
4653
|
width: "calc(100% + 32px)",
|
|
4788
4654
|
transform: "translateX(-16px)",
|
|
4789
4655
|
} }), jsxRuntime.jsxs("div", __assign({ className: "grid w-full", style: {
|
|
4790
|
-
gridTemplateColumns:
|
|
4656
|
+
gridTemplateColumns: CARD_COLUMNS.map(function (column) { return column.width; }).join(" "),
|
|
4791
4657
|
rowGap: "0.75rem",
|
|
4792
|
-
} }, { children: [jsxRuntime.jsx(SubscriptionCardColumnHeaders, { columns:
|
|
4658
|
+
} }, { children: [jsxRuntime.jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), subscription.charges.map(function (charge, chargeIndex) {
|
|
4793
4659
|
if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
|
|
4794
4660
|
return null;
|
|
4795
4661
|
return (jsxRuntime.jsx(SubscriptionCardDesktopRow, { charge: charge, chargeIndex: chargeIndex, subscription: subscription }, chargeIndex));
|
|
@@ -4822,12 +4688,18 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
4822
4688
|
charge.chargeType === common.ChargeType.USAGE,
|
|
4823
4689
|
}).data;
|
|
4824
4690
|
var isRampFirstRow = isRamp && chargeIndex === 0;
|
|
4825
|
-
var
|
|
4826
|
-
|
|
4691
|
+
var isTrial = charge.trial;
|
|
4692
|
+
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.id) === charge.id &&
|
|
4693
|
+
(!isTrial || prevCharge.trial) &&
|
|
4694
|
+
(isTrial || !prevCharge.trial);
|
|
4695
|
+
var isDiscount = charge.kind === common.SubscriptionChargeKind.DISCOUNT;
|
|
4696
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "contents" }, { children: [(isRampFirstRow || !isRamp) && (jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? "1/-1" : "1" }, { children: jsxRuntime.jsx("div", __assign({ className: "flex items-center gap-2 ".concat(isDiscount ? "pl-4" : "") }, { children: jsxRuntime.jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName)
|
|
4827
4697
|
? charge.name
|
|
4828
|
-
: "" }) })) }))), jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsxRuntime.jsx("div", { children: chargePeriod }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.
|
|
4829
|
-
?
|
|
4830
|
-
: charge.
|
|
4698
|
+
: "" }) })) }))), jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsxRuntime.jsx("div", { children: chargePeriod }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === common.SubscriptionChargeKind.DISCOUNT
|
|
4699
|
+
? ""
|
|
4700
|
+
: charge.chargeType === common.ChargeType.USAGE
|
|
4701
|
+
? data && jsxRuntime.jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
|
|
4702
|
+
: charge.quantity })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, subscription: subscription }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
|
|
4831
4703
|
};
|
|
4832
4704
|
|
|
4833
4705
|
var Text = antd.Typography.Text;
|
|
@@ -4855,14 +4727,14 @@ var CHARGE_COLUMNS = [
|
|
|
4855
4727
|
];
|
|
4856
4728
|
var SubscriptionCard = function (_a) {
|
|
4857
4729
|
var _b;
|
|
4858
|
-
var
|
|
4730
|
+
var subscription = _a.subscription;
|
|
4859
4731
|
var darkMode = React.useContext(BunnyContext).darkMode;
|
|
4860
4732
|
// Derived state
|
|
4861
4733
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$1.TRIAL;
|
|
4862
4734
|
var backgroundColor = darkMode
|
|
4863
4735
|
? "var(--row-background-dark)"
|
|
4864
4736
|
: "var(--row-background)";
|
|
4865
|
-
return (jsxRuntime.jsx(Card, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsxRuntime.jsx(SubscriptionCardHeader, {
|
|
4737
|
+
return (jsxRuntime.jsx(Card, { children: jsxRuntime.jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsxRuntime.jsx(SubscriptionCardHeader, { subscription: subscription }), jsxRuntime.jsx(antd.Divider, { className: "my-4", style: {
|
|
4866
4738
|
gridColumn: "1 / -1",
|
|
4867
4739
|
width: "calc(100% + 32px)",
|
|
4868
4740
|
transform: "translateX(-16px)",
|
|
@@ -4876,142 +4748,87 @@ var SubscriptionCard = function (_a) {
|
|
|
4876
4748
|
return null;
|
|
4877
4749
|
var isRamp = charge.isRamp;
|
|
4878
4750
|
var chargePeriod = "".concat(common.formatDate(charge.startDate), " - ").concat(common.formatDate(charge.endDate));
|
|
4879
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "contents" }, { children: [((isRamp && chargeIndex === 0) || !isRamp) && (jsxRuntime.jsxs(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className, style: { gridColumn: isRamp ? "1/-1" : "1" } }, { children: [jsxRuntime.jsx("span", { children: charge.name }), !isRamp ? " - ".concat(chargePeriod) : ""] }))), isRamp && (jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className }, { children: "- ".concat(chargePeriod) }))), jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[1].className }, { children: charge.
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4751
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "contents" }, { children: [((isRamp && chargeIndex === 0) || !isRamp) && (jsxRuntime.jsxs(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className, style: { gridColumn: isRamp ? "1/-1" : "1" } }, { children: [jsxRuntime.jsx("span", { children: charge.name }), !isRamp ? " - ".concat(chargePeriod) : ""] }))), isRamp && (jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className }, { children: "- ".concat(chargePeriod) }))), jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[1].className }, { children: charge.kind === common.SubscriptionChargeKind.DISCOUNT
|
|
4752
|
+
? ""
|
|
4753
|
+
: charge.quantity })), jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[2].className }, { children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, subscription: subscription }) })), jsxRuntime.jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[3].className }, { children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] }), chargeIndex));
|
|
4754
|
+
})] }))] })) }));
|
|
4883
4755
|
};
|
|
4884
4756
|
|
|
4885
4757
|
var SubscriptionsList = function (_a) {
|
|
4886
|
-
var hideExpired = _a.hideExpired,
|
|
4758
|
+
var hideExpired = _a.hideExpired, onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscriptions = _a.subscriptions;
|
|
4887
4759
|
var isMobile = common.useIsMobile();
|
|
4888
4760
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.map(function (subscription, subscriptionIndex) {
|
|
4889
4761
|
if (hideExpired && isSubscriptionNotActive(subscription))
|
|
4890
4762
|
return null;
|
|
4891
4763
|
if (isMobile)
|
|
4892
|
-
return (jsxRuntime.jsx(SubscriptionCard, {
|
|
4893
|
-
return (jsxRuntime.jsx(SubscriptionCardDesktop, {
|
|
4764
|
+
return (jsxRuntime.jsx(SubscriptionCard, { subscription: subscription }, subscriptionIndex));
|
|
4765
|
+
return (jsxRuntime.jsx(SubscriptionCardDesktop, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscription: subscription }, subscriptionIndex));
|
|
4894
4766
|
}) }));
|
|
4895
4767
|
};
|
|
4896
4768
|
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
return (
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4769
|
+
// WARNING: There is a preview button on APP that will need to be changed if this query is changed
|
|
4770
|
+
var PLAN_CHANGE_OPTIONS_QUERY = "\n query planChangeOptions($subscriptionId: ID) {\n planChangeOptions(subscriptionId: $subscriptionId) {\n products {\n everythingInPlus\n id\n name\n features(sort: \"position asc\") {\n description\n id\n isVisible\n kind\n name\n position\n }\n }\n plans {\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 priceLists {\n basePrice\n id\n currencyId\n periodMonths\n plan {\n id\n position\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 productId\n }\n }\n }";
|
|
4771
|
+
var getPlanChangeOptions = function (_a) {
|
|
4772
|
+
var isInPreviewMode = _a.isInPreviewMode, token = _a.token, upgradingSubscription = _a.upgradingSubscription, apiHost = _a.apiHost;
|
|
4773
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4774
|
+
var response, planChangeOptions;
|
|
4775
|
+
return __generator(this, function (_b) {
|
|
4776
|
+
switch (_b.label) {
|
|
4777
|
+
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
4778
|
+
isInPreviewMode: isInPreviewMode,
|
|
4779
|
+
query: PLAN_CHANGE_OPTIONS_QUERY,
|
|
4780
|
+
vars: { subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id },
|
|
4781
|
+
token: token,
|
|
4782
|
+
apiHost: apiHost,
|
|
4783
|
+
})];
|
|
4784
|
+
case 1:
|
|
4785
|
+
response = _b.sent();
|
|
4786
|
+
planChangeOptions = response.planChangeOptions;
|
|
4787
|
+
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.errors)
|
|
4788
|
+
throw planChangeOptions.errors;
|
|
4789
|
+
// Sort planChangeOptions.plans by position
|
|
4790
|
+
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.plans) {
|
|
4791
|
+
planChangeOptions.plans.sort(function (a, b) { return a.position - b.position; });
|
|
4792
|
+
}
|
|
4793
|
+
return [2 /*return*/, planChangeOptions];
|
|
4794
|
+
}
|
|
4795
|
+
});
|
|
4914
4796
|
});
|
|
4915
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isMobile && (jsxRuntime.jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired, subscriptions: subscriptions })), jsxRuntime.jsx("div", __assign({ className: "flex grow gap-2 ".concat(isMobile ? "flex-col shadow-padding-x" : "justify-end") }, { children: !isTempViewOnly && canShowChangeQuantitiesButton && (jsxRuntime.jsx(ChangeQuantitiesButton, { canShowChangeQuantitiesButton: canShowChangeQuantitiesButton, setQuantityDrawerOpen: setQuantityDrawerOpen })) }))] }));
|
|
4916
4797
|
};
|
|
4917
4798
|
|
|
4918
|
-
// !!! This component is intended to be view only, however it still has lots of code for full functionality.
|
|
4919
|
-
// !!! This must be refactored.
|
|
4920
4799
|
var Subscriptions = function (_a) {
|
|
4921
|
-
var
|
|
4800
|
+
var className = _a.className, companyName = _a.companyName, entityId = _a.entityId, _b = _a.hideExpired, hideExpired = _b === void 0 ? false : _b, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, onChangePlanClick = _a.onChangePlanClick, onSubscriptionsLoaded = _a.onSubscriptionsLoaded, _c = _a.styles, styles = _c === void 0 ? {
|
|
4801
|
+
gap: 4,
|
|
4802
|
+
shadow: "sm",
|
|
4803
|
+
} : _c;
|
|
4804
|
+
var gap = styles.gap, shadow = styles.shadow;
|
|
4922
4805
|
// Context
|
|
4923
|
-
var
|
|
4806
|
+
var apiHost = React.useContext(BunnyContext).apiHost;
|
|
4924
4807
|
var token = useToken();
|
|
4925
|
-
// Recoil state
|
|
4926
|
-
// const [updatingChargeQuantityId, setUpdatingChargeQuantityId] =
|
|
4927
|
-
// useRecoilState(updatingChargeQuantityIdState);
|
|
4928
|
-
// Local state
|
|
4929
|
-
var _d = React.useState(), editingQuoteData = _d[0], setEditingQuoteData = _d[1];
|
|
4930
|
-
var _e = React.useState(false), payModalVisible = _e[0], setPayModalVisible = _e[1];
|
|
4931
|
-
var _f = React.useState(true), hideExpired = _f[0], setHideExpired = _f[1];
|
|
4932
|
-
var _g = React.useState(false); _g[0]; var setQuantityDrawerOpen = _g[1];
|
|
4933
|
-
// Hooks
|
|
4934
|
-
var handleAllErrorFormats = common.useAllErrorFormats(onTokenExpired);
|
|
4935
|
-
var queryClient = reactQuery.useQueryClient();
|
|
4936
|
-
var showSuccessNotification = common.useSuccessNotification();
|
|
4937
|
-
// const quoteDelete = useQuoteDelete();
|
|
4938
|
-
var isMobile = common.useIsMobile();
|
|
4939
4808
|
// Queries
|
|
4940
|
-
var
|
|
4809
|
+
var _d = reactQuery.useQuery({
|
|
4941
4810
|
queryKey: common.QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4942
4811
|
queryFn: function () { return getSubscriptions({ entityId: entityId, token: token, apiHost: apiHost }); },
|
|
4943
4812
|
enabled: Boolean(entityId),
|
|
4944
|
-
}), rawSubscriptions =
|
|
4945
|
-
var
|
|
4946
|
-
queryKey: common.QueryKeyFactory.default.createObjectKey("editingQuote", editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id),
|
|
4947
|
-
queryFn: function () {
|
|
4948
|
-
return (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id)
|
|
4949
|
-
? getQuote({ token: token, id: editingQuoteData.id, apiHost: apiHost })
|
|
4950
|
-
: undefined;
|
|
4951
|
-
},
|
|
4952
|
-
enabled: Boolean(editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id),
|
|
4953
|
-
}).data;
|
|
4954
|
-
var _j = reactQuery.useQuery({
|
|
4813
|
+
}), rawSubscriptions = _d.data, subscriptionsAreLoading = _d.isLoading;
|
|
4814
|
+
var _e = reactQuery.useQuery({
|
|
4955
4815
|
queryKey: common.QueryKeyFactory.default.planChangeOptionsKey(),
|
|
4956
4816
|
queryFn: function () { return getPlanChangeOptions({ token: token, apiHost: apiHost }); },
|
|
4957
|
-
|
|
4817
|
+
enabled: Boolean(onChangePlanClick),
|
|
4818
|
+
}), planChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
|
|
4958
4819
|
// Derived state
|
|
4959
4820
|
var subscriptions = useSubscriptions({ data: rawSubscriptions });
|
|
4960
|
-
var allSubscriptionsExpired = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.every(function (subscription) {
|
|
4961
|
-
var _a, _b;
|
|
4962
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.EXPIRED ||
|
|
4963
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.CANCELED;
|
|
4964
|
-
});
|
|
4965
4821
|
React.useEffect(function () {
|
|
4966
|
-
if (
|
|
4967
|
-
|
|
4968
|
-
}, [
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
setQuantityDrawerOpen(false);
|
|
4972
|
-
setEditingQuoteData(undefined);
|
|
4973
|
-
queryClient.invalidateQueries({
|
|
4974
|
-
queryKey: common.QueryKeyFactory.default.transactionsKey(),
|
|
4975
|
-
});
|
|
4976
|
-
queryClient.invalidateQueries({
|
|
4977
|
-
queryKey: common.QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4978
|
-
});
|
|
4979
|
-
showSuccessNotification("Your plan has been updated", "Payment successful");
|
|
4980
|
-
setPayModalVisible(false);
|
|
4981
|
-
setHideExpired(true);
|
|
4982
|
-
};
|
|
4983
|
-
var onCancel = function () {
|
|
4984
|
-
setPayModalVisible(false);
|
|
4985
|
-
};
|
|
4986
|
-
var onFail = function (error) {
|
|
4987
|
-
handleAllErrorFormats(error);
|
|
4988
|
-
};
|
|
4989
|
-
// const onClose = () => {
|
|
4990
|
-
// if (editingQuoteData) {
|
|
4991
|
-
// quoteDelete(editingQuoteData.id, token);
|
|
4992
|
-
// setEditingQuoteData(undefined);
|
|
4993
|
-
// }
|
|
4994
|
-
// // if (updatingChargeQuantityId) {
|
|
4995
|
-
// // setUpdatingChargeQuantityId(undefined);
|
|
4996
|
-
// // }
|
|
4997
|
-
// setQuantityDrawerOpen(false);
|
|
4998
|
-
// };
|
|
4999
|
-
if (subscriptionsAreLoading || arePlanChangeOptionsLoading)
|
|
4822
|
+
if (subscriptions)
|
|
4823
|
+
onSubscriptionsLoaded === null || onSubscriptionsLoaded === void 0 ? void 0 : onSubscriptionsLoaded(subscriptions);
|
|
4824
|
+
}, [subscriptions]);
|
|
4825
|
+
if (subscriptionsAreLoading ||
|
|
4826
|
+
(Boolean(onChangePlanClick) ? arePlanChangeOptionsLoading : false))
|
|
5000
4827
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
5001
|
-
return (jsxRuntime.
|
|
5002
|
-
onChangePlanClick: function () {
|
|
5003
|
-
console.log("onChangePlanClick not implemented");
|
|
5004
|
-
},
|
|
5005
|
-
onClickUpgrade: function () {
|
|
5006
|
-
console.log("onClickUpgrade not implemented");
|
|
5007
|
-
},
|
|
5008
|
-
isTempViewOnly: true,
|
|
5009
|
-
shadow: shadow,
|
|
4828
|
+
return (jsxRuntime.jsx(SubscriptionsContext.Provider, __assign({ value: {
|
|
5010
4829
|
gap: gap,
|
|
5011
|
-
|
|
5012
|
-
} }, { children:
|
|
5013
|
-
flexShrink: 1,
|
|
5014
|
-
} }, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(SubscriptionsList, { hideExpired: hideExpired, planChangeOptions: planChangeOptions, setEditingQuoteData: setEditingQuoteData, setPayModalVisible: setPayModalVisible, subscriptions: subscriptions }) })) : (jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsxRuntime.jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) }))) })), isMobile && (jsxRuntime.jsx("div", __assign({ className: "pt-4 pb-2" }, { children: jsxRuntime.jsx(SubscriptionsNavigation, { hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsxRuntime.jsx(Checkout, { entityId: entityId, onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile })] })));
|
|
4830
|
+
shadow: shadow,
|
|
4831
|
+
} }, { children: jsxRuntime.jsx("div", __assign({ className: "flex flex-col gap-".concat(gap, " shrink shadow-padding-xb overflow-auto ").concat(className) }, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsxRuntime.jsx(SubscriptionsList, { hideExpired: hideExpired, onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscriptions: subscriptions })) : (jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsxRuntime.jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) }))) })) })));
|
|
5015
4832
|
};
|
|
5016
4833
|
|
|
5017
4834
|
var MUTATION = "\nmutation BillingDetailsUpdate(\n $attributes: BillingDetailsAttributes!) {\n billingDetailsUpdate(\n attributes: $attributes\n ) {\n billingDetails {\n billingCity\n billingContact {\n email\n }\n billingCountry\n billingState\n billingStreet\n billingZip\n name\n taxNumber\n }\n errors\n }\n }\n";
|