"use client"; import { useEffect, useState } from "react"; import { AtlasChat } from "@/components/AtlasChat"; import { useRouter, useParams } from "next/navigation"; const DISCOVERY_PHASES = [ "big_picture", "users_personas", "features_scope", "business_model", "screens_data", "risks_questions", ]; interface FreshIdeaMainProps { projectId: string; projectName: string; } export function FreshIdeaMain({ projectId, projectName }: FreshIdeaMainProps) { const router = useRouter(); const params = useParams(); const workspace = params?.workspace as string; const [savedPhaseIds, setSavedPhaseIds] = useState>(new Set()); const [allDone, setAllDone] = useState(false); const [prdLoading, setPrdLoading] = useState(false); const [dismissed, setDismissed] = useState(false); useEffect(() => { const poll = () => { fetch(`/api/projects/${projectId}/save-phase`) .then(r => r.json()) .then(d => { const ids = new Set((d.phases ?? []).map((p: { phase: string }) => p.phase)); setSavedPhaseIds(ids); const done = DISCOVERY_PHASES.every(id => ids.has(id)); setAllDone(done); }) .catch(() => {}); }; poll(); const interval = setInterval(poll, 8_000); return () => clearInterval(interval); }, [projectId]); const handleGeneratePRD = async () => { if (prdLoading) return; setPrdLoading(true); try { router.push(`/${workspace}/project/${projectId}/prd`); } finally { setPrdLoading(false); } }; const handleMVP = () => { router.push(`/${workspace}/project/${projectId}/build`); }; return (
{/* Decision banner — shown when all 6 phases are saved */} {allDone && !dismissed && (
✦ Discovery complete — what's next?
Atlas has captured all 6 discovery phases. Choose your next step.
)}
); }