@fluid-app/portal-sdk 0.1.149 → 0.1.151

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 (90) hide show
  1. package/dist/{AppDownloadScreen-sGvzVEOC.cjs → AppDownloadScreen-CjKkw4Fg.cjs} +2 -2
  2. package/dist/{AppDownloadScreen-sGvzVEOC.cjs.map → AppDownloadScreen-CjKkw4Fg.cjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-D8Y7JAgO.mjs → AppDownloadScreen-DRnjxlvT.mjs} +2 -2
  4. package/dist/{AppDownloadScreen-D8Y7JAgO.mjs.map → AppDownloadScreen-DRnjxlvT.mjs.map} +1 -1
  5. package/dist/{AppDownloadScreen-B1_C7kjK.cjs → AppDownloadScreen-ooVsEvs8.cjs} +2 -2
  6. package/dist/{ContactsScreen-DuKE5ruf.cjs → ContactsScreen-BTff-1nA.cjs} +2 -2
  7. package/dist/{ContactsScreen-DtABz7O7.mjs → ContactsScreen-Cy5bom0o.mjs} +2 -2
  8. package/dist/{ContactsScreen-DtABz7O7.mjs.map → ContactsScreen-Cy5bom0o.mjs.map} +1 -1
  9. package/dist/{ContactsScreen-psnV3fcP.cjs → ContactsScreen-IfYXlJhs.cjs} +2 -2
  10. package/dist/{ContactsScreen-psnV3fcP.cjs.map → ContactsScreen-IfYXlJhs.cjs.map} +1 -1
  11. package/dist/{FluidProvider-BbMqSBkY.mjs → FluidProvider-BdfmEGWq.mjs} +2 -2
  12. package/dist/{FluidProvider-BbMqSBkY.mjs.map → FluidProvider-BdfmEGWq.mjs.map} +1 -1
  13. package/dist/{FluidProvider-C6WODD6y.cjs → FluidProvider-DNrnrUMP.cjs} +2 -2
  14. package/dist/{FluidProvider-C6WODD6y.cjs.map → FluidProvider-DNrnrUMP.cjs.map} +1 -1
  15. package/dist/{MessagingScreen-gbTy8V_o.mjs → MessagingScreen-B90e8S3J.mjs} +3 -3
  16. package/dist/{MessagingScreen-gbTy8V_o.mjs.map → MessagingScreen-B90e8S3J.mjs.map} +1 -1
  17. package/dist/{MessagingScreen-DSU_xyHK.cjs → MessagingScreen-J0CN90BV.cjs} +3 -3
  18. package/dist/{MessagingScreen-DSU_xyHK.cjs.map → MessagingScreen-J0CN90BV.cjs.map} +1 -1
  19. package/dist/{MessagingScreen-B5lqBpVo.cjs → MessagingScreen-mVyTAxP0.cjs} +2 -2
  20. package/dist/{OrdersScreen-BXlGNk8k.cjs → OrdersScreen-CwrDNuJd.cjs} +85 -235
  21. package/dist/OrdersScreen-CwrDNuJd.cjs.map +1 -0
  22. package/dist/{OrdersScreen-B4xeL-Kg.mjs → OrdersScreen-DWBMyuuW.mjs} +87 -237
  23. package/dist/OrdersScreen-DWBMyuuW.mjs.map +1 -0
  24. package/dist/{OrdersScreen-CR2NZAGm.cjs → OrdersScreen-Ygf_IvG8.cjs} +3 -2
  25. package/dist/{ProductsScreen-DG_SMNs5.cjs → ProductsScreen-B9h7P0pF.cjs} +3 -3
  26. package/dist/{ProductsScreen-C8wwsfu0.cjs → ProductsScreen-BiTzo11P.cjs} +3 -3
  27. package/dist/{ProductsScreen-C8wwsfu0.cjs.map → ProductsScreen-BiTzo11P.cjs.map} +1 -1
  28. package/dist/{ProductsScreen--hkyw5c3.mjs → ProductsScreen-R8wkxAQz.mjs} +3 -3
  29. package/dist/{ProductsScreen--hkyw5c3.mjs.map → ProductsScreen-R8wkxAQz.mjs.map} +1 -1
  30. package/dist/{ProductsScreen-IbgDLX51.mjs → ProductsScreen-icFY3n_C.mjs} +3 -8
  31. package/dist/{ProfileScreen-CvtEh4hl.cjs → ProfileScreen-DT_ihepQ.cjs} +2 -2
  32. package/dist/{ProfileScreen-B3bK-8Lp.mjs → ProfileScreen-OKbwvvjy.mjs} +2 -2
  33. package/dist/{ProfileScreen-B3bK-8Lp.mjs.map → ProfileScreen-OKbwvvjy.mjs.map} +1 -1
  34. package/dist/{ProfileScreen-k9HsbdhW.cjs → ProfileScreen-Spy0wH4C.cjs} +2 -2
  35. package/dist/{ProfileScreen-k9HsbdhW.cjs.map → ProfileScreen-Spy0wH4C.cjs.map} +1 -1
  36. package/dist/{ShareablesScreen-Caf2fI3S.cjs → ShareablesScreen-BTvAr7Ok.cjs} +3 -3
  37. package/dist/{ShareablesScreen-B8ZsEkgi.mjs → ShareablesScreen-CHmLiKBq.mjs} +4 -4
  38. package/dist/{ShareablesScreen-B8ZsEkgi.mjs.map → ShareablesScreen-CHmLiKBq.mjs.map} +1 -1
  39. package/dist/{ShareablesScreen-B0JMhiKA.cjs → ShareablesScreen-DzN2T7WM.cjs} +4 -4
  40. package/dist/{ShareablesScreen-B0JMhiKA.cjs.map → ShareablesScreen-DzN2T7WM.cjs.map} +1 -1
  41. package/dist/{ShareablesScreen-C2zLeoy7.mjs → ShareablesScreen-bDjb5T1-.mjs} +3 -9
  42. package/dist/{ShopScreen-BVD2rPsc.cjs → ShopScreen-BW2Dx21M.cjs} +5 -5
  43. package/dist/ShopScreen-BW2Dx21M.cjs.map +1 -0
  44. package/dist/{ShopScreen-DGQuhCjL.cjs → ShopScreen-DnZsZ9_o.cjs} +2 -2
  45. package/dist/{ShopScreen-gE3t8H83.mjs → ShopScreen-DzloqmdT.mjs} +5 -5
  46. package/dist/ShopScreen-DzloqmdT.mjs.map +1 -0
  47. package/dist/{SubscriptionsScreen-OkgAzsMr.cjs → SubscriptionsScreen-9rur531Y.cjs} +4 -4
  48. package/dist/SubscriptionsScreen-9rur531Y.cjs.map +1 -0
  49. package/dist/{SubscriptionsScreen-CU49ip-B.cjs → SubscriptionsScreen-CSiEOTPS.cjs} +2 -2
  50. package/dist/{SubscriptionsScreen-B5uCnkDP.mjs → SubscriptionsScreen-DpPl_eEV.mjs} +4 -4
  51. package/dist/SubscriptionsScreen-DpPl_eEV.mjs.map +1 -0
  52. package/dist/index.cjs +32 -32
  53. package/dist/index.mjs +32 -32
  54. package/dist/order-status-badge-C5K03hR8.cjs +592 -0
  55. package/dist/order-status-badge-C5K03hR8.cjs.map +1 -0
  56. package/dist/order-status-badge-CzCxrkzq.mjs +556 -0
  57. package/dist/order-status-badge-CzCxrkzq.mjs.map +1 -0
  58. package/dist/{portal_tenant-z_4uJF7r.cjs → portal_tenant-BTRzzEQu.cjs} +5 -5
  59. package/dist/portal_tenant-BTRzzEQu.cjs.map +1 -0
  60. package/dist/{portal_tenant-D9tdph5J.mjs → portal_tenant-BuhowW58.mjs} +5 -5
  61. package/dist/portal_tenant-BuhowW58.mjs.map +1 -0
  62. package/dist/{use-current-user-Cj2_q6uf.mjs → use-current-user-CdCeH7yF.mjs} +2 -2
  63. package/dist/{use-current-user-Cj2_q6uf.mjs.map → use-current-user-CdCeH7yF.mjs.map} +1 -1
  64. package/dist/{use-current-user-0N-2bZRJ.cjs → use-current-user-cyO8A9sS.cjs} +2 -2
  65. package/dist/{use-current-user-0N-2bZRJ.cjs.map → use-current-user-cyO8A9sS.cjs.map} +1 -1
  66. package/dist/{use-fluid-api-DzyyTeeh.mjs → use-fluid-api-BEaf_TzG.mjs} +2 -2
  67. package/dist/{use-fluid-api-DzyyTeeh.mjs.map → use-fluid-api-BEaf_TzG.mjs.map} +1 -1
  68. package/dist/{use-fluid-api-gTgB7jKG.cjs → use-fluid-api-BjIXhuT7.cjs} +2 -2
  69. package/dist/{use-fluid-api-gTgB7jKG.cjs.map → use-fluid-api-BjIXhuT7.cjs.map} +1 -1
  70. package/dist/{use-portal-products-client-CYenp38s.cjs → use-portal-products-client-BDE9BflI.cjs} +2 -2
  71. package/dist/{use-portal-products-client-CYenp38s.cjs.map → use-portal-products-client-BDE9BflI.cjs.map} +1 -1
  72. package/dist/{use-portal-products-client-cK-Vbzv_.mjs → use-portal-products-client-DBxWCLx0.mjs} +2 -2
  73. package/dist/{use-portal-products-client-cK-Vbzv_.mjs.map → use-portal-products-client-DBxWCLx0.mjs.map} +1 -1
  74. package/dist/{use-portal-shareables-api-CwSezl14.cjs → use-portal-shareables-api-CH38IaKt.cjs} +3 -3
  75. package/dist/{use-portal-shareables-api-CwSezl14.cjs.map → use-portal-shareables-api-CH38IaKt.cjs.map} +1 -1
  76. package/dist/{use-portal-shareables-api-CCRQARQM.mjs → use-portal-shareables-api-CaXsju8A.mjs} +3 -3
  77. package/dist/{use-portal-shareables-api-CCRQARQM.mjs.map → use-portal-shareables-api-CaXsju8A.mjs.map} +1 -1
  78. package/package.json +14 -14
  79. package/dist/OrdersScreen-B4xeL-Kg.mjs.map +0 -1
  80. package/dist/OrdersScreen-BXlGNk8k.cjs.map +0 -1
  81. package/dist/ShopScreen-BVD2rPsc.cjs.map +0 -1
  82. package/dist/ShopScreen-gE3t8H83.mjs.map +0 -1
  83. package/dist/SubscriptionsScreen-B5uCnkDP.mjs.map +0 -1
  84. package/dist/SubscriptionsScreen-OkgAzsMr.cjs.map +0 -1
  85. package/dist/order-status-badge-CCK76FjJ.mjs +0 -262
  86. package/dist/order-status-badge-CCK76FjJ.mjs.map +0 -1
  87. package/dist/order-status-badge-CDdk0tyF.cjs +0 -304
  88. package/dist/order-status-badge-CDdk0tyF.cjs.map +0 -1
  89. package/dist/portal_tenant-D9tdph5J.mjs.map +0 -1
  90. package/dist/portal_tenant-z_4uJF7r.cjs.map +0 -1
