@nok-integration/storefront-react 0.29.5 → 0.29.6
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.d.ts +1 -0
- package/dist/index.mjs +28 -5
- package/dist/standalone/storefront.mjs +28 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6054,6 +6054,7 @@ declare interface ShopContextValue {
|
|
|
6054
6054
|
subscribe: (listener: OnEvent) => () => void;
|
|
6055
6055
|
navigate: (to: ShopRoute) => void;
|
|
6056
6056
|
prefetch: ((to: ShopRoute) => void) | null;
|
|
6057
|
+
hasSession: () => Promise<boolean>;
|
|
6057
6058
|
}
|
|
6058
6059
|
|
|
6059
6060
|
export declare type ShopEvent = {
|
package/dist/index.mjs
CHANGED
|
@@ -5749,6 +5749,14 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5749
5749
|
const getTokenRef = useRef(getToken);
|
|
5750
5750
|
getTokenRef.current = getToken;
|
|
5751
5751
|
const stableGetToken = useCallback(() => getTokenRef.current(), []);
|
|
5752
|
+
const hasSession = useCallback(async () => {
|
|
5753
|
+
if (sessionTransport === "cookie") return true;
|
|
5754
|
+
try {
|
|
5755
|
+
return Boolean(await getTokenRef.current());
|
|
5756
|
+
} catch {
|
|
5757
|
+
return false;
|
|
5758
|
+
}
|
|
5759
|
+
}, [sessionTransport]);
|
|
5752
5760
|
const productsRef = useRef(null);
|
|
5753
5761
|
productsRef.current ??= new ProductCache();
|
|
5754
5762
|
const products2 = productsRef.current;
|
|
@@ -5837,8 +5845,9 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5837
5845
|
emit,
|
|
5838
5846
|
subscribe,
|
|
5839
5847
|
navigate,
|
|
5840
|
-
prefetch: hostPrefetch ?? null
|
|
5841
|
-
|
|
5848
|
+
prefetch: hostPrefetch ?? null,
|
|
5849
|
+
hasSession
|
|
5850
|
+
}), [api, market, products2, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch, hasSession]);
|
|
5842
5851
|
return jsx(ShopContext.Provider, {
|
|
5843
5852
|
value: value2,
|
|
5844
5853
|
children: jsx(CartCacheContext.Provider, {
|
|
@@ -14999,7 +15008,7 @@ function heroFromProduct(product, ctaLabel) {
|
|
|
14999
15008
|
function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
15000
15009
|
const t = useT();
|
|
15001
15010
|
const toast2 = useToast();
|
|
15002
|
-
const { api, emit } = useShop();
|
|
15011
|
+
const { api, emit, hasSession } = useShop();
|
|
15003
15012
|
const navigate = useNavigate();
|
|
15004
15013
|
const sku = invite.items[0]?.product_sku ?? "";
|
|
15005
15014
|
const loaded = useProduct(sku, {
|
|
@@ -15012,7 +15021,21 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15012
15021
|
else window.location.assign(to);
|
|
15013
15022
|
}, [navigate]);
|
|
15014
15023
|
const fallback = useMemo(() => loaded.product ? heroFromProduct(loaded.product, t("See more")) : null, [loaded.product, t]);
|
|
15024
|
+
const shop2 = useCallback(async () => {
|
|
15025
|
+
if (await hasSession()) go(productPath);
|
|
15026
|
+
else emit({
|
|
15027
|
+
type: "session_required",
|
|
15028
|
+
action: "vip_claim"
|
|
15029
|
+
});
|
|
15030
|
+
}, [emit, go, hasSession, productPath]);
|
|
15015
15031
|
const claim = useCallback(async (variantSku) => {
|
|
15032
|
+
if (!await hasSession()) {
|
|
15033
|
+
emit({
|
|
15034
|
+
type: "session_required",
|
|
15035
|
+
action: "vip_claim"
|
|
15036
|
+
});
|
|
15037
|
+
return;
|
|
15038
|
+
}
|
|
15016
15039
|
try {
|
|
15017
15040
|
const current2 = await api.cart.get().catch(() => null);
|
|
15018
15041
|
if (current2?.vip?.invite_ref === invite.invite_ref) {
|
|
@@ -15053,12 +15076,12 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15053
15076
|
});
|
|
15054
15077
|
toast2.show(t(treatmentFor(code).body), "critical");
|
|
15055
15078
|
}
|
|
15056
|
-
}, [api, emit, invite.invite_ref, t, toast2, token]);
|
|
15079
|
+
}, [api, emit, hasSession, invite.invite_ref, t, toast2, token]);
|
|
15057
15080
|
if (screen2 === "hero") {
|
|
15058
15081
|
const hero2 = invite.hero ?? fallback;
|
|
15059
15082
|
if (hero2) return jsx(VipHero, {
|
|
15060
15083
|
hero: hero2,
|
|
15061
|
-
onContinue: () =>
|
|
15084
|
+
onContinue: () => void shop2()
|
|
15062
15085
|
});
|
|
15063
15086
|
} else if (loaded.product) {
|
|
15064
15087
|
return jsx(ProductDetail, {
|
|
@@ -5749,6 +5749,14 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5749
5749
|
const getTokenRef = useRef(getToken);
|
|
5750
5750
|
getTokenRef.current = getToken;
|
|
5751
5751
|
const stableGetToken = useCallback(() => getTokenRef.current(), []);
|
|
5752
|
+
const hasSession = useCallback(async () => {
|
|
5753
|
+
if (sessionTransport === "cookie") return true;
|
|
5754
|
+
try {
|
|
5755
|
+
return Boolean(await getTokenRef.current());
|
|
5756
|
+
} catch {
|
|
5757
|
+
return false;
|
|
5758
|
+
}
|
|
5759
|
+
}, [sessionTransport]);
|
|
5752
5760
|
const productsRef = useRef(null);
|
|
5753
5761
|
productsRef.current ??= new ProductCache();
|
|
5754
5762
|
const products2 = productsRef.current;
|
|
@@ -5837,8 +5845,9 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5837
5845
|
emit,
|
|
5838
5846
|
subscribe,
|
|
5839
5847
|
navigate,
|
|
5840
|
-
prefetch: hostPrefetch ?? null
|
|
5841
|
-
|
|
5848
|
+
prefetch: hostPrefetch ?? null,
|
|
5849
|
+
hasSession
|
|
5850
|
+
}), [api, market, products2, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch, hasSession]);
|
|
5842
5851
|
return jsx(ShopContext.Provider, {
|
|
5843
5852
|
value: value2,
|
|
5844
5853
|
children: jsx(CartCacheContext.Provider, {
|
|
@@ -14999,7 +15008,7 @@ function heroFromProduct(product, ctaLabel) {
|
|
|
14999
15008
|
function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
15000
15009
|
const t = useT();
|
|
15001
15010
|
const toast2 = useToast();
|
|
15002
|
-
const { api, emit } = useShop();
|
|
15011
|
+
const { api, emit, hasSession } = useShop();
|
|
15003
15012
|
const navigate = useNavigate();
|
|
15004
15013
|
const sku = invite.items[0]?.product_sku ?? "";
|
|
15005
15014
|
const loaded = useProduct(sku, {
|
|
@@ -15012,7 +15021,21 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15012
15021
|
else window.location.assign(to);
|
|
15013
15022
|
}, [navigate]);
|
|
15014
15023
|
const fallback = useMemo(() => loaded.product ? heroFromProduct(loaded.product, t("See more")) : null, [loaded.product, t]);
|
|
15024
|
+
const shop2 = useCallback(async () => {
|
|
15025
|
+
if (await hasSession()) go(productPath);
|
|
15026
|
+
else emit({
|
|
15027
|
+
type: "session_required",
|
|
15028
|
+
action: "vip_claim"
|
|
15029
|
+
});
|
|
15030
|
+
}, [emit, go, hasSession, productPath]);
|
|
15015
15031
|
const claim = useCallback(async (variantSku) => {
|
|
15032
|
+
if (!await hasSession()) {
|
|
15033
|
+
emit({
|
|
15034
|
+
type: "session_required",
|
|
15035
|
+
action: "vip_claim"
|
|
15036
|
+
});
|
|
15037
|
+
return;
|
|
15038
|
+
}
|
|
15016
15039
|
try {
|
|
15017
15040
|
const current2 = await api.cart.get().catch(() => null);
|
|
15018
15041
|
if (current2?.vip?.invite_ref === invite.invite_ref) {
|
|
@@ -15053,12 +15076,12 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15053
15076
|
});
|
|
15054
15077
|
toast2.show(t(treatmentFor(code).body), "critical");
|
|
15055
15078
|
}
|
|
15056
|
-
}, [api, emit, invite.invite_ref, t, toast2, token]);
|
|
15079
|
+
}, [api, emit, hasSession, invite.invite_ref, t, toast2, token]);
|
|
15057
15080
|
if (screen2 === "hero") {
|
|
15058
15081
|
const hero2 = invite.hero ?? fallback;
|
|
15059
15082
|
if (hero2) return jsx(VipHero, {
|
|
15060
15083
|
hero: hero2,
|
|
15061
|
-
onContinue: () =>
|
|
15084
|
+
onContinue: () => void shop2()
|
|
15062
15085
|
});
|
|
15063
15086
|
} else if (loaded.product) {
|
|
15064
15087
|
return jsx(ProductDetail, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nok-integration/storefront-react",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.6",
|
|
4
4
|
"description": "Mountable React storefront components: catalogue, product detail and cart, mounted directly into a host DOM tree. No iframe.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|