From 0ef535ef901bd217ee41e8f66419cb8ad22683d9 Mon Sep 17 00:00:00 2001 From: Akshayasree Padmanaban Date: Mon, 19 Aug 2024 09:32:50 +0530 Subject: [PATCH] added a popup if no user exists with the particular language --- src/common/CreateTaskDialog.jsx | 64 ++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/src/common/CreateTaskDialog.jsx b/src/common/CreateTaskDialog.jsx index 55668335..261991cb 100644 --- a/src/common/CreateTaskDialog.jsx +++ b/src/common/CreateTaskDialog.jsx @@ -72,6 +72,10 @@ const[langLabel,setlabel] =useState("") const [allowedTaskType, setAllowedTaskType] = useState(""); const [showAllowedTaskList, setShowAllowedTaskList] = useState(false); const [showLimitWarning, setShowLimitWarning] = useState(false); + const [showPopup, setShowPopup] = useState(false); + const filteredMembers = projectMembers.filter((member) => + member.languages.includes(langLabel) + ); useEffect(() => { const taskObj = new FetchTaskTypeAPI(); dispatch(APITransport(taskObj)); @@ -84,6 +88,15 @@ const[langLabel,setlabel] =useState("") // eslint-disable-next-line }, []); + useEffect(() => { + console.log(filteredMembers.length) + if (filteredMembers.length === 0) { + setShowPopup(true); + } + else{ + setShowPopup(false) + } + }, [filteredMembers]); useEffect(() => { if (taskType.length && !taskType.includes("TRANSCRIPTION")) { @@ -182,7 +195,7 @@ const[langLabel,setlabel] =useState("") }; const disableBtn = () => { - if (!taskType || !allowedTaskType) { + if (!taskType || !allowedTaskType || !user) { return true; } @@ -371,13 +384,48 @@ const[langLabel,setlabel] =useState("") inputProps={{ "aria-label": "Without label" }} disabled={isAssignUserDropdownDisabled()} > - {projectMembers - .filter((member) => member.languages.includes(langLabel)) - .map((item, index) => ( - - {`${item.first_name} ${item.last_name} (${item.email})`} - - ))} + {filteredMembers.map((item, index) => ( + + {`${item.first_name} ${item.last_name} (${item.email})`} + + ))} + + {showPopup && ( +
+
+

Please add a user for the task language

+ +
+
+ )}