'use client'; import { ProTable, ProTableActions } from '@/components/pro-table'; import { getTicket, getTicketList, updateTicketStatus } from '@/services/admin/ticket'; import { useQuery } from '@tanstack/react-query'; import { Button } from '@workspace/ui/components/button'; import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@workspace/ui/components/drawer'; import { ScrollArea } from '@workspace/ui/components/scroll-area'; import { ConfirmButton } from '@workspace/ui/custom-components/confirm-button'; import { cn } from '@workspace/ui/lib/utils'; import { formatDate } from '@workspace/ui/utils'; import { useTranslations } from 'next-intl'; import NextImage from 'next/legacy/image'; import { useEffect, useRef, useState } from 'react'; import { toast } from 'sonner'; import { UserDetail } from '../user/user-detail'; export default function Page() { const t = useTranslations('ticket'); const [ticketId, setTicketId] = useState(null); const [message, setMessage] = useState(''); const { data: ticket, refetch: refetchTicket } = useQuery({ queryKey: ['getTicket', ticketId], queryFn: async () => { const { data } = await getTicket({ id: ticketId, }); return data.data as API.Ticket; }, enabled: !!ticketId, refetchInterval: 5000, }); const scrollRef = useRef(null); useEffect(() => { setTimeout(() => { if (scrollRef.current) { scrollRef.current.children[1]?.scrollTo({ top: scrollRef.current.children[1].scrollHeight, behavior: 'smooth', }); } }, 66); }, [ticket?.follow?.length]); const ref = useRef(null); return ( <> action={ref} header={{ title: t('ticketList'), }} columns={[ { accessorKey: 'title', header: t('title'), }, { accessorKey: 'user_id', header: t('user'), cell: ({ row }) => , }, { accessorKey: 'status', header: t('status.0'), cell: ({ row }) => ( {t(`status.${row.original.status}`)} ), }, { accessorKey: 'updated_at', header: t('updatedAt'), cell: ({ row }) => formatDate(row.getValue('updated_at')), }, ]} params={[ { key: 'status', placeholder: t('status.0'), options: [ { label: t('close'), value: '4', }, ], }, ]} request={async (pagination, filters) => { const { data } = await getTicketList({ ...pagination, ...filters, }); return { list: data.data?.list || [], total: data.data?.total || 0, }; }} actions={{ render(row) { if (row.status !== 4) { return [ , {t('close')} } title={t('confirmClose')} description={t('closeWarning')} onConfirm={async () => { await updateTicketStatus({ id: row.id, status: 4, }); toast.success(t('closeSuccess')); ref.current?.refresh(); }} cancelText={t('cancel')} confirmText={t('confirm')} />, ]; } return [ , ]; }, }} /> { if (!open) setTicketId(null); }} > {ticket?.title}
提现金额:{ticket?.title?.split('-')[1]}
提现方式:{ticket?.description?.split('-')[0]}
{ticket?.description?.split('-')[1].includes('data:image') ? (
收款码:
) : (
提现地址:{ticket?.description?.split('-')[1]}
)}
); }