"use client"; import { useEffect, useState } from "react"; import { useParams } from "next/navigation"; import { useSession } from "next-auth/react"; import { Loader2 } from "lucide-react"; import { FreshIdeaMain } from "@/components/project-main/FreshIdeaMain"; import { ChatImportMain } from "@/components/project-main/ChatImportMain"; import { CodeImportMain } from "@/components/project-main/CodeImportMain"; import { MigrateMain } from "@/components/project-main/MigrateMain"; interface Project { id: string; productName: string; name?: string; stage?: "discovery" | "architecture" | "building" | "active"; creationMode?: "fresh" | "chat-import" | "code-import" | "migration"; creationStage?: string; sourceData?: { chatText?: string; repoUrl?: string; liveUrl?: string; hosting?: string; description?: string; }; analysisResult?: Record; migrationPlan?: string; } export default function ProjectOverviewPage() { const params = useParams(); const projectId = params.projectId as string; const { status: authStatus } = useSession(); const [project, setProject] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { if (authStatus !== "authenticated") { if (authStatus === "unauthenticated") setLoading(false); return; } fetch(`/api/projects/${projectId}`) .then(r => r.json()) .then(d => setProject(d.project)) .catch(() => {}) .finally(() => setLoading(false)); }, [authStatus, projectId]); if (loading) { return (
); } if (!project) { return (
Project not found.
); } const projectName = project.productName || project.name || "Untitled"; const mode = project.creationMode ?? "fresh"; if (mode === "chat-import") { return ( [0]["analysisResult"]} /> ); } if (mode === "code-import") { return ( ); } if (mode === "migration") { return ( ); } // Default: "fresh" — wraps AtlasChat with decision banner return ( ); }