Skip to content

Commit

Permalink
Merge pull request #506 from AI4Bharat/reopen_task_by_deleting_voiceo…
Browse files Browse the repository at this point in the history
…ver_feature

added delete voiceover and reopen task feature
  • Loading branch information
AlpanaMajhi authored Nov 8, 2023
2 parents 7c934d7 + 16dbc56 commit 7d6d9f4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
49 changes: 48 additions & 1 deletion src/containers/Organization/Project/TaskList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const TaskList = () => {
const [searchedCol, setSearchedCol] = useState({});
const [searchedColumn, setSearchedColumn] = useState({});
const [columnDisplay, setColumnDisplay] = useState(false);
const [reOpenTaskId, setReOpenTaskId]= useState(null);

//Data from Redux
const { total_count: totalCount, tasks_list: taskList } = useSelector(
Expand All @@ -176,6 +177,51 @@ const TaskList = () => {
(state) => state.getPreviewData?.data
);

const reopenActionColumn = {
name: "Action",
label: "Actions",
options: {
filter: false,
sort: false,
align: "center",
setCellHeaderProps: () => ({
className: tableClasses.cellHeaderProps,
}),
customBodyRender: (_value, tableMeta) => {
const { tableData: data, rowIndex } = tableMeta;
const selectedTask = data[rowIndex];

return (
<Tooltip
placement="top"
title='Warning! VoiceOver cannot be recovered once deleted'
sx={{
color:'red',
display: "flex",
justifyContent: "flex-end",
alignItems: "center",
}}
>
<Button
color={'error'}
sx={{whiteSpace:'nowrap',display:'inline'}}
onClick={()=>{
{
console.log(tableMeta.rowData[0]);
console.log(setTableDialogColumn)
const reopenObj = new ReopenTaskAPI(reOpenTaskId,true);
dispatch(APITransport(reopenObj));
}
}
}>
Reopen
</Button>
</Tooltip>
);
},
},
};

useEffect(() => {
const { progress, success, apiType, data } = apiStatus;
if (!progress) {
Expand Down Expand Up @@ -250,7 +296,7 @@ const TaskList = () => {
if (apiType === "REOPEN_TASK" && data.response) {
dispatch(setSnackBar({ open: false }));
handleDialogOpen("tableDialog");
setTableDialogColumn(reopenTableColumns);
setTableDialogColumn([...reopenTableColumns,reopenActionColumn]);
setTableDialogMessage(data.message);
setTableDialogResponse(data.response);
}
Expand Down Expand Up @@ -669,6 +715,7 @@ const TaskList = () => {
case "Reopen":
const reopenObj = new ReopenTaskAPI(id);
dispatch(APITransport(reopenObj));
setReOpenTaskId(id)
break;

default:
Expand Down
5 changes: 3 additions & 2 deletions src/redux/actions/api/Project/ReopenTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import ENDPOINTS from "../../../../config/apiendpoint";
import C from "../../../constants";

export default class ReopenTaskAPI extends API {
constructor(id, timeout = 2000) {
constructor(id, delete_voiceover_and_reopen=false, timeout = 2000) {
super("POST", timeout, false);
this.type = C.REOPEN_TASK;
this.delete_and_reopen=delete_voiceover_and_reopen;
this.id = id;

this.endpoint = `${super.apiEndPointAuto()}${
ENDPOINTS.task
}${id}/reopen_translation_task/`;
}${id}/reopen_translation_task/?delete_voiceover_and_reopen=${delete_voiceover_and_reopen}`;
}

processResponse(res) {
Expand Down

0 comments on commit 7d6d9f4

Please sign in to comment.