import {Check, Loader2} from 'lucide-react'; import {JobStatus} from '@o2o/shared'; import {Button} from '@/components/ui/button'; import {Progress} from '@/components/ui/progress'; import {cn} from '@/lib/utils'; import {useBuilderStore} from '@/stores/builder'; import {useGenerationJob} from './useGenerationJob'; import {GENERATION_LABELS, SKIP_REASONS} from './generationLabels'; /* * ★ 겉모습만 옛 화면 스타일이고 데이터는 실제 잡 진행 상태다. `useGenerationJob` * (새로고침해도 jobId 로 이어서 봄, 실패 시 복구 버튼)을 그대로 쓰고, 카드 모양· * 진행률 바·번호 동그라미 목록만 그 스타일로 그린다. 단계 문구는 실제로 이 COPY * 잡이 하는 일(prepare/generate/save/faq_fill)만 적는다 — 자세한 배경은 DEVLOG.md. */ export function Step5Generating() { const storeName = useBuilderStore((s) => s.storeName); const placeId = useBuilderStore((s) => s.placeId); const {job, error, checkAgain, openEditor, goBack} = useGenerationJob(placeId); const failed = job?.status === JobStatus.DEAD; const waiting = job?.status === JobStatus.PENDING; const steps = job?.progress?.steps ?? []; const total = steps.length; const doneCount = steps.filter((s) => s.status === 'done' || s.status === 'skipped').length; const progress = total ? Math.min(100, Math.round((doneCount / total) * 100)) : 0; const runningIndex = steps.findIndex((s) => s.status === 'running'); const currentLabel = runningIndex >= 0 ? GENERATION_LABELS[steps[runningIndex].id] ?? '콘텐츠 처리' : job?.status === JobStatus.DONE ? '완료' : '준비 중'; const title = error ? '진행 상태 확인이 필요합니다' : failed ? '콘텐츠 생성을 완료하지 못했습니다' : waiting ? (job.attempts ? '생성을 다시 시도할 예정입니다' : '생성 순서를 기다리고 있습니다') : job?.status === JobStatus.DONE ? '콘텐츠 생성을 마쳤습니다' : '웹사이트를 생성하고 있습니다'; return (
{!error && !failed ? : }

{title}

{error || ( <> {storeName}의 확인된 정보만 담아 정적 페이지로 굽고 있어요. )}

{total > 0 && (
{currentLabel} {progress}%
    {steps.map((step, index) => { const state = step.status === 'running' && failed ? 'failed' : step.status; const isDone = state === 'done' || state === 'skipped'; const isCurrent = state === 'running'; return (
  1. {isDone ? : index + 1} {GENERATION_LABELS[step.id] ?? '콘텐츠 처리'} {step.reason && ( ({SKIP_REASONS[step.reason] ?? '건너뜀'}) )}
  2. ); })}
)} {!error && !failed && (

새로고침해도 같은 작업의 진행 상태를 이어서 확인합니다.

)} {(error || failed) && (
{error && }
)}
); }