diff --git a/frontend/src/components/ChatBox.jsx b/frontend/src/components/ChatBox.jsx index f8efa92..1351bcf 100644 --- a/frontend/src/components/ChatBox.jsx +++ b/frontend/src/components/ChatBox.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; const ChatBox = ({ activeUser, messages }) => { - console.log(activeUser); if (!activeUser) { return (
@@ -12,26 +11,45 @@ const ChatBox = ({ activeUser, messages }) => { } return ( -
+
{/* Chat Header */}
-

{activeUser.UserName}

+

{activeUser.UserName}

{/* Chat Messages */}
{messages.map((msg) => ( -
+
+ {msg.SenderID === activeUser.UserID ? ( + <> +
+ {activeUser.UserName} +
{msg.MessageContent} -
+
+
+ + ) : ( + <> +
+
+ {msg.MessageContent} +
+ {msg.SenderID.UserName} +
+ + )} +
))}
diff --git a/frontend/src/message.jsx b/frontend/src/message.jsx index e536a28..677badd 100644 --- a/frontend/src/message.jsx +++ b/frontend/src/message.jsx @@ -33,7 +33,6 @@ const Message = () => { MessageContent: chat.MessageContent, })); setChats(chats); - // console.log(chats); } catch (error) { console.error("Error fetching chats:", error); } @@ -44,9 +43,7 @@ const Message = () => { const response = await axios.get( `http://localhost:3000/message/${userID}/${receiverID}` ); - // setMessages from the response.data setMessages(response.data); - console.log(activeUser); } catch (error) { console.error("Error fetching messages:", error); }