"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { Plus } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { useProjects } from "@/components/projects/projects-context"; const TITLE_MAX = 60; /** The "+ New project" tile on the /projects list -- creates, then jumps * straight into the new project's (empty) board. */ export function CreateProjectDialog() { const { addProject } = useProjects(); const router = useRouter(); const [open, setOpen] = useState(false); const [title, setTitle] = useState(""); const [pending, setPending] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); const trimmed = title.trim(); if (!trimmed) return; setPending(true); const project = await addProject(trimmed); setPending(false); if (!project) return; setTitle(""); setOpen(false); router.push(`/projects/${project.id}`); } return ( New Project } /> New project
setTitle(e.target.value)} placeholder="e.g. Kitchen Remodel" />
); }