@bunnyapp/components 1.0.1 → 1.0.3
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 +87 -42
- package/dist/cjs/src/components/Signup/PaymentForms.d.ts +2 -1
- package/dist/cjs/src/components/Signup/PaymentSuccess.d.ts +2 -2
- package/dist/cjs/src/components/Signup/Signup.d.ts +2 -2
- package/dist/esm/index.js +87 -42
- package/dist/esm/src/components/Signup/PaymentForms.d.ts +2 -1
- package/dist/esm/src/components/Signup/PaymentSuccess.d.ts +2 -2
- package/dist/esm/src/components/Signup/Signup.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1550,14 +1550,14 @@ var BrandContext = React.createContext({
|
|
|
1550
1550
|
topNavImageUrl: common.DEFAULT_TOP_NAV_IMAGE_URL,
|
|
1551
1551
|
});
|
|
1552
1552
|
|
|
1553
|
-
var MUTATION$
|
|
1553
|
+
var MUTATION$9 = "{\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }";
|
|
1554
1554
|
var getBranding = function (_a) {
|
|
1555
1555
|
var token = _a.token, subdomain = _a.subdomain;
|
|
1556
1556
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
1557
1557
|
var response;
|
|
1558
1558
|
return __generator(this, function (_b) {
|
|
1559
1559
|
switch (_b.label) {
|
|
1560
|
-
case 0: return [4 /*yield*/, common.gqlRequest({ query: MUTATION$
|
|
1560
|
+
case 0: return [4 /*yield*/, common.gqlRequest({ query: MUTATION$9, token: token, subdomain: subdomain })];
|
|
1561
1561
|
case 1:
|
|
1562
1562
|
response = _b.sent();
|
|
1563
1563
|
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.entityBranding];
|
|
@@ -2272,6 +2272,7 @@ var DemoPayForm = function (_a) {
|
|
|
2272
2272
|
switch (_a.label) {
|
|
2273
2273
|
case 0:
|
|
2274
2274
|
_a.trys.push([0, 6, , 7]);
|
|
2275
|
+
validateCardDetails();
|
|
2275
2276
|
if (!onlySavePaymentMethod) return [3 /*break*/, 2];
|
|
2276
2277
|
setIsSaving(true);
|
|
2277
2278
|
return [4 /*yield*/, storePayment({
|
|
@@ -2299,14 +2300,6 @@ var DemoPayForm = function (_a) {
|
|
|
2299
2300
|
case 2:
|
|
2300
2301
|
if (!(amountDue !== undefined && currencyId)) return [3 /*break*/, 4];
|
|
2301
2302
|
setIsSaving(true);
|
|
2302
|
-
if (cardDetails.number !== TEST_CARD)
|
|
2303
|
-
throw new Error("Only the card number 4242 4242 4242 4242 will be accepted.");
|
|
2304
|
-
if (!isValidExpiry(cardDetails.expiry))
|
|
2305
|
-
throw new Error("Invalid expiry date");
|
|
2306
|
-
if (isCardExpired(cardDetails.expiry))
|
|
2307
|
-
throw new Error("Card is expired");
|
|
2308
|
-
if (cardDetails.cvc.length !== 3)
|
|
2309
|
-
throw new Error("Invalid CVC");
|
|
2310
2303
|
return [4 /*yield*/, confirmPayment({
|
|
2311
2304
|
amount: amountDue,
|
|
2312
2305
|
currency: currencyId,
|
|
@@ -2335,6 +2328,16 @@ var DemoPayForm = function (_a) {
|
|
|
2335
2328
|
}
|
|
2336
2329
|
});
|
|
2337
2330
|
}); };
|
|
2331
|
+
function validateCardDetails() {
|
|
2332
|
+
if (cardDetails.number !== TEST_CARD)
|
|
2333
|
+
throw new Error("Only the card number 4242 4242 4242 4242 will be accepted.");
|
|
2334
|
+
if (!isValidExpiry(cardDetails.expiry))
|
|
2335
|
+
throw new Error("Invalid expiry date");
|
|
2336
|
+
if (isCardExpired(cardDetails.expiry))
|
|
2337
|
+
throw new Error("Card is expired");
|
|
2338
|
+
if (cardDetails.cvc.length !== 3)
|
|
2339
|
+
throw new Error("Invalid CVC");
|
|
2340
|
+
}
|
|
2338
2341
|
var onCardNumberChange = function (number) {
|
|
2339
2342
|
setCardDetails(__assign(__assign({}, cardDetails), { number: number }));
|
|
2340
2343
|
};
|
|
@@ -2786,7 +2789,7 @@ var PaymentForm = function (_a) {
|
|
|
2786
2789
|
return (jsxRuntime.jsx(ActualPaymentForm, { invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, quote: quote, setIsSaving: setIsSaving }));
|
|
2787
2790
|
};
|
|
2788
2791
|
|
|
2789
|
-
var MUTATION$
|
|
2792
|
+
var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
|
|
2790
2793
|
var checkout = function (_a) {
|
|
2791
2794
|
var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, subdomain = _a.subdomain;
|
|
2792
2795
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2803,7 +2806,7 @@ var checkout = function (_a) {
|
|
|
2803
2806
|
mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
|
|
2804
2807
|
}
|
|
2805
2808
|
return [4 /*yield*/, common.gqlRequest({
|
|
2806
|
-
query: MUTATION$
|
|
2809
|
+
query: MUTATION$8,
|
|
2807
2810
|
token: token,
|
|
2808
2811
|
vars: mutationVars,
|
|
2809
2812
|
subdomain: subdomain,
|
|
@@ -2940,7 +2943,7 @@ function InvoicePDF(_a) {
|
|
|
2940
2943
|
}, title: "Invoice PDF", width: "100%" }));
|
|
2941
2944
|
}
|
|
2942
2945
|
|
|
2943
|
-
var MUTATION$
|
|
2946
|
+
var MUTATION$7 = "\nquery FormattedInvoice($id: ID) {\n formattedInvoice(id: $id) {\n amount\n amountDue\n amountPaid\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n createdAt\n credits\n currency\n currencyId\n currencySymbol\n customerBillingCity\n customerBillingContact\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n dueAt\n html\n id\n isLegacy\n netPaymentDays\n number\n payableId\n poNumber\n printedState\n smallUnitAmountDue\n state\n subscriptionEndDate\n subscriptionStartDate\n subtotal\n taxAmount\n taxNumber\n uuid\n vendorName\n formattedLines {\n amount\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n lineText\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListName\n prorationRate\n quantity\n unitOfMeasure\n priceTiers {\n price\n starts\n }\n }\n }\n}";
|
|
2944
2947
|
var getFormattedInvoice = function (_a) {
|
|
2945
2948
|
var id = _a.id, token = _a.token, subdomain = _a.subdomain;
|
|
2946
2949
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2950,7 +2953,7 @@ var getFormattedInvoice = function (_a) {
|
|
|
2950
2953
|
case 0:
|
|
2951
2954
|
vars = { id: id };
|
|
2952
2955
|
return [4 /*yield*/, common.gqlRequest({
|
|
2953
|
-
query: MUTATION$
|
|
2956
|
+
query: MUTATION$7,
|
|
2954
2957
|
token: token,
|
|
2955
2958
|
vars: vars,
|
|
2956
2959
|
subdomain: subdomain,
|
|
@@ -3244,7 +3247,7 @@ var PandadocPollingModal = function (_a) {
|
|
|
3244
3247
|
return (jsxRuntime.jsxs(antd.Modal, __assign({ title: "Uploading quote to Pandadoc", open: isVisible, closable: false, footer: null }, { children: [jsxRuntime.jsxs("div", __assign({ className: "py-4 text-center" }, { children: ["This may take a few seconds", ".".repeat(numberOfPolls)] })), jsxRuntime.jsx("div", __assign({ className: "text-center" }, { children: infoMessage }))] })));
|
|
3245
3248
|
};
|
|
3246
3249
|
|
|
3247
|
-
var MUTATION$
|
|
3250
|
+
var MUTATION$6 = "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n object { documents { id filename size date url } }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }";
|
|
3248
3251
|
var getFormattedQuote = function (_a) {
|
|
3249
3252
|
var id = _a.id, token = _a.token, subdomain = _a.subdomain;
|
|
3250
3253
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3254,7 +3257,7 @@ var getFormattedQuote = function (_a) {
|
|
|
3254
3257
|
case 0:
|
|
3255
3258
|
vars = { id: id };
|
|
3256
3259
|
return [4 /*yield*/, common.gqlRequest({
|
|
3257
|
-
query: MUTATION$
|
|
3260
|
+
query: MUTATION$6,
|
|
3258
3261
|
token: token,
|
|
3259
3262
|
vars: vars,
|
|
3260
3263
|
subdomain: subdomain,
|
|
@@ -3447,7 +3450,7 @@ function PaymentMethod(_a) {
|
|
|
3447
3450
|
return (jsxRuntime.jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer, processPublicUrl: processPublicUrl } }, { children: jsxRuntime.jsx(ActualPaymentMethod, {}) })));
|
|
3448
3451
|
}
|
|
3449
3452
|
|
|
3450
|
-
var MUTATION$
|
|
3453
|
+
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";
|
|
3451
3454
|
var accountUpdate = function (_a) {
|
|
3452
3455
|
var accountId = _a.accountId, attributes = _a.attributes, token = _a.token;
|
|
3453
3456
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3457,7 +3460,7 @@ var accountUpdate = function (_a) {
|
|
|
3457
3460
|
switch (_c.label) {
|
|
3458
3461
|
case 0:
|
|
3459
3462
|
vars = { id: accountId, attributes: attributes };
|
|
3460
|
-
return [4 /*yield*/, common.gqlRequest({ query: MUTATION$
|
|
3463
|
+
return [4 /*yield*/, common.gqlRequest({ query: MUTATION$5, token: token, vars: vars })];
|
|
3461
3464
|
case 1:
|
|
3462
3465
|
response = _c.sent();
|
|
3463
3466
|
errors = (_b = response === null || response === void 0 ? void 0 : response.accountUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
@@ -3725,7 +3728,7 @@ var Checkout = function (_a) {
|
|
|
3725
3728
|
}, setIsSaving: setIsSaving }))] }))] })) })));
|
|
3726
3729
|
};
|
|
3727
3730
|
|
|
3728
|
-
var MUTATION$
|
|
3731
|
+
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}"; };
|
|
3729
3732
|
var accountSignup = function (_a) {
|
|
3730
3733
|
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;
|
|
3731
3734
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3744,7 +3747,7 @@ var accountSignup = function (_a) {
|
|
|
3744
3747
|
priceListCode: priceListCode,
|
|
3745
3748
|
};
|
|
3746
3749
|
return [4 /*yield*/, common.gqlRequest({
|
|
3747
|
-
query: MUTATION$
|
|
3750
|
+
query: MUTATION$4(),
|
|
3748
3751
|
token: token,
|
|
3749
3752
|
vars: vars,
|
|
3750
3753
|
subdomain: subdomain,
|
|
@@ -3760,7 +3763,7 @@ var accountSignup = function (_a) {
|
|
|
3760
3763
|
});
|
|
3761
3764
|
};
|
|
3762
3765
|
|
|
3763
|
-
var MUTATION$
|
|
3766
|
+
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}"; };
|
|
3764
3767
|
var quoteAccountSignup = function (_a) {
|
|
3765
3768
|
var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
|
|
3766
3769
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3776,7 +3779,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3776
3779
|
billingContact: billingContact,
|
|
3777
3780
|
};
|
|
3778
3781
|
return [4 /*yield*/, common.gqlRequest({
|
|
3779
|
-
query: MUTATION$
|
|
3782
|
+
query: MUTATION$3(),
|
|
3780
3783
|
token: token,
|
|
3781
3784
|
vars: vars,
|
|
3782
3785
|
subdomain: subdomain,
|
|
@@ -3792,7 +3795,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3792
3795
|
});
|
|
3793
3796
|
};
|
|
3794
3797
|
|
|
3795
|
-
var MUTATION$
|
|
3798
|
+
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}"; };
|
|
3796
3799
|
var getPriceList = function (_a) {
|
|
3797
3800
|
var token = _a.token, code = _a.code, subdomain = _a.subdomain;
|
|
3798
3801
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3800,7 +3803,7 @@ var getPriceList = function (_a) {
|
|
|
3800
3803
|
return __generator(this, function (_b) {
|
|
3801
3804
|
switch (_b.label) {
|
|
3802
3805
|
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
3803
|
-
query: MUTATION$
|
|
3806
|
+
query: MUTATION$2(),
|
|
3804
3807
|
token: token,
|
|
3805
3808
|
vars: { code: code },
|
|
3806
3809
|
subdomain: subdomain,
|
|
@@ -3814,10 +3817,8 @@ var getPriceList = function (_a) {
|
|
|
3814
3817
|
};
|
|
3815
3818
|
|
|
3816
3819
|
function PaymentForms(_a) {
|
|
3817
|
-
var quote = _a.quote, paying = _a.paying, setIsPaying = _a.setIsPaying, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId;
|
|
3818
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: accountId && (jsxRuntime.jsx(PaymentContext.Provider, __assign({ value: { accountId: accountId, displayPayButtonNameAnyways: true } }, { children: jsxRuntime.jsx(PaymentForm, { isSaving: paying, setIsSaving: setIsPaying, onFail:
|
|
3819
|
-
console.log("payment saving failed darn");
|
|
3820
|
-
}, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsxRuntime.jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
|
|
3820
|
+
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;
|
|
3821
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: quote ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: accountId && (jsxRuntime.jsx(PaymentContext.Provider, __assign({ value: { accountId: accountId, displayPayButtonNameAnyways: true } }, { children: jsxRuntime.jsx(PaymentForm, { isSaving: paying, setIsSaving: setIsPaying, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsxRuntime.jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
|
|
3821
3822
|
}
|
|
3822
3823
|
function InitialSignupForm(_a) {
|
|
3823
3824
|
var onSubmit = _a.onSubmit, submitting = _a.submitting;
|
|
@@ -3854,10 +3855,10 @@ function InitialSignupForm(_a) {
|
|
|
3854
3855
|
|
|
3855
3856
|
var Title = antd.Typography.Title, Text$a = antd.Typography.Text;
|
|
3856
3857
|
function PaymentSuccessDisplay(_a) {
|
|
3857
|
-
var className = _a.className, amountPaid = _a.amountPaid, style = _a.style,
|
|
3858
|
+
var className = _a.className, amountPaid = _a.amountPaid, style = _a.style, returnUrl = _a.returnUrl;
|
|
3858
3859
|
var window = React.useContext(BunnyContext).window;
|
|
3859
3860
|
var companyName = common.useCurrentUserData().companyName;
|
|
3860
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsxRuntime.jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxRuntime.jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", common.Misc.formatCurrency(amountPaid, "USD"), " successful"] })),
|
|
3861
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsxRuntime.jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxRuntime.jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", common.Misc.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxRuntime.jsxs(Text$a, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
|
|
3861
3862
|
}
|
|
3862
3863
|
|
|
3863
3864
|
var Text$9 = antd.Typography.Text;
|
|
@@ -3894,8 +3895,34 @@ var StyedLink = styled__default["default"].a(templateObject_1$4 || (templateObje
|
|
|
3894
3895
|
var StyledBunnyLink = styled__default["default"](StyedLink)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), common.PRIMARY_COLOR);
|
|
3895
3896
|
var templateObject_1$4, templateObject_2;
|
|
3896
3897
|
|
|
3898
|
+
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";
|
|
3899
|
+
var portalSessionCreate = function (_a) {
|
|
3900
|
+
var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, subdomain = _a.subdomain;
|
|
3901
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
3902
|
+
var response, errors;
|
|
3903
|
+
var _b;
|
|
3904
|
+
return __generator(this, function (_c) {
|
|
3905
|
+
switch (_c.label) {
|
|
3906
|
+
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
3907
|
+
query: MUTATION$1,
|
|
3908
|
+
token: token,
|
|
3909
|
+
vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
|
|
3910
|
+
subdomain: subdomain,
|
|
3911
|
+
})];
|
|
3912
|
+
case 1:
|
|
3913
|
+
response = _c.sent();
|
|
3914
|
+
errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
|
|
3915
|
+
if (errors)
|
|
3916
|
+
throw errors;
|
|
3917
|
+
return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
|
|
3918
|
+
}
|
|
3919
|
+
});
|
|
3920
|
+
});
|
|
3921
|
+
};
|
|
3922
|
+
|
|
3923
|
+
var showErrorNotification = common.NotificationUtils.useErrorNotification();
|
|
3897
3924
|
function Signup(_a) {
|
|
3898
|
-
var priceListCode = _a.priceListCode,
|
|
3925
|
+
var priceListCode = _a.priceListCode, returnUrl = _a.returnUrl;
|
|
3899
3926
|
// Hooks
|
|
3900
3927
|
var _b = React.useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token, window = _b.window;
|
|
3901
3928
|
reactQuery.useQuery({
|
|
@@ -3908,10 +3935,11 @@ function Signup(_a) {
|
|
|
3908
3935
|
var _c = React.useState(undefined), quote = _c[0], setQuote = _c[1];
|
|
3909
3936
|
var _d = React.useState(undefined), accountId = _d[0], setAccountId = _d[1];
|
|
3910
3937
|
var _e = React.useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
|
|
3911
|
-
var _f = React.useState(undefined),
|
|
3912
|
-
var _g = React.useState(
|
|
3913
|
-
var _h = React.useState(false),
|
|
3914
|
-
var _j = React.useState(false),
|
|
3938
|
+
var _f = React.useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
|
|
3939
|
+
var _g = React.useState(undefined), formData = _g[0], setFormData = _g[1];
|
|
3940
|
+
var _h = React.useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
|
|
3941
|
+
var _j = React.useState(false), paying = _j[0], setIsPaying = _j[1];
|
|
3942
|
+
var _k = React.useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
|
|
3915
3943
|
// Queries
|
|
3916
3944
|
var priceListData = reactQuery.useQuery({
|
|
3917
3945
|
queryKey: ["priceList", priceListCode],
|
|
@@ -3919,7 +3947,7 @@ function Signup(_a) {
|
|
|
3919
3947
|
}).data;
|
|
3920
3948
|
function handleSubmit(formData) {
|
|
3921
3949
|
return __awaiter(this, void 0, void 0, function () {
|
|
3922
|
-
var data;
|
|
3950
|
+
var data, portalSessionToken;
|
|
3923
3951
|
return __generator(this, function (_a) {
|
|
3924
3952
|
switch (_a.label) {
|
|
3925
3953
|
case 0:
|
|
@@ -3940,11 +3968,21 @@ function Signup(_a) {
|
|
|
3940
3968
|
case 1:
|
|
3941
3969
|
data = _a.sent();
|
|
3942
3970
|
setAccountId(data.account.id);
|
|
3943
|
-
|
|
3971
|
+
return [4 /*yield*/, portalSessionCreate({
|
|
3972
|
+
token: token,
|
|
3973
|
+
subdomain: subdomain,
|
|
3974
|
+
tenantCode: data.tenant.code,
|
|
3975
|
+
expiry: 24,
|
|
3976
|
+
returnUrl: returnUrl || "",
|
|
3977
|
+
})];
|
|
3978
|
+
case 2:
|
|
3979
|
+
portalSessionToken = _a.sent();
|
|
3980
|
+
setPortalSessionToken(portalSessionToken);
|
|
3981
|
+
setQuoteId(data.quote.id);
|
|
3944
3982
|
setProceedingToPayment(false);
|
|
3945
3983
|
setQuote({
|
|
3946
|
-
amountDue: data.
|
|
3947
|
-
currencyId: data.currencyId,
|
|
3984
|
+
amountDue: data.quote.amountDue,
|
|
3985
|
+
currencyId: data.quote.currencyId,
|
|
3948
3986
|
});
|
|
3949
3987
|
return [2 /*return*/];
|
|
3950
3988
|
}
|
|
@@ -3969,8 +4007,11 @@ function Signup(_a) {
|
|
|
3969
4007
|
if (!accountId) {
|
|
3970
4008
|
throw new Error("Account ID is required");
|
|
3971
4009
|
}
|
|
4010
|
+
if (!portalSessionToken) {
|
|
4011
|
+
throw new Error("Portal session token is required");
|
|
4012
|
+
}
|
|
3972
4013
|
return [4 /*yield*/, accountSignup({
|
|
3973
|
-
token:
|
|
4014
|
+
token: portalSessionToken,
|
|
3974
4015
|
subdomain: subdomain,
|
|
3975
4016
|
entityId: entityId,
|
|
3976
4017
|
quoteId: quoteId,
|
|
@@ -3988,11 +4029,15 @@ function Signup(_a) {
|
|
|
3988
4029
|
});
|
|
3989
4030
|
});
|
|
3990
4031
|
}
|
|
4032
|
+
function handlePaymentFail(error) {
|
|
4033
|
+
showErrorNotification(error.message);
|
|
4034
|
+
setIsPaying(false);
|
|
4035
|
+
}
|
|
3991
4036
|
if (isMobile) {
|
|
3992
|
-
return (jsxRuntime.jsx(Card, __assign({ className: "p-4 flex flex-col" }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0,
|
|
4037
|
+
return (jsxRuntime.jsx(Card, __assign({ className: "p-4 flex flex-col" }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, returnUrl: returnUrl })) : (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-col items-center" }, { children: jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsxRuntime.jsx("div", __assign({ className: "mx-8" }, { children: jsxRuntime.jsx(antd.Divider, { className: "h-full" }) })), jsxRuntime.jsx("div", __assign({ className: "flex items-center justify-center my-12" }, { children: jsxRuntime.jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })));
|
|
3993
4038
|
}
|
|
3994
4039
|
else {
|
|
3995
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0,
|
|
4040
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsxRuntime.jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, returnUrl: returnUrl })) : (jsxRuntime.jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex flex-col w-1/2 items-center" }, { children: jsxRuntime.jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsxRuntime.jsx("div", __assign({ className: "my-4" }, { children: jsxRuntime.jsx(antd.Divider, { className: "h-full", type: "vertical" }) })), jsxRuntime.jsx("div", __assign({ className: "flex w-1/2 items-center justify-center my-12" }, { children: jsxRuntime.jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })), jsxRuntime.jsx(Footer, {})] }));
|
|
3996
4041
|
}
|
|
3997
4042
|
}
|
|
3998
4043
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import "../../styles/index.less";
|
|
2
2
|
import { Quote } from "@bunnyapp/common";
|
|
3
3
|
import { OnPaymentSuccessType } from "../PaymentForm/PaymentFormTypes";
|
|
4
|
-
export default function PaymentForms({ quote, paying, setIsPaying, handlePaymentSaveSuccess, handleSubmit, proceedingToPayment, accountId, }: {
|
|
4
|
+
export default function PaymentForms({ quote, paying, setIsPaying, handlePaymentSaveSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, }: {
|
|
5
5
|
quote?: Quote;
|
|
6
6
|
paying: boolean;
|
|
7
7
|
setIsPaying: (paying: boolean) => void;
|
|
8
8
|
handlePaymentSaveSuccess: (paymentSuccess: OnPaymentSuccessType) => void;
|
|
9
|
+
handlePaymentFail: (error: any) => void;
|
|
9
10
|
handleSubmit: (formData: FormData) => void;
|
|
10
11
|
proceedingToPayment: boolean;
|
|
11
12
|
accountId?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function PaymentSuccessDisplay({ className, amountPaid, style,
|
|
2
|
+
export default function PaymentSuccessDisplay({ className, amountPaid, style, returnUrl, }: {
|
|
3
3
|
className: string;
|
|
4
4
|
amountPaid: number;
|
|
5
5
|
style?: React.CSSProperties;
|
|
6
|
-
|
|
6
|
+
returnUrl?: string;
|
|
7
7
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../styles/index.less";
|
|
2
|
-
export default function Signup({ priceListCode,
|
|
2
|
+
export default function Signup({ priceListCode, returnUrl, }: {
|
|
3
3
|
priceListCode: string;
|
|
4
|
-
|
|
4
|
+
returnUrl?: string;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/index.js
CHANGED
|
@@ -1521,14 +1521,14 @@ var BrandContext = createContext({
|
|
|
1521
1521
|
topNavImageUrl: DEFAULT_TOP_NAV_IMAGE_URL,
|
|
1522
1522
|
});
|
|
1523
1523
|
|
|
1524
|
-
var MUTATION$
|
|
1524
|
+
var MUTATION$9 = "{\n entityBranding {\n accentColor\n brandColor\n topNavImageUrl\n }\n }";
|
|
1525
1525
|
var getBranding = function (_a) {
|
|
1526
1526
|
var token = _a.token, subdomain = _a.subdomain;
|
|
1527
1527
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
1528
1528
|
var response;
|
|
1529
1529
|
return __generator(this, function (_b) {
|
|
1530
1530
|
switch (_b.label) {
|
|
1531
|
-
case 0: return [4 /*yield*/, gqlRequest({ query: MUTATION$
|
|
1531
|
+
case 0: return [4 /*yield*/, gqlRequest({ query: MUTATION$9, token: token, subdomain: subdomain })];
|
|
1532
1532
|
case 1:
|
|
1533
1533
|
response = _b.sent();
|
|
1534
1534
|
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.entityBranding];
|
|
@@ -2243,6 +2243,7 @@ var DemoPayForm = function (_a) {
|
|
|
2243
2243
|
switch (_a.label) {
|
|
2244
2244
|
case 0:
|
|
2245
2245
|
_a.trys.push([0, 6, , 7]);
|
|
2246
|
+
validateCardDetails();
|
|
2246
2247
|
if (!onlySavePaymentMethod) return [3 /*break*/, 2];
|
|
2247
2248
|
setIsSaving(true);
|
|
2248
2249
|
return [4 /*yield*/, storePayment({
|
|
@@ -2270,14 +2271,6 @@ var DemoPayForm = function (_a) {
|
|
|
2270
2271
|
case 2:
|
|
2271
2272
|
if (!(amountDue !== undefined && currencyId)) return [3 /*break*/, 4];
|
|
2272
2273
|
setIsSaving(true);
|
|
2273
|
-
if (cardDetails.number !== TEST_CARD)
|
|
2274
|
-
throw new Error("Only the card number 4242 4242 4242 4242 will be accepted.");
|
|
2275
|
-
if (!isValidExpiry(cardDetails.expiry))
|
|
2276
|
-
throw new Error("Invalid expiry date");
|
|
2277
|
-
if (isCardExpired(cardDetails.expiry))
|
|
2278
|
-
throw new Error("Card is expired");
|
|
2279
|
-
if (cardDetails.cvc.length !== 3)
|
|
2280
|
-
throw new Error("Invalid CVC");
|
|
2281
2274
|
return [4 /*yield*/, confirmPayment({
|
|
2282
2275
|
amount: amountDue,
|
|
2283
2276
|
currency: currencyId,
|
|
@@ -2306,6 +2299,16 @@ var DemoPayForm = function (_a) {
|
|
|
2306
2299
|
}
|
|
2307
2300
|
});
|
|
2308
2301
|
}); };
|
|
2302
|
+
function validateCardDetails() {
|
|
2303
|
+
if (cardDetails.number !== TEST_CARD)
|
|
2304
|
+
throw new Error("Only the card number 4242 4242 4242 4242 will be accepted.");
|
|
2305
|
+
if (!isValidExpiry(cardDetails.expiry))
|
|
2306
|
+
throw new Error("Invalid expiry date");
|
|
2307
|
+
if (isCardExpired(cardDetails.expiry))
|
|
2308
|
+
throw new Error("Card is expired");
|
|
2309
|
+
if (cardDetails.cvc.length !== 3)
|
|
2310
|
+
throw new Error("Invalid CVC");
|
|
2311
|
+
}
|
|
2309
2312
|
var onCardNumberChange = function (number) {
|
|
2310
2313
|
setCardDetails(__assign(__assign({}, cardDetails), { number: number }));
|
|
2311
2314
|
};
|
|
@@ -2757,7 +2760,7 @@ var PaymentForm = function (_a) {
|
|
|
2757
2760
|
return (jsx(ActualPaymentForm, { invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, quote: quote, setIsSaving: setIsSaving }));
|
|
2758
2761
|
};
|
|
2759
2762
|
|
|
2760
|
-
var MUTATION$
|
|
2763
|
+
var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
|
|
2761
2764
|
var checkout = function (_a) {
|
|
2762
2765
|
var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, subdomain = _a.subdomain;
|
|
2763
2766
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2774,7 +2777,7 @@ var checkout = function (_a) {
|
|
|
2774
2777
|
mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
|
|
2775
2778
|
}
|
|
2776
2779
|
return [4 /*yield*/, gqlRequest({
|
|
2777
|
-
query: MUTATION$
|
|
2780
|
+
query: MUTATION$8,
|
|
2778
2781
|
token: token,
|
|
2779
2782
|
vars: mutationVars,
|
|
2780
2783
|
subdomain: subdomain,
|
|
@@ -2911,7 +2914,7 @@ function InvoicePDF(_a) {
|
|
|
2911
2914
|
}, title: "Invoice PDF", width: "100%" }));
|
|
2912
2915
|
}
|
|
2913
2916
|
|
|
2914
|
-
var MUTATION$
|
|
2917
|
+
var MUTATION$7 = "\nquery FormattedInvoice($id: ID) {\n formattedInvoice(id: $id) {\n amount\n amountDue\n amountPaid\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n createdAt\n credits\n currency\n currencyId\n currencySymbol\n customerBillingCity\n customerBillingContact\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n dueAt\n html\n id\n isLegacy\n netPaymentDays\n number\n payableId\n poNumber\n printedState\n smallUnitAmountDue\n state\n subscriptionEndDate\n subscriptionStartDate\n subtotal\n taxAmount\n taxNumber\n uuid\n vendorName\n formattedLines {\n amount\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n lineText\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListName\n prorationRate\n quantity\n unitOfMeasure\n priceTiers {\n price\n starts\n }\n }\n }\n}";
|
|
2915
2918
|
var getFormattedInvoice = function (_a) {
|
|
2916
2919
|
var id = _a.id, token = _a.token, subdomain = _a.subdomain;
|
|
2917
2920
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -2921,7 +2924,7 @@ var getFormattedInvoice = function (_a) {
|
|
|
2921
2924
|
case 0:
|
|
2922
2925
|
vars = { id: id };
|
|
2923
2926
|
return [4 /*yield*/, gqlRequest({
|
|
2924
|
-
query: MUTATION$
|
|
2927
|
+
query: MUTATION$7,
|
|
2925
2928
|
token: token,
|
|
2926
2929
|
vars: vars,
|
|
2927
2930
|
subdomain: subdomain,
|
|
@@ -3215,7 +3218,7 @@ var PandadocPollingModal = function (_a) {
|
|
|
3215
3218
|
return (jsxs(Modal, __assign({ title: "Uploading quote to Pandadoc", open: isVisible, closable: false, footer: null }, { children: [jsxs("div", __assign({ className: "py-4 text-center" }, { children: ["This may take a few seconds", ".".repeat(numberOfPolls)] })), jsx("div", __assign({ className: "text-center" }, { children: infoMessage }))] })));
|
|
3216
3219
|
};
|
|
3217
3220
|
|
|
3218
|
-
var MUTATION$
|
|
3221
|
+
var MUTATION$6 = "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n object { documents { id filename size date url } }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }";
|
|
3219
3222
|
var getFormattedQuote = function (_a) {
|
|
3220
3223
|
var id = _a.id, token = _a.token, subdomain = _a.subdomain;
|
|
3221
3224
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3225,7 +3228,7 @@ var getFormattedQuote = function (_a) {
|
|
|
3225
3228
|
case 0:
|
|
3226
3229
|
vars = { id: id };
|
|
3227
3230
|
return [4 /*yield*/, gqlRequest({
|
|
3228
|
-
query: MUTATION$
|
|
3231
|
+
query: MUTATION$6,
|
|
3229
3232
|
token: token,
|
|
3230
3233
|
vars: vars,
|
|
3231
3234
|
subdomain: subdomain,
|
|
@@ -3418,7 +3421,7 @@ function PaymentMethod(_a) {
|
|
|
3418
3421
|
return (jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer, processPublicUrl: processPublicUrl } }, { children: jsx(ActualPaymentMethod, {}) })));
|
|
3419
3422
|
}
|
|
3420
3423
|
|
|
3421
|
-
var MUTATION$
|
|
3424
|
+
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";
|
|
3422
3425
|
var accountUpdate = function (_a) {
|
|
3423
3426
|
var accountId = _a.accountId, attributes = _a.attributes, token = _a.token;
|
|
3424
3427
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3428,7 +3431,7 @@ var accountUpdate = function (_a) {
|
|
|
3428
3431
|
switch (_c.label) {
|
|
3429
3432
|
case 0:
|
|
3430
3433
|
vars = { id: accountId, attributes: attributes };
|
|
3431
|
-
return [4 /*yield*/, gqlRequest({ query: MUTATION$
|
|
3434
|
+
return [4 /*yield*/, gqlRequest({ query: MUTATION$5, token: token, vars: vars })];
|
|
3432
3435
|
case 1:
|
|
3433
3436
|
response = _c.sent();
|
|
3434
3437
|
errors = (_b = response === null || response === void 0 ? void 0 : response.accountUpdate) === null || _b === void 0 ? void 0 : _b.errors;
|
|
@@ -3696,7 +3699,7 @@ var Checkout = function (_a) {
|
|
|
3696
3699
|
}, setIsSaving: setIsSaving }))] }))] })) })));
|
|
3697
3700
|
};
|
|
3698
3701
|
|
|
3699
|
-
var MUTATION$
|
|
3702
|
+
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}"; };
|
|
3700
3703
|
var accountSignup = function (_a) {
|
|
3701
3704
|
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;
|
|
3702
3705
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3715,7 +3718,7 @@ var accountSignup = function (_a) {
|
|
|
3715
3718
|
priceListCode: priceListCode,
|
|
3716
3719
|
};
|
|
3717
3720
|
return [4 /*yield*/, gqlRequest({
|
|
3718
|
-
query: MUTATION$
|
|
3721
|
+
query: MUTATION$4(),
|
|
3719
3722
|
token: token,
|
|
3720
3723
|
vars: vars,
|
|
3721
3724
|
subdomain: subdomain,
|
|
@@ -3731,7 +3734,7 @@ var accountSignup = function (_a) {
|
|
|
3731
3734
|
});
|
|
3732
3735
|
};
|
|
3733
3736
|
|
|
3734
|
-
var MUTATION$
|
|
3737
|
+
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}"; };
|
|
3735
3738
|
var quoteAccountSignup = function (_a) {
|
|
3736
3739
|
var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
|
|
3737
3740
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3747,7 +3750,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3747
3750
|
billingContact: billingContact,
|
|
3748
3751
|
};
|
|
3749
3752
|
return [4 /*yield*/, gqlRequest({
|
|
3750
|
-
query: MUTATION$
|
|
3753
|
+
query: MUTATION$3(),
|
|
3751
3754
|
token: token,
|
|
3752
3755
|
vars: vars,
|
|
3753
3756
|
subdomain: subdomain,
|
|
@@ -3763,7 +3766,7 @@ var quoteAccountSignup = function (_a) {
|
|
|
3763
3766
|
});
|
|
3764
3767
|
};
|
|
3765
3768
|
|
|
3766
|
-
var MUTATION$
|
|
3769
|
+
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}"; };
|
|
3767
3770
|
var getPriceList = function (_a) {
|
|
3768
3771
|
var token = _a.token, code = _a.code, subdomain = _a.subdomain;
|
|
3769
3772
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3771,7 +3774,7 @@ var getPriceList = function (_a) {
|
|
|
3771
3774
|
return __generator(this, function (_b) {
|
|
3772
3775
|
switch (_b.label) {
|
|
3773
3776
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
3774
|
-
query: MUTATION$
|
|
3777
|
+
query: MUTATION$2(),
|
|
3775
3778
|
token: token,
|
|
3776
3779
|
vars: { code: code },
|
|
3777
3780
|
subdomain: subdomain,
|
|
@@ -3785,10 +3788,8 @@ var getPriceList = function (_a) {
|
|
|
3785
3788
|
};
|
|
3786
3789
|
|
|
3787
3790
|
function PaymentForms(_a) {
|
|
3788
|
-
var quote = _a.quote, paying = _a.paying, setIsPaying = _a.setIsPaying, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId;
|
|
3789
|
-
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:
|
|
3790
|
-
console.log("payment saving failed darn");
|
|
3791
|
-
}, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
|
|
3791
|
+
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;
|
|
3792
|
+
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 })) }));
|
|
3792
3793
|
}
|
|
3793
3794
|
function InitialSignupForm(_a) {
|
|
3794
3795
|
var onSubmit = _a.onSubmit, submitting = _a.submitting;
|
|
@@ -3825,10 +3826,10 @@ function InitialSignupForm(_a) {
|
|
|
3825
3826
|
|
|
3826
3827
|
var Title = Typography.Title, Text$a = Typography.Text;
|
|
3827
3828
|
function PaymentSuccessDisplay(_a) {
|
|
3828
|
-
var className = _a.className, amountPaid = _a.amountPaid, style = _a.style,
|
|
3829
|
+
var className = _a.className, amountPaid = _a.amountPaid, style = _a.style, returnUrl = _a.returnUrl;
|
|
3829
3830
|
var window = useContext(BunnyContext).window;
|
|
3830
3831
|
var companyName = useCurrentUserData().companyName;
|
|
3831
|
-
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"] })),
|
|
3832
|
+
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$a, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
|
|
3832
3833
|
}
|
|
3833
3834
|
|
|
3834
3835
|
var Text$9 = Typography.Text;
|
|
@@ -3865,8 +3866,34 @@ var StyedLink = styled.a(templateObject_1$4 || (templateObject_1$4 = __makeTempl
|
|
|
3865
3866
|
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);
|
|
3866
3867
|
var templateObject_1$4, templateObject_2;
|
|
3867
3868
|
|
|
3869
|
+
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";
|
|
3870
|
+
var portalSessionCreate = function (_a) {
|
|
3871
|
+
var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, subdomain = _a.subdomain;
|
|
3872
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
3873
|
+
var response, errors;
|
|
3874
|
+
var _b;
|
|
3875
|
+
return __generator(this, function (_c) {
|
|
3876
|
+
switch (_c.label) {
|
|
3877
|
+
case 0: return [4 /*yield*/, gqlRequest({
|
|
3878
|
+
query: MUTATION$1,
|
|
3879
|
+
token: token,
|
|
3880
|
+
vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
|
|
3881
|
+
subdomain: subdomain,
|
|
3882
|
+
})];
|
|
3883
|
+
case 1:
|
|
3884
|
+
response = _c.sent();
|
|
3885
|
+
errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
|
|
3886
|
+
if (errors)
|
|
3887
|
+
throw errors;
|
|
3888
|
+
return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
|
|
3889
|
+
}
|
|
3890
|
+
});
|
|
3891
|
+
});
|
|
3892
|
+
};
|
|
3893
|
+
|
|
3894
|
+
var showErrorNotification = NotificationUtils.useErrorNotification();
|
|
3868
3895
|
function Signup(_a) {
|
|
3869
|
-
var priceListCode = _a.priceListCode,
|
|
3896
|
+
var priceListCode = _a.priceListCode, returnUrl = _a.returnUrl;
|
|
3870
3897
|
// Hooks
|
|
3871
3898
|
var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token, window = _b.window;
|
|
3872
3899
|
useQuery({
|
|
@@ -3879,10 +3906,11 @@ function Signup(_a) {
|
|
|
3879
3906
|
var _c = useState(undefined), quote = _c[0], setQuote = _c[1];
|
|
3880
3907
|
var _d = useState(undefined), accountId = _d[0], setAccountId = _d[1];
|
|
3881
3908
|
var _e = useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
|
|
3882
|
-
var _f = useState(undefined),
|
|
3883
|
-
var _g = useState(
|
|
3884
|
-
var _h = useState(false),
|
|
3885
|
-
var _j = useState(false),
|
|
3909
|
+
var _f = useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
|
|
3910
|
+
var _g = useState(undefined), formData = _g[0], setFormData = _g[1];
|
|
3911
|
+
var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
|
|
3912
|
+
var _j = useState(false), paying = _j[0], setIsPaying = _j[1];
|
|
3913
|
+
var _k = useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
|
|
3886
3914
|
// Queries
|
|
3887
3915
|
var priceListData = useQuery({
|
|
3888
3916
|
queryKey: ["priceList", priceListCode],
|
|
@@ -3890,7 +3918,7 @@ function Signup(_a) {
|
|
|
3890
3918
|
}).data;
|
|
3891
3919
|
function handleSubmit(formData) {
|
|
3892
3920
|
return __awaiter(this, void 0, void 0, function () {
|
|
3893
|
-
var data;
|
|
3921
|
+
var data, portalSessionToken;
|
|
3894
3922
|
return __generator(this, function (_a) {
|
|
3895
3923
|
switch (_a.label) {
|
|
3896
3924
|
case 0:
|
|
@@ -3911,11 +3939,21 @@ function Signup(_a) {
|
|
|
3911
3939
|
case 1:
|
|
3912
3940
|
data = _a.sent();
|
|
3913
3941
|
setAccountId(data.account.id);
|
|
3914
|
-
|
|
3942
|
+
return [4 /*yield*/, portalSessionCreate({
|
|
3943
|
+
token: token,
|
|
3944
|
+
subdomain: subdomain,
|
|
3945
|
+
tenantCode: data.tenant.code,
|
|
3946
|
+
expiry: 24,
|
|
3947
|
+
returnUrl: returnUrl || "",
|
|
3948
|
+
})];
|
|
3949
|
+
case 2:
|
|
3950
|
+
portalSessionToken = _a.sent();
|
|
3951
|
+
setPortalSessionToken(portalSessionToken);
|
|
3952
|
+
setQuoteId(data.quote.id);
|
|
3915
3953
|
setProceedingToPayment(false);
|
|
3916
3954
|
setQuote({
|
|
3917
|
-
amountDue: data.
|
|
3918
|
-
currencyId: data.currencyId,
|
|
3955
|
+
amountDue: data.quote.amountDue,
|
|
3956
|
+
currencyId: data.quote.currencyId,
|
|
3919
3957
|
});
|
|
3920
3958
|
return [2 /*return*/];
|
|
3921
3959
|
}
|
|
@@ -3940,8 +3978,11 @@ function Signup(_a) {
|
|
|
3940
3978
|
if (!accountId) {
|
|
3941
3979
|
throw new Error("Account ID is required");
|
|
3942
3980
|
}
|
|
3981
|
+
if (!portalSessionToken) {
|
|
3982
|
+
throw new Error("Portal session token is required");
|
|
3983
|
+
}
|
|
3943
3984
|
return [4 /*yield*/, accountSignup({
|
|
3944
|
-
token:
|
|
3985
|
+
token: portalSessionToken,
|
|
3945
3986
|
subdomain: subdomain,
|
|
3946
3987
|
entityId: entityId,
|
|
3947
3988
|
quoteId: quoteId,
|
|
@@ -3959,11 +4000,15 @@ function Signup(_a) {
|
|
|
3959
4000
|
});
|
|
3960
4001
|
});
|
|
3961
4002
|
}
|
|
4003
|
+
function handlePaymentFail(error) {
|
|
4004
|
+
showErrorNotification(error.message);
|
|
4005
|
+
setIsPaying(false);
|
|
4006
|
+
}
|
|
3962
4007
|
if (isMobile) {
|
|
3963
|
-
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,
|
|
4008
|
+
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 || "" }) }))] }))) })));
|
|
3964
4009
|
}
|
|
3965
4010
|
else {
|
|
3966
|
-
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,
|
|
4011
|
+
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, {})] }));
|
|
3967
4012
|
}
|
|
3968
4013
|
}
|
|
3969
4014
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import "../../styles/index.less";
|
|
2
2
|
import { Quote } from "@bunnyapp/common";
|
|
3
3
|
import { OnPaymentSuccessType } from "../PaymentForm/PaymentFormTypes";
|
|
4
|
-
export default function PaymentForms({ quote, paying, setIsPaying, handlePaymentSaveSuccess, handleSubmit, proceedingToPayment, accountId, }: {
|
|
4
|
+
export default function PaymentForms({ quote, paying, setIsPaying, handlePaymentSaveSuccess, handlePaymentFail, handleSubmit, proceedingToPayment, accountId, }: {
|
|
5
5
|
quote?: Quote;
|
|
6
6
|
paying: boolean;
|
|
7
7
|
setIsPaying: (paying: boolean) => void;
|
|
8
8
|
handlePaymentSaveSuccess: (paymentSuccess: OnPaymentSuccessType) => void;
|
|
9
|
+
handlePaymentFail: (error: any) => void;
|
|
9
10
|
handleSubmit: (formData: FormData) => void;
|
|
10
11
|
proceedingToPayment: boolean;
|
|
11
12
|
accountId?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function PaymentSuccessDisplay({ className, amountPaid, style,
|
|
2
|
+
export default function PaymentSuccessDisplay({ className, amountPaid, style, returnUrl, }: {
|
|
3
3
|
className: string;
|
|
4
4
|
amountPaid: number;
|
|
5
5
|
style?: React.CSSProperties;
|
|
6
|
-
|
|
6
|
+
returnUrl?: string;
|
|
7
7
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../styles/index.less";
|
|
2
|
-
export default function Signup({ priceListCode,
|
|
2
|
+
export default function Signup({ priceListCode, returnUrl, }: {
|
|
3
3
|
priceListCode: string;
|
|
4
|
-
|
|
4
|
+
returnUrl?: string;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,9 +53,9 @@ declare const Checkout: ({ onCancel, onSuccess, onFail, invoice, open, quote, se
|
|
|
53
53
|
|
|
54
54
|
declare const getQuoteAmountDue: (quote: Quote$1) => number;
|
|
55
55
|
|
|
56
|
-
declare function Signup({ priceListCode,
|
|
56
|
+
declare function Signup({ priceListCode, returnUrl, }: {
|
|
57
57
|
priceListCode: string;
|
|
58
|
-
|
|
58
|
+
returnUrl?: string;
|
|
59
59
|
}): react_jsx_runtime.JSX.Element;
|
|
60
60
|
|
|
61
61
|
declare function BunnyProvider({ children, token, subdomain, window, accountId, darkMode, }: {
|
package/package.json
CHANGED