@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/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import React__default, { createContext, useContext, useEffect, useState, useMemo
|
|
|
4
4
|
import { Markup } from 'interweave';
|
|
5
5
|
import { ConfigProvider, Button, Typography, Tag, Divider, Popconfirm, Input, Checkbox, Collapse, Modal, Form, Drawer, Card as Card$1, Select, Image, Dropdown, Skeleton } from 'antd';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, DEFAULT_CONFIG, useErrorNotification, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useSuccessNotification, useAllErrorFormats, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, DOCUMENT_NAME as DOCUMENT_NAME$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
|
|
7
|
+
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, DEFAULT_CONFIG, useErrorNotification, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useSuccessNotification, useAllErrorFormats, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, DOCUMENT_NAME as DOCUMENT_NAME$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount, SubscriptionChargeKind, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, PricingModel, ChargeType } from '@bunnyapp/common';
|
|
8
8
|
import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation } from '@tanstack/react-query';
|
|
9
9
|
import theme from 'antd/lib/theme';
|
|
10
10
|
import { RecoilRoot } from 'recoil';
|
|
@@ -12,7 +12,7 @@ import request, { GraphQLClient } from 'graphql-request';
|
|
|
12
12
|
import { HelmetProvider, Helmet } from 'react-helmet-async';
|
|
13
13
|
import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
|
|
14
14
|
import { loadStripe } from '@stripe/stripe-js/pure';
|
|
15
|
-
import { capitalize, startCase,
|
|
15
|
+
import { capitalize, startCase, omit } from 'lodash';
|
|
16
16
|
import { BarChart, ResponsiveContainer, XAxis, Tooltip, Bar, Rectangle } from 'recharts';
|
|
17
17
|
|
|
18
18
|
function styleInject(css, ref) {
|
|
@@ -1569,7 +1569,7 @@ var BrandContext = createContext({
|
|
|
1569
1569
|
topNavImageUrl: DEFAULT_TOP_NAV_IMAGE_URL,
|
|
1570
1570
|
});
|
|
1571
1571
|
|
|
1572
|
-
var MUTATION$
|
|
1572
|
+
var MUTATION$8 = "\n query entityBranding {\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }\n";
|
|
1573
1573
|
var getBranding = function (_a) {
|
|
1574
1574
|
var token = _a.token, apiHost = _a.apiHost;
|
|
1575
1575
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1577,7 +1577,7 @@ var getBranding = function (_a) {
|
|
|
1577
1577
|
return __generator(this, function (_b) {
|
|
1578
1578
|
switch (_b.label) {
|
|
1579
1579
|
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
1580
|
-
query: MUTATION$
|
|
1580
|
+
query: MUTATION$8,
|
|
1581
1581
|
token: token,
|
|
1582
1582
|
apiHost: apiHost,
|
|
1583
1583
|
})];
|
|
@@ -1771,7 +1771,7 @@ function useToken() {
|
|
|
1771
1771
|
return overrideToken || tokenFromContext;
|
|
1772
1772
|
}
|
|
1773
1773
|
|
|
1774
|
-
var MarkupContainer = styled.div(templateObject_1$
|
|
1774
|
+
var MarkupContainer = styled.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
|
|
1775
1775
|
var InvoiceQuoteView = function (_a) {
|
|
1776
1776
|
var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError;
|
|
1777
1777
|
var downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
|
|
@@ -1789,7 +1789,7 @@ var InvoiceQuoteView = function (_a) {
|
|
|
1789
1789
|
minWidth: "750px",
|
|
1790
1790
|
} }, { children: [jsx(Markup, { content: html }), children] })))] })));
|
|
1791
1791
|
};
|
|
1792
|
-
var templateObject_1$
|
|
1792
|
+
var templateObject_1$7;
|
|
1793
1793
|
|
|
1794
1794
|
var quoteMetaDescription = function (vendorName) {
|
|
1795
1795
|
return "View this quote on the ".concat(vendorName, " customer portal. Powered by Bunny");
|
|
@@ -1947,7 +1947,7 @@ var gqlRequest = function (_a) {
|
|
|
1947
1947
|
});
|
|
1948
1948
|
};
|
|
1949
1949
|
|
|
1950
|
-
var MUTATION$
|
|
1950
|
+
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";
|
|
1951
1951
|
var checkout = function (_a) {
|
|
1952
1952
|
var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
|
|
1953
1953
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1964,7 +1964,7 @@ var checkout = function (_a) {
|
|
|
1964
1964
|
mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
|
|
1965
1965
|
}
|
|
1966
1966
|
return [4 /*yield*/, gqlRequest({
|
|
1967
|
-
query: MUTATION$
|
|
1967
|
+
query: MUTATION$7,
|
|
1968
1968
|
token: token,
|
|
1969
1969
|
vars: mutationVars,
|
|
1970
1970
|
apiHost: apiHost,
|
|
@@ -2167,13 +2167,13 @@ var PlusIcon = function (_a) {
|
|
|
2167
2167
|
return (jsxs("svg", __assign({ width: "14", height: "15", viewBox: "0 0 14 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M2.9165 7.5H11.0832", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M7 3.41663V11.5833", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
2168
2168
|
};
|
|
2169
2169
|
|
|
2170
|
-
var Text$
|
|
2170
|
+
var Text$e = Typography.Text;
|
|
2171
2171
|
var CreditCard = function (_a) {
|
|
2172
2172
|
var _b;
|
|
2173
2173
|
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;
|
|
2174
2174
|
var isMobile = useIsMobile();
|
|
2175
2175
|
var Wrapper = cardEnabled ? Card : "div";
|
|
2176
|
-
return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$
|
|
2176
|
+
return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$e, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Divider, {}), jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
|
|
2177
2177
|
};
|
|
2178
2178
|
var MiniCreditCard = function (_a) {
|
|
2179
2179
|
var _b;
|
|
@@ -2185,7 +2185,7 @@ var MiniCreditCard = function (_a) {
|
|
|
2185
2185
|
var backgroundColor = useMemo(function () {
|
|
2186
2186
|
return darkMode ? "var(--row-background-alternate)" : "bg-slate-50";
|
|
2187
2187
|
}, [darkMode]);
|
|
2188
|
-
return (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 ? (jsxs(Fragment, { children: [jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxs("div", __assign({ className: "flex items-center gap-4 space-between w-full" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$
|
|
2188
|
+
return (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 ? (jsxs(Fragment, { children: [jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxs("div", __assign({ className: "flex items-center gap-4 space-between w-full" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$e, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier }), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })) })), !hideRemoveButton && (jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined$1, {}), jsx(Text$e, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsx(Button, { disabled: true, type: "link" })] }))) })));
|
|
2189
2189
|
};
|
|
2190
2190
|
var CardImage = function (_a) {
|
|
2191
2191
|
var _b, _c;
|
|
@@ -2204,7 +2204,7 @@ var CardImage = function (_a) {
|
|
|
2204
2204
|
};
|
|
2205
2205
|
var CardAttribute = function (_a) {
|
|
2206
2206
|
var title = _a.title, value = _a.value;
|
|
2207
|
-
return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsx(Text$
|
|
2207
|
+
return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsx(Text$e, { children: value })] })));
|
|
2208
2208
|
};
|
|
2209
2209
|
var CardActions = function (_a) {
|
|
2210
2210
|
var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
|
|
@@ -2214,7 +2214,7 @@ var CardActions = function (_a) {
|
|
|
2214
2214
|
var EmptyCard = function (_a) {
|
|
2215
2215
|
var onClick = _a.onClick, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, _c = _a.cardEnabled, cardEnabled = _c === void 0 ? true : _c;
|
|
2216
2216
|
var brandColor = useContext(BrandContext).brandColor;
|
|
2217
|
-
return (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: [jsx(LargeCardIcon, {}), jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsx(Button, __assign({ type: "link" }, { children: jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
|
|
2217
|
+
return (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: [jsx(LargeCardIcon, {}), jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsx(Button, __assign({ type: "link", id: "openAddPaymentMethodDrawer" }, { children: jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
|
|
2218
2218
|
};
|
|
2219
2219
|
var isExpired = function (paymentMethodData) {
|
|
2220
2220
|
var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
|
|
@@ -2302,7 +2302,7 @@ var DemoPayCardCvc = function (_a) {
|
|
|
2302
2302
|
var cvc = event.target.value.replace(/\D/g, "");
|
|
2303
2303
|
onChange(cvc);
|
|
2304
2304
|
};
|
|
2305
|
-
return (jsx("div", __assign({ className: "grow" }, { children: jsx(Input, { autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: value, maxLength: 3, placeholder: placeholder || "CVC" }) })));
|
|
2305
|
+
return (jsx("div", __assign({ className: "grow" }, { children: jsx(Input, { name: "cvc", autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: value, maxLength: 3, placeholder: placeholder || "CVC" }) })));
|
|
2306
2306
|
};
|
|
2307
2307
|
|
|
2308
2308
|
var CARD_NUMBER_MAX_LENGTH = 19; // Why 19 instead of 16? Because we add spaces
|
|
@@ -2319,7 +2319,7 @@ var DemoPayCardNumber = function (_a) {
|
|
|
2319
2319
|
var number = event.target.value.replace(/\s/g, "");
|
|
2320
2320
|
onChange(number);
|
|
2321
2321
|
};
|
|
2322
|
-
return (jsx("div", __assign({ className: "grow" }, { children: jsx(Input, { autoFocus: autoFocus, maxLength: CARD_NUMBER_MAX_LENGTH, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, placeholder: placeholder || "Card Number", value: formatCardNumber(value) }) })));
|
|
2322
|
+
return (jsx("div", __assign({ className: "grow" }, { children: jsx(Input, { name: "cardNumber", autoFocus: autoFocus, maxLength: CARD_NUMBER_MAX_LENGTH, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, placeholder: placeholder || "Card Number", value: formatCardNumber(value) }) })));
|
|
2323
2323
|
};
|
|
2324
2324
|
|
|
2325
2325
|
var DemoPayExpiry = function (_a) {
|
|
@@ -2332,7 +2332,7 @@ var DemoPayExpiry = function (_a) {
|
|
|
2332
2332
|
var expiry = event.target.value.replace(/\D/g, "");
|
|
2333
2333
|
onChange(expiry);
|
|
2334
2334
|
};
|
|
2335
|
-
return (jsx("div", __assign({ className: "grow" }, { children: jsx(Input, { autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: formatCardExpiry(value), maxLength: 5, placeholder: placeholder || "MM/YY" }) })));
|
|
2335
|
+
return (jsx("div", __assign({ className: "grow" }, { children: jsx(Input, { name: "expiry", autoFocus: autoFocus, onKeyDown: onKeyPress, onKeyUp: onKeyPress, onChange: onNumberChange, value: formatCardExpiry(value), maxLength: 5, placeholder: placeholder || "MM/YY" }) })));
|
|
2336
2336
|
};
|
|
2337
2337
|
|
|
2338
2338
|
function useSave$1(_a) {
|
|
@@ -2385,7 +2385,7 @@ function useSave$1(_a) {
|
|
|
2385
2385
|
return { save: save, isSaving: isSaving };
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
|
-
var Text$
|
|
2388
|
+
var Text$d = Typography.Text;
|
|
2389
2389
|
var TEST_CARD = "4242424242424242";
|
|
2390
2390
|
var DemoPayForm = function (_a) {
|
|
2391
2391
|
var onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod, plugin = _a.plugin;
|
|
@@ -2446,16 +2446,16 @@ var DemoPayForm = function (_a) {
|
|
|
2446
2446
|
var onCardCvcChange = function (cvc) {
|
|
2447
2447
|
setCardDetails(__assign(__assign({}, cardDetails), { cvc: cvc }));
|
|
2448
2448
|
};
|
|
2449
|
-
return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsx(Text$
|
|
2449
|
+
return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsx(Text$d, __assign({ className: "text-xs" }, { children: "DemoPay is for testing only." })), jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
|
|
2450
2450
|
};
|
|
2451
|
-
var StyledInputs = styled.div(templateObject_1$
|
|
2451
|
+
var StyledInputs = styled.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) {
|
|
2452
2452
|
var darkMode = _a.darkMode;
|
|
2453
2453
|
return darkMode ? "var(--row-background-dark)" : "white";
|
|
2454
2454
|
}, function (_a) {
|
|
2455
2455
|
var darkMode = _a.darkMode;
|
|
2456
2456
|
return darkMode ? GRAY_500 : GRAY_200;
|
|
2457
2457
|
});
|
|
2458
|
-
var templateObject_1$
|
|
2458
|
+
var templateObject_1$6;
|
|
2459
2459
|
|
|
2460
2460
|
var createPaymentMethod = function (_a) {
|
|
2461
2461
|
var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
|
|
@@ -2684,7 +2684,7 @@ var CardIcon = function () {
|
|
|
2684
2684
|
return (jsxs("svg", __assign({ width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [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: SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M1.5 7.5H16.5", stroke: SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
2685
2685
|
};
|
|
2686
2686
|
|
|
2687
|
-
var Text$
|
|
2687
|
+
var Text$c = Typography.Text;
|
|
2688
2688
|
var PaymentMethodSelector = function (_a) {
|
|
2689
2689
|
var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, value = _a.value;
|
|
2690
2690
|
return (jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentPlugin: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
|
|
@@ -2697,9 +2697,9 @@ var PaymentOption = function (_a) {
|
|
|
2697
2697
|
var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
|
|
2698
2698
|
return (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
|
|
2699
2699
|
? "var(--row-background-dark) border-gray-500"
|
|
2700
|
-
: "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$
|
|
2700
|
+
: "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$c, { children: name })] })), isAch ? (jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
|
|
2701
2701
|
};
|
|
2702
|
-
var PaymentOptionContainer = styled.div(templateObject_1$
|
|
2702
|
+
var PaymentOptionContainer = styled.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) {
|
|
2703
2703
|
var $brandColor = _a.$brandColor, $selected = _a.$selected;
|
|
2704
2704
|
return $selected &&
|
|
2705
2705
|
"\n border-color: ".concat($brandColor, ";\n ");
|
|
@@ -2707,34 +2707,44 @@ var PaymentOptionContainer = styled.div(templateObject_1$6 || (templateObject_1$
|
|
|
2707
2707
|
var $brandColor = _a.$brandColor;
|
|
2708
2708
|
return $brandColor;
|
|
2709
2709
|
});
|
|
2710
|
-
var templateObject_1$
|
|
2710
|
+
var templateObject_1$5;
|
|
2711
2711
|
|
|
2712
2712
|
function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
|
|
2713
|
+
var _this = this;
|
|
2713
2714
|
var queryClient = useQueryClient();
|
|
2714
2715
|
var showErrorNotification = useErrorNotification();
|
|
2715
2716
|
var showSuccessNotification = useSuccessNotification();
|
|
2716
|
-
var removePaymentMethod = useCallback(function (data) {
|
|
2717
|
-
var plugin
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2717
|
+
var removePaymentMethod = useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
2718
|
+
var plugin;
|
|
2719
|
+
return __generator(this, function (_a) {
|
|
2720
|
+
switch (_a.label) {
|
|
2721
|
+
case 0:
|
|
2722
|
+
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); });
|
|
2723
|
+
if (!(data && plugin)) return [3 /*break*/, 2];
|
|
2724
|
+
return [4 /*yield*/, invokePlugin({
|
|
2725
|
+
plugin: plugin,
|
|
2726
|
+
method: "remove_payment_method",
|
|
2727
|
+
payload: {
|
|
2728
|
+
payment_method_id: data.id,
|
|
2729
|
+
account_id: accountId,
|
|
2730
|
+
},
|
|
2731
|
+
token: token,
|
|
2732
|
+
apiHost: apiHost,
|
|
2733
|
+
})
|
|
2734
|
+
.then(function () {
|
|
2735
|
+
showSuccessNotification("Payment method was removed", "Success");
|
|
2736
|
+
queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey, null);
|
|
2737
|
+
})
|
|
2738
|
+
.catch(function (error) {
|
|
2739
|
+
showErrorNotification(error.message, "Error removing payment method");
|
|
2740
|
+
})];
|
|
2741
|
+
case 1:
|
|
2742
|
+
_a.sent();
|
|
2743
|
+
_a.label = 2;
|
|
2744
|
+
case 2: return [2 /*return*/];
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
2747
|
+
}); }, [paymentPlugins, token, apiHost, queryClient]);
|
|
2738
2748
|
return removePaymentMethod;
|
|
2739
2749
|
}
|
|
2740
2750
|
|
|
@@ -2801,7 +2811,7 @@ var PaymentForm = function (_a) {
|
|
|
2801
2811
|
//if not paying and payment method is saved, show Collapse
|
|
2802
2812
|
jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-2" }, { children: jsxs(Button, __assign({ onClick: function () {
|
|
2803
2813
|
setShowPaymentMethodForm(true);
|
|
2804
|
-
}, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
|
|
2814
|
+
}, type: "default", className: "w-full", id: "addPaymentMethod" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
|
|
2805
2815
|
};
|
|
2806
2816
|
function StripeWrapper(_a) {
|
|
2807
2817
|
var children = _a.children, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
|
|
@@ -2835,17 +2845,14 @@ function ActualInvoice() {
|
|
|
2835
2845
|
var showSuccessNotification = useSuccessNotification();
|
|
2836
2846
|
var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
|
|
2837
2847
|
// Queries
|
|
2838
|
-
var
|
|
2848
|
+
var formattedInvoice = useQuery({
|
|
2839
2849
|
queryKey: QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
|
|
2840
2850
|
queryFn: function () { return getFormattedInvoice({ id: id, token: token, apiHost: apiHost }); },
|
|
2841
|
-
})
|
|
2851
|
+
}).data;
|
|
2842
2852
|
// Derived state
|
|
2843
2853
|
var isInvoicePayable = PAYABLE_INVOICE_STATES.includes((formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.state) || "");
|
|
2844
2854
|
// Local state
|
|
2845
2855
|
var isMobile = useIsMobile(isInvoicePayable ? BreakpointNumbers.lg : undefined);
|
|
2846
|
-
if (error) {
|
|
2847
|
-
return jsxs("div", { children: ["Error loading invoice: ", error.message] });
|
|
2848
|
-
}
|
|
2849
2856
|
if (!formattedInvoice)
|
|
2850
2857
|
return jsx(Fragment, {});
|
|
2851
2858
|
var onSuccess = function () {
|
|
@@ -2866,7 +2873,7 @@ function ActualInvoice() {
|
|
|
2866
2873
|
}) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost, token: token }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "w-full ".concat(hideDownloadButton || formattedInvoice.isLegacy ? "" : "pt-12") }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice, graphQLClient: graphQLClient }) })))] }))] }));
|
|
2867
2874
|
}
|
|
2868
2875
|
|
|
2869
|
-
var MUTATION$
|
|
2876
|
+
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 }"; };
|
|
2870
2877
|
var getFormattedQuote = function (_a) {
|
|
2871
2878
|
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
2872
2879
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2874,7 +2881,7 @@ var getFormattedQuote = function (_a) {
|
|
|
2874
2881
|
return __generator(this, function (_b) {
|
|
2875
2882
|
switch (_b.label) {
|
|
2876
2883
|
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
2877
|
-
query: MUTATION$
|
|
2884
|
+
query: MUTATION$6(),
|
|
2878
2885
|
token: token,
|
|
2879
2886
|
apiHost: apiHost,
|
|
2880
2887
|
vars: { id: id },
|
|
@@ -2928,24 +2935,18 @@ var useSendAcceptQuote = function (_a) {
|
|
|
2928
2935
|
if (rsp.errors)
|
|
2929
2936
|
console.log("rsp.errors", rsp.errors);
|
|
2930
2937
|
else {
|
|
2931
|
-
console.log("rsp.data.quoteSigningUrlCreate.pluginShortName === 'pandadoc'", rsp.data.quoteSigningUrlCreate.pluginShortName === "pandadoc");
|
|
2932
|
-
console.log("rsp", rsp);
|
|
2933
2938
|
if (rsp.data.quoteSigningUrlCreate.pluginShortName === "dropbox_sign") {
|
|
2934
2939
|
openDropboxSignModal(rsp.data.quoteSigningUrlCreate.pluginClientId, rsp.data.quoteSigningUrlCreate.redirectUri);
|
|
2935
|
-
console.log("dropbox sign is not implemented");
|
|
2936
2940
|
}
|
|
2937
2941
|
else if (rsp.data.quoteSigningUrlCreate.pluginShortName === "pandadoc") {
|
|
2938
2942
|
setPandadocPollingModalVisible(true);
|
|
2939
|
-
console.log("setPandadocPollingModalVisible");
|
|
2940
2943
|
}
|
|
2941
2944
|
else {
|
|
2942
2945
|
window.location.href = rsp.data.quoteSigningUrlCreate.redirectUri;
|
|
2943
|
-
console.log("window.location.href", rsp.data.quoteSigningUrlCreate.redirectUri);
|
|
2944
2946
|
}
|
|
2945
2947
|
}
|
|
2946
2948
|
});
|
|
2947
2949
|
};
|
|
2948
|
-
// TODO: Fix hellosign-embedded window is undefined bug
|
|
2949
2950
|
var openDropboxSignModal = function (clientId, url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2950
2951
|
var HelloSign, client;
|
|
2951
2952
|
return __generator(this, function (_a) {
|
|
@@ -2961,7 +2962,12 @@ var useSendAcceptQuote = function (_a) {
|
|
|
2961
2962
|
clientId: clientId,
|
|
2962
2963
|
});
|
|
2963
2964
|
client.on("sign", function (data) {
|
|
2964
|
-
|
|
2965
|
+
queryClient.refetchQueries({
|
|
2966
|
+
queryKey: QueryKeyFactory.default.createQuoteKey(token, quoteId),
|
|
2967
|
+
});
|
|
2968
|
+
queryClient.refetchQueries({
|
|
2969
|
+
queryKey: QueryKeyFactory.default.createQuoteKey(token),
|
|
2970
|
+
});
|
|
2965
2971
|
});
|
|
2966
2972
|
// Open the DropboxSign modal
|
|
2967
2973
|
client.open(url, {
|
|
@@ -2972,7 +2978,6 @@ var useSendAcceptQuote = function (_a) {
|
|
|
2972
2978
|
}
|
|
2973
2979
|
});
|
|
2974
2980
|
}); };
|
|
2975
|
-
// TODO: update useing fetch
|
|
2976
2981
|
var sendAccept = function (changedFormItems) {
|
|
2977
2982
|
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 }";
|
|
2978
2983
|
var variables = __assign(__assign({}, changedFormItems), { quoteId: quoteId });
|
|
@@ -2981,6 +2986,9 @@ var useSendAcceptQuote = function (_a) {
|
|
|
2981
2986
|
handleAllErrorFormats(rsp.errors);
|
|
2982
2987
|
else {
|
|
2983
2988
|
setAcceptBoxVisible(false);
|
|
2989
|
+
queryClient.invalidateQueries({
|
|
2990
|
+
queryKey: QueryKeyFactory.default.createQuoteKey(token, quoteId),
|
|
2991
|
+
});
|
|
2984
2992
|
queryClient.invalidateQueries({
|
|
2985
2993
|
queryKey: QueryKeyFactory.default.createQuoteKey(token),
|
|
2986
2994
|
});
|
|
@@ -3072,11 +3080,11 @@ var PandadocPollingModal = function (_a) {
|
|
|
3072
3080
|
return (jsxs(Modal, __assign({ title: "Uploading quote to Pandadoc", open: isVisible, closable: false, footer: null }, { children: [jsxs("div", __assign({ className: "py-4 text-center" }, { children: ["This may take a few seconds", ".".repeat(numberOfPolls)] })), jsx("div", __assign({ className: "text-center" }, { children: infoMessage }))] })));
|
|
3073
3081
|
};
|
|
3074
3082
|
|
|
3075
|
-
var ModalOverrideBrandStylings = styled(Modal)(templateObject_1$
|
|
3083
|
+
var ModalOverrideBrandStylings = styled(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"])), MARK_PRO);
|
|
3076
3084
|
var StyledModal$1 = function (props) {
|
|
3077
3085
|
return jsx(ModalOverrideBrandStylings, __assign({ closable: false }, props));
|
|
3078
3086
|
};
|
|
3079
|
-
var templateObject_1$
|
|
3087
|
+
var templateObject_1$4;
|
|
3080
3088
|
|
|
3081
3089
|
var useFocusFirstInput = function (_a) {
|
|
3082
3090
|
var firstInputRef = _a.firstInputRef, isVisible = _a.isVisible;
|
|
@@ -3117,9 +3125,9 @@ var DOCUMENT_NAME;
|
|
|
3117
3125
|
DOCUMENT_NAME["QUOTE"] = "quote";
|
|
3118
3126
|
})(DOCUMENT_NAME || (DOCUMENT_NAME = {}));
|
|
3119
3127
|
|
|
3120
|
-
var Text$
|
|
3128
|
+
var Text$b = Typography.Text;
|
|
3121
3129
|
var documentName = DOCUMENT_NAME.QUOTE;
|
|
3122
|
-
styled.div(templateObject_1$
|
|
3130
|
+
styled.div(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
|
|
3123
3131
|
function Quote(_a) {
|
|
3124
3132
|
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;
|
|
3125
3133
|
return (jsx(HelmetProvider, { children: jsx(InvoiceQuoteContext.Provider, __assign({ value: {
|
|
@@ -3187,7 +3195,7 @@ function ActualQuote(_a) {
|
|
|
3187
3195
|
documentName: documentName,
|
|
3188
3196
|
}) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedQuote.vendorName) })] }), jsxs("div", __assign({ className: "flex flex-col gap-4 ".concat(isMobile ? "w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [jsxs("div", __assign({ className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
|
|
3189
3197
|
color: entityBranding.secondaryColor,
|
|
3190
|
-
} }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$
|
|
3198
|
+
} }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$b, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxs("div", __assign({ className: isMobile
|
|
3191
3199
|
? "flex w-full justify-end gap-2"
|
|
3192
3200
|
: "flex items-center justify-end gap-2" }, { children: [!isMobile && !hideDownloadButton ? (jsx(Button, __assign({ icon: jsx(DownloadOutlined$1, {}), onClick: function () {
|
|
3193
3201
|
return downloadFile(apiHost + "/api/pdf/quote", token);
|
|
@@ -3195,7 +3203,7 @@ function ActualQuote(_a) {
|
|
|
3195
3203
|
return (jsx(Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
|
|
3196
3204
|
}) }))) : null }))] })), jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept }), jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
|
|
3197
3205
|
}
|
|
3198
|
-
var templateObject_1$
|
|
3206
|
+
var templateObject_1$3;
|
|
3199
3207
|
|
|
3200
3208
|
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 }"); };
|
|
3201
3209
|
var getQuotes = function (_a) {
|
|
@@ -3218,7 +3226,7 @@ var getQuotes = function (_a) {
|
|
|
3218
3226
|
});
|
|
3219
3227
|
};
|
|
3220
3228
|
|
|
3221
|
-
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}"); };
|
|
3229
|
+
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}"); };
|
|
3222
3230
|
var getTransactions = function (filter, token, apiHost) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3223
3231
|
var response, _a, data, errors;
|
|
3224
3232
|
return __generator(this, function (_b) {
|
|
@@ -3282,10 +3290,10 @@ var getColor = function (state) {
|
|
|
3282
3290
|
}
|
|
3283
3291
|
};
|
|
3284
3292
|
|
|
3285
|
-
var Text$
|
|
3293
|
+
var Text$a = Typography.Text;
|
|
3286
3294
|
var TransactionDate = function (_a) {
|
|
3287
3295
|
var date = _a.date;
|
|
3288
|
-
return jsx(Text$
|
|
3296
|
+
return jsx(Text$a, __assign({ className: "text-sm" }, { children: formatDate(date) }));
|
|
3289
3297
|
};
|
|
3290
3298
|
|
|
3291
3299
|
// TODO: delete
|
|
@@ -3316,13 +3324,13 @@ var TransactionGridCell = styled.div.withConfig({
|
|
|
3316
3324
|
shouldForwardProp: function (prop) {
|
|
3317
3325
|
return !["gridColumn", "padding", "right"].includes(prop);
|
|
3318
3326
|
},
|
|
3319
|
-
})(templateObject_1$
|
|
3320
|
-
var templateObject_1$
|
|
3327
|
+
})(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"); }, SLATE_600);
|
|
3328
|
+
var templateObject_1$2;
|
|
3321
3329
|
|
|
3322
|
-
var Text$
|
|
3330
|
+
var Text$9 = Typography.Text;
|
|
3323
3331
|
var TransactionsEmptyState = function () {
|
|
3324
3332
|
var noTransactionsMessage = useContext(TransactionsListContext).noTransactionsMessage;
|
|
3325
|
-
return (jsx(Text$
|
|
3333
|
+
return (jsx(Text$9, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
|
|
3326
3334
|
};
|
|
3327
3335
|
|
|
3328
3336
|
var isInvoice = function (transaction) {
|
|
@@ -3339,11 +3347,27 @@ var TransactionRowTitle = function (_a) {
|
|
|
3339
3347
|
return (jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
|
|
3340
3348
|
};
|
|
3341
3349
|
|
|
3342
|
-
|
|
3350
|
+
function transactionDateToDisplay(transaction, transactionDateType) {
|
|
3351
|
+
var _a, _b;
|
|
3352
|
+
if (transaction.kind === "PAYMENT") {
|
|
3353
|
+
return transaction.createdAt;
|
|
3354
|
+
}
|
|
3355
|
+
else if (transactionDateType === "dueAt") {
|
|
3356
|
+
return (_a = transaction.transactionable) === null || _a === void 0 ? void 0 : _a.dueAt;
|
|
3357
|
+
}
|
|
3358
|
+
else if (transactionDateType === "issuedAt") {
|
|
3359
|
+
return (_b = transaction.transactionable) === null || _b === void 0 ? void 0 : _b.issuedAt;
|
|
3360
|
+
}
|
|
3361
|
+
else {
|
|
3362
|
+
return transaction.createdAt;
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
var Text$8 = Typography.Text;
|
|
3343
3367
|
var TransactionsListDesktop = function (_a) {
|
|
3344
3368
|
var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
|
|
3345
|
-
var
|
|
3346
|
-
var
|
|
3369
|
+
var _b = useContext(TransactionsListContext), columns = _b.columns, transactionDateType = _b.transactionDateType;
|
|
3370
|
+
var _c = useContext(BunnyContext), apiHost = _c.apiHost, darkMode = _c.darkMode;
|
|
3347
3371
|
var token = useToken();
|
|
3348
3372
|
var showAmount = columns.includes("amount");
|
|
3349
3373
|
var showDateAndTitle = columns.includes("date-and-title");
|
|
@@ -3351,24 +3375,27 @@ var TransactionsListDesktop = function (_a) {
|
|
|
3351
3375
|
var showState = columns.includes("state");
|
|
3352
3376
|
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
3353
3377
|
return jsx(TransactionsEmptyState, {});
|
|
3354
|
-
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3378
|
+
return (jsx(Fragment, { children: transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3379
|
+
var _a;
|
|
3380
|
+
var isClickable = onTransactionClick !== undefined;
|
|
3381
|
+
return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
3382
|
+
onTransactionClick === null || onTransactionClick === void 0 ? void 0 : onTransactionClick(transaction);
|
|
3383
|
+
}, style: {
|
|
3384
|
+
backgroundColor: index % 2 === 0
|
|
3385
|
+
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
3386
|
+
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
3387
|
+
} }, { children: [!showDateAndTitle &&
|
|
3388
|
+
!showState &&
|
|
3389
|
+
!showAmount &&
|
|
3390
|
+
!showDownload && (jsx(TransactionGridCell, { children: jsx(Text$8, { children: "No columns selected" }) })), showDateAndTitle && (jsxs(Fragment, { children: [jsx(TransactionGridCell, __assign({ right: false }, { children: jsx(TransactionDate, { date: transactionDateToDisplay(transaction, transactionDateType) }) })), jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsx(Text$8, { children: capitalize(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsx(TransactionGridCell, { children: jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })), showState ? (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(StateTag, { state: transaction.state }) }))) : null, showAmount && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(Text$8, { children: formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
|
|
3391
|
+
}) }));
|
|
3365
3392
|
};
|
|
3366
3393
|
|
|
3367
|
-
var Text$
|
|
3394
|
+
var Text$7 = Typography.Text;
|
|
3368
3395
|
var TransactionsListMobile = function (_a) {
|
|
3369
3396
|
var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
|
|
3370
|
-
var
|
|
3371
|
-
var
|
|
3397
|
+
var _b = useContext(TransactionsListContext), columns = _b.columns, transactionDateType = _b.transactionDateType;
|
|
3398
|
+
var _c = useContext(BunnyContext), apiHost = _c.apiHost, darkMode = _c.darkMode;
|
|
3372
3399
|
var token = useToken();
|
|
3373
3400
|
var showAmount = columns.includes("amount");
|
|
3374
3401
|
var showDateAndTitle = columns.includes("date-and-title");
|
|
@@ -3376,19 +3403,20 @@ var TransactionsListMobile = function (_a) {
|
|
|
3376
3403
|
var showState = columns.includes("state");
|
|
3377
3404
|
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
3378
3405
|
return jsx(TransactionsEmptyState, {});
|
|
3379
|
-
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3406
|
+
return (jsx(Fragment, { children: transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3407
|
+
var isClickable = transaction.kind === "INVOICE";
|
|
3408
|
+
return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
3409
|
+
onTransactionClick(transaction);
|
|
3410
|
+
}, style: {
|
|
3411
|
+
backgroundColor: index % 2 === 0
|
|
3412
|
+
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
3413
|
+
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
3414
|
+
} }, { children: [jsx(TransactionGridCell, { children: jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxs(Fragment, { children: [jsx(Text$7, { children: capitalize(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] })), showState && jsx(StateTag, { state: transaction.state })] })), jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsx(TransactionDate, { date: transactionDateToDisplay(transaction, transactionDateType) })), showAmount && showDateAndTitle && jsx(Text$7, { children: "\u00B7" }), showAmount && (jsx(Text$7, { children: formatCurrency(transaction.transactionable.amount ||
|
|
3415
|
+
transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })))] }), index));
|
|
3416
|
+
}) }));
|
|
3389
3417
|
};
|
|
3390
3418
|
|
|
3391
|
-
var Text$
|
|
3419
|
+
var Text$6 = Typography.Text;
|
|
3392
3420
|
var DISPLAY_WIDTH = 1200;
|
|
3393
3421
|
function Transactions(_a) {
|
|
3394
3422
|
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 ? [
|
|
@@ -3398,7 +3426,7 @@ function Transactions(_a) {
|
|
|
3398
3426
|
TransactionKind.WRITE_OFF,
|
|
3399
3427
|
] : _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) {
|
|
3400
3428
|
return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
|
3401
|
-
} : _k;
|
|
3429
|
+
} : _k, _l = _a.transactionDateType, transactionDateType = _l === void 0 ? "createdAt" : _l;
|
|
3402
3430
|
var contextValues = {
|
|
3403
3431
|
showSearchBar: showSearchBar,
|
|
3404
3432
|
showTitle: showTitle,
|
|
@@ -3418,11 +3446,12 @@ function Transactions(_a) {
|
|
|
3418
3446
|
entityId: entityId,
|
|
3419
3447
|
filterTransactions: filterTransactions,
|
|
3420
3448
|
sortTransactions: sortTransactions,
|
|
3449
|
+
transactionDateType: transactionDateType,
|
|
3421
3450
|
};
|
|
3422
3451
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
3423
3452
|
var token = useToken();
|
|
3424
3453
|
// Local state
|
|
3425
|
-
var
|
|
3454
|
+
var _m = useState(""), search = _m[0], setSearch = _m[1];
|
|
3426
3455
|
var filterValue = filter ||
|
|
3427
3456
|
(search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
|
|
3428
3457
|
// Queries
|
|
@@ -3436,7 +3465,7 @@ function Transactions(_a) {
|
|
|
3436
3465
|
function TransactionsDisplay(_a) {
|
|
3437
3466
|
var _b, _c;
|
|
3438
3467
|
var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search;
|
|
3439
|
-
var _d = 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;
|
|
3468
|
+
var _d = 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;
|
|
3440
3469
|
var columns = useContext(TransactionsListContext).columns;
|
|
3441
3470
|
var darkMode = useContext(BunnyContext).darkMode;
|
|
3442
3471
|
var secondaryColor = useContext(BrandContext).secondaryColor;
|
|
@@ -3497,7 +3526,7 @@ function TransactionsDisplay(_a) {
|
|
|
3497
3526
|
onTransactionDisplayClose === null || onTransactionDisplayClose === void 0 ? void 0 : onTransactionDisplayClose(selectedTransaction);
|
|
3498
3527
|
setDrawerOpen(false);
|
|
3499
3528
|
}
|
|
3500
|
-
return (jsxs("div", __assign({ style: style }, { children: [jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsx(Text$
|
|
3529
|
+
return (jsxs("div", __assign({ style: style }, { children: [jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsx(Text$6, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title }))) : (jsx("div", {}) // Empty div so justify-between works
|
|
3501
3530
|
), showSearchBar && (jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "") }, { children: jsx(Input, { className: searchBarClassName
|
|
3502
3531
|
? searchBarClassName
|
|
3503
3532
|
: "border border-slate-200", onChange: function (e) {
|
|
@@ -3510,13 +3539,7 @@ function TransactionsDisplay(_a) {
|
|
|
3510
3539
|
}, value: search }) })))] }))) : null, jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat(shadow), style: {
|
|
3511
3540
|
gridTemplateColumns: gridTemplateColumns(),
|
|
3512
3541
|
backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
|
|
3513
|
-
} }, { children: isMobile ? (jsx(
|
|
3514
|
-
transactions: updatedTransactions,
|
|
3515
|
-
onTransactionClick: handleTransactionClick,
|
|
3516
|
-
}) })) : (jsx(Fragment, { children: TransactionsListDesktop({
|
|
3517
|
-
transactions: updatedTransactions,
|
|
3518
|
-
onTransactionClick: handleTransactionClick,
|
|
3519
|
-
}) })) }))] })), useModal ? (jsx(Modal, __assign({ title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxs(Card$1, __assign({ className: "shadow-md" }, { children: [jsx(Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Amount:" }), " ", jsx(Typography.Text, { children: formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Description:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Kind:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "State:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
|
|
3542
|
+
} }, { children: isMobile ? (jsx(TransactionsListMobile, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) : (jsx(TransactionsListDesktop, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) }))] })), useModal ? (jsx(Modal, __assign({ title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxs(Card$1, __assign({ className: "shadow-md" }, { children: [jsx(Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Amount:" }), " ", jsx(Typography.Text, { children: formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Description:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Kind:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "State:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
|
|
3520
3543
|
}
|
|
3521
3544
|
|
|
3522
3545
|
function Quotes(_a) {
|
|
@@ -3549,6 +3572,7 @@ function Quotes(_a) {
|
|
|
3549
3572
|
sortTransactions: sort,
|
|
3550
3573
|
downloadTransactionLink: function (id) { return "".concat(apiHost, "/api/pdf/quote/").concat(id); },
|
|
3551
3574
|
entityId: entityId,
|
|
3575
|
+
transactionDateType: "createdAt", // Required for the transactions list, but doesn't affect quotes
|
|
3552
3576
|
};
|
|
3553
3577
|
function quoteStateRenderer(state) {
|
|
3554
3578
|
var getColor = function (state) {
|
|
@@ -3614,10 +3638,10 @@ function QuotesWrapper() {
|
|
|
3614
3638
|
return (jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
|
|
3615
3639
|
}
|
|
3616
3640
|
|
|
3617
|
-
var Text$
|
|
3641
|
+
var Text$5 = Typography.Text;
|
|
3618
3642
|
var DrawerHeader = function (_a) {
|
|
3619
3643
|
var description = _a.description, onClose = _a.onClose, title = _a.title;
|
|
3620
|
-
return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx(Text$
|
|
3644
|
+
return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx(Text$5, __assign({ className: "text-xl", style: { fontWeight: 400 } }, { children: title })), jsx("button", __assign({ onClick: onClose, className: "ant-drawer-close" }, { children: jsx(CloseOutlined$1, {}) }))] })), description && jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
|
|
3621
3645
|
};
|
|
3622
3646
|
|
|
3623
3647
|
var PaymentMethod = function (_a) {
|
|
@@ -3643,7 +3667,16 @@ var PaymentMethod = function (_a) {
|
|
|
3643
3667
|
};
|
|
3644
3668
|
if (data === undefined)
|
|
3645
3669
|
return jsx(Fragment, {});
|
|
3646
|
-
return (jsxs("div", __assign({ className: "".concat(className) }, { children: [data ? (jsx(CreditCard, { onClickRemove: function () { return
|
|
3670
|
+
return (jsxs("div", __assign({ className: "".concat(className) }, { children: [data ? (jsx(CreditCard, { onClickRemove: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3671
|
+
return __generator(this, function (_a) {
|
|
3672
|
+
switch (_a.label) {
|
|
3673
|
+
case 0: return [4 /*yield*/, onClickRemove(data)];
|
|
3674
|
+
case 1:
|
|
3675
|
+
_a.sent();
|
|
3676
|
+
return [2 /*return*/];
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
}); }, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data, shadow: shadow, cardEnabled: cardEnabled })) : (jsx(EmptyCard, { onClick: function () { return setShowModal(true); }, shadow: shadow, cardEnabled: cardEnabled })), jsx(Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
|
|
3647
3680
|
body: isMobile
|
|
3648
3681
|
? {
|
|
3649
3682
|
padding: "1rem 0 0",
|
|
@@ -3689,7 +3722,7 @@ var quoteRecalculateTaxes = function (_a) {
|
|
|
3689
3722
|
});
|
|
3690
3723
|
};
|
|
3691
3724
|
|
|
3692
|
-
var MUTATION$
|
|
3725
|
+
var MUTATION$5 = "{\n currentUser {\n taxationRequiredAccountFields\n }\n}";
|
|
3693
3726
|
var getTaxationRequiredAccountFields = function (_a) {
|
|
3694
3727
|
var token = _a.token, apiHost = _a.apiHost;
|
|
3695
3728
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3698,7 +3731,7 @@ var getTaxationRequiredAccountFields = function (_a) {
|
|
|
3698
3731
|
return __generator(this, function (_d) {
|
|
3699
3732
|
switch (_d.label) {
|
|
3700
3733
|
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
3701
|
-
query: MUTATION$
|
|
3734
|
+
query: MUTATION$5,
|
|
3702
3735
|
token: token,
|
|
3703
3736
|
apiHost: apiHost,
|
|
3704
3737
|
})];
|
|
@@ -3723,7 +3756,7 @@ var useHasTaxPlugin = function (_a) {
|
|
|
3723
3756
|
return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
|
|
3724
3757
|
};
|
|
3725
3758
|
|
|
3726
|
-
var MUTATION$
|
|
3759
|
+
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";
|
|
3727
3760
|
var accountUpdate = function (_a) {
|
|
3728
3761
|
var accountId = _a.accountId, attributes = _a.attributes, token = _a.token, apiHost = _a.apiHost;
|
|
3729
3762
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3734,7 +3767,7 @@ var accountUpdate = function (_a) {
|
|
|
3734
3767
|
case 0:
|
|
3735
3768
|
vars = { id: accountId, attributes: attributes };
|
|
3736
3769
|
return [4 /*yield*/, gqlRequest$1({
|
|
3737
|
-
query: MUTATION$
|
|
3770
|
+
query: MUTATION$4,
|
|
3738
3771
|
token: token,
|
|
3739
3772
|
vars: vars,
|
|
3740
3773
|
apiHost: apiHost,
|
|
@@ -3915,7 +3948,7 @@ var Checkout = function (_a) {
|
|
|
3915
3948
|
}, onPaymentSuccess: onSuccess, graphQLClient: graphQLClient }))] }))] })) })));
|
|
3916
3949
|
};
|
|
3917
3950
|
|
|
3918
|
-
var MUTATION$
|
|
3951
|
+
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}"; };
|
|
3919
3952
|
var accountSignup = function (_a) {
|
|
3920
3953
|
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;
|
|
3921
3954
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3934,7 +3967,7 @@ var accountSignup = function (_a) {
|
|
|
3934
3967
|
priceListCode: priceListCode,
|
|
3935
3968
|
};
|
|
3936
3969
|
return [4 /*yield*/, gqlRequest({
|
|
3937
|
-
query: MUTATION$
|
|
3970
|
+
query: MUTATION$3(),
|
|
3938
3971
|
token: token,
|
|
3939
3972
|
vars: vars,
|
|
3940
3973
|
apiHost: apiHost,
|
|
@@ -3950,7 +3983,7 @@ var accountSignup = function (_a) {
|
|
|
3950
3983
|
});
|
|
3951
3984
|
};
|
|
3952
3985
|
|
|
3953
|
-
var MUTATION$
|
|
3986
|
+
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}"; };
|
|
3954
3987
|
var quoteAccountSignup = function (_a) {
|
|
3955
3988
|
var token = _a.token, apiHost = _a.apiHost, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
|
|
3956
3989
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3966,7 +3999,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3966
3999
|
billingContact: billingContact,
|
|
3967
4000
|
};
|
|
3968
4001
|
return [4 /*yield*/, gqlRequest({
|
|
3969
|
-
query: MUTATION$
|
|
4002
|
+
query: MUTATION$2(),
|
|
3970
4003
|
token: token,
|
|
3971
4004
|
vars: vars,
|
|
3972
4005
|
apiHost: apiHost,
|
|
@@ -3982,7 +4015,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3982
4015
|
});
|
|
3983
4016
|
};
|
|
3984
4017
|
|
|
3985
|
-
var MUTATION$
|
|
4018
|
+
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}"; };
|
|
3986
4019
|
var getPriceList = function (_a) {
|
|
3987
4020
|
var token = _a.token, code = _a.code, apiHost = _a.apiHost;
|
|
3988
4021
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3990,7 +4023,7 @@ var getPriceList = function (_a) {
|
|
|
3990
4023
|
return __generator(this, function (_b) {
|
|
3991
4024
|
switch (_b.label) {
|
|
3992
4025
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
3993
|
-
query: MUTATION$
|
|
4026
|
+
query: MUTATION$1(),
|
|
3994
4027
|
token: token,
|
|
3995
4028
|
vars: { code: code },
|
|
3996
4029
|
apiHost: apiHost,
|
|
@@ -4024,19 +4057,19 @@ function InitialSignupForm(_a) {
|
|
|
4024
4057
|
] }, { children: jsx(Input, { placeholder: "Account name" }) }))] })), jsx(Form.Item, { children: jsx(Button, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
|
|
4025
4058
|
}
|
|
4026
4059
|
|
|
4027
|
-
var Title = Typography.Title, Text$
|
|
4060
|
+
var Title = Typography.Title, Text$4 = Typography.Text;
|
|
4028
4061
|
function PaymentSuccessDisplay(_a) {
|
|
4029
4062
|
var amountPaid = _a.amountPaid, className = _a.className, companyName = _a.companyName, returnUrl = _a.returnUrl, style = _a.style;
|
|
4030
|
-
return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxs(Text$
|
|
4063
|
+
return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxs(Text$4, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
|
|
4031
4064
|
}
|
|
4032
4065
|
|
|
4033
|
-
var Text$
|
|
4066
|
+
var Text$3 = Typography.Text;
|
|
4034
4067
|
function PriceListDisplay(_a) {
|
|
4035
4068
|
var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
|
|
4036
4069
|
if (!priceListData)
|
|
4037
4070
|
return null;
|
|
4038
4071
|
console.log("topNavImageUrl", topNavImageUrl);
|
|
4039
|
-
return (jsx(Fragment, { children: jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsx(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsx(Text$
|
|
4072
|
+
return (jsx(Fragment, { children: jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsx(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsx(Text$3, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$3, __assign({ className: "font-bold text-xl" }, { children: [formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), priceListData.trialAllowed ? (jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$3, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), 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] })) })) }));
|
|
4040
4073
|
}
|
|
4041
4074
|
|
|
4042
4075
|
var showErrorNotification = useErrorNotification();
|
|
@@ -4152,60 +4185,9 @@ function Signup(_a) {
|
|
|
4152
4185
|
: "w-1/2 items-center justify-center my-12") }, { children: jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2") }, { children: jsx(PaymentForms, { entityId: entityId, quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction }) })) }))] }))) })));
|
|
4153
4186
|
}
|
|
4154
4187
|
|
|
4155
|
-
|
|
4156
|
-
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 }";
|
|
4157
|
-
var getPlanChangeOptions = function (_a) {
|
|
4158
|
-
var isInPreviewMode = _a.isInPreviewMode, token = _a.token, upgradingSubscription = _a.upgradingSubscription, apiHost = _a.apiHost;
|
|
4159
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4160
|
-
var response, planChangeOptions;
|
|
4161
|
-
return __generator(this, function (_b) {
|
|
4162
|
-
switch (_b.label) {
|
|
4163
|
-
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
4164
|
-
isInPreviewMode: isInPreviewMode,
|
|
4165
|
-
query: PLAN_CHANGE_OPTIONS_QUERY,
|
|
4166
|
-
vars: { subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id },
|
|
4167
|
-
token: token,
|
|
4168
|
-
apiHost: apiHost,
|
|
4169
|
-
})];
|
|
4170
|
-
case 1:
|
|
4171
|
-
response = _b.sent();
|
|
4172
|
-
planChangeOptions = response.planChangeOptions;
|
|
4173
|
-
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.errors)
|
|
4174
|
-
throw planChangeOptions.errors;
|
|
4175
|
-
// Sort planChangeOptions.plans by position
|
|
4176
|
-
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.plans) {
|
|
4177
|
-
planChangeOptions.plans.sort(function (a, b) { return a.position - b.position; });
|
|
4178
|
-
}
|
|
4179
|
-
return [2 /*return*/, planChangeOptions];
|
|
4180
|
-
}
|
|
4181
|
-
});
|
|
4182
|
-
});
|
|
4183
|
-
};
|
|
4184
|
-
|
|
4185
|
-
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 }"; };
|
|
4186
|
-
var getQuote = function (_a) {
|
|
4187
|
-
var id = _a.id, token = _a.token, apiHost = _a.apiHost;
|
|
4188
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4189
|
-
var response;
|
|
4190
|
-
return __generator(this, function (_b) {
|
|
4191
|
-
switch (_b.label) {
|
|
4192
|
-
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
4193
|
-
query: QUOTE_QUERY(),
|
|
4194
|
-
token: token,
|
|
4195
|
-
vars: { id: id },
|
|
4196
|
-
apiHost: apiHost,
|
|
4197
|
-
})];
|
|
4198
|
-
case 1:
|
|
4199
|
-
response = _b.sent();
|
|
4200
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quote];
|
|
4201
|
-
}
|
|
4202
|
-
});
|
|
4203
|
-
});
|
|
4204
|
-
};
|
|
4205
|
-
|
|
4206
|
-
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 }";
|
|
4188
|
+
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 }";
|
|
4207
4189
|
var getSubscriptions = function (_a) {
|
|
4208
|
-
var
|
|
4190
|
+
var apiHost = _a.apiHost, entityId = _a.entityId, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
4209
4191
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
4210
4192
|
var response;
|
|
4211
4193
|
var _b;
|
|
@@ -4231,44 +4213,56 @@ var useSubscriptions = function (_a) {
|
|
|
4231
4213
|
return useMemo(function () {
|
|
4232
4214
|
var combinedSubscriptions = data === null || data === void 0 ? void 0 : data.map(function (subscription) {
|
|
4233
4215
|
var _a;
|
|
4234
|
-
var
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4216
|
+
var orderedSubscriptionCharges = subscription.charges.sort(function (a, b) {
|
|
4217
|
+
if (a.priceListChargeId !== b.priceListChargeId) {
|
|
4218
|
+
return a.priceListChargeId.localeCompare(b.priceListChargeId);
|
|
4219
|
+
}
|
|
4220
|
+
if (a.kind === SubscriptionChargeKind.DISCOUNT &&
|
|
4221
|
+
b.kind !== SubscriptionChargeKind.DISCOUNT) {
|
|
4222
|
+
return 1;
|
|
4223
|
+
}
|
|
4224
|
+
if (a.kind !== SubscriptionChargeKind.DISCOUNT &&
|
|
4225
|
+
b.kind === SubscriptionChargeKind.DISCOUNT) {
|
|
4226
|
+
return -1;
|
|
4227
|
+
}
|
|
4228
|
+
return (a.endDate.localeCompare(b.endDate) ||
|
|
4229
|
+
a.startDate.localeCompare(b.startDate));
|
|
4239
4230
|
});
|
|
4240
|
-
var isTrial = ((_a =
|
|
4231
|
+
var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
4241
4232
|
var combinedSubscriptionCharges = [];
|
|
4242
4233
|
var aggregationCharge;
|
|
4243
4234
|
for (var index = 0; index < orderedSubscriptionCharges.length; index++) {
|
|
4244
4235
|
var charge = orderedSubscriptionCharges[index];
|
|
4245
4236
|
var nextCharge = orderedSubscriptionCharges[index + 1];
|
|
4246
|
-
// Initialize aggregationCharge if it is not already set
|
|
4247
4237
|
if (!aggregationCharge)
|
|
4248
4238
|
aggregationCharge = charge;
|
|
4249
|
-
// If the next charge
|
|
4239
|
+
// If the next charge is the same priceListChargeId and endDate, aggregate the quantities
|
|
4250
4240
|
if (nextCharge &&
|
|
4251
4241
|
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
4252
|
-
charge.endDate === nextCharge.endDate
|
|
4242
|
+
charge.endDate === nextCharge.endDate &&
|
|
4243
|
+
charge.startDate === nextCharge.startDate &&
|
|
4244
|
+
charge.kind === nextCharge.kind) {
|
|
4253
4245
|
aggregationCharge.quantity += nextCharge.quantity;
|
|
4246
|
+
// If the next charge is different, push the aggregationCharge to the combinedSubscriptionCharges
|
|
4254
4247
|
}
|
|
4255
|
-
// If the next charge exists, has the same priceListChargeId but different endDate, and matches the trial state, push the current aggregationCharge and reset it
|
|
4256
4248
|
else if (nextCharge &&
|
|
4257
4249
|
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
4258
|
-
charge.endDate !== nextCharge.endDate
|
|
4250
|
+
(charge.endDate !== nextCharge.endDate ||
|
|
4251
|
+
charge.startDate !== nextCharge.startDate) &&
|
|
4252
|
+
charge.kind === nextCharge.kind &&
|
|
4259
4253
|
(!isTrial || charge.trial) &&
|
|
4260
4254
|
(isTrial || !charge.trial)) {
|
|
4255
|
+
nextCharge.name = "";
|
|
4261
4256
|
combinedSubscriptionCharges.push(aggregationCharge);
|
|
4262
4257
|
aggregationCharge = undefined;
|
|
4263
4258
|
}
|
|
4264
|
-
// If the next charge does not match the above conditions, push the current aggregationCharge and reset it
|
|
4265
4259
|
else {
|
|
4266
4260
|
combinedSubscriptionCharges.push(aggregationCharge);
|
|
4267
4261
|
aggregationCharge = undefined;
|
|
4268
4262
|
}
|
|
4269
4263
|
}
|
|
4270
|
-
|
|
4271
|
-
return
|
|
4264
|
+
subscription.charges = combinedSubscriptionCharges;
|
|
4265
|
+
return subscription;
|
|
4272
4266
|
});
|
|
4273
4267
|
var subscriptionOrder = Object.values(SubscriptionState$2);
|
|
4274
4268
|
combinedSubscriptions === null || combinedSubscriptions === void 0 ? void 0 : combinedSubscriptions.sort(function (a, b) {
|
|
@@ -4283,38 +4277,6 @@ var ErrorView = function (_a) {
|
|
|
4283
4277
|
return (jsxs("div", __assign({ className: "flex flex-col w-full", style: { marginTop: "80px" } }, { children: [jsx("div", __assign({ style: { fontSize: "32px" } }, { children: message })), children] })));
|
|
4284
4278
|
};
|
|
4285
4279
|
|
|
4286
|
-
var Text$4 = Typography.Text;
|
|
4287
|
-
var PageHeaderWithActions = function (_a) {
|
|
4288
|
-
var children = _a.children, title = _a.title, className = _a.className;
|
|
4289
|
-
var isMobile = useIsMobile();
|
|
4290
|
-
return (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: [jsx(PageSubTitle, { title: title }), children] })));
|
|
4291
|
-
};
|
|
4292
|
-
var PageSubTitle = function (_a) {
|
|
4293
|
-
var title = _a.title;
|
|
4294
|
-
var secondaryColor = useContext(BrandContext).secondaryColor;
|
|
4295
|
-
var darkMode = useContext(BunnyContext).darkMode;
|
|
4296
|
-
return (jsx(Text$4, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
|
|
4297
|
-
};
|
|
4298
|
-
|
|
4299
|
-
var Text$3 = Typography.Text;
|
|
4300
|
-
var HideExpiredToggle = function (_a) {
|
|
4301
|
-
var hideExpired = _a.hideExpired, setHideExpired = _a.setHideExpired, subscriptions = _a.subscriptions;
|
|
4302
|
-
var isMobile = useIsMobile();
|
|
4303
|
-
var secondaryColor = useContext(BrandContext).secondaryColor;
|
|
4304
|
-
var hasExpiredOrCanceledSubscriptions = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
4305
|
-
var _a, _b;
|
|
4306
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.EXPIRED ||
|
|
4307
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.CANCELED;
|
|
4308
|
-
});
|
|
4309
|
-
if (!hasExpiredOrCanceledSubscriptions)
|
|
4310
|
-
return null;
|
|
4311
|
-
return (jsxs("div", __assign({ className: "flex items-center gap-4 pl-4" }, { children: [!isMobile && jsx(Divider, { className: "h-5", type: "vertical" }), jsx(StyledCheckbox, { children: jsx(Checkbox, __assign({ checked: hideExpired, onChange: function (e) { return setHideExpired(e.target.checked); }, style: {
|
|
4312
|
-
color: secondaryColor,
|
|
4313
|
-
} }, { children: jsx(Text$3, { children: isMobile ? "Hide inactive" : "Hide inactive subscriptions" }) })) })] })));
|
|
4314
|
-
};
|
|
4315
|
-
var StyledCheckbox = styled.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"])));
|
|
4316
|
-
var templateObject_1$2;
|
|
4317
|
-
|
|
4318
4280
|
var SubscriptionState;
|
|
4319
4281
|
(function (SubscriptionState) {
|
|
4320
4282
|
SubscriptionState["ACTIVE"] = "ACTIVE";
|
|
@@ -4512,57 +4474,6 @@ var templateObject_1;
|
|
|
4512
4474
|
|
|
4513
4475
|
var SubscriptionsContext = createContext({});
|
|
4514
4476
|
|
|
4515
|
-
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";
|
|
4516
|
-
var getGuoteSubscriptionReinstate = function (_a) {
|
|
4517
|
-
var ids = _a.ids, token = _a.token, apiHost = _a.apiHost;
|
|
4518
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
4519
|
-
var vars, response, _b, errors, quote;
|
|
4520
|
-
return __generator(this, function (_c) {
|
|
4521
|
-
switch (_c.label) {
|
|
4522
|
-
case 0:
|
|
4523
|
-
vars = { ids: ids };
|
|
4524
|
-
return [4 /*yield*/, gqlRequest$1({
|
|
4525
|
-
query: MUTATION$1,
|
|
4526
|
-
token: token,
|
|
4527
|
-
vars: vars,
|
|
4528
|
-
apiHost: apiHost,
|
|
4529
|
-
})];
|
|
4530
|
-
case 1:
|
|
4531
|
-
response = _c.sent();
|
|
4532
|
-
_b = response === null || response === void 0 ? void 0 : response.quoteSubscriptionReinstate, errors = _b.errors, quote = _b.quote;
|
|
4533
|
-
if (errors)
|
|
4534
|
-
throw errors;
|
|
4535
|
-
return [2 /*return*/, quote];
|
|
4536
|
-
}
|
|
4537
|
-
});
|
|
4538
|
-
});
|
|
4539
|
-
};
|
|
4540
|
-
|
|
4541
|
-
// import { EditingSubscriptionType } from "../../../features/quantityChangeDrawer/QuantityInput";
|
|
4542
|
-
var canShowQuantitiesInput = function (charge, subscription) {
|
|
4543
|
-
// Check if the subscription is active, pending, or in trial,
|
|
4544
|
-
// the pricing model is not flat,
|
|
4545
|
-
// and if it's not a trial, also check if the current charge is the last one in the subscription.
|
|
4546
|
-
var _a, _b, _c;
|
|
4547
|
-
var isActiveSubscription = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.ACTIVE;
|
|
4548
|
-
var isPendingSubscription = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.PENDING;
|
|
4549
|
-
var isTrialSubscription = ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
4550
|
-
var isFlatPricing = charge.pricingModel === "FLAT";
|
|
4551
|
-
var shouldProcessCharge = (isActiveSubscription || isPendingSubscription || isTrialSubscription) &&
|
|
4552
|
-
!isFlatPricing &&
|
|
4553
|
-
charge.selfServiceQuantity &&
|
|
4554
|
-
!charge.expired;
|
|
4555
|
-
// Now you can use the value of shouldProcessCharge to determine whether to process the charge.
|
|
4556
|
-
return shouldProcessCharge;
|
|
4557
|
-
};
|
|
4558
|
-
var canShowChangeQuantities = function (_a) {
|
|
4559
|
-
var subscriptions = _a.subscriptions;
|
|
4560
|
-
return subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.some(function (subscription) {
|
|
4561
|
-
return subscription.charges.some(function (charge, chargeIndex) {
|
|
4562
|
-
return canShowQuantitiesInput(charge, subscription);
|
|
4563
|
-
});
|
|
4564
|
-
});
|
|
4565
|
-
};
|
|
4566
4477
|
var isSubscriptionNotActive = function (subscription) {
|
|
4567
4478
|
var _a, _b;
|
|
4568
4479
|
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.EXPIRED ||
|
|
@@ -4576,69 +4487,13 @@ var canShowSubscriptionActions = function (subscription) {
|
|
|
4576
4487
|
|
|
4577
4488
|
var SubscriptionCardActions = function (_a) {
|
|
4578
4489
|
var _b, _c;
|
|
4579
|
-
var
|
|
4580
|
-
// Context
|
|
4581
|
-
var apiHost = useContext(BunnyContext).apiHost;
|
|
4582
|
-
var token = useToken();
|
|
4583
|
-
var _d = useContext(SubscriptionsContext), onChangePlanClick = _d.onChangePlanClick, onClickUpgrade = _d.onClickUpgrade, isTempViewOnly = _d.isTempViewOnly;
|
|
4584
|
-
// Hooks
|
|
4585
|
-
useSuccessNotification();
|
|
4586
|
-
// const cancelSubscription = useCancelSubscription();
|
|
4587
|
-
useQueryClient();
|
|
4588
|
-
// const navigate = usePortalNavigate();
|
|
4589
|
-
// const handleUpgradingSubscriptionChange =
|
|
4590
|
-
// useHandleUpgradingSubscriptionChange();
|
|
4490
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscription = _a.subscription;
|
|
4591
4491
|
// Derived state
|
|
4592
4492
|
var canShowCancelButton = subscription.plan.selfServiceCancel;
|
|
4593
4493
|
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; });
|
|
4594
4494
|
var canShowChangePlanButton = ((productPlans === null || productPlans === void 0 ? void 0 : productPlans.length) || 0) > 0;
|
|
4595
|
-
// Mutations
|
|
4596
|
-
// const subscriptionCancel = useMutation({
|
|
4597
|
-
// mutationFn: () => cancelSubscription([subscription.id], token),
|
|
4598
|
-
// onSuccess: () => {
|
|
4599
|
-
// queryClient.invalidateQueries({
|
|
4600
|
-
// queryKey: QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4601
|
-
// });
|
|
4602
|
-
// showSuccessNotification("Subscription canceled");
|
|
4603
|
-
// },
|
|
4604
|
-
// });
|
|
4605
|
-
useMutation({
|
|
4606
|
-
mutationFn: function () {
|
|
4607
|
-
return getGuoteSubscriptionReinstate({
|
|
4608
|
-
ids: [subscription.id],
|
|
4609
|
-
token: token,
|
|
4610
|
-
apiHost: apiHost,
|
|
4611
|
-
});
|
|
4612
|
-
},
|
|
4613
|
-
onSuccess: function (quote) {
|
|
4614
|
-
setEditingQuoteData({ id: quote.id, isTrial: false });
|
|
4615
|
-
setPayModalVisible(true);
|
|
4616
|
-
},
|
|
4617
|
-
});
|
|
4618
|
-
// Handlers
|
|
4619
|
-
var handleChangePlanClick = function () {
|
|
4620
|
-
// handleUpgradingSubscriptionChange({
|
|
4621
|
-
// subscription,
|
|
4622
|
-
// });
|
|
4623
|
-
console.log("handleChangePlanClick handleUpgradingSubscriptionChange not implemented");
|
|
4624
|
-
// navigate("plan-manager", {
|
|
4625
|
-
// subscriptionUpgradeId: subscription.id,
|
|
4626
|
-
// });
|
|
4627
|
-
onChangePlanClick();
|
|
4628
|
-
};
|
|
4629
4495
|
return (canShowChangePlanButton || canShowCancelButton) &&
|
|
4630
|
-
canShowSubscriptionActions(subscription) ? (jsxs(Fragment, { children: [
|
|
4631
|
-
// onConfirm={() => subscriptionCancel.mutate()}
|
|
4632
|
-
title: "Cancel subscription" }, { children: jsx(Button, __assign({ className: "p-0", type: "link" }, { children: "Cancel subscription" })) }))), !isTempViewOnly && canShowChangePlanButton && (jsx(Button, __assign({ onClick: function () { return handleChangePlanClick(); }, type: "primary" }, { children: "Change plan" })))] })) : ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState$2.TRIAL ? (jsx(Fragment, { children: !isTempViewOnly && (jsx(Button, __assign({ onClick: function () {
|
|
4633
|
-
// handleUpgradingSubscriptionChange({
|
|
4634
|
-
// subscription,
|
|
4635
|
-
// });
|
|
4636
|
-
console.log("onClickUpgrade handleUpgradingSubscriptionChange not implemented");
|
|
4637
|
-
// navigate("plan-manager", {
|
|
4638
|
-
// subscriptionUpgradeId: subscription.id,
|
|
4639
|
-
// });
|
|
4640
|
-
onClickUpgrade();
|
|
4641
|
-
}, type: "primary" }, { children: "Upgrade" }))) })) : null;
|
|
4496
|
+
canShowSubscriptionActions(subscription) ? (jsxs(Fragment, { children: [canShowCancelButton && (jsx(Popconfirm, __assign({ icon: null, onConfirm: function () { return onCancelSubscriptionClick === null || onCancelSubscriptionClick === void 0 ? void 0 : onCancelSubscriptionClick(subscription); }, title: "Cancel subscription" }, { children: jsx(Button, __assign({ className: "p-0", type: "link" }, { children: "Cancel subscription" })) }))), canShowChangePlanButton && (jsx(Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: "primary" }, { children: "Change plan" })))] })) : ((_c = subscription.state) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === SubscriptionState$2.TRIAL ? (jsx(Button, __assign({ onClick: function () { return onChangePlanClick(subscription); }, type: "primary" }, { children: "Upgrade" }))) : null;
|
|
4642
4497
|
};
|
|
4643
4498
|
|
|
4644
4499
|
var Text$2 = Typography.Text;
|
|
@@ -4660,7 +4515,7 @@ var getSubscriptionStatusText = function (subscription) {
|
|
|
4660
4515
|
};
|
|
4661
4516
|
var SubscriptionCardHeader = function (_a) {
|
|
4662
4517
|
var _b, _c, _d, _e, _f;
|
|
4663
|
-
var
|
|
4518
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscription = _a.subscription;
|
|
4664
4519
|
var darkMode = useContext(BunnyContext).darkMode;
|
|
4665
4520
|
var brandColor = useContext(BrandContext).brandColor;
|
|
4666
4521
|
var isMobile = useIsMobile();
|
|
@@ -4669,7 +4524,10 @@ var SubscriptionCardHeader = function (_a) {
|
|
|
4669
4524
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
4670
4525
|
return (jsxs("div", __assign({ className: "flex items-center justify-between", style: {
|
|
4671
4526
|
backgroundColor: darkMode ? "var(--row-background-dark)" : "",
|
|
4672
|
-
} }, { children: [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) && (jsx("div", __assign({ className: "font-medium", style: { fontSize: "11px", color: brandColor } }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), 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) && (jsx(Text$2, __assign({ className: "text-lg" }, { children: subscription.plan.name }))), jsxs(Tag, __assign({ className: "ant-tag-".concat(TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()]) }, { children: [capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft, " days left)") : ""] }))] }))] })), jsxs("div", __assign({ className: "flex items-center gap-6" }, { children: [jsx(Text$2, __assign({ className: "grow text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile &&
|
|
4527
|
+
} }, { children: [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) && (jsx("div", __assign({ className: "font-medium", style: { fontSize: "11px", color: brandColor } }, { children: (_d = subscription.product.name) === null || _d === void 0 ? void 0 : _d.toUpperCase() }))), 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) && (jsx(Text$2, __assign({ className: "text-lg" }, { children: subscription.plan.name }))), jsxs(Tag, __assign({ className: "ant-tag-".concat(TAG_COLORS[(_f = subscription.state) === null || _f === void 0 ? void 0 : _f.toUpperCase()]) }, { children: [capitalize(subscription.state.toLowerCase()), isTrial ? " (".concat(trialDaysLeft, " days left)") : ""] }))] }))] })), jsxs("div", __assign({ className: "flex items-center gap-6" }, { children: [jsx(Text$2, __assign({ className: "grow text-xs" }, { children: getSubscriptionStatusText(subscription) })), !isMobile &&
|
|
4528
|
+
planChangeOptions &&
|
|
4529
|
+
onChangePlanClick &&
|
|
4530
|
+
onCancelSubscriptionClick && (jsx(SubscriptionCardActions, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscription: subscription }))] }))] })));
|
|
4673
4531
|
};
|
|
4674
4532
|
|
|
4675
4533
|
var BillingPeriodConverter;
|
|
@@ -4682,16 +4540,23 @@ var BillingPeriodConverter;
|
|
|
4682
4540
|
})(BillingPeriodConverter || (BillingPeriodConverter = {}));
|
|
4683
4541
|
var SubscriptionChargeTotal = function (_a) {
|
|
4684
4542
|
var charge = _a.charge, subscription = _a.subscription;
|
|
4543
|
+
var billingPeriod = charge.billingPeriod && BillingPeriodConverter[charge.billingPeriod];
|
|
4685
4544
|
var isMobile = useIsMobile();
|
|
4686
|
-
|
|
4545
|
+
var currencyId = subscription.currencyId;
|
|
4546
|
+
var formattedDiscountedPrice = formatCurrency(charge.price, currencyId);
|
|
4547
|
+
var formattedPeriodPrice = formatCurrency(charge.periodPrice, currencyId);
|
|
4548
|
+
return (jsx("div", __assign({ className: "flex gap-1 ".concat(isMobile ? "flex-col" : "") }, { children: charge.kind === SubscriptionChargeKind.DISCOUNT
|
|
4549
|
+
? "-".concat(formattedDiscountedPrice, " ").concat(billingPeriod)
|
|
4550
|
+
: "".concat(formattedPeriodPrice, " ").concat(billingPeriod) })));
|
|
4687
4551
|
};
|
|
4688
4552
|
|
|
4689
4553
|
var SubscriptionChargeUnitPrice = function (_a) {
|
|
4690
|
-
var _b, _c;
|
|
4691
4554
|
var charge = _a.charge, subscription = _a.subscription;
|
|
4692
4555
|
var darkMode = useContext(BunnyContext).darkMode;
|
|
4693
|
-
var
|
|
4694
|
-
|
|
4556
|
+
var _b = useState(false), showPriceTiers = _b[0], setShowPriceTiers = _b[1];
|
|
4557
|
+
var displayPriceTiers = (charge === null || charge === void 0 ? void 0 : charge.priceTiers) && charge.pricingModel === PricingModel.TIERED;
|
|
4558
|
+
var isDiscount = (charge === null || charge === void 0 ? void 0 : charge.kind) === SubscriptionChargeKind.DISCOUNT;
|
|
4559
|
+
if (displayPriceTiers)
|
|
4695
4560
|
return (jsx(Dropdown, __assign({ dropdownRender: function () {
|
|
4696
4561
|
var _a, _b;
|
|
4697
4562
|
return (jsx("div", __assign({ className: "flex flex-col rounded border border-solid border-slate-200 p-2", style: {
|
|
@@ -4705,9 +4570,11 @@ var SubscriptionChargeUnitPrice = function (_a) {
|
|
|
4705
4570
|
: "∞";
|
|
4706
4571
|
return (jsxs("div", __assign({ className: "contents" }, { children: [jsxs("div", __assign({ className: "whitespace-nowrap" }, { children: [tier.starts.toLocaleString(), " - ", ends.toLocaleString(), " ", ":"] })), jsx("div", __assign({ className: "whitespace-nowrap text-right" }, { children: formatCurrency(tier.price, subscription.currencyId, charge.priceDecimals) }))] }), index));
|
|
4707
4572
|
}) })) })));
|
|
4708
|
-
}, onOpenChange: setShowPriceTiers, open: showPriceTiers, trigger: ["click"] }, { children: jsx("div", __assign({ className: "cursor-pointer underline", onClick: function () { return setShowPriceTiers(!showPriceTiers); } }, { children: showPriceTiers ? "
|
|
4709
|
-
|
|
4710
|
-
|
|
4573
|
+
}, onOpenChange: setShowPriceTiers, open: showPriceTiers, trigger: ["click"] }, { children: jsx("div", __assign({ className: "cursor-pointer underline", onClick: function () { return setShowPriceTiers(!showPriceTiers); } }, { children: showPriceTiers ? "Hide tiers" : "Show tiers" })) })));
|
|
4574
|
+
else if (isDiscount)
|
|
4575
|
+
return (jsxs(Fragment, { children: ["-", formatCurrency(charge.discountedPrice, subscription.currencyId)] }));
|
|
4576
|
+
else
|
|
4577
|
+
return (jsx(Fragment, { children: formatCurrency(charge.discountedPrice, subscription.currencyId) }));
|
|
4711
4578
|
};
|
|
4712
4579
|
|
|
4713
4580
|
var SubscriptionCardColumnHeaders = function (_a) {
|
|
@@ -4721,7 +4588,7 @@ var SubscriptionsListCell = function (_a) {
|
|
|
4721
4588
|
return (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 })));
|
|
4722
4589
|
};
|
|
4723
4590
|
|
|
4724
|
-
var
|
|
4591
|
+
var CARD_COLUMNS = [
|
|
4725
4592
|
{
|
|
4726
4593
|
title: "CHARGE",
|
|
4727
4594
|
width: "minmax(min-content, 26%)",
|
|
@@ -4745,22 +4612,21 @@ var createCardColumns = function () { return [
|
|
|
4745
4612
|
title: "TOTAL",
|
|
4746
4613
|
width: "minmax(min-content, 18%)",
|
|
4747
4614
|
},
|
|
4748
|
-
];
|
|
4615
|
+
];
|
|
4749
4616
|
var SubscriptionCardDesktop = function (_a) {
|
|
4750
4617
|
var _b;
|
|
4751
|
-
var
|
|
4618
|
+
var onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscription = _a.subscription;
|
|
4752
4619
|
var shadow = useContext(SubscriptionsContext).shadow;
|
|
4753
4620
|
// Derived state
|
|
4754
4621
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$1.TRIAL;
|
|
4755
|
-
|
|
4756
|
-
return (jsxs(Card, __assign({ className: "p-4 ".concat(shadow ? "shadow-".concat(shadow) : "") }, { children: [jsx(SubscriptionCardHeader, { planChangeOptions: planChangeOptions, setEditingQuoteData: setEditingQuoteData, setPayModalVisible: setPayModalVisible, subscription: subscription }), jsx(Divider, { className: "my-4", style: {
|
|
4622
|
+
return (jsxs(Card, __assign({ className: "p-4 ".concat(shadow ? "shadow-".concat(shadow) : "") }, { children: [jsx(SubscriptionCardHeader, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscription: subscription }), jsx(Divider, { className: "my-4", style: {
|
|
4757
4623
|
gridColumn: "1 / 5",
|
|
4758
4624
|
width: "calc(100% + 32px)",
|
|
4759
4625
|
transform: "translateX(-16px)",
|
|
4760
4626
|
} }), jsxs("div", __assign({ className: "grid w-full", style: {
|
|
4761
|
-
gridTemplateColumns:
|
|
4627
|
+
gridTemplateColumns: CARD_COLUMNS.map(function (column) { return column.width; }).join(" "),
|
|
4762
4628
|
rowGap: "0.75rem",
|
|
4763
|
-
} }, { children: [jsx(SubscriptionCardColumnHeaders, { columns:
|
|
4629
|
+
} }, { children: [jsx(SubscriptionCardColumnHeaders, { columns: CARD_COLUMNS }), subscription.charges.map(function (charge, chargeIndex) {
|
|
4764
4630
|
if ((isTrial && !charge.trial) || (!isTrial && charge.trial))
|
|
4765
4631
|
return null;
|
|
4766
4632
|
return (jsx(SubscriptionCardDesktopRow, { charge: charge, chargeIndex: chargeIndex, subscription: subscription }, chargeIndex));
|
|
@@ -4793,12 +4659,18 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
4793
4659
|
charge.chargeType === ChargeType.USAGE,
|
|
4794
4660
|
}).data;
|
|
4795
4661
|
var isRampFirstRow = isRamp && chargeIndex === 0;
|
|
4796
|
-
var
|
|
4797
|
-
|
|
4662
|
+
var isTrial = charge.trial;
|
|
4663
|
+
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.id) === charge.id &&
|
|
4664
|
+
(!isTrial || prevCharge.trial) &&
|
|
4665
|
+
(isTrial || !prevCharge.trial);
|
|
4666
|
+
var isDiscount = charge.kind === SubscriptionChargeKind.DISCOUNT;
|
|
4667
|
+
return (jsxs("div", __assign({ className: "contents" }, { children: [(isRampFirstRow || !isRamp) && (jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? "1/-1" : "1" }, { children: jsx("div", __assign({ className: "flex items-center gap-2 ".concat(isDiscount ? "pl-4" : "") }, { children: jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName)
|
|
4798
4668
|
? charge.name
|
|
4799
|
-
: "" }) })) }))), jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsx("div", { children: chargePeriod }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.
|
|
4800
|
-
?
|
|
4801
|
-
: charge.
|
|
4669
|
+
: "" }) })) }))), jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsx("div", { children: chargePeriod }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === SubscriptionChargeKind.DISCOUNT
|
|
4670
|
+
? ""
|
|
4671
|
+
: charge.chargeType === ChargeType.USAGE
|
|
4672
|
+
? data && jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
|
|
4673
|
+
: charge.quantity })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsx(SubscriptionChargeUnitPrice, { charge: charge, subscription: subscription }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] })));
|
|
4802
4674
|
};
|
|
4803
4675
|
|
|
4804
4676
|
var Text = Typography.Text;
|
|
@@ -4826,14 +4698,14 @@ var CHARGE_COLUMNS = [
|
|
|
4826
4698
|
];
|
|
4827
4699
|
var SubscriptionCard = function (_a) {
|
|
4828
4700
|
var _b;
|
|
4829
|
-
var
|
|
4701
|
+
var subscription = _a.subscription;
|
|
4830
4702
|
var darkMode = useContext(BunnyContext).darkMode;
|
|
4831
4703
|
// Derived state
|
|
4832
4704
|
var isTrial = ((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$1.TRIAL;
|
|
4833
4705
|
var backgroundColor = darkMode
|
|
4834
4706
|
? "var(--row-background-dark)"
|
|
4835
4707
|
: "var(--row-background)";
|
|
4836
|
-
return (jsx(Card, { children: jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(SubscriptionCardHeader, {
|
|
4708
|
+
return (jsx(Card, { children: jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(SubscriptionCardHeader, { subscription: subscription }), jsx(Divider, { className: "my-4", style: {
|
|
4837
4709
|
gridColumn: "1 / -1",
|
|
4838
4710
|
width: "calc(100% + 32px)",
|
|
4839
4711
|
transform: "translateX(-16px)",
|
|
@@ -4847,142 +4719,87 @@ var SubscriptionCard = function (_a) {
|
|
|
4847
4719
|
return null;
|
|
4848
4720
|
var isRamp = charge.isRamp;
|
|
4849
4721
|
var chargePeriod = "".concat(formatDate(charge.startDate), " - ").concat(formatDate(charge.endDate));
|
|
4850
|
-
return (jsxs("div", __assign({ className: "contents" }, { children: [((isRamp && chargeIndex === 0) || !isRamp) && (jsxs(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className, style: { gridColumn: isRamp ? "1/-1" : "1" } }, { children: [jsx("span", { children: charge.name }), !isRamp ? " - ".concat(chargePeriod) : ""] }))), isRamp && (jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className }, { children: "- ".concat(chargePeriod) }))), jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[1].className }, { children: charge.
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4722
|
+
return (jsxs("div", __assign({ className: "contents" }, { children: [((isRamp && chargeIndex === 0) || !isRamp) && (jsxs(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className, style: { gridColumn: isRamp ? "1/-1" : "1" } }, { children: [jsx("span", { children: charge.name }), !isRamp ? " - ".concat(chargePeriod) : ""] }))), isRamp && (jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[0].className }, { children: "- ".concat(chargePeriod) }))), jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[1].className }, { children: charge.kind === SubscriptionChargeKind.DISCOUNT
|
|
4723
|
+
? ""
|
|
4724
|
+
: charge.quantity })), jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[2].className }, { children: jsx(SubscriptionChargeUnitPrice, { charge: charge, subscription: subscription }) })), jsx(SubscriptionCardCellMobile, __assign({ className: CHARGE_COLUMNS[3].className }, { children: jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) }))] }), chargeIndex));
|
|
4725
|
+
})] }))] })) }));
|
|
4854
4726
|
};
|
|
4855
4727
|
|
|
4856
4728
|
var SubscriptionsList = function (_a) {
|
|
4857
|
-
var hideExpired = _a.hideExpired,
|
|
4729
|
+
var hideExpired = _a.hideExpired, onChangePlanClick = _a.onChangePlanClick, onCancelSubscriptionClick = _a.onCancelSubscriptionClick, planChangeOptions = _a.planChangeOptions, subscriptions = _a.subscriptions;
|
|
4858
4730
|
var isMobile = useIsMobile();
|
|
4859
4731
|
return (jsx(Fragment, { children: subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.map(function (subscription, subscriptionIndex) {
|
|
4860
4732
|
if (hideExpired && isSubscriptionNotActive(subscription))
|
|
4861
4733
|
return null;
|
|
4862
4734
|
if (isMobile)
|
|
4863
|
-
return (jsx(SubscriptionCard, {
|
|
4864
|
-
return (jsx(SubscriptionCardDesktop, {
|
|
4735
|
+
return (jsx(SubscriptionCard, { subscription: subscription }, subscriptionIndex));
|
|
4736
|
+
return (jsx(SubscriptionCardDesktop, { onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscription: subscription }, subscriptionIndex));
|
|
4865
4737
|
}) }));
|
|
4866
4738
|
};
|
|
4867
4739
|
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
return (
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4740
|
+
// WARNING: There is a preview button on APP that will need to be changed if this query is changed
|
|
4741
|
+
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 }";
|
|
4742
|
+
var getPlanChangeOptions = function (_a) {
|
|
4743
|
+
var isInPreviewMode = _a.isInPreviewMode, token = _a.token, upgradingSubscription = _a.upgradingSubscription, apiHost = _a.apiHost;
|
|
4744
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4745
|
+
var response, planChangeOptions;
|
|
4746
|
+
return __generator(this, function (_b) {
|
|
4747
|
+
switch (_b.label) {
|
|
4748
|
+
case 0: return [4 /*yield*/, gqlRequest$1({
|
|
4749
|
+
isInPreviewMode: isInPreviewMode,
|
|
4750
|
+
query: PLAN_CHANGE_OPTIONS_QUERY,
|
|
4751
|
+
vars: { subscriptionId: upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.id },
|
|
4752
|
+
token: token,
|
|
4753
|
+
apiHost: apiHost,
|
|
4754
|
+
})];
|
|
4755
|
+
case 1:
|
|
4756
|
+
response = _b.sent();
|
|
4757
|
+
planChangeOptions = response.planChangeOptions;
|
|
4758
|
+
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.errors)
|
|
4759
|
+
throw planChangeOptions.errors;
|
|
4760
|
+
// Sort planChangeOptions.plans by position
|
|
4761
|
+
if (planChangeOptions === null || planChangeOptions === void 0 ? void 0 : planChangeOptions.plans) {
|
|
4762
|
+
planChangeOptions.plans.sort(function (a, b) { return a.position - b.position; });
|
|
4763
|
+
}
|
|
4764
|
+
return [2 /*return*/, planChangeOptions];
|
|
4765
|
+
}
|
|
4766
|
+
});
|
|
4885
4767
|
});
|
|
4886
|
-
return (jsxs(Fragment, { children: [!isMobile && (jsx(HideExpiredToggle, { hideExpired: hideExpired, setHideExpired: setHideExpired, subscriptions: subscriptions })), jsx("div", __assign({ className: "flex grow gap-2 ".concat(isMobile ? "flex-col shadow-padding-x" : "justify-end") }, { children: !isTempViewOnly && canShowChangeQuantitiesButton && (jsx(ChangeQuantitiesButton, { canShowChangeQuantitiesButton: canShowChangeQuantitiesButton, setQuantityDrawerOpen: setQuantityDrawerOpen })) }))] }));
|
|
4887
4768
|
};
|
|
4888
4769
|
|
|
4889
|
-
// !!! This component is intended to be view only, however it still has lots of code for full functionality.
|
|
4890
|
-
// !!! This must be refactored.
|
|
4891
4770
|
var Subscriptions = function (_a) {
|
|
4892
|
-
var
|
|
4771
|
+
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 ? {
|
|
4772
|
+
gap: 4,
|
|
4773
|
+
shadow: "sm",
|
|
4774
|
+
} : _c;
|
|
4775
|
+
var gap = styles.gap, shadow = styles.shadow;
|
|
4893
4776
|
// Context
|
|
4894
|
-
var
|
|
4777
|
+
var apiHost = useContext(BunnyContext).apiHost;
|
|
4895
4778
|
var token = useToken();
|
|
4896
|
-
// Recoil state
|
|
4897
|
-
// const [updatingChargeQuantityId, setUpdatingChargeQuantityId] =
|
|
4898
|
-
// useRecoilState(updatingChargeQuantityIdState);
|
|
4899
|
-
// Local state
|
|
4900
|
-
var _d = useState(), editingQuoteData = _d[0], setEditingQuoteData = _d[1];
|
|
4901
|
-
var _e = useState(false), payModalVisible = _e[0], setPayModalVisible = _e[1];
|
|
4902
|
-
var _f = useState(true), hideExpired = _f[0], setHideExpired = _f[1];
|
|
4903
|
-
var _g = useState(false); _g[0]; var setQuantityDrawerOpen = _g[1];
|
|
4904
|
-
// Hooks
|
|
4905
|
-
var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
|
|
4906
|
-
var queryClient = useQueryClient();
|
|
4907
|
-
var showSuccessNotification = useSuccessNotification();
|
|
4908
|
-
// const quoteDelete = useQuoteDelete();
|
|
4909
|
-
var isMobile = useIsMobile();
|
|
4910
4779
|
// Queries
|
|
4911
|
-
var
|
|
4780
|
+
var _d = useQuery({
|
|
4912
4781
|
queryKey: QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4913
4782
|
queryFn: function () { return getSubscriptions({ entityId: entityId, token: token, apiHost: apiHost }); },
|
|
4914
4783
|
enabled: Boolean(entityId),
|
|
4915
|
-
}), rawSubscriptions =
|
|
4916
|
-
var
|
|
4917
|
-
queryKey: QueryKeyFactory.default.createObjectKey("editingQuote", editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id),
|
|
4918
|
-
queryFn: function () {
|
|
4919
|
-
return (editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id)
|
|
4920
|
-
? getQuote({ token: token, id: editingQuoteData.id, apiHost: apiHost })
|
|
4921
|
-
: undefined;
|
|
4922
|
-
},
|
|
4923
|
-
enabled: Boolean(editingQuoteData === null || editingQuoteData === void 0 ? void 0 : editingQuoteData.id),
|
|
4924
|
-
}).data;
|
|
4925
|
-
var _j = useQuery({
|
|
4784
|
+
}), rawSubscriptions = _d.data, subscriptionsAreLoading = _d.isLoading;
|
|
4785
|
+
var _e = useQuery({
|
|
4926
4786
|
queryKey: QueryKeyFactory.default.planChangeOptionsKey(),
|
|
4927
4787
|
queryFn: function () { return getPlanChangeOptions({ token: token, apiHost: apiHost }); },
|
|
4928
|
-
|
|
4788
|
+
enabled: Boolean(onChangePlanClick),
|
|
4789
|
+
}), planChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
|
|
4929
4790
|
// Derived state
|
|
4930
4791
|
var subscriptions = useSubscriptions({ data: rawSubscriptions });
|
|
4931
|
-
var allSubscriptionsExpired = subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.every(function (subscription) {
|
|
4932
|
-
var _a, _b;
|
|
4933
|
-
return ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.EXPIRED ||
|
|
4934
|
-
((_b = subscription.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.CANCELED;
|
|
4935
|
-
});
|
|
4936
4792
|
useEffect(function () {
|
|
4937
|
-
if (
|
|
4938
|
-
|
|
4939
|
-
}, [
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
setQuantityDrawerOpen(false);
|
|
4943
|
-
setEditingQuoteData(undefined);
|
|
4944
|
-
queryClient.invalidateQueries({
|
|
4945
|
-
queryKey: QueryKeyFactory.default.transactionsKey(),
|
|
4946
|
-
});
|
|
4947
|
-
queryClient.invalidateQueries({
|
|
4948
|
-
queryKey: QueryKeyFactory.default.createTableKey("subscriptions"),
|
|
4949
|
-
});
|
|
4950
|
-
showSuccessNotification("Your plan has been updated", "Payment successful");
|
|
4951
|
-
setPayModalVisible(false);
|
|
4952
|
-
setHideExpired(true);
|
|
4953
|
-
};
|
|
4954
|
-
var onCancel = function () {
|
|
4955
|
-
setPayModalVisible(false);
|
|
4956
|
-
};
|
|
4957
|
-
var onFail = function (error) {
|
|
4958
|
-
handleAllErrorFormats(error);
|
|
4959
|
-
};
|
|
4960
|
-
// const onClose = () => {
|
|
4961
|
-
// if (editingQuoteData) {
|
|
4962
|
-
// quoteDelete(editingQuoteData.id, token);
|
|
4963
|
-
// setEditingQuoteData(undefined);
|
|
4964
|
-
// }
|
|
4965
|
-
// // if (updatingChargeQuantityId) {
|
|
4966
|
-
// // setUpdatingChargeQuantityId(undefined);
|
|
4967
|
-
// // }
|
|
4968
|
-
// setQuantityDrawerOpen(false);
|
|
4969
|
-
// };
|
|
4970
|
-
if (subscriptionsAreLoading || arePlanChangeOptionsLoading)
|
|
4793
|
+
if (subscriptions)
|
|
4794
|
+
onSubscriptionsLoaded === null || onSubscriptionsLoaded === void 0 ? void 0 : onSubscriptionsLoaded(subscriptions);
|
|
4795
|
+
}, [subscriptions]);
|
|
4796
|
+
if (subscriptionsAreLoading ||
|
|
4797
|
+
(Boolean(onChangePlanClick) ? arePlanChangeOptionsLoading : false))
|
|
4971
4798
|
return jsx(Fragment, {});
|
|
4972
|
-
return (
|
|
4973
|
-
onChangePlanClick: function () {
|
|
4974
|
-
console.log("onChangePlanClick not implemented");
|
|
4975
|
-
},
|
|
4976
|
-
onClickUpgrade: function () {
|
|
4977
|
-
console.log("onClickUpgrade not implemented");
|
|
4978
|
-
},
|
|
4979
|
-
isTempViewOnly: true,
|
|
4980
|
-
shadow: shadow,
|
|
4799
|
+
return (jsx(SubscriptionsContext.Provider, __assign({ value: {
|
|
4981
4800
|
gap: gap,
|
|
4982
|
-
|
|
4983
|
-
} }, { children:
|
|
4984
|
-
flexShrink: 1,
|
|
4985
|
-
} }, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsx(Fragment, { children: jsx(SubscriptionsList, { hideExpired: hideExpired, planChangeOptions: planChangeOptions, setEditingQuoteData: setEditingQuoteData, setPayModalVisible: setPayModalVisible, subscriptions: subscriptions }) })) : (jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) }))) })), isMobile && (jsx("div", __assign({ className: "pt-4 pb-2" }, { children: jsx(SubscriptionsNavigation, { hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsx(Checkout, { entityId: entityId, onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile })] })));
|
|
4801
|
+
shadow: shadow,
|
|
4802
|
+
} }, { children: 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 ? (jsx(SubscriptionsList, { hideExpired: hideExpired, onChangePlanClick: onChangePlanClick, onCancelSubscriptionClick: onCancelSubscriptionClick, planChangeOptions: planChangeOptions, subscriptions: subscriptions })) : (jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) }))) })) })));
|
|
4986
4803
|
};
|
|
4987
4804
|
|
|
4988
4805
|
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";
|