From f1e39e12e974ee30ee9e43c590d85188cc3a3b1a Mon Sep 17 00:00:00 2001 From: Laurian-Dufrechou Date: Tue, 21 Mar 2023 22:05:14 +0100 Subject: [PATCH] feat(finished Card): Finished Card, missing responsive --- src/components/CardUser.jsx | 6 +-- src/components/Carousel.jsx | 87 +++++++++++++++++++++++++++++++--- src/pages/api/user/readUser.ts | 33 ++++++------- src/pages/test_card.jsx | 6 ++- 4 files changed, 104 insertions(+), 28 deletions(-) diff --git a/src/components/CardUser.jsx b/src/components/CardUser.jsx index 50bb38f..5068b13 100644 --- a/src/components/CardUser.jsx +++ b/src/components/CardUser.jsx @@ -4,7 +4,7 @@ import Carousel from "./Carousel"; export default function CardUser(props) { const { user } = props; // const data_user = props; - const borderRad = "1.5rem"; + const borderRad = "2rem"; return ( diff --git a/src/components/Carousel.jsx b/src/components/Carousel.jsx index 3ef7d03..2ecb074 100644 --- a/src/components/Carousel.jsx +++ b/src/components/Carousel.jsx @@ -1,7 +1,23 @@ import React from "react"; -import { Box, IconButton, useBreakpointValue } from "@chakra-ui/react"; +import { + Box, + Flex, + Spacer, + IconButton, + useBreakpointValue, + ButtonGroup, + Badge, + Text, +} from "@chakra-ui/react"; // Here we have used react-icons package for the icons -import { BiLeftArrowAlt, BiRightArrowAlt } from "react-icons/bi"; +import { + BiLeftArrowAlt, + BiRightArrowAlt, + BiHeart, + // RxCross1, +} from "react-icons/bi"; + +import { RxCross1 } from "react-icons/rx"; // And react-slick as our Carousel Lib import Slider from "react-slick"; @@ -19,11 +35,25 @@ const settings = { }; export default function Carousel(props) { - const { heightPhoto, heightText, borderRadiusImg, user } = props; + const { borderRadiusImg, user } = props; // As we have used custom buttons, we need a reference variable to // change the state + + // C'est l'utilisateur qui est login + const actualUser = { + lastName: "Alexandra", + firstName: "Lamie", + age: 21, + aPropos: "Je suis la personne fictive la plus fictive", + images: ["401446.webp"], + passions: ["Sport", "Voiture", "Cuisine"], + }; + const [slider, setSlider] = React.useState(); + const heightPhoto = "75vh"; + const heightText = "25vh"; + // These are the breakpoints which changes the position of the // buttons as the screen size changes const top = useBreakpointValue({ base: "90%", md: "50%" }); @@ -98,10 +128,53 @@ export default function Carousel(props) { ))} - -

- {user.name} {user.surname} , {user.age} -

+ + +

+ {user.firstName} {user.lastName} , {user.age} ans +

+ + + + + + + + + + + + + +
+ + + {user.aPropos} + + +

Passions :

+ + {user.passions.map((passion, index) => + actualUser.passions.includes(passion) ? ( + + #{passion} + + ) : ( + #{passion} + ) + )} + +
); diff --git a/src/pages/api/user/readUser.ts b/src/pages/api/user/readUser.ts index 2d4fe43..3fd0dd9 100644 --- a/src/pages/api/user/readUser.ts +++ b/src/pages/api/user/readUser.ts @@ -1,23 +1,24 @@ -import {NextApiRequest, NextApiResponse} from 'next'; -import { PrismaClient } from '@prisma/client' +import { NextApiRequest, NextApiResponse } from "next"; +import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); -export default async function readUser(req: NextApiRequest, res: NextApiResponse) { - - const {email, password} = req.query - - if(!email) { - const users = await prisma.user.findMany() - return res.status(200).send({message: "readUser", users}); +export default async function readUser( + req: NextApiRequest, + res: NextApiResponse +) { + const { email, password } = req.query; + + if (!email && !password) { + const users = await prisma.user.findMany(); + return res.status(200).send({ message: "readUser", users }); } - - const user = await prisma.user.findUnique({where :{"email" : email}}) - + + const user = await prisma.user.findUnique({ where: { email: email } }); + if (user?.password == password) { - res.status(200).send({message: "User found", user}); + res.status(200).send({ message: "User found", user }); } - res.status(400).send({message: "Mot de passe incorrect"}); - -} \ No newline at end of file + res.status(400).send({ message: "Mot de passe incorrect" }); +} diff --git a/src/pages/test_card.jsx b/src/pages/test_card.jsx index 37747d9..d436f0f 100644 --- a/src/pages/test_card.jsx +++ b/src/pages/test_card.jsx @@ -2,13 +2,15 @@ import CardUser from "../components/CardUser"; export default function Test_card() { const user = { - name: "dujardin", - surname: "jean", + lastName: "dujardin", + firstName: "jean", age: 19, aPropos: "Je suis une personne fictive, pas tres fictive", images: ["401446.webp"], passions: ["Sport", "Piscine", "Formule1"], }; + //faudra faire une requete sur la BD pour chaque utilisateurs + return ; }