"use client"; import {ColumnDef} from "@tanstack/react-table"; import {NotificationLogWithRelations} from "@/db/services/notification-log"; import {humanReadableDate} from "@/utils/date-formatting"; import {CheckCircle2, XCircle} from "lucide-react"; import {Badge} from "@/components/ui/badge"; import {NotificationLogModal} from "@/components/wrappers/dashboard/admin/notifications/logs/notification-log-modal"; import {getChannelIcon} from "@/components/wrappers/dashboard/admin/channels/helpers/common"; export function notificationLogsColumns(): ColumnDef[] { return [ { accessorKey: "success", header: "Status", cell: ({row}) => { const status = row.original.success ? "delivered" : "failed"; return( {getStatusIcon(row.original.success)} {status} ) } }, { accessorKey: "channel", header: "Channel", cell: ({row}) => { const channel = row.original.channel return (
{getChannelIcon(channel?.provider ?? "")}
{channel?.name}
) } }, { accessorKey: "sentAt", header: "Sent At", cell: ({row}) => { const sentAt = humanReadableDate(row.original.sentAt) return (
{sentAt}
) } }, { accessorKey: "policy", header: "Event Kind", cell: ({ row }) => { const eventKind = row.original.policy?.event; if (!eventKind) { return (
No event
); } return (
{eventKind}
); } }, { accessorKey: "details", header: "Details", cell: ({row}) => { return (
); } } ]; } export const getStatusIcon = (status: boolean) => { switch (status) { case true: return case false: return } } export const getStatusColor = (status: string) => { switch (status) { case "delivered": return "bg-green-100 dark:bg-green-100/10" case "success": return "bg-green-100 dark:bg-green-100/10" case "failed": return "bg-red-100 dark:bg-red-100/10" case "pending": return "bg-orange-100 dark:bg-orange-100/10" } }