feat(admin-ui): Phase B frontend — notifications preferences route + UI

This commit is contained in:
Александр Зимин
2026-05-15 14:56:48 +00:00
parent 300fd12d6c
commit e2fc3bcbe0
7 changed files with 332 additions and 4 deletions
+21
View File
@@ -7,6 +7,7 @@ import {
type CascadePlan,
type ChangelogDiff,
type ChangelogResponse,
type NotificationPreferences,
type NotificationsResponse,
type SchemaDraft,
type SchemaReviewQueuePage,
@@ -851,3 +852,23 @@ export const myNotificationsQuery = (unreadOnly = false, limit = 20) =>
export const useMyNotifications = (unreadOnly = false, limit = 20) =>
useQuery(myNotificationsQuery(unreadOnly, limit))
/**
* Phase B — per-channel notification preferences для current user. GET — single
* row (no pagination), 401 если anonymous. Default semantics filled in
* backend-side когда DB row missing (email=true / express=false / telegram=false).
*/
export const myNotificationPreferencesQuery = () =>
queryOptions({
queryKey: ['notifications', 'me', 'preferences'] as const,
queryFn: async (): Promise<NotificationPreferences> => {
const { data } = await apiClient.get<NotificationPreferences>(
'/me/notifications/preferences',
)
return data
},
staleTime: 60_000, // prefs не меняются часто, кэш дольше
})
export const useMyNotificationPreferences = () =>
useQuery(myNotificationPreferencesQuery())