import { useState } from "react";
import {
Shield,
Users,
AlertTriangle,
ShieldCheck,
BarChart3,
Sparkles,
ChevronDown
} from "lucide-react";
import Button from "@/components/common/button";
import StatCard from "@/components/common/dashStatCard";
import InfoBanner from '@/components/common/infoBanner';
import Table from '@/components/common/dataTable';
import { StatusBadge } from "@/components/common/statusBadge";
export const trustedDeviceHeaders = [
"USER",
"DEVICE",
"IP",
"LAST SEEN",
"EXPIRES",
"STATUS",
"ACTIONS",
];
export const trustedDeviceRows = [
[
Dhananjay T. ,
"Chrome 126 · Windows 11",
103.212.14.8 ,
Today, 08:12 ,
Jul 30, 2026 ,
,
Revoke
,
],
[
Kavya Raghunathan ,
"Safari 18 · macOS",
49.37.201.55 ,
Yesterday, 17:40 ,
Jul 21, 2026 ,
,
Revoke
,
],
[
Rahul Iyer ,
"KAFM Mobile · Android 15",
152.58.33.104 ,
Today, 06:58 ,
Jul 12, 2026 ,
,
Revoke
,
],
[
Meera Pillai ,
"Edge 126 · Windows 10",
103.212.14.31 ,
Jun 18, 2026 ,
Expired ,
,
— ,
],
];
export const auditLogHeaders = [
"WHEN",
"USER",
"EVENT",
"IP",
"RESULT",
];
export const auditLogRows = [
[
Today 08:12 ,
dhananjay@kafm.io ,
Sign-in · password + MFA ,
103.212.14.8 ,
,
],
[
Today 07:56 ,
kavya@kafm.io ,
Role changed · Technician → M&E Supervisor
,
49.37.201.55 ,
,
],
[
Today 07:31 ,
unknown@ext.net ,
Sign-in · wrong password (3rd attempt)
,
91.240.118.7 ,
,
],
[
Today 06:58 ,
rahul@kafm.io ,
Device trusted · KAFM Mobile (30 days)
,
152.58.33.104 ,
,
],
[
Yesterday 17:40 ,
kavya@kafm.io ,
Password reset · self-service link
,
49.37.201.55 ,
,
],
[
Yesterday 14:05 ,
meera@kafm.io ,
MFA reset by admin · device revoked
,
103.212.14.31 ,
,
],
[
Jun 30 09:12 ,
admin@kafm.io ,
Sign-in policy updated · idle timeout 30 min
,
103.212.14.8 ,
,
],
];
export default function SecurityPortal() {
const [enforceMfa, setEnforceMfa] = useState(true);
const [keepMeSignedIn, setKeepMeSignedIn] = useState(true);
const [reAuthenticate, setReAuthenticate] = useState(false);
return (
{/* --- HEADER SECTION --- */}
PLATFORM
•
SECURITY
Security & sessions
Platform-wide sign-in policy, trusted devices and the immutable authentication audit trail. Sign-ins, MFA, resets and policy changes are logged automatically.
{/* --- HEADER BUTTONS --- */}
Export log
Publish policy
{/* --- STAT CARDS --- */}
{/* --- TOP GRID SECTION: AUDIT LOG + SIGN-IN POLICY --- */}
{/* --- LEFT: AUDIT LOG TABLE CONTAINER --- */}
Authentication audit trail
immutable
•
90-day retention
{/* AUDIT LOG TABLE */}
{/* --- RIGHT: SIGN-IN POLICY PANEL --- */}
Sign-in policy
{/* Toggle 1: Enforce MFA */}
Enforce MFA for all users
6-digit code required on every untrusted device
setEnforceMfa(!enforceMfa)}
className={`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${enforceMfa ? 'bg-teal-400' : 'bg-slate-800'}`}
>
{/* Select 1: Idle Session Timeout */}
Idle session timeout
Auto sign-out after inactivity
30 minutes
15 minutes
1 hour
{/* Toggle 2: Keep me signed in */}
“Keep me signed in” by default
Pre-checks the persistent-session option at sign-in
setKeepMeSignedIn(!keepMeSignedIn)}
className={`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${keepMeSignedIn ? 'bg-teal-400' : 'bg-slate-800'}`}
>
{/* Toggle 3: Re-authenticate */}
Re-authenticate for sensitive actions
Password prompt before user, role or policy changes
setReAuthenticate(!reAuthenticate)}
className={`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${reAuthenticate ? 'bg-teal-400' : 'bg-slate-800'}`}
>
{/* Select 2: Trusted device window */}
Trusted device window
Days MFA is skipped on a trusted device
30
60
90
{/* --- BOTTOM SECTION: TRUSTED DEVICES TABLE CONTAINER --- */}
Trusted devices
MFA skipped until expiry
Revoke all
{/* TRUSTED DEVICES TABLE */}
Revoking forces MFA on the next sign-in from that device. Password changes revoke all devices automatically.
{/* --- INFO BANNER --- */}
);
}