- Expand NotificationRepository (unread list paginated, count, markRead ownership-scoped); new ActivityLogRepository (create, findByProject paginated) with deterministic created_at+id ordering - NotificationService (notifyOnEvent, resolveTargets for 8 event types, injectable SseBroadcaster for M8) + ActivityLogService (logActivity, listByProject) - NotificationEvent/SseEvent/SseBroadcaster types in lib/types - APIs: GET /api/notifications, POST /api/notifications/:id/read, GET /api/projects/:projectId/activity - Screens: notifications list + MarkReadButton, NotificationBadge in Header, project activity page + ProjectNav link - Unit tests for both repositories and services (28 new)
28 lines
887 B
TypeScript
28 lines
887 B
TypeScript
import { redirect } from 'next/navigation';
|
|
import { getCurrentUser, toPublicUser } from '@/lib/auth/getCurrentUser';
|
|
import { createNotificationService } from '@/lib/api/services';
|
|
import { Header } from '@/components/layout/Header';
|
|
import { NotificationList } from '@/components/notifications/NotificationList';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export default async function NotificationsPage() {
|
|
const user = await getCurrentUser();
|
|
if (!user) {
|
|
redirect('/login');
|
|
}
|
|
|
|
const service = createNotificationService();
|
|
const { items } = service.listUnread(user.id, 1);
|
|
|
|
return (
|
|
<div className="min-h-screen bg-gray-50">
|
|
<Header user={toPublicUser(user)} />
|
|
<main className="mx-auto max-w-2xl space-y-6 p-6">
|
|
<h1 className="text-2xl font-bold">通知</h1>
|
|
<NotificationList notifications={items} />
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|