import { Head, Link, router } from '@inertiajs/react'; import { Bell, CheckCheck } from 'lucide-react'; import { PageHeading } from '@/components/page-heading'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import type { Paginated } from '@/types'; type PortalNotification = { id: string; data: { message: string; url?: string; reference?: string; }; read_at: string | null; created_at: string; }; export default function NotificationsIndex({ notifications, }: { notifications: Paginated; }) { function openNotification(notification: PortalNotification) { router.post(`/notificacoes/${notification.id}/ler`); } return ( <> router.post('/notificacoes/ler-todas') } > Marcar todas como lidas } /> {notifications.data.map((notification) => ( openNotification(notification)} className={cn( 'flex w-full gap-4 border-b p-5 text-left last:border-0 hover:bg-slate-50 dark:hover:bg-slate-900', notification.read_at === null && 'bg-primary/5', )} > {notification.data.message} {new Intl.DateTimeFormat('pt-PT', { dateStyle: 'medium', timeStyle: 'short', }).format( new Date(notification.created_at), )} {notification.read_at === null && ( )} ))} {notifications.data.length === 0 && ( Não existem notificações. )} {notifications.last_page > 1 && ( {notifications.links.map((link, index) => ( {link.url ? ( ) : ( )} ))} )} > ); } NotificationsIndex.layout = { breadcrumbs: [{ title: 'Notificações', href: '/notificacoes' }], };
{notification.data.message}
{new Intl.DateTimeFormat('pt-PT', { dateStyle: 'medium', timeStyle: 'short', }).format( new Date(notification.created_at), )}