import React from "react";
import { Check } from "lucide-react";
export type StageKey = "scan" | "route" | "section" | "design" | "quantity" | "document";
export interface WorkflowState {
current_stage: StageKey;
completed: StageKey[];
stale_from: StageKey | null;
stage1_confirmed: any | null;
}
interface StageInfo {
key: StageKey;
label: string;
}
const STAGES: StageInfo[] = [
{ key: "scan", label: "지표면 모델 분석" },
{ key: "route", label: "경로 설계 (BP/EP/CP)" },
{ key: "section", label: "종·횡단 생성" },
{ key: "design", label: "예정 설계" },
{ key: "quantity", label: "수량 산출" },
{ key: "document", label: "견적/문서" },
];
interface WorkflowBarProps {
state: WorkflowState;
onNavigate: (stage: StageKey) => void;
}
export function WorkflowBar({ state, onNavigate }: WorkflowBarProps) {
return (
{STAGES.map((stage, idx) => {
const isCurrent = state.current_stage === stage.key;
const isCompleted = state.completed.includes(stage.key);
const isStale = state.stale_from !== null && STAGES.findIndex(s => s.key === state.stale_from) <= idx;
const canClick = stage.key === "scan"
|| (stage.key === "route" && state.completed.includes("scan"))
|| (stage.key === "section" && state.completed.includes("route"))
|| isCompleted;
// 현재는 1~3단계까지 활성화한다.
const isSupported = stage.key === "scan" || stage.key === "route" || stage.key === "section";
const activeClick = canClick && isSupported;
return (
activeClick && onNavigate(stage.key)}
style={{
display: "flex",
alignItems: "center",
gap: "8px",
cursor: activeClick ? "pointer" : "not-allowed",
opacity: isSupported ? 1 : 0.4,
position: "relative"
}}
>
{isCompleted ? : idx + 1}
{stage.label}
{isStale && (
stale
)}
{idx < STAGES.length - 1 && (
)}
);
})}
);
}