"use client"; import { motion } from "framer-motion" import { SideMenu } from "@/components/pages/dashboard/SideMenu" import { Switch } from "@/components/ui/switch" import { Label } from "@/components/ui/label" import { Card } from "@/components/ui/card" import { ChangePassword } from "@/components/cards/dashboard/Settings/ChangePassword" import { useState, useEffect } from "react"; const fadeIn = { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.4 }, } export default function Settings() { const [settings, setSettings] = useState({ hideGenAI: false, hideUpgrades: false, hideCrypto: false }); const [loading, setLoading] = useState(false); useEffect(() => { const fetchSettings = async () => { try { setLoading(true); const response = await fetch('/api/users/settings'); if (response.ok) { const data = await response.json(); setSettings(data); } else { console.error('[!] Failed to fetch settings'); } } catch (error) { console.error('[!] Error fetching settings:', error); } finally { setLoading(false); } }; fetchSettings(); }, []); const updateSetting = async (settingName: string, value: boolean) => { setSettings(prev => ({ ...prev, [settingName]: value })); try { setLoading(true); const response = await fetch('/api/users/settings', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ ...settings, [settingName]: value }), }); if (response.ok) { const updatedSettings = await response.json(); setSettings(updatedSettings); } else { console.error('[!] Failed to update settings'); setSettings(prev => ({ ...prev, [settingName]: !value })); } } catch (error) { console.error('[!] Error updating settings:', error); setSettings(prev => ({ ...prev, [settingName]: !value })); } finally { setLoading(false); window.location.reload(); } }; return (

Settings

UI Settings

updateSetting('hideGenAI', checked)} />
updateSetting('hideUpgrades', checked)} />
updateSetting('hideCrypto', checked)} />
) }