diff --git a/Components/Chat/ChatHeader.tsx b/Components/Chat/ChatHeader.tsx index e8b8253..fd8664b 100644 --- a/Components/Chat/ChatHeader.tsx +++ b/Components/Chat/ChatHeader.tsx @@ -54,7 +54,7 @@ const ChatHeader = ({ onClick={handleLeaveChat} className="ml-2 mr-1" /> - {chatUsers} + {chatUsers} { setChatUsers([...chatUsers, ...responseData.users]); - socket.emit( - 'message-to-server', - `${responseData.users[0]} 님이 입장하셨습니다.`, - ); + Swal.fire(`${responseData.users[0]} 님이 입장하셨습니다.`); }); } @@ -102,10 +100,7 @@ const ChatRoom = ({ if (socket?.connected) { socket.on('leave', (responseData) => { setChatUsers([...chatUsers, ...responseData.users]); - socket.emit( - 'message-to-server', - `${responseData.leaver} 님이 퇴장하셨습니다.`, - ); + Swal.fire(`${responseData.leaver} 님이 퇴장하셨습니다.`); }); } @@ -131,7 +126,7 @@ const ChatRoom = ({ }; return ( -
+
)} -
+
setNewMessage(e.target.value)} onKeyPress={handleKeyPress} - className="w-4/5 px-4 py-3 rounded-2xl" + className="w-4/5 px-4 py-3 rounded-2xl focus:outline-none" /> -
+
{user.id === myId ? (
  • -

    +

    {changeTime(message.createdAt.toString())}

    -
    -

    - {message.text} -

    -
    +

    + {message.text} +

  • ) : (
  • @@ -52,14 +50,17 @@ const Chats = ({ height={50} alt="User Picture" onClick={useModal ? openProfile : undefined} + className="shadow-gray-100 shadow-md rounded-xl" />

    {user.username}

    -

    +

    {message.text}

    -

    {changeTime(message.createdAt.toString())}

    +

    + {changeTime(message.createdAt.toString())} +

  • )} diff --git a/Components/Chat/RenderChats.tsx b/Components/Chat/RenderChats.tsx index 86c7e88..d8181db 100644 --- a/Components/Chat/RenderChats.tsx +++ b/Components/Chat/RenderChats.tsx @@ -29,40 +29,38 @@ const RenderChats = ({ }, [messages.length]); return ( - <> -
      - {messages.map((message, index) => { - const myUser = chatUsers.find((user) => user.id === message.userId); +
        + {messages.map((message, index) => { + const myUser = chatUsers.find((user) => user.id === message.userId); - if (myUser) { - return ( - - {index === 0 || - new Date(message.createdAt).toDateString() !== - new Date(messages[index - 1].createdAt).toDateString() ? ( -
      • - - {new Date(message.createdAt).toDateString()} - -
      • - ) : null} - -
        - ); - } - })} -
        -
      - + if (myUser) { + return ( + + {index === 0 || + new Date(message.createdAt).toDateString() !== + new Date(messages[index - 1].createdAt).toDateString() ? ( +
    • + + {new Date(message.createdAt).toDateString()} + +
    • + ) : null} + +
      + ); + } + })} +
      +
    ); }; export default RenderChats; diff --git a/tailwind.config.ts b/tailwind.config.ts index 251e132..df9260b 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -31,6 +31,10 @@ const config: Config = withMT({ bgfill: '#7E7E7E', chat: '#5B5B5B', bglight: '#EFEFEF', + footer: '#FFB8DA', + send: '#FB72B4', + users: '#848484', + time: '#7E7E7E', }, backgroundImage: { 'trash-can': "url('../public/icon_trash.svg')",