import { useEffect } from 'react'; import { useQuery } from '@tanstack/react-query'; import { X, Check, AlertTriangle, Loader2 } from 'lucide-react'; import { api } from '../api/client'; import type { ArchiveComparison } from '../api/client'; import { Button } from './Button'; interface CompareArchivesModalProps { archiveIds: number[]; onClose: () => void; } export function CompareArchivesModal({ archiveIds, onClose }: CompareArchivesModalProps) { // Close on Escape key useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [onClose]); const { data: comparison, isLoading, error } = useQuery({ queryKey: ['archive-comparison', archiveIds], queryFn: () => api.compareArchives(archiveIds), }); return (
Failed to load comparison
{error instanceof Error ? error.message : 'Unknown error'}
| Setting | {comparison.archives.map((archive) => (
{archive.print_name}
{archive.status}
|
))}
|---|---|
|
{field.has_difference && (
|
{field.values.map((value, idx) => (
{value ?? -} {field.unit && value !== null && ( {field.unit} )} | ))}
No clear correlations found between settings and outcomes.
)}{comparison.success_correlation.message || 'Need both successful and failed prints for correlation analysis.'}