feat(notifications): TODO 7 — draft decision toast + email + bell badge

This commit is contained in:
Александр Зимин
2026-05-14 14:40:35 +00:00
parent 50d263745a
commit 9050e2427e
21 changed files with 1992 additions and 82 deletions
+36
View File
@@ -664,3 +664,39 @@ export const useRetryWebhookDelivery = () => {
},
})
}
// === Notifications mutations (TODO 7) ===
/**
* Mark одно notification как read. Optimistic update — UI обновляется
* мгновенно, query invalidates после server confirm. Если backend reject'нет,
* onError refetch'нет original state.
*/
export const useMarkNotificationRead = () => {
const qc = useQueryClient()
return useMutation({
mutationFn: async (notificationId: string): Promise<void> => {
await apiClient.post(
`/me/notifications/${encodeURIComponent(notificationId)}/read`,
)
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['notifications', 'me'] })
},
})
}
/**
* Mark все unread notifications as read. Drawer footer button "Mark all read".
*/
export const useMarkAllNotificationsRead = () => {
const qc = useQueryClient()
return useMutation({
mutationFn: async (): Promise<void> => {
await apiClient.post('/me/notifications/read-all')
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['notifications', 'me'] })
},
})
}