"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { ArrowLeft, ArrowRight, Check, Sparkles, Code2 } from "lucide-react"; import { useRouter } from "next/navigation"; type ProjectType = "scratch" | "existing" | null; export default function NewProjectPage() { const router = useRouter(); const [step, setStep] = useState(1); const [projectName, setProjectName] = useState(""); const [projectType, setProjectType] = useState(null); // Product vision (can skip) const [productVision, setProductVision] = useState(""); // Product details const [productName, setProductName] = useState(""); const [isForClient, setIsForClient] = useState(null); const [hasLogo, setHasLogo] = useState(null); const [hasDomain, setHasDomain] = useState(null); const [hasWebsite, setHasWebsite] = useState(null); const [hasGithub, setHasGithub] = useState(null); const [hasChatGPT, setHasChatGPT] = useState(null); const [isCheckingSlug, setIsCheckingSlug] = useState(false); const [slugAvailable, setSlugAvailable] = useState(null); const generateSlug = (name: string) => { return name .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/^-+|-+$/g, ""); }; const checkSlugAvailability = async (name: string) => { const slug = generateSlug(name); if (!slug) return; setIsCheckingSlug(true); // TODO: Replace with actual API call await new Promise(resolve => setTimeout(resolve, 500)); // Mock check - in reality, check against database const isAvailable = !["test", "demo", "admin"].includes(slug); setSlugAvailable(isAvailable); setIsCheckingSlug(false); }; const handleProductNameChange = (value: string) => { setProductName(value); setSlugAvailable(null); if (value.length > 2) { checkSlugAvailability(value); } }; const handleNext = () => { if (step === 1 && projectName && projectType) { setStep(2); } else if (step === 2) { // Can skip questions setStep(3); } else if (step === 3 && productName && slugAvailable) { handleCreateProject(); } }; const handleBack = () => { if (step > 1) setStep(step - 1); }; const handleSkipQuestions = () => { setStep(3); }; const handleCreateProject = async () => { const slug = generateSlug(productName); const projectData = { projectName, projectType, slug, vision: productVision, product: { name: productName, isForClient, hasLogo, hasDomain, hasWebsite, hasGithub, hasChatGPT, }, }; // TODO: API call to create project console.log("Creating project:", projectData); // Redirect to the new project router.push(`/${slug}/overview`); }; const canProceedStep1 = projectName.trim() && projectType; const canProceedStep3 = productName.trim() && slugAvailable; return (
{/* Header */}

Create New Project

Step {step} of 3

{/* Progress */}
{[1, 2, 3].map((s) => (
))}
{/* Step 1: Project Setup */} {step === 1 && ( Project Setup Give your project a name and choose how you want to start
setProjectName(e.target.value)} />
)} {/* Step 2: Product Vision */} {step === 2 && ( Describe your product vision Help us understand your project (you can skip this)