@instockng/storefront-ui 1.0.70 → 1.0.72
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.map +1 -1
- package/dist/hooks/usePageTracking.d.ts +1 -1
- package/dist/hooks/usePageTracking.d.ts.map +1 -1
- package/dist/index.mjs +65 -63
- package/dist/index100.mjs +174 -28
- package/dist/index101.mjs +53 -2
- package/dist/index102.mjs +69 -2
- package/dist/index106.mjs +2 -2
- package/dist/index107.mjs +2 -2
- package/dist/index140.mjs +1 -1
- package/dist/index142.mjs +2 -21
- package/dist/index143.mjs +19 -54
- package/dist/index144.mjs +55 -28
- package/dist/index145.mjs +28 -6
- package/dist/index146.mjs +6 -51
- package/dist/index147.mjs +51 -5
- package/dist/index148.mjs +6 -12
- package/dist/index149.mjs +12 -7
- package/dist/index15.mjs +1 -1
- package/dist/index150.mjs +6 -27
- package/dist/index151.mjs +28 -2
- package/dist/index152.mjs +2 -70
- package/dist/index153.mjs +67 -164
- package/dist/index154.mjs +167 -2
- package/dist/index158.mjs +1 -1
- package/dist/index159.mjs +1 -1
- package/dist/index160.mjs +1 -1
- package/dist/index161.mjs +1 -1
- package/dist/index162.mjs +1 -1
- package/dist/index164.mjs +3 -3
- package/dist/index165.mjs +1 -1
- package/dist/index167.mjs +2 -2
- package/dist/index168.mjs +1 -1
- package/dist/index173.mjs +2 -2
- package/dist/index175.mjs +1 -1
- package/dist/index177.mjs +2 -2
- package/dist/index178.mjs +5 -5
- package/dist/index181.mjs +1 -1
- package/dist/index184.mjs +1 -1
- package/dist/index187.mjs +1 -1
- package/dist/index188.mjs +1 -1
- package/dist/index192.mjs +1 -1
- package/dist/index194.mjs +1 -1
- package/dist/index198.mjs +1 -1
- package/dist/index2.mjs +1 -1
- package/dist/index200.mjs +1 -1
- package/dist/index213.mjs +2 -13
- package/dist/index214.mjs +2 -7
- package/dist/index215.mjs +2 -31
- package/dist/index216.mjs +2 -11
- package/dist/index217.mjs +2 -4
- package/dist/index218.mjs +2 -4
- package/dist/index219.mjs +2 -12
- package/dist/index22.mjs +10 -6
- package/dist/index220.mjs +2 -5
- package/dist/index221.mjs +108 -33
- package/dist/index222.mjs +2 -31
- package/dist/index223.mjs +2 -28
- package/dist/index224.mjs +34 -58
- package/dist/index225.mjs +2 -2
- package/dist/index226.mjs +2 -2
- package/dist/index227.mjs +244 -2
- package/dist/index228.mjs +2 -2
- package/dist/index229.mjs +28 -103
- package/dist/index23.mjs +13 -14
- package/dist/index230.mjs +65 -2
- package/dist/index231.mjs +25 -2
- package/dist/index232.mjs +2 -2
- package/dist/index233.mjs +2 -2
- package/dist/index234.mjs +2 -2
- package/dist/index236.mjs +2 -37
- package/dist/index237.mjs +2 -2
- package/dist/index238.mjs +2 -244
- package/dist/index239.mjs +2 -2
- package/dist/index240.mjs +30 -32
- package/dist/index241.mjs +10 -64
- package/dist/index242.mjs +3 -24
- package/dist/index243.mjs +4 -2
- package/dist/index244.mjs +13 -2
- package/dist/index245.mjs +7 -2
- package/dist/index246.mjs +12 -2
- package/dist/index247.mjs +5 -2
- package/dist/index248.mjs +33 -2
- package/dist/index249.mjs +31 -2
- package/dist/index250.mjs +28 -2
- package/dist/index251.mjs +61 -2
- package/dist/index253.mjs +2 -2
- package/dist/index256.mjs +2 -3
- package/dist/index257.mjs +2 -2
- package/dist/index258.mjs +18 -2
- package/dist/index259.mjs +46 -16
- package/dist/index260.mjs +2 -13
- package/dist/index261.mjs +2 -6
- package/dist/index262.mjs +2 -30
- package/dist/index264.mjs +91 -2
- package/dist/index265.mjs +2 -2
- package/dist/index266.mjs +3 -2
- package/dist/index267.mjs +2 -2
- package/dist/index268.mjs +2 -91
- package/dist/index269.mjs +17 -2
- package/dist/index27.mjs +17 -17
- package/dist/index270.mjs +12 -17
- package/dist/index271.mjs +6 -47
- package/dist/index272.mjs +30 -2
- package/dist/index273.mjs +2 -2
- package/dist/index275.mjs +2 -2
- package/dist/index28.mjs +58 -47
- package/dist/index29.mjs +11 -11
- package/dist/index3.mjs +141 -123
- package/dist/index30.mjs +4 -4
- package/dist/index31.mjs +5 -5
- package/dist/index33.mjs +21 -20
- package/dist/index35.mjs +36 -29
- package/dist/index36.mjs +8 -25
- package/dist/index37.mjs +1 -1
- package/dist/index38.mjs +26 -9
- package/dist/index39.mjs +9 -9
- package/dist/index4.mjs +59 -46
- package/dist/index40.mjs +2 -2
- package/dist/index42.mjs +2 -2
- package/dist/index45.mjs +3 -3
- package/dist/index46.mjs +1 -1
- package/dist/index49.mjs +1 -1
- package/dist/index54.mjs +17 -17
- package/dist/index55.mjs +2 -2
- package/dist/index56.mjs +1 -1
- package/dist/index57.mjs +1 -1
- package/dist/index58.mjs +1 -1
- package/dist/index59.mjs +1 -1
- package/dist/index6.mjs +7 -7
- package/dist/index60.mjs +1 -1
- package/dist/index61.mjs +1 -1
- package/dist/index62.mjs +1 -1
- package/dist/index63.mjs +1 -1
- package/dist/index64.mjs +1 -1
- package/dist/index65.mjs +1 -1
- package/dist/index66.mjs +1 -1
- package/dist/index67.mjs +1 -1
- package/dist/index68.mjs +23 -4
- package/dist/index69.mjs +149 -19
- package/dist/index7.mjs +1 -1
- package/dist/index70.mjs +2 -24
- package/dist/index71.mjs +19 -149
- package/dist/index72.mjs +75 -2
- package/dist/index73.mjs +14 -74
- package/dist/index74.mjs +62 -14
- package/dist/index75.mjs +4 -62
- package/dist/index76.mjs +2 -34
- package/dist/index77.mjs +5 -42
- package/dist/index78.mjs +1129 -230
- package/dist/index79.mjs +19 -5
- package/dist/index80.mjs +48 -127
- package/dist/index81.mjs +32 -67
- package/dist/index82.mjs +2 -87
- package/dist/index83.mjs +2 -29
- package/dist/index84.mjs +34 -9
- package/dist/index85.mjs +39 -71
- package/dist/index86.mjs +234 -3
- package/dist/index87.mjs +6 -2
- package/dist/index88.mjs +128 -77
- package/dist/index89.mjs +67 -53
- package/dist/index90.mjs +86 -5
- package/dist/index91.mjs +28 -4
- package/dist/index92.mjs +7 -177
- package/dist/index93.mjs +72 -50
- package/dist/index94.mjs +4 -69
- package/dist/index95.mjs +2 -2
- package/dist/index96.mjs +82 -5
- package/dist/index97.mjs +53 -1133
- package/dist/index98.mjs +5 -19
- package/dist/index99.mjs +4 -54
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/providers/MetaPixelProvider.d.ts +3 -2
- package/dist/providers/MetaPixelProvider.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/contexts/CartContext.tsx +50 -22
- package/src/hooks/usePageTracking.ts +3 -3
- package/src/lib/utils.ts +11 -0
- package/src/providers/MetaPixelProvider.tsx +20 -6
package/dist/index272.mjs
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
2
|
+
import r from "./index86.mjs";
|
|
3
|
+
import c from "./index150.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/index273.mjs
CHANGED
package/dist/index275.mjs
CHANGED
package/dist/index28.mjs
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { createRpcClients as
|
|
3
|
-
|
|
4
|
-
async function
|
|
5
|
-
const s = await
|
|
6
|
-
param: { id:
|
|
2
|
+
import { createRpcClients as o } from "./index26.mjs";
|
|
3
|
+
const r = "https://oms-api.instock.com.ng";
|
|
4
|
+
async function m(n) {
|
|
5
|
+
const s = await o(r).carts[":id"].$get({
|
|
6
|
+
param: { id: n }
|
|
7
7
|
});
|
|
8
8
|
if (!s.ok)
|
|
9
9
|
throw new Error(`Failed to fetch cart: ${s.statusText}`);
|
|
10
10
|
return s.json();
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
13
|
-
const s = await
|
|
14
|
-
json: { brandSlug:
|
|
12
|
+
async function p(n) {
|
|
13
|
+
const s = await o(r).carts.index.$post({
|
|
14
|
+
json: { brandSlug: n }
|
|
15
15
|
});
|
|
16
16
|
if (!s.ok)
|
|
17
17
|
throw new Error(`Failed to create cart: ${s.statusText}`);
|
|
18
18
|
return s.json();
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
21
|
-
const t = await
|
|
22
|
-
param: { id:
|
|
20
|
+
async function w(n, e) {
|
|
21
|
+
const t = await o(r).carts[":id"].$patch({
|
|
22
|
+
param: { id: n },
|
|
23
23
|
// @ts-expect-error - Hono RPC type inference issue
|
|
24
|
-
json:
|
|
24
|
+
json: e
|
|
25
25
|
});
|
|
26
26
|
if (!t.ok)
|
|
27
27
|
throw new Error(`Failed to update cart: ${t.statusText}`);
|
|
28
28
|
return t.json();
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
const
|
|
32
|
-
param: { id:
|
|
30
|
+
async function f(n, e, s, t, a, c, d) {
|
|
31
|
+
const i = await o(r).carts[":id"].items.$post({
|
|
32
|
+
param: { id: n },
|
|
33
33
|
// @ts-expect-error - Hono RPC type inference issue
|
|
34
|
-
json: { sku:
|
|
34
|
+
json: { sku: e, quantity: s, fbc: t, fbp: a, ttp: c, ttclid: d }
|
|
35
35
|
});
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error(`Failed to add item to cart: ${
|
|
38
|
-
return
|
|
36
|
+
if (!i.ok)
|
|
37
|
+
throw new Error(`Failed to add item to cart: ${i.statusText}`);
|
|
38
|
+
return i.json();
|
|
39
39
|
}
|
|
40
|
-
async function h(
|
|
41
|
-
const a = await
|
|
42
|
-
param: { id:
|
|
40
|
+
async function h(n, e, s) {
|
|
41
|
+
const a = await o(r).carts[":id"].items[":itemId"].$patch({
|
|
42
|
+
param: { id: n, itemId: e },
|
|
43
43
|
// @ts-expect-error - Hono RPC type inference issue
|
|
44
44
|
json: { quantity: s }
|
|
45
45
|
});
|
|
@@ -47,61 +47,72 @@ async function h(e, r, s) {
|
|
|
47
47
|
throw new Error(`Failed to update cart item: ${a.statusText}`);
|
|
48
48
|
return a.json();
|
|
49
49
|
}
|
|
50
|
-
async function
|
|
51
|
-
const t = await
|
|
52
|
-
param: { id:
|
|
50
|
+
async function $(n, e) {
|
|
51
|
+
const t = await o(r).carts[":id"].items[":itemId"].$delete({
|
|
52
|
+
param: { id: n, itemId: e }
|
|
53
53
|
});
|
|
54
54
|
if (!t.ok)
|
|
55
55
|
throw new Error(`Failed to remove cart item: ${t.statusText}`);
|
|
56
56
|
return t.json();
|
|
57
57
|
}
|
|
58
|
-
async function
|
|
59
|
-
const t = await
|
|
60
|
-
param: { id:
|
|
58
|
+
async function j(n, e) {
|
|
59
|
+
const t = await o(r).carts[":id"]["apply-discount"].$post({
|
|
60
|
+
param: { id: n },
|
|
61
61
|
// @ts-expect-error - Hono RPC type inference issue
|
|
62
|
-
json: { code:
|
|
62
|
+
json: { code: e }
|
|
63
63
|
});
|
|
64
64
|
if (!t.ok)
|
|
65
65
|
throw new Error(`Failed to apply discount: ${t.statusText}`);
|
|
66
66
|
return t.json();
|
|
67
67
|
}
|
|
68
|
-
async function k(
|
|
69
|
-
const s = await
|
|
70
|
-
param: { id:
|
|
68
|
+
async function k(n) {
|
|
69
|
+
const s = await o(r).carts[":id"]["remove-discount"].$post({
|
|
70
|
+
param: { id: n }
|
|
71
71
|
});
|
|
72
72
|
if (!s.ok)
|
|
73
73
|
throw new Error(`Failed to remove discount: ${s.statusText}`);
|
|
74
74
|
return s.json();
|
|
75
75
|
}
|
|
76
|
-
async function
|
|
77
|
-
const t = await
|
|
78
|
-
param: { id:
|
|
76
|
+
async function y(n, e) {
|
|
77
|
+
const t = await o(r).carts[":id"].checkout.$post({
|
|
78
|
+
param: { id: n },
|
|
79
79
|
// @ts-expect-error - Hono RPC type inference issue
|
|
80
|
-
json:
|
|
80
|
+
json: e
|
|
81
81
|
});
|
|
82
82
|
if (!t.ok)
|
|
83
83
|
throw new Error(`Failed to checkout cart: ${t.statusText}`);
|
|
84
84
|
return t.json();
|
|
85
85
|
}
|
|
86
|
-
async function
|
|
87
|
-
const t = await
|
|
88
|
-
param: { id:
|
|
86
|
+
async function x(n, e) {
|
|
87
|
+
const t = await o(r).carts[":id"]["initiate-checkout"].$post({
|
|
88
|
+
param: { id: n },
|
|
89
|
+
// @ts-expect-error - Hono RPC type inference issue
|
|
90
|
+
json: e
|
|
91
|
+
});
|
|
92
|
+
if (!t.ok)
|
|
93
|
+
throw new Error(`Failed to initiate checkout intent: ${t.statusText}`);
|
|
94
|
+
return t.json();
|
|
95
|
+
}
|
|
96
|
+
async function E(n, e) {
|
|
97
|
+
const t = await o(r).carts[":id"].recommendations.$get({
|
|
98
|
+
param: { id: n },
|
|
89
99
|
// @ts-ignore - Hono RPC type inference issue with query parameters
|
|
90
|
-
query: { limit:
|
|
100
|
+
query: { limit: e.toString() }
|
|
91
101
|
});
|
|
92
102
|
if (!t.ok)
|
|
93
103
|
throw new Error(`Failed to fetch cart recommendations: ${t.statusText}`);
|
|
94
104
|
return t.json();
|
|
95
105
|
}
|
|
96
106
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
f as addCartItem,
|
|
108
|
+
j as applyDiscount,
|
|
109
|
+
y as checkoutCart,
|
|
110
|
+
p as createCart,
|
|
111
|
+
m as fetchCart,
|
|
102
112
|
E as fetchCartRecommendations,
|
|
103
|
-
|
|
113
|
+
x as initiateCheckout,
|
|
114
|
+
$ as removeCartItem,
|
|
104
115
|
k as removeDiscount,
|
|
105
|
-
|
|
116
|
+
w as updateCart,
|
|
106
117
|
h as updateCartItem
|
|
107
118
|
};
|
package/dist/index29.mjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { createRpcClients as s } from "./index26.mjs";
|
|
3
|
-
|
|
4
|
-
async function
|
|
3
|
+
const i = "https://oms-api.instock.com.ng";
|
|
4
|
+
async function a(r, o) {
|
|
5
5
|
const t = await s(i).orders[":id"][":token"].$get({
|
|
6
|
-
param: { id: r, token:
|
|
6
|
+
param: { id: r, token: o }
|
|
7
7
|
});
|
|
8
8
|
if (!t.ok)
|
|
9
9
|
throw new Error(`Failed to fetch order: ${t.statusText}`);
|
|
10
10
|
return t.json();
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
12
|
+
async function d(r, o) {
|
|
13
13
|
const t = await s(i).orders.confirm.$post({
|
|
14
|
-
json: { orderId: r, token:
|
|
14
|
+
json: { orderId: r, token: o }
|
|
15
15
|
});
|
|
16
16
|
if (!t.ok)
|
|
17
17
|
throw new Error(`Failed to confirm order: ${t.statusText}`);
|
|
18
18
|
return t.json();
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
20
|
+
async function m(r, o, e = 4) {
|
|
21
21
|
const n = await s(i).orders[":id"][":token"].recommendations.$get({
|
|
22
|
-
param: { id: r, token:
|
|
22
|
+
param: { id: r, token: o },
|
|
23
23
|
// @ts-ignore - Hono RPC type inference issue with query parameters
|
|
24
|
-
query: { limit: String(
|
|
24
|
+
query: { limit: String(e) }
|
|
25
25
|
});
|
|
26
26
|
if (!n.ok)
|
|
27
27
|
throw new Error(`Failed to fetch order recommendations: ${n.statusText}`);
|
|
28
28
|
return n.json();
|
|
29
29
|
}
|
|
30
30
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
d as confirmOrder,
|
|
32
|
+
a as fetchOrder,
|
|
33
|
+
m as fetchOrderRecommendations
|
|
34
34
|
};
|
package/dist/index3.mjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
2
|
+
import { jsxs as dt, jsx as ft } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as lt, useState as x, useRef as P, useEffect as f, useCallback as a, useContext as Ct } from "react";
|
|
4
4
|
import "./index23.mjs";
|
|
5
|
-
import { queryKeys as
|
|
6
|
-
import { useGetCart as
|
|
7
|
-
import { useQueryClient as
|
|
8
|
-
import { ShoppingCart as
|
|
9
|
-
import { useMetaPixel as
|
|
10
|
-
import { useTikTokPixel as
|
|
11
|
-
import { getFbCookies as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const [t, m] =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, []),
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
m(
|
|
5
|
+
import { queryKeys as pt } from "./index32.mjs";
|
|
6
|
+
import { useGetCart as It, useCreateCart as kt, useAddCartItem as wt, useUpdateCartItem as ht, useRemoveCartItem as yt, useApplyDiscount as vt, useRemoveDiscount as Tt, useUpdateCart as gt, useCheckoutCart as At, useInitiateCheckout as Dt } from "./index35.mjs";
|
|
7
|
+
import { useQueryClient as Mt } from "@tanstack/react-query";
|
|
8
|
+
import { ShoppingCart as Et } from "./index13.mjs";
|
|
9
|
+
import { useMetaPixel as St } from "./index4.mjs";
|
|
10
|
+
import { useTikTokPixel as xt } from "./index5.mjs";
|
|
11
|
+
import { getFbCookies as j, getTikTokCookies as O, generateClientEventId as Pt } from "./index22.mjs";
|
|
12
|
+
const l = "oms_cart_id", Q = lt(null);
|
|
13
|
+
function Ot({ children: C, brandSlug: u, initialCartId: p, shoppingCartProps: $ }) {
|
|
14
|
+
const [t, m] = x(p || null), [I, y] = x(!1), [G, H] = x(!1), _ = P(!1), R = P(!1), v = P(!1), Y = Mt(), { trackAddToCart: T, trackInitiateCheckout: g } = St(), { trackAddToCart: A, trackInitiateCheckout: D } = xt();
|
|
15
|
+
f(() => {
|
|
16
|
+
H(!0);
|
|
17
|
+
}, []), f(() => {
|
|
18
|
+
if (p || _.current) return;
|
|
19
|
+
_.current = !0;
|
|
20
|
+
const o = new URLSearchParams(window.location.search).get("cartId");
|
|
21
|
+
if (o) {
|
|
22
|
+
m(o), y(!0);
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
const { data:
|
|
25
|
+
const c = localStorage.getItem(l);
|
|
26
|
+
c && m(c);
|
|
27
|
+
}, [p]);
|
|
28
|
+
const { data: n, isLoading: z, error: k, refetch: s } = It(t || "", {
|
|
29
29
|
enabled: !!t,
|
|
30
30
|
retry: !1
|
|
31
31
|
// Don't retry on failure - cart might be invalid/expired
|
|
32
|
-
}),
|
|
32
|
+
}), M = kt({
|
|
33
33
|
onSuccess: (e) => {
|
|
34
34
|
if ("error" in e) {
|
|
35
35
|
console.error("Failed to create cart:", e.error);
|
|
@@ -42,149 +42,167 @@ function Lt({ children: l, brandSlug: u, initialCartId: C, shoppingCartProps: q
|
|
|
42
42
|
},
|
|
43
43
|
retry: 10
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
f(() => {
|
|
46
46
|
if (R.current) return;
|
|
47
47
|
R.current = !0;
|
|
48
48
|
const e = setTimeout(() => {
|
|
49
|
-
!(typeof window < "u" ? localStorage.getItem(
|
|
49
|
+
!(typeof window < "u" ? localStorage.getItem(l) : null) && !p && M.mutate(u);
|
|
50
50
|
}, 150);
|
|
51
51
|
return () => clearTimeout(e);
|
|
52
|
-
}, []),
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
}, []), f(() => {
|
|
53
|
+
k && t && !v.current && (v.current = !0, console.warn("Cart fetch failed, creating new cart:", k), m(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
|
|
54
|
+
M.mutate(u), v.current = !1;
|
|
55
55
|
}, 100));
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
58
|
-
onSuccess: () =>
|
|
59
|
-
}),
|
|
60
|
-
onSuccess: () =>
|
|
61
|
-
}),
|
|
56
|
+
}, [k, t, u]);
|
|
57
|
+
const B = wt(t || "", {
|
|
58
|
+
onSuccess: () => s()
|
|
59
|
+
}), J = ht(t || "", {
|
|
60
|
+
onSuccess: () => s()
|
|
61
|
+
}), V = yt(t || "", {
|
|
62
62
|
onSuccess: () => {
|
|
63
|
-
|
|
63
|
+
s(), t && Y.invalidateQueries({ queryKey: pt.public.carts.recommendations(t) });
|
|
64
64
|
}
|
|
65
|
-
}),
|
|
66
|
-
onSuccess: () =>
|
|
67
|
-
}),
|
|
68
|
-
onSuccess: () =>
|
|
69
|
-
}),
|
|
70
|
-
onSuccess: () =>
|
|
65
|
+
}), W = vt(t || "", {
|
|
66
|
+
onSuccess: () => s()
|
|
67
|
+
}), X = Tt(t || "", {
|
|
68
|
+
onSuccess: () => s()
|
|
69
|
+
}), Z = gt(t || "", {
|
|
70
|
+
onSuccess: () => s(),
|
|
71
71
|
retry: 3
|
|
72
|
-
}),
|
|
72
|
+
}), tt = At(t || "", {
|
|
73
73
|
onSuccess: () => {
|
|
74
74
|
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
t && typeof window < "u" && localStorage.setItem(
|
|
75
|
+
}), b = Dt(t || "");
|
|
76
|
+
f(() => {
|
|
77
|
+
t && typeof window < "u" && localStorage.setItem(l, t);
|
|
78
78
|
}, [t]);
|
|
79
|
-
const
|
|
80
|
-
async (e,
|
|
81
|
-
var
|
|
79
|
+
const et = a(
|
|
80
|
+
async (e, o, c, i, r) => {
|
|
81
|
+
var K;
|
|
82
82
|
if (!t) throw new Error("No cart ID");
|
|
83
|
-
const { fbc:
|
|
84
|
-
sku:
|
|
85
|
-
quantity:
|
|
86
|
-
fbc:
|
|
87
|
-
fbp:
|
|
88
|
-
ttp:
|
|
89
|
-
ttclid:
|
|
83
|
+
const { fbc: d, fbp: E } = j(), { ttp: S, ttclid: mt } = O(), N = await B.mutateAsync({
|
|
84
|
+
sku: i,
|
|
85
|
+
quantity: r,
|
|
86
|
+
fbc: d,
|
|
87
|
+
fbp: E,
|
|
88
|
+
ttp: S,
|
|
89
|
+
ttclid: mt,
|
|
90
90
|
refreshRecommendations: !I
|
|
91
91
|
});
|
|
92
|
-
if ("error" in
|
|
93
|
-
const
|
|
94
|
-
(
|
|
95
|
-
var
|
|
96
|
-
return ((
|
|
92
|
+
if ("error" in N) return;
|
|
93
|
+
const w = (K = N.items) == null ? void 0 : K.filter(
|
|
94
|
+
(h) => {
|
|
95
|
+
var L;
|
|
96
|
+
return ((L = h.variant) == null ? void 0 : L.sku) === i;
|
|
97
97
|
}
|
|
98
|
-
),
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
|
|
98
|
+
), U = w == null ? void 0 : w[w.length - 1];
|
|
99
|
+
if (U) {
|
|
100
|
+
const h = `cart_${t}_item_${U.id}`;
|
|
101
|
+
T(i, o, c, r, h), A(e, o, c, r, h);
|
|
102
102
|
} else
|
|
103
|
-
|
|
103
|
+
T(i, o, c, r), A(e, o, c, r);
|
|
104
104
|
},
|
|
105
105
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
|
-
[t, I,
|
|
107
|
-
),
|
|
108
|
-
async (e,
|
|
106
|
+
[t, I, T, A]
|
|
107
|
+
), rt = a(
|
|
108
|
+
async (e, o) => {
|
|
109
109
|
if (!t) throw new Error("No cart ID");
|
|
110
|
-
await
|
|
110
|
+
await J.mutateAsync({ itemId: e, quantity: o });
|
|
111
111
|
},
|
|
112
112
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
113
|
[t]
|
|
114
|
-
),
|
|
114
|
+
), ot = a(
|
|
115
115
|
async (e) => {
|
|
116
116
|
if (!t) throw new Error("No cart ID");
|
|
117
|
-
await
|
|
117
|
+
await V.mutateAsync(e);
|
|
118
118
|
},
|
|
119
119
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
120
|
[t]
|
|
121
|
-
),
|
|
121
|
+
), nt = a(
|
|
122
122
|
async (e) => {
|
|
123
123
|
if (!t) throw new Error("No cart ID");
|
|
124
|
-
await
|
|
124
|
+
await W.mutateAsync({ code: e });
|
|
125
125
|
},
|
|
126
126
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
127
127
|
[t]
|
|
128
|
-
),
|
|
128
|
+
), ct = a(async () => {
|
|
129
129
|
if (!t) throw new Error("No cart ID");
|
|
130
|
-
await
|
|
131
|
-
}, [t]), F =
|
|
132
|
-
m(null), typeof window < "u" && localStorage.removeItem(
|
|
133
|
-
}, []),
|
|
134
|
-
F(),
|
|
135
|
-
}, [u]),
|
|
136
|
-
|
|
137
|
-
}, []),
|
|
138
|
-
|
|
139
|
-
}, []),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
130
|
+
await X.mutateAsync();
|
|
131
|
+
}, [t]), F = a(() => {
|
|
132
|
+
m(null), typeof window < "u" && localStorage.removeItem(l);
|
|
133
|
+
}, []), at = a(() => {
|
|
134
|
+
F(), M.mutate(u);
|
|
135
|
+
}, [u]), st = a(() => {
|
|
136
|
+
y(!0);
|
|
137
|
+
}, []), q = a(() => {
|
|
138
|
+
y(!1);
|
|
139
|
+
}, []), it = a(async () => {
|
|
140
|
+
if (!(!n || !n.pricing))
|
|
141
|
+
try {
|
|
142
|
+
const e = Pt("cart", n.id, "checkout"), o = n.pricing.total, c = n.items.reduce((r, d) => r + d.quantity, 0), i = n.items.map((r) => ({
|
|
143
|
+
id: r.variant.sku,
|
|
144
|
+
quantity: r.quantity,
|
|
145
|
+
item_price: Number(r.variant.price)
|
|
146
|
+
}));
|
|
147
|
+
if (g && g(o, c, i, e), n.brand.metaPixelId || n.brand.tiktokPixelId) {
|
|
148
|
+
const { fbc: r, fbp: d } = j(), { ttp: E, ttclid: S } = O();
|
|
149
|
+
b.mutate({
|
|
150
|
+
email: n.customerEmail,
|
|
151
|
+
phone: n.customerPhone,
|
|
152
|
+
fbc: r,
|
|
153
|
+
fbp: d,
|
|
154
|
+
ttp: E,
|
|
155
|
+
ttclid: S
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
D && D(o, c, e, i.map((r) => ({
|
|
159
|
+
content_id: r.id,
|
|
160
|
+
quantity: r.quantity,
|
|
161
|
+
price: r.item_price
|
|
162
|
+
})));
|
|
163
|
+
} catch (e) {
|
|
164
|
+
console.error("Error tracking initiate checkout:", e);
|
|
165
|
+
}
|
|
166
|
+
}, [n, g, D, b]), ut = {
|
|
167
|
+
cart: n || null,
|
|
150
168
|
cartId: t,
|
|
151
|
-
isLoading:
|
|
152
|
-
error:
|
|
153
|
-
updateCartMutation:
|
|
154
|
-
checkoutMutation:
|
|
155
|
-
addItem:
|
|
156
|
-
updateItem:
|
|
157
|
-
removeItem:
|
|
158
|
-
applyDiscount:
|
|
159
|
-
removeDiscount:
|
|
160
|
-
trackCheckoutInitiated:
|
|
169
|
+
isLoading: z,
|
|
170
|
+
error: k,
|
|
171
|
+
updateCartMutation: Z,
|
|
172
|
+
checkoutMutation: tt,
|
|
173
|
+
addItem: et,
|
|
174
|
+
updateItem: rt,
|
|
175
|
+
removeItem: ot,
|
|
176
|
+
applyDiscount: nt,
|
|
177
|
+
removeDiscount: ct,
|
|
178
|
+
trackCheckoutInitiated: it,
|
|
161
179
|
clearCart: F,
|
|
162
|
-
clearAndCreateNewCart:
|
|
163
|
-
refetch:
|
|
180
|
+
clearAndCreateNewCart: at,
|
|
181
|
+
refetch: s,
|
|
164
182
|
isOpen: I,
|
|
165
|
-
open:
|
|
166
|
-
close:
|
|
183
|
+
open: st,
|
|
184
|
+
close: q
|
|
167
185
|
};
|
|
168
|
-
return /* @__PURE__ */
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
186
|
+
return /* @__PURE__ */ dt(Q.Provider, { value: ut, children: [
|
|
187
|
+
C,
|
|
188
|
+
G && /* @__PURE__ */ ft(
|
|
189
|
+
Et,
|
|
172
190
|
{
|
|
173
191
|
isOpen: I,
|
|
174
|
-
onClose:
|
|
175
|
-
|
|
192
|
+
onClose: q,
|
|
193
|
+
...$
|
|
176
194
|
}
|
|
177
195
|
)
|
|
178
196
|
] });
|
|
179
197
|
}
|
|
180
|
-
function
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
198
|
+
function Qt() {
|
|
199
|
+
const C = Ct(Q);
|
|
200
|
+
if (!C)
|
|
183
201
|
throw new Error("useCart must be used within CartProvider");
|
|
184
|
-
return
|
|
202
|
+
return C;
|
|
185
203
|
}
|
|
186
204
|
export {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
205
|
+
Q as CartContext,
|
|
206
|
+
Ot as CartProvider,
|
|
207
|
+
Qt as useCart
|
|
190
208
|
};
|
package/dist/index30.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { createRpcClients as o } from "./index26.mjs";
|
|
3
|
-
|
|
4
|
-
async function
|
|
5
|
-
const e = await o(
|
|
3
|
+
const n = "https://oms-api.instock.com.ng";
|
|
4
|
+
async function r(t) {
|
|
5
|
+
const e = await o(n).deliveryZones.index.$get({
|
|
6
6
|
query: t ? { brandId: t } : {}
|
|
7
7
|
});
|
|
8
8
|
if (!e.ok)
|
|
@@ -10,5 +10,5 @@ async function c(t) {
|
|
|
10
10
|
return e.json();
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
r as fetchDeliveryZones
|
|
14
14
|
};
|
package/dist/index31.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { createRpcClients as
|
|
3
|
-
|
|
4
|
-
async function c(
|
|
5
|
-
const t = await
|
|
6
|
-
param: { slug:
|
|
2
|
+
import { createRpcClients as s } from "./index26.mjs";
|
|
3
|
+
const o = "https://oms-api.instock.com.ng";
|
|
4
|
+
async function c(n) {
|
|
5
|
+
const t = await s(o).brands[":slug"].$get({
|
|
6
|
+
param: { slug: n }
|
|
7
7
|
});
|
|
8
8
|
if (!t.ok)
|
|
9
9
|
throw new Error(`Failed to fetch brand: ${t.statusText}`);
|