From 2def92dc25280a165ad6f31879776003e190d2b3 Mon Sep 17 00:00:00 2001 From: Laurian Dufrechou Date: Mon, 27 Mar 2023 15:30:51 +0200 Subject: [PATCH] UserProfile --- src/components/BottomBar.tsx | 24 +++++++ src/pages/userProfile.tsx | 120 +++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 src/components/BottomBar.tsx create mode 100644 src/pages/userProfile.tsx diff --git a/src/components/BottomBar.tsx b/src/components/BottomBar.tsx new file mode 100644 index 0000000..0a23dcb --- /dev/null +++ b/src/components/BottomBar.tsx @@ -0,0 +1,24 @@ +import { + Box, + Flex, + Text, + Button, + Image, + } from '@chakra-ui/react'; + + + export default function BottomBar(props) { + + const {variant, saveData} = props; + + return ( + + + + + + ); + + } + \ No newline at end of file diff --git a/src/pages/userProfile.tsx b/src/pages/userProfile.tsx new file mode 100644 index 0000000..38691c2 --- /dev/null +++ b/src/pages/userProfile.tsx @@ -0,0 +1,120 @@ +import { useSession } from "next-auth/react"; +import { useRouter } from "next/router"; +import type {Session} from '@/models/auth/Session'; +import Carousel from "@/components/Carousel"; +import { Box, Button, Center, Container, Divider, Editable, EditableInput, EditablePreview, EditableTextarea, Flex, Spacer, Text, useToast } from "@chakra-ui/react"; + +import {RiEditBoxLine} from "react-icons/ri" +import BottomBar from "@/components/BottomBar"; +import { useState } from "react"; + +export default function UserProfile() { + const router = useRouter(); + const {data: session, status} = useSession(); + const [isLoading, setIsLoading] = useState(false); + + // faire un model avec toutes les infos de user + const [loginData, setLoginData] = useState(new userData()); + + + const toast = useToast(); + + // if (status === 'unauthenticated') router.push('/login'); + + // if (status === 'authenticated') { + // const {user} = session as unknown as Session; + + + const saveData = () => { + // let {email, firstName, lastName, password, confirmPassword} = registerData; + toast({ + title: `Modifications effectuées`, + status: "success", + isClosable: true, + }) + // const options = { + // method: 'POST', + // headers: {'Content-Type': 'application/json'}, + // body: JSON.stringify(userData), + // }; + + // setIsLoading(true); + // fetch('/api/users', options).then(() => { + // setIsLoading(false) + // toast({ + // title: `Modifications effectuées`, + // status: "success", + // isClosable: true, + // }) + + // }).catch(() => { + // setIsLoading(false); + // toast({ + // title: `Erreur lors de l'envoi des modifications`, + // status: "error", + // isClosable: true, + // }) + // }); + }; + + const formateDate = (dateString: string) => { + var options = { year: 'numeric', month: 'long', day: 'numeric' }; + return new Date(dateString).toLocaleDateString([],options); + } + + var dateString = "2018-05-18T04:00:00.000Z" + console.log(formateDate(dateString)); + + + const refinedUser = { + // ...user, + firstName: "Jean", + lastName: "Dujardin", + birthdate: formateDate(new Date), + aPropos: 'Je suis la personne fictive la plus fictive', + images: ['135538.webp'], + passions: ['Sport', 'Voiture', 'Cuisine'], + }; + + return ( + + + + + + + + + + Modifiez les champs en les selectionnants + + + + Prénom : + {value = refinedUser.lastName}}> + + + + + + Nom : + refinedUser.firstName = value}> + + + + + + Date de naissance : + + {refinedUser.birthdate} + + + + + + + + + ); + // } +} \ No newline at end of file