@instockng/storefront-ui 1.0.21 → 1.0.22
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/contexts/CartContext.d.ts +2 -0
- package/dist/contexts/CartContext.d.ts.map +1 -1
- package/dist/index134.mjs +2 -2
- package/dist/index135.mjs +1 -1
- package/dist/index136.mjs +6 -6
- package/dist/index137.mjs +2 -2
- package/dist/index138.mjs +2 -2
- package/dist/index140.mjs +2 -2
- package/dist/index141.mjs +2 -2
- package/dist/index142.mjs +1 -1
- package/dist/index144.mjs +8 -8
- package/dist/index145.mjs +8 -8
- package/dist/index150.mjs +1 -1
- package/dist/index151.mjs +1 -1
- package/dist/index152.mjs +1 -1
- package/dist/index153.mjs +1 -1
- package/dist/index154.mjs +1 -1
- package/dist/index156.mjs +1 -1
- package/dist/index157.mjs +1 -1
- package/dist/index159.mjs +2 -2
- package/dist/index160.mjs +1 -1
- package/dist/index165.mjs +2 -2
- package/dist/index167.mjs +1 -1
- package/dist/index169.mjs +2 -2
- package/dist/index170.mjs +5 -5
- package/dist/index173.mjs +1 -1
- package/dist/index176.mjs +1 -1
- package/dist/index179.mjs +1 -1
- package/dist/index180.mjs +1 -1
- package/dist/index184.mjs +1 -1
- package/dist/index186.mjs +1 -1
- package/dist/index190.mjs +1 -1
- package/dist/index192.mjs +1 -1
- package/dist/index201.mjs +2 -2
- package/dist/index203.mjs +1 -1
- package/dist/index204.mjs +1 -1
- package/dist/index205.mjs +2 -31
- package/dist/index206.mjs +2 -11
- package/dist/index207.mjs +2 -4
- package/dist/index208.mjs +2 -4
- package/dist/index209.mjs +2 -13
- package/dist/index210.mjs +2 -7
- package/dist/index211.mjs +2 -12
- package/dist/index212.mjs +2 -5
- package/dist/index213.mjs +108 -33
- package/dist/index214.mjs +2 -31
- package/dist/index215.mjs +2 -28
- package/dist/index216.mjs +34 -58
- package/dist/index217.mjs +2 -2
- package/dist/index218.mjs +244 -2
- package/dist/index219.mjs +2 -2
- package/dist/index220.mjs +33 -2
- package/dist/index221.mjs +65 -2
- package/dist/index222.mjs +25 -2
- package/dist/index225.mjs +2 -108
- package/dist/index226.mjs +2 -2
- package/dist/index227.mjs +2 -2
- package/dist/index228.mjs +2 -2
- package/dist/index229.mjs +2 -37
- package/dist/index230.mjs +2 -2
- package/dist/index231.mjs +2 -244
- package/dist/index232.mjs +2 -2
- package/dist/index233.mjs +4 -33
- package/dist/index234.mjs +2 -65
- package/dist/index235.mjs +2 -25
- package/dist/index236.mjs +31 -2
- package/dist/index237.mjs +11 -2
- package/dist/index238.mjs +4 -2
- package/dist/index239.mjs +4 -2
- package/dist/index240.mjs +13 -2
- package/dist/index241.mjs +7 -2
- package/dist/index242.mjs +12 -2
- package/dist/index243.mjs +5 -2
- package/dist/index244.mjs +33 -2
- package/dist/index245.mjs +31 -4
- package/dist/index246.mjs +28 -2
- package/dist/index247.mjs +61 -2
- package/dist/index25.mjs +48 -48
- package/dist/index252.mjs +2 -2
- package/dist/index253.mjs +2 -2
- package/dist/index254.mjs +2 -2
- package/dist/index255.mjs +91 -2
- package/dist/index256.mjs +2 -91
- package/dist/index257.mjs +1 -2
- package/dist/index258.mjs +3 -2
- package/dist/index259.mjs +2 -2
- package/dist/index260.mjs +2 -17
- package/dist/index261.mjs +15 -11
- package/dist/index262.mjs +13 -6
- package/dist/index263.mjs +6 -30
- package/dist/index264.mjs +30 -2
- package/dist/index3.mjs +133 -102
- package/dist/index32.mjs +26 -26
- package/dist/index37.mjs +2 -2
- package/dist/index38.mjs +2 -2
- package/dist/index4.mjs +50 -49
- package/dist/index42.mjs +1 -1
- package/dist/index47.mjs +17 -17
- package/dist/index48.mjs +2 -2
- package/dist/index60.mjs +21 -20
- package/dist/index61.mjs +2 -24
- package/dist/index62.mjs +19 -149
- package/dist/index63.mjs +153 -2
- package/dist/index66.mjs +2 -2
- package/dist/index73.mjs +1 -1
- package/dist/index75.mjs +2 -235
- package/dist/index76.mjs +233 -4
- package/dist/index77.mjs +5 -133
- package/dist/index78.mjs +129 -63
- package/dist/index79.mjs +67 -86
- package/dist/index80.mjs +85 -27
- package/dist/index81.mjs +28 -8
- package/dist/index82.mjs +8 -74
- package/dist/index83.mjs +74 -3
- package/dist/index84.mjs +4 -2
- package/dist/index85.mjs +2 -83
- package/dist/index86.mjs +81 -52
- package/dist/index87.mjs +53 -5
- package/dist/index88.mjs +5 -4
- package/dist/index89.mjs +4 -178
- package/dist/index90.mjs +174 -48
- package/dist/index91.mjs +51 -67
- package/dist/index92.mjs +69 -34
- package/dist/index93.mjs +31 -40
- package/dist/index94.mjs +43 -2
- package/dist/providers/MetaPixelProvider.d.ts +10 -5
- package/dist/providers/MetaPixelProvider.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/contexts/CartContext.tsx +69 -6
- package/src/providers/MetaPixelProvider.tsx +24 -16
package/dist/index256.mjs
CHANGED
|
@@ -1,94 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
var l;
|
|
4
|
-
function T() {
|
|
5
|
-
return l ? c.exports : (l = 1, (() => {
|
|
6
|
-
typeof __nccwpck_require__ < "u" && (__nccwpck_require__.ab = __dirname + "/");
|
|
7
|
-
var m = {};
|
|
8
|
-
(() => {
|
|
9
|
-
var v = m;
|
|
10
|
-
/*!
|
|
11
|
-
* cookie
|
|
12
|
-
* Copyright(c) 2012-2014 Roman Shtylman
|
|
13
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
14
|
-
* MIT Licensed
|
|
15
|
-
*/
|
|
16
|
-
v.parse = S, v.serialize = x;
|
|
17
|
-
var w = decodeURIComponent, h = encodeURIComponent, y = /; */, f = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
18
|
-
function S(i, n) {
|
|
19
|
-
if (typeof i != "string")
|
|
20
|
-
throw new TypeError("argument str must be a string");
|
|
21
|
-
for (var a = {}, e = n || {}, o = i.split(y), s = e.decode || w, r = 0; r < o.length; r++) {
|
|
22
|
-
var t = o[r], p = t.indexOf("=");
|
|
23
|
-
if (!(p < 0)) {
|
|
24
|
-
var d = t.substr(0, p).trim(), u = t.substr(++p, t.length).trim();
|
|
25
|
-
u[0] == '"' && (u = u.slice(1, -1)), a[d] == null && (a[d] = _(u, s));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return a;
|
|
29
|
-
}
|
|
30
|
-
function x(i, n, a) {
|
|
31
|
-
var e = a || {}, o = e.encode || h;
|
|
32
|
-
if (typeof o != "function")
|
|
33
|
-
throw new TypeError("option encode is invalid");
|
|
34
|
-
if (!f.test(i))
|
|
35
|
-
throw new TypeError("argument name is invalid");
|
|
36
|
-
var s = o(n);
|
|
37
|
-
if (s && !f.test(s))
|
|
38
|
-
throw new TypeError("argument val is invalid");
|
|
39
|
-
var r = i + "=" + s;
|
|
40
|
-
if (e.maxAge != null) {
|
|
41
|
-
var t = e.maxAge - 0;
|
|
42
|
-
if (isNaN(t) || !isFinite(t))
|
|
43
|
-
throw new TypeError("option maxAge is invalid");
|
|
44
|
-
r += "; Max-Age=" + Math.floor(t);
|
|
45
|
-
}
|
|
46
|
-
if (e.domain) {
|
|
47
|
-
if (!f.test(e.domain))
|
|
48
|
-
throw new TypeError("option domain is invalid");
|
|
49
|
-
r += "; Domain=" + e.domain;
|
|
50
|
-
}
|
|
51
|
-
if (e.path) {
|
|
52
|
-
if (!f.test(e.path))
|
|
53
|
-
throw new TypeError("option path is invalid");
|
|
54
|
-
r += "; Path=" + e.path;
|
|
55
|
-
}
|
|
56
|
-
if (e.expires) {
|
|
57
|
-
if (typeof e.expires.toUTCString != "function")
|
|
58
|
-
throw new TypeError("option expires is invalid");
|
|
59
|
-
r += "; Expires=" + e.expires.toUTCString();
|
|
60
|
-
}
|
|
61
|
-
if (e.httpOnly && (r += "; HttpOnly"), e.secure && (r += "; Secure"), e.sameSite) {
|
|
62
|
-
var p = typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite;
|
|
63
|
-
switch (p) {
|
|
64
|
-
case !0:
|
|
65
|
-
r += "; SameSite=Strict";
|
|
66
|
-
break;
|
|
67
|
-
case "lax":
|
|
68
|
-
r += "; SameSite=Lax";
|
|
69
|
-
break;
|
|
70
|
-
case "strict":
|
|
71
|
-
r += "; SameSite=Strict";
|
|
72
|
-
break;
|
|
73
|
-
case "none":
|
|
74
|
-
r += "; SameSite=None";
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
throw new TypeError("option sameSite is invalid");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return r;
|
|
81
|
-
}
|
|
82
|
-
function _(i, n) {
|
|
83
|
-
try {
|
|
84
|
-
return n(i);
|
|
85
|
-
} catch {
|
|
86
|
-
return i;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
})(), c.exports = m;
|
|
90
|
-
})(), c.exports);
|
|
91
|
-
}
|
|
2
|
+
var e = {};
|
|
92
3
|
export {
|
|
93
|
-
|
|
4
|
+
e as __exports
|
|
94
5
|
};
|
package/dist/index257.mjs
CHANGED
package/dist/index258.mjs
CHANGED
package/dist/index259.mjs
CHANGED
package/dist/index260.mjs
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
t = t || 10;
|
|
4
|
-
const c = new Array(t), o = new Array(t);
|
|
5
|
-
let e = 0, r = 0, i;
|
|
6
|
-
return n = n !== void 0 ? n : 1e3, function(h) {
|
|
7
|
-
const d = Date.now(), a = o[r];
|
|
8
|
-
i || (i = d), c[e] = h, o[e] = d;
|
|
9
|
-
let f = r, u = 0;
|
|
10
|
-
for (; f !== e; )
|
|
11
|
-
u += c[f++], f = f % t;
|
|
12
|
-
if (e = (e + 1) % t, e === r && (r = (r + 1) % t), d - i < n)
|
|
13
|
-
return;
|
|
14
|
-
const w = a && d - a;
|
|
15
|
-
return w ? Math.round(u * 1e3 / w) : void 0;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
2
|
+
const l = typeof Blob < "u" ? Blob : null;
|
|
18
3
|
export {
|
|
19
|
-
|
|
4
|
+
l as default
|
|
20
5
|
};
|
package/dist/index261.mjs
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
2
|
+
function y(t, n) {
|
|
3
|
+
t = t || 10;
|
|
4
|
+
const c = new Array(t), o = new Array(t);
|
|
5
|
+
let e = 0, r = 0, i;
|
|
6
|
+
return n = n !== void 0 ? n : 1e3, function(h) {
|
|
7
|
+
const d = Date.now(), a = o[r];
|
|
8
|
+
i || (i = d), c[e] = h, o[e] = d;
|
|
9
|
+
let f = r, u = 0;
|
|
10
|
+
for (; f !== e; )
|
|
11
|
+
u += c[f++], f = f % t;
|
|
12
|
+
if (e = (e + 1) % t, e === r && (r = (r + 1) % t), d - i < n)
|
|
13
|
+
return;
|
|
14
|
+
const w = a && d - a;
|
|
15
|
+
return w ? Math.round(u * 1e3 / w) : void 0;
|
|
6
16
|
};
|
|
7
|
-
return [(...l) => {
|
|
8
|
-
const o = Date.now(), i = o - s;
|
|
9
|
-
i >= u ? n(l, o) : (e = l, t || (t = setTimeout(() => {
|
|
10
|
-
t = null, n(e);
|
|
11
|
-
}, u - i)));
|
|
12
|
-
}, () => e && n(e)];
|
|
13
17
|
}
|
|
14
18
|
export {
|
|
15
|
-
|
|
19
|
+
y as default
|
|
16
20
|
};
|
package/dist/index262.mjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
function h(r, a) {
|
|
3
|
+
let s = 0, u = 1e3 / a, e, t;
|
|
4
|
+
const n = (l, o = Date.now()) => {
|
|
5
|
+
s = o, e = null, t && (clearTimeout(t), t = null), r(...l);
|
|
6
|
+
};
|
|
7
|
+
return [(...l) => {
|
|
8
|
+
const o = Date.now(), i = o - s;
|
|
9
|
+
i >= u ? n(l, o) : (e = l, t || (t = setTimeout(() => {
|
|
10
|
+
t = null, n(e);
|
|
11
|
+
}, u - i)));
|
|
12
|
+
}, () => e && n(e)];
|
|
13
|
+
}
|
|
7
14
|
export {
|
|
8
|
-
|
|
15
|
+
h as default
|
|
9
16
|
};
|
package/dist/index263.mjs
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
write(e, t, n, i, s, u) {
|
|
8
|
-
const o = [e + "=" + encodeURIComponent(t)];
|
|
9
|
-
r.isNumber(n) && o.push("expires=" + new Date(n).toGMTString()), r.isString(i) && o.push("path=" + i), r.isString(s) && o.push("domain=" + s), u === !0 && o.push("secure"), document.cookie = o.join("; ");
|
|
10
|
-
},
|
|
11
|
-
read(e) {
|
|
12
|
-
const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
|
|
13
|
-
return t ? decodeURIComponent(t[3]) : null;
|
|
14
|
-
},
|
|
15
|
-
remove(e) {
|
|
16
|
-
this.write(e, "", Date.now() - 864e5);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
) : (
|
|
20
|
-
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
21
|
-
{
|
|
22
|
-
write() {
|
|
23
|
-
},
|
|
24
|
-
read() {
|
|
25
|
-
return null;
|
|
26
|
-
},
|
|
27
|
-
remove() {
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
);
|
|
2
|
+
import o from "./index141.mjs";
|
|
3
|
+
const n = o.hasStandardBrowserEnv ? /* @__PURE__ */ ((r, e) => (t) => (t = new URL(t, o.origin), r.protocol === t.protocol && r.host === t.host && (e || r.port === t.port)))(
|
|
4
|
+
new URL(o.origin),
|
|
5
|
+
o.navigator && /(msie|trident)/i.test(o.navigator.userAgent)
|
|
6
|
+
) : () => !0;
|
|
31
7
|
export {
|
|
32
|
-
|
|
8
|
+
n as default
|
|
33
9
|
};
|
package/dist/index264.mjs
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
2
|
+
import r from "./index76.mjs";
|
|
3
|
+
import c from "./index141.mjs";
|
|
4
|
+
const p = c.hasStandardBrowserEnv ? (
|
|
5
|
+
// Standard browser envs support document.cookie
|
|
6
|
+
{
|
|
7
|
+
write(e, t, n, i, s, u) {
|
|
8
|
+
const o = [e + "=" + encodeURIComponent(t)];
|
|
9
|
+
r.isNumber(n) && o.push("expires=" + new Date(n).toGMTString()), r.isString(i) && o.push("path=" + i), r.isString(s) && o.push("domain=" + s), u === !0 && o.push("secure"), document.cookie = o.join("; ");
|
|
10
|
+
},
|
|
11
|
+
read(e) {
|
|
12
|
+
const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
|
|
13
|
+
return t ? decodeURIComponent(t[3]) : null;
|
|
14
|
+
},
|
|
15
|
+
remove(e) {
|
|
16
|
+
this.write(e, "", Date.now() - 864e5);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
) : (
|
|
20
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
21
|
+
{
|
|
22
|
+
write() {
|
|
23
|
+
},
|
|
24
|
+
read() {
|
|
25
|
+
return null;
|
|
26
|
+
},
|
|
27
|
+
remove() {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
3
31
|
export {
|
|
4
|
-
|
|
32
|
+
p as default
|
|
5
33
|
};
|
package/dist/index3.mjs
CHANGED
|
@@ -1,170 +1,201 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
2
|
+
import { jsxs as nt, jsx as ct } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as st, useState as k, useRef as _, useCallback as c, useEffect as d, useContext as at } from "react";
|
|
4
4
|
import "./index20.mjs";
|
|
5
|
-
import { useGetCart as
|
|
5
|
+
import { useGetCart as ut, useCreateCart as it, useAddCartItem as ft, useUpdateCartItem as mt, useRemoveCartItem as dt, useApplyDiscount as lt, useRemoveDiscount as pt, useUpdateCart as Ct, useCheckoutCart as It } from "./index32.mjs";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
|
-
import { ShoppingCart as
|
|
8
|
-
import { useMetaPixel as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
const [t,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import { ShoppingCart as wt } from "./index10.mjs";
|
|
8
|
+
import { useMetaPixel as ht } from "./index4.mjs";
|
|
9
|
+
const l = "oms_cart_id", F = st(null);
|
|
10
|
+
function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L }) {
|
|
11
|
+
const [t, f] = k(C || null), [g, A] = k(!1), [U, j] = k(!1), S = _(!1), b = _(!1), w = _(!1), { trackAddToCart: h, trackInitiateCheckout: M, trackPurchase: G } = ht(), E = c(() => {
|
|
12
|
+
if (typeof document > "u") return { fbc: void 0, fbp: void 0 };
|
|
13
|
+
const e = (r) => {
|
|
14
|
+
var o;
|
|
15
|
+
const n = `; ${document.cookie}`.split(`; ${r}=`);
|
|
16
|
+
if (n.length === 2) return (o = n.pop()) == null ? void 0 : o.split(";").shift();
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
fbc: e("_fbc"),
|
|
20
|
+
fbp: e("_fbp")
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
d(() => {
|
|
24
|
+
j(!0);
|
|
25
|
+
}, []), d(() => {
|
|
26
|
+
if (C || S.current) return;
|
|
16
27
|
S.current = !0;
|
|
17
28
|
const r = new URLSearchParams(window.location.search).get("cartId");
|
|
18
29
|
if (r) {
|
|
19
|
-
|
|
30
|
+
f(r);
|
|
20
31
|
return;
|
|
21
32
|
}
|
|
22
|
-
const s = localStorage.getItem(
|
|
23
|
-
s &&
|
|
24
|
-
}, [
|
|
25
|
-
const { data:
|
|
33
|
+
const s = localStorage.getItem(l);
|
|
34
|
+
s && f(s);
|
|
35
|
+
}, [C]);
|
|
36
|
+
const { data: m, isLoading: O, error: I, refetch: a } = ut(t || "", {
|
|
26
37
|
enabled: !!t,
|
|
27
38
|
retry: !1
|
|
28
39
|
// Don't retry on failure - cart might be invalid/expired
|
|
29
|
-
}),
|
|
40
|
+
}), v = it({
|
|
30
41
|
onSuccess: (e) => {
|
|
31
42
|
if ("error" in e) {
|
|
32
43
|
console.error("Failed to create cart:", e.error);
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
|
-
|
|
46
|
+
f(e.id);
|
|
36
47
|
},
|
|
37
48
|
onError: (e) => {
|
|
38
49
|
console.error("Failed to create cart:", e);
|
|
39
50
|
},
|
|
40
51
|
retry: 10
|
|
41
52
|
});
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
53
|
+
d(() => {
|
|
54
|
+
if (b.current) return;
|
|
55
|
+
b.current = !0;
|
|
45
56
|
const e = setTimeout(() => {
|
|
46
|
-
!(typeof window < "u" ? localStorage.getItem(
|
|
57
|
+
!(typeof window < "u" ? localStorage.getItem(l) : null) && !C && v.mutate(i);
|
|
47
58
|
}, 150);
|
|
48
59
|
return () => clearTimeout(e);
|
|
49
|
-
}, []),
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
}, []), d(() => {
|
|
61
|
+
I && t && !w.current && (w.current = !0, console.warn("Cart fetch failed, creating new cart:", I), f(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
|
|
62
|
+
v.mutate(i), w.current = !1;
|
|
52
63
|
}, 100));
|
|
53
|
-
}, [
|
|
54
|
-
const
|
|
55
|
-
onSuccess: () =>
|
|
56
|
-
}),
|
|
57
|
-
onSuccess: () =>
|
|
58
|
-
}),
|
|
59
|
-
onSuccess: () =>
|
|
60
|
-
}),
|
|
61
|
-
onSuccess: () =>
|
|
62
|
-
}),
|
|
63
|
-
onSuccess: () =>
|
|
64
|
-
}),
|
|
65
|
-
onSuccess: () =>
|
|
64
|
+
}, [I, t, i]);
|
|
65
|
+
const q = ft(t || "", {
|
|
66
|
+
onSuccess: () => a()
|
|
67
|
+
}), H = mt(t || "", {
|
|
68
|
+
onSuccess: () => a()
|
|
69
|
+
}), K = dt(t || "", {
|
|
70
|
+
onSuccess: () => a()
|
|
71
|
+
}), Y = lt(t || "", {
|
|
72
|
+
onSuccess: () => a()
|
|
73
|
+
}), z = pt(t || "", {
|
|
74
|
+
onSuccess: () => a()
|
|
75
|
+
}), B = Ct(t || "", {
|
|
76
|
+
onSuccess: () => a(),
|
|
66
77
|
retry: 3
|
|
67
|
-
}),
|
|
78
|
+
}), J = It(t || "", {
|
|
68
79
|
onSuccess: (e) => {
|
|
69
|
-
var
|
|
80
|
+
var n;
|
|
70
81
|
if ("error" in e) return;
|
|
71
|
-
const r = ((
|
|
72
|
-
var
|
|
82
|
+
const r = ((n = e.items) == null ? void 0 : n.map((o) => {
|
|
83
|
+
var u;
|
|
73
84
|
return {
|
|
74
|
-
id: ((
|
|
75
|
-
quantity:
|
|
76
|
-
item_price: Number(
|
|
85
|
+
id: ((u = o.variant) == null ? void 0 : u.sku) || "",
|
|
86
|
+
quantity: o.quantity,
|
|
87
|
+
item_price: Number(o.priceAtPurchase)
|
|
77
88
|
};
|
|
78
|
-
})) || []
|
|
79
|
-
|
|
89
|
+
})) || [], s = `order_${e.id}`;
|
|
90
|
+
G(
|
|
80
91
|
Number(e.totalPrice),
|
|
81
92
|
"NGN",
|
|
82
93
|
e.id,
|
|
83
|
-
r
|
|
94
|
+
r,
|
|
95
|
+
s
|
|
84
96
|
);
|
|
85
97
|
}
|
|
86
98
|
});
|
|
87
|
-
|
|
88
|
-
t && typeof window < "u" && localStorage.setItem(
|
|
99
|
+
d(() => {
|
|
100
|
+
t && typeof window < "u" && localStorage.setItem(l, t);
|
|
89
101
|
}, [t]);
|
|
90
|
-
const
|
|
91
|
-
async (e, r, s,
|
|
102
|
+
const Q = c(
|
|
103
|
+
async (e, r, s, n, o) => {
|
|
104
|
+
var T;
|
|
92
105
|
if (!t) throw new Error("No cart ID");
|
|
93
|
-
|
|
106
|
+
const { fbc: u, fbp: y } = E(), x = await q.mutateAsync({ sku: n, quantity: o, fbc: u, fbp: y });
|
|
107
|
+
if ("error" in x) return;
|
|
108
|
+
const R = (T = x.items) == null ? void 0 : T.findLast(
|
|
109
|
+
(D) => {
|
|
110
|
+
var $;
|
|
111
|
+
return (($ = D.variant) == null ? void 0 : $.sku) === n;
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
if (R) {
|
|
115
|
+
const D = `cart_${t}_item_${R.id}`;
|
|
116
|
+
h(e, r, s, o, D);
|
|
117
|
+
} else
|
|
118
|
+
h(e, r, s, o);
|
|
94
119
|
},
|
|
95
120
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
[t,
|
|
97
|
-
),
|
|
121
|
+
[t, h, E]
|
|
122
|
+
), V = c(
|
|
98
123
|
async (e, r) => {
|
|
99
124
|
if (!t) throw new Error("No cart ID");
|
|
100
|
-
await
|
|
125
|
+
await H.mutateAsync({ itemId: e, quantity: r });
|
|
101
126
|
},
|
|
102
127
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
128
|
[t]
|
|
104
|
-
),
|
|
129
|
+
), W = c(
|
|
105
130
|
async (e) => {
|
|
106
131
|
if (!t) throw new Error("No cart ID");
|
|
107
|
-
await
|
|
132
|
+
await K.mutateAsync(e);
|
|
108
133
|
},
|
|
109
134
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
135
|
[t]
|
|
111
|
-
),
|
|
136
|
+
), X = c(
|
|
112
137
|
async (e) => {
|
|
113
138
|
if (!t) throw new Error("No cart ID");
|
|
114
|
-
await
|
|
139
|
+
await Y.mutateAsync({ code: e });
|
|
115
140
|
},
|
|
116
141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
142
|
[t]
|
|
118
|
-
),
|
|
143
|
+
), Z = c(async () => {
|
|
119
144
|
if (!t) throw new Error("No cart ID");
|
|
120
|
-
await
|
|
121
|
-
}, [t]),
|
|
122
|
-
|
|
123
|
-
}, []),
|
|
124
|
-
|
|
125
|
-
}, [
|
|
126
|
-
|
|
127
|
-
}, []),
|
|
128
|
-
|
|
129
|
-
}, []),
|
|
130
|
-
|
|
145
|
+
await z.mutateAsync();
|
|
146
|
+
}, [t]), N = c(() => {
|
|
147
|
+
f(null), typeof window < "u" && localStorage.removeItem(l);
|
|
148
|
+
}, []), tt = c(() => {
|
|
149
|
+
N(), v.mutate(i);
|
|
150
|
+
}, [i]), et = c(() => {
|
|
151
|
+
A(!0);
|
|
152
|
+
}, []), P = c(() => {
|
|
153
|
+
A(!1);
|
|
154
|
+
}, []), rt = c(() => {
|
|
155
|
+
var n, o;
|
|
156
|
+
if (!m || !t) return;
|
|
157
|
+
const e = Number(((n = m.pricing) == null ? void 0 : n.total) || 0), r = ((o = m.items) == null ? void 0 : o.reduce((u, y) => u + y.quantity, 0)) || 0, s = `cart_${t}_checkout`;
|
|
158
|
+
M(e, r, s);
|
|
159
|
+
}, [m, t, M]), ot = {
|
|
160
|
+
cart: m || null,
|
|
131
161
|
cartId: t,
|
|
132
|
-
isLoading:
|
|
133
|
-
error:
|
|
134
|
-
updateCartMutation:
|
|
135
|
-
checkoutMutation:
|
|
136
|
-
addItem:
|
|
137
|
-
updateItem:
|
|
138
|
-
removeItem:
|
|
139
|
-
applyDiscount:
|
|
140
|
-
removeDiscount:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
162
|
+
isLoading: O,
|
|
163
|
+
error: I,
|
|
164
|
+
updateCartMutation: B,
|
|
165
|
+
checkoutMutation: J,
|
|
166
|
+
addItem: Q,
|
|
167
|
+
updateItem: V,
|
|
168
|
+
removeItem: W,
|
|
169
|
+
applyDiscount: X,
|
|
170
|
+
removeDiscount: Z,
|
|
171
|
+
trackCheckoutInitiated: rt,
|
|
172
|
+
clearCart: N,
|
|
173
|
+
clearAndCreateNewCart: tt,
|
|
174
|
+
refetch: a,
|
|
175
|
+
isOpen: g,
|
|
176
|
+
open: et,
|
|
177
|
+
close: P
|
|
147
178
|
};
|
|
148
|
-
return /* @__PURE__ */
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
179
|
+
return /* @__PURE__ */ nt(F.Provider, { value: ot, children: [
|
|
180
|
+
p,
|
|
181
|
+
U && /* @__PURE__ */ ct(
|
|
182
|
+
wt,
|
|
152
183
|
{
|
|
153
|
-
isOpen:
|
|
154
|
-
onClose:
|
|
155
|
-
...
|
|
184
|
+
isOpen: g,
|
|
185
|
+
onClose: P,
|
|
186
|
+
...L
|
|
156
187
|
}
|
|
157
188
|
)
|
|
158
189
|
] });
|
|
159
190
|
}
|
|
160
|
-
function
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
191
|
+
function bt() {
|
|
192
|
+
const p = at(F);
|
|
193
|
+
if (!p)
|
|
163
194
|
throw new Error("useCart must be used within CartProvider");
|
|
164
|
-
return
|
|
195
|
+
return p;
|
|
165
196
|
}
|
|
166
197
|
export {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
198
|
+
F as CartContext,
|
|
199
|
+
St as CartProvider,
|
|
200
|
+
bt as useCart
|
|
170
201
|
};
|