@fluid-app/portal-sdk 0.1.129 → 0.1.130

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 (122) hide show
  1. package/dist/{AppDownloadScreen-DTxo4z3_.cjs → AppDownloadScreen-ChKim_6A.cjs} +2 -2
  2. package/dist/{AppDownloadScreen-DTxo4z3_.cjs.map → AppDownloadScreen-ChKim_6A.cjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-BoGSdsJk.mjs → AppDownloadScreen-DGHd6hYM.mjs} +2 -2
  4. package/dist/{AppDownloadScreen-BoGSdsJk.mjs.map → AppDownloadScreen-DGHd6hYM.mjs.map} +1 -1
  5. package/dist/{AppDownloadScreen-Chxavsr_.cjs → AppDownloadScreen-DpyV1tJw.cjs} +2 -2
  6. package/dist/{ContactsScreen-BKOHursc.mjs → ContactsScreen-Bcea6126.mjs} +3 -3
  7. package/dist/{ContactsScreen-BKOHursc.mjs.map → ContactsScreen-Bcea6126.mjs.map} +1 -1
  8. package/dist/{ContactsScreen-DN8Qt2Ih.cjs → ContactsScreen-CsIGZaWy.cjs} +4 -4
  9. package/dist/{ContactsScreen-DN8Qt2Ih.cjs.map → ContactsScreen-CsIGZaWy.cjs.map} +1 -1
  10. package/dist/{ContactsScreen-FrVLbjGO.cjs → ContactsScreen-OBDC1046.cjs} +4 -4
  11. package/dist/{FluidProvider-CgTeGUnF.mjs → FluidProvider-BJQSXofR.mjs} +198 -615
  12. package/dist/FluidProvider-BJQSXofR.mjs.map +1 -0
  13. package/dist/{FluidProvider-BMMu_rp3.cjs → FluidProvider-DvqnkjZI.cjs} +196 -625
  14. package/dist/FluidProvider-DvqnkjZI.cjs.map +1 -0
  15. package/dist/{MessagingScreen-Bvq3Dd5i.mjs → MessagingScreen-B48ksZOJ.mjs} +3 -3
  16. package/dist/{MessagingScreen-Bvq3Dd5i.mjs.map → MessagingScreen-B48ksZOJ.mjs.map} +1 -1
  17. package/dist/{MessagingScreen-DMDXiH97.mjs → MessagingScreen-COGo4S9K.mjs} +2 -2
  18. package/dist/{MessagingScreen-DgbNN4BF.cjs → MessagingScreen-DYgiatey.cjs} +3 -3
  19. package/dist/{MessagingScreen-DgbNN4BF.cjs.map → MessagingScreen-DYgiatey.cjs.map} +1 -1
  20. package/dist/{MessagingScreen-bzzXjQMu.cjs → MessagingScreen-QyUOxYXl.cjs} +2 -2
  21. package/dist/{MySiteScreen-nV8x9xyy.cjs → MySiteScreen-ByIJ6CkU.cjs} +2 -2
  22. package/dist/{MySiteScreen-nV8x9xyy.cjs.map → MySiteScreen-ByIJ6CkU.cjs.map} +1 -1
  23. package/dist/{MySiteScreen-BJH5-RNT.mjs → MySiteScreen-DZ0ru6Bn.mjs} +2 -2
  24. package/dist/{MySiteScreen-BJH5-RNT.mjs.map → MySiteScreen-DZ0ru6Bn.mjs.map} +1 -1
  25. package/dist/{MySiteScreen-CYZpUYTn.cjs → MySiteScreen-DrWUJJiH.cjs} +2 -2
  26. package/dist/{OrdersScreen-BL__flBE.cjs → OrdersScreen-CkvoeTvK.cjs} +3 -3
  27. package/dist/OrdersScreen-D_7TJgZ4.mjs +561 -0
  28. package/dist/OrdersScreen-D_7TJgZ4.mjs.map +1 -0
  29. package/dist/OrdersScreen-DyYYjl9I.cjs +568 -0
  30. package/dist/OrdersScreen-DyYYjl9I.cjs.map +1 -0
  31. package/dist/{ProductsScreen-BIYHPaBZ.cjs → ProductsScreen-B8NmyIJy.cjs} +3 -3
  32. package/dist/{ProductsScreen-COwahI-V.mjs → ProductsScreen-CMnhqsSA.mjs} +5 -5
  33. package/dist/{ProductsScreen-COwahI-V.mjs.map → ProductsScreen-CMnhqsSA.mjs.map} +1 -1
  34. package/dist/{ProductsScreen-D6h-r9ht.mjs → ProductsScreen-DzNmbwVi.mjs} +3 -3
  35. package/dist/{ProductsScreen-C8UfVLRr.cjs → ProductsScreen-Z1hx1YZQ.cjs} +5 -5
  36. package/dist/{ProductsScreen-C8UfVLRr.cjs.map → ProductsScreen-Z1hx1YZQ.cjs.map} +1 -1
  37. package/dist/{ProfileScreen-CZp_NrjO.cjs → ProfileScreen-B81Ovmh_.cjs} +2 -2
  38. package/dist/{ProfileScreen-FYGHStqM.cjs → ProfileScreen-CYTxOGeW.cjs} +526 -137
  39. package/dist/ProfileScreen-CYTxOGeW.cjs.map +1 -0
  40. package/dist/{ProfileScreen-BKRn8AqI.mjs → ProfileScreen-QOXtyrJi.mjs} +522 -133
  41. package/dist/ProfileScreen-QOXtyrJi.mjs.map +1 -0
  42. package/dist/{ShareablesScreen-BEPVTMeI.cjs → ShareablesScreen-1HpfEjyd.cjs} +7 -7
  43. package/dist/{ShareablesScreen-BEPVTMeI.cjs.map → ShareablesScreen-1HpfEjyd.cjs.map} +1 -1
  44. package/dist/{ShareablesScreen-BrC5LGtU.cjs → ShareablesScreen-BXO8MpAy.cjs} +3 -3
  45. package/dist/{ShareablesScreen-BXzxUg0E.mjs → ShareablesScreen-DSsMJJh_.mjs} +7 -7
  46. package/dist/{ShareablesScreen-BXzxUg0E.mjs.map → ShareablesScreen-DSsMJJh_.mjs.map} +1 -1
  47. package/dist/{ShareablesScreen-aMnwEOAH.mjs → ShareablesScreen-Oo3jMHX6.mjs} +3 -3
  48. package/dist/{ShopScreen-CHH0cx2P.cjs → ShopScreen-BDcWpmi7.cjs} +4 -4
  49. package/dist/{ShopScreen-CHH0cx2P.cjs.map → ShopScreen-BDcWpmi7.cjs.map} +1 -1
  50. package/dist/{ShopScreen-8OQhLeLt.cjs → ShopScreen-CWxOPn7H.cjs} +2 -2
  51. package/dist/{ShopScreen-Yi9sOX_2.mjs → ShopScreen-DsReuJ7P.mjs} +4 -4
  52. package/dist/{ShopScreen-Yi9sOX_2.mjs.map → ShopScreen-DsReuJ7P.mjs.map} +1 -1
  53. package/dist/{SubscriptionsScreen-oApGaq11.cjs → SubscriptionsScreen-B8mLGt5-.cjs} +27 -10
  54. package/dist/SubscriptionsScreen-B8mLGt5-.cjs.map +1 -0
  55. package/dist/{SubscriptionsScreen-C2F3HNJS.cjs → SubscriptionsScreen-C2zbEjMC.cjs} +4 -4
  56. package/dist/{SubscriptionsScreen-CZ-1jSO2.mjs → SubscriptionsScreen-DZxLo4up.mjs} +21 -4
  57. package/dist/SubscriptionsScreen-DZxLo4up.mjs.map +1 -0
  58. package/dist/index.cjs +37 -37
  59. package/dist/index.d.cts.map +1 -1
  60. package/dist/index.d.mts.map +1 -1
  61. package/dist/index.mjs +37 -37
  62. package/dist/order-status-badge-KooNqnAs.mjs +262 -0
  63. package/dist/order-status-badge-KooNqnAs.mjs.map +1 -0
  64. package/dist/order-status-badge-cwqA8dZ-.cjs +304 -0
  65. package/dist/order-status-badge-cwqA8dZ-.cjs.map +1 -0
  66. package/dist/portal_tenant-CP5Ce8Jn.cjs +261 -0
  67. package/dist/portal_tenant-CP5Ce8Jn.cjs.map +1 -0
  68. package/dist/portal_tenant-CWy4Zg2t.mjs +166 -0
  69. package/dist/portal_tenant-CWy4Zg2t.mjs.map +1 -0
  70. package/dist/src-BOIW-KES.mjs +3 -0
  71. package/dist/src-CzwiFO_J.cjs +3 -0
  72. package/dist/{src-BMUEjfhg.mjs → src-Dgo44BGe.mjs} +1 -1
  73. package/dist/{src-BMUEjfhg.mjs.map → src-Dgo44BGe.mjs.map} +1 -1
  74. package/dist/{src-BJdOxgpp.cjs → src-DkhHoxnS.cjs} +1 -1
  75. package/dist/{src-BJdOxgpp.cjs.map → src-DkhHoxnS.cjs.map} +1 -1
  76. package/dist/use-account-clients-Dim60sir.mjs +451 -0
  77. package/dist/use-account-clients-Dim60sir.mjs.map +1 -0
  78. package/dist/use-account-clients-DoJW3KTx.cjs +481 -0
  79. package/dist/use-account-clients-DoJW3KTx.cjs.map +1 -0
  80. package/dist/{use-current-user-DCk55_Qn.mjs → use-current-user-Baxj7HJt.mjs} +3 -3
  81. package/dist/{use-current-user-DCk55_Qn.mjs.map → use-current-user-Baxj7HJt.mjs.map} +1 -1
  82. package/dist/{use-current-user-BR5_zaoZ.cjs → use-current-user-BcZWV7oU.cjs} +3 -3
  83. package/dist/{use-current-user-BR5_zaoZ.cjs.map → use-current-user-BcZWV7oU.cjs.map} +1 -1
  84. package/dist/{use-fluid-api-CmCAH10d.mjs → use-fluid-api-BP05Cf-f.mjs} +2 -2
  85. package/dist/{use-fluid-api-CmCAH10d.mjs.map → use-fluid-api-BP05Cf-f.mjs.map} +1 -1
  86. package/dist/{use-fluid-api-C1KeHB7q.cjs → use-fluid-api-Ds8BInAZ.cjs} +2 -2
  87. package/dist/{use-fluid-api-C1KeHB7q.cjs.map → use-fluid-api-Ds8BInAZ.cjs.map} +1 -1
  88. package/dist/{use-fluid-auth-BQEV7ylM.mjs → use-fluid-auth-C-Qpl8j4.mjs} +2 -2
  89. package/dist/{use-fluid-auth-BQEV7ylM.mjs.map → use-fluid-auth-C-Qpl8j4.mjs.map} +1 -1
  90. package/dist/{use-fluid-auth-CyKaXLbW.cjs → use-fluid-auth-sGNMgfnt.cjs} +2 -2
  91. package/dist/{use-fluid-auth-CyKaXLbW.cjs.map → use-fluid-auth-sGNMgfnt.cjs.map} +1 -1
  92. package/dist/{use-portal-products-client-pptYMuSw.cjs → use-portal-products-client-DKYkBjm-.cjs} +7 -48
  93. package/dist/use-portal-products-client-DKYkBjm-.cjs.map +1 -0
  94. package/dist/{use-portal-products-client-BL1xVtex.mjs → use-portal-products-client-s2qtZjhU.mjs} +3 -44
  95. package/dist/use-portal-products-client-s2qtZjhU.mjs.map +1 -0
  96. package/package.json +13 -12
  97. package/dist/FluidProvider-BMMu_rp3.cjs.map +0 -1
  98. package/dist/FluidProvider-CgTeGUnF.mjs.map +0 -1
  99. package/dist/OrdersScreen-BLb3_KtI.mjs +0 -176
  100. package/dist/OrdersScreen-BLb3_KtI.mjs.map +0 -1
  101. package/dist/OrdersScreen-uL3mRk1h.cjs +0 -183
  102. package/dist/OrdersScreen-uL3mRk1h.cjs.map +0 -1
  103. package/dist/ProfileScreen-BKRn8AqI.mjs.map +0 -1
  104. package/dist/ProfileScreen-FYGHStqM.cjs.map +0 -1
  105. package/dist/SubscriptionsScreen-CZ-1jSO2.mjs.map +0 -1
  106. package/dist/SubscriptionsScreen-oApGaq11.cjs.map +0 -1
  107. package/dist/order-detail-DHXdE4Cl.cjs +0 -961
  108. package/dist/order-detail-DHXdE4Cl.cjs.map +0 -1
  109. package/dist/order-detail-iZm_R0TX.mjs +0 -931
  110. package/dist/order-detail-iZm_R0TX.mjs.map +0 -1
  111. package/dist/src-BJSTFxSO.mjs +0 -1
  112. package/dist/src-DMVR26Fk.cjs +0 -1
  113. package/dist/use-account-clients-CL6rr17o.cjs +0 -214
  114. package/dist/use-account-clients-CL6rr17o.cjs.map +0 -1
  115. package/dist/use-account-clients-CMjRB5On.mjs +0 -190
  116. package/dist/use-account-clients-CMjRB5On.mjs.map +0 -1
  117. package/dist/use-customer-account-BAolVc3q.mjs +0 -22
  118. package/dist/use-customer-account-BAolVc3q.mjs.map +0 -1
  119. package/dist/use-customer-account-DSsXbcme.cjs +0 -28
  120. package/dist/use-customer-account-DSsXbcme.cjs.map +0 -1
  121. package/dist/use-portal-products-client-BL1xVtex.mjs.map +0 -1
  122. package/dist/use-portal-products-client-pptYMuSw.cjs.map +0 -1
