From 576abe4b9fe19f06fc65013eb7e222cb7580e5b3 Mon Sep 17 00:00:00 2001 From: vanessa082 Date: Thu, 2 Jan 2025 19:06:49 +0100 Subject: [PATCH 1/3] building the chat page ui --- api/src/main.ts | 2 +- .../pages/chats/chat-page/chat-page copy.tsx | 68 +++++++++++++++++++ .../pages/chats/chat-page/chat-page.tsx | 64 ++++++++++++++++- .../chats-layout/chat-list/chat-list.tsx | 2 +- 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 web/src/core/features/pages/chats/chat-page/chat-page copy.tsx diff --git a/api/src/main.ts b/api/src/main.ts index b1aa046..f24cdb3 100644 --- a/api/src/main.ts +++ b/api/src/main.ts @@ -3,6 +3,6 @@ import { AppModule } from "./modules/app/app.module"; async function bootstrap() { const app = await NestFactory.create(AppModule); - await app.listen(process.env.PORT ?? 3001); + await app.listen(process.env.PORT ?? 3000); } bootstrap(); diff --git a/web/src/core/features/pages/chats/chat-page/chat-page copy.tsx b/web/src/core/features/pages/chats/chat-page/chat-page copy.tsx new file mode 100644 index 0000000..fa582ad --- /dev/null +++ b/web/src/core/features/pages/chats/chat-page/chat-page copy.tsx @@ -0,0 +1,68 @@ +import { MainTag } from "@/components/atoms"; +import { Avatar, AvatarFallback, AvatarImage } from "@radix-ui/react-avatar"; +import { MoreVerticalIcon, Phone, PhoneCallIcon, VideoIcon } from "lucide-react"; +import { Input } from "../../../../components/ui/input"; +import { Button } from "../../../../components/ui/button"; + +interface Props { + params: Promise<{ id: string }>; +} + +export default async function ChatPage(props: Props) { + const { id } = await props.params; + + return ( + +
+
+ + + AN + + +
+

Van

+

+ OnlineLast Seen + 2:30pm +

+
+
+ +
+ + + +
+
+ +
+ {/* Send */} +
+
+
+ Hey There! +
+ Today, 8.30pm +
+ + {/* Receive */} + +
+
Hello!
+ Today, 8.33pm +
+
+ +
+ + +
+
+
+ ); +} diff --git a/web/src/core/features/pages/chats/chat-page/chat-page.tsx b/web/src/core/features/pages/chats/chat-page/chat-page.tsx index c933d42..2506d5f 100644 --- a/web/src/core/features/pages/chats/chat-page/chat-page.tsx +++ b/web/src/core/features/pages/chats/chat-page/chat-page.tsx @@ -1,6 +1,10 @@ +"use client"; + import type { Chat, Message } from "@/interfaces/chat.types"; import { MainTag } from "@/components/atoms"; import { Fetcher } from "@/lib/fetch"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { getInitials, getProfileURLFromInitials } from "@/lib/utils"; interface Props { params: Promise<{ id: string }>; @@ -16,11 +20,65 @@ export default async function ChatPage(props: Props) { chat: Chat; }>(`/api/chats/${id}`); + const getPhoto = () => { + return chat.profileImg.url || getProfileURLFromInitials(chat.name); + }; + return ( - Chats Page Loading messages with id: {id} - {JSON.stringify(props, null, 4)} -
{JSON.stringify(messages, null, 2)}
+ {/* Chat Header */} +
+ + + {getInitials(chat.name)} + +
+

{chat.name}

+

Online

+
+
+ + {/* Messages */} +
+ {messages.length > 0 ? ( + messages.map((message) => ( +
+
+

{message.textContent}

+ {/* Reactions */} + {message.mediaContent.length > 0 && ( +
+ {message.mediaContent.map((reaction, idx) => ( + + {reaction} + + ))} +
+ )} + {/* Seen Status */} + {message.senderId === "user_1" && ( +
+ {message.status.value === "SEEN" ? "Seen" : "Sent"} +
+ )} +
+
+ )) + ) : ( +

No messages yet...

+ )} +
); } diff --git a/web/src/core/features/pages/chats/chats-layout/chat-list/chat-list.tsx b/web/src/core/features/pages/chats/chats-layout/chat-list/chat-list.tsx index 7d9921e..daf3393 100644 --- a/web/src/core/features/pages/chats/chats-layout/chat-list/chat-list.tsx +++ b/web/src/core/features/pages/chats/chats-layout/chat-list/chat-list.tsx @@ -9,7 +9,7 @@ async function ChatList() { <>

Inbox

- {chats.map((c) => ( + {chats?.map((c) => ( ))} From 14af0f37850b95d2ef0c2d4e2ffbff37e08ff177 Mon Sep 17 00:00:00 2001 From: vanessa082 Date: Thu, 2 Jan 2025 19:09:04 +0100 Subject: [PATCH 2/3] commmented out the message car --- .../pages/chats/chat-page/chat-page.tsx | 70 ++++++------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/web/src/core/features/pages/chats/chat-page/chat-page.tsx b/web/src/core/features/pages/chats/chat-page/chat-page.tsx index 2506d5f..e4203d9 100644 --- a/web/src/core/features/pages/chats/chat-page/chat-page.tsx +++ b/web/src/core/features/pages/chats/chat-page/chat-page.tsx @@ -1,4 +1,4 @@ -"use client"; +// "use client" import type { Chat, Message } from "@/interfaces/chat.types"; import { MainTag } from "@/components/atoms"; @@ -10,6 +10,18 @@ interface Props { params: Promise<{ id: string }>; } + + +// const messageCard = () => { +// return ( +//
+//
+ +//
+//
+// ) +// } + export default async function ChatPage(props: Props) { const { id } = await props.params; @@ -22,63 +34,27 @@ export default async function ChatPage(props: Props) { const getPhoto = () => { return chat.profileImg.url || getProfileURLFromInitials(chat.name); - }; + } return ( - {/* Chat Header */}
- {getInitials(chat.name)} + + {getInitials(chat.name)} + + {/*
*/}

{chat.name}

-

Online

+

{ }

- - {/* Messages */} -
- {messages.length > 0 ? ( - messages.map((message) => ( -
-
-

{message.textContent}

- {/* Reactions */} - {message.mediaContent.length > 0 && ( -
- {message.mediaContent.map((reaction, idx) => ( - - {reaction} - - ))} -
- )} - {/* Seen Status */} - {message.senderId === "user_1" && ( -
- {message.status.value === "SEEN" ? "Seen" : "Sent"} -
- )} -
-
- )) - ) : ( -

No messages yet...

- )} -
+ {/* + Chats Page Loading messages with id: {id} + {JSON.stringify(props, null, 4)} +
{JSON.stringify(messages, null, 2)}
*/}
); } From 957298673a66f75883dcf28bd748d95f0625f7f7 Mon Sep 17 00:00:00 2001 From: vanessa082 Date: Fri, 3 Jan 2025 22:31:38 +0100 Subject: [PATCH 3/3] added a console to read messages since the fetcher is unable to fet --- web/src/core/features/pages/chats/chat-page/chat-page.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web/src/core/features/pages/chats/chat-page/chat-page.tsx b/web/src/core/features/pages/chats/chat-page/chat-page.tsx index e4203d9..bb752d9 100644 --- a/web/src/core/features/pages/chats/chat-page/chat-page.tsx +++ b/web/src/core/features/pages/chats/chat-page/chat-page.tsx @@ -32,6 +32,8 @@ export default async function ChatPage(props: Props) { chat: Chat; }>(`/api/chats/${id}`); + console.log(messages, 'yo') + const getPhoto = () => { return chat.profileImg.url || getProfileURLFromInitials(chat.name); } @@ -51,10 +53,7 @@ export default async function ChatPage(props: Props) {

{ }

- {/* - Chats Page Loading messages with id: {id} - {JSON.stringify(props, null, 4)} -
{JSON.stringify(messages, null, 2)}
*/} + ); }