kcg-ai-monitoring/frontend/src/features/statistics/ReportManagement.tsx
htlee f4d56ea891 fix(frontend): 아이콘 전용 버튼 접근 이름 누락 7곳 보완
이전 스캐너가 놓친 패턴 — 모달 닫기 X 버튼과 토글 스위치 등:

- NoticeManagement: 모달 헤더 X → '닫기'
- ReportManagement: 업로드 패널 X → '업로드 패널 닫기'
- AIModelManagement: 규칙 토글 → role=switch + aria-checked + aria-label
                     API 예시 복사 → '예시 URL 복사'
- FileUpload: 파일 제거 X → '{파일명} 제거'
- NotificationBanner: 알림 닫기 X → '알림 닫기'
- SearchInput: 입력 aria-label (placeholder), 지우기 버튼 → '검색어 지우기'

검증:
- 개선된 스캐너로 remaining=0 확인 (JSX tag 중첩 파싱)
- tsc 
2026-04-08 13:16:20 +09:00

196 lines
9.2 KiB
TypeScript

import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Card, CardContent } from '@shared/components/ui/card';
import { Badge } from '@shared/components/ui/badge';
import { Button } from '@shared/components/ui/button';
import { PageContainer, PageHeader } from '@shared/components/layout';
import { ExcelExport } from '@shared/components/common/ExcelExport';
import { PrintButton } from '@shared/components/common/PrintButton';
import { FileUpload } from '@shared/components/common/FileUpload';
import { SaveButton } from '@shared/components/common/SaveButton';
import { SearchInput } from '@shared/components/common/SearchInput';
import { FileText, Plus, Upload, X, Clock, MapPin, Download } from 'lucide-react';
import type { BadgeIntent } from '@lib/theme/variants';
interface Report {
id: string;
name: string;
type: string;
status: string;
statusIntent: BadgeIntent;
date: string;
mmsiNote: string;
evidence: number;
}
const reports: Report[] = [
{ id: 'RPT-2024-0142', name: '浙江렌센號', type: 'EEZ 침범', status: 'EEZ', statusIntent: 'success', date: '2026-01-20 14:30:00', mmsiNote: 'MMSI 변조', evidence: 12 },
{ id: 'RPT-2024-0231', name: '福建海丰號', type: 'EEZ 침범', status: '확인', statusIntent: 'info', date: '2026-01-20 14:29:00', mmsiNote: '', evidence: 8 },
{ id: 'RPT-2024-0089', name: '무명선박-A', type: '다크베셀', status: '처리중', statusIntent: 'warning', date: '2026-01-20 14:05:00', mmsiNote: '', evidence: 6 },
];
export function ReportManagement() {
const { t } = useTranslation('statistics');
const [selected, setSelected] = useState<Report>(reports[0]);
const [search, setSearch] = useState('');
const [showUpload, setShowUpload] = useState(false);
const filtered = reports.filter((r) =>
!search || r.name.includes(search) || r.id.includes(search) || r.type.includes(search)
);
return (
<PageContainer>
<PageHeader
icon={FileText}
iconColor="text-muted-foreground"
title={t('reports.title')}
description={t('reports.desc')}
demo
actions={
<>
<SearchInput value={search} onChange={setSearch} placeholder="보고서 검색..." className="w-48" />
<ExcelExport
data={reports as unknown as Record<string, unknown>[]}
columns={[
{ key: 'id', label: '보고서번호' }, { key: 'name', label: '선박명' },
{ key: 'type', label: '유형' }, { key: 'status', label: '상태' },
{ key: 'date', label: '일시' }, { key: 'evidence', label: '증거수' },
]}
filename="보고서목록"
/>
<PrintButton />
<Button
variant="secondary"
size="sm"
onClick={() => setShowUpload(!showUpload)}
icon={<Upload className="w-3 h-3" />}
>
</Button>
<Button variant="destructive" size="md" icon={<Plus className="w-4 h-4" />}>
</Button>
</>
}
/>
{/* 증거 파일 업로드 */}
{showUpload && (
<div className="rounded-xl border border-border bg-card p-4">
<div className="flex items-center justify-between mb-2">
<span className="text-[11px] text-label font-bold"> (··)</span>
<button type="button" aria-label="업로드 패널 닫기" onClick={() => setShowUpload(false)} className="text-hint hover:text-muted-foreground"><X className="w-4 h-4" /></button>
</div>
<FileUpload accept=".jpg,.jpeg,.png,.mp4,.pdf,.hwp,.docx" multiple maxSizeMB={100} />
<div className="flex justify-end mt-3">
<SaveButton onClick={() => setShowUpload(false)} label="증거 저장" />
</div>
</div>
)}
<div className="flex gap-5">
{/* 보고서 목록 */}
<Card className="flex-1 bg-surface-overlay border-slate-700/40">
<CardContent className="p-5">
<div className="text-sm text-label mb-3"> </div>
<div className="space-y-3">
{filtered.map((r) => (
<div
key={r.id}
onClick={() => setSelected(r)}
className={`p-4 rounded-lg border cursor-pointer transition-all ${
selected?.id === r.id
? 'bg-switch-background/40 border-blue-500/40'
: 'bg-surface-raised border-slate-700/30 hover:bg-surface-overlay'
}`}
>
<div className="flex items-center justify-between mb-1">
<span className="text-heading font-medium text-sm">{r.name}</span>
<Badge intent={r.statusIntent} size="xs">{r.status}</Badge>
</div>
<div className="text-[11px] text-hint">{r.id}</div>
<div className="flex items-center gap-2 text-[11px] text-hint mt-0.5">
<span>{r.type}</span>
{r.mmsiNote && <><span>·</span><span>{r.mmsiNote}</span></>}
<span>·</span>
<Clock className="w-3 h-3 inline" />
<span>{r.date}</span>
</div>
<div className="text-[11px] text-hint mt-1"> {r.evidence}</div>
<div className="flex gap-2 mt-2">
<button type="button" className="bg-blue-600 text-on-vivid text-[11px] px-3 py-1 rounded hover:bg-blue-500 transition-colors">PDF</button>
<button type="button" className="bg-muted text-heading text-[11px] px-3 py-1 rounded hover:bg-muted transition-colors"></button>
</div>
</div>
))}
</div>
</CardContent>
</Card>
{/* 보고서 미리보기 */}
{selected && (
<Card className="w-[460px] shrink-0 bg-surface-overlay border-slate-700/40">
<CardContent className="p-5">
<div className="flex items-center justify-between mb-4">
<div className="text-sm text-label"> </div>
<button type="button" className="flex items-center gap-1.5 bg-blue-600 hover:bg-blue-500 text-on-vivid px-3 py-1.5 rounded-lg text-xs transition-colors">
<Download className="w-3.5 h-3.5" />
</button>
</div>
<div className="bg-surface-raised border border-slate-700/40 rounded-xl p-6 space-y-5">
{/* 제목 */}
<div>
<h3 className="text-lg font-bold text-heading mb-0.5"> </h3>
<div className="text-[11px] text-hint"> : {selected.id}</div>
</div>
{/* 사건 개요 */}
<div>
<div className="text-sm text-label mb-2"> </div>
<div className="grid grid-cols-2 gap-y-2 text-[11px]">
<div className="text-hint">:</div><div className="text-heading text-right">{selected.name}</div>
<div className="text-hint"> :</div><div className="text-heading text-right">{selected.mmsiNote || selected.type}</div>
<div className="text-hint"> :</div><div className="text-heading text-right">2026-01-20 14:23:15</div>
<div className="text-hint">:</div><div className="text-heading text-right">EEZ (37.56°N, 129.12°E)</div>
</div>
</div>
{/* 지도 스냅샷 */}
<div>
<div className="text-sm text-label mb-2"> </div>
<div className="bg-green-950/10 border border-green-900/20 rounded-lg h-24 flex items-center justify-center">
<MapPin className="w-8 h-8 text-hint" />
</div>
</div>
{/* AI 판단 설명 */}
<div>
<div className="text-sm text-label mb-2">AI </div>
<div className="space-y-1.5">
{['MMSI 변조 패턴 감지', '3kn 이하 저속 42분간 지속', 'EEZ 1.2km 침범'].map((t, i) => (
<div key={i} className="flex items-center gap-2 text-[11px] text-muted-foreground">
<div className="w-1.5 h-1.5 rounded-full bg-green-500 shrink-0" />{t}
</div>
))}
</div>
</div>
{/* 조치 이력 */}
<div>
<div className="text-sm text-label mb-2"> </div>
{['2026-01-20 14:30: 사건 등록', '2026-01-20 14:35: 증거 수집 완료', '2026-01-20 14:45: 보고서 생성'].map((t, i) => (
<div key={i} className="text-[11px] text-hint">- {t}</div>
))}
</div>
</div>
</CardContent>
</Card>
)}
</div>
</PageContainer>
);
}