@zonos/elements 1.2.1 → 1.2.2
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/{cart-7b70853c.js → cart-d4b52ae8.js} +1 -1
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{localization-387a8a65.js → localization-d7fe7290.js} +40 -13
- package/dist/cjs/{submitGtag-bf6e7c5e.js → submitGtag-d65003f9.js} +1 -1
- package/dist/cjs/zonos-address_2.cjs.entry.js +7 -2
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +6 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +4 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-flag_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +15 -7
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-payment.cjs.entry.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +3 -5
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +15 -7
- package/dist/collection/components/store/hello/localization.js +31 -9
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +5 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +9 -4
- package/dist/components/localization.js +40 -13
- package/dist/components/zonos-address2.js +5 -0
- package/dist/components/zonos-checkout.js +1 -1
- package/dist/components/zonos-hello-dialog2.js +15 -7
- package/dist/components/zonos-shipping2.js +4 -5
- package/dist/esm/{cart-07091d2a.js → cart-e1b93711.js} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/{localization-b3c2a9a9.js → localization-f3828793.js} +40 -13
- package/dist/esm/{submitGtag-c0b655ad.js → submitGtag-a901ece5.js} +1 -1
- package/dist/esm/zonos-address_2.entry.js +7 -2
- package/dist/esm/zonos-cart-items_10.entry.js +6 -7
- package/dist/esm/zonos-checkout.entry.js +4 -4
- package/dist/esm/zonos-controller.entry.js +2 -2
- package/dist/esm/zonos-country-flag_4.entry.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +15 -7
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-payment.entry.js +2 -2
- package/dist/esm-es5/{cart-07091d2a.js → cart-e1b93711.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{localization-b3c2a9a9.js → localization-f3828793.js} +1 -1
- package/dist/esm-es5/{submitGtag-c0b655ad.js → submitGtag-a901ece5.js} +1 -1
- package/dist/esm-es5/zonos-address_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-payment.entry.js +1 -1
- package/dist/scripts/loadZonos.js +3 -3
- package/dist/scripts/zonos.js +3 -3
- package/dist/types/components/store/hello/localization.d.ts +2 -0
- package/dist/types/components/utils/api/getExchangeRate.d.ts +9 -3
- package/dist/types/components/utils/changeDeepProperty.d.ts +1 -1
- package/dist/types/components/utils/changeDeepPropertyAtIndex.d.ts +1 -1
- package/dist/types/types/generated/graphql.customer.types.d.ts +1 -0
- package/dist/types/types/generated/graphql.customer.types.ts +1 -0
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-37db3842.system.entry.js → p-05256415.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-42ba069d.system.js → p-164fae93.system.js} +1 -1
- package/dist/zonos-elements/{p-30fd29fb.js → p-25db3885.js} +1 -1
- package/dist/zonos-elements/{p-9dc9cbc8.entry.js → p-28681677.entry.js} +1 -1
- package/dist/zonos-elements/{p-d43749bd.entry.js → p-34a49bce.entry.js} +1 -1
- package/dist/zonos-elements/p-365970ff.entry.js +1 -0
- package/dist/zonos-elements/p-3f3fbcea.entry.js +1 -0
- package/dist/zonos-elements/p-40083e93.system.entry.js +1 -0
- package/dist/zonos-elements/{p-98105ede.entry.js → p-40778e43.entry.js} +1 -1
- package/dist/zonos-elements/{p-b64bbf38.system.js → p-53649e16.system.js} +1 -1
- package/dist/zonos-elements/{p-0a788f68.entry.js → p-5d7ffddb.entry.js} +1 -1
- package/dist/zonos-elements/{p-87f324c5.entry.js → p-60821b2a.entry.js} +1 -1
- package/dist/zonos-elements/{p-bb36a9f8.js → p-770c959e.js} +1 -1
- package/dist/zonos-elements/{p-0f7233fd.system.entry.js → p-81c699f7.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f23749e4.system.js → p-8aabbb9b.system.js} +1 -1
- package/dist/zonos-elements/{p-79f9e330.system.js → p-8db8cc05.system.js} +1 -1
- package/dist/zonos-elements/{p-9b86e655.system.entry.js → p-a3641931.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a20b97e9.system.entry.js → p-aca66238.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c28157ec.system.entry.js → p-c8ad044e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-343071d5.entry.js → p-cc070c1c.entry.js} +1 -1
- package/dist/zonos-elements/{p-4524a84f.system.entry.js → p-cc1c785c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-23b0b4a2.system.entry.js → p-de9d8a4f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-6df1eaee.js → p-f7875c40.js} +1 -1
- package/dist/zonos-elements/p-f8491335.system.js +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-2c20c082.entry.js +0 -1
- package/dist/zonos-elements/p-37fc9f6b.entry.js +0 -1
- package/dist/zonos-elements/p-9adf546f.system.entry.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
4
|
-
const localization = require('./localization-
|
|
4
|
+
const localization = require('./localization-d7fe7290.js');
|
|
5
5
|
const isDarkColor = require('./isDarkColor-f3446afd.js');
|
|
6
6
|
const getBorderRadius = require('./getBorderRadius-fdd605c6.js');
|
|
7
7
|
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const cart = require('./cart-
|
|
5
|
+
const cart = require('./cart-d4b52ae8.js');
|
|
6
6
|
require('./zonosStore-a430ec5b.js');
|
|
7
7
|
require('./index-9542d2e7.js');
|
|
8
|
-
require('./localization-
|
|
8
|
+
require('./localization-d7fe7290.js');
|
|
9
9
|
require('./isDarkColor-f3446afd.js');
|
|
10
10
|
require('./getBorderRadius-fdd605c6.js');
|
|
11
11
|
|
|
@@ -3198,18 +3198,23 @@ const getCountryLandedCost = async (countryCode) => {
|
|
|
3198
3198
|
|
|
3199
3199
|
const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCurrency, }) => {
|
|
3200
3200
|
var _a;
|
|
3201
|
+
// If source currency matches target currency (US -> US) and is not a guaranteed rate, return null
|
|
3202
|
+
if (sourceCurrency === targetCurrency && !isGuaranteed) {
|
|
3203
|
+
return { exchangeRate: null, maxAge: null };
|
|
3204
|
+
}
|
|
3201
3205
|
const url = `${"https://v1.route.js.zonos.com"}/api/exchange-rates?sourceCurrency=${sourceCurrency}&targetCurrency=${targetCurrency}&isGuaranteed=${isGuaranteed}&country=${country}}`;
|
|
3202
3206
|
const { errors, json } = await handleFetch(url);
|
|
3203
3207
|
if (errors.length || !json) {
|
|
3204
3208
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
3205
|
-
return null;
|
|
3209
|
+
return { exchangeRate: null, maxAge: null };
|
|
3206
3210
|
}
|
|
3207
|
-
const { rate, targetFormat } = json.exchangeRateCreate;
|
|
3211
|
+
const { maxAge, rate, targetFormat } = json.exchangeRateCreate;
|
|
3208
3212
|
if (rate) {
|
|
3209
3213
|
sessionStorage.setItem(country + '_rate', JSON.stringify(rate));
|
|
3210
|
-
|
|
3214
|
+
const exchangeRate = { rate, targetFormat };
|
|
3215
|
+
return { exchangeRate, maxAge };
|
|
3211
3216
|
}
|
|
3212
|
-
return null;
|
|
3217
|
+
return { exchangeRate: null, maxAge: null };
|
|
3213
3218
|
};
|
|
3214
3219
|
|
|
3215
3220
|
const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
@@ -3467,23 +3472,45 @@ const { state: localizationStore } = zonosStore.createStore({
|
|
|
3467
3472
|
shippingZoneCountries: null,
|
|
3468
3473
|
targetCurrency: 'USD',
|
|
3469
3474
|
});
|
|
3475
|
+
const triggerGetExchangeRate = async (isGuaranteed) => {
|
|
3476
|
+
const { exchangeRate, maxAge } = await getExchangeRate({
|
|
3477
|
+
country: localizationStore.selectedCountryCode,
|
|
3478
|
+
isGuaranteed,
|
|
3479
|
+
sourceCurrency: zonosStore.zonosStore.sourceCurrency,
|
|
3480
|
+
targetCurrency: localizationStore.targetCurrency,
|
|
3481
|
+
});
|
|
3482
|
+
if (exchangeRate) {
|
|
3483
|
+
localizationStore.exchangeRate = exchangeRate;
|
|
3484
|
+
currencyDisplay();
|
|
3485
|
+
}
|
|
3486
|
+
return { maxAge };
|
|
3487
|
+
};
|
|
3488
|
+
// This recursive function is for users who step away from their computer and come back needing a new exchange rate
|
|
3489
|
+
const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
|
|
3490
|
+
if (localizationStore.exchangeRateTimeout) {
|
|
3491
|
+
clearTimeout(localizationStore.exchangeRateTimeout);
|
|
3492
|
+
}
|
|
3493
|
+
// maxAge comes in seconds, convert to milliseconds
|
|
3494
|
+
const defaultMaxAge = 5 * 60;
|
|
3495
|
+
const maxAgeToUse = maxAge || defaultMaxAge;
|
|
3496
|
+
// Recursively set timeouts to get new exchange rates when the current one expires
|
|
3497
|
+
localizationStore.exchangeRateTimeout = setTimeout(async () => {
|
|
3498
|
+
const { maxAge: newMaxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
3499
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge: newMaxAge });
|
|
3500
|
+
}, maxAgeToUse * 1000);
|
|
3501
|
+
};
|
|
3470
3502
|
const getNewLocalization = async () => {
|
|
3471
3503
|
log('get new localization store');
|
|
3472
3504
|
const { isShippableCountry, selectedCountryCode } = localizationStore;
|
|
3473
|
-
const isGuaranteed = zonosStore.zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
3474
3505
|
if (zonosStore.zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
|
|
3475
3506
|
!isShippableCountry ||
|
|
3476
3507
|
!selectedCountryCode) {
|
|
3477
3508
|
return;
|
|
3478
3509
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
isGuaranteed
|
|
3482
|
-
|
|
3483
|
-
targetCurrency: localizationStore.targetCurrency,
|
|
3484
|
-
});
|
|
3485
|
-
if (localizationStore.exchangeRate) {
|
|
3486
|
-
currencyDisplay();
|
|
3510
|
+
if (zonosStore.zonosStore.sourceCurrency !== localizationStore.targetCurrency) {
|
|
3511
|
+
const isGuaranteed = zonosStore.zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
3512
|
+
const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
3513
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
3487
3514
|
}
|
|
3488
3515
|
localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
|
|
3489
3516
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
4
|
-
const localization = require('./localization-
|
|
4
|
+
const localization = require('./localization-d7fe7290.js');
|
|
5
5
|
|
|
6
6
|
const checkoutBreakpoint = 890;
|
|
7
7
|
const isCheckoutMobile = (isMobile) => {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d4b52ae8.js');
|
|
7
|
+
const localization = require('./localization-d7fe7290.js');
|
|
8
8
|
require('./zonosStore-a430ec5b.js');
|
|
9
9
|
require('./isDarkColor-f3446afd.js');
|
|
10
10
|
require('./getBorderRadius-fdd605c6.js');
|
|
@@ -39,6 +39,11 @@ const ZonosAddress = class {
|
|
|
39
39
|
? Object.values(shippableCountries).map(country => country.code)
|
|
40
40
|
: [],
|
|
41
41
|
contacts: this.defaultAddress ? [this.defaultAddress] : undefined,
|
|
42
|
+
defaultValues: {
|
|
43
|
+
address: {
|
|
44
|
+
country: localization.localizationStore.selectedCountryCode || 'AL',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
42
47
|
display: {
|
|
43
48
|
name: 'split',
|
|
44
49
|
},
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d4b52ae8.js');
|
|
7
|
+
const localization = require('./localization-d7fe7290.js');
|
|
8
8
|
const getBorderRadius = require('./getBorderRadius-fdd605c6.js');
|
|
9
|
-
const submitGtag = require('./submitGtag-
|
|
9
|
+
const submitGtag = require('./submitGtag-d65003f9.js');
|
|
10
10
|
const classes = require('./classes-b7918f56.js');
|
|
11
11
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
12
12
|
require('./isDarkColor-f3446afd.js');
|
|
@@ -468,9 +468,8 @@ const ZonosShipping = class {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
render() {
|
|
471
|
-
var _a
|
|
472
|
-
const
|
|
473
|
-
const serviceLevels = (_b = cart.cartStore.shippingData) === null || _b === void 0 ? void 0 : _b.flatMap((item) => {
|
|
471
|
+
var _a;
|
|
472
|
+
const serviceLevels = (_a = cart.cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.flatMap((item) => {
|
|
474
473
|
var _a, _b;
|
|
475
474
|
const { expectedDate, maxTransit, minTransit } = cart.cartStoreGetShippingTransitInfo(item);
|
|
476
475
|
const sublabel = expectedDate
|
|
@@ -491,7 +490,7 @@ const ZonosShipping = class {
|
|
|
491
490
|
value: item.id,
|
|
492
491
|
};
|
|
493
492
|
});
|
|
494
|
-
return (index.h(index.Host, { class: "zonos--shipping zonos--elements" }, index.h("div", { class: "zonos--group" }, index.h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, localization.translate('Shipping information')), index.h("zonos-text", { class: "zonos--shipping-method-title", type: "semiBoldLabel" }, localization.translate('Shipping method')), !(serviceLevels === null || serviceLevels === void 0 ? void 0 : serviceLevels.length) ? (index.h("zonos-banner", { bannerTitle: "No shipping methods found - try editing your address or contacting support if the error persists", intent: "error" })) : (index.h("zonos-shipping-rich-radio", { items: serviceLevels || [], onRadioSelected: e => this.handleRadioSelected(e) }))
|
|
493
|
+
return (index.h(index.Host, { class: "zonos--shipping zonos--elements" }, index.h("div", { class: "zonos--group" }, index.h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, localization.translate('Shipping information')), index.h("zonos-text", { class: "zonos--shipping-method-title", type: "semiBoldLabel" }, localization.translate('Shipping method')), !(serviceLevels === null || serviceLevels === void 0 ? void 0 : serviceLevels.length) ? (index.h("zonos-banner", { bannerTitle: "No shipping methods found - try editing your address or contacting support if the error persists", intent: "error" })) : (index.h("zonos-shipping-rich-radio", { items: serviceLevels || [], onRadioSelected: e => this.handleRadioSelected(e) }))), index.h("zonos-button", { backgroundColor: this.submitBtnColor, "is-disabled": this.disabled, loading: this.continueLoading, onClick: () => this.continueClickHandler(), size: "lg",
|
|
495
494
|
// use primary type when on mobile mode
|
|
496
495
|
variant: this.submitBtnType }, localization.translate('Go to payment'))));
|
|
497
496
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d4b52ae8.js');
|
|
7
|
+
const localization = require('./localization-d7fe7290.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
9
|
-
const submitGtag = require('./submitGtag-
|
|
9
|
+
const submitGtag = require('./submitGtag-d65003f9.js');
|
|
10
10
|
const classes = require('./classes-b7918f56.js');
|
|
11
11
|
const getBorderRadius = require('./getBorderRadius-fdd605c6.js');
|
|
12
12
|
const isDarkColor = require('./isDarkColor-f3446afd.js');
|
|
@@ -20,7 +20,7 @@ const MessageIcon = `<svg width="18" height="18" viewBox="0 0 18 18" fill="none"
|
|
|
20
20
|
|
|
21
21
|
const RemoveIcon = `<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>`;
|
|
22
22
|
|
|
23
|
-
const zonosCheckoutCss = ".sc-zonos-checkout-h{font-family:Inter;display:block}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-48) var(--amino-space-56)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0);padding-bottom:var(--amino-space-80)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--back-button.sc-zonos-checkout{margin-bottom:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-
|
|
23
|
+
const zonosCheckoutCss = ".sc-zonos-checkout-h{font-family:Inter;display:block}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-48) var(--amino-space-56)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0);padding-bottom:var(--amino-space-80)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--back-button.sc-zonos-checkout{margin-bottom:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-align:center;align-items:center;position:absolute;bottom:var(--amino-space-32);right:var(--amino-space-56);gap:var(--amino-space-8)}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--amino-space-16);margin-top:var(--amino-space-24);border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}.mobile.sc-zonos-checkout-h .zonos--footer.sc-zonos-checkout{bottom:0;left:0;padding:var(--amino-space-12);position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background-color:var(--amino-gray-0)}";
|
|
24
24
|
|
|
25
25
|
const ZonosCheckout = class {
|
|
26
26
|
constructor(hostRef) {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d4b52ae8.js');
|
|
7
|
+
const localization = require('./localization-d7fe7290.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
9
9
|
require('./isDarkColor-f3446afd.js');
|
|
10
10
|
require('./getBorderRadius-fdd605c6.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const localization = require('./localization-
|
|
6
|
+
const localization = require('./localization-d7fe7290.js');
|
|
7
7
|
const classes = require('./classes-b7918f56.js');
|
|
8
8
|
const isDarkColor = require('./isDarkColor-f3446afd.js');
|
|
9
9
|
require('./zonosStore-a430ec5b.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const localization = require('./localization-
|
|
6
|
+
const localization = require('./localization-d7fe7290.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
8
8
|
const classes = require('./classes-b7918f56.js');
|
|
9
9
|
const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-2855491b.js');
|
|
@@ -82,18 +82,26 @@ const ZonosHelloDialog = class {
|
|
|
82
82
|
const { countryLandedCost, selectedCountryCode } = localization.localizationStore;
|
|
83
83
|
// Our Robby API spells deminimis wrong here
|
|
84
84
|
const dutyDeminimis = (countryLandedCost === null || countryLandedCost === void 0 ? void 0 : countryLandedCost.dutyDeminimus)
|
|
85
|
-
? localization.
|
|
85
|
+
? localization.currencyFormat(countryLandedCost.dutyDeminimus)
|
|
86
86
|
: null;
|
|
87
|
+
// If Canada, use 40 CAD (courier duty de minimis)
|
|
88
|
+
const dutyDeminimisToUse = localization.localizationStore.selectedCountryCode === 'CA'
|
|
89
|
+
? localization.currencyFormat(40)
|
|
90
|
+
: dutyDeminimis;
|
|
87
91
|
// If deminimis is undefined or null, assume it's $0
|
|
88
|
-
const dutyDeMinimisMessage =
|
|
89
|
-
? `${localization.translate('Spend')} ${
|
|
92
|
+
const dutyDeMinimisMessage = dutyDeminimisToUse
|
|
93
|
+
? `${localization.translate('Spend')} ${dutyDeminimisToUse} ${localization.translate('duty free')}`
|
|
90
94
|
: localization.translate('Duties will apply to all orders');
|
|
91
95
|
// Our Robby API spells deminimis wrong here
|
|
92
96
|
const taxDeminimis = (countryLandedCost === null || countryLandedCost === void 0 ? void 0 : countryLandedCost.vatTaxDeminimus)
|
|
93
|
-
? localization.
|
|
97
|
+
? localization.currencyFormat(countryLandedCost.vatTaxDeminimus)
|
|
94
98
|
: null;
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
// If Canada, use 150 CAD (courier tax de minimis)
|
|
100
|
+
const taxDeminimisToUse = localization.localizationStore.selectedCountryCode === 'CA'
|
|
101
|
+
? localization.currencyFormat(150)
|
|
102
|
+
: taxDeminimis;
|
|
103
|
+
const taxDeMinimisMessage = taxDeminimisToUse
|
|
104
|
+
? `${localization.translate('Spend')} ${taxDeminimisToUse} ${localization.translate('tax free')}`
|
|
97
105
|
: localization.translate('Taxes will apply to all orders');
|
|
98
106
|
const animateLeft = this.animateFromLeftOverride ||
|
|
99
107
|
(this.dialogRef && getHasMoreSpaceOnRight.getHasMoreSpaceOnRight(this.dialogRef));
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
6
|
const zonosStore = require('./zonosStore-a430ec5b.js');
|
|
7
|
-
const localization = require('./localization-
|
|
7
|
+
const localization = require('./localization-d7fe7290.js');
|
|
8
8
|
const classes = require('./classes-b7918f56.js');
|
|
9
9
|
const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-2855491b.js');
|
|
10
10
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9542d2e7.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-d4b52ae8.js');
|
|
7
7
|
require('./zonosStore-a430ec5b.js');
|
|
8
|
-
require('./localization-
|
|
8
|
+
require('./localization-d7fe7290.js');
|
|
9
9
|
require('./isDarkColor-f3446afd.js');
|
|
10
10
|
require('./getBorderRadius-fdd605c6.js');
|
|
11
11
|
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
}
|
|
108
108
|
:host .zonos--right .zonos--close-button {
|
|
109
109
|
position: absolute;
|
|
110
|
-
right: var(--amino-space-
|
|
111
|
-
top: var(--amino-space-
|
|
110
|
+
right: var(--amino-space-24);
|
|
111
|
+
top: var(--amino-space-24);
|
|
112
112
|
}
|
|
113
113
|
:host .zonos--footer {
|
|
114
114
|
display: flex;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
2
|
import { cartStore, cartStoreGetShippingTransitInfo, cartStoreUpdateSelectedShippingOption, } from "../../../store/checkout/cart";
|
|
3
|
-
import { stripeStore } from "../../../store/checkout/stripe";
|
|
4
3
|
import { translate } from "../../../store/translationStore";
|
|
5
4
|
import { formatCurrency } from "../../../utils/formatCurrency";
|
|
6
5
|
import { submitGtag } from "../../../utils/submitGtag";
|
|
@@ -42,9 +41,8 @@ export class ZonosShipping {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
render() {
|
|
45
|
-
var _a
|
|
46
|
-
const
|
|
47
|
-
const serviceLevels = (_b = cartStore.shippingData) === null || _b === void 0 ? void 0 : _b.flatMap((item) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const serviceLevels = (_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.flatMap((item) => {
|
|
48
46
|
var _a, _b;
|
|
49
47
|
const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(item);
|
|
50
48
|
const sublabel = expectedDate
|
|
@@ -65,7 +63,7 @@ export class ZonosShipping {
|
|
|
65
63
|
value: item.id,
|
|
66
64
|
};
|
|
67
65
|
});
|
|
68
|
-
return (h(Host, { class: "zonos--shipping zonos--elements" }, h("div", { class: "zonos--group" }, h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, translate('Shipping information')), h("zonos-text", { class: "zonos--shipping-method-title", type: "semiBoldLabel" }, translate('Shipping method')), !(serviceLevels === null || serviceLevels === void 0 ? void 0 : serviceLevels.length) ? (h("zonos-banner", { bannerTitle: "No shipping methods found - try editing your address or contacting support if the error persists", intent: "error" })) : (h("zonos-shipping-rich-radio", { items: serviceLevels || [], onRadioSelected: e => this.handleRadioSelected(e) }))
|
|
66
|
+
return (h(Host, { class: "zonos--shipping zonos--elements" }, h("div", { class: "zonos--group" }, h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, translate('Shipping information')), h("zonos-text", { class: "zonos--shipping-method-title", type: "semiBoldLabel" }, translate('Shipping method')), !(serviceLevels === null || serviceLevels === void 0 ? void 0 : serviceLevels.length) ? (h("zonos-banner", { bannerTitle: "No shipping methods found - try editing your address or contacting support if the error persists", intent: "error" })) : (h("zonos-shipping-rich-radio", { items: serviceLevels || [], onRadioSelected: e => this.handleRadioSelected(e) }))), h("zonos-button", { backgroundColor: this.submitBtnColor, "is-disabled": this.disabled, loading: this.continueLoading, onClick: () => this.continueClickHandler(), size: "lg",
|
|
69
67
|
// use primary type when on mobile mode
|
|
70
68
|
variant: this.submitBtnType }, translate('Go to payment'))));
|
|
71
69
|
}
|
|
@@ -3,7 +3,7 @@ import { localizationStore } from "../../store/hello/localization";
|
|
|
3
3
|
import { translate } from "../../store/translationStore";
|
|
4
4
|
import { zonosStore } from "../../store/zonosStore";
|
|
5
5
|
import { classes } from "../../utils/classes";
|
|
6
|
-
import {
|
|
6
|
+
import { currencyFormat } from "../../utils/hello/currencyConversion/currencyFormat";
|
|
7
7
|
import { getHasMoreSpaceAbove } from "../../utils/hello/getHasMoreSpaceAbove";
|
|
8
8
|
import { getHasMoreSpaceOnRight } from "../../utils/hello/getHasMoreSpaceOnRight";
|
|
9
9
|
// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
|
|
@@ -60,18 +60,26 @@ export class ZonosHelloDialog {
|
|
|
60
60
|
const { countryLandedCost, selectedCountryCode } = localizationStore;
|
|
61
61
|
// Our Robby API spells deminimis wrong here
|
|
62
62
|
const dutyDeminimis = (countryLandedCost === null || countryLandedCost === void 0 ? void 0 : countryLandedCost.dutyDeminimus)
|
|
63
|
-
?
|
|
63
|
+
? currencyFormat(countryLandedCost.dutyDeminimus)
|
|
64
64
|
: null;
|
|
65
|
+
// If Canada, use 40 CAD (courier duty de minimis)
|
|
66
|
+
const dutyDeminimisToUse = localizationStore.selectedCountryCode === 'CA'
|
|
67
|
+
? currencyFormat(40)
|
|
68
|
+
: dutyDeminimis;
|
|
65
69
|
// If deminimis is undefined or null, assume it's $0
|
|
66
|
-
const dutyDeMinimisMessage =
|
|
67
|
-
? `${translate('Spend')} ${
|
|
70
|
+
const dutyDeMinimisMessage = dutyDeminimisToUse
|
|
71
|
+
? `${translate('Spend')} ${dutyDeminimisToUse} ${translate('duty free')}`
|
|
68
72
|
: translate('Duties will apply to all orders');
|
|
69
73
|
// Our Robby API spells deminimis wrong here
|
|
70
74
|
const taxDeminimis = (countryLandedCost === null || countryLandedCost === void 0 ? void 0 : countryLandedCost.vatTaxDeminimus)
|
|
71
|
-
?
|
|
75
|
+
? currencyFormat(countryLandedCost.vatTaxDeminimus)
|
|
72
76
|
: null;
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
// If Canada, use 150 CAD (courier tax de minimis)
|
|
78
|
+
const taxDeminimisToUse = localizationStore.selectedCountryCode === 'CA'
|
|
79
|
+
? currencyFormat(150)
|
|
80
|
+
: taxDeminimis;
|
|
81
|
+
const taxDeMinimisMessage = taxDeminimisToUse
|
|
82
|
+
? `${translate('Spend')} ${taxDeminimisToUse} ${translate('tax free')}`
|
|
75
83
|
: translate('Taxes will apply to all orders');
|
|
76
84
|
const animateLeft = this.animateFromLeftOverride ||
|
|
77
85
|
(this.dialogRef && getHasMoreSpaceOnRight(this.dialogRef));
|
|
@@ -22,23 +22,45 @@ const { state: localizationStore } = createStore({
|
|
|
22
22
|
shippingZoneCountries: null,
|
|
23
23
|
targetCurrency: 'USD',
|
|
24
24
|
});
|
|
25
|
+
const triggerGetExchangeRate = async (isGuaranteed) => {
|
|
26
|
+
const { exchangeRate, maxAge } = await getExchangeRate({
|
|
27
|
+
country: localizationStore.selectedCountryCode,
|
|
28
|
+
isGuaranteed,
|
|
29
|
+
sourceCurrency: zonosStore.sourceCurrency,
|
|
30
|
+
targetCurrency: localizationStore.targetCurrency,
|
|
31
|
+
});
|
|
32
|
+
if (exchangeRate) {
|
|
33
|
+
localizationStore.exchangeRate = exchangeRate;
|
|
34
|
+
currencyDisplay();
|
|
35
|
+
}
|
|
36
|
+
return { maxAge };
|
|
37
|
+
};
|
|
38
|
+
// This recursive function is for users who step away from their computer and come back needing a new exchange rate
|
|
39
|
+
const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
|
|
40
|
+
if (localizationStore.exchangeRateTimeout) {
|
|
41
|
+
clearTimeout(localizationStore.exchangeRateTimeout);
|
|
42
|
+
}
|
|
43
|
+
// maxAge comes in seconds, convert to milliseconds
|
|
44
|
+
const defaultMaxAge = 5 * 60;
|
|
45
|
+
const maxAgeToUse = maxAge || defaultMaxAge;
|
|
46
|
+
// Recursively set timeouts to get new exchange rates when the current one expires
|
|
47
|
+
localizationStore.exchangeRateTimeout = setTimeout(async () => {
|
|
48
|
+
const { maxAge: newMaxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
49
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge: newMaxAge });
|
|
50
|
+
}, maxAgeToUse * 1000);
|
|
51
|
+
};
|
|
25
52
|
const getNewLocalization = async () => {
|
|
26
53
|
log('get new localization store');
|
|
27
54
|
const { isShippableCountry, selectedCountryCode } = localizationStore;
|
|
28
|
-
const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
29
55
|
if (zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
|
|
30
56
|
!isShippableCountry ||
|
|
31
57
|
!selectedCountryCode) {
|
|
32
58
|
return;
|
|
33
59
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
isGuaranteed
|
|
37
|
-
|
|
38
|
-
targetCurrency: localizationStore.targetCurrency,
|
|
39
|
-
});
|
|
40
|
-
if (localizationStore.exchangeRate) {
|
|
41
|
-
currencyDisplay();
|
|
60
|
+
if (zonosStore.sourceCurrency !== localizationStore.targetCurrency) {
|
|
61
|
+
const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
62
|
+
const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
63
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
42
64
|
}
|
|
43
65
|
localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
|
|
44
66
|
};
|
|
@@ -33,6 +33,11 @@ export class ZonosAddress {
|
|
|
33
33
|
? Object.values(shippableCountries).map(country => country.code)
|
|
34
34
|
: [],
|
|
35
35
|
contacts: this.defaultAddress ? [this.defaultAddress] : undefined,
|
|
36
|
+
defaultValues: {
|
|
37
|
+
address: {
|
|
38
|
+
country: localizationStore.selectedCountryCode || 'AL',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
36
41
|
display: {
|
|
37
42
|
name: 'split',
|
|
38
43
|
},
|
|
@@ -2,16 +2,21 @@ import { handleFetch } from "../handleFetch";
|
|
|
2
2
|
import { logError } from "../logging/logError";
|
|
3
3
|
export const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCurrency, }) => {
|
|
4
4
|
var _a;
|
|
5
|
+
// If source currency matches target currency (US -> US) and is not a guaranteed rate, return null
|
|
6
|
+
if (sourceCurrency === targetCurrency && !isGuaranteed) {
|
|
7
|
+
return { exchangeRate: null, maxAge: null };
|
|
8
|
+
}
|
|
5
9
|
const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/exchange-rates?sourceCurrency=${sourceCurrency}&targetCurrency=${targetCurrency}&isGuaranteed=${isGuaranteed}&country=${country}}`;
|
|
6
10
|
const { errors, json } = await handleFetch(url);
|
|
7
11
|
if (errors.length || !json) {
|
|
8
12
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
9
|
-
return null;
|
|
13
|
+
return { exchangeRate: null, maxAge: null };
|
|
10
14
|
}
|
|
11
|
-
const { rate, targetFormat } = json.exchangeRateCreate;
|
|
15
|
+
const { maxAge, rate, targetFormat } = json.exchangeRateCreate;
|
|
12
16
|
if (rate) {
|
|
13
17
|
sessionStorage.setItem(country + '_rate', JSON.stringify(rate));
|
|
14
|
-
|
|
18
|
+
const exchangeRate = { rate, targetFormat };
|
|
19
|
+
return { exchangeRate, maxAge };
|
|
15
20
|
}
|
|
16
|
-
return null;
|
|
21
|
+
return { exchangeRate: null, maxAge: null };
|
|
17
22
|
};
|
|
@@ -3196,18 +3196,23 @@ const getCountryLandedCost = async (countryCode) => {
|
|
|
3196
3196
|
|
|
3197
3197
|
const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCurrency, }) => {
|
|
3198
3198
|
var _a;
|
|
3199
|
+
// If source currency matches target currency (US -> US) and is not a guaranteed rate, return null
|
|
3200
|
+
if (sourceCurrency === targetCurrency && !isGuaranteed) {
|
|
3201
|
+
return { exchangeRate: null, maxAge: null };
|
|
3202
|
+
}
|
|
3199
3203
|
const url = `${"https://v1.route.js.zonos.com"}/api/exchange-rates?sourceCurrency=${sourceCurrency}&targetCurrency=${targetCurrency}&isGuaranteed=${isGuaranteed}&country=${country}}`;
|
|
3200
3204
|
const { errors, json } = await handleFetch(url);
|
|
3201
3205
|
if (errors.length || !json) {
|
|
3202
3206
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
3203
|
-
return null;
|
|
3207
|
+
return { exchangeRate: null, maxAge: null };
|
|
3204
3208
|
}
|
|
3205
|
-
const { rate, targetFormat } = json.exchangeRateCreate;
|
|
3209
|
+
const { maxAge, rate, targetFormat } = json.exchangeRateCreate;
|
|
3206
3210
|
if (rate) {
|
|
3207
3211
|
sessionStorage.setItem(country + '_rate', JSON.stringify(rate));
|
|
3208
|
-
|
|
3212
|
+
const exchangeRate = { rate, targetFormat };
|
|
3213
|
+
return { exchangeRate, maxAge };
|
|
3209
3214
|
}
|
|
3210
|
-
return null;
|
|
3215
|
+
return { exchangeRate: null, maxAge: null };
|
|
3211
3216
|
};
|
|
3212
3217
|
|
|
3213
3218
|
const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
@@ -3465,23 +3470,45 @@ const { state: localizationStore } = createStore({
|
|
|
3465
3470
|
shippingZoneCountries: null,
|
|
3466
3471
|
targetCurrency: 'USD',
|
|
3467
3472
|
});
|
|
3473
|
+
const triggerGetExchangeRate = async (isGuaranteed) => {
|
|
3474
|
+
const { exchangeRate, maxAge } = await getExchangeRate({
|
|
3475
|
+
country: localizationStore.selectedCountryCode,
|
|
3476
|
+
isGuaranteed,
|
|
3477
|
+
sourceCurrency: zonosStore.sourceCurrency,
|
|
3478
|
+
targetCurrency: localizationStore.targetCurrency,
|
|
3479
|
+
});
|
|
3480
|
+
if (exchangeRate) {
|
|
3481
|
+
localizationStore.exchangeRate = exchangeRate;
|
|
3482
|
+
currencyDisplay();
|
|
3483
|
+
}
|
|
3484
|
+
return { maxAge };
|
|
3485
|
+
};
|
|
3486
|
+
// This recursive function is for users who step away from their computer and come back needing a new exchange rate
|
|
3487
|
+
const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
|
|
3488
|
+
if (localizationStore.exchangeRateTimeout) {
|
|
3489
|
+
clearTimeout(localizationStore.exchangeRateTimeout);
|
|
3490
|
+
}
|
|
3491
|
+
// maxAge comes in seconds, convert to milliseconds
|
|
3492
|
+
const defaultMaxAge = 5 * 60;
|
|
3493
|
+
const maxAgeToUse = maxAge || defaultMaxAge;
|
|
3494
|
+
// Recursively set timeouts to get new exchange rates when the current one expires
|
|
3495
|
+
localizationStore.exchangeRateTimeout = setTimeout(async () => {
|
|
3496
|
+
const { maxAge: newMaxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
3497
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge: newMaxAge });
|
|
3498
|
+
}, maxAgeToUse * 1000);
|
|
3499
|
+
};
|
|
3468
3500
|
const getNewLocalization = async () => {
|
|
3469
3501
|
log('get new localization store');
|
|
3470
3502
|
const { isShippableCountry, selectedCountryCode } = localizationStore;
|
|
3471
|
-
const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
3472
3503
|
if (zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
|
|
3473
3504
|
!isShippableCountry ||
|
|
3474
3505
|
!selectedCountryCode) {
|
|
3475
3506
|
return;
|
|
3476
3507
|
}
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
isGuaranteed
|
|
3480
|
-
|
|
3481
|
-
targetCurrency: localizationStore.targetCurrency,
|
|
3482
|
-
});
|
|
3483
|
-
if (localizationStore.exchangeRate) {
|
|
3484
|
-
currencyDisplay();
|
|
3508
|
+
if (zonosStore.sourceCurrency !== localizationStore.targetCurrency) {
|
|
3509
|
+
const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
|
|
3510
|
+
const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
|
|
3511
|
+
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
3485
3512
|
}
|
|
3486
3513
|
localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
|
|
3487
3514
|
};
|
|
@@ -34,6 +34,11 @@ const ZonosAddress = /*@__PURE__*/ proxyCustomElement(class ZonosAddress extends
|
|
|
34
34
|
? Object.values(shippableCountries).map(country => country.code)
|
|
35
35
|
: [],
|
|
36
36
|
contacts: this.defaultAddress ? [this.defaultAddress] : undefined,
|
|
37
|
+
defaultValues: {
|
|
38
|
+
address: {
|
|
39
|
+
country: localizationStore.selectedCountryCode || 'AL',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
37
42
|
display: {
|
|
38
43
|
name: 'split',
|
|
39
44
|
},
|