Commit 88508f5d authored by Ermolaev Timur's avatar Ermolaev Timur

#129 реализовал проекты в модалке для недельного календаря

parent d38e42bc
......@@ -2,7 +2,7 @@ import { Grid } from "@mui/material";
import { Box } from "@mui/system";
import { useCallback, useState } from "react";
import ModalTask from "../../ModalTask/ModalTask";
import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarModalTaskContent from "../../CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRow from "../../CalendarRow/CalendarRow";
import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell";
......@@ -98,13 +98,14 @@ function WeekCalendarBody({ week, hoursInDay, hourFormat, setHourFormat, date, t
handleClose={() => { handleClose() }}
week={true}
>
<MonthCalendarModalContent
<CalendarModalTaskContent
title={currentTask.title}
description={currentTask.description}
priority={currentTask.priority}
id={currentTask.id}
startHour={currentTask.infoForCell?.startHour}
endHour={currentTask.infoForCell?.endHour}
project={currentTask.project}
onChangeCurrentTaskHandler={(e) => { onChangeCurrentTaskHandler(e) }}
sendNewTaskHandler={() => { sendNewTaskHandler(); handleClose() }}
deleteTaskHandler={() => { deleteTaskHandler(currentTask.id); handleClose() }}
......
......@@ -25,7 +25,7 @@ function MonthCalendar() {
const [userId, setUserId] = useState('')
const [userCalendarId, setUserCalendarId] = useState(null)
const [modal, setModal] = useState(false)
console.log(currentTask)
useEffect(() => {
setDateNow({
month: new Date().getMonth(),
......@@ -148,10 +148,10 @@ function MonthCalendar() {
endHour: hourDue,
startDay: dayNumber
},
project: allUserProjects[0]?.id
project: allUserProjects[0].id
}
setCurrentTask((newTask))
}, [dateNow.month, dateNow.year, hourFormat])
}, [dateNow.month, dateNow.year, hourFormat, allUserProjects])
const dragTaskHandler = useCallback(async (dayNumber, hour) => {
const hourDiff = currentTask.infoForCell.endHour - currentTask.infoForCell.startHour
......
......@@ -4,14 +4,17 @@ import { useDispatch, useSelector } from 'react-redux';
import WeekCalendarBody from '../../components/Calendars/WeekCalendar/WeekCalendarBody/WeekCalendarBody';
import WeekCalendarHeader from '../../components/Calendars/WeekCalendar/WeekCalendarHeader/WeekCalendarHeader';
import { getWeekInfoString, getWeekFromCurrentDate, dateToISOLikeButLocal } from '../../helpers/CalendarHelpers';
import { fetchAllUserProjects } from '../../store/actions/projectsActions';
import { addCalendarTask, addCopyCalendarTask, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions';
function WeekCalendar() {
const dispatch = useDispatch();
const { calendarTasks } = useSelector(state => state.tasks);
const [copyTask, setCopyTask] = useState(null)
const { allUserProjects } = useSelector(state => state.projects)
const user = useSelector(state => state.users?.user);
const [copyTask, setCopyTask] = useState(null)
const [weekGoal, setWeekGoal] = useState('Наладить режим сна')
const [weekPriorities, setWeekPriorities] = useState({ priorityOne: 'Один', priorityTwo: 'Два', priorityThree: 'Три' })
const [dateNow, setDateNow] = useState({ year: '', month: '', currentDay: '' })
......@@ -25,6 +28,7 @@ function WeekCalendar() {
const currentDay = moment().date()
setDateNow({ year: year, month: month, currentDay: currentDay })
dispatch(fetchCalendarTasks(user.id))
dispatch(fetchAllUserProjects())
setUserId(user.id)
}, [dispatch, user.id])
......@@ -122,10 +126,11 @@ function WeekCalendar() {
endHour: hourDue,
startDay: dayNumber,
month: month
}
},
project: allUserProjects[0]?.id
}
setCurrentTask((newTask))
}, [dateNow.year, hourFormat])
}, [dateNow.year, hourFormat, allUserProjects])
const sendNewTaskHandler = useCallback(async () => {
const timeEndHour = currentTask.infoForCell.endHour
......
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