Skip to content

Commit

Permalink
Merge pull request #801 from AI4Bharat/login
Browse files Browse the repository at this point in the history
added a popup if no user exists with the particular language
  • Loading branch information
aparna-aa authored Aug 19, 2024
2 parents 34d6d28 + 5ad95c6 commit 7fa0588
Showing 1 changed file with 56 additions and 8 deletions.
64 changes: 56 additions & 8 deletions src/common/CreateTaskDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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")) {
Expand Down Expand Up @@ -182,7 +195,7 @@ const[langLabel,setlabel] =useState("")
};

const disableBtn = () => {
if (!taskType || !allowedTaskType) {
if (!taskType || !allowedTaskType || !user) {
return true;
}

Expand Down Expand Up @@ -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) => (
<MenuItem key={index} value={item}>
{`${item.first_name} ${item.last_name} (${item.email})`}
</MenuItem>
))}
{filteredMembers.map((item, index) => (
<MenuItem key={index} value={item}>
{`${item.first_name} ${item.last_name} (${item.email})`}
</MenuItem>
))}

{showPopup && (
<div
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0,0,0,0.5)',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: 9999,
}}
>
<div
style={{
backgroundColor: 'white',
padding: '20px',
borderRadius: '8px',
textAlign: 'center',
position: 'relative',
minWidth: '300px',
}}
>
<p>Please add a user for the task language</p>
<Button
style={{ marginTop: '10px' }}
onClick={() => setShowPopup(false)}
variant="contained"
>
Close
</Button>
</div>
</div>
)}
</Select>
</FormControl>
</Box>
Expand Down

0 comments on commit 7fa0588

Please sign in to comment.