Notifications
Architecture
Toast functions
All located in src/lib/show-notifications.tsx:
| Function | Use case |
|---|---|
showSuccessToast(title, message) | Successful mutation |
showFailedToast(title, message) | Failed operation |
showInfoToast(title, message) | Informational |
showWarningToast(title, message) | Warning |
handleServerSuccess signature
handleServerSuccess(
request?, // mutation input variables
response?, // mutation response data
translationKey?, // becomes notification title (use t() key)
invalidateQueryKeys?,
message? // becomes notification message (app title / context)
)
Notification triggers
| Event | Title | Message |
|---|---|---|
| Application created | t('success.created') | variables.input.title |
| Application updated | t('success.updated') | data.title from response |
| Comment added | t('success.commented') | "Domain · AppTitle · Visibility" |
| Document reviewed | t('success.reviewed') | App title (optional) |
| Applicant CRUD | t('success.*') | application?.title from context |
Message format
The message field uses · as separator for structured context:
"Domain · Application Title · Visibility"
Examples:
"Application · My Tax App · Internal""Document · My Tax App · External""My Tax App"— plain app title for create/update events
parseContext() in notification-panel.tsx splits on · → { label, title, visibility }.
Key files
| File | Purpose |
|---|---|
src/stores/notification-store.ts | Zustand store: unread count, flush queue, settings |
src/lib/show-notifications.tsx | Toast helper functions |
src/features/notifications/notification-flusher.tsx | Flushes queue to backend; polls unread count every 30s |
src/features/notifications/notification-bell.tsx | Bell icon with unread badge |
src/features/notifications/notification-panel.tsx | Sheet panel: list, mark-read, settings |
src/features/notifications/hooks/use-notifications.ts | All GraphQL hooks |
src/components/layout/authenticated-layout.tsx | Mounts NotificationFlusher and NotificationBell |
Adding a new notification source
- Call
showSuccessToast(title, appTitle)on mutation success — that's sufficient for most cases - For hooks using
handleServerSuccess, pass app title as 5th argument - For hooks inside
ApplicationProvider, useuseApplicationContext()to getapplication?.title - The flusher persists everything automatically — no extra wiring needed
See also
- Frontend Rules: Notifications — full implementation reference
- Comments & Messaging