"use client"; import { useState, useEffect } from 'react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { auth } from '@/lib/firebase/config'; import { toast } from 'sonner'; import { Settings, User, Bell, Shield, Trash2 } from 'lucide-react'; import { useParams, useRouter } from 'next/navigation'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; interface WorkspaceSettings { name: string; description: string; createdAt: any; } export default function SettingsPage() { const params = useParams(); const router = useRouter(); const workspace = params.workspace as string; const [settings, setSettings] = useState(null); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const [displayName, setDisplayName] = useState(''); const [email, setEmail] = useState(''); useEffect(() => { loadSettings(); loadUserProfile(); }, []); const loadSettings = async () => { try { const user = auth.currentUser; if (!user) return; const token = await user.getIdToken(); const response = await fetch(`/api/workspace/${workspace}/settings`, { headers: { 'Authorization': `Bearer ${token}`, }, }); if (response.ok) { const data = await response.json(); setSettings(data); } } catch (error) { console.error('Error loading settings:', error); } finally { setLoading(false); } }; const loadUserProfile = () => { const user = auth.currentUser; if (user) { setDisplayName(user.displayName || ''); setEmail(user.email || ''); } }; const handleSaveProfile = async () => { setSaving(true); try { const user = auth.currentUser; if (!user) { toast.error('Please sign in'); return; } // Update profile logic would go here toast.success('Profile updated successfully'); } catch (error) { console.error('Error saving profile:', error); toast.error('Failed to update profile'); } finally { setSaving(false); } }; return (
{/* Header */}

Settings

Manage your workspace and account preferences

{/* Profile Settings */}
Profile
Update your personal information
setDisplayName(e.target.value)} placeholder="Your display name" />

Email cannot be changed directly. Contact support if needed.

{/* Workspace Settings */}
Workspace
Configure workspace settings

Workspace identifier cannot be changed after creation

{settings?.createdAt && (

{new Date(settings.createdAt._seconds * 1000).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}

)}
{/* Notifications */}
Notifications
Manage your notification preferences

Email Notifications

Receive updates via email

Session Summaries

Daily AI session summaries

{/* Security */}
Security
Manage your account security

Change Password

Update your account password

Two-Factor Authentication

Add an extra layer of security

{/* Danger Zone */}
Danger Zone
Irreversible and destructive actions
Are you absolutely sure? This action cannot be undone. This will permanently delete your workspace and all associated data. Cancel Delete Workspace
); }