import { useParams, useNavigate, Link } from 'react-router-dom';
import { useVariability } from '../hooks/useVariability';
import { VariabilityPanel } from './VariabilityPanel';
import { formatDateShort } from '../utils/dateUtils';
export function DetailsView() {
const { type, value } = useParams<{ type: string; value: string }>();
const navigate = useNavigate();
const { data, loading, error } = useVariability(type || '', value || '');
if (loading) {
return (
Chargement…
);
}
if (error) {
return (
Erreur : {error.message}
);
}
if (!data) return null;
const typeLabels: Record = {
ip: 'IP',
ja4: 'JA4',
country: 'Pays',
asn: 'ASN',
host: 'Host',
user_agent: 'User-Agent',
};
const typeLabel = typeLabels[type || ''] || type;
const isIP = type === 'ip';
const isJA4 = type === 'ja4';
const first = data.date_range.first_seen ? new Date(data.date_range.first_seen) : null;
const last = data.date_range.last_seen ? new Date(data.date_range.last_seen) : null;
const sameDate = first && last && first.getTime() === last.getTime();
const fmtDate = (d: Date) => formatDateShort(d.toISOString());
return (
{/* Breadcrumb */}
{/* Header card */}
{/* Identité */}
{/* Actions */}
{isIP && (
)}
{isJA4 && (
)}
{/* Métriques clés */}
{!isIP && (
)}
{first && last && (
sameDate ? (
) : (
Période
{fmtDate(first)}
→ {fmtDate(last)}
)
)}
{/* Insights */}
{data.insights.length > 0 && (
{data.insights.map((ins, i) => {
const s: Record
= {
warning: 'bg-yellow-500/10 border-yellow-500/40 text-yellow-400',
info: 'bg-blue-500/10 border-blue-500/40 text-blue-400',
success: 'bg-green-500/10 border-green-500/40 text-green-400',
};
return (
{ins.message}
);
})}
)}
{/* Attributs */}
);
}
function Metric({ label, value, accent }: { label: string; value: string; accent?: boolean }) {
return (
);
}