"use client"; import React from "react"; import { X, Play, Square, ChevronRight } from "lucide-react"; import { WorkOrder, WorkStep } from "./types"; interface PopProductionPanelProps { isOpen: boolean; workOrder: WorkOrder | null; workSteps: WorkStep[]; currentStepIndex: number; currentDateTime: Date; onStepChange: (index: number) => void; onStepsUpdate: (steps: WorkStep[]) => void; onClose: () => void; } export function PopProductionPanel({ isOpen, workOrder, workSteps, currentStepIndex, currentDateTime, onStepChange, onStepsUpdate, onClose, }: PopProductionPanelProps) { if (!isOpen || !workOrder) return null; const currentStep = workSteps[currentStepIndex]; const formatDate = (date: Date) => { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; }; const formatTime = (date: Date | null) => { if (!date) return "--:--"; const d = new Date(date); return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`; }; const handleStartStep = () => { const newSteps = [...workSteps]; newSteps[currentStepIndex] = { ...newSteps[currentStepIndex], status: "in-progress", startTime: new Date(), }; onStepsUpdate(newSteps); }; const handleEndStep = () => { const newSteps = [...workSteps]; newSteps[currentStepIndex] = { ...newSteps[currentStepIndex], endTime: new Date(), }; onStepsUpdate(newSteps); }; const handleSaveAndNext = () => { const newSteps = [...workSteps]; const step = newSteps[currentStepIndex]; // 시간 자동 설정 if (!step.startTime) step.startTime = new Date(); if (!step.endTime) step.endTime = new Date(); step.status = "completed"; onStepsUpdate(newSteps); // 다음 단계로 이동 if (currentStepIndex < workSteps.length - 1) { onStepChange(currentStepIndex + 1); } }; const renderStepForm = () => { if (!currentStep) return null; const isCompleted = currentStep.status === "completed"; if (currentStep.type === "work" || currentStep.type === "record") { return (

작업 내용 입력