/** * Admin Activity Logs Page * View system activity and audit trail */ import { useState, useEffect } from 'react'; import { Search, Filter, Loader2, AlertCircle, Activity } from 'lucide-react'; import { Card } from '../../components/ui/card'; import Badge from '../../components/ui/badge/Badge'; interface ActivityLog { id: number; user_email: string; account_name: string; action: string; resource_type: string; resource_id: string | null; ip_address: string; timestamp: string; details: string; } export default function AdminActivityLogsPage() { const [logs, setLogs] = useState([]); const [loading, setLoading] = useState(true); const [searchTerm, setSearchTerm] = useState(''); const [actionFilter, setActionFilter] = useState('all'); useEffect(() => { // Mock data - replace with API call setLogs([ { id: 1, user_email: 'john@example.com', account_name: 'Acme Corp', action: 'create', resource_type: 'Site', resource_id: '123', ip_address: '192.168.1.1', timestamp: new Date().toISOString(), details: 'Created new site "Main Website"', }, { id: 2, user_email: 'jane@example.com', account_name: 'TechStart', action: 'update', resource_type: 'Account', resource_id: '456', ip_address: '192.168.1.2', timestamp: new Date(Date.now() - 3600000).toISOString(), details: 'Updated account billing address', }, ]); setLoading(false); }, []); const filteredLogs = logs.filter((log) => { const matchesSearch = log.user_email.toLowerCase().includes(searchTerm.toLowerCase()) || log.account_name.toLowerCase().includes(searchTerm.toLowerCase()); const matchesAction = actionFilter === 'all' || log.action === actionFilter; return matchesSearch && matchesAction; }); if (loading) { return (
); } return (

Activity Logs

System activity and audit trail

setSearchTerm(e.target.value)} className="w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-800" />
{filteredLogs.length === 0 ? ( ) : ( filteredLogs.map((log) => ( )) )}
Timestamp User Account Action Resource Details IP Address
No activity logs found
{new Date(log.timestamp).toLocaleString()} {log.user_email} {log.account_name} {log.action} {log.resource_type} {log.details} {log.ip_address}
); }