diff --git a/frontend/src/app/chat/[roomId]/ChatBody.tsx b/frontend/src/app/chat/[roomId]/ChatBody.tsx index ee63d59..fc6ff35 100644 --- a/frontend/src/app/chat/[roomId]/ChatBody.tsx +++ b/frontend/src/app/chat/[roomId]/ChatBody.tsx @@ -22,7 +22,7 @@ function Page() { }, []); return ( -
+
diff --git a/frontend/src/app/chat/layout.tsx b/frontend/src/app/chat/layout.tsx index d4f03d5..d025440 100644 --- a/frontend/src/app/chat/layout.tsx +++ b/frontend/src/app/chat/layout.tsx @@ -10,7 +10,7 @@ export default function RoomLayout({ return ( -
+
{children}
diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index 7e0cf8f..3b84627 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -26,12 +26,12 @@ } .custom-scrollbar::-webkit-scrollbar { - width: 6px; /* Ajustez la largeur de la scrollbar */ - border-radius: 10px; /* Ajustez le rayon de bordure de la scrollbar */ -} + width: 6px; /* Ajustez la largeur de la scrollbar */ + border-radius: 10px; /* Ajustez le rayon de bordure de la scrollbar */ + } -.custom-scrollbar::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, 0.3); /* Couleur de la scrollbar */ - border-radius: 10px; /* Rayon de bordure de la scrollbar */ -} + .custom-scrollbar::-webkit-scrollbar-thumb { + background-color: rgba(0, 0, 0, 0.3); /* Couleur de la scrollbar */ + border-radius: 10px; /* Rayon de bordure de la scrollbar */ + } } diff --git a/frontend/src/components/Chat/ChatBody.tsx b/frontend/src/components/Chat/ChatBody.tsx index 44b3984..6f3316a 100644 --- a/frontend/src/components/Chat/ChatBody.tsx +++ b/frontend/src/components/Chat/ChatBody.tsx @@ -80,7 +80,7 @@ function ChatBody({ roomId }: { roomId: string }) { }, [socket, roomId]); return ( -
+
{messages[roomId]?.map((message: any, index: number) => message.systemMessage ? (
diff --git a/frontend/src/components/Chat/ChatFooter.tsx b/frontend/src/components/Chat/ChatFooter.tsx index b634368..cd9a992 100644 --- a/frontend/src/components/Chat/ChatFooter.tsx +++ b/frontend/src/components/Chat/ChatFooter.tsx @@ -6,13 +6,12 @@ import { BsImage, BsEmojiSmileFill } from "react-icons/bs"; import { IoMdSend, IoMdCloseCircle } from "react-icons/io"; import Picker from "emoji-picker-react"; import Toast from "../shared/Toast"; -import 'react-toastify/dist/ReactToastify.css'; -import { toast, ToastContainer } from 'react-toastify'; -import { v4 as uuidv4 } from 'uuid'; +import "react-toastify/dist/ReactToastify.css"; +import { toast, ToastContainer } from "react-toastify"; +import { v4 as uuidv4 } from "uuid"; import { useRoom } from "@/contexts/RoomContext"; import { useRouter } from "next/navigation"; - function ChatFooter({ roomId }: { roomId: string }) { const [showListPopup, setShowListPopup] = useState(false); const [roomList, setRoomList] = useState([]); @@ -41,7 +40,7 @@ function ChatFooter({ roomId }: { roomId: string }) { toast.info(`Rooms: ${message}`); }); - socket.on('room_created', (room) => { + socket.on("room_created", (room) => { toast.success(`Room created: ${room.name}`); }); @@ -69,13 +68,16 @@ function ChatFooter({ roomId }: { roomId: string }) { if (socket) { socket.on("room_joined", (id, username) => { toast.success(`Joined room: ${id.roomName}`); - setMyRooms((prevRooms) => [...prevRooms, { id: id.roomId, title: id.roomName }]); + setMyRooms((prevRooms) => [ + ...prevRooms, + { id: id.roomId, title: id.roomName }, + ]); }); - + socket.on("join_error", (errorMessage) => { toast.error(errorMessage); }); - + return () => { socket.off("room_joined"); socket.off("join_error"); @@ -83,12 +85,10 @@ function ChatFooter({ roomId }: { roomId: string }) { } }, [socket]); - function handleCommand(commandString: string, socket: any) { const parts = commandString.substr(1).split(" "); const command = parts[0].toLowerCase(); const args = parts.slice(1); - switch (command) { case "nick": @@ -119,39 +119,39 @@ function ChatFooter({ roomId }: { roomId: string }) { toast.info(`Creating room: ${roomName}`); socket?.emit("join_room", newRoomId, roomName); } - break; - case "delete": + break; + case "delete": socket?.emit("delete_room", roomId); toast.info("Deleting room..."); - break; + break; case "join": - if (args.length === 0) { - toast.error("Please specify a room ID to join."); - } else { - const roomIdToJoin = args[0]; + if (args.length === 0) { + toast.error("Please specify a room ID to join."); + } else { + const roomIdToJoin = args[0]; + const username = localStorage.getItem("name"); + socket.emit("join", roomIdToJoin, username); + } + break; + case "quit": const username = localStorage.getItem("name"); - socket.emit("join", roomIdToJoin, username); - } - break; - case "quit": - const username = localStorage.getItem("name"); - socket?.emit("leave_room", username, roomId); - setMyRooms(myRooms.filter((room) => room.id !== roomId)); - router.push("/chat/1"); - break; - case "users": - socket?.emit("users"); - break; - case "msg": - const msgParam = args.join(" "); - socket?.emit("msg", msgParam); - break; - case 'clear': - socket.emit('clear' , roomId); - break; - default: - console.error("Unknown command."); - break; + socket?.emit("leave_room", username, roomId); + setMyRooms(myRooms.filter((room) => room.id !== roomId)); + router.push("/chat/1"); + break; + case "users": + socket?.emit("users"); + break; + case "msg": + const msgParam = args.join(" "); + socket?.emit("msg", msgParam); + break; + case "clear": + socket.emit("clear", roomId); + break; + default: + console.error("Unknown command."); + break; } } @@ -225,7 +225,7 @@ function ChatFooter({ roomId }: { roomId: string }) {
)} -
+
{message.length === 0 && ( <> +

{room?.title}