mirror of
https://github.com/temetro/temetro.git
synced 2026-07-27 20:28:57 +00:00
288d14758f
Auto-generate notifications on patient record create/update (fan out to the other clinic members, pushed live), and wire the sidebar bell to real data via a useNotifications hook over the shared socket: live unread badge, real list, mark-all-read on open. Drops the hardcoded sample array and the dead "View all" link. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
889 B
TypeScript
33 lines
889 B
TypeScript
import { apiFetch } from "@/lib/api-client";
|
|
|
|
// A notification for the signed-in user. Mirrors the backend
|
|
// `src/types/notification.ts`.
|
|
export type Notification = {
|
|
id: string;
|
|
type: string;
|
|
text: string;
|
|
read: boolean;
|
|
entityType: string | null;
|
|
entityId: string | null;
|
|
actorName: string | null;
|
|
actorInitials: string | null;
|
|
createdAt: string;
|
|
};
|
|
|
|
export type NotificationsResponse = {
|
|
notifications: Notification[];
|
|
unread: number;
|
|
};
|
|
|
|
export function listNotifications(): Promise<NotificationsResponse> {
|
|
return apiFetch<NotificationsResponse>("/api/notifications");
|
|
}
|
|
|
|
export function markNotificationRead(id: string): Promise<void> {
|
|
return apiFetch<void>(`/api/notifications/${id}/read`, { method: "PATCH" });
|
|
}
|
|
|
|
export function markAllNotificationsRead(): Promise<void> {
|
|
return apiFetch<void>("/api/notifications/read-all", { method: "POST" });
|
|
}
|