@numueg/theme-sdk 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +14 -12
- package/dist/index.mjs.map +1 -1
- package/dist/validation.cjs +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var MAX_BLOCK_DEPTH = 5;
|
|
|
7
7
|
|
|
8
8
|
// src/validation/index.ts
|
|
9
9
|
var THEME_CONTRACT_VERSION = 1;
|
|
10
|
-
var SDK_VERSION = "0.5.
|
|
10
|
+
var SDK_VERSION = "0.5.2" ;
|
|
11
11
|
var REQUIRED_TEMPLATES = [
|
|
12
12
|
"home",
|
|
13
13
|
"product",
|
|
@@ -707,7 +707,7 @@ function useOrder(id) {
|
|
|
707
707
|
const [tick, setTick] = useState(0);
|
|
708
708
|
useEffect(() => {
|
|
709
709
|
if (typeof window === "undefined") return;
|
|
710
|
-
if (!
|
|
710
|
+
if (!id) {
|
|
711
711
|
setOrder(null);
|
|
712
712
|
setError(null);
|
|
713
713
|
setLoading(false);
|
|
@@ -718,14 +718,15 @@ function useOrder(id) {
|
|
|
718
718
|
setError(null);
|
|
719
719
|
void (async () => {
|
|
720
720
|
try {
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
721
|
+
const trackUrl = `/api/storefront/track/${encodeURIComponent(id)}`;
|
|
722
|
+
let res = customer ? await fetch(`/api/customer/me/orders/${encodeURIComponent(id)}`, {
|
|
723
|
+
method: "GET",
|
|
724
|
+
credentials: "include",
|
|
725
|
+
cache: "no-store"
|
|
726
|
+
}) : await fetch(trackUrl, { cache: "no-store" });
|
|
727
|
+
if (!res.ok && customer) {
|
|
728
|
+
res = await fetch(trackUrl, { cache: "no-store" });
|
|
729
|
+
}
|
|
729
730
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
730
731
|
const body = unwrap(await res.json());
|
|
731
732
|
if (cancelled) return;
|
|
@@ -1467,16 +1468,17 @@ function availableValues(product, selection) {
|
|
|
1467
1468
|
const variants = product.variants || [];
|
|
1468
1469
|
const out = {};
|
|
1469
1470
|
for (const axis of axes) {
|
|
1470
|
-
|
|
1471
|
+
const set = /* @__PURE__ */ new Set();
|
|
1471
1472
|
for (const v of variants) {
|
|
1472
1473
|
const opts = v.option_values || v.options || {};
|
|
1473
1474
|
const compatible = Object.entries(selection).every(
|
|
1474
1475
|
([k, val]) => k === axis.name || opts[k] === val
|
|
1475
1476
|
);
|
|
1476
1477
|
if (compatible && opts[axis.name]) {
|
|
1477
|
-
|
|
1478
|
+
set.add(opts[axis.name]);
|
|
1478
1479
|
}
|
|
1479
1480
|
}
|
|
1481
|
+
out[axis.name] = set.size > 0 ? set : new Set(axis.values || []);
|
|
1480
1482
|
}
|
|
1481
1483
|
return out;
|
|
1482
1484
|
}
|