From bcf4c96e3b49efe9008401ddec3eca9adc312613 Mon Sep 17 00:00:00 2001 From: Melissa Date: Thu, 25 Jun 2026 11:55:05 +0200 Subject: [PATCH] tried adding the tri in form but doesnt work --- react-project/src/App.jsx | 44 +++++++++++++++++-- react-project/src/components/Badge.jsx | 2 +- .../src/components/BarreRecherche.jsx | 33 ++------------ react-project/src/components/Carte.jsx | 2 +- react-project/src/components/Form.jsx | 26 +++++++++++ 5 files changed, 72 insertions(+), 35 deletions(-) create mode 100644 react-project/src/components/Form.jsx diff --git a/react-project/src/App.jsx b/react-project/src/App.jsx index 18f4b0b..5e27d79 100644 --- a/react-project/src/App.jsx +++ b/react-project/src/App.jsx @@ -1,6 +1,7 @@ import Header from "./components/Header"; import Footer from "./components/Footer"; import Carte from "./components/Carte"; +import BarreRecherche from "./components/BarreRecherche"; import { useState, useEffect } from "react"; import "./App.css"; @@ -9,6 +10,25 @@ function App() { const [total, setTotal] = useState(0); const [jeux, setJeux] = useState([]); const [chargement, setChargement] = useState(true); + const [titre, setTitre] = useState(""); + const [annee, setAnnee] = useState(""); + const [console, setConsole] = useState(""); + + function ajouter(e) { + e.preventDefault(); + if (titre.trim() === "") return; + const nouveau = { + id: Date.now(), + titre, + annee: Number(annee), + console, + Type: "3d", + }; + setJeux([...jeux, nouveau]); + setTitre(""); + setAnnee(""); + setConsole(""); + } const filtres = jeux.filter((j) => j.titre.toLowerCase().includes(recherche.toLowerCase()), @@ -30,9 +50,7 @@ function App() { <>
- setRecherche(e.target.value)} /> @@ -46,12 +64,32 @@ function App() { titre={jeu.titre} console={jeu.console} annee={jeu.annee} + Type={jeu.Type} onLike={() => setTotal((t) => t + 1)} /> ))}

Total de likes : {total}

+
+ setTitre(e.target.value)} + placeholder="Titre du jeu" + /> + setAnnee(e.target.value)} + placeholder="Année" + /> + setConsole(e.target.value)} + placeholder="Console" + /> + +
+