import React from 'react'; import { BehaviorAnomaly, AnomalyType, AnomalySeverity } from '../../types.ts'; import { BrainIcon } from '../icons/Icons.tsx'; interface BehaviorAnomalyLogProps { anomalies: BehaviorAnomaly[]; } const anomalyConfig = { [AnomalyType.AGGRESSION]: { icon: 'fa-hand-fist', color: 'text-red-600', bg: 'bg-red-100' }, [AnomalyType.ISOLATION]: { icon: 'fa-person', color: 'text-yellow-600', bg: 'bg-yellow-100' }, [AnomalyType.PANIC]: { icon: 'fa-person-running', color: 'text-purple-600', bg: 'bg-purple-100' }, [AnomalyType.REDUCED_MOBILITY]: { icon: 'fa-person-falling', color: 'text-blue-600', bg: 'bg-blue-100', }, }; const BehaviorAnomalyLog: React.FC = ({ anomalies }) => { const formatTime = (date: Date) => { return date.toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' }); }; const formatDate = (date: Date) => { const today = new Date(); const yesterday = new Date(today); yesterday.setDate(yesterday.getDate() - 1); if (date.toDateString() === today.toDateString()) { return 'Hari Ini'; } if (date.toDateString() === yesterday.toDateString()) { return 'Kemarin'; } return date.toLocaleDateString('id-ID', { day: 'numeric', month: 'short' }); }; return (

Log Anomali Perilaku

{anomalies.length > 0 ? (
{anomalies.map((log) => { const config = anomalyConfig[log.type]; return (

{log.type} Terdeteksi {log.severity === AnomalySeverity.CRITICAL && ( Kritis )}

{log.details} di {log.location}

{formatTime(log.timestamp)}
{formatDate(log.timestamp)}
); })}
) : (

Tidak ada anomali terdeteksi.

)}
); }; export default BehaviorAnomalyLog;