Merge branch 'task-90-fix/delete_edit_dateTiemTask' into 'development'

Task 90 fix/delete edit date tiem task

See merge request !63
parents a640c930 f9d9d493
...@@ -41,8 +41,9 @@ router.post("/make-copy", async(req:Request, res:Response):Promise<Response>=>{ ...@@ -41,8 +41,9 @@ router.post("/make-copy", async(req:Request, res:Response):Promise<Response>=>{
} ) } )
/** change date time of copy of task in calendar view */ /** change date time of copy of task in calendar view */
router.put("/change-copy", authAuthorOrExecutorOfTask, async(req:Request, res: Response):Promise<Response>=>{ router.put("/change-copy/:dateTimeTaskId", authAuthorOrExecutorOfTask, async(req:Request, res: Response):Promise<Response>=>{
const {executorStatus, dateTimeTaskId, taskId, dateTimeStart, dateTimeDue, description, title, priority} = req.body const {dateTimeTaskId} = req.params
const {executorStatus, taskId, dateTimeStart, dateTimeDue, description, title, priority} = req.body
const dateTimeTask = await dataSource const dateTimeTask = await dataSource
.createQueryBuilder() .createQueryBuilder()
.select('dateTimeTask') .select('dateTimeTask')
...@@ -55,7 +56,7 @@ router.put("/change-copy", authAuthorOrExecutorOfTask, async(req:Request, res: R ...@@ -55,7 +56,7 @@ router.put("/change-copy", authAuthorOrExecutorOfTask, async(req:Request, res: R
await dateTimeTask.save() await dateTimeTask.save()
const task = await taskFinderById(taskId) const task = await taskFinderById(taskId)
if (!task) return res.status(404).send({Message:'task not found'}) if (!task) return res.status(404).send({Message:'task not found'})
task.title = title; task.title = title;
task.description = description; task.description = description;
task.priority = priority; task.priority = priority;
await task.save() await task.save()
......
...@@ -157,8 +157,9 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=> ...@@ -157,8 +157,9 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
/**change of task by task id */ /**change of task by task id */
router.put('/',authAuthorOrExecutorOfTask,async(req:Request, res:Response)=> { router.put('/:taskId',authAuthorOrExecutorOfTask,async(req:Request, res:Response)=> {
const {authorStatus,executorStatus,taskId,title,description,note, archive,project,dateTimeTaskId,dateTimeStart,dateTimeDue,executor,accomplish,dateTimeDeadLine, dateTimeFactDeadLine,priority} = req.body; const {taskId} = req.params
const {authorStatus,executorStatus,title,description,note, archive,project,dateTimeTaskId,dateTimeStart,dateTimeDue,executor,accomplish,dateTimeDeadLine, dateTimeFactDeadLine,priority} = req.body;
const task = await taskFinderById(taskId) const task = await taskFinderById(taskId)
if (!task) return res.status(404).send({Message:'task not found'}) if (!task) return res.status(404).send({Message:'task not found'})
let dateTimeTask = null; let dateTimeTask = null;
......
...@@ -31,7 +31,7 @@ const TableRowTask= ({ ...@@ -31,7 +31,7 @@ const TableRowTask= ({
deleteHandle, deleteHandle,
handleEditTask, handleEditTask,
deleteDateTimeTask, deleteDateTimeTask,
handleEditDateTimeTask, // handleEditDateTimeTask,
onChange, onChange,
onModalOpen, onModalOpen,
onProjectChange, onProjectChange,
...@@ -339,8 +339,10 @@ const TableRowTask= ({ ...@@ -339,8 +339,10 @@ const TableRowTask= ({
</TableCell> </TableCell>
{/* Edit option datetimeTask */} {/* Edit option datetimeTask */}
<TableCell style={{width:'0%'}}> <TableCell
<Tooltip title="Редактировать Копию"> // style={{width:'0%'}}
>
{/* <Tooltip title="Редактировать Копию">
{task.isEditMode ? ( {task.isEditMode ? (
<IconButton <IconButton
aria-label="done" aria-label="done"
...@@ -359,9 +361,9 @@ const TableRowTask= ({ ...@@ -359,9 +361,9 @@ const TableRowTask= ({
<Edit /> <Edit />
</IconButton> </IconButton>
)} )}
</Tooltip> </Tooltip> */}
</TableCell > </TableCell >
{/* delete option datetimeTask */} {/* delete option datetimeTask */}
{task.author.id===user.id ? {task.author.id===user.id ?
(<TableCell style={{width:'0%'}}> (<TableCell style={{width:'0%'}}>
......
...@@ -13,7 +13,7 @@ import TaskModal from "../../components/MyTasksCompoments/TaskModal/TaskModal"; ...@@ -13,7 +13,7 @@ import TaskModal from "../../components/MyTasksCompoments/TaskModal/TaskModal";
import EnhancedTableHead from "./MyTasksHeader/MyTasksHeader"; import EnhancedTableHead from "./MyTasksHeader/MyTasksHeader";
import moment from "moment"; import moment from "moment";
import MyTaskToolBar from "../../components/MyTasksCompoments/MyTaskToolBar"; import MyTaskToolBar from "../../components/MyTasksCompoments/MyTaskToolBar";
import { fetchAllTasks, deleteTask,editTask} from "../../store/actions/tasksActions"; import { fetchAllTasks, deleteTask,editTask, deleteDateTimeTask} from "../../store/actions/tasksActions";
import NewTaskForm from "../../components/MyTasksCompoments/NewTaskForm"; import NewTaskForm from "../../components/MyTasksCompoments/NewTaskForm";
import TableRowTask from "../../components/MyTasksCompoments/TableRowTask/TableRowTask"; import TableRowTask from "../../components/MyTasksCompoments/TableRowTask/TableRowTask";
...@@ -44,7 +44,7 @@ export default function EnhancedTable() { ...@@ -44,7 +44,7 @@ export default function EnhancedTable() {
if (tasks && tasks?.length > 0) { if (tasks && tasks?.length > 0) {
setRecievedTasks(tasks); setRecievedTasks(tasks);
} }
}, [tasks?.length]); }, [dispatch, tasks?.length]);
useEffect(() => { useEffect(() => {
dispatch(fetchAllTasks()); dispatch(fetchAllTasks());
...@@ -162,9 +162,9 @@ useEffect(() => { ...@@ -162,9 +162,9 @@ useEffect(() => {
dispatch(deleteTask(id)); dispatch(deleteTask(id));
}; };
const deleteDateTimeTask=(dateTImeTaskId)=>{ const deleteDateTimeTaskHandle=(dateTimeTaskId)=>{
console.log('delete by dateTImeTaskId') console.log('delete by dateTimeTaskId ', dateTimeTaskId)
// dispatch(deleteDateTimeTask(dateTImeTaskId)) dispatch(deleteDateTimeTask(dateTimeTaskId))
} }
const handleEditDateTimeTask=(dateTimeTask)=>{ const handleEditDateTimeTask=(dateTimeTask)=>{
...@@ -272,7 +272,7 @@ console.log('tasks', tasks) ...@@ -272,7 +272,7 @@ console.log('tasks', tasks)
deleteHandle={deleteHandle} deleteHandle={deleteHandle}
handleEditTask ={handleEditTask} handleEditTask ={handleEditTask}
handleEditDateTimeTask={handleEditDateTimeTask} handleEditDateTimeTask={handleEditDateTimeTask}
deleteDateTimeTask={deleteDateTimeTask} deleteDateTimeTask={deleteDateTimeTaskHandle}
onChange={onChange} onChange={onChange}
onModalOpen={onModalOpen} onModalOpen={onModalOpen}
onProjectChange={onProjectChange} onProjectChange={onProjectChange}
......
...@@ -20,4 +20,8 @@ export const DELETE_TASK_REQUEST = "DELETE_TASK_REQUEST"; ...@@ -20,4 +20,8 @@ export const DELETE_TASK_REQUEST = "DELETE_TASK_REQUEST";
export const DELETE_TASK_SUCCESS = "DELETE_TASK_SUCCESS"; export const DELETE_TASK_SUCCESS = "DELETE_TASK_SUCCESS";
export const DELETE_TASK_FAILURE = "DELETE_TASK_FAILURE"; export const DELETE_TASK_FAILURE = "DELETE_TASK_FAILURE";
export const EDIT_CALENDAR_TASK = "EDIT_CALENDAR_TASK"; export const EDIT_CALENDAR_TASK = "EDIT_CALENDAR_TASK";
\ No newline at end of file
export const DELETE_DATETIMETASK_REQUEST = "DELETE_TASK_REQUEST";
export const DELETE_DATETIMETASK_SUCCESS = "DELETE_TASK_SUCCESS";
export const DELETE_DATETIMETASK_FAILURE = "DELETE_TASK_FAILURE";
\ No newline at end of file
...@@ -14,7 +14,10 @@ import { ...@@ -14,7 +14,10 @@ import {
FETCH_ALL_TASKS_SUCCESS, FETCH_ALL_TASKS_SUCCESS,
FETCH_TASKS_BY_PROJECT_SUCCESS, FETCH_TASKS_BY_PROJECT_SUCCESS,
FETCH_TASKS_BY_PROJECT_FAILURE, FETCH_TASKS_BY_PROJECT_FAILURE,
FETCH_TASKS_BY_PROJECT_REQUEST FETCH_TASKS_BY_PROJECT_REQUEST,
DELETE_DATETIMETASK_FAILURE,
DELETE_DATETIMETASK_SUCCESS,
DELETE_DATETIMETASK_REQUEST,
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner' import axios from '../../axiosPlanner'
...@@ -209,4 +212,31 @@ export const fetchTasksByProject = (projects) => { ...@@ -209,4 +212,31 @@ export const fetchTasksByProject = (projects) => {
dispatch(fetchTasksByProjectFailure(error.response.data)); dispatch(fetchTasksByProjectFailure(error.response.data));
} }
} }
} }
\ No newline at end of file
const deleteDateTimeTaskRequest = () => {
return {type: DELETE_DATETIMETASK_REQUEST}
};
const deleteDateTimeTaskSuccess = () => {
return {type: DELETE_DATETIMETASK_SUCCESS}
};
const deleteDateTimeTaskFailure = (error) => {
return {type: DELETE_DATETIMETASK_FAILURE, error}
};
export const deleteDateTimeTask = (dateTimeTaskId) => {
return async (dispatch) => {
dispatch(deleteDateTimeTaskRequest());
try {
await axios.delete(`/copy-tasks/${dateTimeTaskId}`);
dispatch(deleteDateTimeTaskSuccess())
dispatch(fetchAllTasks())
} catch (error) {
dispatch(deleteDateTimeTaskFailure(error.response.data));
}
}
}
...@@ -15,7 +15,10 @@ import { ...@@ -15,7 +15,10 @@ import {
EDIT_CALENDAR_TASK, EDIT_CALENDAR_TASK,
FETCH_TASKS_BY_PROJECT_REQUEST, FETCH_TASKS_BY_PROJECT_REQUEST,
FETCH_TASKS_BY_PROJECT_SUCCESS, FETCH_TASKS_BY_PROJECT_SUCCESS,
FETCH_TASKS_BY_PROJECT_FAILURE FETCH_TASKS_BY_PROJECT_FAILURE,
DELETE_DATETIMETASK_FAILURE,
DELETE_DATETIMETASK_SUCCESS,
DELETE_DATETIMETASK_REQUEST
} from "../actionTypes/tasksTypes"; } from "../actionTypes/tasksTypes";
const initialState = { const initialState = {
...@@ -102,6 +105,12 @@ const tasksReduсer = (state = initialState, action) => { ...@@ -102,6 +105,12 @@ const tasksReduсer = (state = initialState, action) => {
return {...state, loading: true}; return {...state, loading: true};
case DELETE_TASK_FAILURE: case DELETE_TASK_FAILURE:
return {...state, loading: false, error: action.error}; return {...state, loading: false, error: action.error};
case DELETE_DATETIMETASK_SUCCESS:
return {...state, loading: false};
case DELETE_DATETIMETASK_REQUEST:
return {...state, loading: true};
case DELETE_DATETIMETASK_FAILURE:
return {...state, loading: false, error: action.error};
default: default:
return state; return state;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment