import { createFileRoute } from '@tanstack/react-router' import { useTranslation } from 'react-i18next' import { useAuth } from 'react-oidc-context' import { Button, EmptyState, LoadingBlock, PageHeader, Panel, QueryErrorState, Switch, } from '@/ui' import { useMyNotificationPreferences } from '@/api/queries' import { useUpdateNotificationPreferences } from '@/api/mutations' import type { NotificationPreferences } from '@/api/client' export const Route = createFileRoute('/me/notifications/preferences')({ component: NotificationPreferencesPage, }) /** * Phase B — UI для per-channel notification opt-in/out. * *
Email — единственный actually wired channel в Phase A/B (через Spring * \`spring.mail.host\`). Express + Telegram toggles disabled с подсказкой * "Скоро" — backend хранит preference (на случай early opt-in), но dispatcher * никогда не пошлёт пока channel bean не зарегистрирован. * *
Optimistic update — toggle flips мгновенно, network roundtrip ~200ms
* почти не виден. onError refetch восстанавливает state если PUT 4xx/5xx.
*/
function NotificationPreferencesPage() {
const { t } = useTranslation()
const auth = useAuth()
const prefsQ = useMyNotificationPreferences()
const updateMut = useUpdateNotificationPreferences()
if (!auth.isAuthenticated) {
return (
{description}