@fluid-app/portal-sdk 0.1.28 → 0.1.30

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.
Files changed (87) hide show
  1. package/dist/{AppNavigationContext-DrayF_RG.cjs → AppNavigationContext-DAcrNgXZ.cjs} +1 -1
  2. package/dist/{AppNavigationContext-DrayF_RG.cjs.map → AppNavigationContext-DAcrNgXZ.cjs.map} +1 -1
  3. package/dist/{AppNavigationContext-2nkMoO8F.mjs → AppNavigationContext-v_y8OYHo.mjs} +1 -1
  4. package/dist/{AppNavigationContext-2nkMoO8F.mjs.map → AppNavigationContext-v_y8OYHo.mjs.map} +1 -1
  5. package/dist/{ContactsScreen-GPOgZ-Wi.cjs → ContactsScreen-BL5Jlaz5.cjs} +2 -2
  6. package/dist/{ContactsScreen-GPOgZ-Wi.cjs.map → ContactsScreen-BL5Jlaz5.cjs.map} +1 -1
  7. package/dist/{ContactsScreen-BicHZ37M.mjs → ContactsScreen-CcNUC8xu.mjs} +2 -2
  8. package/dist/{ContactsScreen-BicHZ37M.mjs.map → ContactsScreen-CcNUC8xu.mjs.map} +1 -1
  9. package/dist/{CoreScreenPlaceholder-Cl_zuOBC.cjs → CoreScreenPlaceholder-B64M78iR.cjs} +1 -1
  10. package/dist/{CoreScreenPlaceholder-Cl_zuOBC.cjs.map → CoreScreenPlaceholder-B64M78iR.cjs.map} +1 -1
  11. package/dist/{CoreScreenPlaceholder-Cdyl97Wo.mjs → CoreScreenPlaceholder-DVVLc-OM.mjs} +1 -1
  12. package/dist/{CoreScreenPlaceholder-Cdyl97Wo.mjs.map → CoreScreenPlaceholder-DVVLc-OM.mjs.map} +1 -1
  13. package/dist/{CustomersScreen-Brz5zLkq.mjs → CustomersScreen-SuHGSUdb.mjs} +2 -2
  14. package/dist/{CustomersScreen-Brz5zLkq.mjs.map → CustomersScreen-SuHGSUdb.mjs.map} +1 -1
  15. package/dist/{CustomersScreen-CK1jJhvM.cjs → CustomersScreen-zl_vRzcJ.cjs} +2 -2
  16. package/dist/{CustomersScreen-CK1jJhvM.cjs.map → CustomersScreen-zl_vRzcJ.cjs.map} +1 -1
  17. package/dist/{MessagingScreen-DVU3c8fX.mjs → MessagingScreen-BGzfLD8k.mjs} +2 -2
  18. package/dist/{MessagingScreen-sAWF7pjl.cjs → MessagingScreen-CRLd91tP.cjs} +2 -2
  19. package/dist/{MessagingScreen-sAWF7pjl.cjs.map → MessagingScreen-CRLd91tP.cjs.map} +1 -1
  20. package/dist/{MessagingScreen-C33eDdna.cjs → MessagingScreen-DIZ72Tg0.cjs} +2 -2
  21. package/dist/{MessagingScreen-II_iNqLk.mjs → MessagingScreen-We1B2pka.mjs} +2 -2
  22. package/dist/{MessagingScreen-II_iNqLk.mjs.map → MessagingScreen-We1B2pka.mjs.map} +1 -1
  23. package/dist/OrdersScreen-Bu-ENmH6.cjs +133 -0
  24. package/dist/OrdersScreen-Bu-ENmH6.cjs.map +1 -0
  25. package/dist/OrdersScreen-TSXDDHZe.cjs +33 -0
  26. package/dist/OrdersScreen-afRAHf07.mjs +126 -0
  27. package/dist/OrdersScreen-afRAHf07.mjs.map +1 -0
  28. package/dist/{ProductsScreen-DrrBYFl0.mjs → ProductsScreen-B-oWUzvD.mjs} +3 -3
  29. package/dist/{ProductsScreen-BOngRxSO.mjs → ProductsScreen-ChvK61hX.mjs} +3 -3
  30. package/dist/{ProductsScreen-BOngRxSO.mjs.map → ProductsScreen-ChvK61hX.mjs.map} +1 -1
  31. package/dist/{ProductsScreen-DzD-TPh5.cjs → ProductsScreen-CkE2nyuw.cjs} +3 -3
  32. package/dist/{ProductsScreen-DzD-TPh5.cjs.map → ProductsScreen-CkE2nyuw.cjs.map} +1 -1
  33. package/dist/{ProductsScreen-CdP_m_Ok.cjs → ProductsScreen-PCg91SbX.cjs} +3 -3
  34. package/dist/ProfileScreen-B6Dp7RLa.cjs +2856 -0
  35. package/dist/ProfileScreen-B6Dp7RLa.cjs.map +1 -0
  36. package/dist/ProfileScreen-B83tzedh.mjs +2849 -0
  37. package/dist/ProfileScreen-B83tzedh.mjs.map +1 -0
  38. package/dist/{AccountScreen-Vzz8W4Iq.cjs → ProfileScreen-CH3B-IQz.cjs} +3 -3
  39. package/dist/{ShareablesScreen-DYPJgZ3z.cjs → ShareablesScreen-Bqj6dtOM.cjs} +3 -3
  40. package/dist/{ShareablesScreen-DYPJgZ3z.cjs.map → ShareablesScreen-Bqj6dtOM.cjs.map} +1 -1
  41. package/dist/{ShareablesScreen-jHqLmOC6.cjs → ShareablesScreen-BvJIBZvI.cjs} +3 -3
  42. package/dist/{ShareablesScreen-CQy39TAK.mjs → ShareablesScreen-ChS517hq.mjs} +3 -3
  43. package/dist/{ShareablesScreen-CQy39TAK.mjs.map → ShareablesScreen-ChS517hq.mjs.map} +1 -1
  44. package/dist/{ShareablesScreen-BsqZvRSK.mjs → ShareablesScreen-CqVj81Ol.mjs} +3 -3
  45. package/dist/{ShopScreen-BPCwix1m.cjs → ShopScreen-CjoTGnCJ.cjs} +2 -2
  46. package/dist/{ShopScreen-BPCwix1m.cjs.map → ShopScreen-CjoTGnCJ.cjs.map} +1 -1
  47. package/dist/{ShopScreen--pUsiUNt.cjs → ShopScreen-DS4p47Ry.cjs} +1 -1
  48. package/dist/{ShopScreen-BKBzgkr7.mjs → ShopScreen-KeU6x3PT.mjs} +2 -2
  49. package/dist/{ShopScreen-BKBzgkr7.mjs.map → ShopScreen-KeU6x3PT.mjs.map} +1 -1
  50. package/dist/SubscriptionsScreen-CHn_Q0zf.cjs +1288 -0
  51. package/dist/SubscriptionsScreen-CHn_Q0zf.cjs.map +1 -0
  52. package/dist/SubscriptionsScreen-D5_eJwBP.mjs +1281 -0
  53. package/dist/SubscriptionsScreen-D5_eJwBP.mjs.map +1 -0
  54. package/dist/SubscriptionsScreen-DGJ_YeX3.cjs +33 -0
  55. package/dist/{es-kNOrmozy.cjs → es-BtechuHV.cjs} +1 -1
  56. package/dist/{es-kNOrmozy.cjs.map → es-BtechuHV.cjs.map} +1 -1
  57. package/dist/{es-BL8VBBDa.mjs → es-DxWiENwN.mjs} +1 -1
  58. package/dist/{es-BL8VBBDa.mjs.map → es-DxWiENwN.mjs.map} +1 -1
  59. package/dist/index.cjs +166 -94
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +38 -8
  62. package/dist/index.d.cts.map +1 -1
  63. package/dist/index.d.mts +38 -8
  64. package/dist/index.d.mts.map +1 -1
  65. package/dist/index.mjs +162 -92
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/src-BZEkCfd4.mjs +973 -0
  68. package/dist/src-BZEkCfd4.mjs.map +1 -0
  69. package/dist/src-DXC-Jw6i.cjs +1009 -0
  70. package/dist/src-DXC-Jw6i.cjs.map +1 -0
  71. package/dist/{src-DMjlIMO9.cjs → src-vxm9rMYT.cjs} +2 -2
  72. package/dist/{src-DMjlIMO9.cjs.map → src-vxm9rMYT.cjs.map} +1 -1
  73. package/dist/{src-9pW9wS5O.mjs → src-wpQFW94i.mjs} +2 -2
  74. package/dist/{src-9pW9wS5O.mjs.map → src-wpQFW94i.mjs.map} +1 -1
  75. package/dist/use-account-clients-DYTyFvdN.mjs +134 -0
  76. package/dist/use-account-clients-DYTyFvdN.mjs.map +1 -0
  77. package/dist/use-account-clients-n2a8bdSP.cjs +182 -0
  78. package/dist/use-account-clients-n2a8bdSP.cjs.map +1 -0
  79. package/package.json +10 -10
  80. package/dist/AccountScreen-Dp6QFyEr.cjs +0 -5322
  81. package/dist/AccountScreen-Dp6QFyEr.cjs.map +0 -1
  82. package/dist/AccountScreen-E4ZBgOUS.mjs +0 -5309
  83. package/dist/AccountScreen-E4ZBgOUS.mjs.map +0 -1
  84. package/dist/OrdersScreen-DGt-CTBS.mjs +0 -24
  85. package/dist/OrdersScreen-DGt-CTBS.mjs.map +0 -1
  86. package/dist/OrdersScreen-Dy-JChVQ.cjs +0 -41
  87. package/dist/OrdersScreen-Dy-JChVQ.cjs.map +0 -1