@@ -1,931 +0,0 @@
1
- import { P as Input, _n as cn, d as TableBody, f as TableCell, h as TableRow, m as TableHeader, p as TableHead, u as Table$1, x as Skeleton } from "./src-N020oyu4.mjs";
2
- import { createContext, useCallback, useContext, useEffect, useState } from "react";
3
- import { useQuery } from "@tanstack/react-query";
4
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
- import { ChevronLeft, ChevronRight, Search, Truck } from "lucide-react";
6
- //#region ../../orders/core/src/context.ts
7
- const OrdersApiContext = createContext(null);
8
- const OrdersApiProvider = OrdersApiContext.Provider;
9
- function useOrdersApi() {
10
- const api = useContext(OrdersApiContext);
11
- if (!api) throw new Error("useOrdersApi must be used within an OrdersCoreProvider");
12
- return api;
13
- }
14
- //#endregion
15
- //#region ../../orders/core/src/provider.tsx
16
- function OrdersCoreProvider({ api, children }) {
17
- return /* @__PURE__ */ jsx(OrdersApiProvider, {
18
- value: api,
19
- children
20
- });
21
- }
22
- //#endregion
23
- //#region ../../orders/core/src/query-keys.ts
24
- const ordersKeys = {
25
- all: ["orders"],
26
- list: (params) => [
27
- ...ordersKeys.all,
28
- "list",
29
- params
30
- ],
31
- detail: (orderToken) => [
32
- ...ordersKeys.all,
33
- "detail",
34
- orderToken
35
- ]
36
- };
37
- //#endregion
38
- //#region ../../orders/core/src/hooks/use-order.ts
39
- function useOrder(orderToken, options) {
40
- const api = useOrdersApi();
41
- return useQuery({
42
- queryKey: ordersKeys.detail(orderToken),
43
- queryFn: () => api.fetchOrder(orderToken),
44
- enabled: (options?.enabled ?? true) && !!orderToken
45
- });
46
- }
47
- //#endregion
48
- //#region ../../orders/core/src/hooks/use-customer-orders.ts
49
- function useCustomerOrders(params, options) {
50
- const api = useOrdersApi();
51
- return useQuery({
52
- queryKey: ordersKeys.list(params),
53
- queryFn: () => api.fetchCustomerOrders(params),
54
- enabled: options?.enabled ?? true
55
- });
56
- }
57
- //#endregion
58
- //#region ../../orders/core/src/utils/format-order-total.ts
59
- function formatOrderTotal(order) {
60
- if (order.order_total_after_points_redemption != null) return `${order.currency_symbol || "$"}${Number(order.order_total_after_points_redemption).toFixed(2)}`;
61
- return order.total_display_amount || `${order.currency_symbol || "$"}${Number(order.amount).toFixed(2)}`;
62
- }
63
- //#endregion
64
- //#region ../../orders/ui/src/components/search-input.tsx
65
- function SearchInput({ searchTerm, onSearchChange, placeholder }) {
66
- return /* @__PURE__ */ jsxs("div", {
67
- className: "relative",
68
- 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, {
69
- value: searchTerm,
70
- onChange: (e) => onSearchChange(e.target.value),
71
- placeholder,
72
- className: "pl-9"
73
- })]
74
- });
75
- }
76
- //#endregion
77
- //#region ../../orders/ui/src/components/pagination-footer.tsx
78
- function PaginationFooter({ currentPage, totalPages, pageSize, totalItems, onPageChange, cursorPaginationMode, hasNextPage, hasPrevPage, onCursorNext, onCursorPrev }) {
79
- const isCursor = !!cursorPaginationMode;
80
- const isPrevDisabled = isCursor ? !hasPrevPage : currentPage === 1;
81
- const isNextDisabled = isCursor ? !hasNextPage : totalPages === 0 || currentPage === totalPages;
82
- const handlePrevClick = () => {
83
- if (isCursor) onCursorPrev?.();
84
- else onPageChange?.(currentPage - 1);
85
- };
86
- const handleNextClick = () => {
87
- if (isCursor) onCursorNext?.();
88
- else onPageChange?.(currentPage + 1);
89
- };
90
- const displayText = (() => {
91
- if (isCursor) return /* @__PURE__ */ jsxs(Fragment$1, { children: [
92
- "Total ",
93
- /* @__PURE__ */ jsx("span", {
94
- className: "font-medium",
95
- children: totalItems
96
- }),
97
- " results"
98
- ] });
99
- const start = totalItems === 0 ? 0 : (currentPage - 1) * pageSize + 1;
100
- const end = Math.min(currentPage * pageSize, totalItems);
101
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
102
- "Showing ",
103
- /* @__PURE__ */ jsx("span", {
104
- className: "font-medium",
105
- children: start
106
- }),
107
- " to",
108
- " ",
109
- /* @__PURE__ */ jsx("span", {
110
- className: "font-medium",
111
- children: end
112
- }),
113
- " of",
114
- " ",
115
- /* @__PURE__ */ jsx("span", {
116
- className: "font-medium",
117
- children: totalItems
118
- }),
119
- " results"
120
- ] });
121
- })();
122
- const buttonBase = "relative inline-flex items-center px-3 py-2 text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50";
123
- return /* @__PURE__ */ jsxs("div", {
124
- className: "border-border flex items-center justify-between border-t px-4 py-3 sm:px-6",
125
- children: [/* @__PURE__ */ jsxs("div", {
126
- className: "flex flex-1 justify-between sm:hidden",
127
- children: [/* @__PURE__ */ jsx("button", {
128
- type: "button",
129
- onClick: handlePrevClick,
130
- disabled: isPrevDisabled,
131
- className: cn(buttonBase, "border-border bg-background text-foreground hover:bg-accent rounded-md border"),
132
- children: "Previous"
133
- }), /* @__PURE__ */ jsx("button", {
134
- type: "button",
135
- onClick: handleNextClick,
136
- disabled: isNextDisabled,
137
- className: cn(buttonBase, "border-border bg-background text-foreground hover:bg-accent ml-3 rounded-md border"),
138
- children: "Next"
139
- })]
140
- }), /* @__PURE__ */ jsxs("div", {
141
- className: "hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",
142
- children: [/* @__PURE__ */ jsx("p", {
143
- className: "text-muted-foreground text-xs",
144
- children: displayText
145
- }), /* @__PURE__ */ jsxs("nav", {
146
- "aria-label": "Pagination",
147
- className: "isolate inline-flex -space-x-px rounded-md shadow-sm",
148
- children: [
149
- /* @__PURE__ */ jsxs("button", {
150
- type: "button",
151
- onClick: handlePrevClick,
152
- disabled: isPrevDisabled,
153
- className: cn(buttonBase, "border-border text-muted-foreground hover:bg-accent rounded-l-md border"),
154
- children: [/* @__PURE__ */ jsx("span", {
155
- className: "sr-only",
156
- children: "Previous"
157
- }), /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })]
158
- }),
159
- !isCursor && /* @__PURE__ */ jsxs("span", {
160
- className: "border-border bg-background text-foreground relative inline-flex items-center border px-4 py-2 text-sm font-medium",
161
- children: [
162
- currentPage,
163
- " / ",
164
- totalPages
165
- ]
166
- }),
167
- /* @__PURE__ */ jsxs("button", {
168
- type: "button",
169
- onClick: handleNextClick,
170
- disabled: isNextDisabled,
171
- className: cn(buttonBase, "border-border text-muted-foreground hover:bg-accent rounded-r-md border"),
172
- children: [/* @__PURE__ */ jsx("span", {
173
- className: "sr-only",
174
- children: "Next"
175
- }), /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })]
176
- })
177
- ]
178
- })]
179
- })]
180
- });
181
- }
182
- //#endregion
183
- //#region ../../orders/ui/src/components/status-badge.tsx
184
- const colorStyles = {
185
- green: "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",
186
- yellow: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400",
187
- red: "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400",
188
- blue: "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",
189
- gray: "bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"
190
- };
191
- const dotColorStyles = {
192
- green: "bg-green-500",
193
- yellow: "bg-yellow-500",
194
- red: "bg-red-500",
195
- blue: "bg-blue-500",
196
- gray: "bg-gray-500"
197
- };
198
- const sizeStyles = {
199
- xs: "px-1.5 py-0.5 text-[10px]",
200
- sm: "px-2 py-0.5 text-xs",
201
- md: "px-2.5 py-1 text-sm"
202
- };
203
- function StatusBadge({ color, dot, size = "md", className, children }) {
204
- return /* @__PURE__ */ jsxs("span", {
205
- className: cn("inline-flex items-center gap-1 rounded-full font-medium whitespace-nowrap", colorStyles[color], sizeStyles[size], className),
206
- children: [dot && /* @__PURE__ */ jsx("span", { className: cn("h-1.5 w-1.5 rounded-full", dotColorStyles[color]) }), children]
207
- });
208
- }
209
- //#endregion
210
- //#region ../../orders/ui/src/components/table-column.tsx
211
- function TableColumn({ label, sortable = true, className, onSortClick, sortBy, sortData, chevronUpIcon, chevronDownIcon }) {
212
- const hideUpIcon = sortData?.column !== sortBy || sortData?.column === sortBy && sortData?.direction === "asc";
213
- const hideDownIcon = sortData?.column !== sortBy || sortData?.column === sortBy && sortData?.direction === "desc";
214
- return /* @__PURE__ */ jsx(TableHead, {
215
- className: cn("group text-muted-foreground cursor-pointer px-3 text-xs transition-colors duration-200", "hover:text-primary", className),
216
- onClick: () => sortable && onSortClick?.(sortBy ?? ""),
217
- children: /* @__PURE__ */ jsxs("div", {
218
- className: "relative flex items-center",
219
- children: [label, sortable && chevronUpIcon && chevronDownIcon && /* @__PURE__ */ jsx("button", {
220
- 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`,
221
- children: /* @__PURE__ */ jsxs("div", {
222
- className: "flex flex-col",
223
- children: [/* @__PURE__ */ jsx("img", {
224
- src: chevronUpIcon,
225
- alt: "",
226
- width: 12,
227
- height: 12,
228
- className: cn("text-muted-foreground group-hover:text-primary h-2.5 w-2.5 transition-colors duration-200", hideUpIcon && "opacity-0", sortData?.column !== sortBy && "group-hover:opacity-100")
229
- }), /* @__PURE__ */ jsx("img", {
230
- src: chevronDownIcon,
231
- alt: "",
232
- width: 12,
233
- height: 12,
234
- className: cn("text-muted-foreground group-hover:text-primary h-2.5 w-2.5 transition-colors duration-200", hideDownIcon && "opacity-0", sortData?.column !== sortBy && "group-hover:opacity-100")
235
- })]
236
- })
237
- })]
238
- })
239
- });
240
- }
241
- //#endregion
242
- //#region ../../orders/ui/src/components/orders-list.tsx
243
- function OrdersList({ customerId, onOrderClick, onSubscriptionClick, t, pageSize = 10 }) {
244
- const [cursor, setCursor] = useState(null);
245
- const [searchTerm, setSearchTerm] = useState("");
246
- const { data, isLoading } = useCustomerOrders({
247
- customerId,
248
- limit: pageSize,
249
- search: searchTerm || void 0,
250
- cursor: cursor || void 0,
251
- sort: "-created_at"
252
- }, { enabled: !!customerId });
253
- const handleSearchChange = useCallback((term) => {
254
- setSearchTerm(term);
255
- setCursor(null);
256
- }, []);
257
- const handleNextPage = useCallback(() => {
258
- const nextCursor = data?.meta?.pagination?.next_cursor;
259
- if (nextCursor) setCursor(nextCursor);
260
- }, [data?.meta?.pagination?.next_cursor]);
261
- const handlePrevPage = useCallback(() => {
262
- const prevCursor = data?.meta?.pagination?.prev_cursor;
263
- if (prevCursor) setCursor(prevCursor);
264
- else setCursor(null);
265
- }, [data?.meta?.pagination?.prev_cursor]);
266
- const ordersList = data?.orders || [];
267
- const pagination = data?.meta?.pagination;
268
- const totalItems = pagination?.total_count ?? ordersList.length;
269
- const totalPages = pagination?.total_pages ?? 1;
270
- const currentPage = pagination?.current_page ?? 1;
271
- const hasNextPage = !!pagination?.next_cursor;
272
- const hasPrevPage = !!pagination?.prev_cursor;
273
- return /* @__PURE__ */ jsxs("div", {
274
- className: "border-border overflow-hidden rounded-lg border shadow-sm",
275
- children: [
276
- /* @__PURE__ */ jsx("div", {
277
- className: "p-3 text-left",
278
- children: /* @__PURE__ */ jsx("div", {
279
- className: "w-full md:mr-auto md:w-1/2 lg:w-1/3",
280
- children: /* @__PURE__ */ jsx(SearchInput, {
281
- searchTerm,
282
- onSearchChange: handleSearchChange,
283
- placeholder: t("search_orders")
284
- })
285
- })
286
- }),
287
- /* @__PURE__ */ jsx("div", {
288
- className: "block md:hidden",
289
- children: isLoading ? Array(5).fill(0).map((_, index) => /* @__PURE__ */ jsx("div", {
290
- className: "border-border border-b p-4",
291
- children: /* @__PURE__ */ jsxs("div", {
292
- className: "flex space-x-3",
293
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-12 rounded-md" }), /* @__PURE__ */ jsxs("div", {
294
- className: "flex-1 space-y-2",
295
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-1/2" })]
296
- })]
297
- })
298
- }, `skeleton-${index}`)) : ordersList.length === 0 ? /* @__PURE__ */ jsx("div", {
299
- className: "text-muted-foreground px-3 py-8 text-center text-sm",
300
- children: searchTerm ? t("no_matching_orders") : t("no_orders_found")
301
- }) : ordersList.map((order) => /* @__PURE__ */ jsx("div", {
302
- className: "border-border hover:bg-accent cursor-pointer border-b p-4 transition-colors duration-200 ease-in-out last:border-b-0",
303
- onClick: () => onOrderClick(order),
304
- children: /* @__PURE__ */ jsxs("div", {
305
- className: "flex items-start space-x-3",
306
- children: [order.first_item?.image_url ? /* @__PURE__ */ jsx("img", {
307
- src: order.first_item.image_url,
308
- alt: t("no_image_available"),
309
- width: 48,
310
- height: 48,
311
- className: "h-12 w-12 flex-shrink-0 rounded-md object-cover"
312
- }) : /* @__PURE__ */ jsx("div", { className: "bg-border h-12 w-12 flex-shrink-0 rounded-md" }), /* @__PURE__ */ jsxs("div", {
313
- className: "w-0 min-w-0 flex-1",
314
- children: [
315
- order.first_item?.title ? /* @__PURE__ */ jsx("p", {
316
- className: "text-foreground truncate text-sm font-medium",
317
- children: order.first_item.title
318
- }) : /* @__PURE__ */ jsx("div", {
319
- className: "bg-muted rounded-lg p-2",
320
- children: /* @__PURE__ */ jsx("div", {
321
- className: "text-muted-foreground text-xs",
322
- children: t("this_product_no_longer_exists")
323
- })
324
- }),
325
- order.subscription && /* @__PURE__ */ jsx(StatusBadge, {
326
- color: "blue",
327
- size: "xs",
328
- className: "mt-1",
329
- children: t("subscription")
330
- }),
331
- order.subscription && onSubscriptionClick && /* @__PURE__ */ jsx("button", {
332
- type: "button",
333
- className: "text-foreground hover:text-foreground/80 mt-1 inline-block text-xs transition-colors duration-200 hover:underline",
334
- onClick: (e) => {
335
- e.stopPropagation();
336
- onSubscriptionClick(order.subscription.subscription_token);
337
- },
338
- children: t("view_subscription")
339
- }),
340
- /* @__PURE__ */ jsxs("div", {
341
- className: "mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-sm",
342
- children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
343
- className: "text-muted-foreground block text-xs",
344
- children: t("date")
345
- }), /* @__PURE__ */ jsx("span", {
346
- className: "text-muted-foreground",
347
- children: new Date(order.created_at).toLocaleDateString()
348
- })] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
349
- className: "text-muted-foreground block text-xs",
350
- children: t("total")
351
- }), /* @__PURE__ */ jsx("span", {
352
- className: "text-foreground font-medium",
353
- children: formatOrderTotal(order)
354
- })] })]
355
- })
356
- ]
357
- })]
358
- })
359
- }, order.id))
360
- }),
361
- /* @__PURE__ */ jsx("div", {
362
- className: "hidden md:block",
363
- children: /* @__PURE__ */ jsxs(Table$1, {
364
- className: "min-w-full table-fixed",
365
- children: [
366
- /* @__PURE__ */ jsxs("colgroup", { children: [
367
- /* @__PURE__ */ jsx("col", { className: "w-2/5 min-w-[240px]" }),
368
- /* @__PURE__ */ jsx("col", { className: "w-1/3 min-w-[100px]" }),
369
- /* @__PURE__ */ jsx("col", { className: "w-[26.67%] min-w-[100px]" })
370
- ] }),
371
- /* @__PURE__ */ jsx(TableHeader, {
372
- className: "bg-muted",
373
- children: /* @__PURE__ */ jsxs(TableRow, {
374
- className: "hover:bg-muted h-10",
375
- children: [
376
- /* @__PURE__ */ jsx(TableColumn, {
377
- label: t("product"),
378
- sortable: false
379
- }),
380
- /* @__PURE__ */ jsx(TableColumn, {
381
- label: t("date"),
382
- sortable: false
383
- }),
384
- /* @__PURE__ */ jsx(TableColumn, {
385
- label: t("total"),
386
- sortable: false
387
- })
388
- ]
389
- })
390
- }),
391
- /* @__PURE__ */ jsx(TableBody, {
392
- className: "bg-background",
393
- children: isLoading ? Array(5).fill(0).map((_, index) => /* @__PURE__ */ jsxs(TableRow, { children: [
394
- /* @__PURE__ */ jsx(TableCell, {
395
- className: "px-3 py-4",
396
- children: /* @__PURE__ */ jsxs("div", {
397
- className: "flex items-center space-x-2",
398
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9 rounded-md" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" })]
399
- })
400
- }),
401
- /* @__PURE__ */ jsx(TableCell, {
402
- className: "px-3 py-4",
403
- children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })
404
- }),
405
- /* @__PURE__ */ jsx(TableCell, {
406
- className: "px-3 py-4",
407
- children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })
408
- })
409
- ] }, `skeleton-${index}`)) : ordersList.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
410
- colSpan: 3,
411
- className: "text-muted-foreground px-3 py-8 text-center text-sm",
412
- children: searchTerm ? t("no_matching_orders") : t("no_orders_found")
413
- }) }) : ordersList.map((order) => /* @__PURE__ */ jsxs(TableRow, {
414
- className: "cursor-pointer",
415
- onClick: () => onOrderClick(order),
416
- children: [
417
- /* @__PURE__ */ jsx(TableCell, {
418
- className: "text-muted-foreground px-3 py-4 text-sm",
419
- children: /* @__PURE__ */ jsxs("div", {
420
- className: "flex max-w-[280px] flex-row items-center space-x-3",
421
- children: [order.first_item?.image_url ? /* @__PURE__ */ jsx("img", {
422
- src: order.first_item.image_url,
423
- alt: t("no_image_available"),
424
- width: 42,
425
- height: 42,
426
- className: "h-[42px] w-[42px] flex-shrink-0 rounded-md object-cover"
427
- }) : /* @__PURE__ */ jsx("div", { className: "bg-border ml-1 h-9 w-9 flex-shrink-0 rounded-md" }), /* @__PURE__ */ jsxs("div", {
428
- className: "flex min-w-0 flex-col space-y-1",
429
- children: [/* @__PURE__ */ jsxs("div", {
430
- className: "flex items-center space-x-2",
431
- children: [order.first_item?.title ? /* @__PURE__ */ jsx("span", {
432
- className: "text-foreground truncate text-sm font-medium",
433
- children: order.first_item.title
434
- }) : /* @__PURE__ */ jsx("div", {
435
- className: "bg-muted w-full rounded-lg p-2",
436
- children: /* @__PURE__ */ jsx("div", {
437
- className: "text-muted-foreground text-xs",
438
- children: t("this_product_no_longer_exists")
439
- })
440
- }), order.subscription && /* @__PURE__ */ jsx(StatusBadge, {
441
- color: "blue",
442
- size: "xs",
443
- className: "flex-shrink-0",
444
- children: t("subscription")
445
- })]
446
- }), order.subscription && onSubscriptionClick && /* @__PURE__ */ jsx("button", {
447
- type: "button",
448
- className: "text-foreground hover:text-foreground/80 text-left text-xs transition-colors duration-200 hover:underline",
449
- onClick: (e) => {
450
- e.stopPropagation();
451
- onSubscriptionClick(order.subscription.subscription_token);
452
- },
453
- children: t("view_subscription")
454
- })]
455
- })]
456
- })
457
- }),
458
- /* @__PURE__ */ jsx(TableCell, {
459
- className: "text-muted-foreground px-3 py-4 text-sm whitespace-nowrap",
460
- children: new Date(order.created_at).toLocaleDateString()
461
- }),
462
- /* @__PURE__ */ jsx(TableCell, {
463
- className: "text-foreground px-3 py-4 text-sm whitespace-nowrap",
464
- children: formatOrderTotal(order)
465
- })
466
- ]
467
- }, order.id))
468
- })
469
- ]
470
- })
471
- }),
472
- /* @__PURE__ */ jsx(PaginationFooter, {
473
- currentPage,
474
- totalPages,
475
- pageSize,
476
- totalItems,
477
- cursorPaginationMode: true,
478
- hasNextPage,
479
- hasPrevPage,
480
- onCursorNext: handleNextPage,
481
- onCursorPrev: handlePrevPage
482
- })
483
- ]
484
- });
485
- }
486
- //#endregion
487
- //#region ../../orders/ui/src/lib/format.ts
488
- function startCase(str) {
489
- if (!str) return "";
490
- return str.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
491
- }
492
- function formatCurrency(symbol, value) {
493
- return `${symbol}${Number(value).toFixed(2)}`;
494
- }
495
- //#endregion
496
- //#region ../../orders/ui/src/components/order-status-badge.tsx
497
- const statusColorMap = {
498
- paid: "green",
499
- fulfilled: "green",
500
- delivered: "green",
501
- complete: "green",
502
- pending: "yellow",
503
- unfulfilled: "yellow",
504
- partially_fulfilled: "yellow",
505
- processing: "yellow",
506
- refunded: "red",
507
- cancelled: "red",
508
- failed: "red",
509
- voided: "red"
510
- };
511
- function OrderStatusBadge({ status, className }) {
512
- return /* @__PURE__ */ jsx(StatusBadge, {
513
- color: statusColorMap[status] ?? "gray",
514
- dot: true,
515
- size: "sm",
516
- className,
517
- children: startCase(status)
518
- });
519
- }
520
- //#endregion
521
- //#region ../../orders/ui/src/components/order-detail.tsx
522
- function OrderDetailSkeleton() {
523
- return /* @__PURE__ */ jsxs("div", {
524
- className: "flex flex-col lg:grid lg:grid-cols-8",
525
- children: [/* @__PURE__ */ jsx("div", {
526
- className: "bg-muted flex flex-col items-center px-8 lg:col-span-4",
527
- children: /* @__PURE__ */ jsxs("div", {
528
- className: "w-full max-w-lg py-6",
529
- children: [
530
- /* @__PURE__ */ jsx(Skeleton, { className: "mb-4 h-6 w-48" }),
531
- /* @__PURE__ */ jsx("div", {
532
- className: "space-y-4",
533
- children: /* @__PURE__ */ jsxs("div", {
534
- className: "flex items-center space-x-4",
535
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-24 rounded" }), /* @__PURE__ */ jsxs("div", {
536
- className: "flex-1 space-y-2",
537
- children: [
538
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }),
539
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }),
540
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/4" })
541
- ]
542
- })]
543
- })
544
- }),
545
- /* @__PURE__ */ jsxs("div", {
546
- className: "mt-6 space-y-2",
547
- children: [
548
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }),
549
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }),
550
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }),
551
- /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" })
552
- ]
553
- })
554
- ]
555
- })
556
- }), /* @__PURE__ */ jsx("div", {
557
- className: "bg-background px-8 pt-4 lg:col-span-4",
558
- children: /* @__PURE__ */ jsxs("div", {
559
- className: "mx-auto max-w-lg lg:mx-0 lg:mr-auto",
560
- children: [
561
- /* @__PURE__ */ jsx(Skeleton, { className: "mb-4 h-10 w-full rounded" }),
562
- /* @__PURE__ */ jsxs("div", {
563
- className: "mt-6 space-y-4",
564
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-40" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full rounded" })]
565
- }),
566
- /* @__PURE__ */ jsxs("div", {
567
- className: "mt-6 space-y-4",
568
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-40" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full rounded" })]
569
- }),
570
- /* @__PURE__ */ jsxs("div", {
571
- className: "mt-6 space-y-4",
572
- children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-40" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full rounded" })]
573
- })
574
- ]
575
- })
576
- })]
577
- });
578
- }
579
- function OrderItemRow({ item }) {
580
- return /* @__PURE__ */ jsxs("div", {
581
- className: "flex items-center space-x-4 py-4",
582
- children: [/* @__PURE__ */ jsxs("div", {
583
- className: "relative shrink-0",
584
- children: [/* @__PURE__ */ jsx("div", {
585
- className: "bg-muted h-24 w-24 overflow-hidden rounded",
586
- children: item.image_url ? /* @__PURE__ */ jsx("img", {
587
- src: item.image_url,
588
- alt: item.title,
589
- width: 96,
590
- height: 96,
591
- className: "h-full w-full object-cover"
592
- }) : /* @__PURE__ */ jsx("div", {
593
- className: "text-muted-foreground flex h-full w-full items-center justify-center",
594
- children: "No image"
595
- })
596
- }), item.quantity > 1 && /* @__PURE__ */ jsx("span", {
597
- className: "bg-foreground text-background absolute -top-2 -right-2 z-10 flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium",
598
- children: item.quantity
599
- })]
600
- }), /* @__PURE__ */ jsxs("div", {
601
- className: "flex min-w-0 flex-1 flex-col space-y-0.5",
602
- children: [
603
- /* @__PURE__ */ jsx("p", {
604
- className: "text-foreground truncate text-sm font-medium",
605
- title: item.title,
606
- children: item.title
607
- }),
608
- item.ordered_variant.length > 0 && /* @__PURE__ */ jsx("p", {
609
- className: "text-muted-foreground text-sm",
610
- children: item.ordered_variant.map((v) => v.value).join(" / ")
611
- }),
612
- item.sku && /* @__PURE__ */ jsxs("p", {
613
- className: "text-muted-foreground text-xs",
614
- children: ["SKU: ", item.sku]
615
- }),
616
- item.subscription && /* @__PURE__ */ jsx(StatusBadge, {
617
- color: "blue",
618
- size: "xs",
619
- className: "mt-1 self-start",
620
- children: "Subscription"
621
- }),
622
- /* @__PURE__ */ jsx("p", {
623
- className: "text-foreground text-sm font-medium",
624
- children: item.display_total
625
- }),
626
- item.quantity > 1 && /* @__PURE__ */ jsxs("p", {
627
- className: "text-muted-foreground text-xs",
628
- children: [
629
- item.display_price,
630
- " x ",
631
- item.quantity
632
- ]
633
- })
634
- ]
635
- })]
636
- });
637
- }
638
- function OrderItemsSection({ order }) {
639
- const visibleItems = order.items.filter((item) => item.display_to_customer !== false);
640
- const sym = order.currency_symbol || "$";
641
- return /* @__PURE__ */ jsx("section", {
642
- className: "bg-muted flex w-full flex-col items-center px-8 lg:col-span-4",
643
- children: /* @__PURE__ */ jsxs("div", {
644
- className: "flex w-full max-w-lg flex-col",
645
- children: [
646
- /* @__PURE__ */ jsxs("div", {
647
- className: "mt-4",
648
- children: [/* @__PURE__ */ jsxs("h2", {
649
- className: "text-foreground mb-2 text-lg font-medium",
650
- children: [
651
- "Items (",
652
- visibleItems.length,
653
- ")"
654
- ]
655
- }), /* @__PURE__ */ jsx("hr", { className: "border-border" })]
656
- }),
657
- /* @__PURE__ */ jsx("div", {
658
- className: "divide-border divide-y",
659
- children: visibleItems.map((item) => /* @__PURE__ */ jsx(OrderItemRow, { item }, item.id))
660
- }),
661
- /* @__PURE__ */ jsxs("div", {
662
- className: "border-border mb-4 border-t pt-4",
663
- children: [
664
- /* @__PURE__ */ jsxs("div", {
665
- className: "flex justify-between text-sm",
666
- children: [/* @__PURE__ */ jsx("p", {
667
- className: "text-muted-foreground font-medium",
668
- children: "Subtotal"
669
- }), /* @__PURE__ */ jsx("p", {
670
- className: "text-muted-foreground font-medium",
671
- children: order.sub_total_in_currency
672
- })]
673
- }),
674
- Number(order.discount) > 0 && /* @__PURE__ */ jsxs("div", {
675
- className: "mt-2 flex justify-between text-sm",
676
- children: [/* @__PURE__ */ jsxs("p", {
677
- className: "text-muted-foreground font-medium",
678
- children: ["Discount", order.discount_codes?.length ? ` (${order.discount_codes.join(", ")})` : ""]
679
- }), /* @__PURE__ */ jsxs("p", {
680
- className: "text-muted-foreground font-medium",
681
- children: ["-", order.discount_in_currency]
682
- })]
683
- }),
684
- /* @__PURE__ */ jsxs("div", {
685
- className: "mt-2 flex justify-between text-sm",
686
- children: [/* @__PURE__ */ jsx("p", {
687
- className: "text-muted-foreground font-medium",
688
- children: "Shipping"
689
- }), /* @__PURE__ */ jsx("p", {
690
- className: "text-muted-foreground font-medium",
691
- children: order.free_shipping ? "Free" : order.shipping_total_for_display
692
- })]
693
- }),
694
- /* @__PURE__ */ jsxs("div", {
695
- className: "mt-2 flex justify-between text-sm",
696
- children: [/* @__PURE__ */ jsxs("p", {
697
- className: "text-muted-foreground font-medium",
698
- children: ["Tax", order.price_inclusive_of_tax && order.price_inclusive_tax_name ? ` (${order.price_inclusive_tax_name}, included)` : ""]
699
- }), /* @__PURE__ */ jsx("p", {
700
- className: "text-muted-foreground font-medium",
701
- children: order.tax_in_currency
702
- })]
703
- }),
704
- order.points_applied != null && order.points_applied > 0 && /* @__PURE__ */ jsxs("div", {
705
- className: "mt-2 flex justify-between text-sm",
706
- children: [/* @__PURE__ */ jsxs("p", {
707
- className: "text-muted-foreground font-medium",
708
- children: ["Points Applied", /* @__PURE__ */ jsxs("span", {
709
- className: "text-muted-foreground ml-1 text-xs font-normal",
710
- children: [
711
- "(",
712
- order.points_applied.toLocaleString(),
713
- " ",
714
- order.points_applied === 1 ? "pt" : "pts",
715
- ")"
716
- ]
717
- })]
718
- }), /* @__PURE__ */ jsx("p", {
719
- className: "text-muted-foreground font-medium",
720
- children: `-${formatCurrency(sym, order.points_applied_amount ?? 0)}`
721
- })]
722
- }),
723
- /* @__PURE__ */ jsxs("div", {
724
- className: "mt-4 flex items-center justify-between text-base font-medium",
725
- children: [/* @__PURE__ */ jsx("p", {
726
- className: "text-muted-foreground text-sm font-medium",
727
- children: "Total"
728
- }), /* @__PURE__ */ jsx("p", {
729
- className: "text-foreground text-base font-bold",
730
- children: order.order_total_after_points_redemption != null ? formatCurrency(sym, order.order_total_after_points_redemption) : order.total_in_currency
731
- })]
732
- })
733
- ]
734
- })
735
- ]
736
- })
737
- });
738
- }
739
- function OrderDetailsSection({ order }) {
740
- const paymentDetails = order.payment_details;
741
- const cardDetails = paymentDetails?.details;
742
- return /* @__PURE__ */ jsx("div", {
743
- className: "bg-background px-8 pt-4 lg:col-span-4",
744
- children: /* @__PURE__ */ jsxs("div", {
745
- className: "mx-auto max-w-lg lg:mx-0 lg:mr-auto",
746
- children: [
747
- /* @__PURE__ */ jsx("div", {
748
- className: "border-border mb-6 border-b pb-6",
749
- children: /* @__PURE__ */ jsxs("div", {
750
- className: "flex flex-wrap items-center gap-3",
751
- children: [
752
- /* @__PURE__ */ jsxs("div", {
753
- className: "flex items-center gap-2",
754
- children: [/* @__PURE__ */ jsx("span", {
755
- className: "text-muted-foreground text-sm",
756
- children: "Payment:"
757
- }), /* @__PURE__ */ jsx(OrderStatusBadge, { status: order.payment_status })]
758
- }),
759
- /* @__PURE__ */ jsxs("div", {
760
- className: "flex items-center gap-2",
761
- children: [/* @__PURE__ */ jsx("span", {
762
- className: "text-muted-foreground text-sm",
763
- children: "Fulfillment:"
764
- }), /* @__PURE__ */ jsx(OrderStatusBadge, { status: order.fulfillment_status })]
765
- }),
766
- /* @__PURE__ */ jsxs("div", {
767
- className: "flex items-center gap-2",
768
- children: [/* @__PURE__ */ jsx("span", {
769
- className: "text-muted-foreground text-sm",
770
- children: "Delivery:"
771
- }), /* @__PURE__ */ jsx(OrderStatusBadge, { status: order.delivery_status })]
772
- })
773
- ]
774
- })
775
- }),
776
- /* @__PURE__ */ jsxs("div", {
777
- className: "border-border mb-6 border-b pb-6",
778
- children: [
779
- /* @__PURE__ */ jsx("h3", {
780
- className: "text-foreground mb-3 text-sm/6 font-semibold",
781
- children: "Order Info"
782
- }),
783
- /* @__PURE__ */ jsxs("div", {
784
- className: "divide-border flex divide-x",
785
- children: [/* @__PURE__ */ jsxs("div", {
786
- className: "flex-1 pr-4",
787
- children: [/* @__PURE__ */ jsx("div", {
788
- className: "text-muted-foreground text-sm",
789
- children: "Order Number"
790
- }), /* @__PURE__ */ jsx("div", {
791
- className: "text-foreground font-medium",
792
- children: order.order_number
793
- })]
794
- }), /* @__PURE__ */ jsxs("div", {
795
- className: "flex-1 pl-4 text-right",
796
- children: [/* @__PURE__ */ jsx("div", {
797
- className: "text-muted-foreground text-sm",
798
- children: "Date"
799
- }), /* @__PURE__ */ jsx("div", {
800
- className: "text-foreground font-medium",
801
- children: new Date(order.created_at).toLocaleDateString("en-US", {
802
- year: "numeric",
803
- month: "short",
804
- day: "numeric"
805
- })
806
- })]
807
- })]
808
- }),
809
- order.email && /* @__PURE__ */ jsxs("div", {
810
- className: "mt-3",
811
- children: [/* @__PURE__ */ jsx("div", {
812
- className: "text-muted-foreground text-sm",
813
- children: "Email"
814
- }), /* @__PURE__ */ jsx("div", {
815
- className: "text-foreground text-sm font-medium",
816
- children: order.email
817
- })]
818
- })
819
- ]
820
- }),
821
- paymentDetails && /* @__PURE__ */ jsxs("div", {
822
- className: "border-border mb-6 border-b pb-4",
823
- children: [/* @__PURE__ */ jsx("div", {
824
- className: "text-muted-foreground mb-1 text-sm",
825
- children: "Payment Method"
826
- }), /* @__PURE__ */ jsxs("div", {
827
- className: "text-foreground flex items-center gap-2 text-sm",
828
- children: [cardDetails?.logo_url ? /* @__PURE__ */ jsx("img", {
829
- src: cardDetails.logo_url,
830
- alt: cardDetails.card_type ?? "Card",
831
- className: "h-6 w-9 object-contain",
832
- width: 35,
833
- height: 24
834
- }) : /* @__PURE__ */ jsx("div", {
835
- className: "bg-muted text-muted-foreground flex h-6 w-9 items-center justify-center rounded text-xs",
836
- children: (paymentDetails.payment_title || paymentDetails.payment_type || "P").charAt(0)
837
- }), /* @__PURE__ */ jsxs("span", {
838
- className: "font-medium",
839
- children: [cardDetails?.card_type ? startCase(cardDetails.card_type) : paymentDetails.payment_title || startCase(paymentDetails.payment_type), cardDetails?.last_four ? ` ending in ${cardDetails.last_four}` : ""]
840
- })]
841
- })]
842
- }),
843
- order.ship_to && /* @__PURE__ */ jsxs("div", {
844
- className: "border-border mb-6 border-b pb-4",
845
- children: [/* @__PURE__ */ jsx("div", {
846
- className: "text-muted-foreground mb-1 text-sm",
847
- children: "Shipping Address"
848
- }), /* @__PURE__ */ jsxs("div", {
849
- className: "text-foreground flex items-start gap-2 text-sm",
850
- children: [/* @__PURE__ */ jsx(Truck, { className: "text-muted-foreground mt-0.5 mr-1 h-4 w-4 shrink-0" }), /* @__PURE__ */ jsxs("div", {
851
- className: "flex flex-col",
852
- children: [
853
- order.ship_to.name && /* @__PURE__ */ jsx("span", {
854
- className: "font-medium",
855
- children: order.ship_to.name
856
- }),
857
- order.ship_to.address1 && /* @__PURE__ */ jsx("span", { children: order.ship_to.address1 }),
858
- (order.ship_to.city || order.ship_to.state || order.ship_to.postal_code) && /* @__PURE__ */ jsx("span", { children: [[order.ship_to.city, order.ship_to.state].filter(Boolean).join(", "), order.ship_to.postal_code].filter(Boolean).join(" ") }),
859
- order.ship_to.country_code && /* @__PURE__ */ jsx("span", { children: order.ship_to.country_code })
860
- ]
861
- })]
862
- })]
863
- }),
864
- order.bill_to && /* @__PURE__ */ jsxs("div", {
865
- className: "border-border mb-6 border-b pb-4",
866
- children: [/* @__PURE__ */ jsx("div", {
867
- className: "text-muted-foreground mb-1 text-sm",
868
- children: "Billing Address"
869
- }), /* @__PURE__ */ jsxs("div", {
870
- className: "text-foreground text-sm",
871
- children: [
872
- order.bill_to.name && /* @__PURE__ */ jsx("p", {
873
- className: "font-medium",
874
- children: order.bill_to.name
875
- }),
876
- order.bill_to.address1 && /* @__PURE__ */ jsx("p", { children: order.bill_to.address1 }),
877
- (order.bill_to.city || order.bill_to.state || order.bill_to.postal_code) && /* @__PURE__ */ jsx("p", { children: [[order.bill_to.city, order.bill_to.state].filter(Boolean).join(", "), order.bill_to.postal_code].filter(Boolean).join(" ") }),
878
- order.bill_to.country_code && /* @__PURE__ */ jsx("p", { children: order.bill_to.country_code })
879
- ]
880
- })]
881
- }),
882
- order.shipping_method && /* @__PURE__ */ jsxs("div", {
883
- className: "border-border mb-6 border-b pb-4",
884
- children: [
885
- /* @__PURE__ */ jsx("div", {
886
- className: "text-muted-foreground mb-1 text-sm",
887
- children: "Shipping Method"
888
- }),
889
- /* @__PURE__ */ jsx("div", {
890
- className: "text-foreground text-sm font-medium",
891
- children: order.shipping_method.title
892
- }),
893
- order.shipping_method.delivery_time_estimate && /* @__PURE__ */ jsxs("div", {
894
- className: "text-muted-foreground mt-1 text-xs",
895
- children: ["Est. ", order.shipping_method.delivery_time_estimate]
896
- })
897
- ]
898
- })
899
- ]
900
- })
901
- });
902
- }
903
- function OrderDetail({ token, onNotFound, onError }) {
904
- const { data, isLoading, error } = useOrder(token);
905
- const order = data?.order;
906
- useEffect(() => {
907
- if (!isLoading && error) onError?.(error);
908
- }, [
909
- isLoading,
910
- error,
911
- onError
912
- ]);
913
- useEffect(() => {
914
- if (!isLoading && !error && !order) onNotFound?.();
915
- }, [
916
- isLoading,
917
- error,
918
- order,
919
- onNotFound
920
- ]);
921
- if (isLoading) return /* @__PURE__ */ jsx(OrderDetailSkeleton, {});
922
- if (!order) return null;
923
- return /* @__PURE__ */ jsxs("div", {
924
- className: "flex flex-col lg:grid lg:grid-cols-8",
925
- children: [/* @__PURE__ */ jsx(OrderItemsSection, { order }), /* @__PURE__ */ jsx(OrderDetailsSection, { order })]
926
- });
927
- }
928
- //#endregion
929
- export { OrdersCoreProvider as a, PaginationFooter as i, OrdersList as n, TableColumn as r, OrderDetail as t };
930
-
931
- //# sourceMappingURL=order-detail-iZm_R0TX.mjs.map