import React, { useState } from 'react'; import { api } from '@nexus/shared'; const COLORS = { brand: "#7C3AED", bg: "#0A0C10", card: "#161B22", border: "rgba(255,255,255,0.08)", text: "#E6EDF3", subtext: "#8B949E", error: "#F85149", success: "#3FB950", }; interface UserSettingsModalProps { user: any; onClose: () => void; onUpdate: (updatedUser: any) => void; } export const UserSettingsModal: React.FC = ({ user, onClose, onUpdate }) => { const [tab, setTab] = useState<'profile' | 'security'>('profile'); const [loading, setLoading] = useState(false); const [message, setMessage] = useState<{ type: 'success' | 'error', text: string } | null>(null); // Profile Form const [profileForm, setProfileForm] = useState({ full_name: user?.full_name || '', avatar_url: user?.avatar_url || '' }); // Security Form const [securityForm, setSecurityForm] = useState({ old_password: '', new_password: '', confirm_password: '' }); const handleProfileUpdate = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setMessage(null); try { const resp = await api.patch('users/me/', profileForm); onUpdate(resp.data); setMessage({ type: 'success', text: 'Profile updated successfully!' }); } catch (err) { setMessage({ type: 'error', text: 'Failed to update profile.' }); } finally { setLoading(false); } }; const handlePasswordUpdate = async (e: React.FormEvent) => { e.preventDefault(); if (securityForm.new_password !== securityForm.confirm_password) { setMessage({ type: 'error', text: 'Passwords do not match.' }); return; } setLoading(true); setMessage(null); try { await api.post('auth/change-password/', { old_password: securityForm.old_password, new_password: securityForm.new_password }); setMessage({ type: 'success', text: 'Password changed successfully!' }); setSecurityForm({ old_password: '', new_password: '', confirm_password: '' }); } catch (err) { setMessage({ type: 'error', text: 'Incorrect current password or update failed.' }); } finally { setLoading(false); } }; return (

Command Settings

Manage your operational identity and security.

{message && (
{message.text}
)} {tab === 'profile' ? (
setProfileForm({...profileForm, full_name: e.target.value})} style={{ width: '100%', padding: '12px', borderRadius: 8, background: '#0D1117', border: `1px solid ${COLORS.border}`, color: COLORS.text, fontSize: 14, outline: 'none' }} />
setProfileForm({...profileForm, avatar_url: e.target.value})} placeholder="https://nexus.ai/assets/avatar.png" style={{ width: '100%', padding: '12px', borderRadius: 8, background: '#0D1117', border: `1px solid ${COLORS.border}`, color: COLORS.text, fontSize: 14, outline: 'none' }} />
) : (
setSecurityForm({...securityForm, old_password: e.target.value})} style={{ width: '100%', padding: '12px', borderRadius: 8, background: '#0D1117', border: `1px solid ${COLORS.border}`, color: COLORS.text, fontSize: 14, outline: 'none' }} />
setSecurityForm({...securityForm, new_password: e.target.value})} style={{ width: '100%', padding: '12px', borderRadius: 8, background: '#0D1117', border: `1px solid ${COLORS.border}`, color: COLORS.text, fontSize: 14, outline: 'none' }} />
setSecurityForm({...securityForm, confirm_password: e.target.value})} style={{ width: '100%', padding: '12px', borderRadius: 8, background: '#0D1117', border: `1px solid ${COLORS.border}`, color: COLORS.text, fontSize: 14, outline: 'none' }} />
)}
); };