diff --git a/frontend/code/src/Components/Chat/Components/Conversation.tsx b/frontend/code/src/Components/Chat/Components/Conversation.tsx index a6d64af..748c479 100644 --- a/frontend/code/src/Components/Chat/Components/Conversation.tsx +++ b/frontend/code/src/Components/Chat/Components/Conversation.tsx @@ -18,8 +18,7 @@ import { getRoomMessagesCall, sendMessageCall, } from "../Services/MessagesServices"; -import { Message as UserMessage } from "../../Layout/Assets/Message"; -import { useStore } from "zustand"; + import { useUserStore } from "../../../Stores/stores"; export interface ChatPaceHolderProps { @@ -277,21 +276,12 @@ export const Conversation: React.FC = ({ }) => { const chatState = useChatStore((state) => state); const messageContainerRef = useRef(null); - const selectedChatType = useChatStore((state) => state.selectedChatType); - const currentChatMessages = useChatStore((state) => state.currentMessages); - const currentRoomMessages = useChatStore( - (state) => state.currentRoomMessages - ); const pushMessage = useChatStore((state) => state.addNewMessage); const [CurrentsMessages, setMessages] = useState([]); const [inputValue, setInputValue] = useState(""); const [FailToSendMessage, setFail] = useState(false); - const selectedMessages = - selectedChatType === ChatType.Chat - ? currentChatMessages - : currentRoomMessages; // Function to handle input changes const handleInputChange = (e: { target: { value: React.SetStateAction }; @@ -323,8 +313,6 @@ export const Conversation: React.FC = ({ ); setMessages(messages); } - - const response = res?.data; }); fetch(); diff --git a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx index 8457517..c3e68cd 100644 --- a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx +++ b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx @@ -1,6 +1,6 @@ import { SetStateAction, useEffect, useState } from "react"; import { useChatStore } from "../Controllers/RoomChatControllers"; -import users, { +import { ChatGif, ChatRoom, GroupChat, @@ -15,7 +15,7 @@ import users, { check, groupIcon, } from "./tools/Assets"; -import { SelectedUserTile } from ".."; + import { DeleteRoomCall, @@ -410,6 +410,7 @@ export const AddUsersModal = () => { fetchData(); } + // eslint-disable-next-line }, [LayoutState.showAddUsersModal]); return (
@@ -476,7 +477,6 @@ export const RoomSettingsModal = () => { const [RoomPassword, setPassword] = useState(""); const [LoadingUsers, setLOading] = useState(false); - const handlePasswordChange = (event: { target: { value: SetStateAction }; }) => { @@ -647,43 +647,53 @@ export const RoomSettingsModal = () => {
  • { setTakeAction(true); - LayoutState.setShowSettingsModal( - !LayoutState.showSettingsModal - ); await takeActionCall( selectedChatID as string, user.id, - "ban" + user.isBaned ? "unban" : "ban" ).then((res) => { setTakeAction(false); if (res?.status === 200 || res?.status === 201) { - toast.success("User baned Successfully"); + toast.success(res.data.message); } + LayoutState.setShowSettingsModal( + !LayoutState.showSettingsModal + ); }); }} > - Ban + + {user.isBaned ? "UnBan" : "Ban"} +
  • -
  • { - setTakeAction(true); - await takeActionCall( - selectedChatID as string, - user.id, - "mute" - ).then((res) => { - setTakeAction(false); - if (res?.status === 200 || res?.status === 201) { - toast.success( - "User Muted For a 5 minutes Successfully" + {user.isMuted === false && ( +
  • { + setTakeAction(true); + await takeActionCall( + selectedChatID as string, + user.id, + "mute" + ).then((res) => { + setTakeAction(false); + if ( + res?.status === 200 || + res?.status === 201 + ) { + toast.success( + "User Muted For a 5 minutes Successfully" + ); + } + LayoutState.setShowSettingsModal( + !LayoutState.showSettingsModal ); - } - }); - }} - > - mute -
  • + }); + }} + > + mute + + )}
  • { diff --git a/frontend/code/src/Components/Chat/Components/tools/Assets.tsx b/frontend/code/src/Components/Chat/Components/tools/Assets.tsx index 8f5856b..541f7ce 100644 --- a/frontend/code/src/Components/Chat/Components/tools/Assets.tsx +++ b/frontend/code/src/Components/Chat/Components/tools/Assets.tsx @@ -70,12 +70,13 @@ export interface RoomMember { id: string; firstname: string; lastname: string; - avatar: { thumbnail: string; medium: string; large: string; }; + isBaned?: boolean; + isMuted?: boolean; } export interface ChatRoom { diff --git a/frontend/code/src/Components/Chat/Services/MessagesServices.ts b/frontend/code/src/Components/Chat/Services/MessagesServices.ts index 2b9dcae..5dfef84 100644 --- a/frontend/code/src/Components/Chat/Services/MessagesServices.ts +++ b/frontend/code/src/Components/Chat/Services/MessagesServices.ts @@ -1,4 +1,4 @@ -import toast from "react-hot-toast"; + import api from "../../../Api/base"; diff --git a/frontend/code/src/Components/Chat/index.tsx b/frontend/code/src/Components/Chat/index.tsx index 8369b64..4dc9721 100644 --- a/frontend/code/src/Components/Chat/index.tsx +++ b/frontend/code/src/Components/Chat/index.tsx @@ -134,6 +134,8 @@ export const UserPreviewCard: React.FC = ({ }; fetchData(); + + //eslint-disable-next-line }, [SelectedChat]); return (
    diff --git a/frontend/code/src/Components/Layout/index.tsx b/frontend/code/src/Components/Layout/index.tsx index 1529b64..225f958 100644 --- a/frontend/code/src/Components/Layout/index.tsx +++ b/frontend/code/src/Components/Layout/index.tsx @@ -14,7 +14,7 @@ import { matchRoutes, useLocation } from "react-router-dom"; import { useUserStore } from "../../Stores/stores"; import { useNavigate } from "react-router-dom"; import { FirstLogin } from "../FirstLogin"; -import { AxiosError, type AxiosResponse } from "axios"; + const routes = [ { path: "Profile/:id" },