@acmekit/dashboard 2.13.29 → 2.13.31
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/package.json +9 -9
- package/src/lib/table-display-utils.tsx +44 -75
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acmekit/dashboard",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.31",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"generate:static": "node ./scripts/generate-currencies.js && prettier --write ./src/lib/currencies.ts",
|
|
6
6
|
"dev": "../../../node_modules/.bin/vite",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@acmekit/admin-shared": "2.13.
|
|
43
|
-
"@acmekit/icons": "2.13.
|
|
44
|
-
"@acmekit/js-sdk": "2.13.
|
|
45
|
-
"@acmekit/ui": "4.1.
|
|
42
|
+
"@acmekit/admin-shared": "2.13.31",
|
|
43
|
+
"@acmekit/icons": "2.13.31",
|
|
44
|
+
"@acmekit/js-sdk": "2.13.31",
|
|
45
|
+
"@acmekit/ui": "4.1.27",
|
|
46
46
|
"@ariakit/react": "^0.4.15",
|
|
47
47
|
"@babel/runtime": "^7.26.10",
|
|
48
48
|
"@dnd-kit/core": "^6.1.0",
|
|
@@ -80,10 +80,10 @@
|
|
|
80
80
|
"zod": "3.25.76"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@acmekit/admin-shared": "2.13.
|
|
84
|
-
"@acmekit/admin-vite-plugin": "2.13.
|
|
85
|
-
"@acmekit/types": "2.13.
|
|
86
|
-
"@acmekit/ui-preset": "2.13.
|
|
83
|
+
"@acmekit/admin-shared": "2.13.31",
|
|
84
|
+
"@acmekit/admin-vite-plugin": "2.13.31",
|
|
85
|
+
"@acmekit/types": "2.13.31",
|
|
86
|
+
"@acmekit/ui-preset": "2.13.31"
|
|
87
87
|
},
|
|
88
88
|
"packageManager": "yarn@3.2.1"
|
|
89
89
|
}
|
|
@@ -48,14 +48,14 @@ const formatDate = (date: string | Date, format: 'short' | 'long' | 'relative' =
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Payment status display
|
|
51
|
-
const
|
|
51
|
+
const TransactionStatusBadge = ({ status }: { status: string }) => {
|
|
52
52
|
const getStatusColor = (status: string) => {
|
|
53
53
|
switch (status?.toLowerCase()) {
|
|
54
|
-
case '
|
|
55
|
-
case '
|
|
54
|
+
case 'completed':
|
|
55
|
+
case 'success':
|
|
56
56
|
return 'green'
|
|
57
57
|
case 'pending':
|
|
58
|
-
case '
|
|
58
|
+
case 'processing':
|
|
59
59
|
return 'orange'
|
|
60
60
|
case 'failed':
|
|
61
61
|
case 'canceled':
|
|
@@ -72,21 +72,21 @@ const PaymentStatusBadge = ({ status }: { status: string }) => {
|
|
|
72
72
|
)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
//
|
|
76
|
-
const
|
|
75
|
+
// Processing status display
|
|
76
|
+
const ProcessingStatusBadge = ({ status }: { status: string }) => {
|
|
77
77
|
const getStatusColor = (status: string) => {
|
|
78
78
|
switch (status?.toLowerCase()) {
|
|
79
|
-
case '
|
|
80
|
-
case '
|
|
79
|
+
case 'completed':
|
|
80
|
+
case 'done':
|
|
81
81
|
return 'green'
|
|
82
|
-
case '
|
|
82
|
+
case 'partially_completed':
|
|
83
83
|
case 'preparing':
|
|
84
84
|
return 'orange'
|
|
85
85
|
case 'canceled':
|
|
86
86
|
case 'returned':
|
|
87
87
|
return 'red'
|
|
88
88
|
case 'pending':
|
|
89
|
-
case '
|
|
89
|
+
case 'not_started':
|
|
90
90
|
return 'grey'
|
|
91
91
|
default:
|
|
92
92
|
return 'grey'
|
|
@@ -113,8 +113,8 @@ const GenericStatusBadge = ({ status }: { status: string }) => {
|
|
|
113
113
|
export const DISPLAY_STRATEGIES = {
|
|
114
114
|
// Known semantic types with pixel-perfect display
|
|
115
115
|
status: {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
transaction: (value: any) => <TransactionStatusBadge status={value} />,
|
|
117
|
+
processing: (value: any) => <ProcessingStatusBadge status={value} />,
|
|
118
118
|
default: (value: any) => <GenericStatusBadge status={value} />
|
|
119
119
|
},
|
|
120
120
|
|
|
@@ -139,7 +139,6 @@ export const DISPLAY_STRATEGIES = {
|
|
|
139
139
|
},
|
|
140
140
|
|
|
141
141
|
identifier: {
|
|
142
|
-
order: (value: any) => `#${value}`,
|
|
143
142
|
default: (value: any) => value
|
|
144
143
|
},
|
|
145
144
|
|
|
@@ -235,76 +234,76 @@ export const getDisplayStrategy = (column: any) => {
|
|
|
235
234
|
|
|
236
235
|
// Computed column computation functions
|
|
237
236
|
export const COMPUTED_COLUMN_FUNCTIONS = {
|
|
238
|
-
|
|
239
|
-
// Try
|
|
240
|
-
if (row.
|
|
241
|
-
const fullName = `${row.
|
|
237
|
+
user_name: (row: any) => {
|
|
238
|
+
// Try user object first
|
|
239
|
+
if (row.user?.first_name || row.user?.last_name) {
|
|
240
|
+
const fullName = `${row.user.first_name || ''} ${row.user.last_name || ''}`.trim()
|
|
242
241
|
if (fullName) return fullName
|
|
243
242
|
}
|
|
244
|
-
|
|
243
|
+
|
|
245
244
|
// Fall back to email
|
|
246
|
-
if (row.
|
|
247
|
-
return row.
|
|
245
|
+
if (row.user?.email) {
|
|
246
|
+
return row.user.email
|
|
248
247
|
}
|
|
249
|
-
|
|
248
|
+
|
|
250
249
|
// Fall back to phone
|
|
251
|
-
if (row.
|
|
252
|
-
return row.
|
|
250
|
+
if (row.user?.phone) {
|
|
251
|
+
return row.user.phone
|
|
253
252
|
}
|
|
254
|
-
|
|
253
|
+
|
|
255
254
|
return 'Guest'
|
|
256
255
|
},
|
|
257
|
-
|
|
256
|
+
|
|
258
257
|
address_summary: (row: any, column?: any) => {
|
|
259
258
|
// Determine which address to use based on the column field
|
|
260
259
|
let address = null
|
|
261
|
-
if (column?.field === '
|
|
262
|
-
address = row.
|
|
263
|
-
} else if (column?.field === '
|
|
264
|
-
address = row.
|
|
260
|
+
if (column?.field === 'primary_address_display') {
|
|
261
|
+
address = row.primary_address
|
|
262
|
+
} else if (column?.field === 'secondary_address_display') {
|
|
263
|
+
address = row.secondary_address
|
|
265
264
|
} else {
|
|
266
|
-
// Fallback to
|
|
267
|
-
address = row.
|
|
265
|
+
// Fallback to primary address if no specific field
|
|
266
|
+
address = row.primary_address || row.secondary_address
|
|
268
267
|
}
|
|
269
|
-
|
|
268
|
+
|
|
270
269
|
if (!address) return '-'
|
|
271
|
-
|
|
270
|
+
|
|
272
271
|
// Build address parts in a meaningful order
|
|
273
272
|
const parts = []
|
|
274
|
-
|
|
273
|
+
|
|
275
274
|
// Include street address if available
|
|
276
275
|
if (address.address_1) {
|
|
277
276
|
parts.push(address.address_1)
|
|
278
277
|
}
|
|
279
|
-
|
|
278
|
+
|
|
280
279
|
// City, Province/State, Postal Code
|
|
281
280
|
const locationParts = []
|
|
282
281
|
if (address.city) locationParts.push(address.city)
|
|
283
282
|
if (address.province) locationParts.push(address.province)
|
|
284
283
|
if (address.postal_code) locationParts.push(address.postal_code)
|
|
285
|
-
|
|
284
|
+
|
|
286
285
|
if (locationParts.length > 0) {
|
|
287
286
|
parts.push(locationParts.join(', '))
|
|
288
287
|
}
|
|
289
|
-
|
|
288
|
+
|
|
290
289
|
// Country
|
|
291
290
|
if (address.country_code) {
|
|
292
291
|
parts.push(address.country_code.toUpperCase())
|
|
293
292
|
}
|
|
294
|
-
|
|
293
|
+
|
|
295
294
|
return parts.join(' • ') || '-'
|
|
296
295
|
},
|
|
297
|
-
|
|
296
|
+
|
|
298
297
|
country_code: (row: any) => {
|
|
299
|
-
// Get country code from
|
|
300
|
-
const countryCode = row.
|
|
301
|
-
|
|
298
|
+
// Get country code from primary address
|
|
299
|
+
const countryCode = row.primary_address?.country_code
|
|
300
|
+
|
|
302
301
|
if (!countryCode) return <div className="flex w-full justify-center">-</div>
|
|
303
|
-
|
|
302
|
+
|
|
304
303
|
// Get country information
|
|
305
304
|
const country = getCountryByIso2(countryCode)
|
|
306
305
|
const displayName = country?.display_name || countryCode.toUpperCase()
|
|
307
|
-
|
|
306
|
+
|
|
308
307
|
// Display country flag with tooltip - centered in the cell
|
|
309
308
|
return (
|
|
310
309
|
<div className="flex w-full items-center justify-center">
|
|
@@ -326,28 +325,6 @@ export const COMPUTED_COLUMN_FUNCTIONS = {
|
|
|
326
325
|
}
|
|
327
326
|
}
|
|
328
327
|
|
|
329
|
-
// Entity-specific column overrides
|
|
330
|
-
export const ENTITY_COLUMN_OVERRIDES = {
|
|
331
|
-
orders: {
|
|
332
|
-
// Override for customer column that combines multiple fields
|
|
333
|
-
customer: {
|
|
334
|
-
accessor: (row: any) => {
|
|
335
|
-
// Complex logic for combining fields
|
|
336
|
-
const shipping = row.shipping_address
|
|
337
|
-
const customer = row.customer
|
|
338
|
-
|
|
339
|
-
if (shipping?.first_name || shipping?.last_name) {
|
|
340
|
-
return `${shipping.first_name || ''} ${shipping.last_name || ''}`.trim()
|
|
341
|
-
}
|
|
342
|
-
if (customer?.first_name || customer?.last_name) {
|
|
343
|
-
return `${customer.first_name || ''} ${customer.last_name || ''}`.trim()
|
|
344
|
-
}
|
|
345
|
-
return customer?.email || 'Guest'
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
328
|
// Helper function to get entity-specific accessor
|
|
352
329
|
export const getEntityAccessor = (entity: string, fieldName: string, column?: any) => {
|
|
353
330
|
// Check if this is a computed column
|
|
@@ -358,15 +335,7 @@ export const getEntityAccessor = (entity: string, fieldName: string, column?: an
|
|
|
358
335
|
return (row: any) => computationFn(row, column)
|
|
359
336
|
}
|
|
360
337
|
}
|
|
361
|
-
|
|
362
|
-
const entityOverrides = ENTITY_COLUMN_OVERRIDES[entity as keyof typeof ENTITY_COLUMN_OVERRIDES]
|
|
363
|
-
if (entityOverrides) {
|
|
364
|
-
const fieldOverride = entityOverrides[fieldName as keyof typeof entityOverrides]
|
|
365
|
-
if (fieldOverride?.accessor) {
|
|
366
|
-
return fieldOverride.accessor
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
338
|
+
|
|
370
339
|
// Default accessor using dot notation
|
|
371
340
|
return (row: any) => getNestedValue(row, fieldName)
|
|
372
341
|
}
|