@instockng/storefront-ui 1.0.32 → 1.0.34
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +99 -96
- package/dist/index10.mjs +85 -162
- package/dist/index100.mjs +210 -17
- package/dist/index101.mjs +174 -17
- package/dist/index102.mjs +14 -25
- package/dist/index103.mjs +17 -150
- package/dist/index104.mjs +26 -13
- package/dist/index105.mjs +149 -24
- package/dist/index106.mjs +13 -77
- package/dist/index107.mjs +20 -27
- package/dist/index108.mjs +76 -137
- package/dist/index109.mjs +33 -50
- package/dist/index11.mjs +171 -94
- package/dist/index110.mjs +141 -19
- package/dist/index111.mjs +50 -22
- package/dist/index112.mjs +14 -14
- package/dist/index113.mjs +20 -18
- package/dist/index114.mjs +16 -14
- package/dist/index115.mjs +17 -14
- package/dist/index116.mjs +12 -12
- package/dist/index117.mjs +15 -58
- package/dist/index118.mjs +14 -11
- package/dist/index119.mjs +56 -30
- package/dist/index12.mjs +82 -659
- package/dist/index120.mjs +8 -14
- package/dist/index121.mjs +31 -26
- package/dist/index122.mjs +12 -15
- package/dist/index123.mjs +26 -11
- package/dist/index124.mjs +18 -12
- package/dist/index125.mjs +12 -40
- package/dist/index126.mjs +14 -16
- package/dist/index127.mjs +42 -263
- package/dist/index128.mjs +15 -62
- package/dist/index129.mjs +267 -7
- package/dist/index13.mjs +668 -53
- package/dist/index130.mjs +70 -2
- package/dist/index131.mjs +8 -2
- package/dist/index132.mjs +2 -33
- package/dist/index133.mjs +2 -2
- package/dist/index134.mjs +32 -20
- package/dist/index135.mjs +2 -56
- package/dist/index136.mjs +18 -26
- package/dist/index137.mjs +55 -6
- package/dist/index138.mjs +28 -51
- package/dist/index139.mjs +7 -6
- package/dist/index14.mjs +58 -60
- package/dist/index140.mjs +51 -11
- package/dist/index141.mjs +5 -6
- package/dist/index142.mjs +12 -28
- package/dist/index143.mjs +7 -2
- package/dist/index144.mjs +27 -69
- package/dist/index145.mjs +2 -167
- package/dist/index146.mjs +70 -2
- package/dist/index147.mjs +167 -2
- package/dist/index148.mjs +2 -2
- package/dist/index149.mjs +2 -18
- package/dist/index15.mjs +60 -22
- package/dist/index150.mjs +2 -32
- package/dist/index151.mjs +2 -38
- package/dist/index152.mjs +11 -11
- package/dist/index153.mjs +25 -11
- package/dist/index154.mjs +38 -2
- package/dist/index155.mjs +11 -13
- package/dist/index156.mjs +11 -39
- package/dist/index157.mjs +2 -2
- package/dist/index158.mjs +15 -25
- package/dist/index159.mjs +39 -11
- package/dist/index16.mjs +22 -113
- package/dist/index161.mjs +30 -2
- package/dist/index162.mjs +18 -2
- package/dist/index164.mjs +2 -72
- package/dist/index165.mjs +2 -2
- package/dist/index166.mjs +2 -53
- package/dist/index167.mjs +72 -2
- package/dist/index168.mjs +2 -36
- package/dist/index169.mjs +38 -137
- package/dist/index17.mjs +111 -38
- package/dist/index170.mjs +2 -2
- package/dist/index171.mjs +36 -2
- package/dist/index172.mjs +147 -14
- package/dist/index174.mjs +2 -2
- package/dist/index175.mjs +10 -17
- package/dist/index176.mjs +2 -2
- package/dist/index177.mjs +2 -2
- package/dist/index178.mjs +18 -16
- package/dist/index179.mjs +2 -23
- package/dist/index18.mjs +37 -37
- package/dist/index180.mjs +2 -2
- package/dist/index181.mjs +24 -2
- package/dist/index182.mjs +23 -2
- package/dist/index183.mjs +2 -23
- package/dist/index184.mjs +2 -2
- package/dist/index185.mjs +2 -23
- package/dist/index186.mjs +23 -2
- package/dist/index187.mjs +2 -2
- package/dist/index188.mjs +23 -2
- package/dist/index189.mjs +2 -23
- package/dist/index19.mjs +42 -55
- package/dist/index190.mjs +2 -2
- package/dist/index191.mjs +2 -23
- package/dist/index192.mjs +23 -2
- package/dist/index193.mjs +2 -2
- package/dist/index194.mjs +23 -2
- package/dist/index195.mjs +2 -2
- package/dist/index196.mjs +2 -2
- package/dist/index198.mjs +2 -2
- package/dist/index199.mjs +2 -2
- package/dist/index2.mjs +14 -13
- package/dist/index20.mjs +53 -30
- package/dist/index200.mjs +2 -127
- package/dist/index201.mjs +2 -2
- package/dist/index202.mjs +2 -74
- package/dist/index203.mjs +123 -70
- package/dist/index204.mjs +2 -2
- package/dist/index205.mjs +73 -30
- package/dist/index206.mjs +73 -10
- package/dist/index207.mjs +30 -3
- package/dist/index208.mjs +10 -3
- package/dist/index209.mjs +4 -13
- package/dist/index21.mjs +29 -6
- package/dist/index210.mjs +4 -7
- package/dist/index211.mjs +13 -12
- package/dist/index212.mjs +7 -5
- package/dist/index213.mjs +12 -33
- package/dist/index214.mjs +5 -31
- package/dist/index215.mjs +32 -27
- package/dist/index216.mjs +28 -58
- package/dist/index217.mjs +28 -2
- package/dist/index218.mjs +55 -102
- package/dist/index219.mjs +2 -2
- package/dist/index22.mjs +8 -21
- package/dist/index220.mjs +2 -2
- package/dist/index222.mjs +2 -2
- package/dist/index223.mjs +108 -2
- package/dist/index224.mjs +2 -2
- package/dist/index225.mjs +2 -2
- package/dist/index226.mjs +2 -2
- package/dist/index228.mjs +2 -37
- package/dist/index229.mjs +2 -2
- package/dist/index23.mjs +19 -30
- package/dist/index230.mjs +37 -2
- package/dist/index231.mjs +2 -2
- package/dist/index232.mjs +2 -244
- package/dist/index233.mjs +244 -2
- package/dist/index234.mjs +2 -33
- package/dist/index235.mjs +28 -60
- package/dist/index236.mjs +60 -20
- package/dist/index237.mjs +25 -2
- package/dist/index238.mjs +2 -2
- package/dist/index239.mjs +2 -2
- package/dist/index24.mjs +31 -18
- package/dist/index240.mjs +2 -2
- package/dist/index241.mjs +2 -2
- package/dist/index244.mjs +2 -2
- package/dist/index245.mjs +2 -4
- package/dist/index246.mjs +2 -2
- package/dist/index247.mjs +4 -2
- package/dist/index248.mjs +2 -2
- package/dist/index249.mjs +2 -2
- package/dist/index25.mjs +12 -85
- package/dist/index250.mjs +3 -18
- package/dist/index251.mjs +2 -47
- package/dist/index252.mjs +2 -2
- package/dist/index253.mjs +17 -2
- package/dist/index254.mjs +13 -2
- package/dist/index255.mjs +6 -2
- package/dist/index256.mjs +30 -91
- package/dist/index257.mjs +2 -3
- package/dist/index258.mjs +2 -2
- package/dist/index259.mjs +18 -2
- package/dist/index26.mjs +85 -12
- package/dist/index260.mjs +46 -16
- package/dist/index261.mjs +2 -13
- package/dist/index262.mjs +2 -6
- package/dist/index263.mjs +2 -30
- package/dist/index264.mjs +2 -2
- package/dist/index265.mjs +91 -2
- package/dist/index266.mjs +2 -2
- package/dist/index267.mjs +2 -2
- package/dist/index268.mjs +5 -0
- package/dist/index269.mjs +5 -0
- package/dist/index27.mjs +18 -9
- package/dist/index28.mjs +9 -9
- package/dist/index29.mjs +11 -101
- package/dist/index3.mjs +108 -103
- package/dist/index30.mjs +101 -20
- package/dist/index31.mjs +20 -65
- package/dist/index32.mjs +66 -96
- package/dist/index33.mjs +93 -16
- package/dist/index34.mjs +12 -12
- package/dist/index35.mjs +17 -9
- package/dist/index36.mjs +9 -9
- package/dist/index37.mjs +10 -122
- package/dist/index38.mjs +116 -18
- package/dist/index39.mjs +342 -1386
- package/dist/index4.mjs +1 -1
- package/dist/index40.mjs +25 -2
- package/dist/index41.mjs +1425 -52
- package/dist/index42.mjs +2 -51
- package/dist/index43.mjs +60 -33
- package/dist/index44.mjs +49 -13
- package/dist/index45.mjs +32 -2262
- package/dist/index46.mjs +15 -36
- package/dist/index47.mjs +2261 -42
- package/dist/index48.mjs +36 -99
- package/dist/index49.mjs +43 -96
- package/dist/index5.mjs +111 -15
- package/dist/index50.mjs +99 -81
- package/dist/index51.mjs +93 -57
- package/dist/index52.mjs +54 -68
- package/dist/index53.mjs +58 -62
- package/dist/index54.mjs +74 -58
- package/dist/index55.mjs +77 -15
- package/dist/index56.mjs +75 -14
- package/dist/index57.mjs +15 -59
- package/dist/index58.mjs +11 -118
- package/dist/index59.mjs +46 -112
- package/dist/index6.mjs +15 -195
- package/dist/index60.mjs +124 -23
- package/dist/index61.mjs +128 -152
- package/dist/index63.mjs +21 -20
- package/dist/index65.mjs +21 -73
- package/dist/index66.mjs +153 -15
- package/dist/index67.mjs +68 -56
- package/dist/index68.mjs +15 -2
- package/dist/index69.mjs +62 -5
- package/dist/index7.mjs +188 -101
- package/dist/index70.mjs +230 -1129
- package/dist/index71.mjs +5 -19
- package/dist/index72.mjs +127 -48
- package/dist/index73.mjs +67 -32
- package/dist/index74.mjs +87 -2
- package/dist/index75.mjs +23 -229
- package/dist/index76.mjs +8 -5
- package/dist/index77.mjs +66 -125
- package/dist/index78.mjs +3 -67
- package/dist/index79.mjs +2 -87
- package/dist/index8.mjs +103 -73
- package/dist/index80.mjs +78 -24
- package/dist/index81.mjs +52 -7
- package/dist/index82.mjs +5 -74
- package/dist/index83.mjs +4 -3
- package/dist/index84.mjs +179 -2
- package/dist/index85.mjs +49 -79
- package/dist/index86.mjs +68 -53
- package/dist/index87.mjs +34 -6
- package/dist/index88.mjs +42 -4
- package/dist/index89.mjs +2 -179
- package/dist/index9.mjs +72 -90
- package/dist/index90.mjs +6 -53
- package/dist/index91.mjs +1134 -69
- package/dist/index92.mjs +20 -34
- package/dist/index93.mjs +54 -42
- package/dist/index94.mjs +33 -2
- package/dist/index95.mjs +2 -2
- package/dist/index96.mjs +2 -28
- package/dist/index97.mjs +2 -18
- package/dist/index98.mjs +26 -213
- package/dist/index99.mjs +13 -175
- package/dist/providers/StorefrontProvider.d.ts.map +1 -1
- package/dist/providers/TikTokPixelProvider.d.ts +26 -0
- package/dist/providers/TikTokPixelProvider.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/contexts/CartContext.tsx +24 -6
- package/src/index.ts +5 -0
- package/src/providers/StorefrontProvider.tsx +11 -8
- package/src/providers/TikTokPixelProvider.tsx +233 -0
package/dist/index29.mjs
CHANGED
|
@@ -1,104 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
detail: (a, i) => ["public", "orders", a, i]
|
|
13
|
-
},
|
|
14
|
-
products: {
|
|
15
|
-
all: ["public", "products"],
|
|
16
|
-
list: (a) => ["public", "products", a],
|
|
17
|
-
detail: (a) => ["public", "products", a]
|
|
18
|
-
},
|
|
19
|
-
deliveryZones: {
|
|
20
|
-
all: ["public", "delivery-zones"],
|
|
21
|
-
list: (a) => ["public", "delivery-zones", a]
|
|
22
|
-
},
|
|
23
|
-
brands: {
|
|
24
|
-
all: ["public", "brands"],
|
|
25
|
-
detail: (a) => ["public", "brands", a]
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
// Admin API keys (RPC is now the default)
|
|
29
|
-
admin: {
|
|
30
|
-
all: ["admin"],
|
|
31
|
-
orders: {
|
|
32
|
-
all: ["admin", "orders"],
|
|
33
|
-
list: (a) => ["admin", "orders", "list", JSON.stringify(a)],
|
|
34
|
-
detail: (a) => ["admin", "orders", a]
|
|
35
|
-
},
|
|
36
|
-
brands: {
|
|
37
|
-
all: ["admin", "brands"],
|
|
38
|
-
list: () => ["admin", "brands", "list"],
|
|
39
|
-
detail: (a) => ["admin", "brands", a]
|
|
40
|
-
},
|
|
41
|
-
products: {
|
|
42
|
-
all: ["admin", "products"],
|
|
43
|
-
list: (a) => ["admin", "products", "list", a],
|
|
44
|
-
detail: (a) => ["admin", "products", a]
|
|
45
|
-
},
|
|
46
|
-
variants: {
|
|
47
|
-
all: ["admin", "variants"],
|
|
48
|
-
list: () => ["admin", "variants", "list"],
|
|
49
|
-
detail: (a) => ["admin", "variants", a],
|
|
50
|
-
search: (a) => ["admin", "variants", "search", a],
|
|
51
|
-
byProduct: (a) => ["admin", "variants", "product", a],
|
|
52
|
-
inventory: (a) => ["admin", "variants", a, "inventory"]
|
|
53
|
-
},
|
|
54
|
-
warehouses: {
|
|
55
|
-
all: ["admin", "warehouses"],
|
|
56
|
-
list: () => ["admin", "warehouses", "list"],
|
|
57
|
-
detail: (a) => ["admin", "warehouses", a],
|
|
58
|
-
inventory: (a) => ["admin", "warehouses", a, "inventory"]
|
|
59
|
-
},
|
|
60
|
-
inventory: {
|
|
61
|
-
all: ["admin", "inventory"],
|
|
62
|
-
list: (a) => ["admin", "inventory", "list", a],
|
|
63
|
-
transactions: (a) => ["admin", "inventory", "transactions", a],
|
|
64
|
-
lowStock: (a) => ["admin", "inventory", "low-stock", a]
|
|
65
|
-
},
|
|
66
|
-
customers: {
|
|
67
|
-
all: ["admin", "customers"],
|
|
68
|
-
history: (a) => ["admin", "customers", "history", a]
|
|
69
|
-
},
|
|
70
|
-
stats: {
|
|
71
|
-
all: ["admin", "stats"],
|
|
72
|
-
overview: (a) => ["admin", "stats", "overview", a]
|
|
73
|
-
},
|
|
74
|
-
abandonedCarts: {
|
|
75
|
-
all: ["admin", "abandoned-carts"],
|
|
76
|
-
list: (a) => ["admin", "abandoned-carts", "list", a],
|
|
77
|
-
detail: (a) => ["admin", "abandoned-carts", a],
|
|
78
|
-
stats: (a) => ["admin", "abandoned-carts", "stats", a]
|
|
79
|
-
},
|
|
80
|
-
discountCodes: {
|
|
81
|
-
all: ["admin", "discount-codes"],
|
|
82
|
-
list: (a) => ["admin", "discount-codes", "list", a],
|
|
83
|
-
detail: (a) => ["admin", "discount-codes", a],
|
|
84
|
-
analytics: (a) => ["admin", "discount-codes", a, "analytics"],
|
|
85
|
-
overviewStats: () => ["admin", "discount-codes", "stats", "overview"]
|
|
86
|
-
},
|
|
87
|
-
deliveryZones: {
|
|
88
|
-
all: ["admin", "delivery-zones"],
|
|
89
|
-
states: {
|
|
90
|
-
all: ["admin", "delivery-zones", "states"],
|
|
91
|
-
list: () => ["admin", "delivery-zones", "states", "list"],
|
|
92
|
-
detail: (a) => ["admin", "delivery-zones", "states", a]
|
|
93
|
-
},
|
|
94
|
-
zones: {
|
|
95
|
-
all: ["admin", "delivery-zones", "zones"],
|
|
96
|
-
list: (a) => ["admin", "delivery-zones", "zones", "list", a],
|
|
97
|
-
detail: (a) => ["admin", "delivery-zones", "zones", a]
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
2
|
+
import { createRpcClients as s } from "./index24.mjs";
|
|
3
|
+
const r = "https://oms-api.instock.ng";
|
|
4
|
+
async function a(n) {
|
|
5
|
+
const t = await s(r).brands[":slug"].$get({
|
|
6
|
+
param: { slug: n }
|
|
7
|
+
});
|
|
8
|
+
if (!t.ok)
|
|
9
|
+
throw new Error(`Failed to fetch brand: ${t.statusText}`);
|
|
10
|
+
return t.json();
|
|
11
|
+
}
|
|
102
12
|
export {
|
|
103
|
-
|
|
13
|
+
a as fetchBrandBySlug
|
|
104
14
|
};
|
package/dist/index3.mjs
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import "./
|
|
5
|
-
import { useGetCart as
|
|
2
|
+
import { jsxs as at, jsx as ct } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as st, useState as M, useRef as E, useEffect as f, useCallback as n, useContext as it } from "react";
|
|
4
|
+
import "./index21.mjs";
|
|
5
|
+
import { useGetCart as ut, useCreateCart as mt, useAddCartItem as dt, useUpdateCartItem as ft, useRemoveCartItem as lt, useApplyDiscount as Ct, useRemoveDiscount as It, useUpdateCart as wt, useCheckoutCart as pt } from "./index33.mjs";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
|
-
import { ShoppingCart as
|
|
8
|
-
import { useMetaPixel as
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { ShoppingCart as kt } from "./index11.mjs";
|
|
8
|
+
import { useMetaPixel as ht } from "./index4.mjs";
|
|
9
|
+
import { useTikTokPixel as yt } from "./index5.mjs";
|
|
10
|
+
import { getFbCookies as vt } from "./index20.mjs";
|
|
11
|
+
const l = "oms_cart_id", $ = st(null);
|
|
12
|
+
function Pt({ children: C, brandSlug: m, initialCartId: I, shoppingCartProps: j }) {
|
|
13
|
+
const [t, d] = M(I || null), [S, _] = M(!1), [O, G] = M(!1), x = E(!1), g = E(!1), v = E(!1), { trackAddToCart: T, trackInitiateCheckout: P } = ht(), { trackAddToCart: A, trackInitiateCheckout: R } = yt();
|
|
13
14
|
f(() => {
|
|
14
|
-
|
|
15
|
+
G(!0);
|
|
15
16
|
}, []), f(() => {
|
|
16
|
-
if (
|
|
17
|
-
|
|
17
|
+
if (I || x.current) return;
|
|
18
|
+
x.current = !0;
|
|
18
19
|
const r = new URLSearchParams(window.location.search).get("cartId");
|
|
19
20
|
if (r) {
|
|
20
|
-
|
|
21
|
+
d(r);
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
const { data: i, isLoading:
|
|
24
|
+
const o = localStorage.getItem(l);
|
|
25
|
+
o && d(o);
|
|
26
|
+
}, [I]);
|
|
27
|
+
const { data: i, isLoading: H, error: w, refetch: s } = ut(t || "", {
|
|
27
28
|
enabled: !!t,
|
|
28
29
|
retry: !1
|
|
29
30
|
// Don't retry on failure - cart might be invalid/expired
|
|
30
|
-
}),
|
|
31
|
+
}), D = mt({
|
|
31
32
|
onSuccess: (e) => {
|
|
32
33
|
if ("error" in e) {
|
|
33
34
|
console.error("Failed to create cart:", e.error);
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
d(e.id);
|
|
37
38
|
},
|
|
38
39
|
onError: (e) => {
|
|
39
40
|
console.error("Failed to create cart:", e);
|
|
@@ -41,134 +42,138 @@ function Et({ children: l, brandSlug: a, initialCartId: C, shoppingCartProps: L
|
|
|
41
42
|
retry: 10
|
|
42
43
|
});
|
|
43
44
|
f(() => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
45
|
+
if (g.current) return;
|
|
46
|
+
g.current = !0;
|
|
46
47
|
const e = setTimeout(() => {
|
|
47
|
-
!(typeof window < "u" ? localStorage.getItem(
|
|
48
|
+
!(typeof window < "u" ? localStorage.getItem(l) : null) && !I && D.mutate(m);
|
|
48
49
|
}, 150);
|
|
49
50
|
return () => clearTimeout(e);
|
|
50
51
|
}, []), f(() => {
|
|
51
|
-
w && t && !
|
|
52
|
-
|
|
52
|
+
w && t && !v.current && (v.current = !0, console.warn("Cart fetch failed, creating new cart:", w), d(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
|
|
53
|
+
D.mutate(m), v.current = !1;
|
|
53
54
|
}, 100));
|
|
54
|
-
}, [w, t,
|
|
55
|
-
const
|
|
56
|
-
onSuccess: () =>
|
|
57
|
-
}),
|
|
58
|
-
onSuccess: () =>
|
|
59
|
-
}), K = ft(t || "", {
|
|
60
|
-
onSuccess: () => n()
|
|
61
|
-
}), Y = dt(t || "", {
|
|
62
|
-
onSuccess: () => n()
|
|
55
|
+
}, [w, t, m]);
|
|
56
|
+
const K = dt(t || "", {
|
|
57
|
+
onSuccess: () => s()
|
|
58
|
+
}), Y = ft(t || "", {
|
|
59
|
+
onSuccess: () => s()
|
|
63
60
|
}), z = lt(t || "", {
|
|
64
|
-
onSuccess: () =>
|
|
61
|
+
onSuccess: () => s()
|
|
65
62
|
}), B = Ct(t || "", {
|
|
66
|
-
onSuccess: () =>
|
|
63
|
+
onSuccess: () => s()
|
|
64
|
+
}), J = It(t || "", {
|
|
65
|
+
onSuccess: () => s()
|
|
66
|
+
}), Q = wt(t || "", {
|
|
67
|
+
onSuccess: () => s(),
|
|
67
68
|
retry: 3
|
|
68
|
-
}),
|
|
69
|
+
}), V = pt(t || "", {
|
|
69
70
|
onSuccess: () => {
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
73
|
f(() => {
|
|
73
|
-
t && typeof window < "u" && localStorage.setItem(
|
|
74
|
+
t && typeof window < "u" && localStorage.setItem(l, t);
|
|
74
75
|
}, [t]);
|
|
75
|
-
const
|
|
76
|
-
async (e, r,
|
|
77
|
-
var
|
|
76
|
+
const W = n(
|
|
77
|
+
async (e, r, o, p, a) => {
|
|
78
|
+
var U;
|
|
78
79
|
if (!t) throw new Error("No cart ID");
|
|
79
|
-
const { fbc:
|
|
80
|
-
if ("error" in
|
|
81
|
-
const
|
|
82
|
-
(
|
|
83
|
-
var
|
|
84
|
-
return ((
|
|
80
|
+
const { fbc: k, fbp: h } = vt(), c = await K.mutateAsync({ sku: p, quantity: a, fbc: k, fbp: h });
|
|
81
|
+
if ("error" in c) return;
|
|
82
|
+
const u = (U = c.items) == null ? void 0 : U.filter(
|
|
83
|
+
(y) => {
|
|
84
|
+
var L;
|
|
85
|
+
return ((L = y.variant) == null ? void 0 : L.sku) === p;
|
|
85
86
|
}
|
|
86
|
-
),
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
|
|
87
|
+
), b = u == null ? void 0 : u[u.length - 1];
|
|
88
|
+
if (b) {
|
|
89
|
+
const y = `cart_${t}_item_${b.id}`;
|
|
90
|
+
T(e, r, o, a, y), A(e, r, o, a, y);
|
|
90
91
|
} else
|
|
91
|
-
|
|
92
|
+
T(e, r, o, a), A(e, r, o, a);
|
|
92
93
|
},
|
|
93
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
-
[t,
|
|
95
|
-
),
|
|
95
|
+
[t, T, A]
|
|
96
|
+
), X = n(
|
|
96
97
|
async (e, r) => {
|
|
97
98
|
if (!t) throw new Error("No cart ID");
|
|
98
|
-
await
|
|
99
|
+
await Y.mutateAsync({ itemId: e, quantity: r });
|
|
99
100
|
},
|
|
100
101
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
102
|
[t]
|
|
102
|
-
),
|
|
103
|
+
), Z = n(
|
|
103
104
|
async (e) => {
|
|
104
105
|
if (!t) throw new Error("No cart ID");
|
|
105
|
-
await
|
|
106
|
+
await z.mutateAsync(e);
|
|
106
107
|
},
|
|
107
108
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
109
|
[t]
|
|
109
|
-
),
|
|
110
|
+
), q = n(
|
|
110
111
|
async (e) => {
|
|
111
112
|
if (!t) throw new Error("No cart ID");
|
|
112
|
-
await
|
|
113
|
+
await B.mutateAsync({ code: e });
|
|
113
114
|
},
|
|
114
115
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
115
116
|
[t]
|
|
116
|
-
),
|
|
117
|
+
), tt = n(async () => {
|
|
117
118
|
if (!t) throw new Error("No cart ID");
|
|
118
|
-
await
|
|
119
|
-
}, [t]),
|
|
120
|
-
|
|
121
|
-
}, []),
|
|
122
|
-
|
|
123
|
-
}, [
|
|
124
|
-
|
|
125
|
-
}, []),
|
|
126
|
-
|
|
127
|
-
}, []),
|
|
128
|
-
var
|
|
119
|
+
await J.mutateAsync();
|
|
120
|
+
}, [t]), F = n(() => {
|
|
121
|
+
d(null), typeof window < "u" && localStorage.removeItem(l);
|
|
122
|
+
}, []), et = n(() => {
|
|
123
|
+
F(), D.mutate(m);
|
|
124
|
+
}, [m]), rt = n(() => {
|
|
125
|
+
_(!0);
|
|
126
|
+
}, []), N = n(() => {
|
|
127
|
+
_(!1);
|
|
128
|
+
}, []), ot = n(() => {
|
|
129
|
+
var a, k, h;
|
|
129
130
|
if (!i || !t) return;
|
|
130
|
-
const e = Number(((
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const e = Number(((a = i.pricing) == null ? void 0 : a.total) || 0), r = ((k = i.items) == null ? void 0 : k.reduce((c, u) => c + u.quantity, 0)) || 0, o = `cart_${t}_checkout`, p = ((h = i.items) == null ? void 0 : h.map((c) => ({
|
|
132
|
+
content_id: c.variant.sku,
|
|
133
|
+
quantity: c.quantity,
|
|
134
|
+
price: Number(c.variant.price)
|
|
135
|
+
}))) || [];
|
|
136
|
+
P(e, r, o), R(e, r, o, p);
|
|
137
|
+
}, [i, t, P, R]), nt = {
|
|
133
138
|
cart: i || null,
|
|
134
139
|
cartId: t,
|
|
135
|
-
isLoading:
|
|
140
|
+
isLoading: H,
|
|
136
141
|
error: w,
|
|
137
|
-
updateCartMutation:
|
|
138
|
-
checkoutMutation:
|
|
139
|
-
addItem:
|
|
140
|
-
updateItem:
|
|
141
|
-
removeItem:
|
|
142
|
-
applyDiscount:
|
|
143
|
-
removeDiscount:
|
|
144
|
-
trackCheckoutInitiated:
|
|
145
|
-
clearCart:
|
|
146
|
-
clearAndCreateNewCart:
|
|
147
|
-
refetch:
|
|
148
|
-
isOpen:
|
|
149
|
-
open:
|
|
150
|
-
close:
|
|
142
|
+
updateCartMutation: Q,
|
|
143
|
+
checkoutMutation: V,
|
|
144
|
+
addItem: W,
|
|
145
|
+
updateItem: X,
|
|
146
|
+
removeItem: Z,
|
|
147
|
+
applyDiscount: q,
|
|
148
|
+
removeDiscount: tt,
|
|
149
|
+
trackCheckoutInitiated: ot,
|
|
150
|
+
clearCart: F,
|
|
151
|
+
clearAndCreateNewCart: et,
|
|
152
|
+
refetch: s,
|
|
153
|
+
isOpen: S,
|
|
154
|
+
open: rt,
|
|
155
|
+
close: N
|
|
151
156
|
};
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
return /* @__PURE__ */ at($.Provider, { value: nt, children: [
|
|
158
|
+
C,
|
|
159
|
+
O && /* @__PURE__ */ ct(
|
|
160
|
+
kt,
|
|
156
161
|
{
|
|
157
|
-
isOpen:
|
|
158
|
-
onClose:
|
|
159
|
-
...
|
|
162
|
+
isOpen: S,
|
|
163
|
+
onClose: N,
|
|
164
|
+
...j
|
|
160
165
|
}
|
|
161
166
|
)
|
|
162
167
|
] });
|
|
163
168
|
}
|
|
164
|
-
function
|
|
165
|
-
const
|
|
166
|
-
if (!
|
|
169
|
+
function Rt() {
|
|
170
|
+
const C = it($);
|
|
171
|
+
if (!C)
|
|
167
172
|
throw new Error("useCart must be used within CartProvider");
|
|
168
|
-
return
|
|
173
|
+
return C;
|
|
169
174
|
}
|
|
170
175
|
export {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
$ as CartContext,
|
|
177
|
+
Pt as CartProvider,
|
|
178
|
+
Rt as useCart
|
|
174
179
|
};
|
package/dist/index30.mjs
CHANGED
|
@@ -1,23 +1,104 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const s = {
|
|
3
|
+
// Public API keys (RPC is now the default)
|
|
4
|
+
public: {
|
|
5
|
+
all: ["public"],
|
|
6
|
+
carts: {
|
|
7
|
+
all: ["public", "carts"],
|
|
8
|
+
detail: (a) => ["public", "carts", a]
|
|
9
|
+
},
|
|
10
|
+
orders: {
|
|
11
|
+
all: ["public", "orders"],
|
|
12
|
+
detail: (a, i) => ["public", "orders", a, i]
|
|
13
|
+
},
|
|
14
|
+
products: {
|
|
15
|
+
all: ["public", "products"],
|
|
16
|
+
list: (a) => ["public", "products", a],
|
|
17
|
+
detail: (a) => ["public", "products", a]
|
|
18
|
+
},
|
|
19
|
+
deliveryZones: {
|
|
20
|
+
all: ["public", "delivery-zones"],
|
|
21
|
+
list: (a) => ["public", "delivery-zones", a]
|
|
22
|
+
},
|
|
23
|
+
brands: {
|
|
24
|
+
all: ["public", "brands"],
|
|
25
|
+
detail: (a) => ["public", "brands", a]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
// Admin API keys (RPC is now the default)
|
|
29
|
+
admin: {
|
|
30
|
+
all: ["admin"],
|
|
31
|
+
orders: {
|
|
32
|
+
all: ["admin", "orders"],
|
|
33
|
+
list: (a) => ["admin", "orders", "list", JSON.stringify(a)],
|
|
34
|
+
detail: (a) => ["admin", "orders", a]
|
|
35
|
+
},
|
|
36
|
+
brands: {
|
|
37
|
+
all: ["admin", "brands"],
|
|
38
|
+
list: () => ["admin", "brands", "list"],
|
|
39
|
+
detail: (a) => ["admin", "brands", a]
|
|
40
|
+
},
|
|
41
|
+
products: {
|
|
42
|
+
all: ["admin", "products"],
|
|
43
|
+
list: (a) => ["admin", "products", "list", a],
|
|
44
|
+
detail: (a) => ["admin", "products", a]
|
|
45
|
+
},
|
|
46
|
+
variants: {
|
|
47
|
+
all: ["admin", "variants"],
|
|
48
|
+
list: () => ["admin", "variants", "list"],
|
|
49
|
+
detail: (a) => ["admin", "variants", a],
|
|
50
|
+
search: (a) => ["admin", "variants", "search", a],
|
|
51
|
+
byProduct: (a) => ["admin", "variants", "product", a],
|
|
52
|
+
inventory: (a) => ["admin", "variants", a, "inventory"]
|
|
53
|
+
},
|
|
54
|
+
warehouses: {
|
|
55
|
+
all: ["admin", "warehouses"],
|
|
56
|
+
list: () => ["admin", "warehouses", "list"],
|
|
57
|
+
detail: (a) => ["admin", "warehouses", a],
|
|
58
|
+
inventory: (a) => ["admin", "warehouses", a, "inventory"]
|
|
59
|
+
},
|
|
60
|
+
inventory: {
|
|
61
|
+
all: ["admin", "inventory"],
|
|
62
|
+
list: (a) => ["admin", "inventory", "list", a],
|
|
63
|
+
transactions: (a) => ["admin", "inventory", "transactions", a],
|
|
64
|
+
lowStock: (a) => ["admin", "inventory", "low-stock", a]
|
|
65
|
+
},
|
|
66
|
+
customers: {
|
|
67
|
+
all: ["admin", "customers"],
|
|
68
|
+
history: (a) => ["admin", "customers", "history", a]
|
|
69
|
+
},
|
|
70
|
+
stats: {
|
|
71
|
+
all: ["admin", "stats"],
|
|
72
|
+
overview: (a) => ["admin", "stats", "overview", a]
|
|
73
|
+
},
|
|
74
|
+
abandonedCarts: {
|
|
75
|
+
all: ["admin", "abandoned-carts"],
|
|
76
|
+
list: (a) => ["admin", "abandoned-carts", "list", a],
|
|
77
|
+
detail: (a) => ["admin", "abandoned-carts", a],
|
|
78
|
+
stats: (a) => ["admin", "abandoned-carts", "stats", a]
|
|
79
|
+
},
|
|
80
|
+
discountCodes: {
|
|
81
|
+
all: ["admin", "discount-codes"],
|
|
82
|
+
list: (a) => ["admin", "discount-codes", "list", a],
|
|
83
|
+
detail: (a) => ["admin", "discount-codes", a],
|
|
84
|
+
analytics: (a) => ["admin", "discount-codes", a, "analytics"],
|
|
85
|
+
overviewStats: () => ["admin", "discount-codes", "stats", "overview"]
|
|
86
|
+
},
|
|
87
|
+
deliveryZones: {
|
|
88
|
+
all: ["admin", "delivery-zones"],
|
|
89
|
+
states: {
|
|
90
|
+
all: ["admin", "delivery-zones", "states"],
|
|
91
|
+
list: () => ["admin", "delivery-zones", "states", "list"],
|
|
92
|
+
detail: (a) => ["admin", "delivery-zones", "states", a]
|
|
93
|
+
},
|
|
94
|
+
zones: {
|
|
95
|
+
all: ["admin", "delivery-zones", "zones"],
|
|
96
|
+
list: (a) => ["admin", "delivery-zones", "zones", "list", a],
|
|
97
|
+
detail: (a) => ["admin", "delivery-zones", "zones", a]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
7
102
|
export {
|
|
8
|
-
|
|
9
|
-
u as useApplyDiscount,
|
|
10
|
-
o as useCheckoutCart,
|
|
11
|
-
G as useConfirmOrder,
|
|
12
|
-
s as useCreateCart,
|
|
13
|
-
l as useGetBrand,
|
|
14
|
-
a as useGetCart,
|
|
15
|
-
D as useGetDeliveryZones,
|
|
16
|
-
c as useGetOrder,
|
|
17
|
-
x as useGetProduct,
|
|
18
|
-
i as useGetProducts,
|
|
19
|
-
m as useRemoveCartItem,
|
|
20
|
-
C as useRemoveDiscount,
|
|
21
|
-
d as useUpdateCart,
|
|
22
|
-
p as useUpdateCartItem
|
|
103
|
+
s as queryKeys
|
|
23
104
|
};
|
package/dist/index31.mjs
CHANGED
|
@@ -1,68 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useAdjustInventory as k, useGetInventoryTransactions as w, useGetLowStockVariants as T, useListInventory as j, useTransferInventory as E } from "./index54.mjs";
|
|
8
|
-
import { useGetCustomerHistory as g } from "./index55.mjs";
|
|
9
|
-
import { useGetStats as z } from "./index56.mjs";
|
|
10
|
-
import { useCleanupExpiredCarts as J, useGetAbandonedCart as K, useGetAbandonedCartStats as M, useListAbandonedCarts as N } from "./index57.mjs";
|
|
11
|
-
import { useBulkGenerateDiscountCodes as R, useCreateDiscountCode as X, useDeleteDiscountCode as Y, useGetDiscountCode as _, useGetDiscountCodeAnalytics as $, useGetDiscountCodeOverviewStats as ee, useListDiscountCodes as te, useUpdateDiscountCode as se } from "./index58.mjs";
|
|
12
|
-
import { useCreateDeliveryZone as ue, useCreateState as oe, useDeleteDeliveryZone as ae, useDeleteState as ne, useListDeliveryZones as de, useListStates as ie, useUpdateDeliveryZone as pe, useUpdateState as Ce } from "./index59.mjs";
|
|
2
|
+
import { useAddCartItem as r, useApplyDiscount as u, useCheckoutCart as o, useCreateCart as s, useGetCart as a, useRemoveCartItem as m, useRemoveDiscount as C, useUpdateCart as d, useUpdateCartItem as p } from "./index33.mjs";
|
|
3
|
+
import { useConfirmOrder as G, useGetOrder as c } from "./index34.mjs";
|
|
4
|
+
import { useGetProduct as x, useGetProducts as i } from "./index35.mjs";
|
|
5
|
+
import { useGetDeliveryZones as D } from "./index36.mjs";
|
|
6
|
+
import { useGetBrand as l } from "./index37.mjs";
|
|
13
7
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
f as useDeleteProduct,
|
|
30
|
-
ne as useDeleteState,
|
|
31
|
-
S as useDeleteVariant,
|
|
32
|
-
P as useDeleteWarehouse,
|
|
33
|
-
K as useGetAbandonedCart,
|
|
34
|
-
M as useGetAbandonedCartStats,
|
|
35
|
-
C as useGetBrand,
|
|
36
|
-
g as useGetCustomerHistory,
|
|
37
|
-
_ as useGetDiscountCode,
|
|
38
|
-
$ as useGetDiscountCodeAnalytics,
|
|
39
|
-
ee as useGetDiscountCodeOverviewStats,
|
|
40
|
-
w as useGetInventoryTransactions,
|
|
41
|
-
T as useGetLowStockVariants,
|
|
42
|
-
u as useGetOrder,
|
|
43
|
-
m as useGetProduct,
|
|
44
|
-
z as useGetStats,
|
|
45
|
-
U as useGetVariantInventory,
|
|
46
|
-
A as useGetWarehouseInventory,
|
|
47
|
-
N as useListAbandonedCarts,
|
|
48
|
-
D as useListBrands,
|
|
49
|
-
de as useListDeliveryZones,
|
|
50
|
-
te as useListDiscountCodes,
|
|
51
|
-
j as useListInventory,
|
|
52
|
-
o as useListOrders,
|
|
53
|
-
O as useListProductVariants,
|
|
54
|
-
v as useListProducts,
|
|
55
|
-
ie as useListStates,
|
|
56
|
-
W as useListWarehouses,
|
|
57
|
-
V as useSearchVariants,
|
|
58
|
-
E as useTransferInventory,
|
|
59
|
-
c as useUpdateBrand,
|
|
60
|
-
pe as useUpdateDeliveryZone,
|
|
61
|
-
se as useUpdateDiscountCode,
|
|
62
|
-
a as useUpdateOrder,
|
|
63
|
-
n as useUpdateOrderStatus,
|
|
64
|
-
x as useUpdateProduct,
|
|
65
|
-
Ce as useUpdateState,
|
|
66
|
-
h as useUpdateVariant,
|
|
67
|
-
Z as useUpdateWarehouse
|
|
8
|
+
r as useAddCartItem,
|
|
9
|
+
u as useApplyDiscount,
|
|
10
|
+
o as useCheckoutCart,
|
|
11
|
+
G as useConfirmOrder,
|
|
12
|
+
s as useCreateCart,
|
|
13
|
+
l as useGetBrand,
|
|
14
|
+
a as useGetCart,
|
|
15
|
+
D as useGetDeliveryZones,
|
|
16
|
+
c as useGetOrder,
|
|
17
|
+
x as useGetProduct,
|
|
18
|
+
i as useGetProducts,
|
|
19
|
+
m as useRemoveCartItem,
|
|
20
|
+
C as useRemoveDiscount,
|
|
21
|
+
d as useUpdateCart,
|
|
22
|
+
p as useUpdateCartItem
|
|
68
23
|
};
|