♻️ refactor: Enhance log pages with Badge component and update translations
This commit is contained in:
@@ -6,6 +6,7 @@ import { OrderLink } from '@/components/order-link';
|
||||
import { ProTable } from '@/components/pro-table';
|
||||
import { filterBalanceLog } from '@/services/admin/log';
|
||||
import { formatDate } from '@/utils/common';
|
||||
import { Badge } from '@workspace/ui/components/badge';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
@@ -55,7 +56,7 @@ export default function BalanceLogPage() {
|
||||
{
|
||||
accessorKey: 'type',
|
||||
header: t('column.type'),
|
||||
cell: ({ row }) => getBalanceTypeText(row.original.type),
|
||||
cell: ({ row }) => <Badge>{getBalanceTypeText(row.original.type)}</Badge>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'timestamp',
|
||||
|
||||
@@ -6,6 +6,7 @@ import { OrderLink } from '@/components/order-link';
|
||||
import { ProTable } from '@/components/pro-table';
|
||||
import { filterCommissionLog } from '@/services/admin/log';
|
||||
import { formatDate } from '@/utils/common';
|
||||
import { Badge } from '@workspace/ui/components/badge';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
@@ -50,7 +51,7 @@ export default function CommissionLogPage() {
|
||||
{
|
||||
accessorKey: 'type',
|
||||
header: t('column.type'),
|
||||
cell: ({ row }) => getCommissionTypeText(row.original.type),
|
||||
cell: ({ row }) => <Badge>{getCommissionTypeText(row.original.type)}</Badge>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'timestamp',
|
||||
|
||||
@@ -6,6 +6,7 @@ import { OrderLink } from '@/components/order-link';
|
||||
import { ProTable } from '@/components/pro-table';
|
||||
import { filterGiftLog } from '@/services/admin/log';
|
||||
import { formatDate } from '@/utils/common';
|
||||
import { Badge } from '@workspace/ui/components/badge';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
@@ -16,6 +17,14 @@ export default function GiftLogPage() {
|
||||
// 获取今日日期作为默认值
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
const getGiftTypeText = (type: number) => {
|
||||
const typeText = t(`type.${type}`);
|
||||
if (typeText === `log.type.${type}`) {
|
||||
return `${t('unknown')} (${type})`;
|
||||
}
|
||||
return typeText;
|
||||
};
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.get('date') || today,
|
||||
user_id: sp.get('user_id') ? Number(sp.get('user_id')) : undefined,
|
||||
@@ -52,6 +61,11 @@ export default function GiftLogPage() {
|
||||
header: t('column.balance'),
|
||||
cell: ({ row }) => <Display type='currency' value={row.original.balance} />,
|
||||
},
|
||||
{
|
||||
accessorKey: 'type',
|
||||
header: t('column.type'),
|
||||
cell: ({ row }) => <Badge>{getGiftTypeText(row.original.type)}</Badge>,
|
||||
},
|
||||
{ accessorKey: 'remark', header: t('column.remark') },
|
||||
{
|
||||
accessorKey: 'timestamp',
|
||||
|
||||
@@ -33,13 +33,14 @@ export default function LoginLogPage() {
|
||||
{
|
||||
accessorKey: 'user',
|
||||
header: t('column.user'),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: 'method',
|
||||
header: t('column.method'),
|
||||
cell: ({ row }) => <span className='capitalize'>{row.original.method}</span>,
|
||||
cell: ({ row }) => (
|
||||
<div>
|
||||
<Badge className='capitalize'>{row.original.method}</Badge>{' '}
|
||||
<UserDetail id={Number(row.original.user_id)} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: 'login_ip',
|
||||
header: t('column.ip'),
|
||||
|
||||
@@ -5,6 +5,7 @@ import { IpLink } from '@/components/ip-link';
|
||||
import { ProTable } from '@/components/pro-table';
|
||||
import { filterRegisterLog } from '@/services/admin/log';
|
||||
import { formatDate } from '@/utils/common';
|
||||
import { Badge } from '@workspace/ui/components/badge';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
@@ -36,10 +37,14 @@ export default function RegisterLogPage() {
|
||||
},
|
||||
{
|
||||
accessorKey: 'auth_method',
|
||||
header: t('column.method'),
|
||||
cell: ({ row }) => <span className='capitalize'>{row.original.auth_method}</span>,
|
||||
header: t('column.identifier'),
|
||||
cell: ({ row }) => (
|
||||
<div className='flex items-center'>
|
||||
<Badge className='capitalize'>{row.original.auth_method}</Badge>
|
||||
<span className='ml-1 text-sm'>{row.original.identifier}</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{ accessorKey: 'identifier', header: t('column.identifier') },
|
||||
{
|
||||
accessorKey: 'register_ip',
|
||||
header: t('column.ip'),
|
||||
|
||||
@@ -5,6 +5,7 @@ import { OrderLink } from '@/components/order-link';
|
||||
import { ProTable } from '@/components/pro-table';
|
||||
import { filterResetSubscribeLog } from '@/services/admin/log';
|
||||
import { formatDate } from '@/utils/common';
|
||||
import { Badge } from '@workspace/ui/components/badge';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
@@ -14,6 +15,14 @@ export default function ResetSubscribeLogPage() {
|
||||
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
const getResetSubscribeTypeText = (type: number) => {
|
||||
const typeText = t(`type.${type}`);
|
||||
if (typeText === `log.type.${type}`) {
|
||||
return `${t('unknown')} (${type})`;
|
||||
}
|
||||
return typeText;
|
||||
};
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.get('date') || today,
|
||||
user_subscribe_id: sp.get('user_subscribe_id')
|
||||
@@ -37,7 +46,11 @@ export default function ResetSubscribeLogPage() {
|
||||
<UserSubscribeDetail id={Number(row.original.user_subscribe_id)} enabled hoverCard />
|
||||
),
|
||||
},
|
||||
{ accessorKey: 'type', header: t('column.type') },
|
||||
{
|
||||
accessorKey: 'type',
|
||||
header: t('column.type'),
|
||||
cell: ({ row }) => <Badge>{getResetSubscribeTypeText(row.original.type)}</Badge>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'order_no',
|
||||
header: t('column.orderNo'),
|
||||
|
||||
@@ -146,13 +146,15 @@ export function UserDetail({ id }: { id: number }) {
|
||||
|
||||
if (!id) return '--';
|
||||
|
||||
const identifier =
|
||||
data?.auth_methods.find((m) => m.auth_type === 'email')?.auth_identifier ||
|
||||
data?.auth_methods[0]?.auth_identifier;
|
||||
|
||||
return (
|
||||
<HoverCard>
|
||||
<HoverCardTrigger asChild>
|
||||
<Button variant='link' className='p-0' asChild>
|
||||
<Link href={`/dashboard/user?user_id=${id}`}>
|
||||
{data?.auth_methods[0]?.auth_identifier || t('loading')}
|
||||
</Link>
|
||||
<Link href={`/dashboard/user?user_id=${id}`}>{identifier || t('loading')}</Link>
|
||||
</Button>
|
||||
</HoverCardTrigger>
|
||||
<HoverCardContent>
|
||||
|
||||
Reference in New Issue
Block a user