@nok-integration/storefront-react 0.22.2 → 0.22.4
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.mjs +150 -61
- package/dist/standalone/storefront.mjs +150 -61
- package/dist/standalone/styles.css +75 -72
- package/dist/styles.css +75 -72
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5500,7 +5500,7 @@ function resolveAssetUrl(src, base) {
|
|
|
5500
5500
|
if (!src.startsWith("/") || src.startsWith("//")) return src;
|
|
5501
5501
|
return `${base.replace(/\/+$/, "")}${src}`;
|
|
5502
5502
|
}
|
|
5503
|
-
const MAX_AGE_MS = 5 * 6e4;
|
|
5503
|
+
const MAX_AGE_MS$1 = 5 * 6e4;
|
|
5504
5504
|
const CAPACITY = 60;
|
|
5505
5505
|
class ProductCache {
|
|
5506
5506
|
constructor(now = () => Date.now()) {
|
|
@@ -5515,7 +5515,7 @@ class ProductCache {
|
|
|
5515
5515
|
const key = ProductCache.keyFor(sku, market);
|
|
5516
5516
|
const entry = this.entries.get(key);
|
|
5517
5517
|
if (!entry) return void 0;
|
|
5518
|
-
if (this.now() - entry.at > MAX_AGE_MS) {
|
|
5518
|
+
if (this.now() - entry.at > MAX_AGE_MS$1) {
|
|
5519
5519
|
this.entries.delete(key);
|
|
5520
5520
|
return void 0;
|
|
5521
5521
|
}
|
|
@@ -5543,6 +5543,37 @@ class ProductCache {
|
|
|
5543
5543
|
this.entries.clear();
|
|
5544
5544
|
}
|
|
5545
5545
|
}
|
|
5546
|
+
const MAX_AGE_MS = 5 * 6e4;
|
|
5547
|
+
class CartCache {
|
|
5548
|
+
constructor(now = () => Date.now()) {
|
|
5549
|
+
this.now = now;
|
|
5550
|
+
}
|
|
5551
|
+
now;
|
|
5552
|
+
entry = null;
|
|
5553
|
+
version = 0;
|
|
5554
|
+
get() {
|
|
5555
|
+
if (!this.entry) return void 0;
|
|
5556
|
+
if (this.now() - this.entry.at > MAX_AGE_MS) {
|
|
5557
|
+
this.entry = null;
|
|
5558
|
+
return void 0;
|
|
5559
|
+
}
|
|
5560
|
+
return this.entry.cart;
|
|
5561
|
+
}
|
|
5562
|
+
set(cart2) {
|
|
5563
|
+
this.entry = {
|
|
5564
|
+
cart: cart2,
|
|
5565
|
+
at: this.now()
|
|
5566
|
+
};
|
|
5567
|
+
this.version += 1;
|
|
5568
|
+
}
|
|
5569
|
+
get revision() {
|
|
5570
|
+
return this.version;
|
|
5571
|
+
}
|
|
5572
|
+
clear() {
|
|
5573
|
+
this.entry = null;
|
|
5574
|
+
this.version += 1;
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5546
5577
|
function createShopFetch(opts) {
|
|
5547
5578
|
const baseFetch = opts.fetchImpl ?? globalThis.fetch;
|
|
5548
5579
|
if (!baseFetch) throw new Error("No fetch implementation available");
|
|
@@ -5643,6 +5674,7 @@ function NoScreenTitle({ children }) {
|
|
|
5643
5674
|
});
|
|
5644
5675
|
}
|
|
5645
5676
|
const ShopContext = createContext(null);
|
|
5677
|
+
const CartCacheContext = createContext(null);
|
|
5646
5678
|
function DaznShopProvider({ children, ...config }) {
|
|
5647
5679
|
const { apiBaseUrl, getToken, market, navigate: hostNavigate, prefetch: hostPrefetch, sessionTransport = "bearer", theme = "auto", notifications = "internal", features, onEvent, locale, assetBaseUrl } = config;
|
|
5648
5680
|
const listeners = useRef(/* @__PURE__ */ new Set());
|
|
@@ -5672,7 +5704,10 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5672
5704
|
} catch {
|
|
5673
5705
|
}
|
|
5674
5706
|
}, []);
|
|
5675
|
-
const
|
|
5707
|
+
const cartsRef = useRef(null);
|
|
5708
|
+
cartsRef.current ??= new CartCache();
|
|
5709
|
+
const carts = cartsRef.current;
|
|
5710
|
+
const client2 = useMemo(() => clientExports.createClient({
|
|
5676
5711
|
baseUrl: apiBaseUrl,
|
|
5677
5712
|
getToken: stableGetToken,
|
|
5678
5713
|
fetch: createShopFetch({
|
|
@@ -5683,6 +5718,33 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5683
5718
|
credentials: sessionTransport === "cookie" ? "include" : "omit",
|
|
5684
5719
|
market
|
|
5685
5720
|
}), [apiBaseUrl, stableGetToken, emit, sessionTransport, market]);
|
|
5721
|
+
const api = useMemo(() => {
|
|
5722
|
+
carts.clear();
|
|
5723
|
+
const remember2 = (cart2) => {
|
|
5724
|
+
carts.set(cart2);
|
|
5725
|
+
return cart2;
|
|
5726
|
+
};
|
|
5727
|
+
const read = (fn) => (...args) => {
|
|
5728
|
+
const before = carts.revision;
|
|
5729
|
+
return fn(...args).then((cart2) => carts.revision === before ? remember2(cart2) : cart2);
|
|
5730
|
+
};
|
|
5731
|
+
const write = (fn) => (...args) => fn(...args).then(remember2);
|
|
5732
|
+
return {
|
|
5733
|
+
...client2,
|
|
5734
|
+
cart: {
|
|
5735
|
+
...client2.cart,
|
|
5736
|
+
create: read(client2.cart.create),
|
|
5737
|
+
get: read(client2.cart.get),
|
|
5738
|
+
addItem: write(client2.cart.addItem),
|
|
5739
|
+
updateItem: write(client2.cart.updateItem),
|
|
5740
|
+
removeItem: write(client2.cart.removeItem)
|
|
5741
|
+
},
|
|
5742
|
+
vip: {
|
|
5743
|
+
...client2.vip,
|
|
5744
|
+
addToCart: write(client2.vip.addToCart)
|
|
5745
|
+
}
|
|
5746
|
+
};
|
|
5747
|
+
}, [client2, carts]);
|
|
5686
5748
|
const navigate = useCallback((to) => {
|
|
5687
5749
|
emit({
|
|
5688
5750
|
type: "navigate",
|
|
@@ -5719,8 +5781,11 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5719
5781
|
}), [api, market, products, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch]);
|
|
5720
5782
|
return jsx(ShopContext.Provider, {
|
|
5721
5783
|
value: value2,
|
|
5722
|
-
children: jsx(
|
|
5723
|
-
|
|
5784
|
+
children: jsx(CartCacheContext.Provider, {
|
|
5785
|
+
value: carts,
|
|
5786
|
+
children: jsx(ScreenTitleProvider, {
|
|
5787
|
+
children
|
|
5788
|
+
})
|
|
5724
5789
|
})
|
|
5725
5790
|
});
|
|
5726
5791
|
}
|
|
@@ -5757,6 +5822,9 @@ function useShopFeatures() {
|
|
|
5757
5822
|
stockAlerts: true
|
|
5758
5823
|
};
|
|
5759
5824
|
}
|
|
5825
|
+
function useCartCache() {
|
|
5826
|
+
return useContext(CartCacheContext);
|
|
5827
|
+
}
|
|
5760
5828
|
function ShopLink({ to, children, ...rest }) {
|
|
5761
5829
|
const navigate = useNavigate();
|
|
5762
5830
|
const prefetch = usePrefetch();
|
|
@@ -8420,26 +8488,26 @@ function VipHelpLink({ onHelp }) {
|
|
|
8420
8488
|
})]
|
|
8421
8489
|
});
|
|
8422
8490
|
}
|
|
8423
|
-
const crumbs = "
|
|
8424
|
-
const help$2 = "
|
|
8425
|
-
const skeleton = "
|
|
8426
|
-
const skConnector = "
|
|
8427
|
-
const skMain = "
|
|
8428
|
-
const skSubtitle = "
|
|
8429
|
-
const skTimeline = "
|
|
8430
|
-
const skStep = "
|
|
8431
|
-
const skStepText = "
|
|
8432
|
-
const skAside = "
|
|
8433
|
-
const skLine = "
|
|
8434
|
-
const skLineText = "
|
|
8435
|
-
const skMeta = "
|
|
8436
|
-
const skBadge = "
|
|
8437
|
-
const skPrice = "
|
|
8438
|
-
const skCard = "
|
|
8439
|
-
const skAddress = "
|
|
8440
|
-
const skSummary = "
|
|
8441
|
-
const skCell = "
|
|
8442
|
-
const skHelp = "
|
|
8491
|
+
const crumbs = "_crumbs_19inq_1";
|
|
8492
|
+
const help$2 = "_help_19inq_2";
|
|
8493
|
+
const skeleton = "_skeleton_19inq_3";
|
|
8494
|
+
const skConnector = "_skConnector_19inq_43";
|
|
8495
|
+
const skMain = "_skMain_19inq_47";
|
|
8496
|
+
const skSubtitle = "_skSubtitle_19inq_53";
|
|
8497
|
+
const skTimeline = "_skTimeline_19inq_57";
|
|
8498
|
+
const skStep = "_skStep_19inq_64";
|
|
8499
|
+
const skStepText = "_skStepText_19inq_71";
|
|
8500
|
+
const skAside = "_skAside_19inq_84";
|
|
8501
|
+
const skLine = "_skLine_19inq_91";
|
|
8502
|
+
const skLineText = "_skLineText_19inq_97";
|
|
8503
|
+
const skMeta = "_skMeta_19inq_105";
|
|
8504
|
+
const skBadge = "_skBadge_19inq_112";
|
|
8505
|
+
const skPrice = "_skPrice_19inq_116";
|
|
8506
|
+
const skCard = "_skCard_19inq_124";
|
|
8507
|
+
const skAddress = "_skAddress_19inq_132";
|
|
8508
|
+
const skSummary = "_skSummary_19inq_137";
|
|
8509
|
+
const skCell = "_skCell_19inq_145";
|
|
8510
|
+
const skHelp = "_skHelp_19inq_150";
|
|
8443
8511
|
const styles$B = {
|
|
8444
8512
|
crumbs,
|
|
8445
8513
|
help: help$2,
|
|
@@ -8644,25 +8712,25 @@ function SkStep({ lines: lines2 }) {
|
|
|
8644
8712
|
})]
|
|
8645
8713
|
});
|
|
8646
8714
|
}
|
|
8647
|
-
const page$3 = "
|
|
8648
|
-
const widget = "
|
|
8649
|
-
const titleRow = "
|
|
8650
|
-
const headline$2 = "
|
|
8651
|
-
const track$5 = "
|
|
8652
|
-
const rule$1 = "
|
|
8653
|
-
const help$1 = "
|
|
8654
|
-
const helpTitle = "
|
|
8655
|
-
const helpRows = "
|
|
8656
|
-
const helpRowEnd = "
|
|
8657
|
-
const helpStatus = "
|
|
8658
|
-
const helpRow = "
|
|
8659
|
-
const cancel = "
|
|
8660
|
-
const cancelledHead = "
|
|
8661
|
-
const cancelledTitle = "
|
|
8662
|
-
const cancelledMeta = "
|
|
8663
|
-
const aside$1 = "
|
|
8664
|
-
const phoneSkeleton$1 = "
|
|
8665
|
-
const wide$2 = "
|
|
8715
|
+
const page$3 = "_page_j9tz4_8";
|
|
8716
|
+
const widget = "_widget_j9tz4_18";
|
|
8717
|
+
const titleRow = "_titleRow_j9tz4_26";
|
|
8718
|
+
const headline$2 = "_headline_j9tz4_42";
|
|
8719
|
+
const track$5 = "_track_j9tz4_74";
|
|
8720
|
+
const rule$1 = "_rule_j9tz4_99";
|
|
8721
|
+
const help$1 = "_help_j9tz4_109";
|
|
8722
|
+
const helpTitle = "_helpTitle_j9tz4_115";
|
|
8723
|
+
const helpRows = "_helpRows_j9tz4_122";
|
|
8724
|
+
const helpRowEnd = "_helpRowEnd_j9tz4_131";
|
|
8725
|
+
const helpStatus = "_helpStatus_j9tz4_139";
|
|
8726
|
+
const helpRow = "_helpRow_j9tz4_122";
|
|
8727
|
+
const cancel = "_cancel_j9tz4_197";
|
|
8728
|
+
const cancelledHead = "_cancelledHead_j9tz4_221";
|
|
8729
|
+
const cancelledTitle = "_cancelledTitle_j9tz4_227";
|
|
8730
|
+
const cancelledMeta = "_cancelledMeta_j9tz4_241";
|
|
8731
|
+
const aside$1 = "_aside_j9tz4_249";
|
|
8732
|
+
const phoneSkeleton$1 = "_phoneSkeleton_j9tz4_254";
|
|
8733
|
+
const wide$2 = "_wide_j9tz4_258";
|
|
8666
8734
|
const styles$A = {
|
|
8667
8735
|
page: page$3,
|
|
8668
8736
|
widget,
|
|
@@ -9039,16 +9107,16 @@ function HelpRow({ label: label2, status, onClick }) {
|
|
|
9039
9107
|
function shortRef$1(orderRef) {
|
|
9040
9108
|
return orderRef.replace(/^ord_/, "");
|
|
9041
9109
|
}
|
|
9042
|
-
const page$2 = "
|
|
9043
|
-
const confirmed = "
|
|
9044
|
-
const title$h = "
|
|
9045
|
-
const headline$1 = "
|
|
9046
|
-
const subtitle$4 = "
|
|
9047
|
-
const rule = "
|
|
9048
|
-
const done = "
|
|
9049
|
-
const aside = "
|
|
9050
|
-
const phoneSkeleton = "
|
|
9051
|
-
const wide$1 = "
|
|
9110
|
+
const page$2 = "_page_1c6sm_6";
|
|
9111
|
+
const confirmed = "_confirmed_1c6sm_16";
|
|
9112
|
+
const title$h = "_title_1c6sm_22";
|
|
9113
|
+
const headline$1 = "_headline_1c6sm_47";
|
|
9114
|
+
const subtitle$4 = "_subtitle_1c6sm_65";
|
|
9115
|
+
const rule = "_rule_1c6sm_77";
|
|
9116
|
+
const done = "_done_1c6sm_94";
|
|
9117
|
+
const aside = "_aside_1c6sm_98";
|
|
9118
|
+
const phoneSkeleton = "_phoneSkeleton_1c6sm_103";
|
|
9119
|
+
const wide$1 = "_wide_1c6sm_107";
|
|
9052
9120
|
const styles$z = {
|
|
9053
9121
|
page: page$2,
|
|
9054
9122
|
confirmed,
|
|
@@ -10064,6 +10132,16 @@ function BottomSheet({ open, onClose, title: title2, children, footer: footer2 }
|
|
|
10064
10132
|
})]
|
|
10065
10133
|
});
|
|
10066
10134
|
}
|
|
10135
|
+
function messageToNative(message2) {
|
|
10136
|
+
if (typeof window === "undefined") return;
|
|
10137
|
+
const host = window;
|
|
10138
|
+
if (!host.dazn?.native?.isNative) return;
|
|
10139
|
+
try {
|
|
10140
|
+
host.daznNativeBridge?.messageToNative?.(message2);
|
|
10141
|
+
} catch {
|
|
10142
|
+
return;
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10067
10145
|
const LOW_STOCK_THRESHOLD = 5;
|
|
10068
10146
|
function isLowStock(available) {
|
|
10069
10147
|
return available !== void 0 && available > 0 && available <= LOW_STOCK_THRESHOLD;
|
|
@@ -10426,22 +10504,28 @@ function CartViewContent({ onContinueShopping, checkoutLabel } = {}) {
|
|
|
10426
10504
|
const t = useT();
|
|
10427
10505
|
const toast2 = useToast();
|
|
10428
10506
|
const { api, emit } = useShop();
|
|
10429
|
-
const
|
|
10430
|
-
const [
|
|
10507
|
+
const carts = useCartCache();
|
|
10508
|
+
const [cart2, setCart] = useState(() => carts?.get() ?? null);
|
|
10509
|
+
const [state, setState] = useState(() => {
|
|
10510
|
+
const seeded = carts?.get();
|
|
10511
|
+
if (!seeded) return "loading";
|
|
10512
|
+
return seeded.items.length === 0 ? "empty" : "ready";
|
|
10513
|
+
});
|
|
10431
10514
|
const [errorCode, setErrorCode] = useState(void 0);
|
|
10432
10515
|
const [pendingSku, setPendingSku] = useState(null);
|
|
10433
10516
|
const [handingOff, setHandingOff] = useState(false);
|
|
10434
10517
|
const load = useCallback(async () => {
|
|
10435
|
-
setState("loading");
|
|
10518
|
+
if (!carts?.get()) setState("loading");
|
|
10436
10519
|
try {
|
|
10437
|
-
const
|
|
10520
|
+
const fetched = await api.cart.get();
|
|
10521
|
+
const next = carts?.get() ?? fetched;
|
|
10438
10522
|
setCart(next);
|
|
10439
10523
|
setState(next.items.length === 0 ? "empty" : "ready");
|
|
10440
10524
|
} catch (err) {
|
|
10441
10525
|
setErrorCode(codeOf(err));
|
|
10442
10526
|
setState("error");
|
|
10443
10527
|
}
|
|
10444
|
-
}, [api]);
|
|
10528
|
+
}, [api, carts]);
|
|
10445
10529
|
useEffect(() => {
|
|
10446
10530
|
void load();
|
|
10447
10531
|
}, [load]);
|
|
@@ -10561,6 +10645,7 @@ function CartViewContent({ onContinueShopping, checkoutLabel } = {}) {
|
|
|
10561
10645
|
});
|
|
10562
10646
|
}
|
|
10563
10647
|
async function handOff(current2) {
|
|
10648
|
+
messageToNative("showLoader");
|
|
10564
10649
|
setHandingOff(true);
|
|
10565
10650
|
try {
|
|
10566
10651
|
const { checkout_url } = await api.cart.handoff();
|
|
@@ -10620,7 +10705,7 @@ function CartViewContent({ onContinueShopping, checkoutLabel } = {}) {
|
|
|
10620
10705
|
children: jsx(Button, {
|
|
10621
10706
|
variant: "primary",
|
|
10622
10707
|
onClick: () => void handOff(cart2),
|
|
10623
|
-
|
|
10708
|
+
loading: handingOff,
|
|
10624
10709
|
children: checkoutLabel ?? t("Proceed to checkout")
|
|
10625
10710
|
})
|
|
10626
10711
|
})]
|
|
@@ -12929,7 +13014,11 @@ function useCartCount() {
|
|
|
12929
13014
|
const shop = useShopOptional();
|
|
12930
13015
|
const api = shop?.api;
|
|
12931
13016
|
const subscribe = shop?.subscribe;
|
|
12932
|
-
const
|
|
13017
|
+
const carts = useCartCache();
|
|
13018
|
+
const [count2, setCount] = useState(() => {
|
|
13019
|
+
const seeded = carts?.get();
|
|
13020
|
+
return seeded ? seeded.items.reduce((n, i) => n + i.qty, 0) : null;
|
|
13021
|
+
});
|
|
12933
13022
|
useEffect(() => {
|
|
12934
13023
|
if (!api) return;
|
|
12935
13024
|
let live = true;
|
|
@@ -5500,7 +5500,7 @@ function resolveAssetUrl(src, base) {
|
|
|
5500
5500
|
if (!src.startsWith("/") || src.startsWith("//")) return src;
|
|
5501
5501
|
return `${base.replace(/\/+$/, "")}${src}`;
|
|
5502
5502
|
}
|
|
5503
|
-
const MAX_AGE_MS = 5 * 6e4;
|
|
5503
|
+
const MAX_AGE_MS$1 = 5 * 6e4;
|
|
5504
5504
|
const CAPACITY = 60;
|
|
5505
5505
|
class ProductCache {
|
|
5506
5506
|
constructor(now = () => Date.now()) {
|
|
@@ -5515,7 +5515,7 @@ class ProductCache {
|
|
|
5515
5515
|
const key = ProductCache.keyFor(sku, market);
|
|
5516
5516
|
const entry = this.entries.get(key);
|
|
5517
5517
|
if (!entry) return void 0;
|
|
5518
|
-
if (this.now() - entry.at > MAX_AGE_MS) {
|
|
5518
|
+
if (this.now() - entry.at > MAX_AGE_MS$1) {
|
|
5519
5519
|
this.entries.delete(key);
|
|
5520
5520
|
return void 0;
|
|
5521
5521
|
}
|
|
@@ -5543,6 +5543,37 @@ class ProductCache {
|
|
|
5543
5543
|
this.entries.clear();
|
|
5544
5544
|
}
|
|
5545
5545
|
}
|
|
5546
|
+
const MAX_AGE_MS = 5 * 6e4;
|
|
5547
|
+
class CartCache {
|
|
5548
|
+
constructor(now = () => Date.now()) {
|
|
5549
|
+
this.now = now;
|
|
5550
|
+
}
|
|
5551
|
+
now;
|
|
5552
|
+
entry = null;
|
|
5553
|
+
version = 0;
|
|
5554
|
+
get() {
|
|
5555
|
+
if (!this.entry) return void 0;
|
|
5556
|
+
if (this.now() - this.entry.at > MAX_AGE_MS) {
|
|
5557
|
+
this.entry = null;
|
|
5558
|
+
return void 0;
|
|
5559
|
+
}
|
|
5560
|
+
return this.entry.cart;
|
|
5561
|
+
}
|
|
5562
|
+
set(cart2) {
|
|
5563
|
+
this.entry = {
|
|
5564
|
+
cart: cart2,
|
|
5565
|
+
at: this.now()
|
|
5566
|
+
};
|
|
5567
|
+
this.version += 1;
|
|
5568
|
+
}
|
|
5569
|
+
get revision() {
|
|
5570
|
+
return this.version;
|
|
5571
|
+
}
|
|
5572
|
+
clear() {
|
|
5573
|
+
this.entry = null;
|
|
5574
|
+
this.version += 1;
|
|
5575
|
+
}
|
|
5576
|
+
}
|
|
5546
5577
|
function createShopFetch(opts) {
|
|
5547
5578
|
const baseFetch = opts.fetchImpl ?? globalThis.fetch;
|
|
5548
5579
|
if (!baseFetch) throw new Error("No fetch implementation available");
|
|
@@ -5643,6 +5674,7 @@ function NoScreenTitle({ children }) {
|
|
|
5643
5674
|
});
|
|
5644
5675
|
}
|
|
5645
5676
|
const ShopContext = createContext(null);
|
|
5677
|
+
const CartCacheContext = createContext(null);
|
|
5646
5678
|
function DaznShopProvider({ children, ...config }) {
|
|
5647
5679
|
const { apiBaseUrl, getToken, market, navigate: hostNavigate, prefetch: hostPrefetch, sessionTransport = "bearer", theme = "auto", notifications = "internal", features, onEvent, locale, assetBaseUrl } = config;
|
|
5648
5680
|
const listeners = useRef(/* @__PURE__ */ new Set());
|
|
@@ -5672,7 +5704,10 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5672
5704
|
} catch {
|
|
5673
5705
|
}
|
|
5674
5706
|
}, []);
|
|
5675
|
-
const
|
|
5707
|
+
const cartsRef = useRef(null);
|
|
5708
|
+
cartsRef.current ??= new CartCache();
|
|
5709
|
+
const carts = cartsRef.current;
|
|
5710
|
+
const client2 = useMemo(() => clientExports.createClient({
|
|
5676
5711
|
baseUrl: apiBaseUrl,
|
|
5677
5712
|
getToken: stableGetToken,
|
|
5678
5713
|
fetch: createShopFetch({
|
|
@@ -5683,6 +5718,33 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5683
5718
|
credentials: sessionTransport === "cookie" ? "include" : "omit",
|
|
5684
5719
|
market
|
|
5685
5720
|
}), [apiBaseUrl, stableGetToken, emit, sessionTransport, market]);
|
|
5721
|
+
const api = useMemo(() => {
|
|
5722
|
+
carts.clear();
|
|
5723
|
+
const remember2 = (cart2) => {
|
|
5724
|
+
carts.set(cart2);
|
|
5725
|
+
return cart2;
|
|
5726
|
+
};
|
|
5727
|
+
const read = (fn) => (...args) => {
|
|
5728
|
+
const before = carts.revision;
|
|
5729
|
+
return fn(...args).then((cart2) => carts.revision === before ? remember2(cart2) : cart2);
|
|
5730
|
+
};
|
|
5731
|
+
const write = (fn) => (...args) => fn(...args).then(remember2);
|
|
5732
|
+
return {
|
|
5733
|
+
...client2,
|
|
5734
|
+
cart: {
|
|
5735
|
+
...client2.cart,
|
|
5736
|
+
create: read(client2.cart.create),
|
|
5737
|
+
get: read(client2.cart.get),
|
|
5738
|
+
addItem: write(client2.cart.addItem),
|
|
5739
|
+
updateItem: write(client2.cart.updateItem),
|
|
5740
|
+
removeItem: write(client2.cart.removeItem)
|
|
5741
|
+
},
|
|
5742
|
+
vip: {
|
|
5743
|
+
...client2.vip,
|
|
5744
|
+
addToCart: write(client2.vip.addToCart)
|
|
5745
|
+
}
|
|
5746
|
+
};
|
|
5747
|
+
}, [client2, carts]);
|
|
5686
5748
|
const navigate = useCallback((to) => {
|
|
5687
5749
|
emit({
|
|
5688
5750
|
type: "navigate",
|
|
@@ -5719,8 +5781,11 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5719
5781
|
}), [api, market, products, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch]);
|
|
5720
5782
|
return jsx(ShopContext.Provider, {
|
|
5721
5783
|
value: value2,
|
|
5722
|
-
children: jsx(
|
|
5723
|
-
|
|
5784
|
+
children: jsx(CartCacheContext.Provider, {
|
|
5785
|
+
value: carts,
|
|
5786
|
+
children: jsx(ScreenTitleProvider, {
|
|
5787
|
+
children
|
|
5788
|
+
})
|
|
5724
5789
|
})
|
|
5725
5790
|
});
|
|
5726
5791
|
}
|
|
@@ -5757,6 +5822,9 @@ function useShopFeatures() {
|
|
|
5757
5822
|
stockAlerts: true
|
|
5758
5823
|
};
|
|
5759
5824
|
}
|
|
5825
|
+
function useCartCache() {
|
|
5826
|
+
return useContext(CartCacheContext);
|
|
5827
|
+
}
|
|
5760
5828
|
function ShopLink({ to, children, ...rest }) {
|
|
5761
5829
|
const navigate = useNavigate();
|
|
5762
5830
|
const prefetch = usePrefetch();
|
|
@@ -8420,26 +8488,26 @@ function VipHelpLink({ onHelp }) {
|
|
|
8420
8488
|
})]
|
|
8421
8489
|
});
|
|
8422
8490
|
}
|
|
8423
|
-
const crumbs = "
|
|
8424
|
-
const help$2 = "
|
|
8425
|
-
const skeleton = "
|
|
8426
|
-
const skConnector = "
|
|
8427
|
-
const skMain = "
|
|
8428
|
-
const skSubtitle = "
|
|
8429
|
-
const skTimeline = "
|
|
8430
|
-
const skStep = "
|
|
8431
|
-
const skStepText = "
|
|
8432
|
-
const skAside = "
|
|
8433
|
-
const skLine = "
|
|
8434
|
-
const skLineText = "
|
|
8435
|
-
const skMeta = "
|
|
8436
|
-
const skBadge = "
|
|
8437
|
-
const skPrice = "
|
|
8438
|
-
const skCard = "
|
|
8439
|
-
const skAddress = "
|
|
8440
|
-
const skSummary = "
|
|
8441
|
-
const skCell = "
|
|
8442
|
-
const skHelp = "
|
|
8491
|
+
const crumbs = "_crumbs_19inq_1";
|
|
8492
|
+
const help$2 = "_help_19inq_2";
|
|
8493
|
+
const skeleton = "_skeleton_19inq_3";
|
|
8494
|
+
const skConnector = "_skConnector_19inq_43";
|
|
8495
|
+
const skMain = "_skMain_19inq_47";
|
|
8496
|
+
const skSubtitle = "_skSubtitle_19inq_53";
|
|
8497
|
+
const skTimeline = "_skTimeline_19inq_57";
|
|
8498
|
+
const skStep = "_skStep_19inq_64";
|
|
8499
|
+
const skStepText = "_skStepText_19inq_71";
|
|
8500
|
+
const skAside = "_skAside_19inq_84";
|
|
8501
|
+
const skLine = "_skLine_19inq_91";
|
|
8502
|
+
const skLineText = "_skLineText_19inq_97";
|
|
8503
|
+
const skMeta = "_skMeta_19inq_105";
|
|
8504
|
+
const skBadge = "_skBadge_19inq_112";
|
|
8505
|
+
const skPrice = "_skPrice_19inq_116";
|
|
8506
|
+
const skCard = "_skCard_19inq_124";
|
|
8507
|
+
const skAddress = "_skAddress_19inq_132";
|
|
8508
|
+
const skSummary = "_skSummary_19inq_137";
|
|
8509
|
+
const skCell = "_skCell_19inq_145";
|
|
8510
|
+
const skHelp = "_skHelp_19inq_150";
|
|
8443
8511
|
const styles$B = {
|
|
8444
8512
|
crumbs,
|
|
8445
8513
|
help: help$2,
|
|
@@ -8644,25 +8712,25 @@ function SkStep({ lines: lines2 }) {
|
|
|
8644
8712
|
})]
|
|
8645
8713
|
});
|
|
8646
8714
|
}
|
|
8647
|
-
const page$3 = "
|
|
8648
|
-
const widget = "
|
|
8649
|
-
const titleRow = "
|
|
8650
|
-
const headline$2 = "
|
|
8651
|
-
const track$5 = "
|
|
8652
|
-
const rule$1 = "
|
|
8653
|
-
const help$1 = "
|
|
8654
|
-
const helpTitle = "
|
|
8655
|
-
const helpRows = "
|
|
8656
|
-
const helpRowEnd = "
|
|
8657
|
-
const helpStatus = "
|
|
8658
|
-
const helpRow = "
|
|
8659
|
-
const cancel = "
|
|
8660
|
-
const cancelledHead = "
|
|
8661
|
-
const cancelledTitle = "
|
|
8662
|
-
const cancelledMeta = "
|
|
8663
|
-
const aside$1 = "
|
|
8664
|
-
const phoneSkeleton$1 = "
|
|
8665
|
-
const wide$2 = "
|
|
8715
|
+
const page$3 = "_page_j9tz4_8";
|
|
8716
|
+
const widget = "_widget_j9tz4_18";
|
|
8717
|
+
const titleRow = "_titleRow_j9tz4_26";
|
|
8718
|
+
const headline$2 = "_headline_j9tz4_42";
|
|
8719
|
+
const track$5 = "_track_j9tz4_74";
|
|
8720
|
+
const rule$1 = "_rule_j9tz4_99";
|
|
8721
|
+
const help$1 = "_help_j9tz4_109";
|
|
8722
|
+
const helpTitle = "_helpTitle_j9tz4_115";
|
|
8723
|
+
const helpRows = "_helpRows_j9tz4_122";
|
|
8724
|
+
const helpRowEnd = "_helpRowEnd_j9tz4_131";
|
|
8725
|
+
const helpStatus = "_helpStatus_j9tz4_139";
|
|
8726
|
+
const helpRow = "_helpRow_j9tz4_122";
|
|
8727
|
+
const cancel = "_cancel_j9tz4_197";
|
|
8728
|
+
const cancelledHead = "_cancelledHead_j9tz4_221";
|
|
8729
|
+
const cancelledTitle = "_cancelledTitle_j9tz4_227";
|
|
8730
|
+
const cancelledMeta = "_cancelledMeta_j9tz4_241";
|
|
8731
|
+
const aside$1 = "_aside_j9tz4_249";
|
|
8732
|
+
const phoneSkeleton$1 = "_phoneSkeleton_j9tz4_254";
|
|
8733
|
+
const wide$2 = "_wide_j9tz4_258";
|
|
8666
8734
|
const styles$A = {
|
|
8667
8735
|
page: page$3,
|
|
8668
8736
|
widget,
|
|
@@ -9039,16 +9107,16 @@ function HelpRow({ label: label2, status, onClick }) {
|
|
|
9039
9107
|
function shortRef$1(orderRef) {
|
|
9040
9108
|
return orderRef.replace(/^ord_/, "");
|
|
9041
9109
|
}
|
|
9042
|
-
const page$2 = "
|
|
9043
|
-
const confirmed = "
|
|
9044
|
-
const title$h = "
|
|
9045
|
-
const headline$1 = "
|
|
9046
|
-
const subtitle$4 = "
|
|
9047
|
-
const rule = "
|
|
9048
|
-
const done = "
|
|
9049
|
-
const aside = "
|
|
9050
|
-
const phoneSkeleton = "
|
|
9051
|
-
const wide$1 = "
|
|
9110
|
+
const page$2 = "_page_1c6sm_6";
|
|
9111
|
+
const confirmed = "_confirmed_1c6sm_16";
|
|
9112
|
+
const title$h = "_title_1c6sm_22";
|
|
9113
|
+
const headline$1 = "_headline_1c6sm_47";
|
|
9114
|
+
const subtitle$4 = "_subtitle_1c6sm_65";
|
|
9115
|
+
const rule = "_rule_1c6sm_77";
|
|
9116
|
+
const done = "_done_1c6sm_94";
|
|
9117
|
+
const aside = "_aside_1c6sm_98";
|
|
9118
|
+
const phoneSkeleton = "_phoneSkeleton_1c6sm_103";
|
|
9119
|
+
const wide$1 = "_wide_1c6sm_107";
|
|
9052
9120
|
const styles$z = {
|
|
9053
9121
|
page: page$2,
|
|
9054
9122
|
confirmed,
|
|
@@ -10064,6 +10132,16 @@ function BottomSheet({ open, onClose, title: title2, children, footer: footer2 }
|
|
|
10064
10132
|
})]
|
|
10065
10133
|
});
|
|
10066
10134
|
}
|
|
10135
|
+
function messageToNative(message2) {
|
|
10136
|
+
if (typeof window === "undefined") return;
|
|
10137
|
+
const host = window;
|
|
10138
|
+
if (!host.dazn?.native?.isNative) return;
|
|
10139
|
+
try {
|
|
10140
|
+
host.daznNativeBridge?.messageToNative?.(message2);
|
|
10141
|
+
} catch {
|
|
10142
|
+
return;
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10067
10145
|
const LOW_STOCK_THRESHOLD = 5;
|
|
10068
10146
|
function isLowStock(available) {
|
|
10069
10147
|
return available !== void 0 && available > 0 && available <= LOW_STOCK_THRESHOLD;
|
|
@@ -10426,22 +10504,28 @@ function CartViewContent({ onContinueShopping, checkoutLabel } = {}) {
|
|
|
10426
10504
|
const t = useT();
|
|
10427
10505
|
const toast2 = useToast();
|
|
10428
10506
|
const { api, emit } = useShop();
|
|
10429
|
-
const
|
|
10430
|
-
const [
|
|
10507
|
+
const carts = useCartCache();
|
|
10508
|
+
const [cart2, setCart] = useState(() => carts?.get() ?? null);
|
|
10509
|
+
const [state, setState] = useState(() => {
|
|
10510
|
+
const seeded = carts?.get();
|
|
10511
|
+
if (!seeded) return "loading";
|
|
10512
|
+
return seeded.items.length === 0 ? "empty" : "ready";
|
|
10513
|
+
});
|
|
10431
10514
|
const [errorCode, setErrorCode] = useState(void 0);
|
|
10432
10515
|
const [pendingSku, setPendingSku] = useState(null);
|
|
10433
10516
|
const [handingOff, setHandingOff] = useState(false);
|
|
10434
10517
|
const load = useCallback(async () => {
|
|
10435
|
-
setState("loading");
|
|
10518
|
+
if (!carts?.get()) setState("loading");
|
|
10436
10519
|
try {
|
|
10437
|
-
const
|
|
10520
|
+
const fetched = await api.cart.get();
|
|
10521
|
+
const next = carts?.get() ?? fetched;
|
|
10438
10522
|
setCart(next);
|
|
10439
10523
|
setState(next.items.length === 0 ? "empty" : "ready");
|
|
10440
10524
|
} catch (err) {
|
|
10441
10525
|
setErrorCode(codeOf(err));
|
|
10442
10526
|
setState("error");
|
|
10443
10527
|
}
|
|
10444
|
-
}, [api]);
|
|
10528
|
+
}, [api, carts]);
|
|
10445
10529
|
useEffect(() => {
|
|
10446
10530
|
void load();
|
|
10447
10531
|
}, [load]);
|
|
@@ -10561,6 +10645,7 @@ function CartViewContent({ onContinueShopping, checkoutLabel } = {}) {
|
|
|
10561
10645
|
});
|
|
10562
10646
|
}
|
|
10563
10647
|
async function handOff(current2) {
|
|
10648
|
+
messageToNative("showLoader");
|
|
10564
10649
|
setHandingOff(true);
|
|
10565
10650
|
try {
|
|
10566
10651
|
const { checkout_url } = await api.cart.handoff();
|
|
@@ -10620,7 +10705,7 @@ function CartViewContent({ onContinueShopping, checkoutLabel } = {}) {
|
|
|
10620
10705
|
children: jsx(Button, {
|
|
10621
10706
|
variant: "primary",
|
|
10622
10707
|
onClick: () => void handOff(cart2),
|
|
10623
|
-
|
|
10708
|
+
loading: handingOff,
|
|
10624
10709
|
children: checkoutLabel ?? t("Proceed to checkout")
|
|
10625
10710
|
})
|
|
10626
10711
|
})]
|
|
@@ -12929,7 +13014,11 @@ function useCartCount() {
|
|
|
12929
13014
|
const shop = useShopOptional();
|
|
12930
13015
|
const api = shop?.api;
|
|
12931
13016
|
const subscribe = shop?.subscribe;
|
|
12932
|
-
const
|
|
13017
|
+
const carts = useCartCache();
|
|
13018
|
+
const [count2, setCount] = useState(() => {
|
|
13019
|
+
const seeded = carts?.get();
|
|
13020
|
+
return seeded ? seeded.items.reduce((n, i) => n + i.qty, 0) : null;
|
|
13021
|
+
});
|
|
12933
13022
|
useEffect(() => {
|
|
12934
13023
|
if (!api) return;
|
|
12935
13024
|
let live = true;
|