'use client'; /** * 공정상세 섹션 컴포넌트 * * WorkCard 내부에서 토글 확장되는 공정 상세 정보 * - 자재 투입 필요 섹션 * - 공정 단계 (5단계) * - 각 단계별 세부 항목 */ import { useState } from 'react'; import { Package, CheckCircle2, Circle, AlertTriangle, MapPin, Ruler } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { cn } from '@/lib/utils'; import type { ProcessStep, ProcessStepItem } from './types'; // Mock 공정 단계 데이터 const MOCK_PROCESS_STEPS: ProcessStep[] = [ { id: 'step-1', stepNo: 1, name: '절곡판/코일 절단', completed: 0, total: 2, items: [ { id: 'item-1-1', itemNo: '#1', location: '1층 1호-A', isPriority: true, spec: 'W2500 × H3000', material: '절곡판', lot: 'LOT-절곡-2025-001', }, { id: 'item-1-2', itemNo: '#2', location: '1층 1호-B', isPriority: false, spec: 'W2000 × H2500', material: '절곡판', lot: 'LOT-절곡-2025-002', }, ], }, { id: 'step-2', stepNo: 2, name: 'V컷팅', completed: 0, total: 2, items: [ { id: 'item-2-1', itemNo: '#1', location: '1층 2호-A', isPriority: false, spec: 'V10 × L2500', material: 'V컷팅재', lot: 'LOT-V컷-2025-001', }, ], }, { id: 'step-3', stepNo: 3, name: '절곡', completed: 0, total: 3, items: [ { id: 'item-3-1', itemNo: '#1', location: '2층 1호', isPriority: true, spec: '90° × 2회', material: '절곡판', lot: 'LOT-절곡-2025-001', }, ], }, { id: 'step-4', stepNo: 4, name: '중간검사', isInspection: true, completed: 0, total: 1, items: [], }, { id: 'step-5', stepNo: 5, name: '포장', completed: 0, total: 1, items: [], }, ]; interface ProcessDetailSectionProps { isExpanded: boolean; materialRequired: boolean; onMaterialInput: () => void; } export function ProcessDetailSection({ isExpanded, materialRequired, onMaterialInput, }: ProcessDetailSectionProps) { const [steps] = useState(MOCK_PROCESS_STEPS); const [expandedSteps, setExpandedSteps] = useState>(new Set()); const totalSteps = steps.length; const completedSteps = steps.filter((s) => s.completed === s.total).length; const toggleStep = (stepId: string) => { setExpandedSteps((prev) => { const next = new Set(prev); if (next.has(stepId)) { next.delete(stepId); } else { next.add(stepId); } return next; }); }; if (!isExpanded) return null; return (
{/* 자재 투입 필요 섹션 */} {materialRequired && (
자재 투입이 필요합니다
)} {/* 공정 단계 헤더 */}

공정 단계

{completedSteps}/{totalSteps} 완료
{/* 공정 단계 목록 */}
{steps.map((step) => ( toggleStep(step.id)} /> ))}
); } // ===== 하위 컴포넌트 ===== interface ProcessStepCardProps { step: ProcessStep; isExpanded: boolean; onToggle: () => void; } function ProcessStepCard({ step, isExpanded, onToggle }: ProcessStepCardProps) { const isCompleted = step.completed === step.total; const hasItems = step.items.length > 0; return (
{isCompleted ? ( ) : ( )}
{step.stepNo}. {step.name} {step.isInspection && ( 검사 )}
{step.completed}/{step.total} 완료
{hasItems && ( {isExpanded ? '접기' : '펼치기'} )}
{hasItems && (
{step.items.map((item) => ( ))}
)}
); } interface ProcessStepItemCardProps { item: ProcessStepItem; } function ProcessStepItemCard({ item }: ProcessStepItemCardProps) { return (
{item.itemNo} {item.isPriority && ( 선행 생산 )}
{item.lot}
{item.location}
{item.spec}
자재: {item.material}
); }