diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c98e612..8b21b96 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -43,8 +43,8 @@ model User { OtherUserLikesID String[] @db.ObjectId OtherUserLikes User[] @relation("Likes", fields: [OtherUserLikesID], references: [id]) - MatchId String[] @db.ObjectId - Match Match[] @relation(fields: [MatchId], references: [id]) + MatchID String[] @db.ObjectId + Match Match[] @relation(fields: [MatchID], references: [id]) Notification Notification[] } @@ -55,16 +55,16 @@ model Notification { createdAt DateTime @default(now()) hasBeenConsulted Boolean @default(false) - UserId String @db.ObjectId - User User @relation(fields: [UserId], references: [id]) + UserID String @db.ObjectId + User User @relation(fields: [UserID], references: [id]) } model Match { id String @id @default(auto()) @map("_id") @db.ObjectId createdAt DateTime @default(now()) - UserId String[] @db.ObjectId - User User[] @relation(fields: [UserId], references: [id]) + UserID String[] @db.ObjectId + User User[] @relation(fields: [UserID], references: [id]) } model Passion { @@ -74,8 +74,8 @@ model Passion { updatedAt DateTime @updatedAt // Les utilisateurs qui on en commun cette passion - UserId String[] @db.ObjectId - User User[] @relation(fields: [UserId], references: [id]) + UserID String[] @db.ObjectId + User User[] @relation(fields: [UserID], references: [id]) } model Chat { @@ -84,8 +84,8 @@ model Chat { createdAt DateTime @default(now()) // Les utilisateurs qui ont un chat en commun - User User[] @relation(fields: [UserId], references: [id]) - UserId String[] @db.ObjectId + User User[] @relation(fields: [UserID], references: [id]) + UserID String[] @db.ObjectId } model Message { diff --git a/public/logo.svg b/public/logo.svg index a692b35..0701684 100644 --- a/public/logo.svg +++ b/public/logo.svg @@ -1,17 +1,3 @@ - - - - - - - + + diff --git a/src/components/Message.tsx b/src/components/Message.tsx new file mode 100644 index 0000000..5bac151 --- /dev/null +++ b/src/components/Message.tsx @@ -0,0 +1,18 @@ +import {Card, Text, Flex} from '@chakra-ui/react'; + +type Props = { + sender: 'me' | 'other' + message: string +} + +export default function Message(props: Props) { + const {align, message} = props; + + return ( + + + {message} + + + ); +} \ No newline at end of file diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 8740cdd..ae060e0 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -48,7 +48,7 @@ export default function Navbar({variant = "fixed"}: Props) { backdropFilter={'auto'} backdropBlur={'20px'} px={10} py={2}> - + diff --git a/src/components/layout/dashboard/card_user/CardUser.jsx b/src/components/layout/dashboard/card_user/CardUser.jsx index 5a06035..4f43063 100644 --- a/src/components/layout/dashboard/card_user/CardUser.jsx +++ b/src/components/layout/dashboard/card_user/CardUser.jsx @@ -26,7 +26,7 @@ export default function CardUser(props) { }; return ( - + diff --git a/src/pages/chat/[id].tsx b/src/pages/chat/[id].tsx new file mode 100644 index 0000000..f9222dc --- /dev/null +++ b/src/pages/chat/[id].tsx @@ -0,0 +1,54 @@ +import {Container, Flex, Text} from '@chakra-ui/react'; +import Head from 'next/head'; +import {websiteName} from '@/lib/constants'; +import {useSession} from 'next-auth/react'; +import {useRouter} from 'next/router'; +import {useEffect} from 'react'; +import Message from '@/components/Message'; + +export default function Chat() { + const router = useRouter(); + const {data: session, status} = useSession(); + const {id} = router.query; + + useEffect(() => { + switch (status) { + case 'loading': + return; + case 'unauthenticated': + return router.push('/login'); + case 'authenticated': + fetch(`/api/chats/${id}`).then(res => res.json()).then(chat => { + if (!chat.UserID.contain(session?.user?.id)) router.push('/login'); + }); + return; + } + }, [status]); + + if (status === "loading") return Loading... + + const messages = [ + {sender: "me", message: "salut"}, + {sender: "other", message: "salut"}, + {sender: "me", message: "salut"}, + {sender: "other", message: "salut"}, + {sender: "me", message: "salut"}, + {sender: "other", message: "salut"}, + ] + + return ( + <> + {websiteName} + + + + { + messages.map(m => ) + } + + + Hello World {session?.user?.firstName ?? ""} + + + ); +} \ No newline at end of file