import React, { useState, useEffect } from 'react'; import { LoadingSpinner } from './LoadingSpinner'; import { CheckCircleIcon } from './icons/CheckCircleIcon'; import { ExclamationTriangleIcon } from './icons/ExclamationTriangleIcon'; import { StageStatus, ProcessingStage } from '../types'; interface ProcessingStatusProps { stages: ProcessingStage[]; estimatedTime: number; currentFile?: string | null; pageProgress?: {current: number, total: number} | null; bulkProgress?: number; bulkFileCount?: {current: number, total: number} | null; } interface StageIconProps { status: StageStatus; isCritical: boolean; } const StageIcon: React.FC = ({ status, isCritical }) => { switch (status) { case 'in-progress': return
; case 'completed': return ; case 'pending': return
; case 'error': return isCritical ? ( ) : ( ); default: return null; } }; export const ProcessingStatus: React.FC = ({ stages, estimatedTime, currentFile, pageProgress, bulkProgress, bulkFileCount }) => { const [timeRemaining, setTimeRemaining] = useState(estimatedTime); useEffect(() => { setTimeRemaining(estimatedTime); // Reset when component gets new props const timer = setInterval(() => { setTimeRemaining(prevTime => (prevTime > 0 ? prevTime - 1 : 0)); }, 1000); return () => clearInterval(timer); }, [estimatedTime]); const getStatusTextColor = (status: StageStatus, isCritical: boolean) => { switch (status) { case 'in-progress': return 'text-brand-primary font-semibold'; case 'completed': return 'text-gray-700 dark:text-gray-300'; case 'pending': return 'text-gray-400 dark:text-gray-500'; case 'error': return isCritical ? 'text-red-500 font-semibold' : 'text-yellow-600 dark:text-yellow-400'; default: return ''; } } // Render new layout for bulk processing if (currentFile) { const extractionStage = stages.find(s => s.name === 'Extracting All Items from Flyer' && s.status === 'in-progress' && s.progress); const stageList = (
    {stages.map((stage, index) => { const isCritical = stage.critical ?? true; return (
  • {stage.name} {!isCritical && (optional)} {stage.detail}
  • ); })}
); return (

Processing Steps for:
{currentFile}

{/* Left Column: Spinners and Progress Bars */}
{/* Overall Progress */} {bulkFileCount && (

File {bulkFileCount.current} of {bulkFileCount.total}

)} {/* PDF Conversion Progress */} {pageProgress && pageProgress.total > 1 && (

Converting PDF: Page {pageProgress.current} of {pageProgress.total}

)} {/* Item Extraction Progress */} {extractionStage && extractionStage.progress && (

Analyzing page {extractionStage.progress.current} of {extractionStage.progress.total}

)}
{/* Right Column: Checklist */}
{stageList}
); } // Original layout for single file processing const title = 'Processing Your Flyer...'; const subTitle = `Estimated time remaining: ${Math.floor(timeRemaining / 60)}m ${timeRemaining % 60}s`; return (

{title}

{subTitle}

{pageProgress && pageProgress.total > 1 && (

Converting PDF: Page {pageProgress.current} of {pageProgress.total}

)}
    {stages.map((stage, index) => { const isCritical = stage.critical ?? true; return (
  • {stage.name} {!isCritical && (optional)} {stage.detail}
    {stage.progress && stage.status === 'in-progress' && stage.progress.total > 1 && (

    Analyzing page {stage.progress.current} of {stage.progress.total}

    )}
  • ); })}
); };