@instockng/storefront-ui 1.0.11 → 1.0.12
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/components/ShoppingCart.d.ts.map +1 -1
- package/dist/contexts/CartContext.d.ts.map +1 -1
- package/dist/index105.mjs +1 -1
- package/dist/index29.mjs +1 -1
- package/dist/index3.mjs +75 -75
- package/dist/index30.mjs +1 -1
- package/dist/index31.mjs +1 -1
- package/dist/index32.mjs +1 -1
- package/dist/index44.mjs +1 -1
- package/dist/index45.mjs +1 -1
- package/dist/index46.mjs +1 -1
- package/dist/index47.mjs +1 -1
- package/dist/index48.mjs +1 -1
- package/dist/index49.mjs +1 -1
- package/dist/index50.mjs +1 -1
- package/dist/index51.mjs +1 -1
- package/dist/index52.mjs +1 -1
- package/dist/index53.mjs +1 -1
- package/dist/index54.mjs +1 -1
- package/dist/index58.mjs +2 -2
- package/dist/index59.mjs +3 -4
- package/dist/index60.mjs +2 -4
- package/dist/index61.mjs +5 -2
- package/dist/index8.mjs +8 -7
- package/dist/index81.mjs +1 -1
- package/dist/index83.mjs +1 -1
- package/dist/index84.mjs +2 -2
- package/dist/index88.mjs +2 -2
- package/dist/index93.mjs +12 -30
- package/dist/index94.mjs +7 -11
- package/dist/index95.mjs +30 -3
- package/dist/index96.mjs +10 -3
- package/dist/index97.mjs +4 -13
- package/dist/index98.mjs +4 -7
- package/package.json +3 -3
- package/src/components/ShoppingCart.tsx +1 -0
- package/src/contexts/CartContext.tsx +35 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShoppingCart.d.ts","sourceRoot":"","sources":["../../src/components/ShoppingCart.tsx"],"names":[],"mappings":"AAkBA,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,IAAI,CA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EAAE,SAAS,CAAC;IACpB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,IAAI,CAAC,OAAO,4BAA4B,EAAE,iBAAiB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;CACxG;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,iBAAiB,2CAsOxG;AAED;;GAEG;AACH,wBAAgB,OAAO,qBAMtB"}
|
package/dist/index105.mjs
CHANGED
package/dist/index29.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as s, useMutation as i } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as o } from "./
|
|
3
|
+
import { useQueryUnwrapped as o } from "./index61.mjs";
|
|
4
4
|
import { queryKeys as r } from "./index26.mjs";
|
|
5
5
|
import { updateCart as c, createCart as l, applyDiscount as y, removeDiscount as m, addCartItem as C, updateCartItem as p, removeCartItem as q, checkoutCart as d, fetchCart as f } from "./index23.mjs";
|
|
6
6
|
function b(e, t) {
|
package/dist/index3.mjs
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
2
|
+
import { jsxs as Y, jsx as q } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as z, useState as d, useRef as w, useEffect as a, useCallback as r, useContext as B } from "react";
|
|
4
4
|
import "./index18.mjs";
|
|
5
|
-
import { useGetCart as
|
|
5
|
+
import { useGetCart as J, useCreateCart as Q, useAddCartItem as V, useUpdateCartItem as W, useRemoveCartItem as X, useApplyDiscount as Z, useRemoveDiscount as $, useUpdateCart as tt, useCheckoutCart as et } from "./index29.mjs";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
|
-
import { ShoppingCart as
|
|
8
|
-
const m = "oms_cart_id",
|
|
9
|
-
function
|
|
10
|
-
const [t, s] = d(u || null), [
|
|
11
|
-
|
|
7
|
+
import { ShoppingCart as rt } from "./index8.mjs";
|
|
8
|
+
const m = "oms_cart_id", D = z(null);
|
|
9
|
+
function it({ children: c, brandSlug: f, initialCartId: u, shoppingCartProps: E }) {
|
|
10
|
+
const [t, s] = d(u || null), [p, C] = d(!1), [M, g] = d(!1), I = w(!1), h = w(!1), l = w(!1);
|
|
11
|
+
a(() => {
|
|
12
12
|
g(!0);
|
|
13
|
-
}, []),
|
|
14
|
-
if (u ||
|
|
13
|
+
}, []), a(() => {
|
|
14
|
+
if (u || I.current) return;
|
|
15
|
+
I.current = !0;
|
|
15
16
|
const n = new URLSearchParams(window.location.search).get("cartId");
|
|
16
17
|
if (n) {
|
|
17
18
|
s(n);
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
21
|
+
const v = localStorage.getItem(m);
|
|
22
|
+
v && s(v);
|
|
22
23
|
}, [u]);
|
|
23
|
-
const { data:
|
|
24
|
+
const { data: A, isLoading: R, error: i, refetch: o } = J(t || "", {
|
|
24
25
|
enabled: !!t,
|
|
25
26
|
retry: !1
|
|
26
27
|
// Don't retry on failure - cart might be invalid/expired
|
|
27
|
-
}),
|
|
28
|
+
}), y = Q({
|
|
28
29
|
onSuccess: (e) => {
|
|
29
30
|
if ("error" in e) {
|
|
30
31
|
console.error("Failed to create cart:", e.error);
|
|
@@ -36,33 +37,32 @@ function ut({ children: a, brandSlug: v, initialCartId: u, shoppingCartProps: S
|
|
|
36
37
|
console.error("Failed to create cart:", e);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const x = Q(t || "", {
|
|
53
|
-
onSuccess: () => o()
|
|
54
|
-
}), P = V(t || "", {
|
|
40
|
+
a(() => {
|
|
41
|
+
if (h.current) return;
|
|
42
|
+
h.current = !0;
|
|
43
|
+
const e = setTimeout(() => {
|
|
44
|
+
!t && !u && y.mutate(f);
|
|
45
|
+
}, 150);
|
|
46
|
+
return () => clearTimeout(e);
|
|
47
|
+
}, []), a(() => {
|
|
48
|
+
i && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, creating new cart:", i), s(null), typeof window < "u" && localStorage.removeItem(m), setTimeout(() => {
|
|
49
|
+
y.mutate(f), l.current = !1;
|
|
50
|
+
}, 100));
|
|
51
|
+
}, [i, t, f]);
|
|
52
|
+
const x = V(t || "", {
|
|
55
53
|
onSuccess: () => o()
|
|
56
|
-
}),
|
|
54
|
+
}), P = W(t || "", {
|
|
57
55
|
onSuccess: () => o()
|
|
58
56
|
}), N = X(t || "", {
|
|
59
57
|
onSuccess: () => o()
|
|
60
|
-
}),
|
|
58
|
+
}), F = Z(t || "", {
|
|
59
|
+
onSuccess: () => o()
|
|
60
|
+
}), T = $(t || "", {
|
|
61
61
|
onSuccess: () => o()
|
|
62
|
-
}),
|
|
62
|
+
}), U = tt(t || "", {
|
|
63
63
|
onSuccess: () => o()
|
|
64
|
-
}),
|
|
65
|
-
|
|
64
|
+
}), _ = et(t || "");
|
|
65
|
+
a(() => {
|
|
66
66
|
t && typeof window < "u" && localStorage.setItem(m, t);
|
|
67
67
|
}, [t]);
|
|
68
68
|
const k = r(
|
|
@@ -72,74 +72,74 @@ function ut({ children: a, brandSlug: v, initialCartId: u, shoppingCartProps: S
|
|
|
72
72
|
},
|
|
73
73
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
74
|
[t]
|
|
75
|
-
),
|
|
75
|
+
), L = r(
|
|
76
76
|
async (e, n) => {
|
|
77
77
|
if (!t) throw new Error("No cart ID");
|
|
78
78
|
await P.mutateAsync({ itemId: e, quantity: n });
|
|
79
79
|
},
|
|
80
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
81
|
[t]
|
|
82
|
-
),
|
|
82
|
+
), j = r(
|
|
83
83
|
async (e) => {
|
|
84
84
|
if (!t) throw new Error("No cart ID");
|
|
85
|
-
await
|
|
85
|
+
await N.mutateAsync(e);
|
|
86
86
|
},
|
|
87
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
88
|
[t]
|
|
89
|
-
),
|
|
89
|
+
), O = r(
|
|
90
90
|
async (e) => {
|
|
91
91
|
if (!t) throw new Error("No cart ID");
|
|
92
|
-
await
|
|
92
|
+
await F.mutateAsync({ code: e });
|
|
93
93
|
},
|
|
94
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
95
|
[t]
|
|
96
|
-
),
|
|
96
|
+
), b = r(async () => {
|
|
97
97
|
if (!t) throw new Error("No cart ID");
|
|
98
|
-
await
|
|
99
|
-
}, [t]),
|
|
98
|
+
await T.mutateAsync();
|
|
99
|
+
}, [t]), G = r(() => {
|
|
100
100
|
s(null), typeof window < "u" && localStorage.removeItem(m);
|
|
101
|
-
}, []),
|
|
102
|
-
|
|
103
|
-
}, []),
|
|
104
|
-
|
|
105
|
-
}, []),
|
|
106
|
-
cart:
|
|
101
|
+
}, []), H = r(() => {
|
|
102
|
+
C(!0);
|
|
103
|
+
}, []), S = r(() => {
|
|
104
|
+
C(!1);
|
|
105
|
+
}, []), K = {
|
|
106
|
+
cart: A || null,
|
|
107
107
|
cartId: t,
|
|
108
|
-
isLoading:
|
|
109
|
-
error:
|
|
110
|
-
updateCartMutation:
|
|
111
|
-
checkoutMutation:
|
|
108
|
+
isLoading: R,
|
|
109
|
+
error: i,
|
|
110
|
+
updateCartMutation: U,
|
|
111
|
+
checkoutMutation: _,
|
|
112
112
|
addItem: k,
|
|
113
|
-
updateItem:
|
|
114
|
-
removeItem:
|
|
115
|
-
applyDiscount:
|
|
116
|
-
removeDiscount:
|
|
117
|
-
clearCart:
|
|
113
|
+
updateItem: L,
|
|
114
|
+
removeItem: j,
|
|
115
|
+
applyDiscount: O,
|
|
116
|
+
removeDiscount: b,
|
|
117
|
+
clearCart: G,
|
|
118
118
|
refetch: o,
|
|
119
|
-
isOpen:
|
|
120
|
-
open:
|
|
121
|
-
close:
|
|
119
|
+
isOpen: p,
|
|
120
|
+
open: H,
|
|
121
|
+
close: S
|
|
122
122
|
};
|
|
123
|
-
return /* @__PURE__ */
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
return /* @__PURE__ */ Y(D.Provider, { value: K, children: [
|
|
124
|
+
c,
|
|
125
|
+
M && /* @__PURE__ */ q(
|
|
126
|
+
rt,
|
|
127
127
|
{
|
|
128
|
-
isOpen:
|
|
129
|
-
onClose:
|
|
130
|
-
...
|
|
128
|
+
isOpen: p,
|
|
129
|
+
onClose: S,
|
|
130
|
+
...E
|
|
131
131
|
}
|
|
132
132
|
)
|
|
133
133
|
] });
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
135
|
+
function mt() {
|
|
136
|
+
const c = B(D);
|
|
137
|
+
if (!c)
|
|
138
138
|
throw new Error("useCart must be used within CartProvider");
|
|
139
|
-
return
|
|
139
|
+
return c;
|
|
140
140
|
}
|
|
141
141
|
export {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
D as CartContext,
|
|
143
|
+
it as CartProvider,
|
|
144
|
+
mt as useCart
|
|
145
145
|
};
|
package/dist/index30.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useMutation as t } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as u } from "./
|
|
3
|
+
import { useQueryUnwrapped as u } from "./index61.mjs";
|
|
4
4
|
import { queryKeys as n } from "./index26.mjs";
|
|
5
5
|
import { confirmOrder as i, fetchOrder as m } from "./index24.mjs";
|
|
6
6
|
function y(e, r, o) {
|
package/dist/index31.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useQueryUnwrapped as u } from "./
|
|
2
|
+
import { useQueryUnwrapped as u } from "./index61.mjs";
|
|
3
3
|
import { queryKeys as t } from "./index26.mjs";
|
|
4
4
|
import { fetchProductsByBrand as o, fetchProductBySlug as c } from "./index22.mjs";
|
|
5
5
|
function n(r, e) {
|
package/dist/index32.mjs
CHANGED
package/dist/index44.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as y, useMutation as m } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as p } from "./
|
|
3
|
+
import { useQueryUnwrapped as p } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as d, authHeaders as c } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as i } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as l } from "./index19.mjs";
|
package/dist/index45.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as y, useMutation as m } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as b } from "./
|
|
3
|
+
import { useQueryUnwrapped as b } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as o } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as d } from "./index19.mjs";
|
package/dist/index46.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as p, useMutation as y } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as m } from "./
|
|
3
|
+
import { useQueryUnwrapped as m } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as a, authHeaders as c } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as i } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as d } from "./index19.mjs";
|
package/dist/index47.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as m } from "./
|
|
3
|
+
import { useQueryUnwrapped as m } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as i } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as d } from "./index19.mjs";
|
package/dist/index48.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as w, useMutation as y } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as d } from "./
|
|
3
|
+
import { useQueryUnwrapped as d } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as i, authHeaders as c } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as u } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as l } from "./index19.mjs";
|
package/dist/index49.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as d, useMutation as v } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as l } from "./
|
|
3
|
+
import { useQueryUnwrapped as l } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as s } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as y } from "./index19.mjs";
|
package/dist/index50.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useQueryUnwrapped as i } from "./
|
|
2
|
+
import { useQueryUnwrapped as i } from "./index61.mjs";
|
|
3
3
|
import { createAdminRpcClients as n, authHeaders as u } from "./index21.mjs";
|
|
4
4
|
import { queryKeys as m } from "./index26.mjs";
|
|
5
5
|
import { useApiConfig as a } from "./index19.mjs";
|
package/dist/index51.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useQueryUnwrapped as s } from "./
|
|
2
|
+
import { useQueryUnwrapped as s } from "./index61.mjs";
|
|
3
3
|
import { createAdminRpcClients as i, authHeaders as u } from "./index21.mjs";
|
|
4
4
|
import { queryKeys as c } from "./index26.mjs";
|
|
5
5
|
import { useApiConfig as d } from "./index19.mjs";
|
package/dist/index52.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as l, useMutation as y } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as c } from "./
|
|
3
|
+
import { useQueryUnwrapped as c } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as s, authHeaders as o } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as i } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as u } from "./index19.mjs";
|
package/dist/index53.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as l, useMutation as y } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as C } from "./
|
|
3
|
+
import { useQueryUnwrapped as C } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as c, authHeaders as a } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as r } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as d } from "./index19.mjs";
|
package/dist/index54.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
|
|
3
|
-
import { useQueryUnwrapped as m } from "./
|
|
3
|
+
import { useQueryUnwrapped as m } from "./index61.mjs";
|
|
4
4
|
import { createAdminRpcClients as u, authHeaders as l } from "./index21.mjs";
|
|
5
5
|
import { queryKeys as o } from "./index26.mjs";
|
|
6
6
|
import { useApiConfig as c } from "./index19.mjs";
|
package/dist/index58.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { getDefaultExportFromCjs as d } from "./
|
|
3
|
-
import { __module as v } from "./
|
|
2
|
+
import { getDefaultExportFromCjs as d } from "./index59.mjs";
|
|
3
|
+
import { __module as v } from "./index60.mjs";
|
|
4
4
|
v.exports = function(n) {
|
|
5
5
|
return g(m(n), n);
|
|
6
6
|
};
|
package/dist/index59.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return e(r);
|
|
2
|
+
function e(t) {
|
|
3
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
5
4
|
}
|
|
6
5
|
export {
|
|
7
|
-
|
|
6
|
+
e as getDefaultExportFromCjs
|
|
8
7
|
};
|
package/dist/index60.mjs
CHANGED
package/dist/index61.mjs
CHANGED
package/dist/index8.mjs
CHANGED
|
@@ -23,7 +23,7 @@ function W({
|
|
|
23
23
|
emptyMessage: I = "Your cart is empty"
|
|
24
24
|
}) {
|
|
25
25
|
var x, y, g;
|
|
26
|
-
const { cart: t, isLoading: i, error: m } = q(), [
|
|
26
|
+
const { cart: t, isLoading: i, error: m } = q(), [S, u] = Y(!1);
|
|
27
27
|
b(() => (s ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
|
|
28
28
|
document.body.style.overflow = "";
|
|
29
29
|
}), [s]), b(() => {
|
|
@@ -32,9 +32,9 @@ function W({
|
|
|
32
32
|
};
|
|
33
33
|
return window.addEventListener("keydown", r), () => window.removeEventListener("keydown", r);
|
|
34
34
|
}, [s, l]);
|
|
35
|
-
const
|
|
35
|
+
const D = ((x = t == null ? void 0 : t.pricing) == null ? void 0 : x.subtotal) || 0, p = ((y = t == null ? void 0 : t.pricing.discount) == null ? void 0 : y.amount) || 0, F = () => {
|
|
36
36
|
u(!0), d == null || d();
|
|
37
|
-
},
|
|
37
|
+
}, P = () => {
|
|
38
38
|
o == null || o(), l();
|
|
39
39
|
};
|
|
40
40
|
return /* @__PURE__ */ a(N, { children: [
|
|
@@ -103,7 +103,7 @@ function W({
|
|
|
103
103
|
/* @__PURE__ */ a("div", { className: "p-4 space-y-2", children: [
|
|
104
104
|
/* @__PURE__ */ a("div", { className: "flex justify-between", children: [
|
|
105
105
|
/* @__PURE__ */ e("span", { className: "text-gray-600", children: "Subtotal" }),
|
|
106
|
-
/* @__PURE__ */ e("span", { className: "font-semibold", children: n(
|
|
106
|
+
/* @__PURE__ */ e("span", { className: "font-semibold", children: n(D) })
|
|
107
107
|
] }),
|
|
108
108
|
p > 0 && /* @__PURE__ */ a("div", { className: "flex justify-between text-green-600", children: [
|
|
109
109
|
/* @__PURE__ */ e("span", { children: "Discount" }),
|
|
@@ -126,7 +126,7 @@ function W({
|
|
|
126
126
|
/* @__PURE__ */ a(
|
|
127
127
|
v,
|
|
128
128
|
{
|
|
129
|
-
onClick:
|
|
129
|
+
onClick: F,
|
|
130
130
|
disabled: z || t.items.length === 0,
|
|
131
131
|
className: c("w-full bg-accent-500 text-white hover:bg-accent-600", E),
|
|
132
132
|
size: "lg",
|
|
@@ -139,7 +139,7 @@ function W({
|
|
|
139
139
|
/* @__PURE__ */ e(
|
|
140
140
|
v,
|
|
141
141
|
{
|
|
142
|
-
onClick:
|
|
142
|
+
onClick: P,
|
|
143
143
|
variant: "outline",
|
|
144
144
|
className: c("w-full border-gray-300 text-gray-600 hover:bg-gray-100", L),
|
|
145
145
|
size: "lg",
|
|
@@ -155,7 +155,8 @@ function W({
|
|
|
155
155
|
/* @__PURE__ */ e(
|
|
156
156
|
X,
|
|
157
157
|
{
|
|
158
|
-
isOpen:
|
|
158
|
+
isOpen: S,
|
|
159
|
+
onSuccess: () => l(),
|
|
159
160
|
onClose: () => u(!1)
|
|
160
161
|
}
|
|
161
162
|
)
|
package/dist/index81.mjs
CHANGED
package/dist/index83.mjs
CHANGED
package/dist/index84.mjs
CHANGED
package/dist/index88.mjs
CHANGED
package/dist/index93.mjs
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g, function(r) {
|
|
14
|
-
return t[r];
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function a(n, t) {
|
|
18
|
-
this._pairs = [], n && p(n, this, t);
|
|
19
|
-
}
|
|
20
|
-
const c = a.prototype;
|
|
21
|
-
c.append = function(t, o) {
|
|
22
|
-
this._pairs.push([t, o]);
|
|
23
|
-
};
|
|
24
|
-
c.toString = function(t) {
|
|
25
|
-
const o = t ? function(r) {
|
|
26
|
-
return t.call(this, r, i);
|
|
27
|
-
} : i;
|
|
28
|
-
return this._pairs.map(function(e) {
|
|
29
|
-
return o(e[0]) + "=" + o(e[1]);
|
|
30
|
-
}, "").join("&");
|
|
2
|
+
import o from "./index105.mjs";
|
|
3
|
+
import r from "./index106.mjs";
|
|
4
|
+
import t from "./index107.mjs";
|
|
5
|
+
const l = {
|
|
6
|
+
isBrowser: !0,
|
|
7
|
+
classes: {
|
|
8
|
+
URLSearchParams: o,
|
|
9
|
+
FormData: r,
|
|
10
|
+
Blob: t
|
|
11
|
+
},
|
|
12
|
+
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
31
13
|
};
|
|
32
14
|
export {
|
|
33
|
-
|
|
15
|
+
l as default
|
|
34
16
|
};
|
package/dist/index94.mjs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import s from "./index78.mjs";
|
|
5
|
-
function h(f, t) {
|
|
6
|
-
const o = this || m, r = t || o, n = s.from(r.headers);
|
|
7
|
-
let a = r.data;
|
|
8
|
-
return i.forEach(f, function(e) {
|
|
9
|
-
a = e.call(o, a, n.normalize(), t ? t.status : void 0);
|
|
10
|
-
}), n.normalize(), a;
|
|
11
|
-
}
|
|
2
|
+
const e = typeof window < "u" && typeof document < "u", o = typeof navigator == "object" && navigator || void 0, n = e && (!o || ["ReactNative", "NativeScript", "NS"].indexOf(o.product) < 0), t = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
3
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts == "function", r = e && window.location.href || "http://localhost";
|
|
12
4
|
export {
|
|
13
|
-
|
|
5
|
+
e as hasBrowserEnv,
|
|
6
|
+
n as hasStandardBrowserEnv,
|
|
7
|
+
t as hasStandardBrowserWebWorkerEnv,
|
|
8
|
+
o as navigator,
|
|
9
|
+
r as origin
|
|
14
10
|
};
|
package/dist/index95.mjs
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import p from "./index74.mjs";
|
|
3
|
+
function i(n) {
|
|
4
|
+
const t = {
|
|
5
|
+
"!": "%21",
|
|
6
|
+
"'": "%27",
|
|
7
|
+
"(": "%28",
|
|
8
|
+
")": "%29",
|
|
9
|
+
"~": "%7E",
|
|
10
|
+
"%20": "+",
|
|
11
|
+
"%00": "\0"
|
|
12
|
+
};
|
|
13
|
+
return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g, function(r) {
|
|
14
|
+
return t[r];
|
|
15
|
+
});
|
|
4
16
|
}
|
|
17
|
+
function a(n, t) {
|
|
18
|
+
this._pairs = [], n && p(n, this, t);
|
|
19
|
+
}
|
|
20
|
+
const c = a.prototype;
|
|
21
|
+
c.append = function(t, o) {
|
|
22
|
+
this._pairs.push([t, o]);
|
|
23
|
+
};
|
|
24
|
+
c.toString = function(t) {
|
|
25
|
+
const o = t ? function(r) {
|
|
26
|
+
return t.call(this, r, i);
|
|
27
|
+
} : i;
|
|
28
|
+
return this._pairs.map(function(e) {
|
|
29
|
+
return o(e[0]) + "=" + o(e[1]);
|
|
30
|
+
}, "").join("&");
|
|
31
|
+
};
|
|
5
32
|
export {
|
|
6
|
-
|
|
33
|
+
a as default
|
|
7
34
|
};
|
package/dist/index96.mjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import i from "./index64.mjs";
|
|
3
|
+
import m from "./index68.mjs";
|
|
4
|
+
import s from "./index78.mjs";
|
|
5
|
+
function h(f, t) {
|
|
6
|
+
const o = this || m, r = t || o, n = s.from(r.headers);
|
|
7
|
+
let a = r.data;
|
|
8
|
+
return i.forEach(f, function(e) {
|
|
9
|
+
a = e.call(o, a, n.normalize(), t ? t.status : void 0);
|
|
10
|
+
}), n.normalize(), a;
|
|
4
11
|
}
|
|
5
12
|
export {
|
|
6
|
-
|
|
13
|
+
h as default
|
|
7
14
|
};
|
package/dist/index97.mjs
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const l = {
|
|
6
|
-
isBrowser: !0,
|
|
7
|
-
classes: {
|
|
8
|
-
URLSearchParams: o,
|
|
9
|
-
FormData: r,
|
|
10
|
-
Blob: t
|
|
11
|
-
},
|
|
12
|
-
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
13
|
-
};
|
|
2
|
+
function e(t) {
|
|
3
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
4
|
+
}
|
|
14
5
|
export {
|
|
15
|
-
|
|
6
|
+
e as default
|
|
16
7
|
};
|
package/dist/index98.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function n(e, c) {
|
|
3
|
+
return c ? e.replace(/\/?\/$/, "") + "/" + c.replace(/^\/+/, "") : e;
|
|
4
|
+
}
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
-
n as hasStandardBrowserEnv,
|
|
7
|
-
t as hasStandardBrowserWebWorkerEnv,
|
|
8
|
-
o as navigator,
|
|
9
|
-
r as origin
|
|
6
|
+
n as default
|
|
10
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instockng/storefront-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Pre-built UI components for OMS e-commerce sites",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"tailwindcss": "^4.1.14",
|
|
67
67
|
"typescript": "^5.3.3",
|
|
68
68
|
"vite": "^5.4.20",
|
|
69
|
-
"@oms/
|
|
70
|
-
"@oms/
|
|
69
|
+
"@oms/shared": "1.0.0",
|
|
70
|
+
"@oms/api-client": "1.0.0"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"type-check": "tsc --noEmit",
|
|
@@ -84,7 +84,8 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
|
|
|
84
84
|
const [isMounted, setIsMounted] = useState(false);
|
|
85
85
|
|
|
86
86
|
// Use refs to prevent infinite loops
|
|
87
|
-
const
|
|
87
|
+
const hasLoadedFromStorageRef = useRef(false);
|
|
88
|
+
const hasAutoCreatedRef = useRef(false);
|
|
88
89
|
const isHandlingErrorRef = useRef(false);
|
|
89
90
|
|
|
90
91
|
// Set mounted flag on client
|
|
@@ -95,7 +96,9 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
|
|
|
95
96
|
// Load cartId from URL/localStorage after mount (client-side only)
|
|
96
97
|
// This avoids hydration mismatch between server and client
|
|
97
98
|
useEffect(() => {
|
|
98
|
-
if (initialCartId ||
|
|
99
|
+
if (initialCartId || hasLoadedFromStorageRef.current) return;
|
|
100
|
+
|
|
101
|
+
hasLoadedFromStorageRef.current = true;
|
|
99
102
|
|
|
100
103
|
// Check URL query params first
|
|
101
104
|
const urlParams = new URLSearchParams(window.location.search);
|
|
@@ -134,39 +137,47 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
|
|
|
134
137
|
},
|
|
135
138
|
});
|
|
136
139
|
|
|
137
|
-
// Auto-create cart on mount if no cartId
|
|
138
|
-
//
|
|
140
|
+
// Auto-create cart ONLY on initial mount if no cartId in localStorage
|
|
141
|
+
// After the first mount, we don't auto-create (user must explicitly add items)
|
|
139
142
|
useEffect(() => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
// Only run on initial mount
|
|
144
|
+
if (hasAutoCreatedRef.current) return;
|
|
145
|
+
|
|
146
|
+
hasAutoCreatedRef.current = true;
|
|
147
|
+
|
|
148
|
+
// Defer cart creation to allow localStorage to load first
|
|
149
|
+
const timeoutId = setTimeout(() => {
|
|
150
|
+
// Only create if we still don't have a cartId after localStorage loaded
|
|
151
|
+
if (!cartId && !initialCartId) {
|
|
145
152
|
createCartMutation.mutate(brandSlug);
|
|
146
|
-
}
|
|
153
|
+
}
|
|
154
|
+
}, 150); // Delay to ensure localStorage effect has run
|
|
147
155
|
|
|
148
|
-
|
|
149
|
-
}
|
|
156
|
+
return () => clearTimeout(timeoutId);
|
|
150
157
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
151
|
-
}, []);
|
|
158
|
+
}, []); // Empty deps - truly only run once on mount
|
|
152
159
|
|
|
153
160
|
// Handle cart fetch error (invalid/expired cart from URL or localStorage)
|
|
154
|
-
//
|
|
161
|
+
// Clear the invalid cart and create a new one
|
|
155
162
|
useEffect(() => {
|
|
156
163
|
if (error && cartId && !isHandlingErrorRef.current) {
|
|
157
164
|
isHandlingErrorRef.current = true;
|
|
158
|
-
console.warn('Cart fetch failed,
|
|
159
|
-
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
console.warn('Cart fetch failed, creating new cart:', error);
|
|
166
|
+
|
|
167
|
+
// Clear invalid cart
|
|
168
|
+
setCartId(null);
|
|
169
|
+
if (typeof window !== 'undefined') {
|
|
170
|
+
localStorage.removeItem(CART_ID_KEY);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Create a new cart after clearing the invalid one
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
createCartMutation.mutate(brandSlug);
|
|
166
176
|
isHandlingErrorRef.current = false;
|
|
167
|
-
});
|
|
177
|
+
}, 100);
|
|
168
178
|
}
|
|
169
|
-
|
|
179
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
180
|
+
}, [error, cartId, brandSlug]); // Don't include createCartMutation to avoid infinite loop
|
|
170
181
|
|
|
171
182
|
// Mutations
|
|
172
183
|
const addItemMutation = useAddCartItem(cartId || '', {
|