mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-12-05 17:30:50 +00:00
Display Chats in dashboard + autoscroll chat to bottom
Took 1 hour 11 minutes
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
import {Chat, User} from '@prisma/client';
|
||||
import {Box, Flex, Image, Text} from '@chakra-ui/react';
|
||||
import {Box, Button, Flex, Image, Text} from '@chakra-ui/react';
|
||||
import {useRouter} from 'next/router';
|
||||
|
||||
type Props = {
|
||||
user: User,
|
||||
chat: Chat & {User: User[]}
|
||||
chat: Chat & { User: User[] }
|
||||
};
|
||||
|
||||
export default function ChatListItem({user, chat}: Props) {
|
||||
const router = useRouter();
|
||||
const otherUser = chat.User.find((u: User) => u.id !== user.id) as User
|
||||
const otherUser = chat.User.find((u: User) => u.id !== user.id) as User;
|
||||
|
||||
console.log(chat);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flex cursor={"pointer"} onClick={() => router.push(`/chat/${chat.id}`)}>
|
||||
<Image borderRadius={'full'} boxSize='50px' src={otherUser.images[0] ?? "/blank_profile_picture.webp"}/>
|
||||
<Box>
|
||||
<Text>{otherUser.firstName} {otherUser.lastName}</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
</>
|
||||
<Flex alignItems={"center"} gap={5} cursor={'pointer'} onClick={() => router.push(`/chat/${chat.id}`)}>
|
||||
<Image borderRadius={'full'} boxSize="50px" src={otherUser.images[0] ?? '/blank_profile_picture.webp'}/>
|
||||
<Box>
|
||||
<Text>{otherUser.firstName} {otherUser.lastName}</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user