"use client"; import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import { useAuth } from "@/lib/auth"; import { useTheme } from "@/components/ThemeProvider"; import { useTranslation, LOCALES } from "@/lib/i18n"; import type { Locale } from "@/lib/i18n"; export default function SettingsPage() { const { token, user, logout } = useAuth(); const { theme, toggleTheme } = useTheme(); const { t, locale, setLocale } = useTranslation(); const router = useRouter(); const [notifications, setNotifications] = useState({ push: true, email: false, taskReminders: true, dailySummary: false, }); const [saved, setSaved] = useState(false); useEffect(() => { if (!token) { router.replace("/login"); } // Load saved preferences if (typeof window !== "undefined") { const savedNotifs = localStorage.getItem("taskteam_notifications"); if (savedNotifs) { try { setNotifications(JSON.parse(savedNotifs)); } catch { // ignore } } } }, [token, router]); function handleSave() { if (typeof window !== "undefined") { localStorage.setItem("taskteam_notifications", JSON.stringify(notifications)); } setSaved(true); setTimeout(() => setSaved(false), 2000); } function handleLogout() { logout(); router.push("/login"); } if (!token) return null; return (
{user?.name || t("settings.user")}
{user?.email}
{t("common.appName")} {t("common.appVersion")}