"use client" import React, { useState } 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 { Alert, AlertDescription } from '@/components/ui/alert' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { ProtectedRoute } from '@/components/auth/protected-route' import { ApiKeyManager } from '@/components/auth/api-key-manager' import { UserManagement } from '@/components/auth/user-management' import { useAuth } from '@/lib/auth-context' import { authApi } from '@/lib/api' export default function SettingsPage() { const { user, logout } = useAuth() const [activeTab, setActiveTab] = useState('profile') const [error, setError] = useState(null) const [success, setSuccess] = useState(null) const [passwordData, setPasswordData] = useState({ current_password: '', new_password: '', confirm_password: '' }) const handlePasswordChange = async (e: React.FormEvent) => { e.preventDefault() if (passwordData.new_password !== passwordData.confirm_password) { setError('New passwords do not match') return } if (passwordData.new_password.length < 8) { setError('Password must be at least 8 characters long') return } try { await authApi.changePassword(passwordData.current_password, passwordData.new_password) setSuccess('Password changed successfully') setPasswordData({ current_password: '', new_password: '', confirm_password: '' }) setError(null) } catch (err) { setError(err instanceof Error ? err.message : 'Failed to change password') setSuccess(null) } } return (

Settings

Manage your account and application settings

{error && ( {error} )} {success && ( {success} )} Profile API Keys {user?.role === 'admin' && ( User Management )} Profile Information View and manage your account details
{user?.email && (
)}
Change Password Update your account password
setPasswordData(prev => ({ ...prev, current_password: e.target.value }))} required />
setPasswordData(prev => ({ ...prev, new_password: e.target.value }))} required />
setPasswordData(prev => ({ ...prev, confirm_password: e.target.value }))} required />
Account Actions Manage your session
{user?.role === 'admin' && ( )}
) }