Commit d8fa95f4 authored by Ermolaev Timur's avatar Ermolaev Timur

#78 Релизовал полноценное редактирование

parent ffcfc7b5
...@@ -8,6 +8,7 @@ import { addCalendarTask, addCopyCalendarTask, deleteCalendarTask, editCalendarT ...@@ -8,6 +8,7 @@ import { addCalendarTask, addCopyCalendarTask, deleteCalendarTask, editCalendarT
function MonthCalendar() { function MonthCalendar() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { calendarTasks } = useSelector(state => state.tasks); const { calendarTasks } = useSelector(state => state.tasks);
const user = useSelector(state => state.users?.user);
const [hourFormat, setHourFormat] = useState(false); const [hourFormat, setHourFormat] = useState(false);
const [dateNow, setDateNow] = useState({month: '', year: ''}) const [dateNow, setDateNow] = useState({month: '', year: ''})
...@@ -152,22 +153,29 @@ function MonthCalendar() { ...@@ -152,22 +153,29 @@ function MonthCalendar() {
const day = currentTask.infoForCell.startDay const day = currentTask.infoForCell.startDay
const due = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, day, timeEndHour - 1, 59)) const due = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, day, timeEndHour - 1, 59))
const start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, day, timeStartHour, 0)) const start = dateToISOLikeButLocal(new Date(dateNow.year, dateNow.month, day, timeStartHour, 0))
const newTask = { if (currentTask.id) {
...currentTask, const newTask = {
dateTimeStart: start, ...currentTask,
dateTimeDue: due, dateTimeStart: start,
dateTimeTaskId: currentTask.id, dateTimeDue: due,
taskId: currentTask.mainTaskId dateTimeTaskId: currentTask.id,
} taskId: currentTask.mainTaskId
delete newTask.infoForCell }
delete newTask.id delete newTask.infoForCell
if (newTask.dateTimeTaskId) { delete newTask.id
await dispatch(editCalendarTask(newTask)) await dispatch(editCalendarTask(newTask))
} else { } else {
const newTask = {
...currentTask,
dateTimeStart: start,
dateTimeDue: due,
executor: user,
}
delete newTask.infoForCell
delete newTask.id
await dispatch(addCalendarTask(newTask)) await dispatch(addCalendarTask(newTask))
} }
} }
console.log(currentTask)
const createCopyTask = async (dayNumber, hour) => { const createCopyTask = async (dayNumber, hour) => {
const hourDiff = copyTask.infoForCell.endHour - copyTask.infoForCell.startHour const hourDiff = copyTask.infoForCell.endHour - copyTask.infoForCell.startHour
......
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