@@ -0,0 +1,592 @@
1
+ require("./chunk-9hOWP6kD.cjs");
2
+ const require_src = require("./src-DvJ4o9Sq.cjs");
3
+ const require_SearchSort = require("./SearchSort-29u6qhlf.cjs");
4
+ let react = require("react");
5
+ let _tanstack_react_query = require("@tanstack/react-query");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let lucide_react = require("lucide-react");
8
+ //#region ../../orders/core/src/orders-api-context.ts
9
+ const OrdersApiContext = (0, react.createContext)(null);
10
+ const OrdersApiProvider = OrdersApiContext.Provider;
11
+ function useOrdersApi() {
12
+ const api = (0, react.useContext)(OrdersApiContext);
13
+ if (!api) throw new Error("useOrdersApi must be used within an OrdersCoreProvider");
14
+ return api;
15
+ }
16
+ //#endregion
17
+ //#region ../../orders/core/src/provider.tsx
18
+ function OrdersCoreProvider({ api, children }) {
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OrdersApiProvider, {
20
+ value: api,
21
+ children
22
+ });
23
+ }
24
+ //#endregion
25
+ //#region ../../orders/core/src/query-keys.ts
26
+ const ordersKeys = {
27
+ all: ["orders"],
28
+ list: (params) => [
29
+ ...ordersKeys.all,
30
+ "list",
31
+ params
32
+ ],
33
+ detail: (orderToken) => [
34
+ ...ordersKeys.all,
35
+ "detail",
36
+ orderToken
37
+ ]
38
+ };
39
+ const portalTenantOrdersKeys = {
40
+ all: ["portalTenantOrders"],
41
+ list: (params) => [
42
+ ...portalTenantOrdersKeys.all,
43
+ "list",
44
+ params
45
+ ],
46
+ detail: (id) => [
47
+ ...portalTenantOrdersKeys.all,
48
+ "detail",
49
+ id
50
+ ]
51
+ };
52
+ //#endregion
53
+ //#region ../../orders/core/src/hooks/use-customer-orders.ts
54
+ function useCustomerOrders(params, options) {
55
+ const api = useOrdersApi();
56
+ return (0, _tanstack_react_query.useQuery)({
57
+ queryKey: ordersKeys.list(params),
58
+ queryFn: () => {
59
+ if (!api.fetchCustomerOrders) throw new Error("fetchCustomerOrders not implemented on this OrdersApi");
60
+ return api.fetchCustomerOrders(params);
61
+ },
62
+ enabled: options?.enabled ?? true
63
+ });
64
+ }
65
+ //#endregion
66
+ //#region ../../orders/core/src/hooks/use-portal-tenant-order.ts
67
+ function usePortalTenantOrder(id, options) {
68
+ const api = useOrdersApi();
69
+ return (0, _tanstack_react_query.useQuery)({
70
+ queryKey: portalTenantOrdersKeys.detail(id),
71
+ queryFn: () => {
72
+ if (!api.fetchOrderById) throw new Error("fetchOrderById not implemented on this OrdersApi");
73
+ return api.fetchOrderById(id);
74
+ },
75
+ enabled: (options?.enabled ?? true) && !!id
76
+ });
77
+ }
78
+ //#endregion
79
+ //#region ../../orders/core/src/utils/format-order-total.ts
80
+ function formatOrderTotal(order) {
81
+ if (order.order_total_after_points_redemption != null) return `${order.currency_symbol || "$"}${Number(order.order_total_after_points_redemption).toFixed(2)}`;
82
+ return order.total_display_amount || `${order.currency_symbol || "$"}${Number(order.amount).toFixed(2)}`;
83
+ }
84
+ //#endregion
85
+ //#region ../../orders/ui/src/components/pagination-footer.tsx
86
+ function PaginationFooter({ currentPage, totalPages, pageSize, totalItems, onPageChange, cursorPaginationMode, hasNextPage, hasPrevPage, onCursorNext, onCursorPrev }) {
87
+ const isCursor = !!cursorPaginationMode;
88
+ const isPrevDisabled = isCursor ? !hasPrevPage : currentPage === 1;
89
+ const isNextDisabled = isCursor ? !hasNextPage : totalPages === 0 || currentPage === totalPages;
90
+ const handlePrevClick = () => {
91
+ if (isCursor) onCursorPrev?.();
92
+ else onPageChange?.(currentPage - 1);
93
+ };
94
+ const handleNextClick = () => {
95
+ if (isCursor) onCursorNext?.();
96
+ else onPageChange?.(currentPage + 1);
97
+ };
98
+ const displayText = (() => {
99
+ const start = totalItems === 0 ? 0 : (currentPage - 1) * pageSize + 1;
100
+ const end = Math.min(currentPage * pageSize, totalItems);
101
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
102
+ "Showing ",
103
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
104
+ className: "font-medium",
105
+ children: start
106
+ }),
107
+ " to",
108
+ " ",
109
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
110
+ className: "font-medium",
111
+ children: end
112
+ }),
113
+ " of",
114
+ " ",
115
+ /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("div", {
124
+ className: "border-border flex items-center justify-between border-t px-4 py-3 sm:px-6",
125
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
126
+ className: "flex flex-1 justify-between sm:hidden",
127
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
128
+ type: "button",
129
+ onClick: handlePrevClick,
130
+ disabled: isPrevDisabled,
131
+ className: require_src.cn(buttonBase, "border-border bg-background text-foreground hover:bg-accent rounded-md border"),
132
+ children: "Previous"
133
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
134
+ type: "button",
135
+ onClick: handleNextClick,
136
+ disabled: isNextDisabled,
137
+ className: require_src.cn(buttonBase, "border-border bg-background text-foreground hover:bg-accent ml-3 rounded-md border"),
138
+ children: "Next"
139
+ })]
140
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
141
+ className: "hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",
142
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
143
+ className: "text-muted-foreground text-xs",
144
+ children: displayText
145
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
146
+ "aria-label": "Pagination",
147
+ className: "isolate inline-flex -space-x-px rounded-md shadow-sm",
148
+ children: [
149
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
150
+ type: "button",
151
+ onClick: handlePrevClick,
152
+ disabled: isPrevDisabled,
153
+ className: require_src.cn(buttonBase, "border-border text-muted-foreground hover:bg-accent rounded-l-md border"),
154
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
155
+ className: "sr-only",
156
+ children: "Previous"
157
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "h-4 w-4" })]
158
+ }),
159
+ /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("button", {
168
+ type: "button",
169
+ onClick: handleNextClick,
170
+ disabled: isNextDisabled,
171
+ className: require_src.cn(buttonBase, "border-border text-muted-foreground hover:bg-accent rounded-r-md border"),
172
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
173
+ className: "sr-only",
174
+ children: "Next"
175
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.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__ */ (0, react_jsx_runtime.jsxs)("span", {
205
+ className: require_src.cn("inline-flex items-center gap-1 rounded-full font-medium whitespace-nowrap capitalize", colorStyles[color], sizeStyles[size], className),
206
+ children: [dot && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_src.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__ */ (0, react_jsx_runtime.jsx)(require_src.TableHead, {
215
+ className: require_src.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__ */ (0, react_jsx_runtime.jsxs)("div", {
218
+ className: "relative flex items-center",
219
+ children: [label, sortable && chevronUpIcon && chevronDownIcon && /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("div", {
222
+ className: "flex flex-col",
223
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
224
+ src: chevronUpIcon,
225
+ alt: "",
226
+ width: 12,
227
+ height: 12,
228
+ className: require_src.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__ */ (0, react_jsx_runtime.jsx)("img", {
230
+ src: chevronDownIcon,
231
+ alt: "",
232
+ width: 12,
233
+ height: 12,
234
+ className: require_src.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] = (0, react.useState)(null);
245
+ const [currentPage, setCurrentPage] = (0, react.useState)(1);
246
+ const [searchTerm, setSearchTerm] = (0, react.useState)("");
247
+ const { data, isLoading } = useCustomerOrders({
248
+ customerId,
249
+ limit: pageSize,
250
+ search: searchTerm || void 0,
251
+ cursor: cursor || void 0,
252
+ sort: "-created_at"
253
+ }, { enabled: !!customerId });
254
+ const handleSearchChange = (0, react.useCallback)((term) => {
255
+ setSearchTerm(term);
256
+ setCursor(null);
257
+ setCurrentPage(1);
258
+ }, []);
259
+ const handleNextPage = (0, react.useCallback)(() => {
260
+ const nextCursor = data?.meta?.pagination?.next_cursor;
261
+ if (nextCursor) {
262
+ setCursor(nextCursor);
263
+ setCurrentPage((p) => p + 1);
264
+ }
265
+ }, [data?.meta?.pagination?.next_cursor]);
266
+ const handlePrevPage = (0, react.useCallback)(() => {
267
+ const prevCursor = data?.meta?.pagination?.prev_cursor;
268
+ if (prevCursor) {
269
+ setCursor(prevCursor);
270
+ setCurrentPage((p) => Math.max(1, p - 1));
271
+ } else {
272
+ setCursor(null);
273
+ setCurrentPage(1);
274
+ }
275
+ }, [data?.meta?.pagination?.prev_cursor]);
276
+ const ordersList = data?.orders || [];
277
+ const pagination = data?.meta?.pagination;
278
+ const totalItems = pagination?.total_count ?? ordersList.length;
279
+ const totalPages = pagination?.total_pages ?? Math.max(1, Math.ceil(totalItems / pageSize));
280
+ const hasNextPage = !!pagination?.next_cursor;
281
+ const hasPrevPage = !!pagination?.prev_cursor;
282
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
283
+ className: "border-border overflow-hidden rounded-lg border shadow-sm",
284
+ children: [
285
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
286
+ className: "flex justify-end p-3",
287
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
288
+ className: "w-full max-w-sm",
289
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SearchSort.SearchSort, {
290
+ searchValue: searchTerm,
291
+ onSearchChange: handleSearchChange,
292
+ placeholder: t("search_orders")
293
+ })
294
+ })
295
+ }),
296
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
297
+ className: "block md:hidden",
298
+ children: isLoading ? Array(5).fill(0).map((_, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
299
+ className: "border-border border-b p-4",
300
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
301
+ className: "flex space-x-3",
302
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-12 w-12 rounded-md" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
303
+ className: "flex-1 space-y-2",
304
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-4 w-3/4" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-3 w-1/2" })]
305
+ })]
306
+ })
307
+ }, `skeleton-${index}`)) : ordersList.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
308
+ className: "text-muted-foreground px-3 py-8 text-center text-sm",
309
+ children: searchTerm ? t("no_matching_orders") : t("no_orders_found")
310
+ }) : ordersList.map((order) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
311
+ className: "border-border hover:bg-accent cursor-pointer border-b p-4 transition-colors duration-200 ease-in-out last:border-b-0",
312
+ onClick: () => onOrderClick(order),
313
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
314
+ className: "flex items-start space-x-3",
315
+ children: [order.first_item?.image_url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
316
+ src: order.first_item.image_url,
317
+ alt: t("no_image_available"),
318
+ width: 48,
319
+ height: 48,
320
+ className: "h-12 w-12 flex-shrink-0 rounded-md object-cover"
321
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "bg-border h-12 w-12 flex-shrink-0 rounded-md" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
322
+ className: "w-0 min-w-0 flex-1",
323
+ children: [
324
+ order.first_item?.title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
325
+ className: "text-foreground truncate text-sm font-medium",
326
+ children: order.first_item.title
327
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
328
+ className: "bg-muted rounded-lg p-2",
329
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
330
+ className: "text-muted-foreground text-xs",
331
+ children: t("this_product_no_longer_exists")
332
+ })
333
+ }),
334
+ order.subscription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusBadge, {
335
+ color: "blue",
336
+ size: "xs",
337
+ className: "mt-1",
338
+ children: t("subscription")
339
+ }),
340
+ order.subscription?.subscription_token && onSubscriptionClick && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
341
+ type: "button",
342
+ className: "text-foreground hover:text-foreground/80 mt-1 inline-block text-xs transition-colors duration-200 hover:underline",
343
+ onClick: (e) => {
344
+ e.stopPropagation();
345
+ onSubscriptionClick(order.subscription.subscription_token);
346
+ },
347
+ children: t("view_subscription")
348
+ }),
349
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
350
+ className: "mt-2 grid grid-cols-3 gap-x-4 gap-y-1 text-sm",
351
+ children: [
352
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
353
+ className: "text-muted-foreground block text-xs",
354
+ children: t("date")
355
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
356
+ className: "text-muted-foreground",
357
+ children: new Date(order.created_at).toLocaleDateString()
358
+ })] }),
359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
360
+ className: "text-muted-foreground block text-xs",
361
+ children: t("status")
362
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusBadge, {
363
+ color: order.order_status === "completed" || order.order_status === "delivered" || order.order_status === "shipped" ? "green" : order.order_status === "cancelled" || order.order_status === "returned" ? "red" : "yellow",
364
+ size: "xs",
365
+ children: order.order_status
366
+ })] }),
367
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
368
+ className: "text-muted-foreground block text-xs",
369
+ children: t("total")
370
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
371
+ className: "text-foreground font-medium",
372
+ children: formatOrderTotal(order)
373
+ })] })
374
+ ]
375
+ })
376
+ ]
377
+ })]
378
+ })
379
+ }, order.id))
380
+ }),
381
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
382
+ className: "hidden md:block",
383
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.Table, {
384
+ className: "min-w-full table-fixed",
385
+ children: [
386
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("colgroup", { children: [
387
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: "w-2/5 min-w-[240px]" }),
388
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: "w-[20%] min-w-[100px]" }),
389
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: "w-[20%] min-w-[100px]" }),
390
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("col", { className: "w-[20%] min-w-[100px]" })
391
+ ] }),
392
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableHeader, {
393
+ className: "bg-muted",
394
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.TableRow, {
395
+ className: "hover:bg-muted h-10",
396
+ children: [
397
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableColumn, {
398
+ label: t("product"),
399
+ sortable: false
400
+ }),
401
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableColumn, {
402
+ label: t("date"),
403
+ sortable: false
404
+ }),
405
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableColumn, {
406
+ label: t("status"),
407
+ sortable: false
408
+ }),
409
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableColumn, {
410
+ label: t("total"),
411
+ sortable: false
412
+ })
413
+ ]
414
+ })
415
+ }),
416
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableBody, {
417
+ className: "bg-background",
418
+ children: isLoading ? Array(5).fill(0).map((_, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.TableRow, { children: [
419
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
420
+ className: "px-3 py-4",
421
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
422
+ className: "flex items-center space-x-2",
423
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-9 w-9 rounded-md" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-4 w-32" })]
424
+ })
425
+ }),
426
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
427
+ className: "px-3 py-4",
428
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-4 w-24" })
429
+ }),
430
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
431
+ className: "px-3 py-4",
432
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-4 w-20" })
433
+ }),
434
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
435
+ className: "px-3 py-4",
436
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-4 w-24" })
437
+ })
438
+ ] }, `skeleton-${index}`)) : ordersList.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableRow, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
439
+ colSpan: 4,
440
+ className: "text-muted-foreground px-3 py-8 text-center text-sm",
441
+ children: searchTerm ? t("no_matching_orders") : t("no_orders_found")
442
+ }) }) : ordersList.map((order) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.TableRow, {
443
+ className: "cursor-pointer",
444
+ onClick: () => onOrderClick(order),
445
+ children: [
446
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
447
+ className: "text-muted-foreground px-3 py-4 text-sm",
448
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
449
+ className: "flex max-w-[280px] flex-row items-center space-x-3",
450
+ children: [order.first_item?.image_url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
451
+ src: order.first_item.image_url,
452
+ alt: t("no_image_available"),
453
+ width: 42,
454
+ height: 42,
455
+ className: "h-[42px] w-[42px] flex-shrink-0 rounded-md object-cover"
456
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "bg-border ml-1 h-9 w-9 flex-shrink-0 rounded-md" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
457
+ className: "flex min-w-0 flex-col space-y-1",
458
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
459
+ className: "flex items-center space-x-2",
460
+ children: [order.first_item?.title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
461
+ className: "text-foreground truncate text-sm font-medium",
462
+ children: order.first_item.title
463
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
464
+ className: "bg-muted w-full rounded-lg p-2",
465
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
466
+ className: "text-muted-foreground text-xs",
467
+ children: t("this_product_no_longer_exists")
468
+ })
469
+ }), order.subscription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusBadge, {
470
+ color: "blue",
471
+ size: "xs",
472
+ className: "flex-shrink-0",
473
+ children: t("subscription")
474
+ })]
475
+ }), order.subscription?.subscription_token && onSubscriptionClick && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
476
+ type: "button",
477
+ className: "text-foreground hover:text-foreground/80 text-left text-xs transition-colors duration-200 hover:underline",
478
+ onClick: (e) => {
479
+ e.stopPropagation();
480
+ onSubscriptionClick(order.subscription.subscription_token);
481
+ },
482
+ children: t("view_subscription")
483
+ })]
484
+ })]
485
+ })
486
+ }),
487
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
488
+ className: "text-muted-foreground px-3 py-4 text-sm whitespace-nowrap",
489
+ children: new Date(order.created_at).toLocaleDateString()
490
+ }),
491
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
492
+ className: "px-3 py-4 text-sm",
493
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusBadge, {
494
+ color: order.order_status === "completed" || order.order_status === "delivered" || order.order_status === "shipped" ? "green" : order.order_status === "cancelled" || order.order_status === "returned" ? "red" : "yellow",
495
+ size: "xs",
496
+ children: order.order_status
497
+ })
498
+ }),
499
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.TableCell, {
500
+ className: "text-foreground px-3 py-4 text-sm whitespace-nowrap",
501
+ children: formatOrderTotal(order)
502
+ })
503
+ ]
504
+ }, order.id))
505
+ })
506
+ ]
507
+ })
508
+ }),
509
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaginationFooter, {
510
+ currentPage,
511
+ totalPages,
512
+ pageSize,
513
+ totalItems,
514
+ cursorPaginationMode: true,
515
+ hasNextPage,
516
+ hasPrevPage,
517
+ onCursorNext: handleNextPage,
518
+ onCursorPrev: handlePrevPage
519
+ })
520
+ ]
521
+ });
522
+ }
523
+ //#endregion
524
+ //#region ../../orders/ui/src/lib/format.ts
525
+ function startCase(str) {
526
+ if (!str) return "";
527
+ return str.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
528
+ }
529
+ //#endregion
530
+ //#region ../../orders/ui/src/components/order-status-badge.tsx
531
+ const statusColorMap = {
532
+ paid: "green",
533
+ fulfilled: "green",
534
+ delivered: "green",
535
+ complete: "green",
536
+ pending: "yellow",
537
+ unfulfilled: "yellow",
538
+ partially_fulfilled: "yellow",
539
+ processing: "yellow",
540
+ refunded: "red",
541
+ cancelled: "red",
542
+ failed: "red",
543
+ voided: "red"
544
+ };
545
+ function OrderStatusBadge({ status, className }) {
546
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusBadge, {
547
+ color: statusColorMap[status] ?? "gray",
548
+ dot: true,
549
+ size: "sm",
550
+ className,
551
+ children: startCase(status)
552
+ });
553
+ }
554
+ //#endregion
555
+ Object.defineProperty(exports, "OrderStatusBadge", {
556
+ enumerable: true,
557
+ get: function() {
558
+ return OrderStatusBadge;
559
+ }
560
+ });
561
+ Object.defineProperty(exports, "OrdersCoreProvider", {
562
+ enumerable: true,
563
+ get: function() {
564
+ return OrdersCoreProvider;
565
+ }
566
+ });
567
+ Object.defineProperty(exports, "OrdersList", {
568
+ enumerable: true,
569
+ get: function() {
570
+ return OrdersList;
571
+ }
572
+ });
573
+ Object.defineProperty(exports, "PaginationFooter", {
574
+ enumerable: true,
575
+ get: function() {
576
+ return PaginationFooter;
577
+ }
578
+ });
579
+ Object.defineProperty(exports, "TableColumn", {
580
+ enumerable: true,
581
+ get: function() {
582
+ return TableColumn;
583
+ }
584
+ });
585
+ Object.defineProperty(exports, "usePortalTenantOrder", {
586
+ enumerable: true,
587
+ get: function() {
588
+ return usePortalTenantOrder;
589
+ }
590
+ });
591
+
592
+ //# sourceMappingURL=order-status-badge-C5K03hR8.cjs.map