@bunnyapp/components 1.0.6 → 1.0.7
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 +1067 -986
- package/dist/cjs/src/components/Quotes/index.d.ts +1 -0
- package/dist/cjs/src/components/index.d.ts +1 -0
- package/dist/esm/index.js +1070 -990
- package/dist/esm/src/components/Quotes/index.d.ts +1 -0
- package/dist/esm/src/components/index.d.ts +1 -0
- package/dist/index.d.ts +31 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { createContext, useContext, useEffect, useState, useMemo, useRef } from 'react';
|
|
4
4
|
import { Markup } from 'interweave';
|
|
5
|
-
import { ConfigProvider, Button, Typography, Checkbox, Input, Divider, Modal, Form, Tag,
|
|
5
|
+
import { ConfigProvider, Button, Typography, Checkbox, Input, Divider, Modal, Form, Tag, Drawer, Card as Card$1, Popconfirm, Select, Image, Dropdown } 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, createGraphQLClient, Misc, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, QueryKeyFactory, useDownloadFile, NotificationUtils, invokePlugin, useIsMobile as useIsMobile$1, GRAY_500, GRAY_200, CHARCOAL_GRAY, StringUtils, usePaymentPlugins, ApiUtils, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, QuoteInvoiceUtils, usePlugins, GraphqlUtils,
|
|
7
|
+
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, createGraphQLClient, Misc, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, QueryKeyFactory, useDownloadFile, NotificationUtils, invokePlugin, useIsMobile as useIsMobile$1, GRAY_500, GRAY_200, CHARCOAL_GRAY, StringUtils, usePaymentPlugins, ApiUtils, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, QuoteInvoiceUtils, usePlugins, GraphqlUtils, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getTaxationRequiredAccountFields, getAccount, useCurrentUserData, SLATE_500, PRIMARY_COLOR, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
|
|
8
8
|
import { QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient, keepPreviousData } from '@tanstack/react-query';
|
|
9
|
-
import { RecoilRoot, atom,
|
|
9
|
+
import { RecoilRoot, atom, useSetRecoilState, useRecoilValue, useRecoilState } from 'recoil';
|
|
10
10
|
import theme from 'antd/lib/theme';
|
|
11
11
|
import { HelmetProvider, Helmet } from 'react-helmet-async';
|
|
12
12
|
import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
|
|
@@ -3293,1095 +3293,1175 @@ function Quote(_a) {
|
|
|
3293
3293
|
}
|
|
3294
3294
|
var templateObject_1$5;
|
|
3295
3295
|
|
|
3296
|
-
var
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3296
|
+
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 }"); };
|
|
3297
|
+
var getQuotes = function (_a) {
|
|
3298
|
+
var token = _a.token, subdomain = _a.subdomain, filter = _a.filter;
|
|
3299
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
3300
|
+
var response;
|
|
3301
|
+
return __generator(this, function (_b) {
|
|
3302
|
+
switch (_b.label) {
|
|
3303
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
3304
|
+
query: QUOTES_QUERY(filter),
|
|
3305
|
+
token: token,
|
|
3306
|
+
vars: {},
|
|
3307
|
+
subdomain: subdomain,
|
|
3308
|
+
})];
|
|
3309
|
+
case 1:
|
|
3310
|
+
response = _b.sent();
|
|
3311
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quotes];
|
|
3312
|
+
}
|
|
3313
|
+
});
|
|
3314
|
+
});
|
|
3303
3315
|
};
|
|
3304
3316
|
|
|
3305
|
-
var
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3317
|
+
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}"); };
|
|
3318
|
+
var getTransactions = function (filter, token, subdomain, kindsToShow) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3319
|
+
var response, _a, data, errors, transactions;
|
|
3320
|
+
var _b, _c;
|
|
3321
|
+
return __generator(this, function (_d) {
|
|
3322
|
+
switch (_d.label) {
|
|
3323
|
+
case 0: return [4 /*yield*/, fetch(subdomain + "/graphql", {
|
|
3324
|
+
method: "POST",
|
|
3325
|
+
headers: {
|
|
3326
|
+
"Content-type": "application/json; charset=utf-8",
|
|
3327
|
+
Authorization: "Bearer ".concat(token),
|
|
3328
|
+
},
|
|
3329
|
+
body: JSON.stringify({
|
|
3330
|
+
query: transactionMutation(filter),
|
|
3331
|
+
}),
|
|
3332
|
+
})];
|
|
3333
|
+
case 1:
|
|
3334
|
+
response = _d.sent();
|
|
3335
|
+
return [4 /*yield*/, response.json()];
|
|
3336
|
+
case 2:
|
|
3337
|
+
_a = _d.sent(), data = _a.data, errors = _a.errors;
|
|
3338
|
+
if (errors) {
|
|
3339
|
+
throw new Error(errors[0].message);
|
|
3340
|
+
}
|
|
3341
|
+
transactions = (_c = (_b = data === null || data === void 0 ? void 0 : data.transactions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.filter(function (transaction) { return kindsToShow.includes(transaction.kind); });
|
|
3342
|
+
return [2 /*return*/, transactions === null || transactions === void 0 ? void 0 : transactions.reverse()];
|
|
3343
|
+
}
|
|
3344
|
+
});
|
|
3345
|
+
}); };
|
|
3309
3346
|
|
|
3310
|
-
var
|
|
3347
|
+
var pageContentRefState = atom({
|
|
3348
|
+
key: "pageContentRefState",
|
|
3349
|
+
default: undefined,
|
|
3350
|
+
});
|
|
3311
3351
|
|
|
3312
|
-
var
|
|
3352
|
+
var PageContent = function (_a) {
|
|
3313
3353
|
var children = _a.children, className = _a.className, style = _a.style;
|
|
3314
|
-
var
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3354
|
+
var pageContentRef = useRef(null);
|
|
3355
|
+
var setPageContentRef = useSetRecoilState(pageContentRefState);
|
|
3356
|
+
useEffect(function () {
|
|
3357
|
+
setPageContentRef(pageContentRef === null || pageContentRef === void 0 ? void 0 : pageContentRef.current);
|
|
3358
|
+
}, [pageContentRef, setPageContentRef]);
|
|
3359
|
+
return (jsx("div", __assign({ className: className, ref: pageContentRef, style: style }, { children: children })));
|
|
3318
3360
|
};
|
|
3319
3361
|
|
|
3320
3362
|
var Text$b = Typography.Text;
|
|
3321
|
-
var
|
|
3322
|
-
var
|
|
3323
|
-
var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData;
|
|
3324
|
-
var isExpired = function (paymentMethodData) {
|
|
3325
|
-
// paymentMethodData.expirationDate
|
|
3326
|
-
var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
|
|
3327
|
-
return expDate.isBefore(dayjs());
|
|
3328
|
-
};
|
|
3363
|
+
var PageHeaderWithActions = function (_a) {
|
|
3364
|
+
var children = _a.children, title = _a.title;
|
|
3329
3365
|
var isMobile = useIsMobile$1();
|
|
3330
|
-
|
|
3331
|
-
return (jsxs(Card, __assign({ className: "shadow-md 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: [getCardImage((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) && (jsx("img", { alt: "Card", width: "24px", src: "".concat(processPublicUrl, "/").concat(getCardImage((_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.issuer)) })), jsx(Text$b, { children: (_d = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _d === void 0 ? void 0 : _d.description })] })), 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: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).format("MM/YY") }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
|
|
3366
|
+
return (jsxs("div", __assign({ className: "flex pb-4 shadow-padding-x ".concat(isMobile ? "flex-col gap-2" : "items-center justify-between h-8") }, { children: [jsx(PageSubTitle, { title: title }), children] })));
|
|
3332
3367
|
};
|
|
3333
|
-
var
|
|
3334
|
-
var title = _a.title
|
|
3335
|
-
|
|
3368
|
+
var PageSubTitle = function (_a) {
|
|
3369
|
+
var title = _a.title;
|
|
3370
|
+
var secondaryColor = useContext(BrandContext).secondaryColor;
|
|
3371
|
+
var darkMode = useContext(BunnyContext).darkMode;
|
|
3372
|
+
return (jsx(Text$b, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
|
|
3336
3373
|
};
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
var
|
|
3340
|
-
return (
|
|
3374
|
+
|
|
3375
|
+
var StateTag = function (_a) {
|
|
3376
|
+
var state = _a.state;
|
|
3377
|
+
return jsx(Tag, __assign({ color: getColor(state) }, { children: capitalize(startCase(state)) }));
|
|
3341
3378
|
};
|
|
3342
|
-
var
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3379
|
+
var getColor = function (state) {
|
|
3380
|
+
switch (state) {
|
|
3381
|
+
case FrontendTransaction.TransactionState.not_due:
|
|
3382
|
+
return "yellow";
|
|
3383
|
+
case FrontendTransaction.TransactionState.voided:
|
|
3384
|
+
return "black";
|
|
3385
|
+
case FrontendTransaction.TransactionState.ready:
|
|
3386
|
+
return "orange";
|
|
3387
|
+
case FrontendTransaction.TransactionState.preparing:
|
|
3388
|
+
return "purple";
|
|
3389
|
+
case FrontendTransaction.TransactionState.unapplied:
|
|
3390
|
+
case FrontendTransaction.TransactionState.partially_applied:
|
|
3391
|
+
case FrontendTransaction.TransactionState.applied:
|
|
3392
|
+
return "blue";
|
|
3393
|
+
case FrontendTransaction.TransactionState.due:
|
|
3394
|
+
case FrontendTransaction.TransactionState.unpaid:
|
|
3395
|
+
return "orange";
|
|
3396
|
+
case FrontendTransaction.TransactionState.failed:
|
|
3397
|
+
return "red";
|
|
3398
|
+
case FrontendTransaction.TransactionState.paid:
|
|
3399
|
+
return "green";
|
|
3400
|
+
default:
|
|
3401
|
+
return "blue";
|
|
3402
|
+
}
|
|
3346
3403
|
};
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3404
|
+
|
|
3405
|
+
var TransactionGridCell = styled.div.withConfig({
|
|
3406
|
+
shouldForwardProp: function (prop) {
|
|
3407
|
+
return !["gridColumn", "padding", "right"].includes(prop);
|
|
3408
|
+
},
|
|
3409
|
+
})(templateObject_1$4 || (templateObject_1$4 = __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);
|
|
3410
|
+
var templateObject_1$4;
|
|
3411
|
+
|
|
3412
|
+
var Text$a = Typography.Text;
|
|
3413
|
+
var TransactionDate = function (_a) {
|
|
3414
|
+
var date = _a.date;
|
|
3415
|
+
return jsx(Text$a, __assign({ className: "text-sm" }, { children: Misc.formatDate(date) }));
|
|
3352
3416
|
};
|
|
3353
3417
|
|
|
3354
|
-
var
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
var
|
|
3362
|
-
|
|
3363
|
-
console.log("Navigation in PaymentMethod.tsx useAllErrorFormats not implemented");
|
|
3364
|
-
});
|
|
3365
|
-
var isMobile = useIsMobile$1();
|
|
3366
|
-
var data = usePaymentMethod(graphQLClient).data;
|
|
3367
|
-
// Local state
|
|
3368
|
-
var _b = useState(false), showModal = _b[0], setShowModal = _b[1];
|
|
3369
|
-
var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
|
|
3370
|
-
// Queries
|
|
3371
|
-
useQuery({
|
|
3372
|
-
queryKey: QueryKeyFactory.default.currentUserKey,
|
|
3373
|
-
queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
|
|
3374
|
-
});
|
|
3375
|
-
var 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); });
|
|
3376
|
-
var onClickRemove = function () {
|
|
3377
|
-
if (data && plugin) {
|
|
3378
|
-
invokePlugin({
|
|
3379
|
-
plugin: plugin,
|
|
3380
|
-
method: "remove_payment_method",
|
|
3381
|
-
payload: {
|
|
3382
|
-
payment_method_id: data.id,
|
|
3383
|
-
account_id: accountId,
|
|
3384
|
-
},
|
|
3385
|
-
token: token,
|
|
3386
|
-
subdomain: subdomain,
|
|
3387
|
-
})
|
|
3388
|
-
.then(function () {
|
|
3389
|
-
showSuccessNotification("Payment method was removed", "Success");
|
|
3390
|
-
queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey, null);
|
|
3391
|
-
})
|
|
3392
|
-
.catch(function (error) {
|
|
3393
|
-
showErrorNotification(error.message, "Error removing Payment Method");
|
|
3394
|
-
});
|
|
3395
|
-
}
|
|
3396
|
-
};
|
|
3397
|
-
var onSuccess = function () {
|
|
3398
|
-
queryClient.invalidateQueries({
|
|
3399
|
-
queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
|
|
3400
|
-
});
|
|
3401
|
-
setShowModal(false);
|
|
3402
|
-
showSuccessNotification("Your payment method has been saved");
|
|
3403
|
-
};
|
|
3404
|
-
if (data === undefined)
|
|
3418
|
+
var isInvoice = function (transaction) {
|
|
3419
|
+
return transaction.kind === "INVOICE";
|
|
3420
|
+
};
|
|
3421
|
+
var isQuote = function (transaction) {
|
|
3422
|
+
return transaction.kind === "QUOTE";
|
|
3423
|
+
};
|
|
3424
|
+
var TransactionRowTitle = function (_a) {
|
|
3425
|
+
var transaction = _a.transaction;
|
|
3426
|
+
if (!isInvoice(transaction) && !isQuote(transaction)) {
|
|
3405
3427
|
return jsx(Fragment, {});
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
? {
|
|
3409
|
-
padding: "1rem 0 0",
|
|
3410
|
-
}
|
|
3411
|
-
: {},
|
|
3412
|
-
wrapper: isMobile ? { width: "100vw" } : { width: "min-content" },
|
|
3413
|
-
}, title: jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method" }) }, { children: jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
|
|
3414
|
-
handleAllErrorFormats(error);
|
|
3415
|
-
setIsSaving(false);
|
|
3416
|
-
}, onPaymentSuccess: function () {
|
|
3417
|
-
onSuccess();
|
|
3418
|
-
setIsSaving(false);
|
|
3419
|
-
}, setIsSaving: setIsSaving }) }))] }));
|
|
3428
|
+
}
|
|
3429
|
+
return (jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
|
|
3420
3430
|
};
|
|
3421
|
-
function PaymentMethod(_a) {
|
|
3422
|
-
var footer = _a.footer, processPublicUrl = _a.processPublicUrl;
|
|
3423
|
-
return (jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer, processPublicUrl: processPublicUrl } }, { children: jsx(ActualPaymentMethod, {}) })));
|
|
3424
|
-
}
|
|
3425
3431
|
|
|
3426
|
-
|
|
3427
|
-
var
|
|
3428
|
-
var
|
|
3429
|
-
return
|
|
3430
|
-
var vars, response, errors;
|
|
3431
|
-
var _b;
|
|
3432
|
-
return __generator(this, function (_c) {
|
|
3433
|
-
switch (_c.label) {
|
|
3434
|
-
case 0:
|
|
3435
|
-
vars = { id: accountId, attributes: attributes };
|
|
3436
|
-
return [4 /*yield*/, gqlRequest({ query: MUTATION$5, token: token, vars: vars })];
|
|
3437
|
-
case 1:
|
|
3438
|
-
response = _c.sent();
|
|
3439
|
-
errors = (_b = response === null || response === void 0 ? void 0 : response.accountUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
3440
|
-
if (errors)
|
|
3441
|
-
throw errors;
|
|
3442
|
-
return [2 /*return*/, response.accountUpdate];
|
|
3443
|
-
}
|
|
3444
|
-
});
|
|
3445
|
-
});
|
|
3432
|
+
// TODO: delete
|
|
3433
|
+
var ArrowDownToLine = function (_a) {
|
|
3434
|
+
var className = _a.className, _b = _a.color, color = _b === void 0 ? SLATE_600 : _b;
|
|
3435
|
+
return (jsxs("svg", __assign({ className: className, fill: "none", height: "16", viewBox: "0 0 16 16", width: "16", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M8 11.3333V2", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M4 7.33301L8 11.333L12 7.33301", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M12.6654 14H3.33203", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
3446
3436
|
};
|
|
3447
3437
|
|
|
3448
|
-
var
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
var
|
|
3453
|
-
var
|
|
3454
|
-
var
|
|
3455
|
-
|
|
3456
|
-
var
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
case 1:
|
|
3467
|
-
account = _a.sent();
|
|
3468
|
-
return [2 /*return*/, account];
|
|
3469
|
-
}
|
|
3470
|
-
});
|
|
3471
|
-
}); },
|
|
3472
|
-
onSuccess: function () {
|
|
3473
|
-
queryClient.invalidateQueries({
|
|
3474
|
-
queryKey: ["getTaxationRequiredAccountFields", token],
|
|
3475
|
-
});
|
|
3476
|
-
},
|
|
3477
|
-
}), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
|
|
3478
|
-
return (jsxs(Form, __assign({ className: "flex flex-col gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsx(Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsx(Input, { placeholder: "Street" }) })), jsx(Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsx(Input, { placeholder: "City" }) })), jsx(FormBillingState, { form: form }), jsx(Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsx(Select, { options: Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
|
|
3479
|
-
var _a, _b;
|
|
3480
|
-
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
|
|
3481
|
-
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
|
|
3482
|
-
} }) })), jsx(Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsx(Input, { placeholder: "Zip" }) })), jsx(Form.Item, { children: jsx(Button, __assign({ className: "w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
|
|
3438
|
+
var TransactionsListContext = createContext({});
|
|
3439
|
+
|
|
3440
|
+
var TransactionDownload = function (_a) {
|
|
3441
|
+
var transaction = _a.transaction, token = _a.token, subdomain = _a.subdomain;
|
|
3442
|
+
var darkMode = useContext(BunnyContext).darkMode;
|
|
3443
|
+
var downloadTransactionLink = useContext(TransactionsListContext).downloadTransactionLink;
|
|
3444
|
+
var downloadFile = useDownloadFile();
|
|
3445
|
+
var isMobile = useIsMobile$1();
|
|
3446
|
+
var isClickable = transaction.kind === "INVOICE" || downloadTransactionLink !== undefined;
|
|
3447
|
+
var downloadLink = downloadTransactionLink
|
|
3448
|
+
? downloadTransactionLink(transaction.transactionableId)
|
|
3449
|
+
: "".concat(subdomain, "/api/pdf/invoice/").concat(transaction.transactionableId);
|
|
3450
|
+
if (!isClickable)
|
|
3451
|
+
return null;
|
|
3452
|
+
return (jsx("div", __assign({ onClick: function (e) {
|
|
3453
|
+
e.stopPropagation();
|
|
3454
|
+
downloadFile(downloadLink, token);
|
|
3455
|
+
} }, { children: jsx(ArrowDownToLine, { className: "".concat(isMobile ? "" : "show-on-hover"), color: darkMode ? WHITE : SLATE_600 }) })));
|
|
3483
3456
|
};
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
var
|
|
3488
|
-
return (jsx(
|
|
3457
|
+
|
|
3458
|
+
var Text$9 = Typography.Text;
|
|
3459
|
+
var TransactionsEmptyState = function () {
|
|
3460
|
+
var noTransactionsMessage = useContext(TransactionsListContext).noTransactionsMessage;
|
|
3461
|
+
return (jsx(Text$9, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
|
|
3489
3462
|
};
|
|
3490
3463
|
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
var
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
onSuccess: onSuccess,
|
|
3531
|
-
onError: onFail,
|
|
3532
|
-
});
|
|
3533
|
-
// Handlers
|
|
3534
|
-
var handleCheckout = function (_a) {
|
|
3535
|
-
var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
|
|
3536
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3537
|
-
var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
|
|
3538
|
-
return __generator(this, function (_b) {
|
|
3539
|
-
if (pluginPaymentResponse) {
|
|
3540
|
-
token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
|
|
3541
|
-
checkoutMutation.mutate({
|
|
3542
|
-
pluginPaymentMethod: {
|
|
3543
|
-
savePaymentMethod: savePaymentMethod,
|
|
3544
|
-
plugin: plugin,
|
|
3545
|
-
metadata: metadata,
|
|
3546
|
-
token: token_1,
|
|
3547
|
-
},
|
|
3548
|
-
});
|
|
3549
|
-
}
|
|
3550
|
-
else if (savedPaymentMethodResponse) {
|
|
3551
|
-
paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
|
|
3552
|
-
checkoutMutation.mutate({
|
|
3553
|
-
storedPaymentMethod: {
|
|
3554
|
-
paymentMethodId: paymentMethodId,
|
|
3555
|
-
},
|
|
3556
|
-
});
|
|
3557
|
-
}
|
|
3558
|
-
else {
|
|
3559
|
-
checkoutMutation.mutate({});
|
|
3560
|
-
}
|
|
3561
|
-
return [2 /*return*/];
|
|
3562
|
-
});
|
|
3563
|
-
});
|
|
3464
|
+
function capitalizeFirstLetter(string) {
|
|
3465
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
3466
|
+
}
|
|
3467
|
+
var WARREN_STATE_LS_KEY = "warrenState";
|
|
3468
|
+
var CURRENT_WARREN_ID_LS_KEY = "currentWarrenId";
|
|
3469
|
+
var getIsCapacitorApp = function () {
|
|
3470
|
+
var isAndroid = window.location.origin === "http://localhost";
|
|
3471
|
+
var isIOS = window.location.protocol === "capacitor:";
|
|
3472
|
+
return isAndroid || isIOS;
|
|
3473
|
+
};
|
|
3474
|
+
var getLocalStorageSubdomain = function () {
|
|
3475
|
+
var warrenState = JSON.parse(window.localStorage.getItem(WARREN_STATE_LS_KEY) || "{}");
|
|
3476
|
+
var subdomain = warrenState[CURRENT_WARREN_ID_LS_KEY];
|
|
3477
|
+
if (!subdomain) {
|
|
3478
|
+
console.warn("ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED");
|
|
3479
|
+
//throw new Error(ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED);
|
|
3480
|
+
}
|
|
3481
|
+
return subdomain;
|
|
3482
|
+
};
|
|
3483
|
+
var getApiHost = function (subdomain) {
|
|
3484
|
+
var isLocalHost = window.location.href.indexOf(".internal") > 0;
|
|
3485
|
+
var sub = subdomain || getLocalStorageSubdomain();
|
|
3486
|
+
if (getIsCapacitorApp()) {
|
|
3487
|
+
return isLocalHost || process.env.REACT_APP_IS_INTERNAL === "true"
|
|
3488
|
+
? "https://".concat(sub, ".bunny.internal")
|
|
3489
|
+
: "https://".concat(sub, ".").concat(process.env.REACT_APP_ROOT_DOMAIN);
|
|
3490
|
+
}
|
|
3491
|
+
return "";
|
|
3492
|
+
};
|
|
3493
|
+
var getGraphQLBase = function () {
|
|
3494
|
+
if (getIsCapacitorApp()) {
|
|
3495
|
+
return "".concat(getApiHost(), "/graphql");
|
|
3496
|
+
}
|
|
3497
|
+
return "/graphql";
|
|
3498
|
+
};
|
|
3499
|
+
var createRequestHeaders = function (token) {
|
|
3500
|
+
var bearerToken = "Bearer ".concat(token);
|
|
3501
|
+
var headers = {
|
|
3502
|
+
"Content-type": "application/json; charset=utf-8",
|
|
3564
3503
|
};
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { isSaving: isSaving, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, setIsSaving: setIsSaving })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button, __assign({ disabled: isSaving, onClick: function () {
|
|
3568
|
-
setIsSaving(true);
|
|
3569
|
-
handleCheckout({});
|
|
3570
|
-
}, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
|
|
3504
|
+
headers["Authorization"] = bearerToken;
|
|
3505
|
+
return headers;
|
|
3571
3506
|
};
|
|
3507
|
+
var useGraphQLRequest = function () { return function (query, token, variables) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3508
|
+
var error_1;
|
|
3509
|
+
return __generator(this, function (_a) {
|
|
3510
|
+
switch (_a.label) {
|
|
3511
|
+
case 0:
|
|
3512
|
+
_a.trys.push([0, 2, , 3]);
|
|
3513
|
+
return [4 /*yield*/, request(getGraphQLBase(), query, variables, createRequestHeaders(token))];
|
|
3514
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3515
|
+
case 2:
|
|
3516
|
+
error_1 = _a.sent();
|
|
3517
|
+
throw error_1;
|
|
3518
|
+
case 3: return [2 /*return*/];
|
|
3519
|
+
}
|
|
3520
|
+
});
|
|
3521
|
+
}); }; };
|
|
3572
3522
|
|
|
3573
|
-
var
|
|
3574
|
-
|
|
3575
|
-
var
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3523
|
+
var Text$8 = Typography.Text;
|
|
3524
|
+
var TransactionsListDesktop = function (_a) {
|
|
3525
|
+
var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
|
|
3526
|
+
var columns = useContext(TransactionsListContext).columns;
|
|
3527
|
+
var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain, darkMode = _b.darkMode;
|
|
3528
|
+
var showAmount = columns.includes("amount");
|
|
3529
|
+
var showDateAndTitle = columns.includes("date-and-title");
|
|
3530
|
+
var showDownload = columns.includes("download");
|
|
3531
|
+
var showState = columns.includes("state");
|
|
3532
|
+
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
3533
|
+
return jsx(TransactionsEmptyState, {});
|
|
3534
|
+
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3535
|
+
var _a;
|
|
3536
|
+
var isClickable = onTransactionClick !== undefined;
|
|
3537
|
+
return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
3538
|
+
onTransactionClick === null || onTransactionClick === void 0 ? void 0 : onTransactionClick(transaction);
|
|
3539
|
+
}, style: {
|
|
3540
|
+
backgroundColor: index % 2 === 0
|
|
3541
|
+
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
3542
|
+
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
3543
|
+
} }, { children: [showDateAndTitle && (jsxs(Fragment, { children: [jsx(TransactionGridCell, __assign({ right: false }, { children: jsx(TransactionDate, { date: transaction.createdAt }) })), jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsx(Text$8, { children: capitalizeFirstLetter(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsx(TransactionGridCell, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })), showState && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(StateTag, { state: transaction.state }) }))), showAmount && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(Text$8, { children: Misc.formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
|
|
3544
|
+
});
|
|
3580
3545
|
};
|
|
3581
3546
|
|
|
3582
|
-
var
|
|
3583
|
-
|
|
3584
|
-
var
|
|
3585
|
-
var
|
|
3586
|
-
var
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
if (errors)
|
|
3603
|
-
throw errors;
|
|
3604
|
-
return [2 /*return*/, (_c = response.quoteRecalculateTaxes) === null || _c === void 0 ? void 0 : _c.quote];
|
|
3605
|
-
}
|
|
3606
|
-
});
|
|
3547
|
+
var Text$7 = Typography.Text;
|
|
3548
|
+
var TransactionsListMobile = function (_a) {
|
|
3549
|
+
var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
|
|
3550
|
+
var columns = useContext(TransactionsListContext).columns;
|
|
3551
|
+
var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain, darkMode = _b.darkMode;
|
|
3552
|
+
var showAmount = columns.includes("amount");
|
|
3553
|
+
var showDateAndTitle = columns.includes("date-and-title");
|
|
3554
|
+
var showDownload = columns.includes("download");
|
|
3555
|
+
var showState = columns.includes("state");
|
|
3556
|
+
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
3557
|
+
return jsx(TransactionsEmptyState, {});
|
|
3558
|
+
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
3559
|
+
var isClickable = transaction.kind === "INVOICE";
|
|
3560
|
+
return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
3561
|
+
onTransactionClick(transaction);
|
|
3562
|
+
}, style: {
|
|
3563
|
+
backgroundColor: index % 2 === 0
|
|
3564
|
+
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
3565
|
+
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
3566
|
+
} }, { 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: capitalizeFirstLetter(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: transaction.createdAt })), showAmount && showDateAndTitle && jsx(Text$7, { children: "\u00B7" }), showAmount && (jsx(Text$7, { children: Misc.formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })))] }), index));
|
|
3607
3567
|
});
|
|
3608
3568
|
};
|
|
3609
3569
|
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
var
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3570
|
+
// Create a client
|
|
3571
|
+
var queryClient = new QueryClient();
|
|
3572
|
+
function Transactions(_a) {
|
|
3573
|
+
var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.columns, columns = _d === void 0 ? ["date-and-title", "state", "amount"] : _d, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? "md" : _e, searchBarClassName = _a.searchBarClassName, _f = _a.useModal, useModal = _f === void 0 ? false : _f, onTransactionClick = _a.onTransactionClick, _g = _a.suppressTransactionDisplay, suppressTransactionDisplay = _g === void 0 ? false : _g, _h = _a.kindsToShow, kindsToShow = _h === void 0 ? [
|
|
3574
|
+
TransactionKind.INVOICE,
|
|
3575
|
+
TransactionKind.PAYMENT,
|
|
3576
|
+
TransactionKind.REFUND,
|
|
3577
|
+
TransactionKind.WRITE_OFF,
|
|
3578
|
+
] : _h, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage;
|
|
3579
|
+
var contextValues = {
|
|
3580
|
+
showSearchBar: showSearchBar,
|
|
3581
|
+
showTitle: showTitle,
|
|
3582
|
+
transactionComponent: transactionComponent,
|
|
3583
|
+
columns: columns,
|
|
3584
|
+
className: className,
|
|
3585
|
+
searchBarClassName: searchBarClassName,
|
|
3586
|
+
shadow: shadow,
|
|
3587
|
+
useModal: useModal,
|
|
3588
|
+
onTransactionClick: onTransactionClick,
|
|
3589
|
+
suppressTransactionDisplay: suppressTransactionDisplay,
|
|
3590
|
+
kindsToShow: kindsToShow,
|
|
3591
|
+
style: style,
|
|
3592
|
+
filter: filter,
|
|
3593
|
+
noTransactionsMessage: noTransactionsMessage,
|
|
3594
|
+
};
|
|
3595
|
+
return (jsx(QueryClientProvider, __assign({ client: queryClient }, { children: jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(TransactionsWrapper, {}) })) })));
|
|
3596
|
+
}
|
|
3597
|
+
function TransactionsWrapper() {
|
|
3598
|
+
var _a = useContext(TransactionsListContext), kindsToShow = _a.kindsToShow, filterFromContext = _a.filter;
|
|
3599
|
+
var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain;
|
|
3600
|
+
// Local state
|
|
3601
|
+
var _c = useState(""), search = _c[0], setSearch = _c[1];
|
|
3602
|
+
var filter = filterFromContext ||
|
|
3603
|
+
(search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
|
|
3628
3604
|
// Queries
|
|
3629
|
-
var
|
|
3630
|
-
queryKey: ["
|
|
3631
|
-
queryFn: function () { return
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
}
|
|
3664
|
-
});
|
|
3665
|
-
}); },
|
|
3666
|
-
// Recalculate taxes if the quote is open, has a tax plugin, and the taxation required account fields are not required
|
|
3667
|
-
enabled: Boolean(quote) &&
|
|
3668
|
-
open &&
|
|
3669
|
-
hasTaxPlugin &&
|
|
3670
|
-
!taxationRequiredAccountFields &&
|
|
3671
|
-
!isLoadingTaxationRequiredAccountFields,
|
|
3672
|
-
staleTime: 0,
|
|
3673
|
-
});
|
|
3674
|
-
if (!open || isLoadingTaxationRequiredAccountFields || isLoadingAccount)
|
|
3675
|
-
return null;
|
|
3676
|
-
return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
|
|
3677
|
-
zIndex: 1001,
|
|
3678
|
-
} }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : "", isMobile: isMobile })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx(InvoiceCheckout, { invoice: invoice, isSaving: isSaving, onFail: function (error) {
|
|
3679
|
-
onFail(error);
|
|
3680
|
-
setIsSaving(false);
|
|
3681
|
-
}, onSuccess: function (_a) {
|
|
3682
|
-
var savePaymentMethod = _a.savePaymentMethod;
|
|
3683
|
-
onSuccess({ savePaymentMethod: savePaymentMethod });
|
|
3684
|
-
setIsSaving(false);
|
|
3685
|
-
}, setIsSaving: setIsSaving })) : quote ? (jsx(QuoteCheckout, { account: account, isSaving: isSaving, onFail: function (error) {
|
|
3686
|
-
onFail(error);
|
|
3687
|
-
setIsSaving(false);
|
|
3688
|
-
}, onSuccess: function (_a) {
|
|
3689
|
-
var savePaymentMethod = _a.savePaymentMethod;
|
|
3690
|
-
onSuccess({ savePaymentMethod: savePaymentMethod });
|
|
3691
|
-
setIsSaving(false);
|
|
3692
|
-
}, quote: quote, setIsSaving: setIsSaving, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token, storedPaymentMethod: storedPaymentMethod })) : (jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
|
|
3693
|
-
onFail(error);
|
|
3694
|
-
setIsSaving(false);
|
|
3695
|
-
}, onPaymentSuccess: function (_a) {
|
|
3696
|
-
var pluginPaymentResponse = _a.pluginPaymentResponse;
|
|
3697
|
-
onSuccess({
|
|
3698
|
-
savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
|
|
3699
|
-
});
|
|
3700
|
-
setIsSaving(false);
|
|
3701
|
-
}, setIsSaving: setIsSaving }))] }))] })) })));
|
|
3702
|
-
};
|
|
3703
|
-
|
|
3704
|
-
var MUTATION$4 = 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}"; };
|
|
3705
|
-
var accountSignup = function (_a) {
|
|
3706
|
-
var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode;
|
|
3707
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3708
|
-
var vars, response, errors;
|
|
3709
|
-
var _b;
|
|
3710
|
-
return __generator(this, function (_c) {
|
|
3711
|
-
switch (_c.label) {
|
|
3712
|
-
case 0:
|
|
3713
|
-
vars = {
|
|
3714
|
-
entityId: entityId,
|
|
3715
|
-
accountId: accountId,
|
|
3716
|
-
quoteId: quoteId,
|
|
3717
|
-
paymentToken: paymentToken,
|
|
3718
|
-
pluginId: pluginId,
|
|
3719
|
-
paymentMethodId: paymentMethodId,
|
|
3720
|
-
priceListCode: priceListCode,
|
|
3721
|
-
};
|
|
3722
|
-
return [4 /*yield*/, gqlRequest({
|
|
3723
|
-
query: MUTATION$4(),
|
|
3724
|
-
token: token,
|
|
3725
|
-
vars: vars,
|
|
3726
|
-
subdomain: subdomain,
|
|
3727
|
-
})];
|
|
3728
|
-
case 1:
|
|
3729
|
-
response = _c.sent();
|
|
3730
|
-
errors = (_b = response === null || response === void 0 ? void 0 : response.accountSignup) === null || _b === void 0 ? void 0 : _b.errors;
|
|
3731
|
-
if (errors)
|
|
3732
|
-
throw errors;
|
|
3733
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.accountSignup];
|
|
3605
|
+
var data = useQuery({
|
|
3606
|
+
queryKey: ["transactions", token, filter],
|
|
3607
|
+
queryFn: function () { return getTransactions(filter, token, subdomain, kindsToShow); },
|
|
3608
|
+
placeholderData: keepPreviousData,
|
|
3609
|
+
}).data;
|
|
3610
|
+
return (jsx(TransactionsDisplay, { transactions: data, onSearchValueChanged: setSearch, search: search }));
|
|
3611
|
+
}
|
|
3612
|
+
function TransactionsDisplay(_a) {
|
|
3613
|
+
var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search, title = _a.title;
|
|
3614
|
+
var _b = useContext(TransactionsListContext), showSearchBar = _b.showSearchBar, showTitle = _b.showTitle, transactionComponent = _b.transactionComponent, useModal = _b.useModal, suppressTransactionDisplay = _b.suppressTransactionDisplay, className = _b.className, shadow = _b.shadow, searchBarClassName = _b.searchBarClassName, style = _b.style, onTransactionClick = _b.onTransactionClick;
|
|
3615
|
+
var columns = useContext(TransactionsListContext).columns;
|
|
3616
|
+
var darkMode = useContext(BunnyContext).darkMode;
|
|
3617
|
+
// Local state
|
|
3618
|
+
var _c = useState(null), selectedTransaction = _c[0], setSelectedTransaction = _c[1];
|
|
3619
|
+
var _d = useState(false), drawerOpen = _d[0], setDrawerOpen = _d[1];
|
|
3620
|
+
// Hooks
|
|
3621
|
+
var isMobile = useIsMobile$1();
|
|
3622
|
+
function handleTransactionClick(transaction) {
|
|
3623
|
+
if (onTransactionClick) {
|
|
3624
|
+
onTransactionClick(transaction);
|
|
3625
|
+
}
|
|
3626
|
+
if (!suppressTransactionDisplay) {
|
|
3627
|
+
setSelectedTransaction(transaction);
|
|
3628
|
+
setDrawerOpen(true);
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
// Since the columns are dynamic, we need to calculate the grid template columns
|
|
3632
|
+
var gridTemplateColumns = function () {
|
|
3633
|
+
var templateColumns = [];
|
|
3634
|
+
if (isMobile) {
|
|
3635
|
+
if (columns.includes("date-and-title") ||
|
|
3636
|
+
columns.includes("state") ||
|
|
3637
|
+
columns.includes("amount")) {
|
|
3638
|
+
templateColumns.push("auto");
|
|
3734
3639
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
};
|
|
3738
|
-
|
|
3739
|
-
var MUTATION$3 = 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 amount\n currencyId\n quote {\n id\n }\n tenant {\n code\n }\n errors\n }\n}"; };
|
|
3740
|
-
var quoteAccountSignup = function (_a) {
|
|
3741
|
-
var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
|
|
3742
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3743
|
-
var vars, response, errors;
|
|
3744
|
-
var _b;
|
|
3745
|
-
return __generator(this, function (_c) {
|
|
3746
|
-
switch (_c.label) {
|
|
3747
|
-
case 0:
|
|
3748
|
-
vars = {
|
|
3749
|
-
entityId: entityId,
|
|
3750
|
-
priceListCode: priceListCode,
|
|
3751
|
-
accountName: accountName,
|
|
3752
|
-
billingContact: billingContact,
|
|
3753
|
-
};
|
|
3754
|
-
return [4 /*yield*/, gqlRequest({
|
|
3755
|
-
query: MUTATION$3(),
|
|
3756
|
-
token: token,
|
|
3757
|
-
vars: vars,
|
|
3758
|
-
subdomain: subdomain,
|
|
3759
|
-
})];
|
|
3760
|
-
case 1:
|
|
3761
|
-
response = _c.sent();
|
|
3762
|
-
errors = (_b = response === null || response === void 0 ? void 0 : response.quoteAccountSignup) === null || _b === void 0 ? void 0 : _b.errors;
|
|
3763
|
-
if (errors)
|
|
3764
|
-
throw errors;
|
|
3765
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quoteAccountSignup];
|
|
3640
|
+
if (columns.includes("download")) {
|
|
3641
|
+
templateColumns.push("auto");
|
|
3766
3642
|
}
|
|
3767
|
-
}
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
var MUTATION$2 = 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}"; };
|
|
3772
|
-
var getPriceList = function (_a) {
|
|
3773
|
-
var token = _a.token, code = _a.code, subdomain = _a.subdomain;
|
|
3774
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3775
|
-
var response;
|
|
3776
|
-
return __generator(this, function (_b) {
|
|
3777
|
-
switch (_b.label) {
|
|
3778
|
-
case 0: return [4 /*yield*/, gqlRequest({
|
|
3779
|
-
query: MUTATION$2(),
|
|
3780
|
-
token: token,
|
|
3781
|
-
vars: { code: code },
|
|
3782
|
-
subdomain: subdomain,
|
|
3783
|
-
})];
|
|
3784
|
-
case 1:
|
|
3785
|
-
response = _b.sent();
|
|
3786
|
-
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.priceList];
|
|
3643
|
+
}
|
|
3644
|
+
else {
|
|
3645
|
+
if (columns.includes("date-and-title")) {
|
|
3646
|
+
templateColumns.push("auto 3fr");
|
|
3787
3647
|
}
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
}
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
firstName: "",
|
|
3800
|
-
lastName: "",
|
|
3801
|
-
email: "",
|
|
3802
|
-
accountName: "",
|
|
3803
|
-
}), formData = _b[0], setFormData = _b[1];
|
|
3804
|
-
var handleInputChange = function (e) {
|
|
3805
|
-
var _a;
|
|
3806
|
-
var _b = e.target, name = _b.name, value = _b.value;
|
|
3807
|
-
setFormData(__assign(__assign({}, formData), (_a = {}, _a[name] = value, _a)));
|
|
3648
|
+
if (columns.includes("download")) {
|
|
3649
|
+
templateColumns.push("auto");
|
|
3650
|
+
}
|
|
3651
|
+
if (columns.includes("state")) {
|
|
3652
|
+
templateColumns.push("auto");
|
|
3653
|
+
}
|
|
3654
|
+
if (columns.includes("amount")) {
|
|
3655
|
+
templateColumns.push("auto");
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
return templateColumns.join(" ");
|
|
3808
3659
|
};
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3660
|
+
var drawerTitle = function () {
|
|
3661
|
+
if (!selectedTransaction)
|
|
3662
|
+
return "";
|
|
3663
|
+
var kind = selectedTransaction.kind.toLowerCase();
|
|
3664
|
+
return kind.charAt(0).toUpperCase() + kind.slice(1);
|
|
3665
|
+
};
|
|
3666
|
+
return (jsxs("div", __assign({ style: style }, { children: [jsx(PageHeaderWithActions, __assign({ title: title || (showTitle ? "Past transactions" : undefined) }, { children: showSearchBar && (jsx("div", { children: jsx(Input, { className: searchBarClassName
|
|
3667
|
+
? searchBarClassName
|
|
3668
|
+
: "border border-slate-200", onChange: function (e) {
|
|
3669
|
+
if (isNaN(Number(e.target.value))) {
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
onSearchValueChanged(e.target.value);
|
|
3673
|
+
}, prefix: jsx(SearchOutlined$1, {}), placeholder: "Search by id #", style: {
|
|
3674
|
+
minWidth: "300px",
|
|
3675
|
+
}, value: search }) })) })), jsx(PageContent, __assign({ className: "flex w-full shadow-padding-xb ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat("shadow-".concat(shadow)), style: {
|
|
3676
|
+
gridTemplateColumns: gridTemplateColumns(),
|
|
3677
|
+
backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
|
|
3678
|
+
} }, { children: isMobile ? (jsx(Fragment, { children: TransactionsListMobile({
|
|
3679
|
+
transactions: transactions,
|
|
3680
|
+
onTransactionClick: handleTransactionClick,
|
|
3681
|
+
}) })) : (jsx(Fragment, { children: TransactionsListDesktop({
|
|
3682
|
+
transactions: transactions,
|
|
3683
|
+
onTransactionClick: handleTransactionClick,
|
|
3684
|
+
}) })) })) })), useModal ? (jsx(Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: function () { return setDrawerOpen(false); }, onCancel: function () { return setDrawerOpen(false); }, width: 900, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "" }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: function () { return setDrawerOpen(false); }, open: drawerOpen, width: 900 }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId })) : (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: Misc.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 })] })] }))) })))] })));
|
|
3827
3685
|
}
|
|
3828
3686
|
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
var
|
|
3832
|
-
var
|
|
3833
|
-
var
|
|
3834
|
-
|
|
3687
|
+
function Quotes(_a) {
|
|
3688
|
+
var filter = _a.filter, quoteComponent = _a.quoteComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.columns, columns = _d === void 0 ? ["date-and-title", "amount", "download"] : _d, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? "md" : _e, searchBarClassName = _a.searchBarClassName, _f = _a.useModal, useModal = _f === void 0 ? false : _f; _a.onQuoteClick; var _g = _a.suppressQuoteDisplay, suppressQuoteDisplay = _g === void 0 ? false : _g, style = _a.style, _h = _a.noQuotesMessage, noQuotesMessage = _h === void 0 ? "There are no quotes" : _h;
|
|
3689
|
+
var subdomain = useContext(BunnyContext).subdomain;
|
|
3690
|
+
var _j = useState(null), component = _j[0], setComponent = _j[1];
|
|
3691
|
+
var contextValues = {
|
|
3692
|
+
columns: columns,
|
|
3693
|
+
kindsToShow: [],
|
|
3694
|
+
onTransactionClick: handleQuoteClick,
|
|
3695
|
+
transactionComponent: component,
|
|
3696
|
+
showSearchBar: showSearchBar,
|
|
3697
|
+
showTitle: showTitle,
|
|
3698
|
+
className: className,
|
|
3699
|
+
shadow: shadow,
|
|
3700
|
+
searchBarClassName: searchBarClassName,
|
|
3701
|
+
useModal: useModal,
|
|
3702
|
+
suppressTransactionDisplay: suppressQuoteDisplay,
|
|
3703
|
+
style: style,
|
|
3704
|
+
noTransactionsMessage: noQuotesMessage,
|
|
3705
|
+
filter: filter,
|
|
3706
|
+
downloadTransactionLink: function (id) { return "".concat(subdomain, "/api/pdf/quote/").concat(id); },
|
|
3707
|
+
};
|
|
3708
|
+
function handleQuoteClick(quote) {
|
|
3709
|
+
if (quoteComponent) {
|
|
3710
|
+
setComponent(quoteComponent);
|
|
3711
|
+
}
|
|
3712
|
+
else {
|
|
3713
|
+
setComponent(jsx(Quote, { id: quote === null || quote === void 0 ? void 0 : quote.transactionableId }));
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
return (jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(QuotesWrapper, {}) })));
|
|
3835
3717
|
}
|
|
3836
|
-
|
|
3837
|
-
var
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3718
|
+
function QuotesWrapper() {
|
|
3719
|
+
var _a = useContext(BunnyContext), token = _a.token, subdomain = _a.subdomain;
|
|
3720
|
+
var filterFromContext = useContext(TransactionsListContext).filter;
|
|
3721
|
+
// Local state
|
|
3722
|
+
var _b = useState(""), search = _b[0], setSearch = _b[1];
|
|
3723
|
+
var filter = filterFromContext || (search ? "filter: \"quote.id is ".concat(search, "\"") : "");
|
|
3724
|
+
// Queries
|
|
3725
|
+
var data = useQuery({
|
|
3726
|
+
queryKey: ["quotes", token, filter],
|
|
3727
|
+
queryFn: function () { return getQuotes({ token: token, subdomain: subdomain, filter: filter }); },
|
|
3728
|
+
placeholderData: keepPreviousData,
|
|
3729
|
+
}).data;
|
|
3730
|
+
if (data === undefined)
|
|
3841
3731
|
return null;
|
|
3842
|
-
|
|
3732
|
+
var quotesAsTransactions = data.nodes.map(function (quote) { return ({
|
|
3733
|
+
transactionableId: quote.id,
|
|
3734
|
+
state: "unapplied",
|
|
3735
|
+
amount: quote.amount || quote.amountDue,
|
|
3736
|
+
kind: "QUOTE",
|
|
3737
|
+
currencyId: quote.currencyId,
|
|
3738
|
+
transactionable: {
|
|
3739
|
+
number: quote.number,
|
|
3740
|
+
},
|
|
3741
|
+
createdAt: quote.createdAt,
|
|
3742
|
+
}); });
|
|
3743
|
+
return (jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search, title: "Past quotes" }));
|
|
3843
3744
|
}
|
|
3844
3745
|
|
|
3845
|
-
var
|
|
3746
|
+
var DrawerHeader = function (_a) {
|
|
3747
|
+
var description = _a.description, onClose = _a.onClose, title = _a.title;
|
|
3748
|
+
return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx("div", __assign({ className: "text-xl" }, { children: title })), jsx("button", __assign({ onClick: onClose, className: "ant-drawer-close" }, { children: jsx(CloseOutlined$1, {}) }))] })), description && jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
|
|
3749
|
+
};
|
|
3750
|
+
|
|
3751
|
+
var LargeCardIcon = function () {
|
|
3752
|
+
return (jsx("svg", __assign({ width: "72", height: "56", viewBox: "0 0 72 56", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: jsx("path", { d: "M8 0H64C68.375 0 72 3.625 72 8V12H0V8C0 3.625 3.5 0 8 0ZM72 24V48C72 52.5 68.375 56 64 56H8C3.5 56 0 52.5 0 48V24H72ZM14 40C12.875 40 12 41 12 42C12 43.125 12.875 44 14 44H22C23 44 24 43.125 24 42C24 41 23 40 22 40H14ZM28 42C28 43.125 28.875 44 30 44H46C47 44 48 43.125 48 42C48 41 47 40 46 40H30C28.875 40 28 41 28 42Z", fill: "#E2E8F0" }) })));
|
|
3753
|
+
};
|
|
3754
|
+
|
|
3755
|
+
var PlusIcon = function (_a) {
|
|
3846
3756
|
var color = _a.color;
|
|
3847
|
-
return (jsxs("svg", __assign({ width: "
|
|
3757
|
+
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" })] })));
|
|
3848
3758
|
};
|
|
3849
3759
|
|
|
3850
|
-
var
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
var
|
|
3854
|
-
var
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
return null;
|
|
3859
|
-
return (jsxs("div", __assign({ className: "flex items-center justify-between shrink-0 ".concat(className, " ").concat(isMobile ? "flex-col gap-2 grow" : "") }, { children: [(termsUrl || privacyUrl) && (jsxs("div", __assign({ className: "flex items-center gap-3" }, { children: [termsUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsx(BunnyMarketingLink, {})] })));
|
|
3760
|
+
var PaymentMethodContext = createContext({});
|
|
3761
|
+
|
|
3762
|
+
var Card = function (_a) {
|
|
3763
|
+
var children = _a.children, className = _a.className, style = _a.style;
|
|
3764
|
+
var darkMode = useContext(BunnyContext).darkMode;
|
|
3765
|
+
return (jsx("div", __assign({ className: "flex flex-col rounded-md shadow-md ".concat(className), style: __assign(__assign({}, style), { backgroundColor: darkMode
|
|
3766
|
+
? "var(--row-background-dark)"
|
|
3767
|
+
: "var(--row-background)" }) }, { children: children })));
|
|
3860
3768
|
};
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
var
|
|
3865
|
-
|
|
3769
|
+
|
|
3770
|
+
var Text$6 = Typography.Text;
|
|
3771
|
+
var CreditCard = function (_a) {
|
|
3772
|
+
var _b, _c, _d;
|
|
3773
|
+
var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData;
|
|
3774
|
+
var isExpired = function (paymentMethodData) {
|
|
3775
|
+
// paymentMethodData.expirationDate
|
|
3776
|
+
var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
|
|
3777
|
+
return expDate.isBefore(dayjs());
|
|
3778
|
+
};
|
|
3779
|
+
var isMobile = useIsMobile$1();
|
|
3780
|
+
var processPublicUrl = useContext(PaymentMethodContext).processPublicUrl;
|
|
3781
|
+
return (jsxs(Card, __assign({ className: "shadow-md 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: [getCardImage((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) && (jsx("img", { alt: "Card", width: "24px", src: "".concat(processPublicUrl, "/").concat(getCardImage((_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.issuer)) })), jsx(Text$6, { children: (_d = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _d === void 0 ? void 0 : _d.description })] })), 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: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).format("MM/YY") }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
|
|
3782
|
+
};
|
|
3783
|
+
var CardAttribute = function (_a) {
|
|
3784
|
+
var title = _a.title, value = _a.value;
|
|
3785
|
+
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$6, { children: value })] })));
|
|
3786
|
+
};
|
|
3787
|
+
var CardActions = function (_a) {
|
|
3788
|
+
var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
|
|
3789
|
+
var isMobile = useIsMobile$1();
|
|
3790
|
+
return (jsxs("div", __assign({ className: "flex items-center gap-6 ".concat(isMobile ? "justify-center mt-4" : "") }, { children: [jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove payment method" })) })), jsx(Divider, { style: { height: "24px" }, type: "vertical" }), jsx(Button, __assign({ onClick: onClickUpdate, type: "primary" }, { children: "Update" }))] })));
|
|
3791
|
+
};
|
|
3792
|
+
var EmptyCard = function (_a) {
|
|
3793
|
+
var onClick = _a.onClick;
|
|
3794
|
+
var brandColor = useContext(BrandContext).brandColor;
|
|
3795
|
+
return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer bg-white shadow-md 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"] })) }))] })));
|
|
3796
|
+
};
|
|
3797
|
+
var getCardImage = function (issuer) {
|
|
3798
|
+
if (issuer === "visa")
|
|
3799
|
+
return "Visa_Brandmark_Blue_RGB_2021.png";
|
|
3800
|
+
else if (issuer === "mastercard")
|
|
3801
|
+
return "mc_symbol_opt_73_3x.png";
|
|
3802
|
+
};
|
|
3803
|
+
|
|
3804
|
+
var ActualPaymentMethod = function () {
|
|
3805
|
+
var _a = useContext(BunnyContext), token = _a.token, subdomain = _a.subdomain, graphQLClient = _a.graphQLClient;
|
|
3806
|
+
var accountId = useContext(PaymentContext).accountId;
|
|
3807
|
+
// Hooks
|
|
3808
|
+
var queryClient = useQueryClient();
|
|
3809
|
+
var paymentPlugins = usePaymentPlugins({ subdomain: subdomain, token: token }).paymentPlugins;
|
|
3810
|
+
var showErrorNotification = NotificationUtils.useErrorNotification();
|
|
3811
|
+
var showSuccessNotification = NotificationUtils.useSuccessNotification();
|
|
3812
|
+
var handleAllErrorFormats = NotificationUtils.useAllErrorFormats(function () {
|
|
3813
|
+
console.log("Navigation in PaymentMethod.tsx useAllErrorFormats not implemented");
|
|
3814
|
+
});
|
|
3815
|
+
var isMobile = useIsMobile$1();
|
|
3816
|
+
var data = usePaymentMethod(graphQLClient).data;
|
|
3817
|
+
// Local state
|
|
3818
|
+
var _b = useState(false), showModal = _b[0], setShowModal = _b[1];
|
|
3819
|
+
var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
|
|
3820
|
+
// Queries
|
|
3821
|
+
useQuery({
|
|
3822
|
+
queryKey: QueryKeyFactory.default.currentUserKey,
|
|
3823
|
+
queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
|
|
3824
|
+
});
|
|
3825
|
+
var 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); });
|
|
3826
|
+
var onClickRemove = function () {
|
|
3827
|
+
if (data && plugin) {
|
|
3828
|
+
invokePlugin({
|
|
3829
|
+
plugin: plugin,
|
|
3830
|
+
method: "remove_payment_method",
|
|
3831
|
+
payload: {
|
|
3832
|
+
payment_method_id: data.id,
|
|
3833
|
+
account_id: accountId,
|
|
3834
|
+
},
|
|
3835
|
+
token: token,
|
|
3836
|
+
subdomain: subdomain,
|
|
3837
|
+
})
|
|
3838
|
+
.then(function () {
|
|
3839
|
+
showSuccessNotification("Payment method was removed", "Success");
|
|
3840
|
+
queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey, null);
|
|
3841
|
+
})
|
|
3842
|
+
.catch(function (error) {
|
|
3843
|
+
showErrorNotification(error.message, "Error removing Payment Method");
|
|
3844
|
+
});
|
|
3845
|
+
}
|
|
3846
|
+
};
|
|
3847
|
+
var onSuccess = function () {
|
|
3848
|
+
queryClient.invalidateQueries({
|
|
3849
|
+
queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
|
|
3850
|
+
});
|
|
3851
|
+
setShowModal(false);
|
|
3852
|
+
showSuccessNotification("Your payment method has been saved");
|
|
3853
|
+
};
|
|
3854
|
+
if (data === undefined)
|
|
3855
|
+
return jsx(Fragment, {});
|
|
3856
|
+
return (jsxs(Fragment, { children: [data ? (jsx(CreditCard, { onClickRemove: onClickRemove, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data })) : (jsx(EmptyCard, { onClick: function () { return setShowModal(true); } })), jsx(Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
|
|
3857
|
+
body: isMobile
|
|
3858
|
+
? {
|
|
3859
|
+
padding: "1rem 0 0",
|
|
3860
|
+
}
|
|
3861
|
+
: {},
|
|
3862
|
+
wrapper: isMobile ? { width: "100vw" } : { width: "min-content" },
|
|
3863
|
+
}, title: jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method" }) }, { children: jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
|
|
3864
|
+
handleAllErrorFormats(error);
|
|
3865
|
+
setIsSaving(false);
|
|
3866
|
+
}, onPaymentSuccess: function () {
|
|
3867
|
+
onSuccess();
|
|
3868
|
+
setIsSaving(false);
|
|
3869
|
+
}, setIsSaving: setIsSaving }) }))] }));
|
|
3866
3870
|
};
|
|
3867
|
-
|
|
3868
|
-
var
|
|
3869
|
-
|
|
3871
|
+
function PaymentMethod(_a) {
|
|
3872
|
+
var footer = _a.footer, processPublicUrl = _a.processPublicUrl;
|
|
3873
|
+
return (jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer, processPublicUrl: processPublicUrl } }, { children: jsx(ActualPaymentMethod, {}) })));
|
|
3874
|
+
}
|
|
3870
3875
|
|
|
3871
|
-
var MUTATION$
|
|
3872
|
-
var
|
|
3873
|
-
var
|
|
3876
|
+
var MUTATION$5 = "\nmutation accountUpdate(\n $id: ID!,\n $attributes: AccountAttributes!) {\n accountUpdate(\n id: $id,\n attributes: $attributes\n ) {\n account { id }\n errors\n }\n }\n";
|
|
3877
|
+
var accountUpdate = function (_a) {
|
|
3878
|
+
var accountId = _a.accountId, attributes = _a.attributes, token = _a.token;
|
|
3874
3879
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
3875
|
-
var response, errors;
|
|
3880
|
+
var vars, response, errors;
|
|
3876
3881
|
var _b;
|
|
3877
3882
|
return __generator(this, function (_c) {
|
|
3878
3883
|
switch (_c.label) {
|
|
3879
|
-
case 0:
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
|
|
3883
|
-
subdomain: subdomain,
|
|
3884
|
-
})];
|
|
3884
|
+
case 0:
|
|
3885
|
+
vars = { id: accountId, attributes: attributes };
|
|
3886
|
+
return [4 /*yield*/, gqlRequest({ query: MUTATION$5, token: token, vars: vars })];
|
|
3885
3887
|
case 1:
|
|
3886
3888
|
response = _c.sent();
|
|
3887
|
-
errors = (response === null || response === void 0 ? void 0 : response.
|
|
3889
|
+
errors = (_b = response === null || response === void 0 ? void 0 : response.accountUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
3888
3890
|
if (errors)
|
|
3889
3891
|
throw errors;
|
|
3890
|
-
return [2 /*return*/,
|
|
3892
|
+
return [2 /*return*/, response.accountUpdate];
|
|
3891
3893
|
}
|
|
3892
3894
|
});
|
|
3893
3895
|
});
|
|
3894
3896
|
};
|
|
3895
3897
|
|
|
3896
|
-
var
|
|
3897
|
-
function
|
|
3898
|
-
var
|
|
3898
|
+
var COUNTRIES_REQUIRING_STATE = ["US", "CA"];
|
|
3899
|
+
var TaxationForm = function (_a) {
|
|
3900
|
+
var account = _a.account, quote = _a.quote;
|
|
3899
3901
|
// Hooks
|
|
3900
|
-
var
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
var entityId = useCurrentUserData().entityId;
|
|
3908
|
-
var _c = useState(undefined), quote = _c[0], setQuote = _c[1];
|
|
3909
|
-
var _d = useState(undefined), accountId = _d[0], setAccountId = _d[1];
|
|
3910
|
-
var _e = useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
|
|
3911
|
-
var _f = useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
|
|
3912
|
-
var _g = useState(undefined), formData = _g[0], setFormData = _g[1];
|
|
3913
|
-
var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
|
|
3914
|
-
var _j = useState(false), paying = _j[0], setIsPaying = _j[1];
|
|
3915
|
-
var _k = useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
|
|
3916
|
-
// Queries
|
|
3917
|
-
var priceListData = useQuery({
|
|
3918
|
-
queryKey: ["priceList", priceListCode],
|
|
3919
|
-
queryFn: function () { return getPriceList({ token: token, subdomain: subdomain, code: priceListCode }); },
|
|
3920
|
-
}).data;
|
|
3921
|
-
function handleSubmit(formData) {
|
|
3922
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3923
|
-
var data, portalSessionToken;
|
|
3902
|
+
var queryClient = useQueryClient();
|
|
3903
|
+
var token = useContext(BunnyContext).token;
|
|
3904
|
+
var form = Form.useForm()[0];
|
|
3905
|
+
// Mutations
|
|
3906
|
+
var _b = useMutation({
|
|
3907
|
+
mutationFn: function (changedFormData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3908
|
+
var account;
|
|
3924
3909
|
return __generator(this, function (_a) {
|
|
3925
3910
|
switch (_a.label) {
|
|
3926
|
-
case 0:
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
subdomain: subdomain,
|
|
3932
|
-
entityId: entityId,
|
|
3933
|
-
priceListCode: priceListCode,
|
|
3934
|
-
accountName: formData.accountName,
|
|
3935
|
-
billingContact: {
|
|
3936
|
-
firstName: formData.firstName,
|
|
3937
|
-
lastName: formData.lastName,
|
|
3938
|
-
email: formData.email,
|
|
3939
|
-
},
|
|
3940
|
-
})];
|
|
3911
|
+
case 0: return [4 /*yield*/, accountUpdate({
|
|
3912
|
+
accountId: quote.accountId,
|
|
3913
|
+
attributes: changedFormData,
|
|
3914
|
+
token: token,
|
|
3915
|
+
})];
|
|
3941
3916
|
case 1:
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
return [4 /*yield*/, portalSessionCreate({
|
|
3945
|
-
token: token,
|
|
3946
|
-
subdomain: subdomain,
|
|
3947
|
-
tenantCode: data.tenant.code,
|
|
3948
|
-
expiry: 24,
|
|
3949
|
-
returnUrl: returnUrl || "",
|
|
3950
|
-
})];
|
|
3951
|
-
case 2:
|
|
3952
|
-
portalSessionToken = _a.sent();
|
|
3953
|
-
setPortalSessionToken(portalSessionToken);
|
|
3954
|
-
setQuoteId(data.quote.id);
|
|
3955
|
-
setProceedingToPayment(false);
|
|
3956
|
-
setQuote({
|
|
3957
|
-
amountDue: data.quote.amountDue,
|
|
3958
|
-
currencyId: data.quote.currencyId,
|
|
3959
|
-
});
|
|
3960
|
-
return [2 /*return*/];
|
|
3917
|
+
account = _a.sent();
|
|
3918
|
+
return [2 /*return*/, account];
|
|
3961
3919
|
}
|
|
3962
3920
|
});
|
|
3963
|
-
});
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3921
|
+
}); },
|
|
3922
|
+
onSuccess: function () {
|
|
3923
|
+
queryClient.invalidateQueries({
|
|
3924
|
+
queryKey: ["getTaxationRequiredAccountFields", token],
|
|
3925
|
+
});
|
|
3926
|
+
},
|
|
3927
|
+
}), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
|
|
3928
|
+
return (jsxs(Form, __assign({ className: "flex flex-col gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsx(Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsx(Input, { placeholder: "Street" }) })), jsx(Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsx(Input, { placeholder: "City" }) })), jsx(FormBillingState, { form: form }), jsx(Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsx(Select, { options: Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
|
|
3929
|
+
var _a, _b;
|
|
3930
|
+
return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
|
|
3931
|
+
((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
|
|
3932
|
+
} }) })), jsx(Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsx(Input, { placeholder: "Zip" }) })), jsx(Form.Item, { children: jsx(Button, __assign({ className: "w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
|
|
3933
|
+
};
|
|
3934
|
+
var FormBillingState = function (_a) {
|
|
3935
|
+
_a.form;
|
|
3936
|
+
var billingCountry = Form.useWatch("billingCountry");
|
|
3937
|
+
var billingStateRequired = COUNTRIES_REQUIRING_STATE.includes(billingCountry);
|
|
3938
|
+
return (jsx(Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsx(Input, { placeholder: "State" }) })));
|
|
3939
|
+
};
|
|
3940
|
+
|
|
3941
|
+
var QuoteCheckout = function (_a) {
|
|
3942
|
+
var account = _a.account, isSaving = _a.isSaving, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, setIsSaving = _a.setIsSaving, taxationRequiredAccountFields = _a.taxationRequiredAccountFields; _a.storedPaymentMethod;
|
|
3943
|
+
// Context
|
|
3944
|
+
var isMobile = useIsMobile$1();
|
|
3945
|
+
var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token;
|
|
3946
|
+
var paymentRequired = getQuoteAmountDue(quote) > 0;
|
|
3947
|
+
var checkoutMutation = useMutation({
|
|
3948
|
+
mutationFn: function (_a) {
|
|
3949
|
+
var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.storedPaymentMethod;
|
|
3950
|
+
if (!quote)
|
|
3951
|
+
throw new Error("Quote is required");
|
|
3952
|
+
if (!paymentRequired)
|
|
3953
|
+
return checkout({ quoteId: quote.id, token: token, subdomain: subdomain });
|
|
3954
|
+
if (savedPaymentMethod) {
|
|
3955
|
+
var paymentMethodId = savedPaymentMethod.paymentMethodId;
|
|
3956
|
+
return checkout({
|
|
3957
|
+
quoteId: quote.id,
|
|
3958
|
+
paymentMethodId: paymentMethodId,
|
|
3959
|
+
token: token,
|
|
3960
|
+
subdomain: subdomain,
|
|
3961
|
+
});
|
|
3962
|
+
}
|
|
3963
|
+
if (pluginPaymentMethod) {
|
|
3964
|
+
var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
|
|
3965
|
+
var paymentToken = pluginPaymentMethod.token;
|
|
3966
|
+
return checkout({
|
|
3967
|
+
quoteId: quote.id,
|
|
3968
|
+
paymentMethodData: {
|
|
3969
|
+
metadata: metadata,
|
|
3970
|
+
pluginGuid: plugin.guid,
|
|
3971
|
+
savePaymentMethod: savePaymentMethod,
|
|
3972
|
+
token: paymentToken,
|
|
3973
|
+
},
|
|
3974
|
+
token: token,
|
|
3975
|
+
subdomain: subdomain,
|
|
3976
|
+
});
|
|
3977
|
+
}
|
|
3978
|
+
throw new Error("Pay payment method provided");
|
|
3979
|
+
},
|
|
3980
|
+
onSuccess: onSuccess,
|
|
3981
|
+
onError: onFail,
|
|
3982
|
+
});
|
|
3983
|
+
// Handlers
|
|
3984
|
+
var handleCheckout = function (_a) {
|
|
3985
|
+
var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
|
|
3986
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
3987
|
+
var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
|
|
3969
3988
|
return __generator(this, function (_b) {
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
paymentMethodId: (_a = paymentSuccess.savedPaymentMethodResponse) === null || _a === void 0 ? void 0 : _a.paymentMethodId.toString(),
|
|
3992
|
-
pluginId: plugin.id.toString(),
|
|
3993
|
-
priceListCode: priceListCode,
|
|
3994
|
-
accountId: accountId,
|
|
3995
|
-
})];
|
|
3996
|
-
case 1:
|
|
3997
|
-
_b.sent();
|
|
3998
|
-
setIsPaying(false);
|
|
3999
|
-
setPurchaseSucceeded(true);
|
|
4000
|
-
return [2 /*return*/];
|
|
3989
|
+
if (pluginPaymentResponse) {
|
|
3990
|
+
token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
|
|
3991
|
+
checkoutMutation.mutate({
|
|
3992
|
+
pluginPaymentMethod: {
|
|
3993
|
+
savePaymentMethod: savePaymentMethod,
|
|
3994
|
+
plugin: plugin,
|
|
3995
|
+
metadata: metadata,
|
|
3996
|
+
token: token_1,
|
|
3997
|
+
},
|
|
3998
|
+
});
|
|
3999
|
+
}
|
|
4000
|
+
else if (savedPaymentMethodResponse) {
|
|
4001
|
+
paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
|
|
4002
|
+
checkoutMutation.mutate({
|
|
4003
|
+
storedPaymentMethod: {
|
|
4004
|
+
paymentMethodId: paymentMethodId,
|
|
4005
|
+
},
|
|
4006
|
+
});
|
|
4007
|
+
}
|
|
4008
|
+
else {
|
|
4009
|
+
checkoutMutation.mutate({});
|
|
4001
4010
|
}
|
|
4011
|
+
return [2 /*return*/];
|
|
4002
4012
|
});
|
|
4003
4013
|
});
|
|
4004
|
-
}
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
else {
|
|
4013
|
-
return (jsxs(Fragment, { children: [jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, returnUrl: returnUrl })) : (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsx("div", __assign({ className: "flex flex-col w-1/2 items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "my-4" }, { children: jsx(Divider, { className: "h-full", type: "vertical" }) })), jsx("div", __assign({ className: "flex w-1/2 items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })), jsx(Footer, {})] }));
|
|
4014
|
-
}
|
|
4015
|
-
}
|
|
4014
|
+
};
|
|
4015
|
+
if (taxationRequiredAccountFields)
|
|
4016
|
+
return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
|
|
4017
|
+
return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { isSaving: isSaving, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, setIsSaving: setIsSaving })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button, __assign({ disabled: isSaving, onClick: function () {
|
|
4018
|
+
setIsSaving(true);
|
|
4019
|
+
handleCheckout({});
|
|
4020
|
+
}, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
|
|
4021
|
+
};
|
|
4016
4022
|
|
|
4017
|
-
var
|
|
4018
|
-
var
|
|
4019
|
-
var
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4023
|
+
var useHasTaxPlugin = function (_a) {
|
|
4024
|
+
var subdomain = _a.subdomain, token = _a.token;
|
|
4025
|
+
var plugins = usePlugins({
|
|
4026
|
+
subdomain: subdomain,
|
|
4027
|
+
token: token,
|
|
4028
|
+
}).data;
|
|
4029
|
+
return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
|
|
4030
|
+
};
|
|
4031
|
+
|
|
4032
|
+
var QUOTE_FIELDS = "quote {\n formattedQuote {\n html\n }\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\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 invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n ownerId\n periodAmount\n poNumber\n requiresApproval\n startDate\n state\n subtotal\n taxAmount\n updatedAt\n uuid\n amountsByPeriod {\n amount\n id\n name\n }\n endDateOptions {\n endDate\n label\n }\n invoiceUntilOptions {\n endDate\n label\n }\n quoteChanges {\n id\n priceListId\n charges {\n amount\n amountsByPeriod { amount startDate }\n billingPeriod\n billingPeriodAmounts { id amount prorationRate }\n chargeType\n couponId\n createdAt\n currencyId\n discount\n endDate\n feature { id name code isUnit unitName }\n id\n invoiceLineText\n name\n price\n priceDecimals\n priceTiers { starts price }\n pricingModel\n prorationRate\n quantity\n quantityMax\n quantityMin\n startDate\n tieredAveragePrice\n updatedAt\n }\n }\n}";
|
|
4033
|
+
|
|
4034
|
+
var QUOTE_RECALCULATE_TAXES = "\n mutation QuoteRecalculateTaxes($id: ID!) {\n quoteRecalculateTaxes(id: $id) {\n ".concat(QUOTE_FIELDS, "\n errors\n }\n }\n");
|
|
4035
|
+
var quoteRecalculateTaxes = function (_a) {
|
|
4036
|
+
var quoteId = _a.quoteId, token = _a.token;
|
|
4037
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4038
|
+
var vars, response, errors;
|
|
4039
|
+
var _b, _c;
|
|
4040
|
+
return __generator(this, function (_d) {
|
|
4041
|
+
switch (_d.label) {
|
|
4042
|
+
case 0:
|
|
4043
|
+
vars = { id: quoteId };
|
|
4044
|
+
return [4 /*yield*/, gqlRequest({
|
|
4045
|
+
query: QUOTE_RECALCULATE_TAXES,
|
|
4046
|
+
token: token,
|
|
4047
|
+
vars: vars,
|
|
4048
|
+
})];
|
|
4049
|
+
case 1:
|
|
4050
|
+
response = _d.sent();
|
|
4051
|
+
errors = (_b = response === null || response === void 0 ? void 0 : response.quoteRecalculateTaxes) === null || _b === void 0 ? void 0 : _b.errors;
|
|
4052
|
+
if (errors)
|
|
4053
|
+
throw errors;
|
|
4054
|
+
return [2 /*return*/, (_c = response.quoteRecalculateTaxes) === null || _c === void 0 ? void 0 : _c.quote];
|
|
4055
|
+
}
|
|
4056
|
+
});
|
|
4044
4057
|
});
|
|
4045
|
-
}
|
|
4058
|
+
};
|
|
4046
4059
|
|
|
4047
|
-
var
|
|
4048
|
-
key: "
|
|
4060
|
+
var planPickerQuoteDataState = atom({
|
|
4061
|
+
key: "planPickerQuoteDataState",
|
|
4049
4062
|
default: undefined,
|
|
4050
4063
|
});
|
|
4051
4064
|
|
|
4052
|
-
var
|
|
4053
|
-
|
|
4054
|
-
var pageContentRef = useRef(null);
|
|
4055
|
-
var setPageContentRef = useSetRecoilState(pageContentRefState);
|
|
4056
|
-
useEffect(function () {
|
|
4057
|
-
setPageContentRef(pageContentRef === null || pageContentRef === void 0 ? void 0 : pageContentRef.current);
|
|
4058
|
-
}, [pageContentRef, setPageContentRef]);
|
|
4059
|
-
return (jsx("div", __assign({ className: className, ref: pageContentRef, style: style }, { children: children })));
|
|
4065
|
+
var pageWrapperClassName = function (isMobile) {
|
|
4066
|
+
return "flex flex-col grow pt-4 ".concat(isMobile ? "pb-4 overflow-hidden" : "pb-8", " ").concat("content-container");
|
|
4060
4067
|
};
|
|
4061
4068
|
|
|
4062
|
-
var
|
|
4063
|
-
var
|
|
4064
|
-
var
|
|
4065
|
-
var isMobile =
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
var
|
|
4069
|
-
var
|
|
4070
|
-
var
|
|
4071
|
-
|
|
4072
|
-
|
|
4069
|
+
var queryKeyFactory = QueryKeyFactory.default;
|
|
4070
|
+
var Checkout = function (_a) {
|
|
4071
|
+
var _b, _c;
|
|
4072
|
+
var onCancel = _a.onCancel, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, isMobile = _a.isMobile, token = _a.token, storedPaymentMethod = _a.storedPaymentMethod;
|
|
4073
|
+
var subdomain = useContext(BunnyContext).subdomain;
|
|
4074
|
+
var _d = useState(false), isSaving = _d[0], setIsSaving = _d[1];
|
|
4075
|
+
var hasTaxPlugin = useHasTaxPlugin({ subdomain: subdomain || "", token: token });
|
|
4076
|
+
var queryClient = useQueryClient();
|
|
4077
|
+
var quotePreviewData = useRecoilValue(planPickerQuoteDataState);
|
|
4078
|
+
// Queries
|
|
4079
|
+
var _e = useQuery({
|
|
4080
|
+
queryKey: ["getTaxationRequiredAccountFields", token],
|
|
4081
|
+
queryFn: function () { return getTaxationRequiredAccountFields({ token: token }); },
|
|
4082
|
+
enabled: Boolean(quote),
|
|
4083
|
+
staleTime: 0,
|
|
4084
|
+
}), taxationRequiredAccountFields = _e.data, isLoadingTaxationRequiredAccountFields = _e.isLoading;
|
|
4085
|
+
var _f = useQuery({
|
|
4086
|
+
queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
|
|
4087
|
+
queryFn: function () {
|
|
4088
|
+
return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, token: token });
|
|
4089
|
+
},
|
|
4090
|
+
enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
|
|
4091
|
+
((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
|
|
4092
|
+
}), account = _f.data, isLoadingAccount = _f.isLoading;
|
|
4093
|
+
useQuery({
|
|
4094
|
+
queryKey: queryKeyFactory.createQuoteTaxCalculateKey(quote === null || quote === void 0 ? void 0 : quote.id),
|
|
4095
|
+
queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4096
|
+
var updatedQuote;
|
|
4097
|
+
return __generator(this, function (_a) {
|
|
4098
|
+
switch (_a.label) {
|
|
4099
|
+
case 0:
|
|
4100
|
+
if (!quote) return [3 /*break*/, 2];
|
|
4101
|
+
return [4 /*yield*/, quoteRecalculateTaxes({
|
|
4102
|
+
quoteId: quote.id,
|
|
4103
|
+
token: token,
|
|
4104
|
+
})];
|
|
4105
|
+
case 1:
|
|
4106
|
+
updatedQuote = _a.sent();
|
|
4107
|
+
if (updatedQuote) {
|
|
4108
|
+
queryClient.setQueryData(queryKeyFactory.createObjectKey("editingQuote", updatedQuote.id), updatedQuote);
|
|
4109
|
+
queryClient.setQueryData(queryKeyFactory.calculatedPricesKey((quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) || 0, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
|
|
4110
|
+
}
|
|
4111
|
+
_a.label = 2;
|
|
4112
|
+
case 2: return [2 /*return*/, {}];
|
|
4113
|
+
}
|
|
4114
|
+
});
|
|
4115
|
+
}); },
|
|
4116
|
+
// Recalculate taxes if the quote is open, has a tax plugin, and the taxation required account fields are not required
|
|
4117
|
+
enabled: Boolean(quote) &&
|
|
4118
|
+
open &&
|
|
4119
|
+
hasTaxPlugin &&
|
|
4120
|
+
!taxationRequiredAccountFields &&
|
|
4121
|
+
!isLoadingTaxationRequiredAccountFields,
|
|
4122
|
+
staleTime: 0,
|
|
4123
|
+
});
|
|
4124
|
+
if (!open || isLoadingTaxationRequiredAccountFields || isLoadingAccount)
|
|
4125
|
+
return null;
|
|
4126
|
+
return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
|
|
4127
|
+
zIndex: 1001,
|
|
4128
|
+
} }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : "", isMobile: isMobile })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx(InvoiceCheckout, { invoice: invoice, isSaving: isSaving, onFail: function (error) {
|
|
4129
|
+
onFail(error);
|
|
4130
|
+
setIsSaving(false);
|
|
4131
|
+
}, onSuccess: function (_a) {
|
|
4132
|
+
var savePaymentMethod = _a.savePaymentMethod;
|
|
4133
|
+
onSuccess({ savePaymentMethod: savePaymentMethod });
|
|
4134
|
+
setIsSaving(false);
|
|
4135
|
+
}, setIsSaving: setIsSaving })) : quote ? (jsx(QuoteCheckout, { account: account, isSaving: isSaving, onFail: function (error) {
|
|
4136
|
+
onFail(error);
|
|
4137
|
+
setIsSaving(false);
|
|
4138
|
+
}, onSuccess: function (_a) {
|
|
4139
|
+
var savePaymentMethod = _a.savePaymentMethod;
|
|
4140
|
+
onSuccess({ savePaymentMethod: savePaymentMethod });
|
|
4141
|
+
setIsSaving(false);
|
|
4142
|
+
}, quote: quote, setIsSaving: setIsSaving, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token, storedPaymentMethod: storedPaymentMethod })) : (jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
|
|
4143
|
+
onFail(error);
|
|
4144
|
+
setIsSaving(false);
|
|
4145
|
+
}, onPaymentSuccess: function (_a) {
|
|
4146
|
+
var pluginPaymentResponse = _a.pluginPaymentResponse;
|
|
4147
|
+
onSuccess({
|
|
4148
|
+
savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
|
|
4149
|
+
});
|
|
4150
|
+
setIsSaving(false);
|
|
4151
|
+
}, setIsSaving: setIsSaving }))] }))] })) })));
|
|
4073
4152
|
};
|
|
4074
4153
|
|
|
4075
|
-
var
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
var
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4154
|
+
var MUTATION$4 = 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}"; };
|
|
4155
|
+
var accountSignup = function (_a) {
|
|
4156
|
+
var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode;
|
|
4157
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4158
|
+
var vars, response, errors;
|
|
4159
|
+
var _b;
|
|
4160
|
+
return __generator(this, function (_c) {
|
|
4161
|
+
switch (_c.label) {
|
|
4162
|
+
case 0:
|
|
4163
|
+
vars = {
|
|
4164
|
+
entityId: entityId,
|
|
4165
|
+
accountId: accountId,
|
|
4166
|
+
quoteId: quoteId,
|
|
4167
|
+
paymentToken: paymentToken,
|
|
4168
|
+
pluginId: pluginId,
|
|
4169
|
+
paymentMethodId: paymentMethodId,
|
|
4170
|
+
priceListCode: priceListCode,
|
|
4171
|
+
};
|
|
4172
|
+
return [4 /*yield*/, gqlRequest({
|
|
4173
|
+
query: MUTATION$4(),
|
|
4174
|
+
token: token,
|
|
4175
|
+
vars: vars,
|
|
4176
|
+
subdomain: subdomain,
|
|
4177
|
+
})];
|
|
4178
|
+
case 1:
|
|
4179
|
+
response = _c.sent();
|
|
4180
|
+
errors = (_b = response === null || response === void 0 ? void 0 : response.accountSignup) === null || _b === void 0 ? void 0 : _b.errors;
|
|
4181
|
+
if (errors)
|
|
4182
|
+
throw errors;
|
|
4183
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.accountSignup];
|
|
4184
|
+
}
|
|
4185
|
+
});
|
|
4186
|
+
});
|
|
4103
4187
|
};
|
|
4104
4188
|
|
|
4105
|
-
var
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
var
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4189
|
+
var MUTATION$3 = 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 amount\n currencyId\n quote {\n id\n }\n tenant {\n code\n }\n errors\n }\n}"; };
|
|
4190
|
+
var quoteAccountSignup = function (_a) {
|
|
4191
|
+
var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
|
|
4192
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4193
|
+
var vars, response, errors;
|
|
4194
|
+
var _b;
|
|
4195
|
+
return __generator(this, function (_c) {
|
|
4196
|
+
switch (_c.label) {
|
|
4197
|
+
case 0:
|
|
4198
|
+
vars = {
|
|
4199
|
+
entityId: entityId,
|
|
4200
|
+
priceListCode: priceListCode,
|
|
4201
|
+
accountName: accountName,
|
|
4202
|
+
billingContact: billingContact,
|
|
4203
|
+
};
|
|
4204
|
+
return [4 /*yield*/, gqlRequest({
|
|
4205
|
+
query: MUTATION$3(),
|
|
4206
|
+
token: token,
|
|
4207
|
+
vars: vars,
|
|
4208
|
+
subdomain: subdomain,
|
|
4209
|
+
})];
|
|
4210
|
+
case 1:
|
|
4211
|
+
response = _c.sent();
|
|
4212
|
+
errors = (_b = response === null || response === void 0 ? void 0 : response.quoteAccountSignup) === null || _b === void 0 ? void 0 : _b.errors;
|
|
4213
|
+
if (errors)
|
|
4214
|
+
throw errors;
|
|
4215
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quoteAccountSignup];
|
|
4216
|
+
}
|
|
4217
|
+
});
|
|
4218
|
+
});
|
|
4116
4219
|
};
|
|
4117
4220
|
|
|
4118
|
-
var
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4221
|
+
var MUTATION$2 = 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}"; };
|
|
4222
|
+
var getPriceList = function (_a) {
|
|
4223
|
+
var token = _a.token, code = _a.code, subdomain = _a.subdomain;
|
|
4224
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4225
|
+
var response;
|
|
4226
|
+
return __generator(this, function (_b) {
|
|
4227
|
+
switch (_b.label) {
|
|
4228
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
4229
|
+
query: MUTATION$2(),
|
|
4230
|
+
token: token,
|
|
4231
|
+
vars: { code: code },
|
|
4232
|
+
subdomain: subdomain,
|
|
4233
|
+
})];
|
|
4234
|
+
case 1:
|
|
4235
|
+
response = _b.sent();
|
|
4236
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.priceList];
|
|
4237
|
+
}
|
|
4238
|
+
});
|
|
4239
|
+
});
|
|
4130
4240
|
};
|
|
4131
4241
|
|
|
4132
|
-
|
|
4133
|
-
var
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4242
|
+
function PaymentForms(_a) {
|
|
4243
|
+
var quote = _a.quote, paying = _a.paying, setIsPaying = _a.setIsPaying, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId;
|
|
4244
|
+
return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: accountId && (jsx(PaymentContext.Provider, __assign({ value: { accountId: accountId, displayPayButtonNameAnyways: true } }, { children: jsx(PaymentForm, { isSaving: paying, setIsSaving: setIsPaying, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
|
|
4245
|
+
}
|
|
4246
|
+
function InitialSignupForm(_a) {
|
|
4247
|
+
var onSubmit = _a.onSubmit, submitting = _a.submitting;
|
|
4248
|
+
var _b = useState({
|
|
4249
|
+
firstName: "",
|
|
4250
|
+
lastName: "",
|
|
4251
|
+
email: "",
|
|
4252
|
+
accountName: "",
|
|
4253
|
+
}), formData = _b[0], setFormData = _b[1];
|
|
4254
|
+
var handleInputChange = function (e) {
|
|
4255
|
+
var _a;
|
|
4256
|
+
var _b = e.target, name = _b.name, value = _b.value;
|
|
4257
|
+
setFormData(__assign(__assign({}, formData), (_a = {}, _a[name] = value, _a)));
|
|
4258
|
+
};
|
|
4259
|
+
return (jsxs(Form, __assign({ className: "flex w-1/2 flex-col justify-between h-full", onFinish: function () { return onSubmit(formData); } }, { children: [jsxs("div", __assign({ className: "flex flex-col space-y-2" }, { children: [jsx(Form.Item, __assign({ rules: [{ required: true, message: "Please input your first name!" }], initialValue: formData.firstName }, { children: jsx(Input, { placeholder: "First name", value: formData.firstName, onChange: function (e) {
|
|
4260
|
+
handleInputChange(e);
|
|
4261
|
+
setFormData(__assign(__assign({}, formData), { firstName: e.target.value }));
|
|
4262
|
+
} }) })), jsx(Form.Item, __assign({ rules: [{ required: true, message: "Please input your last name!" }], initialValue: formData.lastName }, { children: jsx(Input, { placeholder: "Last name", value: formData.lastName, onChange: function (e) {
|
|
4263
|
+
handleInputChange(e);
|
|
4264
|
+
setFormData(__assign(__assign({}, formData), { lastName: e.target.value }));
|
|
4265
|
+
} }) })), jsx(Form.Item, __assign({ rules: [
|
|
4266
|
+
{ required: true, message: "Please input your email!" },
|
|
4267
|
+
{ type: "email", message: "Please enter a valid email!" },
|
|
4268
|
+
], initialValue: formData.email }, { children: jsx(Input, { placeholder: "Email", value: formData.email, onChange: function (e) {
|
|
4269
|
+
handleInputChange(e);
|
|
4270
|
+
setFormData(__assign(__assign({}, formData), { email: e.target.value }));
|
|
4271
|
+
} }) })), jsx(Form.Item, __assign({ rules: [
|
|
4272
|
+
{ required: true, message: "Please input your account name!" },
|
|
4273
|
+
], initialValue: formData.accountName }, { children: jsx(Input, { placeholder: "Account name", value: formData.accountName, onChange: function (e) {
|
|
4274
|
+
handleInputChange(e);
|
|
4275
|
+
setFormData(__assign(__assign({}, formData), { accountName: e.target.value }));
|
|
4276
|
+
} }) }))] })), jsx(Form.Item, { children: jsx(Button, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
|
|
4277
|
+
}
|
|
4137
4278
|
|
|
4138
|
-
var
|
|
4279
|
+
var Title = Typography.Title, Text$5 = Typography.Text;
|
|
4280
|
+
function PaymentSuccessDisplay(_a) {
|
|
4281
|
+
var className = _a.className, amountPaid = _a.amountPaid, style = _a.style, returnUrl = _a.returnUrl;
|
|
4282
|
+
var window = useContext(BunnyContext).window;
|
|
4283
|
+
var companyName = useCurrentUserData().companyName;
|
|
4284
|
+
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 ", Misc.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxs(Text$5, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
|
|
4285
|
+
}
|
|
4139
4286
|
|
|
4140
|
-
var
|
|
4141
|
-
|
|
4142
|
-
var
|
|
4143
|
-
|
|
4144
|
-
var downloadFile = useDownloadFile();
|
|
4145
|
-
var isMobile = useIsMobile$1();
|
|
4146
|
-
var isClickable = transaction.kind === "INVOICE" || downloadTransactionLink !== undefined;
|
|
4147
|
-
var downloadLink = downloadTransactionLink
|
|
4148
|
-
? downloadTransactionLink(transaction.transactionableId)
|
|
4149
|
-
: "".concat(subdomain, "/api/pdf/invoice/").concat(transaction.transactionableId);
|
|
4150
|
-
if (!isClickable)
|
|
4287
|
+
var Text$4 = Typography.Text;
|
|
4288
|
+
function PriceListDisplay(_a) {
|
|
4289
|
+
var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
|
|
4290
|
+
if (!priceListData)
|
|
4151
4291
|
return null;
|
|
4152
|
-
return (jsx("div", __assign({
|
|
4153
|
-
|
|
4154
|
-
downloadFile(downloadLink, token);
|
|
4155
|
-
} }, { children: jsx(ArrowDownToLine, { className: "".concat(isMobile ? "" : "show-on-hover"), color: darkMode ? WHITE : SLATE_600 }) })));
|
|
4156
|
-
};
|
|
4292
|
+
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$4, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$4, __assign({ className: "font-bold text-xl" }, { children: [Misc.formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$4, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$4, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))] })) })) }));
|
|
4293
|
+
}
|
|
4157
4294
|
|
|
4158
|
-
var
|
|
4159
|
-
var
|
|
4160
|
-
|
|
4161
|
-
return (jsx(Text$6, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
|
|
4295
|
+
var BunnyFooterIcon = function (_a) {
|
|
4296
|
+
var color = _a.color;
|
|
4297
|
+
return (jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsx("path", { className: "icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsx("path", { className: "icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsx("path", { className: "icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsx("path", { className: "icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsx("path", { className: "icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsx("path", { className: "icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsx("defs", { children: jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
|
|
4162
4298
|
};
|
|
4163
4299
|
|
|
4164
|
-
function
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
var
|
|
4168
|
-
var
|
|
4169
|
-
var
|
|
4170
|
-
var
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
};
|
|
4174
|
-
var getLocalStorageSubdomain = function () {
|
|
4175
|
-
var warrenState = JSON.parse(window.localStorage.getItem(WARREN_STATE_LS_KEY) || "{}");
|
|
4176
|
-
var subdomain = warrenState[CURRENT_WARREN_ID_LS_KEY];
|
|
4177
|
-
if (!subdomain) {
|
|
4178
|
-
console.warn("ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED");
|
|
4179
|
-
//throw new Error(ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED);
|
|
4180
|
-
}
|
|
4181
|
-
return subdomain;
|
|
4182
|
-
};
|
|
4183
|
-
var getApiHost = function (subdomain) {
|
|
4184
|
-
var isLocalHost = window.location.href.indexOf(".internal") > 0;
|
|
4185
|
-
var sub = subdomain || getLocalStorageSubdomain();
|
|
4186
|
-
if (getIsCapacitorApp()) {
|
|
4187
|
-
return isLocalHost || process.env.REACT_APP_IS_INTERNAL === "true"
|
|
4188
|
-
? "https://".concat(sub, ".bunny.internal")
|
|
4189
|
-
: "https://".concat(sub, ".").concat(process.env.REACT_APP_ROOT_DOMAIN);
|
|
4190
|
-
}
|
|
4191
|
-
return "";
|
|
4192
|
-
};
|
|
4193
|
-
var getGraphQLBase = function () {
|
|
4194
|
-
if (getIsCapacitorApp()) {
|
|
4195
|
-
return "".concat(getApiHost(), "/graphql");
|
|
4196
|
-
}
|
|
4197
|
-
return "/graphql";
|
|
4300
|
+
var Footer = function (_a) {
|
|
4301
|
+
var className = _a.className;
|
|
4302
|
+
var _b = useCurrentUserData(), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
|
|
4303
|
+
var window = useContext(BunnyContext).window;
|
|
4304
|
+
var isMobile = useIsMobile(window);
|
|
4305
|
+
var quotePreviewData = useRecoilValue(planPickerQuoteDataState);
|
|
4306
|
+
var selectedPriceList = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList;
|
|
4307
|
+
if (selectedPriceList && isMobile)
|
|
4308
|
+
return null;
|
|
4309
|
+
return (jsxs("div", __assign({ className: "flex items-center justify-between shrink-0 ".concat(className, " ").concat(isMobile ? "flex-col gap-2 grow" : "") }, { children: [(termsUrl || privacyUrl) && (jsxs("div", __assign({ className: "flex items-center gap-3" }, { children: [termsUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsx(BunnyMarketingLink, {})] })));
|
|
4198
4310
|
};
|
|
4199
|
-
var
|
|
4200
|
-
var
|
|
4201
|
-
var
|
|
4202
|
-
|
|
4203
|
-
};
|
|
4204
|
-
headers["Authorization"] = bearerToken;
|
|
4205
|
-
return headers;
|
|
4311
|
+
var BunnyMarketingLink = function () {
|
|
4312
|
+
var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
|
|
4313
|
+
var window = useContext(BunnyContext).window;
|
|
4314
|
+
var isMobile = useIsMobile(window);
|
|
4315
|
+
return (jsx("div", __assign({ className: "flex items-end justify-end ".concat(isMobile ? "" : "grow") }, { children: jsx(StyledBunnyLink, __assign({ className: "flex items-end justify-end text-slate-400", href: "https://bunny.com/", rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: jsxs("div", __assign({ className: "flex items-center", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }, { children: ["Powered by\u00A0", jsx("div", __assign({ style: { paddingTop: "5px" } }, { children: jsx(BunnyFooterIcon, { color: isHovered ? PRIMARY_COLOR : SLATE_400 }) }))] })) })) })));
|
|
4206
4316
|
};
|
|
4207
|
-
var
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
switch (_a.label) {
|
|
4211
|
-
case 0:
|
|
4212
|
-
_a.trys.push([0, 2, , 3]);
|
|
4213
|
-
return [4 /*yield*/, request(getGraphQLBase(), query, variables, createRequestHeaders(token))];
|
|
4214
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
4215
|
-
case 2:
|
|
4216
|
-
error_1 = _a.sent();
|
|
4217
|
-
throw error_1;
|
|
4218
|
-
case 3: return [2 /*return*/];
|
|
4219
|
-
}
|
|
4220
|
-
});
|
|
4221
|
-
}); }; };
|
|
4317
|
+
var StyedLink = styled.a(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n"], ["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n"])), SLATE_400, SLATE_500);
|
|
4318
|
+
var StyledBunnyLink = styled(StyedLink)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), PRIMARY_COLOR);
|
|
4319
|
+
var templateObject_1$3, templateObject_2;
|
|
4222
4320
|
|
|
4223
|
-
var
|
|
4224
|
-
var
|
|
4225
|
-
var
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
:
|
|
4243
|
-
}
|
|
4321
|
+
var MUTATION$1 = "\n mutation portalSessionCreate ($tenantCode: String!, $expiry: Int!, $returnUrl: String!) {\n portalSessionCreate (tenantCode: $tenantCode, expiry: $expiry, returnUrl: $returnUrl) {\n errors\n token\n }\n }\n";
|
|
4322
|
+
var portalSessionCreate = function (_a) {
|
|
4323
|
+
var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, subdomain = _a.subdomain;
|
|
4324
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
4325
|
+
var response, errors;
|
|
4326
|
+
var _b;
|
|
4327
|
+
return __generator(this, function (_c) {
|
|
4328
|
+
switch (_c.label) {
|
|
4329
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
4330
|
+
query: MUTATION$1,
|
|
4331
|
+
token: token,
|
|
4332
|
+
vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
|
|
4333
|
+
subdomain: subdomain,
|
|
4334
|
+
})];
|
|
4335
|
+
case 1:
|
|
4336
|
+
response = _c.sent();
|
|
4337
|
+
errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
|
|
4338
|
+
if (errors)
|
|
4339
|
+
throw errors;
|
|
4340
|
+
return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
|
|
4341
|
+
}
|
|
4342
|
+
});
|
|
4244
4343
|
});
|
|
4245
4344
|
};
|
|
4246
4345
|
|
|
4247
|
-
var
|
|
4248
|
-
|
|
4249
|
-
var
|
|
4250
|
-
|
|
4251
|
-
var _b = useContext(BunnyContext),
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
var showState = columns.includes("state");
|
|
4256
|
-
if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
|
|
4257
|
-
return jsx(TransactionsEmptyState, {});
|
|
4258
|
-
return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
|
|
4259
|
-
var isClickable = transaction.kind === "INVOICE";
|
|
4260
|
-
return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
|
|
4261
|
-
onTransactionClick(transaction);
|
|
4262
|
-
}, style: {
|
|
4263
|
-
backgroundColor: index % 2 === 0
|
|
4264
|
-
? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
|
|
4265
|
-
: "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
|
|
4266
|
-
} }, { 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$4, { children: capitalizeFirstLetter(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: transaction.createdAt })), showAmount && showDateAndTitle && jsx(Text$4, { children: "\u00B7" }), showAmount && (jsx(Text$4, { children: Misc.formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })))] }), index));
|
|
4346
|
+
var showErrorNotification = NotificationUtils.useErrorNotification();
|
|
4347
|
+
function Signup(_a) {
|
|
4348
|
+
var priceListCode = _a.priceListCode, returnUrl = _a.returnUrl;
|
|
4349
|
+
// Hooks
|
|
4350
|
+
var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token, window = _b.window;
|
|
4351
|
+
useQuery({
|
|
4352
|
+
queryKey: QueryKeyFactory.default.currentUserKey,
|
|
4353
|
+
queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
|
|
4267
4354
|
});
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
var
|
|
4272
|
-
|
|
4273
|
-
var
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
var contextValues = {
|
|
4280
|
-
showSearchBar: showSearchBar,
|
|
4281
|
-
showTitle: showTitle,
|
|
4282
|
-
transactionComponent: transactionComponent,
|
|
4283
|
-
columns: columns,
|
|
4284
|
-
className: className,
|
|
4285
|
-
searchBarClassName: searchBarClassName,
|
|
4286
|
-
shadow: shadow,
|
|
4287
|
-
useModal: useModal,
|
|
4288
|
-
onTransactionClick: onTransactionClick,
|
|
4289
|
-
suppressTransactionDisplay: suppressTransactionDisplay,
|
|
4290
|
-
kindsToShow: kindsToShow,
|
|
4291
|
-
style: style,
|
|
4292
|
-
filter: filter,
|
|
4293
|
-
noTransactionsMessage: noTransactionsMessage,
|
|
4294
|
-
};
|
|
4295
|
-
return (jsx(QueryClientProvider, __assign({ client: queryClient }, { children: jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(TransactionsWrapper, {}) })) })));
|
|
4296
|
-
}
|
|
4297
|
-
function TransactionsWrapper() {
|
|
4298
|
-
var _a = useContext(TransactionsListContext), kindsToShow = _a.kindsToShow, filterFromContext = _a.filter;
|
|
4299
|
-
var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain;
|
|
4300
|
-
// Local state
|
|
4301
|
-
var _c = useState(""), search = _c[0], setSearch = _c[1];
|
|
4302
|
-
var filter = filterFromContext ||
|
|
4303
|
-
(search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
|
|
4355
|
+
var isMobile = useIsMobile(window);
|
|
4356
|
+
var topNavImageUrl = useContext(BrandContext).topNavImageUrl;
|
|
4357
|
+
var entityId = useCurrentUserData().entityId;
|
|
4358
|
+
var _c = useState(undefined), quote = _c[0], setQuote = _c[1];
|
|
4359
|
+
var _d = useState(undefined), accountId = _d[0], setAccountId = _d[1];
|
|
4360
|
+
var _e = useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
|
|
4361
|
+
var _f = useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
|
|
4362
|
+
var _g = useState(undefined), formData = _g[0], setFormData = _g[1];
|
|
4363
|
+
var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
|
|
4364
|
+
var _j = useState(false), paying = _j[0], setIsPaying = _j[1];
|
|
4365
|
+
var _k = useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
|
|
4304
4366
|
// Queries
|
|
4305
|
-
var
|
|
4306
|
-
queryKey: ["
|
|
4307
|
-
queryFn: function () { return
|
|
4308
|
-
placeholderData: keepPreviousData,
|
|
4367
|
+
var priceListData = useQuery({
|
|
4368
|
+
queryKey: ["priceList", priceListCode],
|
|
4369
|
+
queryFn: function () { return getPriceList({ token: token, subdomain: subdomain, code: priceListCode }); },
|
|
4309
4370
|
}).data;
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4371
|
+
function handleSubmit(formData) {
|
|
4372
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4373
|
+
var data, portalSessionToken;
|
|
4374
|
+
return __generator(this, function (_a) {
|
|
4375
|
+
switch (_a.label) {
|
|
4376
|
+
case 0:
|
|
4377
|
+
setProceedingToPayment(true);
|
|
4378
|
+
setFormData(formData);
|
|
4379
|
+
return [4 /*yield*/, quoteAccountSignup({
|
|
4380
|
+
token: token,
|
|
4381
|
+
subdomain: subdomain,
|
|
4382
|
+
entityId: entityId,
|
|
4383
|
+
priceListCode: priceListCode,
|
|
4384
|
+
accountName: formData.accountName,
|
|
4385
|
+
billingContact: {
|
|
4386
|
+
firstName: formData.firstName,
|
|
4387
|
+
lastName: formData.lastName,
|
|
4388
|
+
email: formData.email,
|
|
4389
|
+
},
|
|
4390
|
+
})];
|
|
4391
|
+
case 1:
|
|
4392
|
+
data = _a.sent();
|
|
4393
|
+
setAccountId(data.account.id);
|
|
4394
|
+
return [4 /*yield*/, portalSessionCreate({
|
|
4395
|
+
token: token,
|
|
4396
|
+
subdomain: subdomain,
|
|
4397
|
+
tenantCode: data.tenant.code,
|
|
4398
|
+
expiry: 24,
|
|
4399
|
+
returnUrl: returnUrl || "",
|
|
4400
|
+
})];
|
|
4401
|
+
case 2:
|
|
4402
|
+
portalSessionToken = _a.sent();
|
|
4403
|
+
setPortalSessionToken(portalSessionToken);
|
|
4404
|
+
setQuoteId(data.quote.id);
|
|
4405
|
+
setProceedingToPayment(false);
|
|
4406
|
+
setQuote({
|
|
4407
|
+
amountDue: data.quote.amountDue,
|
|
4408
|
+
currencyId: data.quote.currencyId,
|
|
4409
|
+
});
|
|
4410
|
+
return [2 /*return*/];
|
|
4411
|
+
}
|
|
4412
|
+
});
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4415
|
+
function handlePaymentSaveSuccess(paymentSuccess) {
|
|
4416
|
+
var _a;
|
|
4417
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4418
|
+
var response, plugin;
|
|
4419
|
+
return __generator(this, function (_b) {
|
|
4420
|
+
switch (_b.label) {
|
|
4421
|
+
case 0:
|
|
4422
|
+
if (!formData) {
|
|
4423
|
+
throw new Error("Form data is required");
|
|
4424
|
+
}
|
|
4425
|
+
response = paymentSuccess.pluginPaymentResponse;
|
|
4426
|
+
plugin = response === null || response === void 0 ? void 0 : response.plugin;
|
|
4427
|
+
if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
|
|
4428
|
+
throw new Error("Plugin ID is required");
|
|
4429
|
+
}
|
|
4430
|
+
if (!accountId) {
|
|
4431
|
+
throw new Error("Account ID is required");
|
|
4432
|
+
}
|
|
4433
|
+
if (!portalSessionToken) {
|
|
4434
|
+
throw new Error("Portal session token is required");
|
|
4435
|
+
}
|
|
4436
|
+
return [4 /*yield*/, accountSignup({
|
|
4437
|
+
token: portalSessionToken,
|
|
4438
|
+
subdomain: subdomain,
|
|
4439
|
+
entityId: entityId,
|
|
4440
|
+
quoteId: quoteId,
|
|
4441
|
+
paymentMethodId: (_a = paymentSuccess.savedPaymentMethodResponse) === null || _a === void 0 ? void 0 : _a.paymentMethodId.toString(),
|
|
4442
|
+
pluginId: plugin.id.toString(),
|
|
4443
|
+
priceListCode: priceListCode,
|
|
4444
|
+
accountId: accountId,
|
|
4445
|
+
})];
|
|
4446
|
+
case 1:
|
|
4447
|
+
_b.sent();
|
|
4448
|
+
setIsPaying(false);
|
|
4449
|
+
setPurchaseSucceeded(true);
|
|
4450
|
+
return [2 /*return*/];
|
|
4451
|
+
}
|
|
4452
|
+
});
|
|
4453
|
+
});
|
|
4454
|
+
}
|
|
4455
|
+
function handlePaymentFail(error) {
|
|
4456
|
+
showErrorNotification(error.message);
|
|
4457
|
+
setIsPaying(false);
|
|
4458
|
+
}
|
|
4459
|
+
if (isMobile) {
|
|
4460
|
+
return (jsx(Card, __assign({ className: "p-4 flex flex-col" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, returnUrl: returnUrl })) : (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsx("div", __assign({ className: "flex flex-col items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "mx-8" }, { children: jsx(Divider, { className: "h-full" }) })), jsx("div", __assign({ className: "flex items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })));
|
|
4461
|
+
}
|
|
4462
|
+
else {
|
|
4463
|
+
return (jsxs(Fragment, { children: [jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, returnUrl: returnUrl })) : (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsx("div", __assign({ className: "flex flex-col w-1/2 items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "my-4" }, { children: jsx(Divider, { className: "h-full", type: "vertical" }) })), jsx("div", __assign({ className: "flex w-1/2 items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })), jsx(Footer, {})] }));
|
|
4330
4464
|
}
|
|
4331
|
-
// Since the columns are dynamic, we need to calculate the grid template columns
|
|
4332
|
-
var gridTemplateColumns = function () {
|
|
4333
|
-
var templateColumns = [];
|
|
4334
|
-
if (isMobile) {
|
|
4335
|
-
if (columns.includes("date-and-title") ||
|
|
4336
|
-
columns.includes("state") ||
|
|
4337
|
-
columns.includes("amount")) {
|
|
4338
|
-
templateColumns.push("auto");
|
|
4339
|
-
}
|
|
4340
|
-
if (columns.includes("download")) {
|
|
4341
|
-
templateColumns.push("auto");
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
else {
|
|
4345
|
-
if (columns.includes("date-and-title")) {
|
|
4346
|
-
templateColumns.push("auto 3fr");
|
|
4347
|
-
}
|
|
4348
|
-
if (columns.includes("download")) {
|
|
4349
|
-
templateColumns.push("auto");
|
|
4350
|
-
}
|
|
4351
|
-
if (columns.includes("state")) {
|
|
4352
|
-
templateColumns.push("auto");
|
|
4353
|
-
}
|
|
4354
|
-
if (columns.includes("amount")) {
|
|
4355
|
-
templateColumns.push("auto");
|
|
4356
|
-
}
|
|
4357
|
-
}
|
|
4358
|
-
return templateColumns.join(" ");
|
|
4359
|
-
};
|
|
4360
|
-
var drawerTitle = function () {
|
|
4361
|
-
if (!selectedTransaction)
|
|
4362
|
-
return "";
|
|
4363
|
-
var kind = selectedTransaction.kind.toLowerCase();
|
|
4364
|
-
return kind.charAt(0).toUpperCase() + kind.slice(1);
|
|
4365
|
-
};
|
|
4366
|
-
return (jsxs("div", __assign({ style: style }, { children: [jsx(PageHeaderWithActions, __assign({ title: title || (showTitle ? "Past transactions" : undefined) }, { children: showSearchBar && (jsx("div", { children: jsx(Input, { className: searchBarClassName
|
|
4367
|
-
? searchBarClassName
|
|
4368
|
-
: "border border-slate-200", onChange: function (e) {
|
|
4369
|
-
if (isNaN(Number(e.target.value))) {
|
|
4370
|
-
return;
|
|
4371
|
-
}
|
|
4372
|
-
onSearchValueChanged(e.target.value);
|
|
4373
|
-
}, prefix: jsx(SearchOutlined$1, {}), placeholder: "Search by id #", style: {
|
|
4374
|
-
minWidth: "300px",
|
|
4375
|
-
}, value: search }) })) })), jsx(PageContent, __assign({ className: "flex w-full shadow-padding-xb ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat("shadow-".concat(shadow)), style: {
|
|
4376
|
-
gridTemplateColumns: gridTemplateColumns(),
|
|
4377
|
-
backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
|
|
4378
|
-
} }, { children: isMobile ? (jsx(Fragment, { children: TransactionsListMobile({
|
|
4379
|
-
transactions: transactions,
|
|
4380
|
-
onTransactionClick: handleTransactionClick,
|
|
4381
|
-
}) })) : (jsx(Fragment, { children: TransactionsListDesktop({
|
|
4382
|
-
transactions: transactions,
|
|
4383
|
-
onTransactionClick: handleTransactionClick,
|
|
4384
|
-
}) })) })) })), useModal ? (jsx(Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: function () { return setDrawerOpen(false); }, onCancel: function () { return setDrawerOpen(false); }, width: 900, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "" }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: function () { return setDrawerOpen(false); }, open: drawerOpen, width: 900 }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId })) : (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: Misc.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 })] })] }))) })))] })));
|
|
4385
4465
|
}
|
|
4386
4466
|
|
|
4387
4467
|
var updatingChargeQuantityIdState = atom({
|
|
@@ -5504,4 +5584,4 @@ var Subscriptions = function (_a) {
|
|
|
5504
5584
|
} }, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (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(Footer, {}), jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile })] })));
|
|
5505
5585
|
};
|
|
5506
5586
|
|
|
5507
|
-
export { BunnyProvider, Checkout, Invoice, PaymentMethod, Quote, Signup, Subscriptions, Transactions, getQuoteAmountDue, usePaymentMethod };
|
|
5587
|
+
export { BunnyProvider, Checkout, Invoice, PaymentMethod, Quote, Quotes, Signup, Subscriptions, Transactions, getQuoteAmountDue, usePaymentMethod };
|