diff --git a/frontend/src/pages/developer/users/components/columns.ts b/frontend/src/pages/developer/users/components/columns.ts index 7b956b8..3ab5a08 100644 --- a/frontend/src/pages/developer/users/components/columns.ts +++ b/frontend/src/pages/developer/users/components/columns.ts @@ -76,7 +76,6 @@ export function getColumns(actions: { header: () => t('developer.users.columns.balance'), cell: ({ row }) => { const balance = row.getValue('balance') as number - const expiryAt = row.original.expiry_at const billingType = row.original.application?.billing_type if (balance === -1) { @@ -84,25 +83,9 @@ export function getColumns(actions: { } if (billingType === 'subscription') { - if (!expiryAt) - return h('span', { class: 'text-muted-foreground' }, '-') - try { - const date = new Date(expiryAt as string) - if (Number.isNaN(date.getTime())) - return '-' - const now = new Date() - if (date < now) { - return h(Badge, { variant: 'destructive' }, () => t('developer.users.expiry.expired')) - } - const daysLeft = Math.ceil((date.getTime() - now.getTime()) / (1000 * 60 * 60 * 24)) - return h('div', { class: 'flex flex-col' }, [ - h('span', { class: 'text-green-600 font-medium' }, `${daysLeft} ${t('developer.users.expiry.daysLeft')}`), - h('span', { class: 'text-xs text-muted-foreground' }, date.toLocaleDateString('zh-CN')), - ]) - } - catch { + if (balance === null || balance === undefined) return '-' - } + return h('span', { class: balance > 0 ? 'text-green-600 font-medium' : 'text-muted-foreground' }, balance.toFixed(2)) } if (balance === null || balance === undefined) @@ -111,6 +94,42 @@ export function getColumns(actions: { return h('span', { class: balance > 0 ? 'text-green-600 font-medium' : 'text-muted-foreground' }, balance.toFixed(2)) }, }, + { + accessorKey: 'expiry_at', + header: () => t('developer.users.columns.expiryAt'), + cell: ({ row }) => { + const expiryAt = row.getValue('expiry_at') as string + const billingType = row.original.application?.billing_type + + if (billingType !== 'subscription') { + return h('span', { class: 'text-muted-foreground' }, '-') + } + + if (!expiryAt) { + return h('span', { class: 'text-muted-foreground' }, '-') + } + + try { + const date = new Date(expiryAt) + if (Number.isNaN(date.getTime())) + return '-' + + const now = new Date() + if (date < now) { + return h(Badge, { variant: 'destructive' }, () => t('developer.users.expiry.expired')) + } + + const daysLeft = Math.ceil((date.getTime() - now.getTime()) / (1000 * 60 * 60 * 24)) + return h('div', { class: 'flex flex-col' }, [ + h('span', { class: 'text-green-600 font-medium' }, `${daysLeft} ${t('developer.users.expiry.daysLeft')}`), + h('span', { class: 'text-xs text-muted-foreground' }, date.toLocaleDateString('zh-CN')), + ]) + } + catch { + return '-' + } + }, + }, { accessorKey: 'last_login_at', header: () => t('developer.users.columns.lastLoginAt'), diff --git a/frontend/src/pages/developer/users/components/data-table.vue b/frontend/src/pages/developer/users/components/data-table.vue index a4572fd..8db1801 100644 --- a/frontend/src/pages/developer/users/components/data-table.vue +++ b/frontend/src/pages/developer/users/components/data-table.vue @@ -53,6 +53,8 @@ const columnLabels: Record = { 'email': 'developer.users.columns.email', 'application.name': 'developer.users.columns.application', 'online_status': 'developer.users.columns.status', + 'balance': 'developer.users.columns.balance', + 'expiry_at': 'developer.users.columns.expiryAt', 'last_login_at': 'developer.users.columns.lastLoginAt', 'created_at': 'developer.users.columns.createdAt', }