@pelcro/react-pelcro-js 4.0.0-alpha.58 → 4.0.0-alpha.59
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/index.cjs.js +458 -140
- package/dist/index.esm.js +455 -141
- package/dist/pelcro.css +21 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -3669,6 +3669,7 @@ var userEdit_en = {
|
|
|
3669
3669
|
|
|
3670
3670
|
var title$z = "Enter your shipping address";
|
|
3671
3671
|
var titleGifting$3 = "Enter your address";
|
|
3672
|
+
var titleBilling = "Enter your billing address";
|
|
3672
3673
|
var selectAddressTitle$3 = "Please select an address";
|
|
3673
3674
|
var selectAddressSubtitle$3 = "Select one of your saved addresses, or add a new one";
|
|
3674
3675
|
var labels$Y = {
|
|
@@ -3694,6 +3695,7 @@ var messages$$ = {
|
|
|
3694
3695
|
var address_en = {
|
|
3695
3696
|
title: title$z,
|
|
3696
3697
|
titleGifting: titleGifting$3,
|
|
3698
|
+
titleBilling: titleBilling,
|
|
3697
3699
|
selectAddressTitle: selectAddressTitle$3,
|
|
3698
3700
|
selectAddressSubtitle: selectAddressSubtitle$3,
|
|
3699
3701
|
labels: labels$Y,
|
|
@@ -3845,7 +3847,11 @@ var labels$W = {
|
|
|
3845
3847
|
dec: "December"
|
|
3846
3848
|
},
|
|
3847
3849
|
checkout: {
|
|
3848
|
-
title: "Payment Information"
|
|
3850
|
+
title: "Payment Information",
|
|
3851
|
+
billingAddress: "Billing Address",
|
|
3852
|
+
NoBillingAddress: "No Billing Address Found",
|
|
3853
|
+
changeBillingAddress: "Change",
|
|
3854
|
+
addNewAddress: "Add New Address"
|
|
3849
3855
|
}
|
|
3850
3856
|
};
|
|
3851
3857
|
var messages$X = {
|
|
@@ -9404,6 +9410,7 @@ const initialState$p = {
|
|
|
9404
9410
|
isAuthenticated: () => window.Pelcro.user.isAuthenticated(),
|
|
9405
9411
|
selectedPaymentMethodId: null,
|
|
9406
9412
|
selectedAddressId: null,
|
|
9413
|
+
selectedBillingAddressId: null,
|
|
9407
9414
|
addressIdToEdit: null
|
|
9408
9415
|
};
|
|
9409
9416
|
|
|
@@ -9563,17 +9570,6 @@ const userHasAddress = () => {
|
|
|
9563
9570
|
const addresses = (_window$Pelcro$user$r2 = (_window$Pelcro$user$r3 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.addresses) !== null && _window$Pelcro$user$r2 !== void 0 ? _window$Pelcro$user$r2 : [];
|
|
9564
9571
|
return addresses.length > 0;
|
|
9565
9572
|
};
|
|
9566
|
-
/** check wether or not the user have any billing addresses
|
|
9567
|
-
* @return {boolean} true if the user have at least one billing address, false otherwise
|
|
9568
|
-
*/
|
|
9569
|
-
|
|
9570
|
-
const userHasBillingAddress = () => {
|
|
9571
|
-
var _window$Pelcro$user$r4, _window$Pelcro$user$r5;
|
|
9572
|
-
|
|
9573
|
-
const addresses = (_window$Pelcro$user$r4 = (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.addresses) !== null && _window$Pelcro$user$r4 !== void 0 ? _window$Pelcro$user$r4 : [];
|
|
9574
|
-
const billingAddresses = addresses.filter(address => address.type == "billing");
|
|
9575
|
-
return billingAddresses.length > 0;
|
|
9576
|
-
};
|
|
9577
9573
|
const calcAndFormatItemsTotal = (items, currency) => {
|
|
9578
9574
|
if (!Array.isArray(items)) return;
|
|
9579
9575
|
let totalWithoutDividingBy100 = 0;
|
|
@@ -9790,13 +9786,37 @@ const getPaymentCardIcon = name => {
|
|
|
9790
9786
|
d: "M22.255 20l-2.113 4.683L18.039 20h-2.695v6.726L12.341 20h-2.274L7 26.981h1.815l.671-1.558h3.432l.682 1.558h3.465v-5.185l2.299 5.185h1.563l2.351-5.095v5.095H25V20H22.255zM10.135 23.915l1.026-2.44 1.066 2.44H10.135zM37.883 23.413L41 20.018h-2.217l-1.994 2.164L34.86 20H28v6.982h6.635l2.092-2.311L38.767 27h2.21L37.883 23.413zM33.728 25.516h-4.011v-1.381h3.838v-1.323h-3.838v-1.308l4.234.012 1.693 1.897L33.728 25.516z"
|
|
9791
9787
|
})),
|
|
9792
9788
|
bacs_debit: /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
9793
|
-
className: "plc-w-
|
|
9789
|
+
className: "plc-w-16",
|
|
9794
9790
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9795
|
-
viewBox: "0 0
|
|
9791
|
+
viewBox: "0 0 1804.35 528.73"
|
|
9792
|
+
}, /*#__PURE__*/React__default['default'].createElement("defs", null, /*#__PURE__*/React__default['default'].createElement("clipPath", {
|
|
9793
|
+
id: "clip1"
|
|
9796
9794
|
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9795
|
+
d: "M0 0h581v528.73H0zm0 0"
|
|
9796
|
+
})), /*#__PURE__*/React__default['default'].createElement("clipPath", {
|
|
9797
|
+
id: "clip2"
|
|
9798
|
+
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
9799
|
+
d: "M584 0h1220.352v528.73H584zm0 0"
|
|
9800
|
+
})), /*#__PURE__*/React__default['default'].createElement("clipPath", {
|
|
9801
|
+
id: "clip3"
|
|
9802
|
+
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
9803
|
+
d: "M0 0h581v528.73H0zm0 0"
|
|
9804
|
+
}))), /*#__PURE__*/React__default['default'].createElement("g", null, /*#__PURE__*/React__default['default'].createElement("g", {
|
|
9805
|
+
clipPath: "url(#clip1)"
|
|
9806
|
+
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
9807
|
+
fill: "#FFF",
|
|
9808
|
+
d: "M580.68 0H101.277L.02 528.64h302.636c120.051-.808 194.696-98.507 214.168-194.1L580.68 0h-.016.016"
|
|
9809
|
+
})), /*#__PURE__*/React__default['default'].createElement("g", {
|
|
9810
|
+
clipPath: "url(#clip2)"
|
|
9811
|
+
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
9812
|
+
fill: "#020202",
|
|
9813
|
+
d: "M1555.66 503.934c16.05 12.386 49.59 24.058 87.512 24.773 74.398 0 134.918-42.289 134.918-116.684 0-39.359-26.969-69.984-66.352-92.586-31.36-17.535-48.136-33.574-48.136-59.09 0-30.644 26.25-53.265 62.738-53.265 26.23 0 48.84 8.777 61.25 16.059l16.762-45.942c-13.114-8.758-41.563-17.515-73.653-17.515-74.39 0-127.629 47.398-127.629 109.402 0 35.75 22.59 67.09 63.442 89.71 36.476 20.411 48.86 37.188 48.86 64.9 0 31.359-26.25 57.632-67.09 57.632-28.454 0-59.071-11.687-75.852-21.883zm-43.851-45.223c-18.23 8.773-45.938 19.707-81.68 19.707-57.598 0-87.508-37.223-87.508-94.102 0-83.128 57.617-173.562 149.488-173.562 26.282 0 45.942 6.543 59.801 13.125l17.52-48.137c-10.93-5.828-40.86-15.32-73.668-15.32-126.883 0-215.864 110.855-215.864 231.191 0 75.153 44.493 137.117 135.66 137.117 47.403 0 83.864-13.132 102.102-21.886zm-309.13-245.766c-8.738-2.191-21.87-5.125-42.288-5.125-91.172 0-165.567 95.559-166.301 193.274 0 39.383 13.87 78.062 60.55 78.062 50.329 0 110.122-65.656 127.63-159.719zm-39.378 307.762c0-21.144 3.668-54.695 8.02-91.168h-1.462c-38.648 72.938-86.789 99.191-137.109 99.191-61.984 0-101.363-49.574-101.363-116.707 0-122.507 90.414-252.34 244.324-252.34 33.559 0 70.719 5.844 94.8 13.868l-35.73 183.789c-11.672 61.265-16.8 124.008-15.32 163.367zm-511.969-136.39c-2.93 11.667-5.11 26.253-4.387 44.507 0 33.535 18.973 52.504 56.895 52.504 91.172 0 146.59-108.664 146.59-186.707 0-43.77-18.973-84.605-67.09-84.605-52.528 0-106.492 53.96-123.988 137.129zM728.622 0l-47.403 231.883h1.457c31.36-47.383 76.586-72.2 123.988-72.2 77.316 0 106.492 64.196 106.492 126.919 0 107.925-78.047 242.128-219.527 242.128-62.004 0-108.668-25.515-108.668-91.148 0-16.781 2.91-37.945 5.844-54.727L668.075 0h60.546"
|
|
9814
|
+
})), /*#__PURE__*/React__default['default'].createElement("g", {
|
|
9815
|
+
clipPath: "url(#clip3)"
|
|
9816
|
+
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
9817
|
+
fill: "#E41C3B",
|
|
9818
|
+
d: "M471.438 172.54C466.851 85.647 370 17.19 241.07 0h-14.316c126.144 23.848 218.434 99.512 218.434 189.246 0 68.027-52.993 128.031-133.649 163.457 98.598-37.238 163.836-105.52 159.899-180.164M275.288 0c126.055 27.027 217.73 102.375 222.637 195.703 6.527 123.57-141.555 231.863-330.766 241.824-52.219 2.766-102.101-2.27-147.094-13.578L0 528.641h302.656c120.035-.809 194.696-98.543 214.188-194.157L580.664 0zm-63.332 377.516c117.512-24.829 202.926-99.672 202.926-188.27 0-89.785-87.754-165.453-207.746-189.246h-29.203c120.695 19.223 211.02 96.816 211.02 189.715 0 97.21-98.9 177.754-227.993 192.082 3.254-.125 6.523-.195 9.816-.36 13.989-.734 27.711-2.101 41.18-3.921m-121.129-17.91a328.134 328.134 0 01-57.473-5.055L98.938 12.156C227.925 15.27 331.18 91.801 331.18 185.79c0 95.992-107.61 173.816-240.352 173.816"
|
|
9819
|
+
}))))
|
|
9800
9820
|
};
|
|
9801
9821
|
return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
9802
9822
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -12817,6 +12837,7 @@ const RESET_NEW_PASSWORD_ERROR = "RESET_NEW_PASSWORD_ERROR";
|
|
|
12817
12837
|
const RESET_CONFIRM_NEW_PASSWORD_ERROR = "RESET_CONFIRM_NEW_PASSWORD_ERROR";
|
|
12818
12838
|
const SHOW_ALERT = "SHOW_ALERT";
|
|
12819
12839
|
const SELECT_ADDRESS = "SELECT_ADDRESS";
|
|
12840
|
+
const SELECT_BILLING_ADDRESS = "SELECT_BILLING_ADDRESS";
|
|
12820
12841
|
const LOAD_ADDRESSES = "LOAD_ADDRESSES";
|
|
12821
12842
|
const SET_CROP = "SET_CROP";
|
|
12822
12843
|
const SET_ZOOM = "SET_ZOOM";
|
|
@@ -22474,7 +22495,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
22474
22495
|
onFailure = () => {},
|
|
22475
22496
|
...props
|
|
22476
22497
|
}) => {
|
|
22477
|
-
var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice, _window$Pelcro, _window$Pelcro$uiSett;
|
|
22498
|
+
var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$selectedBillin, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice, _window$Pelcro, _window$Pelcro$uiSett, _window$Pelcro$user$r, _window, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$, _window$Pelcro2$user$2, _window$Pelcro$user$r2, _window2, _window2$Pelcro, _window2$Pelcro$user, _window2$Pelcro$user$, _window2$Pelcro$user$2, _billingAddress$line, _billingAddress$line2, _billingAddress$city, _billingAddress$state, _billingAddress$count, _billingAddress$posta;
|
|
22478
22499
|
|
|
22479
22500
|
// Get a reference to Stripe or Elements using hooks.
|
|
22480
22501
|
const stripe = useStripe();
|
|
@@ -22500,6 +22521,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
22500
22521
|
const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
|
|
22501
22522
|
const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
|
|
22502
22523
|
const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
|
|
22524
|
+
const selectedBillingAddressId = (_props$selectedBillin = props.selectedBillingAddressId) !== null && _props$selectedBillin !== void 0 ? _props$selectedBillin : pelcroStore.selectedBillingAddressId;
|
|
22503
22525
|
const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
|
|
22504
22526
|
const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
|
|
22505
22527
|
const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
|
|
@@ -23502,6 +23524,30 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
23502
23524
|
}, [selectedPaymentMethodId]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
23503
23525
|
|
|
23504
23526
|
/* ====== Start Stripe integration ======== */
|
|
23527
|
+
// useEffect(() => {
|
|
23528
|
+
// if (!selectedBillingAddressId) {
|
|
23529
|
+
// const defaultAddress = window?.Pelcro?.user
|
|
23530
|
+
// ?.read()
|
|
23531
|
+
// ?.addresses?.find(
|
|
23532
|
+
// (address) => address.type == "billing" && address.is_default
|
|
23533
|
+
// );
|
|
23534
|
+
// if (defaultAddress) {
|
|
23535
|
+
// set({ selectedBillingAddressId: defaultAddress.id });
|
|
23536
|
+
// }
|
|
23537
|
+
// }
|
|
23538
|
+
// }, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
23539
|
+
|
|
23540
|
+
const billingAddress = selectedBillingAddressId ? (_window$Pelcro$user$r = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro2 = _window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : (_window$Pelcro2$user$2 = _window$Pelcro2$user$.addresses) === null || _window$Pelcro2$user$2 === void 0 ? void 0 : _window$Pelcro2$user$2.find(address => address.id == selectedBillingAddressId)) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : {} : (_window$Pelcro$user$r2 = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$user = _window2$Pelcro.user) === null || _window2$Pelcro$user === void 0 ? void 0 : (_window2$Pelcro$user$ = _window2$Pelcro$user.read()) === null || _window2$Pelcro$user$ === void 0 ? void 0 : (_window2$Pelcro$user$2 = _window2$Pelcro$user$.addresses) === null || _window2$Pelcro$user$2 === void 0 ? void 0 : _window2$Pelcro$user$2.find(address => address.type == "billing" && address.is_default)) !== null && _window$Pelcro$user$r2 !== void 0 ? _window$Pelcro$user$r2 : {};
|
|
23541
|
+
const billingDetails = {
|
|
23542
|
+
address: {
|
|
23543
|
+
line1: (_billingAddress$line = billingAddress === null || billingAddress === void 0 ? void 0 : billingAddress.line1) !== null && _billingAddress$line !== void 0 ? _billingAddress$line : null,
|
|
23544
|
+
line2: (_billingAddress$line2 = billingAddress === null || billingAddress === void 0 ? void 0 : billingAddress.line2) !== null && _billingAddress$line2 !== void 0 ? _billingAddress$line2 : null,
|
|
23545
|
+
city: (_billingAddress$city = billingAddress === null || billingAddress === void 0 ? void 0 : billingAddress.city) !== null && _billingAddress$city !== void 0 ? _billingAddress$city : null,
|
|
23546
|
+
state: (_billingAddress$state = billingAddress === null || billingAddress === void 0 ? void 0 : billingAddress.state) !== null && _billingAddress$state !== void 0 ? _billingAddress$state : null,
|
|
23547
|
+
country: (_billingAddress$count = billingAddress === null || billingAddress === void 0 ? void 0 : billingAddress.country) !== null && _billingAddress$count !== void 0 ? _billingAddress$count : null,
|
|
23548
|
+
postal_code: (_billingAddress$posta = billingAddress === null || billingAddress === void 0 ? void 0 : billingAddress.postal_code) !== null && _billingAddress$posta !== void 0 ? _billingAddress$posta : null
|
|
23549
|
+
}
|
|
23550
|
+
};
|
|
23505
23551
|
|
|
23506
23552
|
const initPaymentRequest = (state, dispatch) => {
|
|
23507
23553
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
@@ -23905,7 +23951,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
23905
23951
|
addressId: selectedAddressId,
|
|
23906
23952
|
couponCode
|
|
23907
23953
|
}, (err, orderResponse) => {
|
|
23908
|
-
var _window$
|
|
23954
|
+
var _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro3$user$;
|
|
23909
23955
|
|
|
23910
23956
|
if (err) {
|
|
23911
23957
|
toggleAuthenticationSuccessPendingView(false);
|
|
@@ -23939,7 +23985,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
23939
23985
|
}
|
|
23940
23986
|
|
|
23941
23987
|
window.Pelcro.user.refresh({
|
|
23942
|
-
auth_token: (_window$
|
|
23988
|
+
auth_token: (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : (_window$Pelcro3$user$ = _window$Pelcro3$user.read()) === null || _window$Pelcro3$user$ === void 0 ? void 0 : _window$Pelcro3$user$.auth_token
|
|
23943
23989
|
}, (err, res) => {
|
|
23944
23990
|
dispatch({
|
|
23945
23991
|
type: DISABLE_SUBMIT,
|
|
@@ -23991,14 +24037,16 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
23991
24037
|
}
|
|
23992
24038
|
|
|
23993
24039
|
return stripe.createPaymentMethod({
|
|
23994
|
-
elements
|
|
24040
|
+
elements,
|
|
24041
|
+
params: {
|
|
24042
|
+
billing_details: billingDetails
|
|
24043
|
+
}
|
|
23995
24044
|
}).then(result => {
|
|
23996
24045
|
if (result.error) {
|
|
23997
24046
|
return handlePaymentError(result.error);
|
|
23998
24047
|
}
|
|
23999
24048
|
|
|
24000
24049
|
if (result.paymentMethod) {
|
|
24001
|
-
console.log(result.paymentMethod);
|
|
24002
24050
|
window.Pelcro.paymentMethods.create({
|
|
24003
24051
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
24004
24052
|
token: result.paymentMethod.id
|
|
@@ -24024,10 +24072,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
24024
24072
|
});
|
|
24025
24073
|
}
|
|
24026
24074
|
|
|
24027
|
-
if (result.paymentMethod.type == "bacs_debit") {
|
|
24028
|
-
createBillingAddress(result.paymentMethod.billing_details);
|
|
24029
|
-
}
|
|
24030
|
-
|
|
24031
24075
|
if (((_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$setup_inten = _res$data.setup_intent) === null || _res$data$setup_inten === void 0 ? void 0 : _res$data$setup_inten.status) === "requires_action" || ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$setup_inte = _res$data2.setup_intent) === null || _res$data2$setup_inte === void 0 ? void 0 : _res$data2$setup_inte.status) === "requires_confirmation") {
|
|
24032
24076
|
confirmStripeIntentSetup(res, "create");
|
|
24033
24077
|
} else {
|
|
@@ -24118,7 +24162,10 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
24118
24162
|
}
|
|
24119
24163
|
|
|
24120
24164
|
return stripe.createPaymentMethod({
|
|
24121
|
-
elements
|
|
24165
|
+
elements,
|
|
24166
|
+
params: {
|
|
24167
|
+
billing_details: billingDetails
|
|
24168
|
+
}
|
|
24122
24169
|
}).then(result => {
|
|
24123
24170
|
if (result.error) {
|
|
24124
24171
|
return handlePaymentError(result.error);
|
|
@@ -24142,10 +24189,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
24142
24189
|
});
|
|
24143
24190
|
}
|
|
24144
24191
|
|
|
24145
|
-
if (result.paymentMethod.type == "bacs_debit") {
|
|
24146
|
-
createBillingAddress(result.paymentMethod.billing_details);
|
|
24147
|
-
}
|
|
24148
|
-
|
|
24149
24192
|
if (((_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$setup_inte = _res$data5.setup_intent) === null || _res$data5$setup_inte === void 0 ? void 0 : _res$data5$setup_inte.status) === "requires_action" || ((_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : (_res$data6$setup_inte = _res$data6.setup_intent) === null || _res$data6$setup_inte === void 0 ? void 0 : _res$data6$setup_inte.status) === "requires_confirmation") {
|
|
24150
24193
|
confirmStripeIntentSetup(res, "replace", paymentMethodId);
|
|
24151
24194
|
} else {
|
|
@@ -24231,17 +24274,16 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
24231
24274
|
}
|
|
24232
24275
|
|
|
24233
24276
|
stripe.createPaymentMethod({
|
|
24234
|
-
elements
|
|
24277
|
+
elements,
|
|
24278
|
+
params: {
|
|
24279
|
+
billing_details: billingDetails
|
|
24280
|
+
}
|
|
24235
24281
|
}).then(result => {
|
|
24236
24282
|
if (result.error) {
|
|
24237
24283
|
return handlePaymentError(result.error);
|
|
24238
24284
|
}
|
|
24239
24285
|
|
|
24240
24286
|
if (result.paymentMethod) {
|
|
24241
|
-
if (result.paymentMethod.type == "bacs_debit") {
|
|
24242
|
-
createBillingAddress(result.paymentMethod.billing_details);
|
|
24243
|
-
}
|
|
24244
|
-
|
|
24245
24287
|
return handlePayment(result.paymentMethod);
|
|
24246
24288
|
}
|
|
24247
24289
|
}).catch(error => {
|
|
@@ -24293,37 +24335,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
24293
24335
|
type: LOADING,
|
|
24294
24336
|
payload: false
|
|
24295
24337
|
});
|
|
24296
|
-
};
|
|
24297
|
-
|
|
24298
|
-
const createBillingAddress = billingDetails => {
|
|
24299
|
-
const hasBillingAddress = userHasBillingAddress();
|
|
24300
|
-
if (hasBillingAddress) return;
|
|
24301
|
-
const {
|
|
24302
|
-
name,
|
|
24303
|
-
address
|
|
24304
|
-
} = billingDetails;
|
|
24305
|
-
const [firstName, lastName] = name ? name === null || name === void 0 ? void 0 : name.split(" ") : [];
|
|
24306
|
-
window.Pelcro.address.create({
|
|
24307
|
-
auth_token: window.Pelcro.user.read().auth_token,
|
|
24308
|
-
type: "billing",
|
|
24309
|
-
first_name: firstName,
|
|
24310
|
-
last_name: lastName,
|
|
24311
|
-
line1: address === null || address === void 0 ? void 0 : address.line1,
|
|
24312
|
-
line2: address === null || address === void 0 ? void 0 : address.line2,
|
|
24313
|
-
city: address === null || address === void 0 ? void 0 : address.city,
|
|
24314
|
-
state: address === null || address === void 0 ? void 0 : address.state,
|
|
24315
|
-
country: address === null || address === void 0 ? void 0 : address.country,
|
|
24316
|
-
postal_code: address === null || address === void 0 ? void 0 : address.postal_code,
|
|
24317
|
-
is_default: true
|
|
24318
|
-
}, (err, res) => {
|
|
24319
|
-
if (err) {
|
|
24320
|
-
console.error(err);
|
|
24321
|
-
}
|
|
24322
|
-
|
|
24323
|
-
if (res) {
|
|
24324
|
-
console.log(res);
|
|
24325
|
-
}
|
|
24326
|
-
});
|
|
24327
24338
|
}; // TODO: Refactor deprecated stripe implementation
|
|
24328
24339
|
|
|
24329
24340
|
/* Start Stripe deprecated functions */
|
|
@@ -25253,26 +25264,17 @@ const PelcroPaymentRequestButton = props => {
|
|
|
25253
25264
|
const CheckoutForm = ({
|
|
25254
25265
|
type
|
|
25255
25266
|
}) => {
|
|
25256
|
-
var _window
|
|
25267
|
+
var _window, _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$r, _window2, _window2$Pelcro, _window2$Pelcro$user, _window2$Pelcro$user$, _window3, _window3$Pelcro, _window3$Pelcro$user, _window3$Pelcro$user$;
|
|
25257
25268
|
|
|
25258
25269
|
const {
|
|
25259
25270
|
selectedPaymentMethodId,
|
|
25260
25271
|
paymentMethodToEdit
|
|
25261
25272
|
} = usePelcro();
|
|
25262
25273
|
const cardProcessor = getSiteCardProcessor();
|
|
25263
|
-
const defaultAddress = (_window$Pelcro$user$r = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : (_window$Pelcro$user$r2 = _window$Pelcro$user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : (_window$Pelcro$user$r3 = _window$Pelcro$user$r2.addresses) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.find(address => address.type == "billing" && address.is_default)) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
25264
25274
|
const billingDetails = {
|
|
25265
|
-
name: (
|
|
25266
|
-
email: (
|
|
25267
|
-
phone: (
|
|
25268
|
-
address: {
|
|
25269
|
-
line1: (_defaultAddress$line = defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.line1) !== null && _defaultAddress$line !== void 0 ? _defaultAddress$line : null,
|
|
25270
|
-
line2: (_defaultAddress$line2 = defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.line2) !== null && _defaultAddress$line2 !== void 0 ? _defaultAddress$line2 : null,
|
|
25271
|
-
city: (_defaultAddress$city = defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.city) !== null && _defaultAddress$city !== void 0 ? _defaultAddress$city : null,
|
|
25272
|
-
state: (_defaultAddress$state = defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.state) !== null && _defaultAddress$state !== void 0 ? _defaultAddress$state : null,
|
|
25273
|
-
country: (_defaultAddress$count = defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.country) !== null && _defaultAddress$count !== void 0 ? _defaultAddress$count : null,
|
|
25274
|
-
postal_code: (_defaultAddress$posta = defaultAddress === null || defaultAddress === void 0 ? void 0 : defaultAddress.postal_code) !== null && _defaultAddress$posta !== void 0 ? _defaultAddress$posta : null
|
|
25275
|
-
}
|
|
25275
|
+
name: (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : (_window$Pelcro$user$r = _window$Pelcro$user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.name,
|
|
25276
|
+
email: (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$user = _window2$Pelcro.user) === null || _window2$Pelcro$user === void 0 ? void 0 : (_window2$Pelcro$user$ = _window2$Pelcro$user.read()) === null || _window2$Pelcro$user$ === void 0 ? void 0 : _window2$Pelcro$user$.email,
|
|
25277
|
+
phone: (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$Pelcro = _window3.Pelcro) === null || _window3$Pelcro === void 0 ? void 0 : (_window3$Pelcro$user = _window3$Pelcro.user) === null || _window3$Pelcro$user === void 0 ? void 0 : (_window3$Pelcro$user$ = _window3$Pelcro$user.read()) === null || _window3$Pelcro$user$ === void 0 ? void 0 : _window3$Pelcro$user$.phone
|
|
25276
25278
|
};
|
|
25277
25279
|
const paymentElementOptions = {
|
|
25278
25280
|
layout: {
|
|
@@ -25283,6 +25285,14 @@ const CheckoutForm = ({
|
|
|
25283
25285
|
defaultValues: {
|
|
25284
25286
|
billingDetails: billingDetails
|
|
25285
25287
|
},
|
|
25288
|
+
fields: {
|
|
25289
|
+
billingDetails: {
|
|
25290
|
+
name: "auto",
|
|
25291
|
+
email: "auto",
|
|
25292
|
+
phone: "auto",
|
|
25293
|
+
address: "never"
|
|
25294
|
+
}
|
|
25295
|
+
},
|
|
25286
25296
|
terms: {
|
|
25287
25297
|
applePay: "never",
|
|
25288
25298
|
card: "never",
|
|
@@ -25967,7 +25977,7 @@ const SelectedPaymentMethod = () => {
|
|
|
25967
25977
|
});
|
|
25968
25978
|
return selectedPaymentMethodId && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
25969
25979
|
key: paymentMethod.id,
|
|
25970
|
-
className: "plc-
|
|
25980
|
+
className: "plc-p-4 plc-my-4 plc-text-gray-900 plc-rounded plc-shadow-md_dark pelcro-payment-method-wrapper"
|
|
25971
25981
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
25972
25982
|
className: "plc-flex plc-items-center plc-px-1",
|
|
25973
25983
|
id: `pelcro-payment-method-select-${paymentMethod.id}`
|
|
@@ -26525,8 +26535,76 @@ function PaymentMethodUpdateSetDefault(props) {
|
|
|
26525
26535
|
}, props.label);
|
|
26526
26536
|
}
|
|
26527
26537
|
|
|
26538
|
+
const SelectedAddress = ({
|
|
26539
|
+
type
|
|
26540
|
+
}) => {
|
|
26541
|
+
var _window$Pelcro$user$r, _window, _window$Pelcro, _window$Pelcro$user, _addresses$find, _addresses$find2;
|
|
26542
|
+
|
|
26543
|
+
const {
|
|
26544
|
+
t
|
|
26545
|
+
} = useTranslation("payment");
|
|
26546
|
+
const {
|
|
26547
|
+
state: {
|
|
26548
|
+
isLoading
|
|
26549
|
+
}
|
|
26550
|
+
} = React.useContext(store$m);
|
|
26551
|
+
const {
|
|
26552
|
+
switchView,
|
|
26553
|
+
set,
|
|
26554
|
+
selectedBillingAddressId
|
|
26555
|
+
} = usePelcro();
|
|
26556
|
+
const {
|
|
26557
|
+
addresses
|
|
26558
|
+
} = (_window$Pelcro$user$r = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.read()) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
26559
|
+
const address = selectedBillingAddressId ? (_addresses$find = addresses === null || addresses === void 0 ? void 0 : addresses.find(address => address.id == selectedBillingAddressId)) !== null && _addresses$find !== void 0 ? _addresses$find : null : (_addresses$find2 = addresses === null || addresses === void 0 ? void 0 : addresses.find(address => address.type == "billing" && address.is_default)) !== null && _addresses$find2 !== void 0 ? _addresses$find2 : null;
|
|
26560
|
+
|
|
26561
|
+
const onAddNewAddress = () => {
|
|
26562
|
+
set({
|
|
26563
|
+
flow: type
|
|
26564
|
+
});
|
|
26565
|
+
|
|
26566
|
+
if (address) {
|
|
26567
|
+
switchView("billing-address-select");
|
|
26568
|
+
} else {
|
|
26569
|
+
switchView("billing-address-create");
|
|
26570
|
+
}
|
|
26571
|
+
};
|
|
26572
|
+
|
|
26573
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
26574
|
+
className: "plc-p-4 plc-my-4 last:plc-mb-0 plc-rounded plc-text-gray-900 pelcro-address-wrapper plc-bg-white plc-shadow-md_dark plc-relative"
|
|
26575
|
+
}, address && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
26576
|
+
className: "pelcro-select-address-radio plc-order-2",
|
|
26577
|
+
id: `pelcro-address-select-${address.id}`,
|
|
26578
|
+
name: "address"
|
|
26579
|
+
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
26580
|
+
className: "pelcro-address-name plc-font-semibold"
|
|
26581
|
+
}, t("labels.checkout.billingAddress")), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
26582
|
+
className: "pelcro-address-company"
|
|
26583
|
+
}, address.company), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
26584
|
+
className: "pelcro-address-line1 plc-text-sm plc-mt-2"
|
|
26585
|
+
}, address.line1), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
26586
|
+
className: "pelcro-address-country plc-text-sm"
|
|
26587
|
+
}, address.city, ", ", address.state_name, " ", address.postal_code, ", ", address.country_name)), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
26588
|
+
onClick: onAddNewAddress,
|
|
26589
|
+
disabled: isLoading,
|
|
26590
|
+
variant: "ghost",
|
|
26591
|
+
className: "plc-text-primary-500 plc-absolute plc-top-4 plc-right-5"
|
|
26592
|
+
}, t("labels.checkout.changeBillingAddress"))), !address && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
26593
|
+
className: "pelcro-select-address-radio plc-order-2",
|
|
26594
|
+
id: `pelcro-address-select-${address === null || address === void 0 ? void 0 : address.id}`,
|
|
26595
|
+
name: "address"
|
|
26596
|
+
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
26597
|
+
className: "pelcro-address-name plc-font-semibold"
|
|
26598
|
+
}, t("labels.checkout.NoBillingAddress"))), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
26599
|
+
onClick: onAddNewAddress,
|
|
26600
|
+
disabled: isLoading,
|
|
26601
|
+
variant: "ghost",
|
|
26602
|
+
className: "plc-text-primary-500 plc-absolute plc-top-4 plc-right-5"
|
|
26603
|
+
}, t("labels.checkout.addNewAddress"))));
|
|
26604
|
+
};
|
|
26605
|
+
|
|
26528
26606
|
/**
|
|
26529
|
-
|
|
26607
|
+
*@return {paymentMethodView}
|
|
26530
26608
|
*/
|
|
26531
26609
|
|
|
26532
26610
|
function PaymentMethodView({
|
|
@@ -26585,7 +26663,9 @@ function PaymentMethodView({
|
|
|
26585
26663
|
freeOrders: showOrderButton
|
|
26586
26664
|
}, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
|
|
26587
26665
|
className: "plc-mb-2"
|
|
26588
|
-
}), showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default['default'].createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(
|
|
26666
|
+
}), showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default['default'].createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedAddress, {
|
|
26667
|
+
type: type
|
|
26668
|
+
}), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
26589
26669
|
className: "plc-flex plc-items-start"
|
|
26590
26670
|
}, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
|
|
26591
26671
|
id: "pelcro-input-first-name",
|
|
@@ -29432,7 +29512,7 @@ const AddressCreateContainer = ({
|
|
|
29432
29512
|
};
|
|
29433
29513
|
|
|
29434
29514
|
getCountries();
|
|
29435
|
-
}, []);
|
|
29515
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
29436
29516
|
|
|
29437
29517
|
const submitAddress = ({
|
|
29438
29518
|
firstName,
|
|
@@ -29507,8 +29587,10 @@ const AddressCreateContainer = ({
|
|
|
29507
29587
|
}
|
|
29508
29588
|
|
|
29509
29589
|
if (product || order) {
|
|
29510
|
-
set({
|
|
29590
|
+
type == "shipping" ? set({
|
|
29511
29591
|
selectedAddressId: newAddressId
|
|
29592
|
+
}) : set({
|
|
29593
|
+
selectedBillingAddressId: newAddressId
|
|
29512
29594
|
});
|
|
29513
29595
|
}
|
|
29514
29596
|
|
|
@@ -29643,7 +29725,8 @@ const AddressCreateContainer = ({
|
|
|
29643
29725
|
if (state.country) {
|
|
29644
29726
|
getStates();
|
|
29645
29727
|
}
|
|
29646
|
-
}, [state.country]);
|
|
29728
|
+
}, [state.country]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
29729
|
+
|
|
29647
29730
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
29648
29731
|
style: { ...style
|
|
29649
29732
|
},
|
|
@@ -30165,6 +30248,70 @@ const AddressCreateModal = ({
|
|
|
30165
30248
|
};
|
|
30166
30249
|
AddressCreateModal.viewId = "address-create";
|
|
30167
30250
|
|
|
30251
|
+
const BillingAddressCreateModal = ({
|
|
30252
|
+
onDisplay,
|
|
30253
|
+
onClose,
|
|
30254
|
+
...otherProps
|
|
30255
|
+
}) => {
|
|
30256
|
+
const {
|
|
30257
|
+
switchView,
|
|
30258
|
+
// switchToPaymentView,
|
|
30259
|
+
// resetView,
|
|
30260
|
+
switchToCheckoutForm,
|
|
30261
|
+
flow
|
|
30262
|
+
} = usePelcro();
|
|
30263
|
+
const {
|
|
30264
|
+
t
|
|
30265
|
+
} = useTranslation("address");
|
|
30266
|
+
|
|
30267
|
+
const onSuccess = newAddressId => {
|
|
30268
|
+
var _otherProps$onSuccess;
|
|
30269
|
+
|
|
30270
|
+
(_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, newAddressId);
|
|
30271
|
+
|
|
30272
|
+
switch (flow) {
|
|
30273
|
+
case "createPaymentSource":
|
|
30274
|
+
switchView("payment-method-create");
|
|
30275
|
+
break;
|
|
30276
|
+
|
|
30277
|
+
case "deletePaymentSource":
|
|
30278
|
+
switchView("payment-method-delete");
|
|
30279
|
+
break;
|
|
30280
|
+
|
|
30281
|
+
default:
|
|
30282
|
+
switchToCheckoutForm();
|
|
30283
|
+
break;
|
|
30284
|
+
}
|
|
30285
|
+
}; // const onGiftRedemptionSuccess = () => {
|
|
30286
|
+
// otherProps.onGiftRedemptionSuccess?.();
|
|
30287
|
+
// switchView("subscription-success");
|
|
30288
|
+
// };
|
|
30289
|
+
// FIXME: implement me
|
|
30290
|
+
// const onMembershipAdressUpdateSuccess = () => {
|
|
30291
|
+
// otherProps.onMembershipAdressUpdateSuccess?.();
|
|
30292
|
+
// resetView();
|
|
30293
|
+
// };
|
|
30294
|
+
|
|
30295
|
+
|
|
30296
|
+
return /*#__PURE__*/React__default['default'].createElement(Modal, {
|
|
30297
|
+
id: "pelcro-address-create-modal",
|
|
30298
|
+
onDisplay: onDisplay,
|
|
30299
|
+
onClose: onClose
|
|
30300
|
+
}, /*#__PURE__*/React__default['default'].createElement(ModalHeader, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
30301
|
+
className: "plc-text-left plc-text-gray-900 pelcro-title-wrapper plc-flex-1 plc-flex plc-flex-col plc-justify-center"
|
|
30302
|
+
}, /*#__PURE__*/React__default['default'].createElement("h4", {
|
|
30303
|
+
className: "plc-text-xl plc-font-bold"
|
|
30304
|
+
}, t("titleBilling")))), /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(AddressCreateView, Object.assign({}, otherProps, {
|
|
30305
|
+
type: "billing",
|
|
30306
|
+
onSuccess: onSuccess // onGiftRedemptionSuccess={onGiftRedemptionSuccess}
|
|
30307
|
+
// onMembershipAdressUpdateSuccess={
|
|
30308
|
+
// onMembershipAdressUpdateSuccess
|
|
30309
|
+
// }
|
|
30310
|
+
|
|
30311
|
+
}))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null));
|
|
30312
|
+
};
|
|
30313
|
+
BillingAddressCreateModal.viewId = "billing-address-create";
|
|
30314
|
+
|
|
30168
30315
|
const AddressCreateTextInput = props => {
|
|
30169
30316
|
return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
|
|
30170
30317
|
store: store$g
|
|
@@ -30827,6 +30974,28 @@ const AddressUpdateModal = ({
|
|
|
30827
30974
|
};
|
|
30828
30975
|
AddressUpdateModal.viewId = "address-edit";
|
|
30829
30976
|
|
|
30977
|
+
const BillingAddressUpdateModal = ({
|
|
30978
|
+
onDisplay,
|
|
30979
|
+
onClose,
|
|
30980
|
+
...otherProps
|
|
30981
|
+
}) => {
|
|
30982
|
+
const {
|
|
30983
|
+
t
|
|
30984
|
+
} = useTranslation("address");
|
|
30985
|
+
return /*#__PURE__*/React__default['default'].createElement(Modal, {
|
|
30986
|
+
id: "pelcro-address-update-modal",
|
|
30987
|
+
onDisplay: onDisplay,
|
|
30988
|
+
onClose: onClose
|
|
30989
|
+
}, /*#__PURE__*/React__default['default'].createElement(ModalHeader, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
30990
|
+
className: "plc-text-left plc-text-gray-900 pelcro-title-wrapper plc-flex-1 plc-flex plc-flex-col plc-justify-center"
|
|
30991
|
+
}, /*#__PURE__*/React__default['default'].createElement("h4", {
|
|
30992
|
+
className: "plc-text-xl plc-font-bold"
|
|
30993
|
+
}, t("titleBilling")))), /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(AddressUpdateView, Object.assign({
|
|
30994
|
+
type: "billing"
|
|
30995
|
+
}, otherProps))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null));
|
|
30996
|
+
};
|
|
30997
|
+
BillingAddressUpdateModal.viewId = "billing-address-edit";
|
|
30998
|
+
|
|
30830
30999
|
const AddressUpdateTextInput = props => {
|
|
30831
31000
|
return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
|
|
30832
31001
|
store: store$f
|
|
@@ -33081,19 +33250,25 @@ const GiftRedeemModal = ({
|
|
|
33081
33250
|
};
|
|
33082
33251
|
GiftRedeemModal.viewId = "gift-redeem";
|
|
33083
33252
|
|
|
33084
|
-
const
|
|
33085
|
-
return addresses.find(address => address.is_default) || false;
|
|
33253
|
+
const getDefaultShippingAddress = addresses => {
|
|
33254
|
+
return addresses.find(address => address.type == "shipping" && address.is_default) || false;
|
|
33086
33255
|
};
|
|
33087
33256
|
|
|
33088
|
-
const
|
|
33089
|
-
|
|
33090
|
-
|
|
33091
|
-
|
|
33092
|
-
|
|
33257
|
+
const getDefaultBillingAddress = addresses => {
|
|
33258
|
+
return addresses.find(address => address.type == "billing" && address.is_default) || false;
|
|
33259
|
+
}; // const moveDefaultAddressToStart = (addresses) => {
|
|
33260
|
+
// const defaultAddress = getDefaultAddress(addresses);
|
|
33261
|
+
// const addressesWithoutDefault = addresses.filter(
|
|
33262
|
+
// (address) => !address.is_default
|
|
33263
|
+
// );
|
|
33264
|
+
// return [defaultAddress, ...addressesWithoutDefault];
|
|
33265
|
+
// };
|
|
33266
|
+
|
|
33093
33267
|
|
|
33094
33268
|
const initialState$7 = {
|
|
33095
33269
|
addresses: [],
|
|
33096
33270
|
selectedAddressId: null,
|
|
33271
|
+
selectedBillingAddressId: null,
|
|
33097
33272
|
isSubmitting: false,
|
|
33098
33273
|
alert: {
|
|
33099
33274
|
type: "error",
|
|
@@ -33108,6 +33283,7 @@ const {
|
|
|
33108
33283
|
const AddressSelectContainer = ({
|
|
33109
33284
|
style,
|
|
33110
33285
|
className = "",
|
|
33286
|
+
type = "shipping",
|
|
33111
33287
|
onGiftRedemptionSuccess = () => {},
|
|
33112
33288
|
onMembershipAdressUpdateSuccess = () => {},
|
|
33113
33289
|
onSuccess = () => {},
|
|
@@ -33203,6 +33379,15 @@ const AddressSelectContainer = ({
|
|
|
33203
33379
|
onSuccess(selectedAddressId);
|
|
33204
33380
|
};
|
|
33205
33381
|
|
|
33382
|
+
const submitBillingAddress = ({
|
|
33383
|
+
selectedBillingAddressId
|
|
33384
|
+
}, dispatch) => {
|
|
33385
|
+
set({
|
|
33386
|
+
selectedBillingAddressId
|
|
33387
|
+
});
|
|
33388
|
+
onSuccess(selectedBillingAddressId);
|
|
33389
|
+
};
|
|
33390
|
+
|
|
33206
33391
|
const [state, dispatch] = useReducerWithSideEffects((state, action) => {
|
|
33207
33392
|
switch (action.type) {
|
|
33208
33393
|
case SELECT_ADDRESS:
|
|
@@ -33210,16 +33395,30 @@ const AddressSelectContainer = ({
|
|
|
33210
33395
|
selectedAddressId: action.payload
|
|
33211
33396
|
});
|
|
33212
33397
|
|
|
33398
|
+
case SELECT_BILLING_ADDRESS:
|
|
33399
|
+
return lib_7({ ...state,
|
|
33400
|
+
selectedBillingAddressId: action.payload
|
|
33401
|
+
});
|
|
33402
|
+
|
|
33213
33403
|
case LOAD_ADDRESSES:
|
|
33214
|
-
if (!
|
|
33404
|
+
if (!getDefaultShippingAddress) {
|
|
33215
33405
|
return switchView("address-select");
|
|
33406
|
+
} else if (!getDefaultBillingAddress) {
|
|
33407
|
+
return switchView("billing-address-select");
|
|
33216
33408
|
} else {
|
|
33217
|
-
|
|
33409
|
+
if (type == "shipping") {
|
|
33410
|
+
var _selectedMembership$a;
|
|
33218
33411
|
|
|
33219
|
-
|
|
33220
|
-
|
|
33221
|
-
|
|
33222
|
-
|
|
33412
|
+
return lib_7({ ...state,
|
|
33413
|
+
addresses: action.payload,
|
|
33414
|
+
selectedAddressId: String((_selectedMembership$a = selectedMembership === null || selectedMembership === void 0 ? void 0 : selectedMembership.address_id) !== null && _selectedMembership$a !== void 0 ? _selectedMembership$a : getDefaultShippingAddress(action.payload).id)
|
|
33415
|
+
});
|
|
33416
|
+
} else {
|
|
33417
|
+
return lib_7({ ...state,
|
|
33418
|
+
addresses: action.payload,
|
|
33419
|
+
selectedBillingAddressId: String(getDefaultBillingAddress(action.payload).id)
|
|
33420
|
+
});
|
|
33421
|
+
}
|
|
33223
33422
|
}
|
|
33224
33423
|
|
|
33225
33424
|
case SHOW_ALERT:
|
|
@@ -33235,7 +33434,7 @@ const AddressSelectContainer = ({
|
|
|
33235
33434
|
case HANDLE_SUBMIT:
|
|
33236
33435
|
return lib_5({ ...state,
|
|
33237
33436
|
isSubmitting: true
|
|
33238
|
-
}, (state, dispatch) => submitAddress(state, dispatch));
|
|
33437
|
+
}, (state, dispatch) => type == "shipping" ? submitAddress(state, dispatch) : submitBillingAddress(state));
|
|
33239
33438
|
|
|
33240
33439
|
default:
|
|
33241
33440
|
return state;
|
|
@@ -33248,7 +33447,8 @@ const AddressSelectContainer = ({
|
|
|
33248
33447
|
type: LOAD_ADDRESSES,
|
|
33249
33448
|
payload: (_window$Pelcro$user$r = window.Pelcro.user.read().addresses) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : []
|
|
33250
33449
|
});
|
|
33251
|
-
}, []);
|
|
33450
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
33451
|
+
|
|
33252
33452
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33253
33453
|
style: { ...style
|
|
33254
33454
|
},
|
|
@@ -33266,25 +33466,35 @@ const AddressSelectContainer = ({
|
|
|
33266
33466
|
})));
|
|
33267
33467
|
};
|
|
33268
33468
|
|
|
33269
|
-
const AddressSelectList = (
|
|
33469
|
+
const AddressSelectList = ({
|
|
33470
|
+
type = "shipping"
|
|
33471
|
+
}) => {
|
|
33270
33472
|
const {
|
|
33271
33473
|
dispatch,
|
|
33272
33474
|
state: {
|
|
33273
33475
|
addresses,
|
|
33274
|
-
selectedAddressId
|
|
33476
|
+
selectedAddressId,
|
|
33477
|
+
selectedBillingAddressId
|
|
33275
33478
|
}
|
|
33276
33479
|
} = React.useContext(store$7);
|
|
33277
33480
|
|
|
33278
33481
|
const handleAddressSelect = event => {
|
|
33279
|
-
|
|
33280
|
-
|
|
33281
|
-
|
|
33282
|
-
|
|
33482
|
+
if (type == "shipping") {
|
|
33483
|
+
dispatch({
|
|
33484
|
+
type: SELECT_ADDRESS,
|
|
33485
|
+
payload: event.target.value
|
|
33486
|
+
});
|
|
33487
|
+
} else {
|
|
33488
|
+
dispatch({
|
|
33489
|
+
type: SELECT_BILLING_ADDRESS,
|
|
33490
|
+
payload: event.target.value
|
|
33491
|
+
});
|
|
33492
|
+
}
|
|
33283
33493
|
};
|
|
33284
33494
|
|
|
33285
33495
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33286
33496
|
className: "plc-overflow-y-auto plc-p-2 plc-max-h-80 pelcro-addresses-select-wrapper"
|
|
33287
|
-
}, addresses.map(address => address.type ===
|
|
33497
|
+
}, addresses.sort((a, b) => a.is_default === b.is_default ? 0 : a.is_default ? -1 : 1).map(address => address.type === type && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33288
33498
|
key: address.id,
|
|
33289
33499
|
className: "plc-p-4 plc-mb-4 last:plc-mb-0 plc-rounded plc-text-gray-900 pelcro-address-wrapper plc-bg-white plc-shadow-md_dark"
|
|
33290
33500
|
}, /*#__PURE__*/React__default['default'].createElement(Radio, {
|
|
@@ -33292,7 +33502,7 @@ const AddressSelectList = () => {
|
|
|
33292
33502
|
labelClassName: "plc-cursor-pointer plc-w-full plc-ml-0 plc-mr-2 plc-order-1",
|
|
33293
33503
|
id: `pelcro-address-select-${address.id}`,
|
|
33294
33504
|
name: "address",
|
|
33295
|
-
checked: selectedAddressId === String(address.id),
|
|
33505
|
+
checked: type == "shipping" ? selectedAddressId === String(address.id) : selectedBillingAddressId === String(address.id),
|
|
33296
33506
|
value: address.id,
|
|
33297
33507
|
onChange: handleAddressSelect
|
|
33298
33508
|
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
@@ -33309,13 +33519,15 @@ const AddressSelectList = () => {
|
|
|
33309
33519
|
const AddressSelectSubmit = ({
|
|
33310
33520
|
name,
|
|
33311
33521
|
onClick,
|
|
33522
|
+
type = "shipping",
|
|
33312
33523
|
...otherProps
|
|
33313
33524
|
}) => {
|
|
33314
33525
|
const {
|
|
33315
33526
|
dispatch,
|
|
33316
33527
|
state: {
|
|
33317
33528
|
selectedAddressId,
|
|
33318
|
-
isSubmitting
|
|
33529
|
+
isSubmitting,
|
|
33530
|
+
selectedBillingAddressId
|
|
33319
33531
|
}
|
|
33320
33532
|
} = React.useContext(store$7);
|
|
33321
33533
|
const {
|
|
@@ -33328,7 +33540,7 @@ const AddressSelectSubmit = ({
|
|
|
33328
33540
|
});
|
|
33329
33541
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
33330
33542
|
},
|
|
33331
|
-
disabled: selectedAddressId === "undefined" || selectedAddressId === null || !selectedAddressId,
|
|
33543
|
+
disabled: type == "shipping" ? selectedAddressId === "undefined" || selectedAddressId === null || !selectedAddressId : selectedBillingAddressId === "undefined" || selectedBillingAddressId === null || !selectedBillingAddressId,
|
|
33332
33544
|
isLoading: isSubmitting
|
|
33333
33545
|
}, otherProps), name !== null && name !== void 0 ? name : t("buttons.submit"));
|
|
33334
33546
|
};
|
|
@@ -33342,13 +33554,16 @@ const AddressSelectView = props => {
|
|
|
33342
33554
|
}, /*#__PURE__*/React__default['default'].createElement("form", {
|
|
33343
33555
|
action: "javascript:void(0);",
|
|
33344
33556
|
className: "plc-mt-2 pelcro-form"
|
|
33345
|
-
}, /*#__PURE__*/React__default['default'].createElement(AddressSelectContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), /*#__PURE__*/React__default['default'].createElement(AddressSelectList,
|
|
33557
|
+
}, /*#__PURE__*/React__default['default'].createElement(AddressSelectContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), /*#__PURE__*/React__default['default'].createElement(AddressSelectList, {
|
|
33558
|
+
type: props.type
|
|
33559
|
+
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33346
33560
|
className: "plc-flex plc-justify-center plc-mt-4"
|
|
33347
33561
|
}, /*#__PURE__*/React__default['default'].createElement(Link, {
|
|
33348
33562
|
id: "pelcro-add-address",
|
|
33349
33563
|
onClick: props.onAddNewAddress,
|
|
33350
33564
|
className: "plc-w-full plc-h-12 plc-flex plc-justify-center plc-border plc-items-center plc-border-solid plc-border-gray-300 plc-rounded plc-bg-white hover:plc-border-primary-800"
|
|
33351
33565
|
}, t("buttons.addAddress"))), /*#__PURE__*/React__default['default'].createElement(AddressSelectSubmit, {
|
|
33566
|
+
type: props.type,
|
|
33352
33567
|
role: "submit",
|
|
33353
33568
|
className: "plc-mt-4 plc-w-full",
|
|
33354
33569
|
name: t("buttons.selectAddress"),
|
|
@@ -33416,6 +33631,78 @@ const AddressSelectModal = ({
|
|
|
33416
33631
|
};
|
|
33417
33632
|
AddressSelectModal.viewId = "address-select";
|
|
33418
33633
|
|
|
33634
|
+
const BillingAddressSelectModal = ({
|
|
33635
|
+
onDisplay,
|
|
33636
|
+
onClose,
|
|
33637
|
+
...otherProps
|
|
33638
|
+
}) => {
|
|
33639
|
+
const {
|
|
33640
|
+
switchView,
|
|
33641
|
+
// switchToPaymentView,
|
|
33642
|
+
// resetView,
|
|
33643
|
+
switchToCheckoutForm,
|
|
33644
|
+
flow
|
|
33645
|
+
} = usePelcro();
|
|
33646
|
+
const {
|
|
33647
|
+
t
|
|
33648
|
+
} = useTranslation("address");
|
|
33649
|
+
|
|
33650
|
+
const onSuccess = selectedBillingAddressId => {
|
|
33651
|
+
var _otherProps$onSuccess;
|
|
33652
|
+
|
|
33653
|
+
(_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, selectedBillingAddressId);
|
|
33654
|
+
|
|
33655
|
+
switch (flow) {
|
|
33656
|
+
case "createPaymentSource":
|
|
33657
|
+
switchView("payment-method-create");
|
|
33658
|
+
break;
|
|
33659
|
+
|
|
33660
|
+
case "deletePaymentSource":
|
|
33661
|
+
switchView("payment-method-delete");
|
|
33662
|
+
break;
|
|
33663
|
+
|
|
33664
|
+
default:
|
|
33665
|
+
switchToCheckoutForm();
|
|
33666
|
+
break;
|
|
33667
|
+
}
|
|
33668
|
+
};
|
|
33669
|
+
|
|
33670
|
+
const onAddNewAddress = () => {
|
|
33671
|
+
switchView("billing-address-create");
|
|
33672
|
+
}; // const onGiftRedemptionSuccess = () => {
|
|
33673
|
+
// otherProps.onGiftRedemptionSuccess?.();
|
|
33674
|
+
// switchView("subscription-success");
|
|
33675
|
+
// };
|
|
33676
|
+
// // FIXME: implement me
|
|
33677
|
+
// const onMembershipAdressUpdateSuccess = () => {
|
|
33678
|
+
// otherProps.onMembershipAdressUpdateSuccess?.();
|
|
33679
|
+
// resetView();
|
|
33680
|
+
// };
|
|
33681
|
+
|
|
33682
|
+
|
|
33683
|
+
return /*#__PURE__*/React__default['default'].createElement(Modal, {
|
|
33684
|
+
onDisplay: onDisplay,
|
|
33685
|
+
onClose: onClose,
|
|
33686
|
+
id: "pelcro-address-select-modal"
|
|
33687
|
+
}, /*#__PURE__*/React__default['default'].createElement(ModalHeader, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33688
|
+
className: "plc-text-left plc-text-gray-900 pelcro-title-wrapper plc-flex-1 plc-flex plc-flex-col plc-justify-center"
|
|
33689
|
+
}, /*#__PURE__*/React__default['default'].createElement("h4", {
|
|
33690
|
+
className: "plc-text-xl plc-font-bold"
|
|
33691
|
+
}, t("selectAddressTitle")), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
33692
|
+
className: "plc-text-sm"
|
|
33693
|
+
}, t("selectAddressSubtitle")))), /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(AddressSelectView, Object.assign({
|
|
33694
|
+
onAddNewAddress: onAddNewAddress
|
|
33695
|
+
}, otherProps, {
|
|
33696
|
+
type: "billing",
|
|
33697
|
+
onSuccess: onSuccess // onGiftRedemptionSuccess={onGiftRedemptionSuccess}
|
|
33698
|
+
// onMembershipAdressUpdateSuccess={
|
|
33699
|
+
// onMembershipAdressUpdateSuccess
|
|
33700
|
+
// }
|
|
33701
|
+
|
|
33702
|
+
}))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null));
|
|
33703
|
+
};
|
|
33704
|
+
BillingAddressSelectModal.viewId = "billing-address-select";
|
|
33705
|
+
|
|
33419
33706
|
const moveDefaultPaymentMethodToStart = paymentMethods => {
|
|
33420
33707
|
var _window$Pelcro$user$r;
|
|
33421
33708
|
|
|
@@ -33553,7 +33840,7 @@ const PaymentMethodSelectList = () => {
|
|
|
33553
33840
|
const isSelected = selectedPaymentMethodId === String(paymentMethod.id);
|
|
33554
33841
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
33555
33842
|
key: paymentMethod.id,
|
|
33556
|
-
className: `plc-p-2 plc-pl-4 plc-shadow-md plc-text-gray-900 plc-rounded pelcro-payment-method-wrapper ${isSelected ? "plc-ring-2 plc-ring-primary-400" : "plc-ring-1 plc-ring-gray-200"}`
|
|
33843
|
+
className: `plc-p-2 plc-pl-4 plc-shadow-md plc-text-gray-900 plc-rounded plc-min-h-14 plc-flex plc-items-center pelcro-payment-method-wrapper ${isSelected ? "plc-ring-2 plc-ring-primary-400" : "plc-ring-1 plc-ring-gray-200"}`
|
|
33557
33844
|
}, /*#__PURE__*/React__default['default'].createElement(Radio, {
|
|
33558
33845
|
className: "plc-flex plc-items-center pelcro-select-payment-method-radio",
|
|
33559
33846
|
labelClassName: "plc-flex plc-items-center plc-space-x-2 plc-cursor-pointer plc-w-full",
|
|
@@ -36735,11 +37022,19 @@ const AddressesMenu = props => {
|
|
|
36735
37022
|
};
|
|
36736
37023
|
|
|
36737
37024
|
const displayAddressEdit = e => {
|
|
36738
|
-
const
|
|
37025
|
+
const addressId = e.currentTarget.dataset.key;
|
|
37026
|
+
const addressType = e.currentTarget.dataset.type;
|
|
36739
37027
|
set({
|
|
36740
|
-
addressIdToEdit:
|
|
37028
|
+
addressIdToEdit: addressId
|
|
36741
37029
|
});
|
|
36742
|
-
|
|
37030
|
+
|
|
37031
|
+
if (addressType === "shipping") {
|
|
37032
|
+
return switchView("address-edit");
|
|
37033
|
+
}
|
|
37034
|
+
|
|
37035
|
+
if (addressType === "billing") {
|
|
37036
|
+
return switchView("billing-address-edit");
|
|
37037
|
+
}
|
|
36743
37038
|
};
|
|
36744
37039
|
|
|
36745
37040
|
return /*#__PURE__*/React__default['default'].createElement(Card, {
|
|
@@ -36762,30 +37057,46 @@ const AddressesItems = props => {
|
|
|
36762
37057
|
|
|
36763
37058
|
const {
|
|
36764
37059
|
t
|
|
36765
|
-
} = useTranslation("dashboard");
|
|
36766
|
-
|
|
36767
|
-
const
|
|
36768
|
-
|
|
36769
|
-
|
|
36770
|
-
|
|
36771
|
-
|
|
36772
|
-
|
|
36773
|
-
|
|
36774
|
-
|
|
36775
|
-
|
|
36776
|
-
|
|
36777
|
-
|
|
36778
|
-
|
|
36779
|
-
|
|
36780
|
-
|
|
36781
|
-
|
|
36782
|
-
|
|
37060
|
+
} = useTranslation("dashboard"); // const [selectedAddressId, setSelectedAddressId] = useState(null);
|
|
37061
|
+
|
|
37062
|
+
const addresses = (_window$Pelcro$user$r = window.Pelcro.user.read().addresses) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : []; // useEffect(() => {
|
|
37063
|
+
// setSelectedAddressId(
|
|
37064
|
+
// String(getDefaultShippingAddress(addresses)?.id)
|
|
37065
|
+
// );
|
|
37066
|
+
// }, []);
|
|
37067
|
+
// const getDefaultShippingAddress = (addresses) => {
|
|
37068
|
+
// return (
|
|
37069
|
+
// addresses.find(
|
|
37070
|
+
// (address) => address.type == "shipping" && address.is_default
|
|
37071
|
+
// ) || false
|
|
37072
|
+
// );
|
|
37073
|
+
// };
|
|
37074
|
+
// const getDefaultBillingAddress = (addresses) => {
|
|
37075
|
+
// return (
|
|
37076
|
+
// addresses.find(
|
|
37077
|
+
// (address) => address.type == "billing" && address.is_default
|
|
37078
|
+
// ) || false
|
|
37079
|
+
// );
|
|
37080
|
+
// };
|
|
37081
|
+
// const moveDefaultAddressToStart = (addresses) => {
|
|
37082
|
+
// const defaultShippingAddress =
|
|
37083
|
+
// getDefaultShippingAddress(addresses);
|
|
37084
|
+
// const defaultBillingAddress = getDefaultBillingAddress(addresses);
|
|
37085
|
+
// const addressesWithoutDefault = addresses.filter(
|
|
37086
|
+
// (address) => !address.is_default
|
|
37087
|
+
// );
|
|
37088
|
+
// return [
|
|
37089
|
+
// defaultShippingAddress,
|
|
37090
|
+
// defaultBillingAddress,
|
|
37091
|
+
// ...addressesWithoutDefault
|
|
37092
|
+
// ];
|
|
37093
|
+
// };
|
|
37094
|
+
// const addresses = moveDefaultAddressToStart(allAddresses);
|
|
36783
37095
|
|
|
36784
|
-
const addresses = moveDefaultAddressToStart(allAddresses);
|
|
36785
37096
|
if (addresses.length === 0) return null;
|
|
36786
|
-
return addresses.
|
|
37097
|
+
return addresses.sort((a, b) => a.is_default === b.is_default ? 0 : a.is_default ? -1 : 1).map((address, index) => /*#__PURE__*/React__default['default'].createElement("div", {
|
|
36787
37098
|
key: address.id,
|
|
36788
|
-
className:
|
|
37099
|
+
className: "plc-py-2 plc-px-4 plc-mt-5 plc-flex plc-items-center plc-justify-between last:plc-mb-0 plc-rounded plc-text-gray-900 pelcro-address-wrapper plc-bg-white plc-shadow-md_dark"
|
|
36789
37100
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
36790
37101
|
className: "plc-flex-1 plc-relative"
|
|
36791
37102
|
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
@@ -36796,14 +37107,17 @@ const AddressesItems = props => {
|
|
|
36796
37107
|
className: "pelcro-address-line1 plc-text-sm plc-mt-2"
|
|
36797
37108
|
}, address.line1), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
36798
37109
|
className: "pelcro-address-country plc-text-sm"
|
|
36799
|
-
}, address.city, ", ", address.state_name, " ", address.postal_code, ", ", address.country_name)),
|
|
36800
|
-
className: "plc-rounded-full plc-bg-gray-
|
|
37110
|
+
}, address.city, ", ", address.state_name, " ", address.postal_code, ", ", address.country_name)), /*#__PURE__*/React__default['default'].createElement("span", {
|
|
37111
|
+
className: "plc-rounded-full plc-bg-gray-200 plc-text-black plc-inline-flex plc-items-start plc-py-1 plc-px-4 plc-text-sm plc-capitalize"
|
|
37112
|
+
}, address.type === "shipping" ? t("labels.shipping") : t("labels.billing")), address.is_default && /*#__PURE__*/React__default['default'].createElement("span", {
|
|
37113
|
+
className: "plc-rounded-full plc-bg-gray-800 plc-text-white plc-inline-flex plc-items-start plc-py-1 plc-px-4 plc-text-sm plc-mr-4 plc-ml-2"
|
|
36801
37114
|
}, t("labels.default")), /*#__PURE__*/React__default['default'].createElement(Button, {
|
|
36802
37115
|
variant: "icon",
|
|
36803
37116
|
className: "plc-text-gray-500",
|
|
36804
37117
|
icon: /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
|
|
36805
37118
|
id: "pelcro-button-update-address-" + index,
|
|
36806
37119
|
"data-key": address.id,
|
|
37120
|
+
"data-type": address.type,
|
|
36807
37121
|
onClick: props === null || props === void 0 ? void 0 : props.displayAddressEdit
|
|
36808
37122
|
})));
|
|
36809
37123
|
};
|
|
@@ -36919,7 +37233,7 @@ const PaymentCardsItems = props => {
|
|
|
36919
37233
|
|
|
36920
37234
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
36921
37235
|
key: "dashboard-source-" + source.id,
|
|
36922
|
-
className: "plc-relative plc-py-4 plc-px-6 plc-mt-5 plc-flex plc-items-center plc-justify-between last:plc-mb-0 plc-rounded plc-text-gray-900 plc-bg-white plc-shadow-md_dark"
|
|
37236
|
+
className: "plc-relative plc-py-4 plc-px-6 plc-mt-5 plc-min-h-16 plc-flex plc-items-center plc-justify-between last:plc-mb-0 plc-rounded plc-text-gray-900 plc-bg-white plc-shadow-md_dark"
|
|
36923
37237
|
}, source.is_default && /*#__PURE__*/React__default['default'].createElement("span", {
|
|
36924
37238
|
className: "plc-absolute plc--top-3 plc-right-3 plc-rounded-full plc-bg-gray-800 plc-text-white plc-inline-flex plc-h-7 plc-my-auto plc-items-start plc-py-1 plc-px-4 plc-text-sm"
|
|
36925
37239
|
}, t("labels.default")), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
@@ -41999,6 +42313,9 @@ exports.ApplyCouponButton = ApplyCouponButton;
|
|
|
41999
42313
|
exports.Auth0LoginButton = Auth0LoginButton;
|
|
42000
42314
|
exports.Badge = Badge;
|
|
42001
42315
|
exports.BankRedirection = BankRedirection;
|
|
42316
|
+
exports.BillingAddressCreateModal = BillingAddressCreateModal;
|
|
42317
|
+
exports.BillingAddressSelectModal = BillingAddressSelectModal;
|
|
42318
|
+
exports.BillingAddressUpdateModal = BillingAddressUpdateModal;
|
|
42002
42319
|
exports.Button = Button;
|
|
42003
42320
|
exports.Card = Card;
|
|
42004
42321
|
exports.CartContainer = CartContainer;
|
|
@@ -42167,6 +42484,7 @@ exports.RegisterPassword = RegisterPassword;
|
|
|
42167
42484
|
exports.RegisterView = RegisterView;
|
|
42168
42485
|
exports.Select = Select;
|
|
42169
42486
|
exports.SelectModal = SelectModalWithHook;
|
|
42487
|
+
exports.SelectedAddress = SelectedAddress;
|
|
42170
42488
|
exports.SelectedPaymentMethod = SelectedPaymentMethod;
|
|
42171
42489
|
exports.ShopPurchaseButton = ShopPurchaseButton;
|
|
42172
42490
|
exports.ShopSelectProductButton = ShopSelectProductButton;
|