import React, { useState } from 'react'; import { Search } from 'lucide-react'; const EVENT_LABELS = { signup: 'Sign Up', login: 'Login', logout: 'Logout', create_position: 'Create Position', screen_candidate: 'Screen Candidate', hire_candidate: 'Hire Candidate', assign_employee: 'Assign Employee', apply_job: 'Apply to Job', start_interview: 'Start Interview', }; const EVENT_COLORS = { signup: 'bg-[#EEF3FE] text-[#1E40AF]', login: 'bg-[#ECFDF5] text-[#065F46]', logout: 'bg-[#F3F4F6] text-[#374151]', create_position: 'bg-[#F5F3FF] text-[#5B21B6]', screen_candidate: 'bg-[#FFFBEB] text-[#92400E]', hire_candidate: 'bg-[#ECFDF5] text-[#065F46]', assign_employee: 'bg-[#F0F9FF] text-[#075985]', apply_job: 'bg-[#EEF3FE] text-[#1E40AF]', start_interview: 'bg-[#FEF2F2] text-[#991B1B]', }; function formatTime(dateStr) { if (!dateStr) return ''; const d = new Date(dateStr); return d.toLocaleString('en-US', { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit', }); } export default function ActivityLogTable({ activities }) { const [filter, setFilter] = useState('all'); const [search, setSearch] = useState(''); const filtered = activities.filter((a) => { if (filter !== 'all' && a.event_type !== filter) return false; if (search) { const q = search.toLowerCase(); return ( (a.user_email || '').toLowerCase().includes(q) || (a.user_name || '').toLowerCase().includes(q) ); } return true; }); const eventTypes = ['all', ...Object.keys(EVENT_LABELS)]; return (

Activity Log

setSearch(e.target.value)} placeholder="Search user..." className="pl-8 pr-3 h-8 text-[12px] rounded-md border border-[#E5E7EB] focus:border-[#2563EB] focus:outline-none w-40" />
{filtered.length === 0 ? ( ) : ( filtered.slice(0, 50).map((a) => ( )) )}
Event User Role Details Time
No activity found
{EVENT_LABELS[a.event_type] || a.event_type}
{a.user_name || '—'}
{a.user_email}
{a.account_type || '—'} {a.details || '—'} {formatTime(a.created_date)}
); }