From f323490131e26bf128399da9c6991566fa038d6b Mon Sep 17 00:00:00 2001 From: Ouadia Essendoubi Date: Sun, 22 Oct 2023 18:05:26 +0100 Subject: [PATCH 1/3] fix --- backend/code/src/rooms/rooms.service.ts | 6 +- frontend/code/src/Api/base.tsx | 23 +- .../Chat/Components/RoomChatHelpers.tsx | 10 +- .../Components/Chat/Services/ChatServices.ts | 217 +++++++++--------- 4 files changed, 124 insertions(+), 132 deletions(-) diff --git a/backend/code/src/rooms/rooms.service.ts b/backend/code/src/rooms/rooms.service.ts index 80f8f8f..c3ce584 100644 --- a/backend/code/src/rooms/rooms.service.ts +++ b/backend/code/src/rooms/rooms.service.ts @@ -480,16 +480,18 @@ export class RoomsService { name: true, type: true, ownerId: true, - members: { + ...(joined && {members: { where: { userId: userId, }, select: { is_admin: true, }, - }, + }}) }, }); + if (!joined) + return rooms; return rooms.map((room) => { const is_owner = room.ownerId === userId; return { diff --git a/frontend/code/src/Api/base.tsx b/frontend/code/src/Api/base.tsx index b11ff40..31b23df 100644 --- a/frontend/code/src/Api/base.tsx +++ b/frontend/code/src/Api/base.tsx @@ -1,5 +1,5 @@ -import axios from 'axios'; -import toast from 'react-hot-toast'; +import axios from "axios"; +import toast from "react-hot-toast"; const api = axios.create({ baseURL: `${process.env.REACT_APP_API_ENDPOINT}`, @@ -7,35 +7,30 @@ const api = axios.create({ withCredentials: true, headers: { "Cache-Control": "no-cache", - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, }); let refreshAttempted = false; -const errorHandler = async (error:any) => { - +const errorHandler = async (error: any) => { if (error.response.status === 401) { - if (!refreshAttempted ) { + if (!refreshAttempted) { try { refreshAttempted = true; await api.get("auth/refresh"); return api.request(error.config); - } catch (refreshError) { - } + } catch (refreshError) {} } else { - refreshAttempted = false + refreshAttempted = false; } - } - else - { - toast.error(`${error.response.data.message}`) + } else { + toast.error(`${error.response.data.message}`); } return Promise.reject({ ...error }); }; api.interceptors.response.use( - (response) => response, (error) => errorHandler(error) ); diff --git a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx index 219d883..14f0749 100644 --- a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx +++ b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx @@ -547,11 +547,11 @@ export const ExploreRoomsModal = () => { toast.error("something went wrong, try again"); resetModalState(); } else { - console.log("my recent"); - console.log(recentRooms); + // console.log("my recent"); + // console.log(recentRooms); const rooms: ChatRoom[] = []; res.data.forEach( - (room: { id: string; name: string; type: string }) => { + (room: { id: string; is_admin : boolean, is_owner : boolean, name: string; type: string, }) => { if ( recentRooms.recentRooms.find( (recentRoom) => recentRoom.id === room.id @@ -563,8 +563,8 @@ export const ExploreRoomsModal = () => { type: RoomType[room.type as keyof typeof RoomType], messages: [], usersId: [], - isOwner: true, - isAdmin: true, + isOwner: room.is_owner, + isAdmin: room.is_admin, }); } } diff --git a/frontend/code/src/Components/Chat/Services/ChatServices.ts b/frontend/code/src/Components/Chat/Services/ChatServices.ts index 8c98b10..903e8db 100644 --- a/frontend/code/src/Components/Chat/Services/ChatServices.ts +++ b/frontend/code/src/Components/Chat/Services/ChatServices.ts @@ -1,113 +1,108 @@ -import api from "../../../Api/base"; +import api from "../../../Api/base"; export const createNewRoomCall = async ( - name: string, - type: string, - password?: string - ) => { - try { - - const response = await api.post("/rooms/create", { - name: name, - type: type, - password: password, - }); - console.log(response.data); - console.log(response.status); - return response; - } catch (e) { - console.log(e); - } - }; - - - export const updateRoomCall = async ( - name: string, - type: string, - roomId: string, - password? : string, - - ) => { - try { - - const response = await api.post("/rooms/update", { - name: name, - type: type, - roomId : roomId, - password : password, - }); - console.log(response.data); - console.log(response.status); - return response; - } catch (e) { - console.log(e); - } - - }; - - - export const fetchRoomsCall = async ( - offset: number, - limit : number, - joined : boolean, - - ) => { - - try { - const response = await api.get(`/rooms`, - { params: { offset: offset, limit : limit, joined : joined } }); - joined === true ? console.log("resent :") : console.log("Public :"); - console.log(response.status); - console.log(response.data); - return response; - } catch (e) { - console.log(e); - } - - - - - - - } - - - - export const getRoomMembersCall = async ( - id : string, - offset: number, - limit : number, - ) => { - try { - const response = await api.get(`/rooms/${id}/members`, - { params: {offset: offset, limit : limit } }); - console.log("room members :"); - console.log(response.status); - console.log(response.data); - return response; - } catch (e) { - console.log(e); - } - - } - - - export const joinRoomCall = async ( - roomId : string, - password? : string, - - ) => { - try { - - const response = await api.post("/rooms/join", { - roomId : roomId, - password : password, - }); - console.log("join room") - console.log(response.status); - console.log(response.data); - return response; - } catch (e : any) { - console.log(e.response.data.message); - } - } \ No newline at end of file + name: string, + type: string, + password?: string +) => { + try { + + const response = await api.post("/rooms/create", { + name: name, + type: type, + password: password, + }); + console.log(response.data); + console.log(response.status); + return response; + } catch (e: any) { + console.log(e.response.data.message); + } +}; + + +export const updateRoomCall = async ( + name: string, + type: string, + roomId: string, + password?: string, + +) => { + try { + + const response = await api.post("/rooms/update", { + name: name, + type: type, + roomId: roomId, + password: password, + }); + console.log(response.data); + console.log(response.status); + return response; + } catch (e: any) { + console.log(e.response.data.message); + } + +}; + + +export const fetchRoomsCall = async ( + offset: number, + limit: number, + joined: boolean, + +) => { + + try { + const response = await api.get(`/rooms`, + { params: { offset: offset, limit: limit, joined: joined } }); + joined === true ? console.log("resent :") : console.log("Public :"); + console.log(response.status); + console.log(response.data); + return response; + } catch (e: any) { + console.log(e.response.data.message); + } + +} + + + +export const getRoomMembersCall = async ( + id: string, + offset: number, + limit: number, +) => { + try { + const response = await api.get(`/rooms/${id}/members`, + { params: { offset: offset, limit: limit } }); + console.log("room members :"); + console.log(response.status); + console.log(response.data); + return response; + } catch (e: any) { + console.log(e.response.data.message); + } + +} + + +export const joinRoomCall = async ( + roomId: string, + password?: string, + +) => { + try { + + const response = await api.post("/rooms/join", { + roomId: roomId, + password: password, + }); + console.log("join room") + console.log(response.status); + console.log(response.data); + return response; + } catch (e: any) { + console.log(e.response.data.message); + } +} \ No newline at end of file From a9273d183c2549bd696afbffed7ce82f3a933139 Mon Sep 17 00:00:00 2001 From: Wadie-ess Date: Tue, 24 Oct 2023 09:50:52 +0100 Subject: [PATCH 2/3] mobile responsive --- .DS_Store | Bin 0 -> 8196 bytes .github/.DS_Store | Bin 0 -> 6148 bytes backend/.DS_Store | Bin 0 -> 6148 bytes frontend/.DS_Store | Bin 0 -> 6148 bytes .../Chat/Components/Conversation.tsx | 10 ++++++ .../Components/Chat/Components/RecentChat.tsx | 2 +- .../Chat/Components/RoomChatHelpers.tsx | 4 +-- .../Chat/Controllers/ChatControllers.tsx | 13 +++++++ frontend/code/src/Components/Chat/index.tsx | 32 ++++++++++++++---- frontend/code/src/Utils/helpers.ts | 4 +++ 10 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 .DS_Store create mode 100644 .github/.DS_Store create mode 100644 backend/.DS_Store create mode 100644 frontend/.DS_Store create mode 100644 frontend/code/src/Utils/helpers.ts diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7c1ae9c1b4b754c97b14cfb87bd6d02302443545 GIT binary patch literal 8196 zcmeHMF>ljA6n>YcjiVMRLqQb_mXJV5RY_V26|tC*{sDrD5L6+qLu%FWMX^JWqDUTL zVS*hov9K~TfLNIr_z{$!z<{T$sf+BGz-F@e~_wIf9?6dtG0ASU=R{_`n01GQ& zX%(9ph32VdN=}VjL}cg>LAz2vdhqkvJsDDbZ+fX{3y)|}_QoHeac zz$oxvDnR!K8!MrsFp(&39oUEz05OllqF}#79YkB9qcD+(Ggz2(MU<{gr5H@QhUsfMwi z-%95L@CJinG#8q12*=QZ5WEzh!ly4;3!P8&?#F~rYMlz^SZ1seL@3qk6(S1Mk_@K)Bp%)3?x}30zR;BeW=beAx2<5O9 zm`Ie@hI#&z8m1Tp&Q5_P8G3{A|GoL&|Idz~iEI=w3jA>eSiV-TRWZ!?wQV{g<=QsZ u$5^S5T_RDqU?b9TM3Igop8jEoeH%^5$5EI_#1Sm!ML@`48l%8pRp1xHLJevF literal 0 HcmV?d00001 diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f0bb8b78861e9566b27b29779cc546170f980fb3 GIT binary patch literal 6148 zcmeHKOHKnZ47H()L2SBYN3PHdptKrJ&Qc= zm-uC>MgBO%N6vsV@Xr|FNxN(p_$a$uzkQzEwE=B~CL(@W6bSUuBLD+AN6v~-?Ll<- YMZ>HpS!BM11N|XT2=UGt_yq<&0pc++?*IS* literal 0 HcmV?d00001 diff --git a/backend/.DS_Store b/backend/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3cf6c5b037a67d44cb7267db0928d5e581fcc4f7 GIT binary patch literal 6148 zcmeHKJ5Iw;5ZnbzM1mqE<-0;|U?S%Pxd2Lxph)BpiQXNTph(X-xEHe@kS!~e6fi68 z8^7HhKYI$VS44FA(k?{iA~J&;%Bw9?v%LAlE;3R9)$Xx-T&%a<{xGRLA24nuTj`{g zhY|nk{cV`rcTKa|bsNO|fsfB0cjJ8fWB%|oc($7ps5B}-1*iZOpaTC=0rYIM*>xaS zDnJFOz_$YSeJF6lI;r=?>L=qqd9vn&qJBE!#mhzOK(17P3XB!FjP2a|{|bI){vVULqXJamPbr{Pvu>7n zrR=Sfm$P15;P>z^L#>x%@m37hAks9AXc1}YmYCYsbT>Oq*KT&g?xwLV zg&g%LcoO^#-n@7d1b=}y@h9kA1mD@2Z4#s26f5(>%=6CsF&|IZc{2zhTxeQ3gj9r( z0*zs82)dsL^Rw0`1Huvq#B2_;#sK?vW2lNKvJmP1e$9qs z`$0DQ0S^quPMwY`ab;N9)OTo04~(Gc7YuKmjaDgj%t$xPl1*9_HMv0Dz_4B7g$cGr zAY|jd?OL=|piS5E!(5#^l!TI~sOiJQ+3d8IJ(|`Ib62l}Iy;j)I!Y+1%#|A}m0hRq z(kGlg47W`vBLX9M3d-?m?CPGljquy(G@n#8I!|I~_{_-JQFUy5Vk|k9N~O~0Qt1m9 z(-n2XG^)EbkL`1TI@BvTO|o9|Y)fw#RoktV1M)b~?E_L#$A1W2A=bl=X?4E=G0Bc0 zobI+qh#Stgw7u<`6~652%v=oxy6UZFSWJ^F|~qi;BlReTvw;cNIN zp2K(WB7T6^@fNmu`atx{Ug}*3KZ5b`FYDBDdX?52ET%O1^+mU@PK!lRgP>@&X9EA- ze6Qd7t-rC;nY;454XK@V_jJ#7s9OVDv`^+gsUpsx44>2k$bCx&Bm;kp0d_xV&=}?g zwmF7Z2Xx^R05AsTP(W9i0;mbh3v6=)4+!R|fIJn8CkE!}VAn)kUSOLePe)ihKCoCB zix&zGSBLqvFdX4LN7+jTBm=z+4DzAM>i;eHhJW$??@f{;$$(_wzhVH#ih8jCM-sKQ z?{KWvYS6ZzF=26Sj$sOPq8x_`E5+xbg#tc}DS&x_ZH{08k$(h28e}IK_^S+j2StwI AYybcN literal 0 HcmV?d00001 diff --git a/frontend/code/src/Components/Chat/Components/Conversation.tsx b/frontend/code/src/Components/Chat/Components/Conversation.tsx index 4a9ae57..d0f704e 100644 --- a/frontend/code/src/Components/Chat/Components/Conversation.tsx +++ b/frontend/code/src/Components/Chat/Components/Conversation.tsx @@ -91,6 +91,8 @@ export const ConversationHeader: React.FC = ({ const currentRoom = chatRooms.find((room) => room.id === SelectedChat); + const toggleChatRooms = useChatStore((state) => state.toggleChatRooms); + const [isModalOpen, setIsModalOpen] = useState(false); // Function to open the modal @@ -107,6 +109,14 @@ export const ConversationHeader: React.FC = ({ <>
+
+ +
{
{MyUsers.length > 0 ? ( -
+
{MyUsers.filter((friend) => friend.messages.length > 0).map( // to change 0 to the last message here (friend) => ( diff --git a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx index d2199ad..edcf2a8 100644 --- a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx +++ b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx @@ -76,7 +76,7 @@ export const RoomChatPlaceHolder = () => { }, [ChatRoomsState.selectedChatID]); return ChatRoomsState.recentRooms.length > 0 ? ( -
+
{ChatRoomsState.recentRooms.map((room) => (
{ setSelectedOption(RoomType.public); }; return ( -
+
diff --git a/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx b/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx index 21e2e2f..6b562c7 100644 --- a/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx +++ b/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx @@ -18,6 +18,8 @@ export interface ChatState { currentRoomMessages: Message[]; isLoading: boolean; + showChatRooms: boolean; + recentRooms: ChatRoom[]; fillRecentRooms: (rooms: ChatRoom[]) => void; setIsLoading: (isLoading: boolean) => void; @@ -26,6 +28,7 @@ export interface ChatState { createNewRoom: (name: string, roomType: RoomType, id: string) => void; addNewMessage: (message: Message) => void; changeChatType: (type: ChatType) => void; + toggleChatRooms: (value?: boolean) => void; } export const useChatStore = create()((set) => ({ @@ -33,6 +36,10 @@ export const useChatStore = create()((set) => ({ selectedChatType: ChatType.Chat, recentRooms: chatRooms, isLoading: false, + + // UI state + showChatRooms: false, + // to fix this currentMessages: users.find((user) => user.id === "1")?.messages as Message[], currentRoomMessages: chatRooms.find((room) => room.id === "1") @@ -117,4 +124,10 @@ export const useChatStore = create()((set) => ({ return { ...state }; }), + + toggleChatRooms: (value?: boolean) => + set((state) => ({ + ...state, + showChatRooms: value === undefined ? !state.showChatRooms : value, + })), })); diff --git a/frontend/code/src/Components/Chat/index.tsx b/frontend/code/src/Components/Chat/index.tsx index d19cd10..72cecd9 100644 --- a/frontend/code/src/Components/Chat/index.tsx +++ b/frontend/code/src/Components/Chat/index.tsx @@ -19,6 +19,7 @@ import { NullPlaceHolder } from "./Components/RoomChatHelpers"; import { getRoomMembersCall } from "./Services/ChatServices"; import toast from "react-hot-toast"; +import { classNames } from "../../Utils/helpers"; export interface ConversationProps { onRemoveUserPreview: () => void; @@ -28,23 +29,36 @@ export const Chat = () => { const [showUserPreview, setShowUserPreview] = useState(false); const selectedChatType = useChatStore((state) => state.selectedChatType); + const showChatRooms = useChatStore((state) => state.showChatRooms); + const toggleChatRooms = useChatStore((state) => state.toggleChatRooms); + const chatRooms = useChatStore((state) => state.recentRooms); const handleRemoveUserPreview = () => { setShowUserPreview(!showUserPreview); }; return ( <> -
+
- {} +
+ {showChatRooms && ( +
toggleChatRooms()} + /> + )}
{chatRooms.length < 1 && selectedChatType === ChatType.Room ? ( @@ -53,7 +67,11 @@ export const Chat = () => { )}
-
+ +
{ src={Explore} /> -
- - - - - -
+
diff --git a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx index edcf2a8..4167db9 100644 --- a/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx +++ b/frontend/code/src/Components/Chat/Components/RoomChatHelpers.tsx @@ -1,4 +1,4 @@ -import { SetStateAction, useEffect, useLayoutEffect, useState } from "react"; +import { SetStateAction, useEffect, useState } from "react"; import { useChatStore } from "../Controllers/ChatControllers"; import users, { ChatGif, @@ -17,10 +17,12 @@ import users, { import { SelectedUserTile } from ".."; import { + DeleteRoomCall, createNewRoomCall, fetchRoomsCall, getRoomMembersCall, joinRoomCall, + takeActionCall, updateRoomCall, } from "../Services/ChatServices"; import toast from "react-hot-toast"; @@ -43,7 +45,7 @@ export const RoomChatPlaceHolder = () => { // to make it dynamic later await fetchRoomsCall(0, 100, true).then((res) => { if (res?.status !== 200 && res?.status !== 201) { - toast.error("something went wrong, try again"); + // toast.error("something went wrong, try again"); } else { const rooms: ChatRoom[] = []; res.data.forEach( @@ -158,7 +160,7 @@ export const CreateNewRoomModal = () => { setSelectedOption(RoomType.public); }; return ( -
+
@@ -265,7 +267,7 @@ export const CreateNewRoomModal = () => { : undefined ).then((res) => { if (res?.status !== 200 && res?.status !== 201) { - // toast.error("something went wrong, try again"); + toast.error("something went wrong, try again"); resetModalState(); } else { createNewRoom(RoomName, selectedOption, res.data.id); @@ -295,7 +297,7 @@ export const AddUsersModal = () => { const [MyUsers] = useState(users); return ( -
+
@@ -339,10 +341,8 @@ export const RoomSettingsModal = () => { const currentUser = useUserStore((state) => state); const editRoom = useChatStore((state) => state.editRoom); const selectedChatID = useChatStore((state) => state.selectedChatID); + const deleteRoom = useChatStore((state) => state.deleteRoom); const currentRoom = chatRooms.find((room) => room.id === selectedChatID); - const currentRoomUsers = users.filter( - (user) => currentRoom?.usersId.includes(user.id) as boolean - ); const setIsLoading = useChatStore((state) => state.setIsLoading); const [skipCount, setSkipCount] = useState(true); @@ -368,7 +368,7 @@ export const RoomSettingsModal = () => { if (!skipCount) { const fetchData = async () => { try { - await getRoomMembersCall(currentRoom?.id as string, 0, 10).then( + await getRoomMembersCall(currentRoom?.id as string, 0, 30).then( (res) => { if (res?.status === 200 || res?.status === 201) { const extractedData = res.data; @@ -384,6 +384,7 @@ export const RoomSettingsModal = () => { fetchData(); } + // eslint-disable-next-line }, [selectedChatID]); const resetModalState = () => { @@ -393,7 +394,7 @@ export const RoomSettingsModal = () => { }; return ( -
+
@@ -450,7 +451,6 @@ export const RoomSettingsModal = () => {
- {/* Conditionally render the text input */} {selectedOption === RoomType.protected && (
@@ -467,11 +467,14 @@ export const RoomSettingsModal = () => {

Room Members

{/* Scrollable part */} -
+
{currentUsers .filter((user) => user.id !== currentUser.id) .map((user) => ( -
+
{

-
+
))}
- -
- { - // eslint-disable-next-line - } - - {"Close "} - - { - console.log(RoomType[selectedOption]); - if (RoomName !== "" && RoomName.length > 3) { - setIsLoading(true); - await updateRoomCall( - RoomName, - RoomType[selectedOption], - currentRoom?.id!, - selectedOption === RoomType.protected - ? RoomPassword - : undefined - ).then((res) => { - if (res?.status !== 200 && res?.status !== 201) { - resetModalState(); - } else { - toast.success("Room Updated Successfully"); - editRoom(RoomName, selectedOption, currentRoom?.id!); - resetModalState(); - } - setIsLoading(false); - }); - } else { - toast.error("Room name must be at least 4 characters"); - resetModalState(); - } - }} - className="btn hover:bg-purple-500" - > - {"Save "} - +
+ +
@@ -595,7 +659,7 @@ export const ExploreRoomsModal = () => { setIsLoading(true); await fetchRoomsCall(0, 30, false).then((res) => { if (res?.status !== 200 && res?.status !== 201) { - toast.error("something went wrong, try again"); + // toast.error("something went wrong, try again"); resetModalState(); } else { const rooms: ChatRoom[] = []; @@ -635,7 +699,7 @@ export const ExploreRoomsModal = () => { }, [modalState]); return ( -
+
diff --git a/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx b/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx index 6b562c7..2ea7e05 100644 --- a/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx +++ b/frontend/code/src/Components/Chat/Controllers/ChatControllers.tsx @@ -21,6 +21,7 @@ export interface ChatState { showChatRooms: boolean; recentRooms: ChatRoom[]; + deleteRoom: (id: string) => void; fillRecentRooms: (rooms: ChatRoom[]) => void; setIsLoading: (isLoading: boolean) => void; selectNewChatID: (id: string) => void; @@ -45,6 +46,17 @@ export const useChatStore = create()((set) => ({ currentRoomMessages: chatRooms.find((room) => room.id === "1") ?.messages as Message[], + deleteRoom: (id: string) => + set((state) => { + const roomIndex = chatRooms.findIndex((room) => room.id === id); + if (roomIndex !== -1) { + chatRooms.splice(roomIndex, 1); + } + + state.recentRooms = [...chatRooms]; + state.selectNewChatID(state.recentRooms[0].id); + return { ...state }; + }), setIsLoading: (isLoading: boolean) => set((state) => { state.isLoading = isLoading; diff --git a/frontend/code/src/Components/Chat/Services/ChatServices.ts b/frontend/code/src/Components/Chat/Services/ChatServices.ts index 635de32..a0a73b0 100644 --- a/frontend/code/src/Components/Chat/Services/ChatServices.ts +++ b/frontend/code/src/Components/Chat/Services/ChatServices.ts @@ -131,4 +131,51 @@ export const leaveRoomCall = async ( toast.error(e.response.data.message); } -} \ No newline at end of file +} + +export const takeActionCall = async ( + roomId: string, + memberId: string, + action: string, +) => { + try { + const response = await api.post(`/rooms/${action}`, { + roomId: roomId, + memberId: memberId, + + }); + console.log(`${action} result :`) + console.log(response.status); + console.log(response.data); + return response; + } catch (e: any) { + + console.log(e.response.data.message); + toast.error(e.response.data.message); + } + +} + +export const DeleteRoomCall = async ( + roomId: string, + +) => { + try { + + const response = await api.post("/rooms/delete", { + roomId: roomId, + + }); + console.log("delete result :") + console.log(response.status); + console.log(response.data); + return response; + } catch (e: any) { + + console.log(e.response.data.message); + toast.error(e.response.data.message); + } + +} + + diff --git a/frontend/code/src/Components/Chat/index.tsx b/frontend/code/src/Components/Chat/index.tsx index 72cecd9..94fe26e 100644 --- a/frontend/code/src/Components/Chat/index.tsx +++ b/frontend/code/src/Components/Chat/index.tsx @@ -5,7 +5,7 @@ import { chatRooms, RoomsIcon, RoomMember, - yas, + } from "./Components/tools/Assets"; import { useEffect, useState } from "react"; import { Conversation } from "./Components/Conversation"; @@ -15,7 +15,14 @@ import React from "react"; import { ChatType, useChatStore } from "./Controllers/ChatControllers"; import { RecentConversations } from "./Components/RecentChat"; -import { NullPlaceHolder } from "./Components/RoomChatHelpers"; +import { + AddUsersModal, + CreateNewRoomModal, + ExploreRoomsModal, + NullPlaceHolder, + RoomSettingsModal, + ShowLogoModal, +} from "./Components/RoomChatHelpers"; import { getRoomMembersCall } from "./Services/ChatServices"; import toast from "react-hot-toast"; @@ -39,9 +46,18 @@ export const Chat = () => { return ( <>
+
+ + + + + +
= ({ {}

{currentRoom?.name}'s Members

-
+
{isLoading === false ? ( <> {currentUsers.map((user) => (