import { useNotification } from '@/features/notifications/hooks/useNotifications' import { Drawer, Stack, Text, Badge, Skeleton, Box, Group } from '@mantine/core' import { DataTable, type Column } from '@/components/ui/DataTable' import classes from '@/components/UserDrawer.module.css' interface Props { notificationId: number | null opened: boolean onClose: () => void } const RECIPIENT_STATUS_LABELS: Record = { pending: { label: 'В очереди', color: 'gray' }, sent: { label: 'Доставлено', color: 'green' }, failed: { label: 'Ошибка', color: 'red' }, } export default function NotificationDetailsDrawer({ notificationId, opened, onClose }: Props) { const { data: notification, isLoading } = useNotification(notificationId) const columns: Column[] = [ { key: 'user', header: 'Пользователь', cell: (r) => {r.user?.full_name || `ID ${r.user_id}`} }, { key: 'status', header: 'Статус', width: 120, cell: (r) => { const statusInfo = RECIPIENT_STATUS_LABELS[r.status || ''] || { label: r.status || '—', color: 'gray' } return {statusInfo.label} } }, { key: 'error', header: 'Лог ошибки', cell: (r) => {r.error_message || '—'} } ] return ( Детали уведомления {notification && ID {notification.id}} {isLoading ? ( ) : !notification ? ( Уведомление не найдено ) : ( Содержимое {notification.title}
Получатели ({notification.recipients?.length || 0}) r.id!} minWidth={400} empty={{ title: 'Нет получателей' }} /> )} ) }