import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { cn } from '@/lib/utils'; import { SharedData } from '@/types/global'; import { Link, router, usePage } from '@inertiajs/react'; import { format, formatDistanceToNow } from 'date-fns'; import { Bell } from 'lucide-react'; import { Button } from './ui/button'; import { ScrollArea } from './ui/scroll-area'; const Notification = () => { const { notifications, translate } = usePage().props; const { button, frontend, dashboard } = translate; return (

{dashboard.notifications}

{notifications.length > 0 ? ( notifications.map(({ id, data, created_at }) => { const time = formatDistanceToNow(new Date(created_at), { addSuffix: true }); const timeText = time.slice(0, 1).toUpperCase() + time.slice(1); return (

{data.title}

{timeText} ); }) ) : (

{frontend.no_unread_notifications}

)}
); }; export default Notification;