feat: notifications temps réel — cloche Supabase Realtime - #8
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughCette PR ajoute un système complet de notifications en temps réel pour les rendez-vous cliniques. Un hook Realtime Supabase détecte les nouveaux rendez-vous filtrés par clinique, affiche des toasts formatés en français et expose un compteur de notifications non lues. Un composant NotificationBell dans la barre supérieure affiche ce compteur, gère un panneau déroulant avec actions de marquage lu et navigation. ChangesNotifications en temps réel pour rendez-vous
Sequence DiagramsequenceDiagram
participant User as Utilisateur
participant Topbar as Topbar + NotificationBell
participant Hook as useRealtimeNotifications
participant Supabase as Supabase Realtime
participant DB as BD appointments
User->>Topbar: Charge la page
Topbar->>Hook: Appelle le hook (clinicId)
Hook->>Supabase: S'abonne au canal clinic-appointments-{clinicId}
DB->>Supabase: Nouvel INSERT appointment
Supabase->>Hook: Événement INSERT (clinic_id match)
Hook->>Hook: Fetch details (patient, service)
Hook->>Hook: Crée RealtimeNotification
Hook->>Topbar: setNotifications (prepend + cap 50)
Hook->>Topbar: unreadCount++ (read === false)
Topbar->>User: Badge cloche mise à jour
User->>Topbar: Clique sur cloche
Topbar->>Topbar: Panel ouvert, lance timer 1500ms
Topbar->>Hook: markAllRead()
Hook->>Topbar: unreadCount = 0
Topbar->>User: Affiche liste (read === true)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Résumé
appointments INSERTfiltré parclinic_idChangements
lib/hooks/use-realtime-notifications.ts— hook Realtime avec client stable (useRef), cleanup propre, callback de navigation injectablecomponents/notifications/notification-bell.tsx— cloche + badge + dropdown, router Next.js, timer cleanup sur unmountcomponents/layout/topbar.tsx— intégration deNotificationBellsupabase/migrations/001_realtime_appointments.sql— activation RLS Realtime surappointmentsSécurité
appointmentsajoutée àsupabase_realtimepublication → filtreclinic_idappliqué côté serveur avec RLSuseRef→ pas de fuite de channelTest
/app/appointmentsSummary by CodeRabbit
Release Notes