"use client"; import { useEffect, useState } from "react"; import { useParams } from "next/navigation"; const PRD_SECTIONS = [ { id: "executive_summary", label: "Executive Summary" }, { id: "problem_statement", label: "Problem Statement" }, { id: "users_personas", label: "Users & Personas" }, { id: "user_flows", label: "User Flows" }, { id: "feature_requirements", label: "Feature Requirements" }, { id: "screen_specs", label: "Screen Specs" }, { id: "business_model", label: "Business Model" }, { id: "non_functional", label: "Non-Functional Reqs" }, { id: "risks", label: "Risks" }, ]; interface PRDSection { id: string; label: string; status: "done" | "active" | "pending"; pct: number; content?: string; } interface Project { id: string; prd?: string; prdSections?: Record; } export default function PRDPage() { const params = useParams(); const projectId = params.projectId as string; const [project, setProject] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { fetch(`/api/projects/${projectId}`) .then((r) => r.json()) .then((d) => { setProject(d.project); setLoading(false); }) .catch(() => setLoading(false)); }, [projectId]); // Build sections with real status if available const sections: PRDSection[] = PRD_SECTIONS.map((s) => { const saved = project?.prdSections?.[s.id]; return { ...s, status: (saved?.status as PRDSection["status"]) ?? "pending", pct: saved?.pct ?? 0, content: saved?.content, }; }); // If we have a raw PRD markdown, show that instead of the section list const hasPRD = Boolean(project?.prd); const totalPct = Math.round(sections.reduce((a, s) => a + s.pct, 0) / sections.length); const doneCount = sections.filter((s) => s.status === "done").length; if (loading) { return (
Loading…
); } return (
{hasPRD ? ( /* ── Raw PRD view ── */

Product Requirements

PRD approved
{project?.prd}
) : ( /* ── Section progress view ── */
{/* Progress bar */}
{totalPct}%
{doneCount}/{sections.length} approved
{/* Sections */} {sections.map((s, i) => (
(e.currentTarget.style.borderColor = "#d0ccc4")} onMouseLeave={(e) => (e.currentTarget.style.borderColor = "#e8e4dc")} > {/* Status icon */}
{s.status === "done" ? "✓" : s.status === "active" ? "◐" : "○"}
{s.label} {/* Mini progress bar */}
{s.pct}%
))} {/* Hint */}

Continue chatting with Atlas to complete your PRD

)}
); }