'use client'; import { useEffect, useState } from 'react'; import { Card, CardContent } from '@/components/ui/card'; import { NotificationList } from '@/components/notifications/notification-list'; import type { NotificationItem } from '@/types/notifications'; function NotificationsSkeleton() { return (
{[...Array(3)].map((_, i) => (
))}
); } export default function NotificationsPage() { const [notifications, setNotifications] = useState( null ); const [error, setError] = useState(null); useEffect(() => { fetch('/api/notifications') .then((res) => { if (!res.ok) throw new Error(`HTTP ${res.status}`); return res.json(); }) .then((json) => setNotifications(json)) .catch((err) => setError(err.message)); }, []); const handleMarkRead = async (id: string) => { const res = await fetch(`/api/notifications/${id}/read`, { method: 'POST', }); if (!res.ok) { throw new Error('Failed to mark notification as read'); } }; return (

Notifications

{error ? ( Failed to load notifications: {error} ) : notifications === null ? ( ) : ( )}
); }