add : page tout savoir récupération des produits

feature/page-admin
Eric 4 years ago
parent 99ac2e0b79
commit 7827aa119f

@ -5,11 +5,34 @@ import style from '../styles/ToutSavoir.module.css'
import test from '../public/images/coffret-the-PhotoRoom.webp'; import test from '../public/images/coffret-the-PhotoRoom.webp';
import prisma from "../lib/prisma";
const ToutSavoir = () => { export async function getStaticProps() {
const produits = await prisma.produit.findMany();
return {
props: {
produits,
},
}
}
type Props = {
produits: Produit[];
}
type Produit = {
id: number;
actif: boolean;
nomProduit: string;
prixTtc: number;
}
const ToutSavoir = ({ produits }: Props) => {
console.log('p', produits);
return ( return (
<> <>
<Head> <Head>
<title>Tout savoir</title> <title>Tout savoir</title>
<meta name="description" content="Tout savoir" /> <meta name="description" content="Tout savoir" />
@ -21,73 +44,33 @@ const ToutSavoir = () => {
<link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
</Head> </Head>
{/* backgroundImagePath={'/images/ugh.png'} */} {/* backgroundImagePath={'/images/ugh.png'} */}
<div className="body-content"> <div className="body-content">
<h1 className="text-center mt-3">Tout savoir sur le jeu concours</h1> <h1 className="text-center mt-3">Tout savoir sur le jeu concours</h1>
<div className="container"> <div className="container">
<p className="mt-5 text-center"> <p className="mt-5 text-center">
Le jeu concours vous est proposé à l'occasion de ... Le jeu concours vous est proposé à l'occasion de ...
</p> </p>
<div className="row"> <div className="row">
<div className="col-6 col-lg-3 d-flex justify-content-center my-2 my-lg-3"> {produits.map((produit: Produit) => {
<div className={`${style.aCard} card`}> return <div className="col-6 col-lg-3 d-flex justify-content-center my-2 my-lg-3" key={produit.id}>
<Image <div className={`${style.aCard} card`}>
className="card-img-top" src={test}
width="286"
height="180"
alt="produit"
/>
<div className="card-body">
<h5 className="card-title">Card title</h5>
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<div className="col-6 col-lg-3 d-flex justify-content-center my-2 my-lg-3">
<div className={`${style.aCard} card`}>
<Image
className="card-img-top" src={test}
width="286"
height="180"
alt="produit"
/>
<div className="card-body">
<h5 className="card-title">Card title</h5>
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<div className="col-6 col-lg-3 d-flex justify-content-center my-2 my-lg-3">
<div className={`${style.aCard} card`}>
<Image
className="card-img-top" src={test}
width="286"
height="180"
alt="produit"
/>
<div className="card-body">
<h5 className="card-title">Card title</h5>
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<div className="col-6 col-lg-3 d-flex justify-content-center my-2 my-lg-3">
<div className={`${style.aCard} card`}>
<Image <Image
className="card-img-top" src={test} className="card-img-top" src={test}
width="286" width="286"
height="180" height="180"
alt="produit" alt="produit"
/> />
<div className="card-body"> <div className="card-body">
<h5 className="card-title">Card title</h5> <h5 className="card-title">{produit.nomProduit}</h5>
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div> </div>
</div> </div>
</div> </div>
</div> })}
</div> </div>
</div> </div>
</div>
</> </>
); );
}; };

@ -93,7 +93,7 @@ model Produit {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
actif Boolean? actif Boolean?
nomProduit String? nomProduit String?
prixTtc Decimal? prixTtc Int?
refGain Gain[] refGain Gain[]
} }

Loading…
Cancel
Save