import { useState } from 'react'; import type { ScatDetail } from './scatTypes'; import { sensColor, statusColor } from './scatConstants'; interface ScatRightPanelProps { detail: ScatDetail | null; loading: boolean; onOpenReport?: () => void; onNewSurvey?: () => void; } const tabs = [ { id: 0, label: '๊ตฌ๊ฐ„ ์ƒ์„ธ', icon: '๐Ÿ“‹' }, { id: 1, label: 'ํ˜„์žฅ ์‚ฌ์ง„', icon: '๐Ÿ“ท' }, { id: 2, label: '๋ฐฉ์ œ ๊ถŒ๊ณ ', icon: '๐Ÿ›ก๏ธ' }, ] as const; export default function ScatRightPanel({ detail, loading, }: Omit) { const [activeTab, setActiveTab] = useState(0); if (!detail && !loading) { return (
๐Ÿ–๏ธ
์ขŒ์ธก ๋ชฉ๋ก์—์„œ ๊ตฌ๊ฐ„์„
์„ ํƒํ•˜๋ฉด ์ƒ์„ธ ์ •๋ณด๊ฐ€
์—ฌ๊ธฐ์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
); } return (
{/* ํ—ค๋” */}
{detail ? (
{detail.esi}
{detail.name}
{detail.code}
) : (
๋กœ๋”ฉ ์ค‘...
)}
{/* ํƒญ ๋ฐ” */}
{tabs.map((tab) => ( ))}
{/* ์Šคํฌ๋กค ์˜์—ญ */}
{loading ? (
๋ฐ์ดํ„ฐ ๋กœ๋”ฉ ์ค‘...
) : detail ? ( <> {activeTab === 0 && } {activeTab === 1 && } {activeTab === 2 && } ) : null}
{/* ํ•˜๋‹จ ๋ฒ„ํŠผ */} {/*
*/}
); } /* โ•โ•โ• ํƒญ 0: ๊ตฌ๊ฐ„ ์ƒ์„ธ โ•โ•โ• */ function DetailTab({ detail }: { detail: ScatDetail }) { return (
{/* ๊ธฐ๋ณธ ์ •๋ณด */}
{/* ์ ‘๊ทผ์„ฑ */}
{/* ๋ฏผ๊ฐ ์ž์› */} {detail.sensitive && detail.sensitive.length > 0 && (
{detail.sensitive.map((s, i) => ( ))}
)}
); } /* โ•โ•โ• ํƒญ 1: ํ˜„์žฅ ์‚ฌ์ง„ โ•โ•โ• */ function PhotoTab({ detail }: { detail: ScatDetail }) { const [imgError, setImgError] = useState(false); const imgSrc = `/scat/img/${detail.code}-1.png`; if (imgError) { return (
๐Ÿ“ท
ํ•ด๋‹น ๊ตฌ๊ฐ„์˜ ์‚ฌ์ง„์ด
๋“ฑ๋ก๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
); } return (
{`${detail.name} setImgError(true)} />
{detail.code} ํ•ด์•ˆ ์กฐ์‚ฌ ์‚ฌ์ง„
); } /* โ•โ•โ• ํƒญ 2: ๋ฐฉ์ œ ๊ถŒ๊ณ  โ•โ•โ• */ function CleanupTab({ detail }: { detail: ScatDetail }) { return (
{/* ๋ฐฉ์ œ ๋ฐฉ๋ฒ• */}
{detail.cleanup && detail.cleanup.length > 0 ? (
{detail.cleanup.map((method, i) => ( {method} ))}
) : (
๋“ฑ๋ก๋œ ๋ฐฉ์ œ ๋ฐฉ๋ฒ• ์—†์Œ
)}
{/* ์ข…๋ฃŒ ๊ธฐ์ค€ */}
{detail.endCriteria && detail.endCriteria.length > 0 ? (
{detail.endCriteria.map((c, i) => (
โœ“ {c}
))}
) : (
๋“ฑ๋ก๋œ ์ข…๋ฃŒ ๊ธฐ์ค€ ์—†์Œ
)}
{/* ์ฐธ๊ณ ์‚ฌํ•ญ */}
{detail.notes && detail.notes.length > 0 ? (
{detail.notes.map((note, i) => (
{note}
))}
) : (
๋“ฑ๋ก๋œ ์ฐธ๊ณ ์‚ฌํ•ญ ์—†์Œ
)}
); } /* โ•โ•โ• ๊ณตํ†ต UI โ•โ•โ• */ function Section({ title, children }: { title: string; children: React.ReactNode }) { return (
{title}
{children}
); } function InfoRow({ label, value, valueColor, }: { label: string; value: string; valueColor?: string; }) { return (
{label} {value}
); } function InfoBlock({ label, value }: { label: string; value: string }) { return (
{label}
โ€ข {value}
); }