@burdenoff/microfe-store 2026.705.1 → 2026.712.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.
@@ -4,196 +4,74 @@ import { formatPrice as n } from "../utils/index.js";
4
4
  import { InstallAppModal as r } from "../components/InstallAppModal.js";
5
5
  import { useInstallations as i } from "../hooks/useInstallations.js";
6
6
  import { useOrders as a } from "../hooks/useOrders.js";
7
- import { useMemo as o, useState as s } from "react";
8
- import { useI18n as c } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
9
- import { ArrowLeft as l, CheckCircle as u, Clock as d, Download as f, Loader2 as p, Package as m, RefreshCw as h, ShoppingBag as g, XCircle as _ } from "lucide-react";
10
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
11
- import { useNavigate as x } from "react-router-dom";
7
+ import { useCallback as o, useMemo as s, useState as c } from "react";
8
+ import { useI18n as l } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
9
+ import { ArrowLeft as u, CheckCircle as d, ChevronRight as f, Clock as p, Download as m, Loader2 as h, Package as g, RefreshCw as _, ShoppingBag as v, XCircle as y } from "lucide-react";
10
+ import { jsx as b, jsxs as x } from "react/jsx-runtime";
11
+ import { useNavigate as ee } from "react-router-dom";
12
12
  import { GlassCard as S, IllustratedEmptyState as C, PagePurpose as w } from "@burdenoff/fe-libs/ui";
13
13
  //#region src/pages/OrdersPage.tsx
