From 18d0c0bdb9a23de104aafe0a98e1055997088a26 Mon Sep 17 00:00:00 2001 From: null Date: Sat, 4 Jul 2026 22:29:16 -0500 Subject: [PATCH] =?UTF-8?q?refactor(ts):=20SettingsPage=20=E2=86=92=20Type?= =?UTF-8?q?Script=20(auto-save=20settings=20+=20tracker=20layout=20toggles?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TS flagged a dead prop: onSaved was passed to NotificationPreferences (which only takes settings) — removed it. Notification components imported from ProfilePage (still .jsx) type as any until that page converts. --- .../{SettingsPage.jsx => SettingsPage.tsx} | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) rename client/pages/{SettingsPage.jsx => SettingsPage.tsx} (90%) diff --git a/client/pages/SettingsPage.jsx b/client/pages/SettingsPage.tsx similarity index 90% rename from client/pages/SettingsPage.jsx rename to client/pages/SettingsPage.tsx index b3c500e..1de511f 100644 --- a/client/pages/SettingsPage.jsx +++ b/client/pages/SettingsPage.tsx @@ -1,9 +1,9 @@ -import React, { useState, useEffect, useCallback } from 'react'; +import { useState, useEffect, useCallback, type ComponentType, type ReactNode } from 'react'; import { useNavigate } from 'react-router-dom'; import { toast } from 'sonner'; import { AlertCircle, Moon, RefreshCw, Sun, Users } from 'lucide-react'; import { api } from '@/api'; -import { cn } from '@/lib/utils'; +import { cn, errMessage } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { CalendarFeedManager } from '@/components/CalendarFeedManager'; @@ -18,7 +18,7 @@ import { SaveStatus } from '@/components/ui/save-status'; import { NotificationPreferences, PushNotifications, asSettings } from '@/pages/ProfilePage'; export const LINK_IMPORT_PREF_KEY = 'link_import_ask'; -export function getLinkImportPref() { +export function getLinkImportPref(): boolean { return localStorage.getItem(LINK_IMPORT_PREF_KEY) !== 'false'; } @@ -26,12 +26,12 @@ export function getLinkImportPref() { // preferences; Profile keeps identity, security, and privacy) ────────────── function NotificationsSection() { - const [settings, setSettings] = useState(null); + const [settings, setSettings] = useState | null>(null); const load = useCallback(() => { api.profileSettings() .then((data) => setSettings(asSettings(data))) - .catch((err) => toast.error(err.message || 'Failed to load notification settings.')); + .catch((err) => toast.error(errMessage(err, 'Failed to load notification settings.'))); }, []); useEffect(() => { load(); }, [load]); @@ -39,7 +39,7 @@ function NotificationsSection() { if (!settings) return null; return (
- +
); @@ -47,7 +47,7 @@ function NotificationsSection() { // ─── Card wrapper ───────────────────────────────────────────────────────────── -function SectionCard({ title, children }) { +function SectionCard({ title, children }: { title: ReactNode; children: ReactNode }) { return (
@@ -62,7 +62,7 @@ function SectionCard({ title, children }) { // ─── Setting Row ────────────────────────────────────────────────────────────── -function SettingRow({ label, description, children }) { +function SettingRow({ label, description, children }: { label: ReactNode; description?: ReactNode; children: ReactNode }) { return (
@@ -80,7 +80,13 @@ function SettingRow({ label, description, children }) { // ─── Theme Card ─────────────────────────────────────────────────────────────── -function ThemeCard({ value, label, icon: Icon, currentTheme, onSelect }) { +function ThemeCard({ value, label, icon: Icon, currentTheme, onSelect }: { + value: string; + label: string; + icon: ComponentType<{ className?: string }>; + currentTheme: string; + onSelect: (v: string) => void; +}) { const selected = currentTheme === value; return (