@@ -0,0 +1,973 @@
1
+ import { it as CardTitle, nt as CardContent, qt as cn, rt as CardHeader, tt as Card, u as Skeleton, y as Input } from "./src-PSNQSAUF.mjs";
2
+ import { c as useFluidAuth, n as useFluidPayClient, o as fetchCustomerAccount } from "./use-account-clients-DYTyFvdN.mjs";
3
+ import { createContext, useCallback, useContext, useEffect, useState } from "react";
4
+ import { useQuery } from "@tanstack/react-query";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+ import { ChevronLeft, ChevronRight, Search, Truck } from "lucide-react";
7
+ //#region ../../orders/api-client/src/namespaces/orders.ts
8
+ /**
9
+ * Fetch a single order by token.
10
+ * Endpoint: GET /public/v2025-06/orders/{orderToken}
11
+ */
12
+ async function fetchOrder(client, orderToken) {
13
+ return client.get(`/public/v2025-06/orders/${orderToken}`);
14
+ }
15
+ /**
16
+ * Fetch a paginated list of customer orders.
17
+ * Endpoint: GET /v202506/orders
18
+ */
19
+ async function fetchCustomerOrders(client, params) {
20
+ const input = {};
21
+ if (params.cursor) input["page[cursor]"] = params.cursor;
22
+ if (params.limit != null) input["page[limit]"] = params.limit.toString();
23
+ if (params.search) input.search = params.search;
24
+ if (params.sort) input.sort = params.sort;
25
+ if (params.status) input.status = params.status;
26
+ if (params.type) input.type = params.type;
27
+ if (params.customerId != null) input.customer_id = params.customerId.toString();
28
+ if (params.userCompanyId != null) input.user_company_id = params.userCompanyId.toString();
29
+ if (params.subscriptionId != null) input.subscription_id = params.subscriptionId.toString();
30
+ if (params.startDate) input.start_date = params.startDate;
31
+ if (params.endDate) input.end_date = params.endDate;
32
+ if (params.withinDays != null) input.within_days = params.withinDays.toString();
33
+ if (params.cartSource) input.cart_source = params.cartSource;
34
+ if (params.countryIsos) input.country_isos = params.countryIsos;
35
+ if (params.forceStats != null) input.force_stats = params.forceStats.toString();
36
+ return client.get("/v202506/orders", input);
37
+ }
38
+ //#endregion
39
+ //#region src/account/use-customer-account.ts
40
+ function useCustomerAccount({ enabled = true } = {}) {
41
+ const { token, user } = useFluidAuth();
42
+ const fluidPayClient = useFluidPayClient();
43
+ const jwt = token ?? "";
44
+ const query = useQuery({
45
+ queryKey: ["fluidPayAccount", user?.id],
46
+ queryFn: () => fetchCustomerAccount(fluidPayClient, jwt),
47
+ enabled: !!jwt && enabled
48
+ });
49
+ return {
50
+ customerId: query.data?.customer?.id,
51
+ isLoadingCustomer: query.isLoading,
52
+ isCustomerError: query.isError
53
+ };
54
+ }
55
+ //#endregion
56
+ //#region ../../orders/core/src/context.ts
57
+ const OrdersClientContext = createContext(null);
58
+ const OrdersClientProvider = OrdersClientContext.Provider;
59
+ function useOrdersClient() {
60
+ const client = useContext(OrdersClientContext);
61
+ if (!client) throw new Error("useOrdersClient must be used within an OrdersCoreProvider");
62
+ return client;
63
+ }
64
+ //#endregion
65
+ //#region ../../orders/core/src/provider.tsx
66
+ function OrdersCoreProvider({ client, children }) {
67
+ return /* @__PURE__ */ jsx(OrdersClientProvider, {
68
+ value: client,
69
+ children
70
+ });
71
+ }
72
+ //#endregion
73
+ //#region ../../orders/core/src/query-keys.ts
74
+ const ordersKeys = {
75
+ all: ["orders"],
76
+ list: (params) => [
77
+ ...ordersKeys.all,
78
+ "list",
79
+ params
80
+ ],
81
+ detail: (orderToken) => [
82
+ ...ordersKeys.all,
83
+ "detail",
84
+ orderToken
85
+ ]
86
+ };
87
+ //#endregion
88
+ //#region ../../orders/core/src/hooks/use-order.ts
89
+ function useOrder(orderToken, options) {
90
+ const client = useOrdersClient();
91
+ return useQuery({
92
+ queryKey: ordersKeys.detail(orderToken),
93
+ queryFn: () => fetchOrder(client, orderToken),
94
+ enabled: (options?.enabled ?? true) && !!orderToken
95
+ });
96
+ }
97
+ //#endregion
98
+ //#region ../../orders/core/src/hooks/use-customer-orders.ts
99
+ function useCustomerOrders(params, options) {
100
+ const client = useOrdersClient();
101
+ return useQuery({
102
+ queryKey: ordersKeys.list(params),
103
+ queryFn: () => fetchCustomerOrders(client, params),
104
+ enabled: options?.enabled ?? true
105
+ });
106
+ }
107
+ //#endregion
108
+ //#region ../../orders/core/src/utils/format-order-total.ts
109
+ function formatOrderTotal(order) {
110
+ if (order.order_total_after_points_redemption != null) return `${order.currency_symbol || "$"}${Number(order.order_total_after_points_redemption).toFixed(2)}`;
111
+ return order.total_display_amount || `${order.currency_symbol || "$"}${Number(order.amount).toFixed(2)}`;
112
+ }
113
+ //#endregion
114
+ //#region ../../orders/ui/src/components/search-input.tsx
115
+ function SearchInput({ searchTerm, onSearchChange, placeholder }) {
116
+ return /* @__PURE__ */ jsxs("div", {
117
+ className: "relative",
118
+ children: [/* @__PURE__ */ jsx(Search, { className: "text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2" }), /* @__PURE__ */ jsx(Input, {
119
+ value: searchTerm,
120
+ onChange: (e) => onSearchChange(e.target.value),
121
+ placeholder,
122
+ className: "pl-9"
123
+ })]
124
+ });
125
+ }
126
+ //#endregion
127
+ //#region ../../orders/ui/src/components/pagination-footer.tsx
128
+ function PaginationFooter({ currentPage, totalPages, pageSize, totalItems, onPageChange, cursorPaginationMode, hasNextPage, hasPrevPage, onCursorNext, onCursorPrev }) {
129
+ const isCursor = !!cursorPaginationMode;
130
+ const isPrevDisabled = isCursor ? !hasPrevPage : currentPage === 1;
131
+ const isNextDisabled = isCursor ? !hasNextPage : totalPages === 0 || currentPage === totalPages;
132
+ const handlePrevClick = () => {
133
+ if (isCursor) onCursorPrev?.();
134
+ else onPageChange?.(currentPage - 1);
135
+ };
136
+ const handleNextClick = () => {
137
+ if (isCursor) onCursorNext?.();
138
+ else onPageChange?.(currentPage + 1);
139
+ };
140
+ const displayText = (() => {
141
+ if (isCursor) return /* @__PURE__ */ jsxs(Fragment$1, { children: [
142
+ "Total ",
143
+ /* @__PURE__ */ jsx("span", {
144
+ className: "font-medium",
145
+ children: totalItems
146
+ }),
147
+ " results"
148
+ ] });
149
+ const start = totalItems === 0 ? 0 : (currentPage - 1) * pageSize + 1;
150
+ const end = Math.min(currentPage * pageSize, totalItems);
151
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
152
+ "Showing ",
153
+ /* @__PURE__ */ jsx("span", {
154
+ className: "font-medium",
155
+ children: start
156
+ }),
157
+ " to",
158
+ " ",
159
+ /* @__PURE__ */ jsx("span", {
160
+ className: "font-medium",
161
+ children: end
162
+ }),
163
+ " of",
164
+ " ",
165
+ /* @__PURE__ */ jsx("span", {
166
+ className: "font-medium",
167
+ children: totalItems
168
+ }),
169
+ " results"
170
+ ] });
171
+ })();
172
+ const buttonBase = "relative inline-flex items-center px-3 py-2 text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50";
173
+ return /* @__PURE__ */ jsxs("div", {
174
+ className: "border-border flex items-center justify-between border-t px-4 py-3 sm:px-6",
175
+ children: [/* @__PURE__ */ jsxs("div", {
176
+ className: "flex flex-1 justify-between sm:hidden",
177
+ children: [/* @__PURE__ */ jsx("button", {
178
+ type: "button",
179
+ onClick: handlePrevClick,
180
+ disabled: isPrevDisabled,
181
+ className: cn(buttonBase, "border-border bg-background text-foreground hover:bg-accent rounded-md border"),
182
+ children: "Previous"
183
+ }), /* @__PURE__ */ jsx("button", {
184
+ type: "button",
185
+ onClick: handleNextClick,
186
+ disabled: isNextDisabled,
187
+ className: cn(buttonBase, "border-border bg-background text-foreground hover:bg-accent ml-3 rounded-md border"),
188
+ children: "Next"
189
+ })]
190
+ }), /* @__PURE__ */ jsxs("div", {
191
+ className: "hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",
192
+ children: [/* @__PURE__ */ jsx("p", {
193
+ className: "text-muted-foreground text-xs",
194
+ children: displayText
195
+ }), /* @__PURE__ */ jsxs("nav", {
196
+ "aria-label": "Pagination",
197
+ className: "isolate inline-flex -space-x-px rounded-md shadow-sm",
198
+ children: [
199
+ /* @__PURE__ */ jsxs("button", {
200
+ type: "button",
201
+ onClick: handlePrevClick,
202
+ disabled: isPrevDisabled,
203
+ className: cn(buttonBase, "border-border text-muted-foreground hover:bg-accent rounded-l-md border"),
204
+ children: [/* @__PURE__ */ jsx("span", {
205
+ className: "sr-only",
206
+ children: "Previous"
207
+ }), /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })]
208
+ }),
209
+ !isCursor && /* @__PURE__ */ jsxs("span", {
210
+ className: "border-border bg-background text-foreground relative inline-flex items-center border px-4 py-2 text-sm font-medium",
211
+ children: [
212
+ currentPage,
213
+ " / ",
214
+ totalPages
215
+ ]
216
+ }),
217
+ /* @__PURE__ */ jsxs("button", {
218
+ type: "button",
219
+ onClick: handleNextClick,
220
+ disabled: isNextDisabled,
221
+ className: cn(buttonBase, "border-border text-muted-foreground hover:bg-accent rounded-r-md border"),
222
+ children: [/* @__PURE__ */ jsx("span", {
223
+ className: "sr-only",
224
+ children: "Next"
225
+ }), /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })]
226
+ })
227
+ ]
228
+ })]
229
+ })]
230
+ });
231
+ }
232
+ //#endregion
233
+ //#region ../../orders/ui/src/components/status-badge.tsx
234
+ const colorStyles = {
235
+ green: "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",
236
+ yellow: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400",
237
+ red: "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400",
238
+ blue: "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",
239
+ gray: "bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"
240
+ };
241
+ const dotColorStyles = {
242
+ green: "bg-green-500",
243
+ yellow: "bg-yellow-500",
244
+ red: "bg-red-500",
245
+ blue: "bg-blue-500",
246
+ gray: "bg-gray-500"
247
+ };
248
+ const sizeStyles = {
249
+ xs: "px-1.5 py-0.5 text-[10px]",
250
+ sm: "px-2 py-0.5 text-xs",
251
+ md: "px-2.5 py-1 text-sm"
252
+ };
253
+ function StatusBadge({ color, dot, size = "md", className, children }) {
254
+ return /* @__PURE__ */ jsxs("span", {
255
+ className: cn("inline-flex items-center gap-1 rounded-full font-medium whitespace-nowrap", colorStyles[color], sizeStyles[size], className),
256
+ children: [dot && /* @__PURE__ */ jsx("span", { className: cn("h-1.5 w-1.5 rounded-full", dotColorStyles[color]) }), children]
257
+ });
258
+ }
259
+ //#endregion
260
+ //#region ../../orders/ui/src/components/table-column.tsx
261
+ function TableColumn({ label, sortable = true, className, onSortClick, sortBy, sortData, chevronUpIcon, chevronDownIcon }) {
262
+ const hideUpIcon = sortData?.column !== sortBy || sortData?.column === sortBy && sortData?.direction === "asc";
263
+ const hideDownIcon = sortData?.column !== sortBy || sortData?.column === sortBy && sortData?.direction === "desc";
264
+ return /* @__PURE__ */ jsx("th", {
265
+ className: cn("group cursor-pointer px-3 py-2 text-left text-xs font-medium text-gray-500 transition-colors duration-200", "hover:text-blue-600", className),
266
+ onClick: () => sortable && onSortClick?.(sortBy ?? ""),
267
+ children: /* @__PURE__ */ jsxs("div", {
268
+ className: "relative flex items-center",
269
+ children: [label, sortable && chevronUpIcon && chevronDownIcon && /* @__PURE__ */ jsx("button", {
270
+ className: `ml-2 inline-flex flex-col items-center justify-center group-hover:opacity-100 ${sortData?.column === sortBy ? "opacity-100" : "opacity-0"} transition-opacity duration-200`,
271
+ children: /* @__PURE__ */ jsxs("div", {
272
+ className: "flex flex-col",
273
+ children: [/* @__PURE__ */ jsx("img", {
274
+ src: chevronUpIcon,
275
+ alt: "",
276
+ width: 12,
277
+ height: 12,
278
+ className: cn("h-2.5 w-2.5 text-gray-400 transition-colors duration-200 group-hover:text-blue-600", hideUpIcon && "opacity-0", sortData?.column !== sortBy && "group-hover:opacity-100")
279
+ }), /* @__PURE__ */ jsx("img", {
280
+ src: chevronDownIcon,
281
+ alt: "",
282
+ width: 12,
283
+ height: 12,
284
+ className: cn("h-2.5 w-2.5 text-gray-400 transition-colors duration-200 group-hover:text-blue-600", hideDownIcon && "opacity-0", sortData?.column !== sortBy && "group-hover:opacity-100")
285
+ })]
286
+ })
287
+ })]
288
+ })
289
+ });
290
+ }
291
+ //#endregion
292
+ //#region ../../orders/ui/src/components/orders-list.tsx
293
+ function OrdersList({ customerId, onOrderClick, onSubscriptionClick, t, pageSize = 10 }) {
294
+ const [cursor, setCursor] = useState(null);
295
+ const [searchTerm, setSearchTerm] = useState("");
296
+ const { data, isLoading } = useCustomerOrders({
297
+ customerId,
298
+ limit: pageSize,
299
+ search: searchTerm || void 0,
300
+ cursor: cursor || void 0,
301
+ sort: "-created_at"
302
+ }, { enabled: !!customerId });
303
+ const handleSearchChange = useCallback((term) => {
304
+ setSearchTerm(term);
305
+ setCursor(null);
306
+ }, []);
307
+ const handleNextPage = useCallback(() => {
308
+ const nextCursor = data?.meta?.pagination?.next_cursor;
309
+ if (nextCursor) setCursor(nextCursor);
310
+ }, [data?.meta?.pagination?.next_cursor]);
311
+ const handlePrevPage = useCallback(() => {
312
+ const prevCursor = data?.meta?.pagination?.prev_cursor;
313
+ if (prevCursor) setCursor(prevCursor);
314
+ else setCursor(null);
315
+ }, [data?.meta?.pagination?.prev_cursor]);
316
+ const ordersList = data?.orders || [];
317
+ const pagination = data?.meta?.pagination;
318
+ const totalItems = pagination?.total_count ?? ordersList.length;
319
+ const totalPages = pagination?.total_pages ?? 1;
320
+ const currentPage = pagination?.current_page ?? 1;
321
+ const hasNextPage = !!pagination?.next_cursor;
322
+ const hasPrevPage = !!pagination?.prev_cursor;
323
+ return /* @__PURE__ */ jsxs("div", {
324
+ className: "border-border overflow-hidden rounded-lg border shadow-sm",
325
+ children: [
326
+ /* @__PURE__ */ jsx("div", {
327
+ className: "p-3 text-left",
328
+ children: /* @__PURE__ */ jsx("div", {
329
+ className: "w-full md:mr-auto md:w-1/2 lg:w-1/3",
330
+ children: /* @__PURE__ */ jsx(SearchInput, {
331
+ searchTerm,
332
+ onSearchChange: handleSearchChange,
333
+ placeholder: t("search_orders")
334
+ })
335
+ })
336
+ }),
337
+ /* @__PURE__ */ jsx("div", {
338
+ className: "block md:hidden",
339
+ children: isLoading ? Array(5).fill(0).map((_, index) => /* @__PURE__ */ jsx("div", {
340
+ className: "border-border border-b p-4",
341
+ children: /* @__PURE__ */ jsxs("div", {
342
+ className: "flex space-x-3",
343
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-12 rounded-md" }), /* @__PURE__ */ jsxs("div", {
344
+ className: "flex-1 space-y-2",
345
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-1/2" })]
346
+ })]
347
+ })
348
+ }, `skeleton-${index}`)) : ordersList.length === 0 ? /* @__PURE__ */ jsx("div", {
349
+ className: "text-muted-foreground px-3 py-8 text-center text-sm",
350
+ children: searchTerm ? t("no_matching_orders") : t("no_orders_found")
351
+ }) : ordersList.map((order) => /* @__PURE__ */ jsx("div", {
352
+ className: "border-border hover:bg-accent cursor-pointer border-b p-4 transition-colors duration-200 ease-in-out last:border-b-0",
353
+ onClick: () => onOrderClick(order),
354
+ children: /* @__PURE__ */ jsxs("div", {
355
+ className: "flex items-start space-x-3",
356
+ children: [order.first_item?.image_url ? /* @__PURE__ */ jsx("img", {
357
+ src: order.first_item.image_url,
358
+ alt: t("no_image_available"),
359
+ width: 48,
360
+ height: 48,
361
+ className: "h-12 w-12 flex-shrink-0 rounded-md object-cover"
362
+ }) : /* @__PURE__ */ jsx("div", { className: "bg-border h-12 w-12 flex-shrink-0 rounded-md" }), /* @__PURE__ */ jsxs("div", {
363
+ className: "w-0 min-w-0 flex-1",
364
+ children: [
365
+ order.first_item?.title ? /* @__PURE__ */ jsx("p", {
366
+ className: "text-foreground truncate text-sm font-medium",
367
+ children: order.first_item.title
368
+ }) : /* @__PURE__ */ jsx("div", {
369
+ className: "bg-muted rounded-lg p-2",
370
+ children: /* @__PURE__ */ jsx("div", {
371
+ className: "text-muted-foreground text-xs",
372
+ children: t("this_product_no_longer_exists")
373
+ })
374
+ }),
375
+ order.subscription && /* @__PURE__ */ jsx(StatusBadge, {
376
+ color: "blue",
377
+ size: "xs",
378
+ className: "mt-1",
379
+ children: t("subscription")
380
+ }),
381
+ order.subscription && onSubscriptionClick && /* @__PURE__ */ jsx("button", {
382
+ type: "button",
383
+ className: "text-foreground hover:text-foreground/80 mt-1 inline-block text-xs transition-colors duration-200 hover:underline",
384
+ onClick: (e) => {
385
+ e.stopPropagation();
386
+ onSubscriptionClick(order.subscription.subscription_token);
387
+ },
388
+ children: t("view_subscription")
389
+ }),
390
+ /* @__PURE__ */ jsxs("div", {
391
+ className: "mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-sm",
392
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
393
+ className: "text-muted-foreground block text-xs",
394
+ children: t("date")
395
+ }), /* @__PURE__ */ jsx("span", {
396
+ className: "text-muted-foreground",
397
+ children: new Date(order.created_at).toLocaleDateString()
398
+ })] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
399
+ className: "text-muted-foreground block text-xs",
400
+ children: t("total")
401
+ }), /* @__PURE__ */ jsx("span", {
402
+ className: "text-foreground font-medium",
403
+ children: formatOrderTotal(order)
404
+ })] })]
405
+ })
406
+ ]
407
+ })]
408
+ })
409
+ }, order.id))
410
+ }),
411
+ /* @__PURE__ */ jsx("div", {
412
+ className: "hidden overflow-x-auto md:block",
413
+ children: /* @__PURE__ */ jsxs("table", {
414
+ className: "min-w-full table-fixed",
415
+ children: [
416
+ /* @__PURE__ */ jsxs("colgroup", { children: [
417
+ /* @__PURE__ */ jsx("col", { className: "w-2/5 min-w-[240px]" }),
418
+ /* @__PURE__ */ jsx("col", { className: "w-1/3 min-w-[100px]" }),
419
+ /* @__PURE__ */ jsx("col", { className: "w-[26.67%] min-w-[100px]" })
420
+ ] }),
421
+ /* @__PURE__ */ jsx("thead", {
422
+ className: "bg-muted",
423
+ children: /* @__PURE__ */ jsxs("tr", {
424
+ className: "h-10",
425
+ children: [
426
+ /* @__PURE__ */ jsx(TableColumn, {
427
+ label: t("product"),
428
+ sortable: false
429
+ }),
430
+ /* @__PURE__ */ jsx(TableColumn, {
431
+ label: t("date"),
432
+ sortable: false
433
+ }),
434
+ /* @__PURE__ */ jsx(TableColumn, {
435
+ label: t("total"),
436
+ sortable: false
437
+ })
438
+ ]
439
+ })
440
+ }),
441
+ /* @__PURE__ */ jsx("tbody", {
442
+ className: "divide-border bg-background divide-y",
443
+ children: isLoading ? Array(5).fill(0).map((_, index) => /* @__PURE__ */ jsxs("tr", { children: [
444
+ /* @__PURE__ */ jsx("td", {
445
+ className: "px-3 py-4",
446
+ children: /* @__PURE__ */ jsxs("div", {
447
+ className: "flex items-center space-x-2",
448
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9 rounded-md" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" })]
449
+ })
450
+ }),
451
+ /* @__PURE__ */ jsx("td", {
452
+ className: "px-3 py-4",
453
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })
454
+ }),
455
+ /* @__PURE__ */ jsx("td", {
456
+ className: "px-3 py-4",
457
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })
458
+ })
459
+ ] }, `skeleton-${index}`)) : ordersList.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
460
+ colSpan: 3,
461
+ className: "text-muted-foreground px-3 py-8 text-center text-sm",
462
+ children: searchTerm ? t("no_matching_orders") : t("no_orders_found")
463
+ }) }) : ordersList.map((order) => /* @__PURE__ */ jsxs("tr", {
464
+ className: "hover:bg-accent cursor-pointer transition-colors duration-200 ease-in-out",
465
+ onClick: () => onOrderClick(order),
466
+ children: [
467
+ /* @__PURE__ */ jsx("td", {
468
+ className: "text-muted-foreground px-3 py-4 text-sm",
469
+ children: /* @__PURE__ */ jsxs("div", {
470
+ className: "flex max-w-[280px] flex-row items-center space-x-3",
471
+ children: [order.first_item?.image_url ? /* @__PURE__ */ jsx("img", {
472
+ src: order.first_item.image_url,
473
+ alt: t("no_image_available"),
474
+ width: 42,
475
+ height: 42,
476
+ className: "h-[42px] w-[42px] flex-shrink-0 rounded-md object-cover"
477
+ }) : /* @__PURE__ */ jsx("div", { className: "bg-border ml-1 h-9 w-9 flex-shrink-0 rounded-md" }), /* @__PURE__ */ jsxs("div", {
478
+ className: "flex min-w-0 flex-col space-y-1",
479
+ children: [/* @__PURE__ */ jsxs("div", {
480
+ className: "flex items-center space-x-2",
481
+ children: [order.first_item?.title ? /* @__PURE__ */ jsx("span", {
482
+ className: "text-foreground truncate text-sm font-medium",
483
+ children: order.first_item.title
484
+ }) : /* @__PURE__ */ jsx("div", {
485
+ className: "bg-muted w-full rounded-lg p-2",
486
+ children: /* @__PURE__ */ jsx("div", {
487
+ className: "text-muted-foreground text-xs",
488
+ children: t("this_product_no_longer_exists")
489
+ })
490
+ }), order.subscription && /* @__PURE__ */ jsx(StatusBadge, {
491
+ color: "blue",
492
+ size: "xs",
493
+ className: "flex-shrink-0",
494
+ children: t("subscription")
495
+ })]
496
+ }), order.subscription && onSubscriptionClick && /* @__PURE__ */ jsx("button", {
497
+ type: "button",
498
+ className: "text-foreground hover:text-foreground/80 text-left text-xs transition-colors duration-200 hover:underline",
499
+ onClick: (e) => {
500
+ e.stopPropagation();
501
+ onSubscriptionClick(order.subscription.subscription_token);
502
+ },
503
+ children: t("view_subscription")
504
+ })]
505
+ })]
506
+ })
507
+ }),
508
+ /* @__PURE__ */ jsx("td", {
509
+ className: "text-muted-foreground px-3 py-4 text-sm whitespace-nowrap",
510
+ children: new Date(order.created_at).toLocaleDateString()
511
+ }),
512
+ /* @__PURE__ */ jsx("td", {
513
+ className: "text-foreground px-3 py-4 text-sm whitespace-nowrap",
514
+ children: formatOrderTotal(order)
515
+ })
516
+ ]
517
+ }, order.id))
518
+ })
519
+ ]
520
+ })
521
+ }),
522
+ /* @__PURE__ */ jsx(PaginationFooter, {
523
+ currentPage,
524
+ totalPages,
525
+ pageSize,
526
+ totalItems,
527
+ cursorPaginationMode: true,
528
+ hasNextPage,
529
+ hasPrevPage,
530
+ onCursorNext: handleNextPage,
531
+ onCursorPrev: handlePrevPage
532
+ })
533
+ ]
534
+ });
535
+ }
536
+ //#endregion
537
+ //#region ../../orders/ui/src/components/section.tsx
538
+ function Section({ title, children, footer }) {
539
+ return /* @__PURE__ */ jsxs(Card, { children: [
540
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: title }) }),
541
+ /* @__PURE__ */ jsx(CardContent, { children }),
542
+ footer && /* @__PURE__ */ jsx("div", {
543
+ className: "px-6 pb-6",
544
+ children: footer
545
+ })
546
+ ] });
547
+ }
548
+ //#endregion
549
+ //#region ../../orders/ui/src/components/shipping-address-card.tsx
550
+ function ShippingAddressCard({ name, address, title = "Shipping Address", className }) {
551
+ return /* @__PURE__ */ jsxs(Card, {
552
+ className,
553
+ children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: title }) }), /* @__PURE__ */ jsx(CardContent, { children: !address ? /* @__PURE__ */ jsx("p", {
554
+ className: "text-muted-foreground text-sm",
555
+ children: "No shipping address available"
556
+ }) : /* @__PURE__ */ jsxs("div", {
557
+ className: "flex items-start gap-2",
558
+ children: [/* @__PURE__ */ jsx(Truck, { className: "text-muted-foreground mt-0.5 mr-2 h-4 w-4 shrink-0" }), /* @__PURE__ */ jsxs("div", {
559
+ className: "flex min-w-0 flex-1 flex-col",
560
+ children: [
561
+ name && /* @__PURE__ */ jsx("span", {
562
+ className: "text-foreground min-w-0 truncate text-sm",
563
+ title: name,
564
+ children: name
565
+ }),
566
+ address.line1 && /* @__PURE__ */ jsx("span", {
567
+ className: "text-muted-foreground text-sm",
568
+ children: address.line1
569
+ }),
570
+ address.line2 && /* @__PURE__ */ jsx("span", {
571
+ className: "text-muted-foreground text-sm",
572
+ children: address.line2
573
+ }),
574
+ address.line3 && /* @__PURE__ */ jsx("span", {
575
+ className: "text-muted-foreground text-sm",
576
+ children: address.line3
577
+ })
578
+ ]
579
+ })]
580
+ }) })]
581
+ });
582
+ }
583
+ //#endregion
584
+ //#region ../../orders/ui/src/lib/format.ts
585
+ function startCase(str) {
586
+ if (!str) return "";
587
+ return str.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
588
+ }
589
+ function formatCurrency(symbol, value) {
590
+ return `${symbol}${Number(value).toFixed(2)}`;
591
+ }
592
+ //#endregion
593
+ //#region ../../orders/ui/src/components/payment-method-card.tsx
594
+ function capitalizeFirstLetter(str) {
595
+ if (!str || str.length === 0) return "";
596
+ return str.charAt(0).toUpperCase() + str.slice(1);
597
+ }
598
+ function PaymentDetails({ card }) {
599
+ const paymentTitle = card.payment_title || (card.source ? startCase(card.source) : null);
600
+ if (card.source === "card" || card.card_type) {
601
+ const cardType = capitalizeFirstLetter(card.card_type || "Card");
602
+ const lastFour = card.last_four_digits || "XXXX";
603
+ return /* @__PURE__ */ jsx("div", {
604
+ className: "flex w-full flex-row justify-between",
605
+ children: /* @__PURE__ */ jsxs("div", {
606
+ className: "flex flex-row items-center gap-2.5",
607
+ children: [card.logo_url ? /* @__PURE__ */ jsx("img", {
608
+ src: card.logo_url,
609
+ alt: `${cardType} Logo`,
610
+ className: "h-6 w-9 object-contain",
611
+ width: 35,
612
+ height: 24
613
+ }) : /* @__PURE__ */ jsx("div", {
614
+ className: "bg-muted text-muted-foreground flex h-6 w-9 items-center justify-center rounded text-xs",
615
+ children: cardType.charAt(0)
616
+ }), /* @__PURE__ */ jsxs("span", {
617
+ className: "text-sm font-medium",
618
+ children: [
619
+ cardType,
620
+ " * ",
621
+ lastFour
622
+ ]
623
+ })]
624
+ })
625
+ });
626
+ }
627
+ const displayTitle = paymentTitle || "Payment Method";
628
+ return /* @__PURE__ */ jsx("div", {
629
+ className: "flex w-full flex-row justify-between",
630
+ children: /* @__PURE__ */ jsxs("div", {
631
+ className: "flex flex-row items-center gap-2.5",
632
+ children: [card.logo_url ? /* @__PURE__ */ jsx("img", {
633
+ src: card.logo_url,
634
+ alt: `${displayTitle} Logo`,
635
+ className: "h-6 w-9 object-contain",
636
+ width: 35,
637
+ height: 24
638
+ }) : /* @__PURE__ */ jsx("div", {
639
+ className: "flex h-6 w-9 items-center justify-center rounded bg-blue-100 text-xs font-medium text-blue-600 dark:bg-blue-900/30 dark:text-blue-400",
640
+ children: displayTitle.charAt(0)
641
+ }), /* @__PURE__ */ jsx("span", {
642
+ className: "text-sm font-medium",
643
+ children: displayTitle
644
+ })]
645
+ })
646
+ });
647
+ }
648
+ function PaymentMethodCard({ paymentMethod, title = "Payment Method", className }) {
649
+ return /* @__PURE__ */ jsxs(Card, {
650
+ className,
651
+ children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: title }) }), /* @__PURE__ */ jsx(CardContent, { children: paymentMethod ? /* @__PURE__ */ jsx(PaymentDetails, { card: paymentMethod }) : /* @__PURE__ */ jsx("p", {
652
+ className: "text-muted-foreground text-sm",
653
+ children: "No payment method"
654
+ }) })]
655
+ });
656
+ }
657
+ //#endregion
658
+ //#region ../../orders/ui/src/components/order-status-badge.tsx
659
+ const statusColorMap = {
660
+ paid: "green",
661
+ fulfilled: "green",
662
+ delivered: "green",
663
+ complete: "green",
664
+ pending: "yellow",
665
+ unfulfilled: "yellow",
666
+ partially_fulfilled: "yellow",
667
+ processing: "yellow",
668
+ refunded: "red",
669
+ cancelled: "red",
670
+ failed: "red",
671
+ voided: "red"
672
+ };
673
+ function OrderStatusBadge({ status, className }) {
674
+ return /* @__PURE__ */ jsx(StatusBadge, {
675
+ color: statusColorMap[status] ?? "gray",
676
+ dot: true,
677
+ size: "sm",
678
+ className,
679
+ children: startCase(status)
680
+ });
681
+ }
682
+ //#endregion
683
+ //#region ../../orders/ui/src/components/order-detail.tsx
684
+ function formatAddress(address) {
685
+ return {
686
+ line1: address.address1 ?? "",
687
+ line2: [[address.city, address.state].filter(Boolean).join(", "), address.postal_code].filter(Boolean).join(" "),
688
+ line3: address.country_code ?? ""
689
+ };
690
+ }
691
+ function OrderDetailSkeleton() {
692
+ return /* @__PURE__ */ jsxs("div", {
693
+ className: "space-y-6",
694
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full rounded-lg" }), /* @__PURE__ */ jsxs("div", {
695
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
696
+ children: [/* @__PURE__ */ jsxs("div", {
697
+ className: "space-y-6 lg:col-span-2",
698
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-64 w-full rounded-lg" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-48 w-full rounded-lg" })]
699
+ }), /* @__PURE__ */ jsxs("div", {
700
+ className: "space-y-6",
701
+ children: [
702
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full rounded-lg" }),
703
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full rounded-lg" }),
704
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full rounded-lg" })
705
+ ]
706
+ })]
707
+ })]
708
+ });
709
+ }
710
+ function OrderItemRow({ item }) {
711
+ return /* @__PURE__ */ jsxs("div", {
712
+ className: "flex items-start gap-4 py-4 first:pt-0 last:pb-0",
713
+ children: [
714
+ item.image_url && /* @__PURE__ */ jsx("img", {
715
+ src: item.image_url,
716
+ alt: item.title,
717
+ className: "h-16 w-16 flex-shrink-0 rounded-lg object-cover"
718
+ }),
719
+ /* @__PURE__ */ jsxs("div", {
720
+ className: "min-w-0 flex-1",
721
+ children: [
722
+ /* @__PURE__ */ jsx("p", {
723
+ className: "text-foreground font-medium",
724
+ children: item.title
725
+ }),
726
+ item.ordered_variant.length > 0 && /* @__PURE__ */ jsx("p", {
727
+ className: "text-muted-foreground text-sm",
728
+ children: item.ordered_variant.map((v) => v.value).join(" / ")
729
+ }),
730
+ item.sku && /* @__PURE__ */ jsxs("p", {
731
+ className: "text-muted-foreground text-xs",
732
+ children: ["SKU: ", item.sku]
733
+ }),
734
+ item.subscription && /* @__PURE__ */ jsx(StatusBadge, {
735
+ color: "blue",
736
+ size: "xs",
737
+ className: "mt-1",
738
+ children: "Subscription"
739
+ })
740
+ ]
741
+ }),
742
+ /* @__PURE__ */ jsxs("div", {
743
+ className: "text-right text-sm",
744
+ children: [/* @__PURE__ */ jsx("p", {
745
+ className: "text-foreground font-medium",
746
+ children: item.display_total
747
+ }), item.quantity > 1 && /* @__PURE__ */ jsxs("p", {
748
+ className: "text-muted-foreground",
749
+ children: [
750
+ item.display_price,
751
+ " x ",
752
+ item.quantity
753
+ ]
754
+ })]
755
+ })
756
+ ]
757
+ });
758
+ }
759
+ function OrderPriceSummary({ order }) {
760
+ const sym = order.currency_symbol || "$";
761
+ return /* @__PURE__ */ jsx(Section, {
762
+ title: "Summary",
763
+ children: /* @__PURE__ */ jsxs("dl", {
764
+ className: "space-y-2 text-sm",
765
+ children: [
766
+ /* @__PURE__ */ jsxs("div", {
767
+ className: "flex justify-between",
768
+ children: [/* @__PURE__ */ jsx("dt", {
769
+ className: "text-muted-foreground",
770
+ children: "Subtotal"
771
+ }), /* @__PURE__ */ jsx("dd", {
772
+ className: "text-foreground font-medium",
773
+ children: order.sub_total_in_currency
774
+ })]
775
+ }),
776
+ Number(order.discount) > 0 && /* @__PURE__ */ jsxs("div", {
777
+ className: "flex justify-between",
778
+ children: [/* @__PURE__ */ jsxs("dt", {
779
+ className: "text-muted-foreground",
780
+ children: ["Discount", order.discount_codes?.length ? ` (${order.discount_codes.join(", ")})` : ""]
781
+ }), /* @__PURE__ */ jsxs("dd", {
782
+ className: "text-foreground font-medium",
783
+ children: ["-", order.discount_in_currency]
784
+ })]
785
+ }),
786
+ /* @__PURE__ */ jsxs("div", {
787
+ className: "flex justify-between",
788
+ children: [/* @__PURE__ */ jsx("dt", {
789
+ className: "text-muted-foreground",
790
+ children: "Shipping"
791
+ }), /* @__PURE__ */ jsx("dd", {
792
+ className: "text-foreground font-medium",
793
+ children: order.free_shipping ? "Free" : order.shipping_total_for_display
794
+ })]
795
+ }),
796
+ /* @__PURE__ */ jsxs("div", {
797
+ className: "flex justify-between",
798
+ children: [/* @__PURE__ */ jsxs("dt", {
799
+ className: "text-muted-foreground",
800
+ children: ["Tax", order.price_inclusive_of_tax && order.price_inclusive_tax_name ? ` (${order.price_inclusive_tax_name}, included)` : ""]
801
+ }), /* @__PURE__ */ jsx("dd", {
802
+ className: "text-foreground font-medium",
803
+ children: order.tax_in_currency
804
+ })]
805
+ }),
806
+ order.points_applied_amount_in_currency != null && order.points_applied_amount_in_currency > 0 && /* @__PURE__ */ jsxs("div", {
807
+ className: "flex justify-between",
808
+ children: [/* @__PURE__ */ jsx("dt", {
809
+ className: "text-muted-foreground",
810
+ children: "Points Applied"
811
+ }), /* @__PURE__ */ jsxs("dd", {
812
+ className: "text-foreground font-medium",
813
+ children: ["-", formatCurrency(sym, order.points_applied_amount_in_currency)]
814
+ })]
815
+ }),
816
+ /* @__PURE__ */ jsxs("div", {
817
+ className: "border-border flex justify-between border-t pt-2",
818
+ children: [/* @__PURE__ */ jsx("dt", {
819
+ className: "text-foreground font-semibold",
820
+ children: "Total"
821
+ }), /* @__PURE__ */ jsx("dd", {
822
+ className: "text-foreground font-semibold",
823
+ children: order.total_in_currency
824
+ })]
825
+ })
826
+ ]
827
+ })
828
+ });
829
+ }
830
+ function OrderStatusRow({ order }) {
831
+ return /* @__PURE__ */ jsxs("div", {
832
+ className: "border-border bg-card flex flex-wrap items-center gap-3 rounded-lg border p-6",
833
+ children: [
834
+ /* @__PURE__ */ jsxs("div", {
835
+ className: "flex items-center gap-2",
836
+ children: [/* @__PURE__ */ jsx("span", {
837
+ className: "text-muted-foreground text-sm",
838
+ children: "Payment:"
839
+ }), /* @__PURE__ */ jsx(OrderStatusBadge, { status: order.payment_status })]
840
+ }),
841
+ /* @__PURE__ */ jsxs("div", {
842
+ className: "flex items-center gap-2",
843
+ children: [/* @__PURE__ */ jsx("span", {
844
+ className: "text-muted-foreground text-sm",
845
+ children: "Fulfillment:"
846
+ }), /* @__PURE__ */ jsx(OrderStatusBadge, { status: order.fulfillment_status })]
847
+ }),
848
+ /* @__PURE__ */ jsxs("div", {
849
+ className: "flex items-center gap-2",
850
+ children: [/* @__PURE__ */ jsx("span", {
851
+ className: "text-muted-foreground text-sm",
852
+ children: "Delivery:"
853
+ }), /* @__PURE__ */ jsx(OrderStatusBadge, { status: order.delivery_status })]
854
+ }),
855
+ /* @__PURE__ */ jsx("div", {
856
+ className: "text-muted-foreground ml-auto text-sm",
857
+ children: new Date(order.created_at).toLocaleDateString("en-US", {
858
+ year: "numeric",
859
+ month: "long",
860
+ day: "numeric"
861
+ })
862
+ })
863
+ ]
864
+ });
865
+ }
866
+ function OrderInfoCard({ order }) {
867
+ return /* @__PURE__ */ jsx(Section, {
868
+ title: "Order Info",
869
+ children: /* @__PURE__ */ jsxs("dl", {
870
+ className: "space-y-2 text-sm",
871
+ children: [
872
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
873
+ className: "text-muted-foreground",
874
+ children: "Order Number"
875
+ }), /* @__PURE__ */ jsx("dd", {
876
+ className: "text-foreground font-medium",
877
+ children: order.order_number
878
+ })] }),
879
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
880
+ className: "text-muted-foreground",
881
+ children: "Channel"
882
+ }), /* @__PURE__ */ jsx("dd", {
883
+ className: "text-foreground font-medium",
884
+ children: startCase(order.channel)
885
+ })] }),
886
+ order.email && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
887
+ className: "text-muted-foreground",
888
+ children: "Email"
889
+ }), /* @__PURE__ */ jsx("dd", {
890
+ className: "text-foreground font-medium",
891
+ children: order.email
892
+ })] })
893
+ ]
894
+ })
895
+ });
896
+ }
897
+ function ShippingMethodCard({ method }) {
898
+ return /* @__PURE__ */ jsxs(Section, {
899
+ title: "Shipping Method",
900
+ children: [/* @__PURE__ */ jsx("p", {
901
+ className: "text-muted-foreground text-sm",
902
+ children: method.title
903
+ }), method.delivery_time_estimate && /* @__PURE__ */ jsxs("p", {
904
+ className: "text-muted-foreground mt-1 text-xs",
905
+ children: ["Est. ", method.delivery_time_estimate]
906
+ })]
907
+ });
908
+ }
909
+ function OrderDetail({ token, onNotFound, onError }) {
910
+ const { data, isLoading, error } = useOrder(token);
911
+ const order = data?.order;
912
+ useEffect(() => {
913
+ if (!isLoading && error) onError?.(error);
914
+ }, [
915
+ isLoading,
916
+ error,
917
+ onError
918
+ ]);
919
+ useEffect(() => {
920
+ if (!isLoading && !error && !order) onNotFound?.();
921
+ }, [
922
+ isLoading,
923
+ error,
924
+ order,
925
+ onNotFound
926
+ ]);
927
+ if (isLoading) return /* @__PURE__ */ jsx(OrderDetailSkeleton, {});
928
+ if (!order) return null;
929
+ const visibleItems = order.items.filter((item) => item.display_to_customer !== false);
930
+ return /* @__PURE__ */ jsxs("div", {
931
+ className: "space-y-6",
932
+ children: [/* @__PURE__ */ jsx(OrderStatusRow, { order }), /* @__PURE__ */ jsxs("div", {
933
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
934
+ children: [/* @__PURE__ */ jsxs("div", {
935
+ className: "space-y-6 lg:col-span-2",
936
+ children: [/* @__PURE__ */ jsx(Section, {
937
+ title: `Items (${order.items_count})`,
938
+ children: /* @__PURE__ */ jsx("div", {
939
+ className: "divide-border divide-y",
940
+ children: visibleItems.map((item) => /* @__PURE__ */ jsx(OrderItemRow, { item }, item.id))
941
+ })
942
+ }), /* @__PURE__ */ jsx(OrderPriceSummary, { order })]
943
+ }), /* @__PURE__ */ jsxs("div", {
944
+ className: "space-y-6",
945
+ children: [
946
+ order.payment_details && /* @__PURE__ */ jsx(PaymentMethodCard, { paymentMethod: {
947
+ source: order.payment_details.payment_type,
948
+ payment_title: order.payment_details.payment_title,
949
+ logo_url: order.payment_details.details.logo_url,
950
+ card_type: order.payment_details.details.card_type,
951
+ last_four_digits: order.payment_details.details.last_four
952
+ } }),
953
+ order.ship_to && /* @__PURE__ */ jsx(ShippingAddressCard, {
954
+ name: order.ship_to.name,
955
+ address: formatAddress(order.ship_to),
956
+ title: "Shipping Address"
957
+ }),
958
+ order.bill_to && /* @__PURE__ */ jsx(ShippingAddressCard, {
959
+ name: order.bill_to.name,
960
+ address: formatAddress(order.bill_to),
961
+ title: "Billing Address"
962
+ }),
963
+ order.shipping_method && /* @__PURE__ */ jsx(ShippingMethodCard, { method: order.shipping_method }),
964
+ /* @__PURE__ */ jsx(OrderInfoCard, { order })
965
+ ]
966
+ })]
967
+ })]
968
+ });
969
+ }
970
+ //#endregion
971
+ export { OrdersCoreProvider as a, PaginationFooter as i, OrdersList as n, useCustomerAccount as o, TableColumn as r, OrderDetail as t };
972
+
973
+ //# sourceMappingURL=src-BZEkCfd4.mjs.map