feat(notifications): TODO 7 — draft decision toast + email + bell badge
This commit is contained in:
@@ -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'] })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user