"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; export default function NewProjectPage() { const [formData, setFormData] = useState({ name: "", description: "", technologies: "", image: "", url: "", source: "", status: "En cours", }); const router = useRouter(); const handleChange = (e: React.ChangeEvent) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const res = await fetch("/api/projects", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(formData), }); if (res.ok) { router.push("/projects"); } else { const error = await res.json(); alert(`Erreur lors de la tentative d'ajout d'un projet : ${error.error}`); } }; return (

Créer un projet

{Object.keys(formData).map((key) => (
{key === "description" ? (