14
- var T = (e) => {
14
+ var T = [
15
+ "COMPLETED",
16
+ "FULFILLED",
17
+ "PROCESSED"
18
+ ], E = (e) => {
15
19
  switch (e) {
16
20
  case "COMPLETED":
17
21
  case "FULFILLED":
18
22
  case "PROCESSED": return {
19
- icon: u,
20
- color: "text-status-success-text bg-status-success-bg-subtle/10",
23
+ icon: d,
24
+ classes: "bg-status-success-bg-subtle/15 text-status-success-text border-status-success-text/20",
21
25
  label: "Completed"
22
26
  };
23
27
  case "PROCESSING": return {
24
- icon: d,
25
- color: "text-status-warning-text bg-status-warning-bg-subtle/10",
28
+ icon: p,
29
+ classes: "bg-status-warning-bg-subtle/15 text-status-warning-text border-status-warning-text/20",
26
30
  label: "Processing"
27
31
  };
28
32
  case "PENDING": return {
29
- icon: d,
30
- color: "text-status-warning-text bg-status-warning-bg-subtle/10",
33
+ icon: p,
34
+ classes: "bg-status-warning-bg-subtle/15 text-status-warning-text border-status-warning-text/20",
31
35
  label: "Pending"
32
36
  };
33
37
  case "FAILED": return {
34
- icon: _,
35
- color: "text-status-error-text bg-status-error-bg-subtle/10",
38
+ icon: y,
39
+ classes: "bg-status-error-bg-subtle/15 text-status-error-text border-status-error-text/20",
36
40
  label: "Failed"
37
41
  };
38
42
  case "REFUNDED": return {
39
- icon: h,
40
- color: "text-status-warning-text bg-status-warning-bg-subtle/10",
43
+ icon: _,
44
+ classes: "bg-status-warning-bg-subtle/15 text-status-warning-text border-status-warning-text/20",
41
45
  label: "Refunded"
42
46
  };
43
47
  case "CANCELLED": return {
44
- icon: h,
45
- color: "text-text-muted bg-bg-sunken",
48
+ icon: _,
49
+ classes: "bg-bg-sunken text-text-muted border-border-default",
46
50
  label: "Cancelled"
47
51
  };
48
52
  default: return {
49
- icon: d,
50
- color: "text-text-muted",
53
+ icon: p,
54
+ classes: "bg-bg-sunken text-text-muted border-border-default",
51
55
  label: e
52
56
  };
53
57
  }
54
- }, E = ({ item: e, orderId: t, orderStatus: r, onOpenInstallModal: i, installing: a }) => {
55
- let o = r === "COMPLETED" || r === "FULFILLED" || r === "PROCESSED", s = e.productType !== "PHYSICAL" && e.productType !== "MERCHANDISE";
56
- return /* @__PURE__ */ b("div", {
57
- className: "flex items-center gap-4 rounded-lg border border-border-seam bg-bg-sunken/50 p-4",
58
- children: [
59
- /* @__PURE__ */ y("div", {
60
- className: "size-14 flex-shrink-0 overflow-hidden rounded-lg bg-bg-sunken",
61
- children: e.productIcon ? /* @__PURE__ */ y("img", {
62
- src: e.productIcon,
63
- alt: e.productName,
64
- className: "size-full object-cover"
65
- }) : /* @__PURE__ */ y("div", {
66
- className: "flex size-full items-center justify-center text-lg font-bold text-text-muted",
67
- children: e.productName.charAt(0)
68
- })
69
- }),
70
- /* @__PURE__ */ b("div", {
71
- className: "flex-1 min-w-0",
72
- children: [/* @__PURE__ */ y("h4", {
73
- className: "font-medium text-text-primary truncate",
74
- children: e.productName
75
- }), /* @__PURE__ */ b("div", {
76
- className: "flex items-center gap-2 mt-1",
77
- children: [/* @__PURE__ */ y("span", {
78
- className: "inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-muted",
79
- children: e.productType
80
- }), /* @__PURE__ */ b("span", {
81
- className: "text-sm text-text-muted",
82
- children: [
83
- e.quantity,
84
- " x ",
85
- n(e.unitPrice)
86
- ]
87
- })]
88
- })]
89
- }),
90
- /* @__PURE__ */ y("div", {
91
- className: "text-right",
92
- children: /* @__PURE__ */ y("p", {
93
- className: "font-semibold tabular-nums text-text-primary",
94
- children: n(e.totalPrice)
95
- })
96
- }),
97
- /* @__PURE__ */ y("div", {
98
- className: "flex-shrink-0",
99
- children: e.installed ? /* @__PURE__ */ b("span", {
100
- className: "inline-flex items-center gap-1.5 rounded-lg bg-status-success-bg-subtle/10 px-4 py-2 text-sm font-medium text-status-success-text",
101
- children: [/* @__PURE__ */ y(u, { className: "size-4" }), "Installed"]
102
- }) : o && s ? /* @__PURE__ */ y("button", {
103
- type: "button",
104
- onClick: () => i(t, e),
105
- disabled: a,
106
- className: "inline-flex cursor-pointer items-center gap-1.5 rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-opacity hover:opacity-90 disabled:opacity-50",
107
- children: a ? /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(p, { className: "size-4 animate-spin" }), "Installing…"] }) : /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(f, { className: "size-4" }), "Install App"] })
108
- }) : null
109
- })
110
- ]
111
- });
112
- }, D = ({ order: e, onOpenInstallModal: t, installingItem: r }) => {
113
- let i = T(e.status), a = i.icon;
114
- return /* @__PURE__ */ b(S, {
115
- className: "p-6",
116
- children: [
117
- /* @__PURE__ */ b("div", {
118
- className: "flex items-start justify-between mb-4",
119
- children: [/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ b("div", {
120
- className: "flex items-center gap-3",
121
- children: [/* @__PURE__ */ y("h3", {
122
- className: "text-lg font-semibold text-text-primary",
123
- children: e.orderNumber
124
- }), /* @__PURE__ */ b("span", {
125
- className: `inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-sm font-semibold ${i.color}`,
126
- children: [/* @__PURE__ */ y(a, { className: "size-4" }), i.label]
127
- })]
128
- }), /* @__PURE__ */ y("p", {
129
- className: "text-sm text-text-muted mt-1",
130
- children: new Date(e.createdAt).toLocaleDateString("en-US", {
131
- year: "numeric",
132
- month: "long",
133
- day: "numeric",
134
- hour: "2-digit",
135
- minute: "2-digit"
136
- })
137
- })] }), /* @__PURE__ */ b("div", {
138
- className: "text-right",
139
- children: [/* @__PURE__ */ y("p", {
140
- className: "text-xl font-bold tabular-nums text-text-primary",
141
- children: n(e.total)
142
- }), /* @__PURE__ */ b("p", {
143
- className: "text-xs text-text-muted",
144
- children: [
145
- e.items.length,
146
- " ",
147
- e.items.length === 1 ? "item" : "items"
148
- ]
149
- })]
150
- })]
151
- }),
152
- /* @__PURE__ */ y("div", {
153
- className: "space-y-3",
154
- children: e.items.map((n) => /* @__PURE__ */ y(E, {
155
- item: n,
156
- orderId: e.id,
157
- orderStatus: e.status,
158
- onOpenInstallModal: t,
159
- installing: r === n.id
160
- }, n.id))
161
- }),
162
- /* @__PURE__ */ b("div", {
163
- className: "mt-4 pt-4 border-t border-border-seam",
164
- children: [/* @__PURE__ */ b("div", {
165
- className: "flex justify-between text-sm",
166
- children: [/* @__PURE__ */ y("span", {
167
- className: "text-text-muted",
168
- children: "Subtotal"
169
- }), /* @__PURE__ */ y("span", {
170
- className: "tabular-nums text-text-primary",
171
- children: n(e.subtotal)
172
- })]
173
- }), /* @__PURE__ */ b("div", {
174
- className: "flex justify-between text-sm mt-1",
175
- children: [/* @__PURE__ */ y("span", {
176
- className: "text-text-muted",
177
- children: "Tax"
178
- }), /* @__PURE__ */ y("span", {
179
- className: "tabular-nums text-text-primary",
180
- children: n(e.tax)
181
- })]
182
- })]
183
- })
184
- ]
58
+ }, D = ({ status: e }) => {
59
+ let t = E(e), n = t.icon;
60
+ return /* @__PURE__ */ x("span", {
61
+ className: `inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold ${t.classes}`,
62
+ children: [/* @__PURE__ */ b(n, { className: "size-3.5" }), t.label]
185
63
  });
186
64
  }, O = () => {
187
- let n = x(), { basePath: u } = e(), { t: d } = c(), { orders: f, loading: h, error: v, refetchOrders: S, hasMore: T, loadMore: E } = a(), { installations: O, refetch: k } = i();
65
+ let p = ee(), { basePath: _ } = e(), { t: E } = l(), { orders: O, loading: k, error: A, refetchOrders: j, hasMore: M, loadMore: N } = a(), { installations: P, refetch: te } = i();
188
66
  t({
189
67
  onData: () => {
190
- S();
68
+ j();
191
69
  },
192
70
  onError: (e) => {
193
71
  console.warn("OrderStatusUpdated subscription error:", e.message);
194
72
  }
195
73
  });
196
- let [A, j] = s(!1), [M, N] = s(null), [P, F] = s(null), [I, L] = s(null), R = o(() => new Set(O.flatMap((e) => e.status === "ACTIVE" ? [e.productId] : [])), [O]), z = f.map((e) => {
74
+ let [ne, re] = c(/* @__PURE__ */ new Set()), [F, I] = c("completed"), [L, R] = c(!1), [z, B] = c(null), [V, H] = c(null), [ie, U] = c(null), W = s(() => new Set(P.flatMap((e) => e.status === "ACTIVE" ? [e.productId] : [])), [P]), G = O.map((e) => {
197
75
  let t = e.lineItems || [], n = t.reduce((e, t) => e + t.subtotal, 0), r = e.total - n, i = t.map((t, n) => ({
198
76
  id: `${e.id}-${n}`,
199
77
  productId: t.productId,
@@ -204,7 +82,7 @@ var T = (e) => {
204
82
  quantity: t.quantity,
205
83
  unitPrice: t.unitPrice,
206
84
  totalPrice: t.subtotal,
207
- installed: R.has(t.productId)
85
+ installed: W.has(t.productId)
208
86
  }));
209
87
  return {
210
88
  id: e.id,
@@ -214,134 +92,446 @@ var T = (e) => {
214
92
  tax: r,
215
93
  total: e.total,
216
94
  status: e.status,
217
- createdAt: e.createdAt
95
+ createdAt: e.createdAt,
96
+ fulfillment: e.fulfillment ?? null
218
97
  };
219
- }), B = (e, t) => {
220
- N(e), L(t.id), F({
98
+ }), K = s(() => G.filter((e) => T.includes(e.status)), [G]), q = s(() => G.filter((e) => !T.includes(e.status)), [G]), J = F === "completed" ? K : q, Y = o((e) => {
99
+ re((t) => {
100
+ let n = new Set(t);
101
+ return n.has(e) ? n.delete(e) : n.add(e), n;
102
+ });
103
+ }, []), ae = (e, t) => {
104
+ B(e), U(t.id), H({
221
105
  id: t.productId,
222
106
  name: t.productName,
223
107
  icon: t.productIcon,
224
108
  type: t.productType,
225
109
  version: t.version
226
- }), j(!0);
227
- }, V = () => {
228
- j(!1), N(null), F(null), L(null);
229
- }, H = (e, t) => {
230
- !M || !I || (console.log(`Successfully installed ${P?.name} to workspace ${t} (${e})`), V(), k());
231
- }, U = (e) => {
232
- console.error("Installation failed:", e.message);
233
- }, W = () => {
234
- n(`${u}/marketplace`);
235
- };
236
- return /* @__PURE__ */ b("div", {
237
- className: "h-full overflow-y-auto",
110
+ }), R(!0);
111
+ }, X = () => {
112
+ R(!1), B(null), H(null), U(null);
113
+ }, oe = (e, t) => {
114
+ X(), te();
115
+ }, se = (e) => {}, Z = () => {
116
+ p(`${_}/marketplace`);
117
+ }, Q = "px-4 py-3 text-sm", $ = "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-text-muted";
118
+ return /* @__PURE__ */ x("div", {
119
+ className: "flex h-full flex-col",
238
120
  children: [
239
- /* @__PURE__ */ y("header", {
240
- className: "sticky top-0 z-10 border-b border-border-seam bg-bg-surface px-6 py-4",
241
- children: /* @__PURE__ */ y("div", {
242
- className: "mx-auto max-w-4xl",
121
+ /* @__PURE__ */ b("header", {
122
+ className: "flex-shrink-0 border-b border-border-seam bg-bg-surface px-6 py-4",
123
+ children: /* @__PURE__ */ b("div", {
124
+ className: "mx-auto max-w-6xl",
243
125
  children: /* @__PURE__ */ b("div", {
244
- className: "flex items-center gap-4",
245
- children: [/* @__PURE__ */ y("button", {
246
- type: "button",
247
- onClick: () => n(-1),
248
- "aria-label": "Go back",
249
- className: "cursor-pointer rounded-lg p-2 text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary",
250
- children: /* @__PURE__ */ y(l, { className: "size-5" })
251
- }), /* @__PURE__ */ b("div", {
252
- className: "flex items-center gap-3",
253
- children: [
254
- /* @__PURE__ */ y(m, { className: "size-6 text-text-primary" }),
255
- /* @__PURE__ */ y("h1", {
256
- className: "text-xl font-bold text-text-primary",
257
- children: d("pages.orders.title", { defaultValue: "My Orders" })
258
- }),
259
- z.length > 0 && /* @__PURE__ */ y("span", {
260
- className: "rounded-full bg-action-primary-bg px-2.5 py-0.5 text-sm font-medium text-action-primary-text",
261
- children: z.length
262
- })
263
- ]
264
- })]
126
+ className: "flex items-center justify-between",
127
+ children: /* @__PURE__ */ x("div", {
128
+ className: "flex items-center gap-4",
129
+ children: [/* @__PURE__ */ b("button", {
130
+ type: "button",
131
+ onClick: () => p(-1),
132
+ "aria-label": "Go back",
133
+ className: "cursor-pointer rounded-lg p-2 text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary",
134
+ children: /* @__PURE__ */ b(u, { className: "size-5" })
135
+ }), /* @__PURE__ */ x("div", {
136
+ className: "flex items-center gap-3",
137
+ children: [
138
+ /* @__PURE__ */ b(g, { className: "size-6 text-text-primary" }),
139
+ /* @__PURE__ */ b("h1", {
140
+ className: "text-xl font-bold text-text-primary",
141
+ children: E("pages.orders.title", { defaultValue: "My Orders" })
142
+ }),
143
+ G.length > 0 && /* @__PURE__ */ b("span", {
144
+ className: "rounded-full bg-action-primary-bg/10 px-2.5 py-0.5 text-sm font-medium text-action-primary-bg",
145
+ children: G.length
146
+ })
147
+ ]
148
+ })]
149
+ })
265
150
  })
266
151
  })
267
152
  }),
268
- /* @__PURE__ */ b("main", {
269
- className: "mx-auto max-w-4xl p-6",
270
- children: [/* @__PURE__ */ y(w, {
271
- className: "mb-6",
272
- children: "A record of everything you've purchased from the marketplace. Track each order's status, review what you paid, and — once an order is complete — install the apps you bought into a workspace right from here. Come back to re-install on a new workspace or check a past receipt."
273
- }), h ? /* @__PURE__ */ b("output", {
274
- "aria-label": "Loading orders",
275
- className: "flex flex-col items-center justify-center py-16",
276
- children: [/* @__PURE__ */ y(p, {
277
- className: "size-12 animate-spin text-text-muted mb-4",
278
- "aria-hidden": "true"
279
- }), /* @__PURE__ */ y("p", {
280
- className: "text-text-muted",
281
- children: "Loading your orders…"
282
- })]
283
- }) : v ? /* @__PURE__ */ b("div", {
284
- role: "alert",
285
- className: "flex flex-col items-center justify-center py-16 text-center",
286
- children: [
287
- /* @__PURE__ */ y("div", {
288
- className: "mb-6 rounded-full bg-status-error-bg-subtle/10 p-6",
289
- children: /* @__PURE__ */ y(_, { className: "size-16 text-status-error-text" })
290
- }),
291
- /* @__PURE__ */ y("h2", {
292
- className: "mb-2 text-2xl font-bold text-text-primary",
293
- children: d("pages.orders.failedToLoad", { defaultValue: "Failed to load orders" })
294
- }),
295
- /* @__PURE__ */ y("p", {
296
- className: "mb-6 max-w-md text-text-muted",
297
- children: v.message || "An error occurred while loading your orders. Please try again."
298
- }),
299
- /* @__PURE__ */ b("button", {
153
+ /* @__PURE__ */ b("div", {
154
+ className: "flex-1 overflow-y-auto",
155
+ children: /* @__PURE__ */ x("div", {
156
+ className: "mx-auto max-w-6xl p-6",
157
+ children: [/* @__PURE__ */ b(w, {
158
+ className: "mb-6",
159
+ children: "A record of everything you've purchased from the marketplace. Track each order's status, review what you paid, and — once an order is complete — install the apps you bought into a workspace right from here. Come back to re-install on a new workspace or check a past receipt."
160
+ }), k && G.length === 0 ? /* @__PURE__ */ x("div", {
161
+ className: "flex flex-col items-center justify-center py-24",
162
+ children: [/* @__PURE__ */ b(h, {
163
+ className: "size-12 animate-spin text-text-muted mb-4",
164
+ "aria-hidden": "true"
165
+ }), /* @__PURE__ */ b("p", {
166
+ className: "text-text-muted",
167
+ children: "Loading your orders…"
168
+ })]
169
+ }) : A ? /* @__PURE__ */ x("div", {
170
+ className: "flex flex-col items-center justify-center py-24 text-center",
171
+ children: [
172
+ /* @__PURE__ */ b("div", {
173
+ className: "mb-6 rounded-full bg-status-error-bg-subtle/10 p-6",
174
+ children: /* @__PURE__ */ b(y, { className: "size-16 text-status-error-text" })
175
+ }),
176
+ /* @__PURE__ */ b("h2", {
177
+ className: "mb-2 text-2xl font-bold text-text-primary",
178
+ children: E("pages.orders.failedToLoad", { defaultValue: "Failed to load orders" })
179
+ }),
180
+ /* @__PURE__ */ b("p", {
181
+ className: "mb-6 max-w-md text-text-muted",
182
+ children: A.message || "An error occurred while loading your orders. Please try again."
183
+ }),
184
+ /* @__PURE__ */ x("button", {
185
+ type: "button",
186
+ onClick: Z,
187
+ className: "cursor-pointer flex items-center gap-2 rounded-lg bg-action-primary-bg px-6 py-3 font-semibold text-action-primary-text transition-opacity hover:opacity-90",
188
+ children: [/* @__PURE__ */ b(v, { className: "size-5" }), "Browse Marketplace"]
189
+ })
190
+ ]
191
+ }) : G.length === 0 ? /* @__PURE__ */ b(C, {
192
+ illustration: "empty-data",
193
+ title: E("pages.orders.emptyTitle", { defaultValue: "No orders yet" }),
194
+ description: "You have not placed any orders yet. Browse the marketplace to discover apps and products!",
195
+ action: /* @__PURE__ */ x("button", {
300
196
  type: "button",
301
- onClick: W,
197
+ onClick: Z,
302
198
  className: "cursor-pointer flex items-center gap-2 rounded-lg bg-action-primary-bg px-6 py-3 font-semibold text-action-primary-text transition-opacity hover:opacity-90",
303
- children: [/* @__PURE__ */ y(g, { className: "size-5" }), "Browse Marketplace"]
304
- })
305
- ]
306
- }) : z.length === 0 ? /* @__PURE__ */ y(C, {
307
- illustration: "empty-data",
308
- title: d("pages.orders.emptyTitle", { defaultValue: "No orders yet" }),
309
- description: "You have not placed any orders yet. Browse the marketplace to discover apps and products!",
310
- action: /* @__PURE__ */ b("button", {
311
- type: "button",
312
- onClick: W,
313
- className: "cursor-pointer flex items-center gap-2 rounded-lg bg-action-primary-bg px-6 py-3 font-semibold text-action-primary-text transition-opacity hover:opacity-90",
314
- children: [/* @__PURE__ */ y(g, { className: "size-5" }), "Browse Marketplace"]
315
- })
316
- }) : /* @__PURE__ */ b("ul", {
317
- className: "space-y-6",
318
- children: [z.map((e) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y(D, {
319
- order: e,
320
- onOpenInstallModal: B,
321
- installingItem: A ? I : null
322
- }) }, e.id)), T && /* @__PURE__ */ y("li", {
323
- className: "flex justify-center pt-4 list-none",
324
- children: /* @__PURE__ */ b("button", {
325
- type: "button",
326
- onClick: E,
327
- disabled: h,
328
- className: "flex items-center gap-2 rounded-lg border border-border-default px-6 py-2.5 text-sm font-medium text-text-primary hover:bg-bg-subtle disabled:opacity-50",
329
- "aria-label": d("common.loadMore", { defaultValue: "Load more" }),
330
- children: [h ? /* @__PURE__ */ y(p, {
331
- className: "size-4 animate-spin",
332
- "aria-hidden": "true"
333
- }) : null, d("common.loadMore", { defaultValue: "Load more" })]
199
+ children: [/* @__PURE__ */ b(v, { className: "size-5" }), "Browse Marketplace"]
334
200
  })
201
+ }) : /* @__PURE__ */ x("div", {
202
+ className: "space-y-4",
203
+ children: [/* @__PURE__ */ x("div", {
204
+ className: "inline-flex rounded-xl border border-border-seam bg-bg-surface p-1",
205
+ children: [/* @__PURE__ */ x("button", {
206
+ type: "button",
207
+ onClick: () => I("completed"),
208
+ className: `rounded-lg px-4 py-2 text-sm font-medium transition-colors ${F === "completed" ? "bg-action-primary-bg text-action-primary-text" : "text-text-muted hover:bg-bg-sunken hover:text-text-primary"}`,
209
+ children: ["Completed", /* @__PURE__ */ b("span", {
210
+ className: "ml-2 rounded-full bg-black/10 px-2 py-0.5 text-xs",
211
+ children: K.length
212
+ })]
213
+ }), /* @__PURE__ */ x("button", {
214
+ type: "button",
215
+ onClick: () => I("pending"),
216
+ className: `rounded-lg px-4 py-2 text-sm font-medium transition-colors ${F === "pending" ? "bg-action-primary-bg text-action-primary-text" : "text-text-muted hover:bg-bg-sunken hover:text-text-primary"}`,
217
+ children: ["Pending", /* @__PURE__ */ b("span", {
218
+ className: "ml-2 rounded-full bg-black/10 px-2 py-0.5 text-xs",
219
+ children: q.length
220
+ })]
221
+ })]
222
+ }), J.length === 0 ? /* @__PURE__ */ x(S, {
223
+ className: "p-10 text-center",
224
+ children: [
225
+ /* @__PURE__ */ b("div", {
226
+ className: "mx-auto mb-4 flex size-14 items-center justify-center rounded-full bg-bg-sunken text-text-muted",
227
+ children: /* @__PURE__ */ b(g, { className: "size-6" })
228
+ }),
229
+ /* @__PURE__ */ b("h2", {
230
+ className: "mb-2 text-lg font-semibold text-text-primary",
231
+ children: F === "completed" ? "No completed orders yet" : "No pending orders"
232
+ }),
233
+ /* @__PURE__ */ b("p", {
234
+ className: "text-sm text-text-muted",
235
+ children: F === "completed" ? "Completed purchases will appear here once payment is successful." : "Orders that are pending, processing, failed, refunded, or cancelled will appear here."
236
+ })
237
+ ]
238
+ }) : /* @__PURE__ */ x("div", {
239
+ className: "overflow-hidden rounded-xl border border-border-seam bg-bg-surface",
240
+ children: [
241
+ /* @__PURE__ */ x("div", {
242
+ className: "hidden border-b border-border-seam bg-bg-sunken/50 md:grid md:grid-cols-[40px_1fr_180px_140px_120px_160px]",
243
+ children: [
244
+ /* @__PURE__ */ b("div", { className: $ }),
245
+ /* @__PURE__ */ b("div", {
246
+ className: $,
247
+ children: "Order"
248
+ }),
249
+ /* @__PURE__ */ b("div", {
250
+ className: $,
251
+ children: "Date"
252
+ }),
253
+ /* @__PURE__ */ b("div", {
254
+ className: $,
255
+ children: "Items"
256
+ }),
257
+ /* @__PURE__ */ b("div", {
258
+ className: `${$} text-right`,
259
+ children: "Total"
260
+ }),
261
+ /* @__PURE__ */ b("div", {
262
+ className: `${$} text-center`,
263
+ children: "Status"
264
+ })
265
+ ]
266
+ }),
267
+ J.map((e) => {
268
+ let t = ne.has(e.id), r = e.status === "COMPLETED" || e.status === "FULFILLED" || e.status === "PROCESSED";
269
+ return /* @__PURE__ */ x("div", {
270
+ className: "border-b border-border-seam last:border-b-0",
271
+ children: [/* @__PURE__ */ x("button", {
272
+ type: "button",
273
+ onClick: () => Y(e.id),
274
+ className: "grid w-full cursor-pointer grid-cols-[40px_1fr_180px_140px_120px_160px] items-center transition-colors hover:bg-bg-sunken/50 md:grid",
275
+ children: [
276
+ /* @__PURE__ */ b("div", {
277
+ className: `${Q} flex justify-center`,
278
+ children: /* @__PURE__ */ b(f, { className: `size-4 text-text-muted transition-transform duration-200 ${t ? "rotate-90" : ""}` })
279
+ }),
280
+ /* @__PURE__ */ b("div", {
281
+ className: `${Q} font-medium text-text-primary`,
282
+ children: e.orderNumber
283
+ }),
284
+ /* @__PURE__ */ b("div", {
285
+ className: `${Q} text-text-muted`,
286
+ children: new Date(e.createdAt).toLocaleDateString("en-US", {
287
+ year: "numeric",
288
+ month: "short",
289
+ day: "numeric"
290
+ })
291
+ }),
292
+ /* @__PURE__ */ x("div", {
293
+ className: `${Q} text-text-muted`,
294
+ children: [
295
+ e.items.length,
296
+ " ",
297
+ e.items.length === 1 ? "item" : "items",
298
+ /* @__PURE__ */ b("span", {
299
+ className: "block text-xs text-text-muted/70",
300
+ children: e.items.map((e) => e.productName).join(", ")
301
+ })
302
+ ]
303
+ }),
304
+ /* @__PURE__ */ b("div", {
305
+ className: `${Q} text-right font-semibold tabular-nums text-text-primary`,
306
+ children: n(e.total)
307
+ }),
308
+ /* @__PURE__ */ b("div", {
309
+ className: `${Q} flex justify-center`,
310
+ children: /* @__PURE__ */ b(D, { status: e.status })
311
+ })
312
+ ]
313
+ }), t && /* @__PURE__ */ x("div", {
314
+ className: "border-t border-border-seam bg-bg-sunken/30",
315
+ children: [
316
+ e.fulfillment && /* @__PURE__ */ x("div", {
317
+ className: "mx-4 mt-4 rounded-xl border border-border-seam bg-bg-surface px-4 py-4 md:mx-12",
318
+ children: [/* @__PURE__ */ x("div", {
319
+ className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between",
320
+ children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("div", {
321
+ className: "text-sm font-semibold text-text-primary",
322
+ children: "Order tracking"
323
+ }), /* @__PURE__ */ x("div", {
324
+ className: "mt-1 text-xs text-text-muted",
325
+ children: [
326
+ e.fulfillment.status || "PENDING",
327
+ e.fulfillment.carrier ? ` · ${e.fulfillment.carrier}` : "",
328
+ e.fulfillment.estimatedDeliveryDate ? ` · Est. delivery ${new Date(e.fulfillment.estimatedDeliveryDate).toLocaleDateString()}` : ""
329
+ ]
330
+ })] }), /* @__PURE__ */ x("div", {
331
+ className: "flex flex-col items-start gap-2 md:items-end",
332
+ children: [e.fulfillment.trackingNumber && /* @__PURE__ */ x("div", {
333
+ className: "text-xs text-text-muted",
334
+ children: ["Tracking #: ", /* @__PURE__ */ b("span", {
335
+ className: "font-medium text-text-primary",
336
+ children: e.fulfillment.trackingNumber
337
+ })]
338
+ }), e.fulfillment.trackingUrl && /* @__PURE__ */ x("a", {
339
+ href: e.fulfillment.trackingUrl,
340
+ target: "_blank",
341
+ rel: "noreferrer",
342
+ className: "inline-flex items-center gap-1 rounded-md border border-border-default px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken",
343
+ children: ["Track package", /* @__PURE__ */ b(f, { className: "size-3.5" })]
344
+ })]
345
+ })]
346
+ }), /* @__PURE__ */ b("div", {
347
+ className: "mt-4 grid gap-2 sm:grid-cols-4",
348
+ children: [
349
+ {
350
+ key: "PROCESSING",
351
+ label: "Processing"
352
+ },
353
+ {
354
+ key: "SHIPPED",
355
+ label: "Shipped"
356
+ },
357
+ {
358
+ key: "OUT_FOR_DELIVERY",
359
+ label: "Out for delivery"
360
+ },
361
+ {
362
+ key: "DELIVERED",
363
+ label: "Delivered"
364
+ }
365
+ ].map((t) => {
366
+ let n = e.fulfillment?.status || "PENDING";
367
+ return /* @__PURE__ */ b("div", {
368
+ className: `rounded-lg border px-3 py-2 text-xs font-medium ${[
369
+ "PROCESSING",
370
+ "READY_TO_SHIP",
371
+ "SHIPPED",
372
+ "IN_TRANSIT",
373
+ "OUT_FOR_DELIVERY",
374
+ "DELIVERED"
375
+ ].indexOf(n) >= [
376
+ "PROCESSING",
377
+ "SHIPPED",
378
+ "OUT_FOR_DELIVERY",
379
+ "DELIVERED"
380
+ ].indexOf(t.key) ? "border-status-success-border bg-status-success-bg-subtle text-status-success-text" : "border-border-seam bg-bg-sunken/40 text-text-muted"}`,
381
+ children: t.label
382
+ }, t.key);
383
+ })
384
+ })]
385
+ }),
386
+ /* @__PURE__ */ x("div", {
387
+ className: "hidden grid-cols-[1fr_100px_120px_160px] gap-4 px-12 py-2 md:grid",
388
+ children: [
389
+ /* @__PURE__ */ b("span", {
390
+ className: "text-xs font-medium text-text-muted",
391
+ children: "Product"
392
+ }),
393
+ /* @__PURE__ */ b("span", {
394
+ className: "text-xs font-medium text-text-muted text-right",
395
+ children: "Qty"
396
+ }),
397
+ /* @__PURE__ */ b("span", {
398
+ className: "text-xs font-medium text-text-muted text-right",
399
+ children: "Price"
400
+ }),
401
+ /* @__PURE__ */ b("span", {
402
+ className: "text-xs font-medium text-text-muted text-center",
403
+ children: "Action"
404
+ })
405
+ ]
406
+ }),
407
+ e.items.map((t) => {
408
+ let i = t.productType !== "PHYSICAL" && t.productType !== "MERCHANDISE";
409
+ return /* @__PURE__ */ x("div", {
410
+ className: "grid grid-cols-[auto_1fr_auto] items-center gap-3 px-4 py-3 md:px-12 md:grid-cols-[1fr_100px_120px_160px]",
411
+ children: [
412
+ /* @__PURE__ */ x("div", {
413
+ className: "flex items-center gap-3 min-w-0",
414
+ children: [/* @__PURE__ */ b("div", {
415
+ className: "size-10 flex-shrink-0 overflow-hidden rounded-lg bg-bg-sunken",
416
+ children: t.productIcon ? /* @__PURE__ */ b("img", {
417
+ src: t.productIcon,
418
+ alt: t.productName,
419
+ className: "size-full object-cover"
420
+ }) : /* @__PURE__ */ b("div", {
421
+ className: "flex size-full items-center justify-center text-sm font-bold text-text-muted",
422
+ children: t.productName.charAt(0)
423
+ })
424
+ }), /* @__PURE__ */ x("div", {
425
+ className: "min-w-0",
426
+ children: [/* @__PURE__ */ b("p", {
427
+ className: "truncate text-sm font-medium text-text-primary",
428
+ children: t.productName
429
+ }), /* @__PURE__ */ b("span", {
430
+ className: "inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-muted",
431
+ children: t.productType
432
+ })]
433
+ })]
434
+ }),
435
+ /* @__PURE__ */ b("div", {
436
+ className: "hidden text-right text-sm text-text-muted md:block",
437
+ children: t.quantity
438
+ }),
439
+ /* @__PURE__ */ b("div", {
440
+ className: "hidden text-right text-sm font-semibold tabular-nums text-text-primary md:block",
441
+ children: n(t.totalPrice)
442
+ }),
443
+ /* @__PURE__ */ x("div", {
444
+ className: "text-right text-sm text-text-muted md:hidden",
445
+ children: [/* @__PURE__ */ x("span", {
446
+ className: "tabular-nums",
447
+ children: [t.quantity, " × "]
448
+ }), /* @__PURE__ */ b("span", {
449
+ className: "font-semibold text-text-primary tabular-nums",
450
+ children: n(t.unitPrice)
451
+ })]
452
+ }),
453
+ /* @__PURE__ */ b("div", {
454
+ className: "flex justify-end md:justify-center",
455
+ children: t.installed ? /* @__PURE__ */ x("span", {
456
+ className: "inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs font-medium text-status-success-text",
457
+ children: [/* @__PURE__ */ b(d, { className: "size-3.5" }), "Installed"]
458
+ }) : r && i ? /* @__PURE__ */ x("button", {
459
+ type: "button",
460
+ onClick: (n) => {
461
+ n.stopPropagation(), ae(e.id, t);
462
+ },
463
+ className: "inline-flex cursor-pointer items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text transition-all hover:opacity-90 active:scale-95",
464
+ children: [/* @__PURE__ */ b(m, { className: "size-3.5" }), "Install App"]
465
+ }) : null
466
+ })
467
+ ]
468
+ }, t.id);
469
+ }),
470
+ /* @__PURE__ */ b("div", {
471
+ className: "border-t border-border-seam/50 px-4 py-2 md:px-12",
472
+ children: /* @__PURE__ */ x("div", {
473
+ className: "flex justify-end gap-6 text-xs text-text-muted",
474
+ children: [
475
+ /* @__PURE__ */ x("span", { children: [
476
+ "Subtotal:",
477
+ " ",
478
+ /* @__PURE__ */ b("span", {
479
+ className: "tabular-nums text-text-primary",
480
+ children: n(e.subtotal)
481
+ })
482
+ ] }),
483
+ /* @__PURE__ */ x("span", { children: [
484
+ "Tax:",
485
+ " ",
486
+ /* @__PURE__ */ b("span", {
487
+ className: "tabular-nums text-text-primary",
488
+ children: n(e.tax)
489
+ })
490
+ ] }),
491
+ /* @__PURE__ */ x("span", {
492
+ className: "font-semibold",
493
+ children: [
494
+ "Total:",
495
+ " ",
496
+ /* @__PURE__ */ b("span", {
497
+ className: "tabular-nums text-text-primary",
498
+ children: n(e.total)
499
+ })
500
+ ]
501
+ })
502
+ ]
503
+ })
504
+ })
505
+ ]
506
+ })]
507
+ }, e.id);
508
+ }),
509
+ M && /* @__PURE__ */ b("div", {
510
+ className: "flex justify-center px-4 py-5",
511
+ children: /* @__PURE__ */ x("button", {
512
+ type: "button",
513
+ onClick: N,
514
+ disabled: k,
515
+ className: "flex items-center gap-2 rounded-lg border border-border-default px-6 py-2.5 text-sm font-medium text-text-primary transition-colors hover:bg-bg-subtle disabled:opacity-50",
516
+ "aria-label": E("common.loadMore", { defaultValue: "Load more" }),
517
+ children: [k ? /* @__PURE__ */ b(h, {
518
+ className: "size-4 animate-spin",
519
+ "aria-hidden": "true"
520
+ }) : null, E("common.loadMore", { defaultValue: "Load more" })]
521
+ })
522
+ })
523
+ ]
524
+ })]
335
525
  })]
336
- })]
526
+ })
337
527
  }),
338
- P && /* @__PURE__ */ y(r, {
339
- isOpen: A,
340
- onClose: V,
341
- app: P,
342
- orderId: M,
343
- onInstallSuccess: H,
344
- onInstallError: U
528
+ V && /* @__PURE__ */ b(r, {
529
+ isOpen: L,
530
+ onClose: X,
531
+ app: V,
532
+ orderId: z,
533
+ onInstallSuccess: oe,
534
+ onInstallError: se
345
535
  })
346
536
  ]
347
537
  });