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