Vista ma dwa osobne systemy powiadomień - toasty (ephemeral) i bell notifications (persistent).
subgraph ToastSystem["Toast Notifications (Provider-based)"]
NotificationContext[NotificationContext]
NotificationProvider[NotificationProvider]
ToastContainer[NotificationContainer]
useNotification[useNotification hook]
subgraph BellSystem["Bell Notifications (Hook-based)"]
useNotifications1[useNotifications #1<br/>UnifiedTopToolbar]
useNotifications2[useNotifications #2<br/>Dashboard]
useNotifications3[useNotifications #3<br/>NotificationPanel]
useNotifications4[useNotifications #4<br/>useVisitEditor]
useNotificationsN[useNotifications #N<br/>...więcej instancji]
subgraph Storage["Storage Layer"]
LocalStorage[(localStorage<br/>vista-notifications-userId)]
CustomEvent{{CustomEvent<br/>vista-notifications-changed}}
NotificationProvider --> NotificationContext
NotificationContext --> useNotification
useNotification --> ToastContainer
useNotifications1 --> LocalStorage
useNotifications2 --> LocalStorage
useNotifications3 --> LocalStorage
useNotifications4 --> LocalStorage
useNotificationsN --> LocalStorage
LocalStorage -.-> CustomEvent
CustomEvent -.-> useNotifications1
CustomEvent -.-> useNotifications2
CustomEvent -.-> useNotifications3
Krótkie, auto-dismissable powiadomienia:
| Type | Użycie | Auto-dismiss |
|---|
success | Operacja zakończona sukcesem | 3s |
error | Błąd operacji | 5s |
warning | Ostrzeżenie | 4s |
info | Informacja | 3s |
Użycie:
const { showNotification } = useNotification();
message: 'Wizyta została zapisana',
Persistent powiadomienia w “dzwonku”:
| Type | Wyzwalacz | Opis |
|---|
appointment-reminder | 30 min przed wizytą | Przypomnienie o wizycie |
soap-missing | Finalizacja wizyty | Wizyta bez pełnego SOAP |
ai-suggestions | Po generowaniu | AI wygenerowało sugestie |
onboarding-skip | Skip onboarding | Przypomnienie o ustawieniach |
info | Różne | Ogólne informacje |
participant Hook1 as useNotifications #1
participant Hook2 as useNotifications #2
participant LS as localStorage
participant Event as CustomEvent
Dashboard->>Hook1: checkAppointmentReminders()
Hook1->>Hook1: Check if notif exists in local state
Hook1->>Hook1: addNotification()
Hook1->>LS: setItem(key, notifications)
Hook1->>Event: dispatchEvent('vista-notifications-changed')
Event-->>Hook2: Event received
Hook2->>Hook2: Parse & setState
Note over Hook1,Hook2: Race condition risk!<br/>If event fails, Hook2 is desync
| Cecha | Toast | Bell |
|---|
| Persistence | Ephemeral (auto-dismiss) | Persistent (localStorage) |
| Architecture | Provider-based (single source) | Hook-based (multiple instances) |
| Sync | Via Context | Via CustomEvent |
| Storage | In-memory | localStorage |
| Position | Bottom-right corner | Top toolbar bell icon |
| Component | Typ | Opis |
|---|
NotificationProvider | Context | Zarządza toast notifications |
NotificationContainer | UI | Renderuje toasty |
useNotification | Hook | API do pokazywania toastów |
useNotifications | Hook | Bell notifications (problematyczny!) |
NotificationPanel | UI | Panel po kliknięciu dzwonka |
NotificationBell | UI | Ikonka dzwonka z badge |
| ID | Severity | Description |
|---|
| P2-013 | MEDIUM | Dwa osobne systemy powiadomień (toasts vs bell) |
| P2-014 | MEDIUM | useNotifications nie jest Provider-based - 11 instancji z własnym state |
| P2-015 | MEDIUM | checkAppointmentReminders może tworzyć duplikaty |
subgraph UnifiedSystem["Unified Notification System"]
NotificationsProvider[NotificationsProvider<br/>single source of truth]
ToastAPI[useToast hook<br/>ephemeral, auto-dismiss]
BellAPI[useBellNotifications hook<br/>persistent, localStorage]
subgraph Consumers["Consumers"]
NotificationsProvider --> ToastAPI
NotificationsProvider --> BellAPI