@bunnyapp/components 1.6.0-beta.20 → 1.6.0-beta.22
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 +101 -77
- package/dist/cjs/types/src/components/PaymentForm/context/PaymentProvider.d.ts +3 -2
- package/dist/cjs/types/src/components/PaymentForm/hooks/useHandlePayment.d.ts +1 -0
- package/dist/cjs/types/src/components/PaymentForm/hooks/usePaymentButtonText.d.ts +1 -0
- package/dist/cjs/types/src/components/Quotes/Quotes.d.ts +3 -3
- package/dist/cjs/types/src/graphql/queries/getFormattedQuote.d.ts +139 -1
- package/dist/esm/index.js +103 -79
- package/dist/esm/types/src/components/PaymentForm/context/PaymentProvider.d.ts +3 -2
- package/dist/esm/types/src/components/PaymentForm/hooks/useHandlePayment.d.ts +1 -0
- package/dist/esm/types/src/components/PaymentForm/hooks/usePaymentButtonText.d.ts +1 -0
- package/dist/esm/types/src/components/Quotes/Quotes.d.ts +3 -3
- package/dist/esm/types/src/graphql/queries/getFormattedQuote.d.ts +139 -1
- package/dist/index.d.ts +3 -3
- package/package.json +1 -1
|
@@ -2,5 +2,143 @@ declare const getFormattedQuote: ({ token, apiHost, id, }: {
|
|
|
2
2
|
apiHost: string;
|
|
3
3
|
token?: string;
|
|
4
4
|
id?: string;
|
|
5
|
-
}) => Promise<
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
quote: {
|
|
7
|
+
documentTemplateId: string | null;
|
|
8
|
+
documents: {
|
|
9
|
+
id: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
size: string;
|
|
12
|
+
date: unknown;
|
|
13
|
+
url: string;
|
|
14
|
+
}[] | null;
|
|
15
|
+
firstInvoice: {
|
|
16
|
+
id: string | null;
|
|
17
|
+
state: "FAILED" | "DRAFT" | "NOT_DUE" | "DUE" | "UNPAID" | "PAID" | "VOIDED" | "READY" | "PREPARING" | "PROCESSING_PAYMENT" | "MERGED" | "QUEUED" | "CONSOLIDATED";
|
|
18
|
+
} | null;
|
|
19
|
+
payableId: string | null;
|
|
20
|
+
id: string | null;
|
|
21
|
+
payToAccept: boolean | null;
|
|
22
|
+
currentPaymentHold: {
|
|
23
|
+
createdAt: unknown;
|
|
24
|
+
expiresAt: unknown;
|
|
25
|
+
id: string | null;
|
|
26
|
+
updatedAt: unknown;
|
|
27
|
+
paymentMethod: {
|
|
28
|
+
accountId: string | null;
|
|
29
|
+
createdAt: unknown;
|
|
30
|
+
expirationDate: unknown;
|
|
31
|
+
failureCode: string | null;
|
|
32
|
+
id: string;
|
|
33
|
+
isDefault: boolean | null;
|
|
34
|
+
lastSuccess: unknown;
|
|
35
|
+
paymentType: "ach" | "card" | "other" | "wire" | null;
|
|
36
|
+
pluginId: string | null;
|
|
37
|
+
state: "UNKNOWN" | "SUCCESS" | "FAILED" | null;
|
|
38
|
+
updatedAt: unknown;
|
|
39
|
+
metadata: {
|
|
40
|
+
description: string | null;
|
|
41
|
+
expiration: unknown;
|
|
42
|
+
icon: string | null;
|
|
43
|
+
identifier: string | null;
|
|
44
|
+
issuer: string | null;
|
|
45
|
+
kind: string | null;
|
|
46
|
+
} | null;
|
|
47
|
+
} | null;
|
|
48
|
+
} | null;
|
|
49
|
+
};
|
|
50
|
+
payableId: string | null;
|
|
51
|
+
acceptedAt: unknown;
|
|
52
|
+
acceptedByName: string | null;
|
|
53
|
+
amount: number;
|
|
54
|
+
amountDue: number;
|
|
55
|
+
amountsByPeriod: {
|
|
56
|
+
id: string | null;
|
|
57
|
+
name: string | null;
|
|
58
|
+
amount: number | null;
|
|
59
|
+
}[];
|
|
60
|
+
billingCity: string | null;
|
|
61
|
+
billingCountry: string | null;
|
|
62
|
+
billingState: string | null;
|
|
63
|
+
billingStreet: string | null;
|
|
64
|
+
billingZip: string | null;
|
|
65
|
+
contactName: string | null;
|
|
66
|
+
currency: string | null;
|
|
67
|
+
customerBillingCity: string | null;
|
|
68
|
+
customerBillingCountry: string | null;
|
|
69
|
+
customerBillingState: string | null;
|
|
70
|
+
customerBillingStreet: string | null;
|
|
71
|
+
customerBillingZip: string | null;
|
|
72
|
+
customerName: string | null;
|
|
73
|
+
discount: number;
|
|
74
|
+
discountValue: number;
|
|
75
|
+
duration: string | null;
|
|
76
|
+
endDate: unknown;
|
|
77
|
+
expiresAt: unknown;
|
|
78
|
+
html: string | null;
|
|
79
|
+
formattedLines: {
|
|
80
|
+
amount: number;
|
|
81
|
+
amountsByPeriod: {
|
|
82
|
+
quantity: number | null;
|
|
83
|
+
id: string | null;
|
|
84
|
+
name: string | null;
|
|
85
|
+
startDate: unknown;
|
|
86
|
+
endDate: unknown;
|
|
87
|
+
amount: number | null;
|
|
88
|
+
amountsByTier: {
|
|
89
|
+
id: string | null;
|
|
90
|
+
tier: {
|
|
91
|
+
starts: number | null;
|
|
92
|
+
ends: number | null;
|
|
93
|
+
price: number | null;
|
|
94
|
+
} | null;
|
|
95
|
+
quantity: number | null;
|
|
96
|
+
amount: number | null;
|
|
97
|
+
}[] | null;
|
|
98
|
+
prorationRate: number | null;
|
|
99
|
+
}[];
|
|
100
|
+
billingPeriodEnd: string | null;
|
|
101
|
+
billingPeriodStart: string | null;
|
|
102
|
+
chargeType: string;
|
|
103
|
+
discount: number | null;
|
|
104
|
+
frequency: string;
|
|
105
|
+
isRamp: boolean;
|
|
106
|
+
periods: number;
|
|
107
|
+
planName: string;
|
|
108
|
+
position: number;
|
|
109
|
+
price: number | null;
|
|
110
|
+
priceDecimals: number | null;
|
|
111
|
+
priceListChargeId: string | null;
|
|
112
|
+
priceListChargeName: string | null;
|
|
113
|
+
priceListId: string;
|
|
114
|
+
priceListName: string | null;
|
|
115
|
+
priceTiers: {
|
|
116
|
+
price: number | null;
|
|
117
|
+
starts: number;
|
|
118
|
+
}[] | null;
|
|
119
|
+
pricingModel: string;
|
|
120
|
+
productName: string;
|
|
121
|
+
prorationRate: number | null;
|
|
122
|
+
quantity: number | null;
|
|
123
|
+
showProductNameOnLineItem: boolean;
|
|
124
|
+
taxCode: string | null;
|
|
125
|
+
trialEndDate: unknown;
|
|
126
|
+
trialStartDate: unknown;
|
|
127
|
+
unitOfMeasure: string;
|
|
128
|
+
vatCode: string | null;
|
|
129
|
+
}[];
|
|
130
|
+
netPaymentDays: number | null;
|
|
131
|
+
notes: string | null;
|
|
132
|
+
number: string | null;
|
|
133
|
+
poNumberRequired: boolean | null;
|
|
134
|
+
salesContactEmail: string | null;
|
|
135
|
+
sharedAt: unknown;
|
|
136
|
+
startDate: unknown;
|
|
137
|
+
state: "DRAFT" | "SHARED" | "VIEWED" | "ACCEPTED" | "IN_APPROVAL" | "APPROVED" | "REJECTED" | "UNDONE";
|
|
138
|
+
subtotal: number;
|
|
139
|
+
taxAmount: number;
|
|
140
|
+
taxNumberLabel: string | null;
|
|
141
|
+
taxNumberRequired: boolean | null;
|
|
142
|
+
vendorName: string | null;
|
|
143
|
+
}>;
|
|
6
144
|
export default getFormattedQuote;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { isValidElement, createContext, useContext, useMemo, useState, useEffect, useRef, createElement, useCallback, Fragment as Fragment$1 } from 'react';
|
|
3
3
|
import { DownloadOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, SearchOutlined, CloseOutlined, CheckCircleFilled, InfoCircleOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useErrorNotification, DEFAULT_CONFIG, createClientDevHeaders as createClientDevHeaders$1, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory as QueryKeyFactory$1, useIsMobile as useIsMobile$1, DEFAULT_BRAND_COLOR, isColorTooDark, DEFAULT_TOP_NAV_IMAGE_URL, DEFAULT_ACCENT_COLOR, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, DEFAULT_SECONDARY_COLOR, request as request$1, invokePlugin, useAllErrorFormats as useAllErrorFormats$1, formatCurrency as formatCurrency$1, GRAY_500, GRAY_200, useSuccessNotification, PAYABLE_INVOICE_STATES, BreakpointNumbers as BreakpointNumbers$1, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, QuoteChangeKind, SLATE_500, PRIMARY_COLOR, Lists, getAccount,
|
|
5
|
-
import { ConfigProvider, Spin, Typography, Button, theme as theme$1, Tag, Dropdown, Input, Modal, Checkbox, Skeleton, Collapse, Form, Tooltip, Drawer, Card as Card$1, Select, Divider,
|
|
4
|
+
import { useErrorNotification, DEFAULT_CONFIG, createClientDevHeaders as createClientDevHeaders$1, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory as QueryKeyFactory$1, useIsMobile as useIsMobile$1, DEFAULT_BRAND_COLOR, isColorTooDark, DEFAULT_TOP_NAV_IMAGE_URL, DEFAULT_ACCENT_COLOR, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, DEFAULT_SECONDARY_COLOR, request as request$1, invokePlugin, useAllErrorFormats as useAllErrorFormats$1, formatCurrency as formatCurrency$1, GRAY_500, GRAY_200, useSuccessNotification, PAYABLE_INVOICE_STATES, BreakpointNumbers as BreakpointNumbers$1, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, QuoteChangeKind, SLATE_500, PRIMARY_COLOR, Lists, getAccount, ChargeType, PERIOD_LABELS, MODAL_MAX_HEIGHT, DataInterval, SLATE_100 } from '@bunnyapp/common';
|
|
5
|
+
import { ConfigProvider, Spin, Typography, Button, theme as theme$1, Tag, Dropdown, Input, Modal, Checkbox, Skeleton, Collapse, Form, Tooltip, Drawer, Card as Card$1, Select, Divider, Popconfirm, Table, Radio, Space, Switch } from 'antd';
|
|
6
6
|
import { Markup } from 'interweave';
|
|
7
7
|
import request from 'graphql-request';
|
|
8
8
|
import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation, keepPreviousData } from '@tanstack/react-query';
|
|
@@ -141,7 +141,7 @@ const useAllErrorFormats = () => {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
// This will be replaced at build time by rollup-plugin-replace
|
|
144
|
-
const PACKAGE_VERSION = '1.6.0-beta.
|
|
144
|
+
const PACKAGE_VERSION = '1.6.0-beta.21';
|
|
145
145
|
const createRequestHeaders = (token) => {
|
|
146
146
|
const headers = createClientDevHeaders({ token });
|
|
147
147
|
// Add the components version header
|
|
@@ -927,7 +927,7 @@ function readFragment(...r) {
|
|
|
927
927
|
|
|
928
928
|
var t = initGraphQLTada();
|
|
929
929
|
|
|
930
|
-
const query$
|
|
930
|
+
const query$7 = t(`
|
|
931
931
|
query entityBranding {
|
|
932
932
|
entityBranding {
|
|
933
933
|
accentColor
|
|
@@ -937,7 +937,7 @@ const query$6 = t(`
|
|
|
937
937
|
}
|
|
938
938
|
`);
|
|
939
939
|
const getBranding = async ({ token, apiHost }) => {
|
|
940
|
-
return await execute(query$
|
|
940
|
+
return await execute(query$7, { apiHost, token }, {});
|
|
941
941
|
};
|
|
942
942
|
|
|
943
943
|
const BunnyContext = createContext({});
|
|
@@ -1144,7 +1144,7 @@ const InvoiceQuoteView = ({ children, formattedInvoice, html, backButtonName, on
|
|
|
1144
1144
|
}, children: [targetUrl ? (jsx(DocumentTemplatePreview, { targetUrl: targetUrl })) : (jsx(Markup, { content: html })), children] }))] }));
|
|
1145
1145
|
};
|
|
1146
1146
|
|
|
1147
|
-
const MUTATION$
|
|
1147
|
+
const MUTATION$9 = `
|
|
1148
1148
|
query FormattedInvoice($id: ID) {
|
|
1149
1149
|
formattedInvoice(id: $id) {
|
|
1150
1150
|
amount
|
|
@@ -1212,7 +1212,7 @@ query FormattedInvoice($id: ID) {
|
|
|
1212
1212
|
const getFormattedInvoice = async ({ id, token, apiHost, }) => {
|
|
1213
1213
|
const vars = { id };
|
|
1214
1214
|
const response = await gqlRequest({
|
|
1215
|
-
query: MUTATION$
|
|
1215
|
+
query: MUTATION$9,
|
|
1216
1216
|
token,
|
|
1217
1217
|
vars,
|
|
1218
1218
|
apiHost,
|
|
@@ -18730,7 +18730,7 @@ const QueryKeyFactory = {
|
|
|
18730
18730
|
paymentPluginsKey: (token) => ['paymentPlugins', ...(token ? [token] : [])],
|
|
18731
18731
|
};
|
|
18732
18732
|
|
|
18733
|
-
const query$
|
|
18733
|
+
const query$6 = t(`
|
|
18734
18734
|
query PaymentMethods($accountId: ID) {
|
|
18735
18735
|
paymentMethods(accountId: $accountId) {
|
|
18736
18736
|
nodes {
|
|
@@ -18759,7 +18759,7 @@ const query$5 = t(`
|
|
|
18759
18759
|
`, [PaymentForm_PaymentMethodsFragment]);
|
|
18760
18760
|
const getPaymentMethods = async ({ apiHost, token, accountId, }) => {
|
|
18761
18761
|
var _a, _b, _c;
|
|
18762
|
-
const response = await execute(query$
|
|
18762
|
+
const response = await execute(query$6, { apiHost, token }, { accountId });
|
|
18763
18763
|
// Filter out null values that are technically possible due to api schema
|
|
18764
18764
|
return (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.paymentMethods) === null || _a === void 0 ? void 0 : _a.nodes) === null || _b === void 0 ? void 0 : _b.filter(paymentMethod => paymentMethod !== null)) !== null && _c !== void 0 ? _c : [];
|
|
18765
18765
|
};
|
|
@@ -19005,7 +19005,7 @@ function useSave$1({ onSaveSuccess, onSaveError, accountId, }) {
|
|
|
19005
19005
|
return { save, isSaving };
|
|
19006
19006
|
}
|
|
19007
19007
|
|
|
19008
|
-
const MUTATION$
|
|
19008
|
+
const MUTATION$8 = `
|
|
19009
19009
|
mutation checkout(
|
|
19010
19010
|
$invoiceId: ID,
|
|
19011
19011
|
$quoteId: ID,
|
|
@@ -19054,7 +19054,7 @@ const checkout = async ({ quoteId, invoiceId, paymentMethodId, paymentMethodData
|
|
|
19054
19054
|
};
|
|
19055
19055
|
}
|
|
19056
19056
|
const response = await gqlRequest({
|
|
19057
|
-
query: MUTATION$
|
|
19057
|
+
query: MUTATION$8,
|
|
19058
19058
|
token,
|
|
19059
19059
|
vars: mutationVars,
|
|
19060
19060
|
apiHost: apiHost,
|
|
@@ -19342,14 +19342,20 @@ const useHandlePayment = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSucce
|
|
|
19342
19342
|
const { defaultPaymentMethod } = usePaymentMethod({ accountId });
|
|
19343
19343
|
const { apiHost } = useContext(BunnyContext);
|
|
19344
19344
|
const token = useToken();
|
|
19345
|
+
// State
|
|
19346
|
+
const [isPaid, setIsPaid] = useState(false);
|
|
19345
19347
|
const formattedAmountDue = () => {
|
|
19346
19348
|
const amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
|
|
19347
19349
|
const currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currencyId);
|
|
19348
19350
|
return amountDue && currencyId ? formatCurrency$1(amountDue, currencyId).toString() : undefined;
|
|
19349
19351
|
};
|
|
19352
|
+
// Validation checks
|
|
19353
|
+
if (quote !== undefined && invoice !== undefined) {
|
|
19354
|
+
throw new Error('Either quote or invoice must be provided, not both');
|
|
19355
|
+
}
|
|
19350
19356
|
// Payment hooks
|
|
19351
19357
|
const { pay: payDemoPay, isPaying: isPayingDemoPay } = usePay$1({
|
|
19352
|
-
onPaymentSuccess,
|
|
19358
|
+
onPaymentSuccess: handlePaymentSuccess,
|
|
19353
19359
|
onPaymentError: error => {
|
|
19354
19360
|
handleAllErrorFormats$2(error);
|
|
19355
19361
|
},
|
|
@@ -19358,7 +19364,7 @@ const useHandlePayment = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSucce
|
|
|
19358
19364
|
plugin,
|
|
19359
19365
|
});
|
|
19360
19366
|
const { pay: payStripe, isPaying: isPayingStripe } = usePay({
|
|
19361
|
-
onPaymentSuccess,
|
|
19367
|
+
onPaymentSuccess: handlePaymentSuccess,
|
|
19362
19368
|
onPaymentError: error => {
|
|
19363
19369
|
handleAllErrorFormats$2(error);
|
|
19364
19370
|
},
|
|
@@ -19430,6 +19436,10 @@ const useHandlePayment = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSucce
|
|
|
19430
19436
|
break;
|
|
19431
19437
|
}
|
|
19432
19438
|
};
|
|
19439
|
+
function handlePaymentSuccess(response) {
|
|
19440
|
+
setIsPaid(true);
|
|
19441
|
+
onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
|
|
19442
|
+
}
|
|
19433
19443
|
const handlePayment = async (overridePaymentMethodId) => {
|
|
19434
19444
|
var _a, _b;
|
|
19435
19445
|
if (!plugin)
|
|
@@ -19452,6 +19462,7 @@ const useHandlePayment = ({ quote, invoice, onPaymentSuccess, onPaymentHoldSucce
|
|
|
19452
19462
|
isPayingStripe ||
|
|
19453
19463
|
isApprovingHoldDemoPay ||
|
|
19454
19464
|
isApprovingHoldStripe,
|
|
19465
|
+
isPaid,
|
|
19455
19466
|
paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : PaymentType.PAY,
|
|
19456
19467
|
formattedAmountDue: formattedAmountDue(),
|
|
19457
19468
|
};
|
|
@@ -19539,11 +19550,13 @@ const [ShowPaymentDetailsProvider, useShowPaymentDetails] = createStateContext(u
|
|
|
19539
19550
|
const handleAllErrorFormats$1 = useAllErrorFormats$1();
|
|
19540
19551
|
const showErrorNotification$5 = useErrorNotification();
|
|
19541
19552
|
// Contexts
|
|
19542
|
-
const [
|
|
19553
|
+
const [FormattedAmountDueProvider, useFormattedAmountDue] = createValueContext();
|
|
19543
19554
|
const [PaymentTypeProvider, usePaymentType] = createValueContext();
|
|
19544
19555
|
const [IsPayingProvider, useIsPaying] = createValueContext();
|
|
19545
19556
|
const [HandlePaymentFormSubmitProvider, useHandlePaymentFormSubmit] = createValueContext();
|
|
19546
19557
|
const [IsSavingProvider, useIsSaving] = createValueContext();
|
|
19558
|
+
// Used for PaymentMethodFooter to disable pay button if payment is already successful
|
|
19559
|
+
const [IsPaidProvider, useIsPaid] = createValueContext();
|
|
19547
19560
|
// Used for Signup component. Signup uses an apiClient token which api can't infer an account from, so accountId must be used
|
|
19548
19561
|
const [AccountIdProvider, useAccountId] = createValueContext();
|
|
19549
19562
|
function PaymentProvider({ children, accountId, quote, invoice, onPaymentSuccess, onPaymentHoldSuccess, paymentHoldOptions, onSavePaymentMethod, }) {
|
|
@@ -19554,7 +19567,7 @@ function PaymentProvider({ children, accountId, quote, invoice, onPaymentSuccess
|
|
|
19554
19567
|
// Hooks
|
|
19555
19568
|
const queryClient = useQueryClient();
|
|
19556
19569
|
const token = useToken();
|
|
19557
|
-
const { handlePayment, handleApproveHold, handleCheckoutNoPayment, isPaying, paymentType, formattedAmountDue, } = useHandlePayment({
|
|
19570
|
+
const { handlePayment, handleApproveHold, handleCheckoutNoPayment, isPaying, isPaid, paymentType, formattedAmountDue, } = useHandlePayment({
|
|
19558
19571
|
quote,
|
|
19559
19572
|
invoice,
|
|
19560
19573
|
onPaymentSuccess: (response) => {
|
|
@@ -19660,11 +19673,12 @@ function PaymentProvider({ children, accountId, quote, invoice, onPaymentSuccess
|
|
|
19660
19673
|
}
|
|
19661
19674
|
};
|
|
19662
19675
|
const providers = [
|
|
19663
|
-
[
|
|
19676
|
+
[FormattedAmountDueProvider, { value: formattedAmountDue }],
|
|
19664
19677
|
[PaymentTypeProvider, { value: paymentType }],
|
|
19665
19678
|
[IsPayingProvider, { value: isPaying }],
|
|
19666
19679
|
[HandlePaymentFormSubmitProvider, { value: handlePaymentFormSubmit }],
|
|
19667
19680
|
[IsSavingProvider, { value: isSavingDemoPay || isSavingStripe }],
|
|
19681
|
+
[IsPaidProvider, { value: isPaid }],
|
|
19668
19682
|
[AccountIdProvider, { value: accountId }],
|
|
19669
19683
|
];
|
|
19670
19684
|
return (jsx(Fragment, { children: providers.reduceRight((acc, [Provider, props]) => createElement(Provider, props, acc), children) }));
|
|
@@ -19675,33 +19689,49 @@ function StripeWrapper({ children, currencyId, accountId, }) {
|
|
|
19675
19689
|
return (jsx(Elements, { options: options, stripe: stripe, children: children }));
|
|
19676
19690
|
}
|
|
19677
19691
|
|
|
19692
|
+
function usePaymentButtonText() {
|
|
19693
|
+
const formattedAmountDue = useFormattedAmountDue();
|
|
19694
|
+
const paymentType = usePaymentType();
|
|
19695
|
+
const isPaid = useIsPaid();
|
|
19696
|
+
const isSaving = useIsSaving();
|
|
19697
|
+
const isPaying = useIsPaying();
|
|
19698
|
+
const isProcessing = isSaving || isPaying;
|
|
19699
|
+
// If payment is already successful, show the amount paid
|
|
19700
|
+
if (isPaid) {
|
|
19701
|
+
return 'Paid ' + (formattedAmountDue !== null && formattedAmountDue !== void 0 ? formattedAmountDue : '');
|
|
19702
|
+
}
|
|
19703
|
+
const paymentTypeText = isProcessing
|
|
19704
|
+
? paymentType === PaymentType.APPROVE_HOLD
|
|
19705
|
+
? 'Approving hold for'
|
|
19706
|
+
: 'Paying'
|
|
19707
|
+
: paymentType === PaymentType.APPROVE_HOLD
|
|
19708
|
+
? 'Approve hold for'
|
|
19709
|
+
: 'Pay';
|
|
19710
|
+
return paymentTypeText + ' ' + (formattedAmountDue !== null && formattedAmountDue !== void 0 ? formattedAmountDue : '');
|
|
19711
|
+
}
|
|
19712
|
+
|
|
19678
19713
|
const CheckoutFooter = () => {
|
|
19714
|
+
const isPaid = useIsPaid();
|
|
19679
19715
|
const isMobile = useIsMobile();
|
|
19680
|
-
const paymentType = usePaymentType();
|
|
19681
19716
|
const isPaying = useIsPaying();
|
|
19682
|
-
const
|
|
19717
|
+
const paymentButtonText = usePaymentButtonText();
|
|
19683
19718
|
const onPaymentFormSubmit = useHandlePaymentFormSubmit();
|
|
19684
|
-
|
|
19685
|
-
const isPayingButtonText = paymentType === PaymentType.APPROVE_HOLD ? 'Approving hold for' : 'Paying';
|
|
19686
|
-
return (jsx(Button, { className: "bunny-w-full", disabled: isPaying, onClick: () => onPaymentFormSubmit(), size: isMobile ? 'large' : 'middle', type: "primary", children: `${isPaying ? isPayingButtonText : buttonText} ${formattedAmountDue}` }));
|
|
19719
|
+
return (jsx(Button, { className: "bunny-w-full", disabled: isPaying || isPaid, onClick: () => onPaymentFormSubmit(), size: isMobile ? 'large' : 'middle', type: "primary", children: paymentButtonText }));
|
|
19687
19720
|
};
|
|
19688
19721
|
|
|
19689
19722
|
function PaymentMethodFooter({ onSubmit, noPadding, }) {
|
|
19690
19723
|
const isPaying = useIsPaying();
|
|
19691
19724
|
const isSaving = useIsSaving();
|
|
19692
|
-
const
|
|
19725
|
+
const formattedAmountDue = useFormattedAmountDue();
|
|
19726
|
+
const paymentButtonText = usePaymentButtonText();
|
|
19693
19727
|
const isMobile = useIsMobile$1();
|
|
19694
19728
|
const [, setShowPaymentMethodForm] = useShowPaymentDetails();
|
|
19729
|
+
// If amount due is undefined, show the save button
|
|
19730
|
+
const payableAvailable = formattedAmountDue !== undefined;
|
|
19731
|
+
const saveButtonText = isSaving ? 'Saving' : 'Save';
|
|
19732
|
+
const buttonText = payableAvailable ? paymentButtonText : saveButtonText;
|
|
19695
19733
|
return (jsxs("div", { className: `bunny-flex bunny-justify-end bunny-gap-2 ${noPadding ? '' : 'pt-6'}`, children: [jsx(Button, { className: "bunny-w-full", size: isMobile ? 'large' : 'middle', onClick: () => setShowPaymentMethodForm(false), children: "Cancel" }), jsx(Button, { className: "bunny-w-full", disabled: isSaving || isPaying, loading: isSaving || isPaying, onClick: onSubmit, size: isMobile ? 'large' : 'middle', type: "primary", children: buttonText })] }));
|
|
19696
19734
|
}
|
|
19697
|
-
function useSubmitButtonText() {
|
|
19698
|
-
const amountDue = useAmountDue();
|
|
19699
|
-
const paymentType = usePaymentType();
|
|
19700
|
-
const payableAvailable = amountDue !== undefined;
|
|
19701
|
-
const paymentTypeText = paymentType === PaymentType.APPROVE_HOLD ? 'approve hold for' : 'pay';
|
|
19702
|
-
const buttonTextPrefix = payableAvailable ? paymentTypeText : 'save';
|
|
19703
|
-
return lodashExports.capitalize(buttonTextPrefix) + ' ' + (amountDue !== null && amountDue !== void 0 ? amountDue : '');
|
|
19704
|
-
}
|
|
19705
19735
|
|
|
19706
19736
|
const DemoPayCardCvc = ({ autoFocus, onChange, placeholder, value, }) => {
|
|
19707
19737
|
const onKeyPress = (event) => {
|
|
@@ -19902,7 +19932,7 @@ const useAutoSetDefaultPaymentMethod = ({ handleSetDefault, setDefaultPaymentMet
|
|
|
19902
19932
|
]);
|
|
19903
19933
|
};
|
|
19904
19934
|
|
|
19905
|
-
const query$
|
|
19935
|
+
const query$5 = t(`
|
|
19906
19936
|
query GetCurrentUserData {
|
|
19907
19937
|
company {
|
|
19908
19938
|
name
|
|
@@ -19925,7 +19955,7 @@ const query$4 = t(`
|
|
|
19925
19955
|
`);
|
|
19926
19956
|
const getCurrentUserData = async ({ token, apiHost }) => {
|
|
19927
19957
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19928
|
-
const response = await execute(query$
|
|
19958
|
+
const response = await execute(query$5, { apiHost, token }, {});
|
|
19929
19959
|
return {
|
|
19930
19960
|
authObjectName: (_a = response === null || response === void 0 ? void 0 : response.currentUser) === null || _a === void 0 ? void 0 : _a.authObjectName,
|
|
19931
19961
|
account: (_b = response === null || response === void 0 ? void 0 : response.currentUser) === null || _b === void 0 ? void 0 : _b.account,
|
|
@@ -20084,7 +20114,7 @@ function PaymentFormContent({ onRemovePaymentMethod, onSetDefaultPaymentMethod,
|
|
|
20084
20114
|
const [showPaymentMethodForm, setShowPaymentMethodForm] = useShowPaymentDetails();
|
|
20085
20115
|
const paymentType = usePaymentType();
|
|
20086
20116
|
const isPaying = useIsPaying();
|
|
20087
|
-
const
|
|
20117
|
+
const formattedAmountDue = useFormattedAmountDue();
|
|
20088
20118
|
const selectedPlugin = useSelectedPlugin();
|
|
20089
20119
|
const onPaymentFormSubmit = useHandlePaymentFormSubmit();
|
|
20090
20120
|
const accountId = useAccountId();
|
|
@@ -20131,7 +20161,7 @@ function PaymentFormContent({ onRemovePaymentMethod, onSetDefaultPaymentMethod,
|
|
|
20131
20161
|
label: !showPaymentMethodForm ? (jsx("div", { className: "bunny-pt-2", children: jsx(Button, { onClick: handleClickAddPaymentMethod, type: "default", className: "bunny-w-full", id: "addPaymentMethod", children: "Add payment method" }) })) : null,
|
|
20132
20162
|
children: (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-2 bunny-mt-2", children: [jsx(PaymentMethodSelector, {}), selectedPlugin && (jsx("div", { className: "bunny-flex bunny-flex-col", children: jsx(PaymentMethodDetails, {}) }))] })),
|
|
20133
20163
|
},
|
|
20134
|
-
] }),
|
|
20164
|
+
] }), formattedAmountDue !== undefined && !showPaymentMethodForm && (jsx("div", { className: "bunny-px-4", children: jsx(CheckoutFooter, {}) }))] })) : (jsx(Button, { style: { margin: '0 16px' }, loading: isPaying, onClick: () => onPaymentFormSubmit(), type: "primary", children: isPaying ? 'Processing...' : 'Complete Order' })) }));
|
|
20135
20165
|
}
|
|
20136
20166
|
|
|
20137
20167
|
function Invoice({ id, invoiceQuoteViewComponent, backButtonName, onBackButtonClick, onInvoiceDownloadError, onPaymentSuccess, shadow = 'shadow-md', className, hideDownloadButton = false, hidePaymentForm = false, onInvoiceLoaded, }) {
|
|
@@ -20166,7 +20196,7 @@ function ActualInvoice({ hidePaymentForm }) {
|
|
|
20166
20196
|
const isInvoicePayable = PAYABLE_INVOICE_STATES.includes((formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.state) || '');
|
|
20167
20197
|
// Local state
|
|
20168
20198
|
const isMobile = useIsMobile$1(isInvoicePayable ? BreakpointNumbers$1.lg : undefined);
|
|
20169
|
-
const
|
|
20199
|
+
const handlePaymentSuccess = () => {
|
|
20170
20200
|
queryClient.invalidateQueries({
|
|
20171
20201
|
queryKey: QueryKeyFactory$1.default.transactionsKey({ token }),
|
|
20172
20202
|
});
|
|
@@ -20186,15 +20216,21 @@ function ActualInvoice({ hidePaymentForm }) {
|
|
|
20186
20216
|
}, [formattedInvoice]);
|
|
20187
20217
|
if (!formattedInvoice)
|
|
20188
20218
|
return jsx(Fragment, {});
|
|
20189
|
-
return (jsx("div", { className: "bunny-invoice-container", children: jsxs("div", { className: `bunny-flex bunny-gap-6 ${isMobile ? 'bunny-flex-col bunny-w-full' : ''} ${className}`, children: [formattedInvoice.isLegacy ? (jsx("div", { className: "bunny-flex bunny-justify-center bunny-w-full", children: jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) })) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && !hidePaymentForm && (jsx("div", { className: `bunny-w-full ${hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12'}`, children: jsx(PaymentForm, { onPaymentSuccess:
|
|
20219
|
+
return (jsx("div", { className: "bunny-invoice-container", children: jsxs("div", { className: `bunny-flex bunny-gap-6 ${isMobile ? 'bunny-flex-col bunny-w-full' : ''} ${className}`, children: [formattedInvoice.isLegacy ? (jsx("div", { className: "bunny-flex bunny-justify-center bunny-w-full", children: jsx(LegacyDocument, { documentUuid: formattedInvoice.uuid, documentType: "invoice" }) })) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && !hidePaymentForm && (jsx("div", { className: `bunny-w-full ${hideDownloadButton || formattedInvoice.isLegacy ? '' : 'pt-12'}`, children: jsx(PaymentForm, { onPaymentSuccess: handlePaymentSuccess, invoice: formattedInvoice }) }))] }) }));
|
|
20190
20220
|
}
|
|
20191
20221
|
|
|
20192
|
-
const
|
|
20193
|
-
query formattedQuote
|
|
20194
|
-
formattedQuote
|
|
20222
|
+
const query$4 = t(`
|
|
20223
|
+
query formattedQuote($id: ID) {
|
|
20224
|
+
formattedQuote(id: $id) {
|
|
20195
20225
|
quote {
|
|
20196
20226
|
documentTemplateId
|
|
20197
|
-
documents {
|
|
20227
|
+
documents {
|
|
20228
|
+
id
|
|
20229
|
+
filename
|
|
20230
|
+
size
|
|
20231
|
+
date
|
|
20232
|
+
url
|
|
20233
|
+
}
|
|
20198
20234
|
firstInvoice {
|
|
20199
20235
|
id
|
|
20200
20236
|
state
|
|
@@ -20324,17 +20360,10 @@ const MUTATION$8 = () => `
|
|
|
20324
20360
|
taxNumberRequired
|
|
20325
20361
|
vendorName
|
|
20326
20362
|
}
|
|
20327
|
-
}
|
|
20363
|
+
}
|
|
20364
|
+
`);
|
|
20328
20365
|
const getFormattedQuote = async ({ token, apiHost, id, }) => {
|
|
20329
|
-
const response = await
|
|
20330
|
-
query: MUTATION$8(),
|
|
20331
|
-
token,
|
|
20332
|
-
apiHost,
|
|
20333
|
-
vars: { id },
|
|
20334
|
-
});
|
|
20335
|
-
if (response.errors && response.errors.length > 0) {
|
|
20336
|
-
throw new Error(response.errors[0].message);
|
|
20337
|
-
}
|
|
20366
|
+
const response = await execute(query$4, { apiHost, token }, { id });
|
|
20338
20367
|
return response === null || response === void 0 ? void 0 : response.formattedQuote;
|
|
20339
20368
|
};
|
|
20340
20369
|
|
|
@@ -20669,7 +20698,7 @@ const PaymentHoldModal = ({ visible, setVisible, quote, }) => {
|
|
|
20669
20698
|
const token = useToken();
|
|
20670
20699
|
return (jsxs(StyledModal$2, { centered: true, onCancel: () => {
|
|
20671
20700
|
setVisible(false);
|
|
20672
|
-
}, footer: null, open: visible, width: 600, children: [jsxs("div", { className: "bunny-mt-5 bunny-pb-4 bunny-mx-4", children: [jsx(Title$2, { className: "bunny-mt-0", level: 5, children: "Pay
|
|
20701
|
+
}, footer: null, open: visible, width: 600, children: [jsxs("div", { className: "bunny-mt-5 bunny-pb-4 bunny-mx-4", children: [jsx(Title$2, { className: "bunny-mt-0", level: 5, children: "Pay and sign" }), jsxs(Text$w, { className: "bunny-bt-2 bunny-text-sm/5 bunny-text-gray-500", children: ["To accept this quote, approve a payment hold for", ' ', formatCurrency$1(quote.amount, quote.currency), ". This amount will be charged to your payment method once the quote is signed."] })] }), jsx("div", { className: "bunny-mb-3", children: jsx(PaymentForm, { quote: {
|
|
20673
20702
|
amount: quote.amount,
|
|
20674
20703
|
currencyId: quote.currency,
|
|
20675
20704
|
id: quote.quote.id,
|
|
@@ -20764,7 +20793,7 @@ function ActualQuote({ onQuoteAccepted }) {
|
|
|
20764
20793
|
},
|
|
20765
20794
|
placeholderData: keepPreviousData,
|
|
20766
20795
|
});
|
|
20767
|
-
const formattedQuote = data;
|
|
20796
|
+
const formattedQuote = data; // TODO: fix to use the correct type
|
|
20768
20797
|
// Hooks
|
|
20769
20798
|
const { acceptBoxVisible, isAccepting, sendAccept, setAcceptBoxVisible, setIsAccepting, startAcceptance, pandadocPollingModalVisible, setPandadocPollingModalVisible, isSendAcceptPending, } = useSendAcceptQuote({
|
|
20770
20799
|
token,
|
|
@@ -20811,7 +20840,7 @@ function QuoteButtons({ isAccepted, formattedQuote, isMobile, hideDownloadButton
|
|
|
20811
20840
|
const signingPlugins = useSigningPlugins({ apiHost, token });
|
|
20812
20841
|
return (jsxs("div", { className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
|
|
20813
20842
|
color: secondaryColor,
|
|
20814
|
-
}, children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$v, { children: `Quote was accepted by ${formattedQuote.acceptedByName} on ${formatDate(formattedQuote.acceptedAt)}` })) : null, (!isMobile || !isAccepted) && (jsxs("div", { className: isMobile ? 'flex w-full justify-end gap-2' : 'flex items-center justify-end gap-2', children: [paymentHold ? (jsx(PaymentHoldDisplay, { paymentHold: paymentHold, currency: formattedQuote.currency, amount: formattedQuote.amount })) : null, !isMobile && !hideDownloadButton ? (jsx(Button, { icon: jsx(DownloadOutlined, {}), onClick: () => downloadFile(apiHost + '/api/pdf/quote', token), children: "Download" })) : null, shouldDoPaymentHold && !paymentHoldCompleted ? (jsx(Button, { disabled: isExpired, onClick: () => setPaymentHoldModalVisible(true), type: "primary", children: "Pay
|
|
20843
|
+
}, children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$v, { children: `Quote was accepted by ${formattedQuote.acceptedByName} on ${formatDate(formattedQuote.acceptedAt)}` })) : null, (!isMobile || !isAccepted) && (jsxs("div", { className: isMobile ? 'flex w-full justify-end gap-2' : 'flex items-center justify-end gap-2', children: [paymentHold ? (jsx(PaymentHoldDisplay, { paymentHold: paymentHold, currency: formattedQuote.currency, amount: formattedQuote.amount })) : null, !isMobile && !hideDownloadButton ? (jsx(Button, { icon: jsx(DownloadOutlined, {}), onClick: () => downloadFile(apiHost + '/api/pdf/quote', token), children: "Download" })) : null, shouldDoPaymentHold && !paymentHoldCompleted ? (jsx(Button, { disabled: isExpired, onClick: () => setPaymentHoldModalVisible(true), type: "primary", children: "Pay and sign" })) : (jsx(Fragment, { children: !isAccepted ? (jsx(Button, { disabled: isExpired || isAccepting, onClick: handleClickAccept, type: "primary", children: isExpired
|
|
20815
20844
|
? 'Quote is expired'
|
|
20816
20845
|
: (signingPlugins === null || signingPlugins === void 0 ? void 0 : signingPlugins.length)
|
|
20817
20846
|
? 'Start signing'
|
|
@@ -20827,6 +20856,8 @@ function PaymentHoldDisplay({ paymentHold, currency, amount, }) {
|
|
|
20827
20856
|
return (jsx(Tooltip, { title: `${formattedAmount} will be charged to ${paymentMethod} once the quote is accepted. Hold will be released on ${expirationDate} if not accepted.`, children: jsx(Fragment, { children: jsxs(CustomizedTag, { color: 'orange', className: "rounded-md", style: { padding: 6 }, children: ["Hold of ", formattedAmount, " on ****", paymentMethod] }) }) }));
|
|
20828
20857
|
}
|
|
20829
20858
|
|
|
20859
|
+
const TransactionsListContext = createContext({});
|
|
20860
|
+
|
|
20830
20861
|
const QUOTES_QUERY = (filter) => `
|
|
20831
20862
|
query quotes {
|
|
20832
20863
|
quotes ${filter ? `(${filter})` : ''} {
|
|
@@ -20863,8 +20894,6 @@ const getQuotes = async ({ token, apiHost, filter, }) => {
|
|
|
20863
20894
|
return response === null || response === void 0 ? void 0 : response.quotes;
|
|
20864
20895
|
};
|
|
20865
20896
|
|
|
20866
|
-
const TransactionsListContext = createContext({});
|
|
20867
|
-
|
|
20868
20897
|
const transactionMutation = (filter) => `
|
|
20869
20898
|
query transactions {
|
|
20870
20899
|
transactions ${filter ? `(${filter})` : ''} {
|
|
@@ -21188,7 +21217,7 @@ function TransactionsDisplay({ transactions, onSearchValueChanged, search, }) {
|
|
|
21188
21217
|
}, children: isMobile ? (jsx(TransactionsListMobile, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) : (jsx(TransactionsListDesktop, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) })] }), useModal ? (jsx(Modal, { title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null, children: jsx(Invoice, { id: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId, hidePaymentForm: hidePaymentForm }) })) : (jsx(Drawer, { title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH, children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === 'INVOICE' ? (jsx(Invoice, { id: selectedTransaction.transactionableId, hidePaymentForm: hidePaymentForm })) : (jsxs(Card$1, { className: "bunny-shadow-md", children: [jsx(Typography.Title, { level: 2, className: "bunny-mb-4", children: "Transaction Details" }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Amount:" }), ' ', jsx(Typography.Text, { children: formatCurrency$1((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 })] })] })) }))] }));
|
|
21189
21218
|
}
|
|
21190
21219
|
|
|
21191
|
-
function Quotes({ className, columns = ['date', 'title', 'amount', 'download', 'state'], filter, filterQuotes, sort = (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), noQuotesMessage = 'There are no quotes', onQuoteClick,
|
|
21220
|
+
function Quotes({ className, columns = ['date', 'title', 'amount', 'download', 'state'], filter, filterQuotes, sort = (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), noQuotesMessage = 'There are no quotes', onQuoteClick, renderQuote, searchBarClassName, shadow = 'shadow-md', showSearchBar = true, showTitle = true, title = 'Past quotes', style, suppressQuoteDisplay = false, useModal = false, }) {
|
|
21192
21221
|
const { apiHost } = useContext(BunnyContext);
|
|
21193
21222
|
const [component, setComponent] = useState(null);
|
|
21194
21223
|
const contextValues = {
|
|
@@ -21238,8 +21267,8 @@ function Quotes({ className, columns = ['date', 'title', 'amount', 'download', '
|
|
|
21238
21267
|
}
|
|
21239
21268
|
function handleQuoteClick(quote) {
|
|
21240
21269
|
onQuoteClick === null || onQuoteClick === void 0 ? void 0 : onQuoteClick(quote);
|
|
21241
|
-
if (
|
|
21242
|
-
setComponent(
|
|
21270
|
+
if (renderQuote !== undefined) {
|
|
21271
|
+
setComponent(renderQuote(quote));
|
|
21243
21272
|
}
|
|
21244
21273
|
else {
|
|
21245
21274
|
setComponent(jsx(Quote, { id: quote === null || quote === void 0 ? void 0 : quote.transactionableId }));
|
|
@@ -22173,12 +22202,8 @@ const CheckoutBarInput = ({ disabled, priceListCharge, quantity, onQuantityChang
|
|
|
22173
22202
|
}, min: priceListCharge === null || priceListCharge === void 0 ? void 0 : priceListCharge.quantityMin, max: priceListCharge === null || priceListCharge === void 0 ? void 0 : priceListCharge.quantityMax, style: { minWidth: '120px' }, type: "number", value: quantity, required: true }) })] }));
|
|
22174
22203
|
};
|
|
22175
22204
|
const QuantityLabel = ({ activeCharge }) => {
|
|
22176
|
-
|
|
22177
|
-
|
|
22178
|
-
const pluralizedFeatureName = (StringUtils.isStringPluralized(featureName) || !featureName
|
|
22179
|
-
? featureName
|
|
22180
|
-
: StringUtils.pluralizeEntityName(featureName)) || '';
|
|
22181
|
-
return (jsx(Text$n, { className: "bunny-text-slate-500 bunny-font-medium bunny-text-nowrap", style: { fontSize: '11px' }, children: pluralizedFeatureName.toUpperCase() }));
|
|
22205
|
+
const chargeName = activeCharge.name;
|
|
22206
|
+
return (jsx(Text$n, { className: "bunny-text-slate-500 bunny-font-medium bunny-text-nowrap", style: { fontSize: '11px' }, children: chargeName.toUpperCase() }));
|
|
22182
22207
|
};
|
|
22183
22208
|
|
|
22184
22209
|
const periodMonthsConverter = (period) => {
|
|
@@ -22707,11 +22732,8 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
|
|
|
22707
22732
|
token,
|
|
22708
22733
|
});
|
|
22709
22734
|
const { mutate: recalculateTaxesMutation } = useMutation({
|
|
22710
|
-
mutationFn: () => {
|
|
22711
|
-
|
|
22712
|
-
throw new Error('Quote ID is required');
|
|
22713
|
-
}
|
|
22714
|
-
return quoteRecalculateTaxes({ token, apiHost, quoteId: quote.id });
|
|
22735
|
+
mutationFn: (quoteId) => {
|
|
22736
|
+
return quoteRecalculateTaxes({ token, apiHost, quoteId });
|
|
22715
22737
|
},
|
|
22716
22738
|
onError: (error) => {
|
|
22717
22739
|
if (!error[0].message.includes('Ensure that you have a taxation plugin')) {
|
|
@@ -22760,8 +22782,7 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
|
|
|
22760
22782
|
}),
|
|
22761
22783
|
});
|
|
22762
22784
|
setInitialQuote(data.quote);
|
|
22763
|
-
|
|
22764
|
-
handleRecalculateTaxes();
|
|
22785
|
+
handleRecalculateTaxes(data.quote.id);
|
|
22765
22786
|
},
|
|
22766
22787
|
onError: (error) => {
|
|
22767
22788
|
const errorMessage = error.response.errors[0].message;
|
|
@@ -22799,7 +22820,7 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
|
|
|
22799
22820
|
queryKey: ['quote', quote === null || quote === void 0 ? void 0 : quote.id],
|
|
22800
22821
|
});
|
|
22801
22822
|
showSuccessNotification('Coupon applied');
|
|
22802
|
-
handleRecalculateTaxes();
|
|
22823
|
+
handleRecalculateTaxes(quote === null || quote === void 0 ? void 0 : quote.id);
|
|
22803
22824
|
setCouponEditorCouponCode('');
|
|
22804
22825
|
},
|
|
22805
22826
|
onCouponRemoved: () => {
|
|
@@ -22807,7 +22828,7 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
|
|
|
22807
22828
|
queryKey: ['quote', quote === null || quote === void 0 ? void 0 : quote.id],
|
|
22808
22829
|
});
|
|
22809
22830
|
showSuccessNotification('Coupon removed');
|
|
22810
|
-
handleRecalculateTaxes();
|
|
22831
|
+
handleRecalculateTaxes(quote === null || quote === void 0 ? void 0 : quote.id);
|
|
22811
22832
|
},
|
|
22812
22833
|
});
|
|
22813
22834
|
// Handle default coupon application
|
|
@@ -22841,18 +22862,21 @@ function Signup({ companyName, priceListCode, returnUrl, couponCode, className,
|
|
|
22841
22862
|
accountId,
|
|
22842
22863
|
});
|
|
22843
22864
|
}
|
|
22844
|
-
function handleRecalculateTaxes() {
|
|
22845
|
-
|
|
22865
|
+
function handleRecalculateTaxes(quoteId) {
|
|
22866
|
+
if (!quoteId) {
|
|
22867
|
+
showErrorNotification$1('No quote ID found to recalculate taxes');
|
|
22868
|
+
return;
|
|
22869
|
+
}
|
|
22846
22870
|
if (!hasTaxPlugin) {
|
|
22847
|
-
|
|
22871
|
+
showErrorNotification$1('No tax plugin found to recalculate taxes');
|
|
22848
22872
|
return;
|
|
22849
22873
|
}
|
|
22850
|
-
recalculateTaxesMutation();
|
|
22874
|
+
recalculateTaxesMutation(quoteId);
|
|
22851
22875
|
}
|
|
22852
22876
|
if (purchaseSucceeded) {
|
|
22853
22877
|
return (jsx(Fragment, { children: (quote === null || quote === void 0 ? void 0 : quote.currencyId) !== undefined ? (jsx("div", { className: "bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 bunny-flex bunny-items-start bunny-pt-[25vh]", children: jsx(PaymentSuccessDisplay, { amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, className: "bunny-w-full", companyName: companyName, returnUrl: returnUrl, currencyId: quote === null || quote === void 0 ? void 0 : quote.currencyId }) })) : (jsx("div", { children: "No currency ID found from Quote" })) }));
|
|
22854
22878
|
}
|
|
22855
|
-
return (jsxs("div", { className: `bunny-flex ${isMobile ? 'bunny-flex-col' : 'bunny-flex-row'} bunny-h-screen bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 ${shadow} ${className}`, style: style, children: [jsx("div", { className: `bunny-flex bunny-items-center bunny-flex-col ${isMobile ? 'bunny-w-full bunny-h-1/2' : 'bunny-w-1/2 bunny-h-full'} bunny-justify-center`, children: jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-start bunny-justify-between bunny-w-3/5 bunny-h-full bunny-gap-4 bunny-my-24", children: [jsx("div", { children: topNavImageUrl.length > 0 && (jsx(
|
|
22879
|
+
return (jsxs("div", { className: `bunny-flex ${isMobile ? 'bunny-flex-col' : 'bunny-flex-row'} bunny-h-screen bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 ${shadow} ${className}`, style: style, children: [jsx("div", { className: `bunny-flex bunny-items-center bunny-flex-col ${isMobile ? 'bunny-w-full bunny-h-1/2' : 'bunny-w-1/2 bunny-h-full'} bunny-justify-center`, children: jsxs("div", { className: "bunny-flex bunny-flex-col bunny-items-start bunny-justify-between bunny-w-3/5 bunny-h-full bunny-gap-4 bunny-my-24", children: [jsx("div", { children: topNavImageUrl.length > 0 && (jsx("img", { alt: "Logo", src: topNavImageUrl, style: { width: 'auto', height: '28px' } })) }), data ? (jsx(CheckoutSummary, { quote: data, className: "bunny-h-full bunny-w-full", onAddCoupon: addCoupon, onRemoveCoupon: removeCoupon, isRemovingCoupon: isRemovingCoupon, priceListData: priceListData, isAddingCoupon: isAddingCoupon, couponCode: couponEditorCouponCode, setCouponCode: setCouponEditorCouponCode, activeCouponsExist: activeCouponsExist })) : (jsx("div", { className: "bunny-h-full", children: isLoadingPriceList ? (jsx(Skeleton, { active: true })) : (jsx(PriceListDisplay, { priceListData: priceListData })) })), jsx(Footer, {})] }) }), jsx("div", { className: `bunny-flex bunny-flex-col ${isMobile ? 'bunny-w-full bunny-h-1/2 bunny-overflow-auto' : 'bunny-w-1/2 bunny-h-full'} bunny-items-center`, style: {
|
|
22856
22880
|
boxShadow: '-5px 0 20px 0 rgba(0, 0, 0, 0.05)',
|
|
22857
22881
|
}, children: isLoadingPriceList ? (jsx(Skeleton, { active: true, className: `bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24` })) : (jsx("div", { className: `bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24`, children: jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction, defaultValues: defaultValues }) })) })] }));
|
|
22858
22882
|
}
|
|
@@ -24621,7 +24645,7 @@ function doesPriceListHaveFlatFeeCharges(maskedPriceList) {
|
|
|
24621
24645
|
function priceDescriptionString({ unitName, showPriceAsMonthly, periodMonths, priceListHasFlatFeeCharges, }) {
|
|
24622
24646
|
const periodMonthsConverted = periodMonthsConverter(periodMonths);
|
|
24623
24647
|
const periodLabel = periodMonthsConverted ? PERIOD_LABELS[periodMonthsConverted] : null;
|
|
24624
|
-
return `
|
|
24648
|
+
return `Per ${unitName && !priceListHasFlatFeeCharges ? `${unitName.toLowerCase()} / ` : ''}${showPriceAsMonthly ? 'month' : periodLabel}`;
|
|
24625
24649
|
}
|
|
24626
24650
|
|
|
24627
24651
|
var localizedFormat$2 = {exports: {}};
|