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

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

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