@numueg/theme-sdk 0.5.0 → 0.5.1

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 CHANGED
@@ -9,7 +9,7 @@ var MAX_BLOCK_DEPTH = 5;
9
9
 
10
10
  // src/validation/index.ts
11
11
  var THEME_CONTRACT_VERSION = 1;
12
- var SDK_VERSION = "0.5.0" ;
12
+ var SDK_VERSION = "0.5.1" ;
13
13
  var REQUIRED_TEMPLATES = [
14
14
  "home",
15
15
  "product",
@@ -709,7 +709,7 @@ function useOrder(id) {
709
709
  const [tick, setTick] = react.useState(0);
710
710
  react.useEffect(() => {
711
711
  if (typeof window === "undefined") return;
712
- if (!customer || !id) {
712
+ if (!id) {
713
713
  setOrder(null);
714
714
  setError(null);
715
715
  setLoading(false);
@@ -720,14 +720,15 @@ function useOrder(id) {
720
720
  setError(null);
721
721
  void (async () => {
722
722
  try {
723
- const res = await fetch(
724
- `/api/customer/me/orders/${encodeURIComponent(id)}`,
725
- {
726
- method: "GET",
727
- credentials: "include",
728
- cache: "no-store"
729
- }
730
- );
723
+ const trackUrl = `/api/storefront/track/${encodeURIComponent(id)}`;
724
+ let res = customer ? await fetch(`/api/customer/me/orders/${encodeURIComponent(id)}`, {
725
+ method: "GET",
726
+ credentials: "include",
727
+ cache: "no-store"
728
+ }) : await fetch(trackUrl, { cache: "no-store" });
729
+ if (!res.ok && customer) {
730
+ res = await fetch(trackUrl, { cache: "no-store" });
731
+ }
731
732
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
732
733
  const body = unwrap(await res.json());
733
734
  if (cancelled) return;