diff --git a/frontend/src/components/pages/Profile/ProfilePage.tsx b/frontend/src/components/pages/Profile/ProfilePage.tsx index c211065..4c770bc 100644 --- a/frontend/src/components/pages/Profile/ProfilePage.tsx +++ b/frontend/src/components/pages/Profile/ProfilePage.tsx @@ -28,7 +28,7 @@ const ProfilePage = () => { {!isEdit && (

Profile

-
+
{!user?.profile_picture && (

No Profile picture

diff --git a/frontend/src/components/pages/dashboard/team/TeamDetails.tsx b/frontend/src/components/pages/dashboard/team/TeamDetails.tsx index f71080c..10901db 100644 --- a/frontend/src/components/pages/dashboard/team/TeamDetails.tsx +++ b/frontend/src/components/pages/dashboard/team/TeamDetails.tsx @@ -98,23 +98,23 @@ const TeamDetails = ({ team }: { team: ITeam }) => {
{admin.id === user.id && ( <> -

+

-

+

-

+

{ }, }} > - @@ -134,20 +134,20 @@ const TeamDetails = ({ team }: { team: ITeam }) => { )} {admin?.id !== user?.id && ( -

+

)} -

+

{ }, }} > - diff --git a/frontend/src/components/pages/teams/collaborations/common/MessageForm.tsx b/frontend/src/components/pages/teams/collaborations/common/MessageForm.tsx index 715650e..f16770c 100644 --- a/frontend/src/components/pages/teams/collaborations/common/MessageForm.tsx +++ b/frontend/src/components/pages/teams/collaborations/common/MessageForm.tsx @@ -46,7 +46,7 @@ const MessageForm = ({ teamId, type }: Props) => { const uploadImages = useUploadMultipleImage(); const uploadFiles = useUploadMultipleFile(); const [sendMessage] = useSendMessageMutation(); - const [isMessage, setIsMessage] = useState(false); + const [isMessage, setIsMessage] = useState({ status: false, value: "" }); const openLinkModal = () => { setShowLinkModal(true); @@ -73,6 +73,8 @@ const MessageForm = ({ teamId, type }: Props) => { data.poster = user.id; data.conversationId = teamId; data.type = type; + data.text = data?.text || isMessage?.value; + console.log({ payload: data }); const result: any = await sendMessage(data); if (result?.data?.success) { const message = result?.data?.data; @@ -249,10 +251,17 @@ const MessageForm = ({ teamId, type }: Props) => { setIsMessage(e.target.value ? true : false)} + onChange={(e) => + setIsMessage({ + status: e.target.value ? true : false, + value: e.target.value, + }) + } className="border-2 border-gray-300 p-2 rounded-md focus:outline-none focus:border-blue-500 flex-grow" /> @@ -261,14 +270,14 @@ const MessageForm = ({ teamId, type }: Props) => { links.length <= 0 && filePreview.length <= 0 && imagePreview.length <= 0 && - !isMessage + !isMessage?.status } type="submit" className={`${ links.length <= 0 && filePreview.length <= 0 && imagePreview.length <= 0 && - !isMessage + !isMessage?.status ? "bg-gray-500 hover:bg-gray-600" : "bg-blue-500 hover:bg-blue-600" } text-white px-4 py-2 rounded-md focus:outline-none`} diff --git a/frontend/src/components/pages/teams/collaborations/common/ShowMessages.tsx b/frontend/src/components/pages/teams/collaborations/common/ShowMessages.tsx index 5afab7f..ed962b3 100644 --- a/frontend/src/components/pages/teams/collaborations/common/ShowMessages.tsx +++ b/frontend/src/components/pages/teams/collaborations/common/ShowMessages.tsx @@ -11,6 +11,7 @@ import { IUser } from "@/interfaces/user.interface"; import React, { useContext, useEffect, useRef, useState } from "react"; import toast from "react-hot-toast"; import { FaRegTrashAlt, FaPencilAlt } from "react-icons/fa"; +import { HiDotsVertical } from "react-icons/hi"; import moment from "moment"; import { formattedDate } from "@/utils/formattedDate"; import { ITeam } from "@/interfaces/team.interface"; @@ -24,17 +25,11 @@ const ShowMessages = ({ messages, team }: Props) => { const { socket, realTimeMessages, setRealTimeMessages }: any = useContext(SocketContext); const messagesContainerRef = useRef(null); - const [isEdit, setIsEdit] = useState({ index: 0, status: false }); const [editedMessage, setEditedMessage] = useState(""); const [imageModalOpen, setImageModalOpen] = useState(false); const [selectedImage, setSelectedImage] = useState(""); - const [isEditMessage, setIsEditMessage] = useState<{ - id: string | undefined; - status: boolean; - }>({ - id: "", - status: false, - }); + const [msIndex, setMsIndex] = useState(null); + const [isEditMessage, setIsEditMessage] = useState(""); const { data: userData } = useLoggedInUserQuery({}); const user: IUser = userData?.data; const [deleteMessage] = useDeleteMessageMutation(); @@ -49,22 +44,35 @@ const ShowMessages = ({ messages, team }: Props) => { const result: any = await deleteMessage(id); if (result?.data?.success) { toast.success("Message deleted"); + setMsIndex(null); } if (result?.error) { toast.error("Message was not deleted"); } }; + const handleShowDropdown = (index: number) => { + if (msIndex === index) { + setMsIndex(null); + } else { + setMsIndex(index); + } + }; + const handleEditMessage = async () => { const result: any = await editMessage({ - id: isEditMessage.id, + id: isEditMessage, text: editedMessage, }); if (result?.data?.success) { toast.success("Message updated"); + setMsIndex(null); + setIsEditMessage(""); } if (result?.error) { toast.error("Message was not updated"); + setMsIndex(null); + setIsEditMessage(""); } }; @@ -99,13 +107,8 @@ const ShowMessages = ({ messages, team }: Props) => { className="mx-auto mt-8 h-screen overflow-hidden hover:overflow-auto scrollbar scrollbar-w-[4px] scrollbar-thumb-blue-600 scrollbar-thin-rounded-md scrollbar-track-slate-100" > {realTimeMessages?.map((post: IMessage, index: number) => ( -

setIsEdit({ index: index, status: true })} - onMouseLeave={() => setIsEdit({ index: 0, status: false })} - > -
+
+
{
- {(isEdit.status && - isEdit?.index === index && - user?.id === post?.poster?.id) || - (user?.id === team?.admin?.id && ( -
- {user.id === post.poster.id && ( + {(user?.id === post?.poster?.id || + user?.id === team?.admin?.id) && ( +
+ + {msIndex === index && ( +
+ {user?.id === post?.poster?.id && ( + + )} - )} - -
- ))} + +
+ )} +
+ )}
- {isEditMessage?.status && isEditMessage.id === post?.id ? ( + {isEditMessage === post?.id ? (