Przejdź do głównej zawartości

Notifications

Vista ma dwa osobne systemy powiadomień - toasty (ephemeral) i bell notifications (persistent).


graph TB
subgraph ToastSystem["Toast Notifications (Provider-based)"]
NotificationContext[NotificationContext]
NotificationProvider[NotificationProvider]
ToastContainer[NotificationContainer]
useNotification[useNotification hook]
end
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]
end
subgraph Storage["Storage Layer"]
LocalStorage[(localStorage<br/>vista-notifications-userId)]
CustomEvent{{CustomEvent<br/>vista-notifications-changed}}
end
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:

TypeUżycieAuto-dismiss
successOperacja zakończona sukcesem3s
errorBłąd operacji5s
warningOstrzeżenie4s
infoInformacja3s

Użycie:

const { showNotification } = useNotification();
showNotification({
type: 'success',
title: 'Zapisano',
message: 'Wizyta została zapisana',
});

Persistent powiadomienia w “dzwonku”:

TypeWyzwalaczOpis
appointment-reminder30 min przed wizytąPrzypomnienie o wizycie
soap-missingFinalizacja wizytyWizyta bez pełnego SOAP
ai-suggestionsPo generowaniuAI wygenerowało sugestie
onboarding-skipSkip onboardingPrzypomnienie o ustawieniach
infoRóżneOgólne informacje

sequenceDiagram
participant Dashboard
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
alt Not exists
Hook1->>Hook1: addNotification()
Hook1->>LS: setItem(key, notifications)
Hook1->>Event: dispatchEvent('vista-notifications-changed')
Event-->>Hook2: Event received
Hook2->>LS: getItem(key)
Hook2->>Hook2: Parse & setState
end
Note over Hook1,Hook2: Race condition risk!<br/>If event fails, Hook2 is desync

CechaToastBell
PersistenceEphemeral (auto-dismiss)Persistent (localStorage)
ArchitectureProvider-based (single source)Hook-based (multiple instances)
SyncVia ContextVia CustomEvent
StorageIn-memorylocalStorage
PositionBottom-right cornerTop toolbar bell icon

ComponentTypOpis
NotificationProviderContextZarządza toast notifications
NotificationContainerUIRenderuje toasty
useNotificationHookAPI do pokazywania toastów
useNotificationsHookBell notifications (problematyczny!)
NotificationPanelUIPanel po kliknięciu dzwonka
NotificationBellUIIkonka dzwonka z badge

IDSeverityDescription
P2-013MEDIUMDwa osobne systemy powiadomień (toasts vs bell)
P2-014MEDIUMuseNotifications nie jest Provider-based - 11 instancji z własnym state
P2-015MEDIUMcheckAppointmentReminders może tworzyć duplikaty

graph TB
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]
end
subgraph Consumers["Consumers"]
C1[UnifiedTopToolbar]
C2[Dashboard]
C3[NotificationPanel]
C4[Components...]
end
NotificationsProvider --> ToastAPI
NotificationsProvider --> BellAPI
ToastAPI --> C1
BellAPI --> C1
BellAPI --> C2
BellAPI --> C3