cliquer sur un item envoie a une page de detail avec son id

This commit is contained in:
Medenos 2022-10-16 21:22:41 -04:00
parent 6eb27b319b
commit 67e0aa9636
4 changed files with 36 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import AboutUs from "../pages/AboutUs";
import Privacy from "../pages/Privacy"; import Privacy from "../pages/Privacy";
import ContactUs from "../pages/ContactUs"; import ContactUs from "../pages/ContactUs";
import Morceaux from "../pages/Morceaux"; import Morceaux from "../pages/Morceaux";
import MorceauDetail from "../pages/MorceauDetail";
const App = () => { const App = () => {
@ -17,6 +18,7 @@ const App = () => {
<Route path="aboutUs" element={<AboutUs/>} /> <Route path="aboutUs" element={<AboutUs/>} />
<Route path="contactUs" element={<ContactUs/>}/> <Route path="contactUs" element={<ContactUs/>}/>
<Route path="privacy" element={<Privacy/>}/> <Route path="privacy" element={<Privacy/>}/>
<Route path="morceaux/:id" element={<MorceauDetail/>}/>
</Route> </Route>
</Routes> </Routes>
</BrowserRouter> </BrowserRouter>

View File

@ -1,5 +1,6 @@
import { Button } from 'react-bootstrap'; import { Button } from 'react-bootstrap';
import Item from './Item'; import Item from './Item';
import { Link } from 'react-router-dom';
const ItemList = ({ items }) => { const ItemList = ({ items }) => {
@ -7,12 +8,15 @@ const ItemList = ({ items }) => {
<> <>
<div className='item-list'> <div className='item-list'>
{items.map((item) => {items.map((item) =>
<Item imageUrl={item.imageUrl} <Link className='item-link' to={`/morceaux/${item.id}`}>
name={item.name} <Item key={item.id} imageUrl={item.imageUrl}
price={item.price} name={item.name}
status={item.status} price={item.price}
newPrice={item.newPrice} status={item.status}
/> newPrice={item.newPrice}
/>
</Link>
)} )}
</div> </div>
<div> <div>

View File

@ -0,0 +1,19 @@
import { useEffect } from "react";
import {useParams} from "react-router-dom";
const MorceauDetail = () => {
const {id} = useParams();
useEffect(() => {
document.title = 'Morceaux';
});
return (
<>
<p>{id}</p>
</>
);
}
export default MorceauDetail;

View File

@ -345,6 +345,11 @@ html {
} }
.item-link, .item-link:hover{
color: black;
text-decoration: none;
}
.btn-primary{ .btn-primary{
background-color: purple; background-color: purple;