"use client"; import { useQuery } from "@tanstack/react-query"; import { useAuth } from "@/hooks/use-auth"; import { useTranslations } from "@/lib/i18n/context"; import { NotificationStatusCard } from "@/components/settings/notification-status-card"; import { NtfyCard } from "@/components/settings/ntfy-card"; import { TelegramCard } from "@/components/settings/telegram-card"; import { WebPushCard } from "@/components/settings/web-push-card"; interface GlobalServiceAvailability { telegramGlobal: boolean; ntfyGlobal: boolean; webPushGlobal: boolean; apiGlobal: boolean; moodLogGlobal: boolean; } export function NotificationsSection() { const { t } = useTranslations(); const { isAuthenticated } = useAuth(); const { data: globalServices } = useQuery({ queryKey: ["settings", "global-services"], queryFn: async () => { const res = await fetch("/api/settings/global-services"); if (!res.ok) throw new Error("Failed"); return (await res.json()).data as GlobalServiceAvailability; }, enabled: isAuthenticated, }); const showTelegram = globalServices?.telegramGlobal ?? true; const showNtfy = globalServices?.ntfyGlobal ?? true; const showWebPush = globalServices?.webPushGlobal ?? true; return (

{t("settings.sections.notifications.title")}

{t("settings.sections.notifications.description")}

{showTelegram && (
)} {showNtfy && (
)} {showWebPush && (
)}
); }