"use client"; import { CheckCircle2, Circle } from "lucide-react"; import { useEffect, useState } from "react"; import { db } from "@/lib/firebase/config"; import { doc, onSnapshot } from "firebase/firestore"; interface ExtractionReviewChecklistProps { projectId: string; className?: string; } export function ExtractionReviewChecklist({ projectId, className }: ExtractionReviewChecklistProps) { const [hasProblems, setHasProblems] = useState(false); const [hasUsers, setHasUsers] = useState(false); const [hasFeatures, setHasFeatures] = useState(false); const [reviewedWithAI, setReviewedWithAI] = useState(false); const [readyForVision, setReadyForVision] = useState(false); useEffect(() => { if (!projectId) return; const unsubscribe = onSnapshot( doc(db, "projects", projectId), (snapshot) => { if (snapshot.exists()) { const data = snapshot.data(); const extraction = data?.phaseData?.phaseHandoffs?.extraction; if (extraction) { // Check if we have key data setHasProblems((extraction.confirmed?.problems?.length || 0) > 0); setHasUsers((extraction.confirmed?.targetUsers?.length || 0) > 0); setHasFeatures((extraction.confirmed?.features?.length || 0) > 0); setReadyForVision(extraction.readyForNextPhase || false); } // Check if user has reviewed with AI (simplified: check if there are any messages in chat) // This is a placeholder - you might track this differently setReviewedWithAI(data?.lastChatAt ? true : false); } } ); return () => unsubscribe(); }, [projectId]); const checklist = [ { id: "problems", label: "Problems identified", checked: hasProblems, }, { id: "users", label: "Target users defined", checked: hasUsers, }, { id: "features", label: "Key features extracted", checked: hasFeatures, }, { id: "reviewed", label: "Reviewed with AI", checked: reviewedWithAI, }, ]; const completedCount = checklist.filter((item) => item.checked).length; const progress = (completedCount / checklist.length) * 100; const isCompleted = completedCount === checklist.length || readyForVision; return (
{isCompleted ? `${checklist.length} of ${checklist.length} complete` : `${completedCount} of ${checklist.length} complete`}
{item.label}
✓ Ready for Vision phase