small details added
This commit is contained in:
@@ -4,6 +4,8 @@ import Header from "./components/Header";
|
||||
import Footer from "./components/Footer";
|
||||
import Accueil from "./pages/Accueil";
|
||||
import Detail from "./pages/Detail";
|
||||
import NotFound from "./pages/NotFound";
|
||||
|
||||
import "./App.css";
|
||||
|
||||
function App() {
|
||||
@@ -11,6 +13,7 @@ function App() {
|
||||
const stocke = localStorage.getItem("jeux");
|
||||
return stocke ? JSON.parse(stocke) : null;
|
||||
});
|
||||
|
||||
const [likes, setLikes] = useState(() =>
|
||||
JSON.parse(localStorage.getItem("likes") || "{}"),
|
||||
);
|
||||
@@ -51,10 +54,12 @@ function App() {
|
||||
setJeux={setJeux}
|
||||
likes={likes}
|
||||
onLike={liker}
|
||||
setLikes={setLikes}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Route path="/jeu/:id" element={<Detail jeux={jeux} likes={likes} />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
<Footer />
|
||||
</>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { useState } from "react";
|
||||
|
||||
function Header() {
|
||||
const [count, setCount] = useState(0);
|
||||
return (
|
||||
<section id="center">
|
||||
<div>
|
||||
@@ -10,13 +7,6 @@ function Header() {
|
||||
<img src="https://www.greenmangaming.com/blog/wp-content/uploads/2021/06/zelda-timeline.jpg"></img>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="counter"
|
||||
onClick={() => setCount((count) => count + 1)}
|
||||
>
|
||||
Count is {count}
|
||||
</button>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import Carte from "../components/Carte";
|
||||
import BarreRecherche from "../components/BarreRecherche";
|
||||
import { useState } from "react";
|
||||
|
||||
function Accueil({ jeux, setJeux, likes, onLike }) {
|
||||
function Accueil({ jeux, setJeux, likes, setLikes, onLike }) {
|
||||
const [recherche, setRecherche] = useState("");
|
||||
const [titre, setTitre] = useState("");
|
||||
const [annee, setAnnee] = useState("");
|
||||
@@ -17,6 +17,11 @@ function Accueil({ jeux, setJeux, likes, onLike }) {
|
||||
: 0;
|
||||
function supprimer(id) {
|
||||
setJeux(jeux.filter((j) => j.id !== id));
|
||||
setLikes((prev) => {
|
||||
const copie = { ...prev }; // une COPIE (on ne modifie jamais l'ancien objet)
|
||||
delete copie[id]; // on retire l'entrée de ce jeu
|
||||
return copie; // on renvoie le nouvel objet
|
||||
});
|
||||
}
|
||||
|
||||
const top = [...jeux]
|
||||
|
||||
@@ -15,7 +15,7 @@ function Detail({ jeux, likes }) {
|
||||
<Link to="/">← Retour</Link>
|
||||
<h1>{jeu.titre}</h1>
|
||||
<p>
|
||||
{jeu.console} — {jeu.annee} — {jeu.Type}
|
||||
{jeu.plateforme} — {jeu.annee} — {jeu.Type}
|
||||
</p>
|
||||
<p>❤️ Likes : {likes[jeu.id] || 0}</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user