@bunnyapp/components 1.0.76-beta.8 → 1.0.76-beta.9
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 +33 -9
- package/dist/cjs/src/components/Signup/PaymentForms.d.ts +9 -1
- package/dist/cjs/src/components/Signup/Signup.d.ts +11 -1
- package/dist/cjs/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/EverythingPlanFeatures.d.ts +7 -0
- package/dist/cjs/src/components/Transactions/transactionsList/utils.d.ts +1 -1
- package/dist/esm/index.js +33 -9
- package/dist/esm/src/components/Signup/PaymentForms.d.ts +9 -1
- package/dist/esm/src/components/Signup/Signup.d.ts +11 -1
- package/dist/esm/src/components/Subscriptions/PlanManager/PlanPicker/planPickerDesktop/EverythingPlanFeatures.d.ts +7 -0
- package/dist/esm/src/components/Transactions/transactionsList/utils.d.ts +1 -1
- package/dist/index.d.ts +11 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -154,7 +154,7 @@ var BrandContext = react.createContext({
|
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
// This will be replaced at build time by rollup-plugin-replace
|
|
157
|
-
var PACKAGE_VERSION = '1.0.76-beta.
|
|
157
|
+
var PACKAGE_VERSION = '1.0.76-beta.9';
|
|
158
158
|
var createRequestHeaders = function (token) {
|
|
159
159
|
var headers = common.createClientDevHeaders(token);
|
|
160
160
|
// Add the components version header
|
|
@@ -20499,12 +20499,12 @@ var CheckoutSummaryDivider = function () {
|
|
|
20499
20499
|
|
|
20500
20500
|
var Title$1 = antd.Typography.Title;
|
|
20501
20501
|
function PaymentForms(_a) {
|
|
20502
|
-
var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction;
|
|
20502
|
+
var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, defaultValues = _a.defaultValues;
|
|
20503
20503
|
var entityId = useCurrentUserData().entityId;
|
|
20504
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment })] })) }));
|
|
20504
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: overrideToken ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsxRuntime.jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })] })) : null })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsxRuntime.jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
|
|
20505
20505
|
}
|
|
20506
20506
|
function InitialSignupForm(_a) {
|
|
20507
|
-
var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting;
|
|
20507
|
+
var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting, defaultValues = _a.defaultValues;
|
|
20508
20508
|
var form = antd.Form.useForm()[0];
|
|
20509
20509
|
var isMobile = common.useIsMobile();
|
|
20510
20510
|
function handleSubmit() {
|
|
@@ -20512,6 +20512,22 @@ function InitialSignupForm(_a) {
|
|
|
20512
20512
|
onSubmit(form.getFieldsValue());
|
|
20513
20513
|
});
|
|
20514
20514
|
}
|
|
20515
|
+
react.useEffect(function () {
|
|
20516
|
+
if (defaultValues) {
|
|
20517
|
+
// Set all non empty default values
|
|
20518
|
+
form.setFieldsValue(Object.fromEntries(Object.entries(__assign(__assign({}, defaultValues), { billingCountry: undefined })).filter(function (_a) {
|
|
20519
|
+
var v = _a[0]; _a[1];
|
|
20520
|
+
return v;
|
|
20521
|
+
})));
|
|
20522
|
+
// Set billing country if it's in the country list
|
|
20523
|
+
if (defaultValues.billingCountry &&
|
|
20524
|
+
common.Lists.COUNTRY_LIST.find(function (c) { return c.value === defaultValues.billingCountry; })) {
|
|
20525
|
+
form.setFieldsValue({
|
|
20526
|
+
billingCountry: defaultValues.billingCountry,
|
|
20527
|
+
});
|
|
20528
|
+
}
|
|
20529
|
+
}
|
|
20530
|
+
}, [defaultValues]);
|
|
20515
20531
|
return (jsxRuntime.jsx(antd.Form, __assign({ className: "bunny-flex bunny-flex-col bunny-h-full bunny-w-full ".concat(className), form: form, layout: "vertical", autoComplete: "off" }, { children: jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-space-y-2" }, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ name: "firstName", rules: [{ required: true, message: 'First name is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "First name" }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ name: "lastName", rules: [{ required: true, message: 'Last name is required' }], className: "bunny-flex-1" }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Last name" }) }))] })), jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsxRuntime.jsx(antd.Form.Item, __assign({ name: "email", rules: [
|
|
20516
20532
|
{ required: true, message: 'Email is required' },
|
|
20517
20533
|
{ type: 'email', message: 'Please enter a valid email' },
|
|
@@ -20540,7 +20556,7 @@ var showErrorNotification = common.useErrorNotification();
|
|
|
20540
20556
|
var showSuccessNotification$1 = common.useSuccessNotification();
|
|
20541
20557
|
function Signup(_a) {
|
|
20542
20558
|
var _b, _c, _d;
|
|
20543
|
-
var companyName = _a.companyName, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, couponCode = _a.couponCode, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? 'shadow-md' : _e, style = _a.style;
|
|
20559
|
+
var companyName = _a.companyName, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, couponCode = _a.couponCode, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? 'shadow-md' : _e, style = _a.style, defaultFirstName = _a.defaultFirstName, defaultLastName = _a.defaultLastName, defaultEmail = _a.defaultEmail, defaultCompanyName = _a.defaultCompanyName, defaultBillingCountry = _a.defaultBillingCountry;
|
|
20544
20560
|
// Hooks
|
|
20545
20561
|
var apiHost = react.useContext(BunnyContext).apiHost;
|
|
20546
20562
|
var tokenFromContexts = useToken();
|
|
@@ -20640,16 +20656,18 @@ function Signup(_a) {
|
|
|
20640
20656
|
enabled: !!(initialQuote === null || initialQuote === void 0 ? void 0 : initialQuote.id),
|
|
20641
20657
|
}), data = _o.data, isLoadingQuote = _o.isLoading;
|
|
20642
20658
|
var quote = data || initialQuote;
|
|
20659
|
+
var quoteChangeId = (_d = (_b = quote === null || quote === void 0 ? void 0 : quote.quoteChanges) === null || _b === void 0 ? void 0 : _b[((_c = quote === null || quote === void 0 ? void 0 : quote.quoteChanges) === null || _c === void 0 ? void 0 : _c.length) - 1]) === null || _d === void 0 ? void 0 : _d.id;
|
|
20643
20660
|
var _p = useUpdateCoupons({
|
|
20644
20661
|
apiHost: apiHost,
|
|
20645
20662
|
token: token,
|
|
20646
|
-
quoteChangeId:
|
|
20663
|
+
quoteChangeId: quoteChangeId,
|
|
20647
20664
|
onCouponAdded: function () {
|
|
20648
20665
|
queryClient.invalidateQueries({
|
|
20649
20666
|
queryKey: ['quote', quote === null || quote === void 0 ? void 0 : quote.id],
|
|
20650
20667
|
});
|
|
20651
20668
|
showSuccessNotification$1('Coupon applied');
|
|
20652
20669
|
recalculateTaxes();
|
|
20670
|
+
setCouponEditorCouponCode('');
|
|
20653
20671
|
},
|
|
20654
20672
|
onCouponRemoved: function () {
|
|
20655
20673
|
queryClient.invalidateQueries({
|
|
@@ -20661,11 +20679,11 @@ function Signup(_a) {
|
|
|
20661
20679
|
}), addCoupon = _p.addCoupon, removeCoupon = _p.removeCoupon, isAddingCoupon = _p.isAddingCoupon, isRemovingCoupon = _p.isRemovingCoupon, activeCouponsExist = _p.activeCouponsExist;
|
|
20662
20680
|
// Handle default coupon application
|
|
20663
20681
|
react.useEffect(function () {
|
|
20664
|
-
if (couponCode &&
|
|
20682
|
+
if (couponCode && quoteChangeId && defaultCouponAppliedRef.current !== couponCode) {
|
|
20665
20683
|
addCoupon(couponCode);
|
|
20666
20684
|
defaultCouponAppliedRef.current = couponCode;
|
|
20667
20685
|
}
|
|
20668
|
-
}, [couponCode,
|
|
20686
|
+
}, [couponCode, quoteChangeId]);
|
|
20669
20687
|
function handleSubmit(formData) {
|
|
20670
20688
|
return __awaiter(this, void 0, void 0, function () {
|
|
20671
20689
|
return __generator(this, function (_a) {
|
|
@@ -20727,7 +20745,13 @@ function Signup(_a) {
|
|
|
20727
20745
|
}
|
|
20728
20746
|
return (jsxRuntime.jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-col' : 'bunny-flex-row', " bunny-h-screen bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 ").concat(shadow, " ").concat(className), style: style }, { children: [jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-flex-col ".concat(isMobile ? 'bunny-w-full bunny-h-1/2' : 'bunny-w-1/2 bunny-h-full', " bunny-justify-center") }, { children: jsxRuntime.jsxs("div", __assign({ 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: [jsxRuntime.jsx("div", { children: topNavImageUrl.length > 0 && (jsxRuntime.jsx(antd.Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false })) }), data ? (jsxRuntime.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 })) : (jsxRuntime.jsx("div", __assign({ className: "bunny-h-full" }, { children: isLoadingPriceList ? (jsxRuntime.jsx(antd.Skeleton, { active: true })) : (jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData })) }))), jsxRuntime.jsx(Footer, {})] })) })), jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col ".concat(isMobile ? 'bunny-w-full bunny-h-1/2 bunny-overflow-auto' : 'bunny-w-1/2 bunny-h-full', " bunny-items-center"), style: {
|
|
20729
20747
|
boxShadow: '-5px 0 20px 0 rgba(0, 0, 0, 0.05)',
|
|
20730
|
-
} }, { children: isLoadingPriceList ? (jsxRuntime.jsx(antd.Skeleton, { active: true, className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" })) : (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" }, { children: jsxRuntime.jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction
|
|
20748
|
+
} }, { children: isLoadingPriceList ? (jsxRuntime.jsx(antd.Skeleton, { active: true, className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" })) : (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" }, { children: jsxRuntime.jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction, defaultValues: {
|
|
20749
|
+
firstName: defaultFirstName,
|
|
20750
|
+
lastName: defaultLastName,
|
|
20751
|
+
email: defaultEmail,
|
|
20752
|
+
accountName: defaultCompanyName,
|
|
20753
|
+
billingCountry: defaultBillingCountry,
|
|
20754
|
+
} }) }))) }))] })));
|
|
20731
20755
|
}
|
|
20732
20756
|
|
|
20733
20757
|
var useQuoteSubscriptionUpgrade = function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginData, Quote } from '@bunnyapp/common';
|
|
2
|
-
export default function PaymentForms({ quote, handlePaymentSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, overrideToken, customCheckoutFunction, }: {
|
|
2
|
+
export default function PaymentForms({ quote, handlePaymentSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, overrideToken, customCheckoutFunction, defaultValues, }: {
|
|
3
3
|
quote?: Quote;
|
|
4
4
|
handlePaymentSuccess: () => void;
|
|
5
5
|
handlePaymentFail: (error: any) => void;
|
|
@@ -8,6 +8,7 @@ export default function PaymentForms({ quote, handlePaymentSuccess, handlePaymen
|
|
|
8
8
|
accountId?: string;
|
|
9
9
|
overrideToken?: string;
|
|
10
10
|
customCheckoutFunction?: (plugin: PluginData | undefined) => Promise<any>;
|
|
11
|
+
defaultValues?: DefaultSignupValues;
|
|
11
12
|
}): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export type FormData = {
|
|
13
14
|
firstName: string;
|
|
@@ -21,3 +22,10 @@ export type FormData = {
|
|
|
21
22
|
billingStreet: string;
|
|
22
23
|
taxNumber: string;
|
|
23
24
|
};
|
|
25
|
+
export type DefaultSignupValues = {
|
|
26
|
+
firstName?: string;
|
|
27
|
+
lastName?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
accountName?: string;
|
|
30
|
+
billingCountry?: string;
|
|
31
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import '../../styles/index.less';
|
|
3
3
|
import { ShadowType } from '../../types/shadowType';
|
|
4
|
-
export default function Signup({ companyName, priceListCode, returnUrl, couponCode, className, shadow, style, }: {
|
|
4
|
+
export default function Signup({ companyName, priceListCode, returnUrl, couponCode, className, shadow, style, defaultFirstName, defaultLastName, defaultEmail, defaultCompanyName, defaultBillingCountry, }: {
|
|
5
5
|
/** The company name to display on the signup page */
|
|
6
6
|
companyName: string;
|
|
7
7
|
/** The price list code to use for the signup */
|
|
@@ -16,4 +16,14 @@ export default function Signup({ companyName, priceListCode, returnUrl, couponCo
|
|
|
16
16
|
shadow?: ShadowType;
|
|
17
17
|
/** A custom style to apply to the component */
|
|
18
18
|
style?: React.CSSProperties;
|
|
19
|
+
/** The default first name to use for the signup */
|
|
20
|
+
defaultFirstName?: string;
|
|
21
|
+
/** The default last name to use for the signup */
|
|
22
|
+
defaultLastName?: string;
|
|
23
|
+
/** The default email to use for the signup */
|
|
24
|
+
defaultEmail?: string;
|
|
25
|
+
/** The default company name to use for the signup */
|
|
26
|
+
defaultCompanyName?: string;
|
|
27
|
+
/** The default billing country to use for the signup */
|
|
28
|
+
defaultBillingCountry?: string;
|
|
19
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -43,9 +43,16 @@ export declare const filterUniqueFeatures: ({ availablePriceLists, }: {
|
|
|
43
43
|
name: string;
|
|
44
44
|
periodMonths: 0 | 1 | 3 | 6 | 12;
|
|
45
45
|
planId: string;
|
|
46
|
+
priceAdjustmentAction?: import("@bunnyapp/common").PriceAdjustmentAction | undefined;
|
|
47
|
+
priceAdjustmentActionOptions?: string[] | undefined;
|
|
48
|
+
priceAdjustmentPercentage?: number | undefined;
|
|
49
|
+
priceAdjustmentTiming?: import("@bunnyapp/common").PriceAdjustmentTiming | undefined;
|
|
50
|
+
priceAdjustmentTimingOptions?: string[] | undefined;
|
|
46
51
|
priceDescription?: string | undefined;
|
|
47
52
|
product: Product;
|
|
48
53
|
productId?: string | undefined;
|
|
54
|
+
renewalTermMonths?: number | undefined;
|
|
55
|
+
showPriceAsMonthly?: boolean | undefined;
|
|
49
56
|
sku?: string | undefined;
|
|
50
57
|
trialAllowed: boolean;
|
|
51
58
|
trialExpirationAction?: ("CANCEL" | "ACTIVATE") | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Transaction } from '@bunnyapp/common';
|
|
2
2
|
import { TransactionDateType } from '../TransactionsListContext';
|
|
3
|
-
export declare function transactionDateToDisplay(transaction: Transaction, transactionDateType: TransactionDateType):
|
|
3
|
+
export declare function transactionDateToDisplay(transaction: Transaction, transactionDateType: TransactionDateType): string;
|
package/dist/esm/index.js
CHANGED
|
@@ -143,7 +143,7 @@ var BrandContext = createContext({
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
// This will be replaced at build time by rollup-plugin-replace
|
|
146
|
-
var PACKAGE_VERSION = '1.0.76-beta.
|
|
146
|
+
var PACKAGE_VERSION = '1.0.76-beta.9';
|
|
147
147
|
var createRequestHeaders = function (token) {
|
|
148
148
|
var headers = createClientDevHeaders(token);
|
|
149
149
|
// Add the components version header
|
|
@@ -20488,12 +20488,12 @@ var CheckoutSummaryDivider = function () {
|
|
|
20488
20488
|
|
|
20489
20489
|
var Title$1 = Typography.Title;
|
|
20490
20490
|
function PaymentForms(_a) {
|
|
20491
|
-
var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction;
|
|
20491
|
+
var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction, defaultValues = _a.defaultValues;
|
|
20492
20492
|
var entityId = useCurrentUserData().entityId;
|
|
20493
|
-
return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsxs(Fragment, { children: [jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })] })) : null })) : (jsxs(Fragment, { children: [jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment })] })) }));
|
|
20493
|
+
return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsxs(Fragment, { children: [jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Payment" })), jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, customCheckoutFunction: customCheckoutFunction })] })) : null })) : (jsxs(Fragment, { children: [jsx(Title$1, __assign({ className: "bunny-px-4 bunny-m-0", level: 2 }, { children: "Signup" })), jsx(InitialSignupForm, { className: "bunny-px-4", onSubmit: handleSubmit, submitting: proceedingToPayment, defaultValues: defaultValues })] })) }));
|
|
20494
20494
|
}
|
|
20495
20495
|
function InitialSignupForm(_a) {
|
|
20496
|
-
var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting;
|
|
20496
|
+
var className = _a.className, onSubmit = _a.onSubmit, submitting = _a.submitting, defaultValues = _a.defaultValues;
|
|
20497
20497
|
var form = Form.useForm()[0];
|
|
20498
20498
|
var isMobile = useIsMobile();
|
|
20499
20499
|
function handleSubmit() {
|
|
@@ -20501,6 +20501,22 @@ function InitialSignupForm(_a) {
|
|
|
20501
20501
|
onSubmit(form.getFieldsValue());
|
|
20502
20502
|
});
|
|
20503
20503
|
}
|
|
20504
|
+
useEffect(function () {
|
|
20505
|
+
if (defaultValues) {
|
|
20506
|
+
// Set all non empty default values
|
|
20507
|
+
form.setFieldsValue(Object.fromEntries(Object.entries(__assign(__assign({}, defaultValues), { billingCountry: undefined })).filter(function (_a) {
|
|
20508
|
+
var v = _a[0]; _a[1];
|
|
20509
|
+
return v;
|
|
20510
|
+
})));
|
|
20511
|
+
// Set billing country if it's in the country list
|
|
20512
|
+
if (defaultValues.billingCountry &&
|
|
20513
|
+
Lists.COUNTRY_LIST.find(function (c) { return c.value === defaultValues.billingCountry; })) {
|
|
20514
|
+
form.setFieldsValue({
|
|
20515
|
+
billingCountry: defaultValues.billingCountry,
|
|
20516
|
+
});
|
|
20517
|
+
}
|
|
20518
|
+
}
|
|
20519
|
+
}, [defaultValues]);
|
|
20504
20520
|
return (jsx(Form, __assign({ className: "bunny-flex bunny-flex-col bunny-h-full bunny-w-full ".concat(className), form: form, layout: "vertical", autoComplete: "off" }, { children: jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-space-y-2" }, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsx(Form.Item, __assign({ name: "firstName", rules: [{ required: true, message: 'First name is required' }], className: "bunny-flex-1" }, { children: jsx(Input, { placeholder: "First name" }) })), jsx(Form.Item, __assign({ name: "lastName", rules: [{ required: true, message: 'Last name is required' }], className: "bunny-flex-1" }, { children: jsx(Input, { placeholder: "Last name" }) }))] })), jsxs("div", __assign({ className: "bunny-flex bunny-gap-4" }, { children: [jsx(Form.Item, __assign({ name: "email", rules: [
|
|
20505
20521
|
{ required: true, message: 'Email is required' },
|
|
20506
20522
|
{ type: 'email', message: 'Please enter a valid email' },
|
|
@@ -20529,7 +20545,7 @@ var showErrorNotification = useErrorNotification();
|
|
|
20529
20545
|
var showSuccessNotification$1 = useSuccessNotification();
|
|
20530
20546
|
function Signup(_a) {
|
|
20531
20547
|
var _b, _c, _d;
|
|
20532
|
-
var companyName = _a.companyName, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, couponCode = _a.couponCode, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? 'shadow-md' : _e, style = _a.style;
|
|
20548
|
+
var companyName = _a.companyName, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, couponCode = _a.couponCode, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? 'shadow-md' : _e, style = _a.style, defaultFirstName = _a.defaultFirstName, defaultLastName = _a.defaultLastName, defaultEmail = _a.defaultEmail, defaultCompanyName = _a.defaultCompanyName, defaultBillingCountry = _a.defaultBillingCountry;
|
|
20533
20549
|
// Hooks
|
|
20534
20550
|
var apiHost = useContext(BunnyContext).apiHost;
|
|
20535
20551
|
var tokenFromContexts = useToken();
|
|
@@ -20629,16 +20645,18 @@ function Signup(_a) {
|
|
|
20629
20645
|
enabled: !!(initialQuote === null || initialQuote === void 0 ? void 0 : initialQuote.id),
|
|
20630
20646
|
}), data = _o.data, isLoadingQuote = _o.isLoading;
|
|
20631
20647
|
var quote = data || initialQuote;
|
|
20648
|
+
var quoteChangeId = (_d = (_b = quote === null || quote === void 0 ? void 0 : quote.quoteChanges) === null || _b === void 0 ? void 0 : _b[((_c = quote === null || quote === void 0 ? void 0 : quote.quoteChanges) === null || _c === void 0 ? void 0 : _c.length) - 1]) === null || _d === void 0 ? void 0 : _d.id;
|
|
20632
20649
|
var _p = useUpdateCoupons({
|
|
20633
20650
|
apiHost: apiHost,
|
|
20634
20651
|
token: token,
|
|
20635
|
-
quoteChangeId:
|
|
20652
|
+
quoteChangeId: quoteChangeId,
|
|
20636
20653
|
onCouponAdded: function () {
|
|
20637
20654
|
queryClient.invalidateQueries({
|
|
20638
20655
|
queryKey: ['quote', quote === null || quote === void 0 ? void 0 : quote.id],
|
|
20639
20656
|
});
|
|
20640
20657
|
showSuccessNotification$1('Coupon applied');
|
|
20641
20658
|
recalculateTaxes();
|
|
20659
|
+
setCouponEditorCouponCode('');
|
|
20642
20660
|
},
|
|
20643
20661
|
onCouponRemoved: function () {
|
|
20644
20662
|
queryClient.invalidateQueries({
|
|
@@ -20650,11 +20668,11 @@ function Signup(_a) {
|
|
|
20650
20668
|
}), addCoupon = _p.addCoupon, removeCoupon = _p.removeCoupon, isAddingCoupon = _p.isAddingCoupon, isRemovingCoupon = _p.isRemovingCoupon, activeCouponsExist = _p.activeCouponsExist;
|
|
20651
20669
|
// Handle default coupon application
|
|
20652
20670
|
useEffect(function () {
|
|
20653
|
-
if (couponCode &&
|
|
20671
|
+
if (couponCode && quoteChangeId && defaultCouponAppliedRef.current !== couponCode) {
|
|
20654
20672
|
addCoupon(couponCode);
|
|
20655
20673
|
defaultCouponAppliedRef.current = couponCode;
|
|
20656
20674
|
}
|
|
20657
|
-
}, [couponCode,
|
|
20675
|
+
}, [couponCode, quoteChangeId]);
|
|
20658
20676
|
function handleSubmit(formData) {
|
|
20659
20677
|
return __awaiter(this, void 0, void 0, function () {
|
|
20660
20678
|
return __generator(this, function (_a) {
|
|
@@ -20716,7 +20734,13 @@ function Signup(_a) {
|
|
|
20716
20734
|
}
|
|
20717
20735
|
return (jsxs("div", __assign({ className: "bunny-flex ".concat(isMobile ? 'bunny-flex-col' : 'bunny-flex-row', " bunny-h-screen bunny-w-screen bunny-absolute bunny-top-0 bunny-left-0 ").concat(shadow, " ").concat(className), style: style }, { children: [jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-flex-col ".concat(isMobile ? 'bunny-w-full bunny-h-1/2' : 'bunny-w-1/2 bunny-h-full', " bunny-justify-center") }, { children: jsxs("div", __assign({ 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(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false })) }), 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", __assign({ className: "bunny-h-full" }, { children: isLoadingPriceList ? (jsx(Skeleton, { active: true })) : (jsx(PriceListDisplay, { priceListData: priceListData })) }))), jsx(Footer, {})] })) })), jsx("div", __assign({ className: "bunny-flex bunny-flex-col ".concat(isMobile ? 'bunny-w-full bunny-h-1/2 bunny-overflow-auto' : 'bunny-w-1/2 bunny-h-full', " bunny-items-center"), style: {
|
|
20718
20736
|
boxShadow: '-5px 0 20px 0 rgba(0, 0, 0, 0.05)',
|
|
20719
|
-
} }, { children: isLoadingPriceList ? (jsx(Skeleton, { active: true, className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" })) : (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" }, { children: jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction
|
|
20737
|
+
} }, { children: isLoadingPriceList ? (jsx(Skeleton, { active: true, className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" })) : (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-w-3/5 bunny-mt-24" }, { children: jsx(PaymentForms, { quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: isSigningUp || isLoadingQuote, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction, defaultValues: {
|
|
20738
|
+
firstName: defaultFirstName,
|
|
20739
|
+
lastName: defaultLastName,
|
|
20740
|
+
email: defaultEmail,
|
|
20741
|
+
accountName: defaultCompanyName,
|
|
20742
|
+
billingCountry: defaultBillingCountry,
|
|
20743
|
+
} }) }))) }))] })));
|
|
20720
20744
|
}
|
|
20721
20745
|
|
|
20722
20746
|
var useQuoteSubscriptionUpgrade = function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginData, Quote } from '@bunnyapp/common';
|
|
2
|
-
export default function PaymentForms({ quote, handlePaymentSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, overrideToken, customCheckoutFunction, }: {
|
|
2
|
+
export default function PaymentForms({ quote, handlePaymentSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, overrideToken, customCheckoutFunction, defaultValues, }: {
|
|
3
3
|
quote?: Quote;
|
|
4
4
|
handlePaymentSuccess: () => void;
|
|
5
5
|
handlePaymentFail: (error: any) => void;
|
|
@@ -8,6 +8,7 @@ export default function PaymentForms({ quote, handlePaymentSuccess, handlePaymen
|
|
|
8
8
|
accountId?: string;
|
|
9
9
|
overrideToken?: string;
|
|
10
10
|
customCheckoutFunction?: (plugin: PluginData | undefined) => Promise<any>;
|
|
11
|
+
defaultValues?: DefaultSignupValues;
|
|
11
12
|
}): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export type FormData = {
|
|
13
14
|
firstName: string;
|
|
@@ -21,3 +22,10 @@ export type FormData = {
|
|
|
21
22
|
billingStreet: string;
|
|
22
23
|
taxNumber: string;
|
|
23
24
|
};
|
|
25
|
+
export type DefaultSignupValues = {
|
|
26
|
+
firstName?: string;
|
|
27
|
+
lastName?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
accountName?: string;
|
|
30
|
+
billingCountry?: string;
|
|
31
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import '../../styles/index.less';
|
|
3
3
|
import { ShadowType } from '../../types/shadowType';
|
|
4
|
-
export default function Signup({ companyName, priceListCode, returnUrl, couponCode, className, shadow, style, }: {
|
|
4
|
+
export default function Signup({ companyName, priceListCode, returnUrl, couponCode, className, shadow, style, defaultFirstName, defaultLastName, defaultEmail, defaultCompanyName, defaultBillingCountry, }: {
|
|
5
5
|
/** The company name to display on the signup page */
|
|
6
6
|
companyName: string;
|
|
7
7
|
/** The price list code to use for the signup */
|
|
@@ -16,4 +16,14 @@ export default function Signup({ companyName, priceListCode, returnUrl, couponCo
|
|
|
16
16
|
shadow?: ShadowType;
|
|
17
17
|
/** A custom style to apply to the component */
|
|
18
18
|
style?: React.CSSProperties;
|
|
19
|
+
/** The default first name to use for the signup */
|
|
20
|
+
defaultFirstName?: string;
|
|
21
|
+
/** The default last name to use for the signup */
|
|
22
|
+
defaultLastName?: string;
|
|
23
|
+
/** The default email to use for the signup */
|
|
24
|
+
defaultEmail?: string;
|
|
25
|
+
/** The default company name to use for the signup */
|
|
26
|
+
defaultCompanyName?: string;
|
|
27
|
+
/** The default billing country to use for the signup */
|
|
28
|
+
defaultBillingCountry?: string;
|
|
19
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -43,9 +43,16 @@ export declare const filterUniqueFeatures: ({ availablePriceLists, }: {
|
|
|
43
43
|
name: string;
|
|
44
44
|
periodMonths: 0 | 1 | 3 | 6 | 12;
|
|
45
45
|
planId: string;
|
|
46
|
+
priceAdjustmentAction?: import("@bunnyapp/common").PriceAdjustmentAction | undefined;
|
|
47
|
+
priceAdjustmentActionOptions?: string[] | undefined;
|
|
48
|
+
priceAdjustmentPercentage?: number | undefined;
|
|
49
|
+
priceAdjustmentTiming?: import("@bunnyapp/common").PriceAdjustmentTiming | undefined;
|
|
50
|
+
priceAdjustmentTimingOptions?: string[] | undefined;
|
|
46
51
|
priceDescription?: string | undefined;
|
|
47
52
|
product: Product;
|
|
48
53
|
productId?: string | undefined;
|
|
54
|
+
renewalTermMonths?: number | undefined;
|
|
55
|
+
showPriceAsMonthly?: boolean | undefined;
|
|
49
56
|
sku?: string | undefined;
|
|
50
57
|
trialAllowed: boolean;
|
|
51
58
|
trialExpirationAction?: ("CANCEL" | "ACTIVATE") | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Transaction } from '@bunnyapp/common';
|
|
2
2
|
import { TransactionDateType } from '../TransactionsListContext';
|
|
3
|
-
export declare function transactionDateToDisplay(transaction: Transaction, transactionDateType: TransactionDateType):
|
|
3
|
+
export declare function transactionDateToDisplay(transaction: Transaction, transactionDateType: TransactionDateType): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ declare const PaymentForm: ({ invoice, onFail, onPaymentSuccess, onPaymentHoldSu
|
|
|
90
90
|
} | undefined;
|
|
91
91
|
}) => react_jsx_runtime.JSX.Element;
|
|
92
92
|
|
|
93
|
-
declare function Signup({ companyName, priceListCode, returnUrl, couponCode, className, shadow, style, }: {
|
|
93
|
+
declare function Signup({ companyName, priceListCode, returnUrl, couponCode, className, shadow, style, defaultFirstName, defaultLastName, defaultEmail, defaultCompanyName, defaultBillingCountry, }: {
|
|
94
94
|
/** The company name to display on the signup page */
|
|
95
95
|
companyName: string;
|
|
96
96
|
/** The price list code to use for the signup */
|
|
@@ -105,6 +105,16 @@ declare function Signup({ companyName, priceListCode, returnUrl, couponCode, cla
|
|
|
105
105
|
shadow?: ShadowType;
|
|
106
106
|
/** A custom style to apply to the component */
|
|
107
107
|
style?: React.CSSProperties;
|
|
108
|
+
/** The default first name to use for the signup */
|
|
109
|
+
defaultFirstName?: string;
|
|
110
|
+
/** The default last name to use for the signup */
|
|
111
|
+
defaultLastName?: string;
|
|
112
|
+
/** The default email to use for the signup */
|
|
113
|
+
defaultEmail?: string;
|
|
114
|
+
/** The default company name to use for the signup */
|
|
115
|
+
defaultCompanyName?: string;
|
|
116
|
+
/** The default billing country to use for the signup */
|
|
117
|
+
defaultBillingCountry?: string;
|
|
108
118
|
}): react_jsx_runtime.JSX.Element;
|
|
109
119
|
|
|
110
120
|
declare function BunnyProvider({ children, darkMode, queryClient, apiHost, token, onTokenExpired, configProviderProps, }: {
|
package/package.json
CHANGED