import { useState } from 'react'; import { Grid, Card, Box, Stack, TextField, MenuItem, Switch, Button, Typography, Divider, Snackbar, Alert, Chip, IconButton, InputAdornment, LinearProgress, Avatar } from '@mui/material'; import SaveOutlinedIcon from '@mui/icons-material/SaveOutlined'; import TuneOutlinedIcon from '@mui/icons-material/TuneOutlined'; import NotificationsNoneIcon from '@mui/icons-material/NotificationsNone'; import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; import ShieldOutlinedIcon from '@mui/icons-material/ShieldOutlined'; import CampaignOutlinedIcon from '@mui/icons-material/CampaignOutlined'; import BusinessOutlinedIcon from '@mui/icons-material/BusinessOutlined'; import VerifiedOutlinedIcon from '@mui/icons-material/VerifiedOutlined'; import WarningAmberRoundedIcon from '@mui/icons-material/WarningAmberRounded'; import HelpOutlineRoundedIcon from '@mui/icons-material/HelpOutlineRounded'; import LogoutOutlinedIcon from '@mui/icons-material/LogoutOutlined'; import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import Visibility from '@mui/icons-material/Visibility'; import VisibilityOff from '@mui/icons-material/VisibilityOff'; import PageHeader from '@/components/PageHeader'; const TIMEZONES = ['Asia/Kolkata (IST)', 'Asia/Dubai (GST)', 'UTC', 'America/New_York (EST)']; const LANGUAGES = ['English', 'हिन्दी (Hindi)', 'العربية (Arabic)']; const INITIAL_GENERAL = { orgName: 'Doormile Technologies', supportEmail: 'support@doormile.in', contact: '+91 63749 46729', timezone: TIMEZONES[0], language: LANGUAGES[0] }; const INITIAL_NOTIFY = { newClient: true, contractStatus: true, teamAccess: false, databaseSync: true, emailAlerts: true, smsAlerts: false }; const INITIAL_SECURITY = { currentPassword: '', newPassword: '', confirmPassword: '', twoFactor: false }; const NAV = [ { icon: TuneOutlinedIcon, label: 'General', desc: 'Organisation profile' }, { icon: NotificationsNoneIcon, label: 'Notifications', desc: 'Alerts & channels' }, { icon: LockOutlinedIcon, label: 'Security', desc: 'Password & 2FA' } ]; const NOTIFY_ROWS = [ { k: 'newClient', t: 'New client onboarded', d: 'Notify when a new client is added to the system' }, { k: 'contractStatus', t: 'Contract status', d: 'When a client contract becomes active or expires' }, { k: 'teamAccess', t: 'Team access', d: 'When a new team member is granted or revoked access' }, { k: 'databaseSync', t: 'Database sync', d: 'Alerts for vector database synchronization events' } ]; const STRENGTH = [ { label: 'Too weak', color: 'error' }, { label: 'Weak', color: 'error' }, { label: 'Fair', color: 'warning' }, { label: 'Good', color: 'info' }, { label: 'Strong', color: 'success' } ]; const scorePassword = (pw) => { let s = 0; if (pw.length >= 8) s++; if (/[a-z]/.test(pw) && /[A-Z]/.test(pw)) s++; if (/\d/.test(pw)) s++; if (/[^A-Za-z0-9]/.test(pw)) s++; return s; }; // Section surface with a tinted icon header band. function Section({ icon: Icon, title, subtitle, color = 'primary', danger = false, children }) { return ( `linear-gradient(90deg, ${theme.palette[color].lighter}66 0%, ${theme.palette.background.paper} 72%)` }} > {title} {subtitle && {subtitle}} {children} ); } // Two-column row: label + helper on the left, control on the right. function Row({ label, description, children, align = 'center' }) { return ( {label} {description && {description}} {children} ); } const rightAlign = { display: 'flex', justifyContent: { sm: 'flex-end' } }; function PasswordField({ label, value, onChange, autoComplete }) { const [show, setShow] = useState(false); return ( setShow((s) => !s)} edge="end" size="small"> {show ? : } ) }} /> ); } export default function Settings() { const [tab, setTab] = useState(0); const [toast, setToast] = useState(false); const [dirty, setDirty] = useState(false); const [general, setGeneral] = useState(INITIAL_GENERAL); const [notify, setNotify] = useState(INITIAL_NOTIFY); const [security, setSecurity] = useState(INITIAL_SECURITY); const setG = (k) => (e) => { setGeneral((p) => ({ ...p, [k]: e.target.value })); setDirty(true); }; const setN = (k) => (e) => { setNotify((p) => ({ ...p, [k]: e.target.checked })); setDirty(true); }; const setSText = (k) => (e) => { setSecurity((p) => ({ ...p, [k]: e.target.value })); setDirty(true); }; const save = () => { setToast(true); setDirty(false); }; const discard = () => { setGeneral(INITIAL_GENERAL); setNotify(INITIAL_NOTIFY); setSecurity(INITIAL_SECURITY); setDirty(false); }; const pwScore = scorePassword(security.newPassword); const pwMeta = STRENGTH[pwScore]; const mismatch = security.confirmPassword && security.newPassword !== security.confirmPassword; return ( <> {dirty && } } /> {/* Sidebar */} Preferences {NAV.map((item, i) => { const active = tab === i; const Icon = item.icon; return ( setTab(i)} sx={{ px: 1.5, py: 1.25, borderRadius: 2, cursor: 'pointer', position: 'relative', bgcolor: active ? 'primary.lighter' : 'transparent', transition: 'background-color .15s', '&:hover': { bgcolor: active ? 'primary.lighter' : 'grey.50' }, '&::before': active ? { content: '""', position: 'absolute', left: 0, top: 9, bottom: 9, width: 3, borderRadius: 3, bgcolor: 'primary.main' } : {} }} > {item.label} {item.desc} ); })} Need a hand? Our team is available 24/7 for operational support. {/* Content */} {tab === 0 && ( {/* Organisation identity banner */} `linear-gradient(90deg, ${theme.palette.primary.lighter}88 0%, ${theme.palette.background.paper} 75%)` }} > {general.orgName} } label="Verified" sx={{ fontWeight: 700, bgcolor: 'success.lighter', color: 'success.dark', '& .MuiChip-icon': { color: 'inherit' } }} /> {general.supportEmail} · {general.contact}
}> {TIMEZONES.map((t) => {t})} {LANGUAGES.map((l) => {l})}
)} {tab === 1 && (
}> {NOTIFY_ROWS.map((row) => ( ))}
}>
)} {tab === 2 && (
}> {security.newPassword && ( {pwMeta.label} )} {mismatch && Passwords do not match}
} label={security.twoFactor ? 'Enabled' : 'Disabled'} sx={{ fontWeight: 700, bgcolor: security.twoFactor ? 'success.lighter' : 'grey.100', color: security.twoFactor ? 'success.dark' : 'grey.600', '& .MuiChip-icon': { color: 'inherit' } }} /> { setSecurity((p) => ({ ...p, twoFactor: e.target.checked })); setDirty(true); }} />
)}
setToast(false)} anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} > setToast(false)} sx={{ width: '100%' }}> Settings saved successfully. ); }