'use client'; import { useEffect, useState } from 'react'; import { api } from '@/lib/api'; import { useAuth } from '@/components/auth-provider'; import { ChevronLeft, ChevronRight, Bell, Globe, Shield, Store, LogOut, HelpCircle, Mail, Phone, User, Star, Sparkles } from 'lucide-react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { PageSkeleton } from '@/components/page-skeleton'; import { API_BASE } from '@/lib/api'; export default function SettingsPage() { const { user, loading: authLoading, logout } = useAuth(); const router = useRouter(); const [profile, setProfile] = useState(null); const [isSeller, setIsSeller] = useState(false); useEffect(() => { if (!authLoading && !user) { router.push('/login?next=/settings'); return; } if (user) { (async () => { const profileResp = await api.profile.get(); if (profileResp.success && profileResp.profile) { setProfile(profileResp.profile); } // Check seller status try { const sellerResp = await fetch(`${API_BASE}/api/seller-profile`, { credentials: 'include', method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ op: 'get' }), }); if (sellerResp.ok) { const sellerData = await sellerResp.json(); if (sellerData.success && sellerData.seller) { setIsSeller(true); } } } catch {} })(); } }, [user, authLoading, router]); if (authLoading) { return ; } const handleLogout = async () => { await logout(); router.push('/'); }; const sectionLabel = "text-xs font-semibold text-slate-400 uppercase tracking-wide px-4 mb-2"; return (
{/* Top bar */}

Settings

{/* Account section */}

Account

Edit Profile
{profile?.full_name || user?.email}
Email
{user?.email}
Phone
{profile?.phone || 'Not set'}
{/* Preferences */}

Preferences

{/* Seller section */}

Selling

{isSeller ? (
Seller Dashboard
Manage your products, orders & analytics
) : (
Become a Seller
Start selling on Cellex — it's free
)}
{/* Support */}

Support

Help & Support
Get help via Telegram
Ask AI Assistant
Get instant help from our AI
{/* Security */}

Security

Account Security
HTTP-only cookie auth · 7-day session
{/* Logout */}
Cellex v0.2.15 · Nigeria's #1 social marketplace
); } function ToggleRow({ icon: Icon, label, desc, defaultOn }: { icon: any; label: string; desc: string; defaultOn?: boolean }) { const [on, setOn] = useState(!!defaultOn); return (
{label}
{desc}
); }