Commit 53fe8f38 authored by Ermolaev Timur's avatar Ermolaev Timur

#135 Добавил мод редактирования

parent d56c1f40
......@@ -6,7 +6,6 @@ import CalendarStandartCell from "../../UI/CalendarStandartCell/CalendarStandart
import ModalTask from "../../UI/ModalTask/ModalTask"
import MonthCalendarModalContent from "../../UI/CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
import { useSelector } from "react-redux";
function MonthCalendarBody({ month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth, dragTaskHandler, createCopyTask, setCopyTask, copyTask}) {
......
import { AppBar, Button, Toolbar, Typography } from '@mui/material';
import { AppBar, Toolbar, } from '@mui/material';
import { Box } from '@mui/system';
import ButtonSwapCalendar from '../../UI/ButtonSwapCalendar/ButtonSwapCalendar';
import CalendarUserDisplayName from '../../UI/CalendarUserDisplayName/CalendarUserDisplayName';
......
import Box from '@mui/material/Box';
import Modal from '@mui/material/Modal';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
export default function ModalTask({ modal, handleClose, children, week }) {
......@@ -38,7 +38,7 @@ export default function ModalTask({ modal, handleClose, children, week }) {
return modal.yClickСordinates - modal.yDiv - modal.yDivClick - ((modal.yClickСordinates + 470) - windowDimenion.winHeight) - 30
}
}
}, [windowDimenion.winHeight, modal])
}, [windowDimenion.winHeight, modal, week])
const getXCordinatesToModal = useCallback(() => {
if (windowDimenion.winWidth > modal.xClickСordinates + 270 + modal.xDiv) {
......
......@@ -94,7 +94,7 @@ function CalendarWeekTask({ height, width, left, top, task, zIndex, handleOpen,
e.stopPropagation();
setCopyTask(task)
}, [task, setCopyTask])
console.log(tasksLength)
return (
<Box
draggable={true}
......
......@@ -22,6 +22,9 @@ import BasicSelect from "../../UI/Select/Select";
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { useNavigate } from "react-router-dom";
import { useDispatch } from "react-redux";
import { activateCreateCopyTasksMode } from "../../../store/actions/tasksActions";
const weekDays = ["Вс","Пн","Вт","Ср","Чт","Пт","Сб" ];
......@@ -42,7 +45,8 @@ const TableRowTask= ({
})=>{
const [open, setOpen] = React.useState(false);
const navigate = useNavigate()
const dispatch = useDispatch()
const roudHourUp =(dateIso)=>{
let m = moment(dateIso);
let roundUp = m.minute() || m.second() || m.millisecond() ? m.add(1, 'hour').startOf('hour') : m.startOf('hour');
......@@ -59,7 +63,7 @@ const TableRowTask= ({
return weekDays[date.day()];
}
const calendarOpen=(taskId)=>{
console.log('task Id in Calendar Open' , taskId)
dispatch(activateCreateCopyTasksMode(task, navigate))
}
return (
......@@ -159,11 +163,11 @@ const TableRowTask= ({
user:user
}}
/>
{task.isEditMode && task.author.id===user.id ? (
{task.dateTimeTasks.length === 0 && task.author.id === user.id ? (
<TableCell>
<Tooltip title="Перейти в календарь">
<IconButton
onClick={() => { calendarOpen(task.id)}}
onClick={() => { calendarOpen(task)}}
>
<CalendarMonthIcon />
</IconButton>
......@@ -172,7 +176,7 @@ const TableRowTask= ({
</TableCell>
) : (
task.dateTimeTasks.length>1 ?
task.dateTimeTasks.length >= 1 ?
<TableCell>
<IconButton
aria-label="expand row"
......@@ -286,7 +290,7 @@ const TableRowTask= ({
</TableCell>):null}
</TableRow>
{task.dateTimeTasks.length>1?
{task.dateTimeTasks.length>=1?
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={11}>
<Collapse in={open} timeout="auto" unmountOnExit>
......
......@@ -189,7 +189,6 @@ export default function EnhancedTable() {
setRecievedTasks(tasksFilteredByProject)
setFilterProjectTumbler(true)
}
// if (
// tasks &&
// tasks?.length > 0
......
......@@ -8,15 +8,15 @@ import DefaultModal from '../../components/UI/DefaultModal/DefaultModal';
import { AllHoursOneHourFormat, AllHoursTwoHourFormat } from '../../constants';
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, deactivateCreateCopyTasksMode, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions';
import { fetchCurrentCalendarDisplayName } from '../../store/actions/usersActions';
function WeekCalendar() {
const dispatch = useDispatch();
const { calendarTasks } = useSelector(state => state.tasks);
const { calendarTasks, copyMode } = useSelector(state => state.tasks);
const { user, currentCalendarDisplayName } = useSelector(state => state.users);
const { allUserProjects, project } = useSelector(state => state.projects)
const { allUserProjects} = useSelector(state => state.projects)
console.log(copyMode)
const [weekGoal, setWeekGoal] = useState('Наладить режим сна')
const [weekPriorities, setWeekPriorities] = useState({ priorityOne: 'Один', priorityTwo: 'Два', priorityThree: 'Три' })
const [workerInfo, setWorkerInfo] = useState({ project: '', worker: '' });
......@@ -33,8 +33,9 @@ function WeekCalendar() {
const month = new Date().getMonth()
const currentDay = moment().date()
setDateNow({ year: year, month: month, currentDay: currentDay })
dispatch(fetchCalendarTasks(user.id))
dispatch(fetchAllUserProjects())
return () =>{
dispatch(deactivateCreateCopyTasksMode())
}
}, [dispatch, user.id])
useEffect(() => {
......
......@@ -29,3 +29,6 @@ export const DELETE_DATETIMETASK_FAILURE = "DELETE_TASK_FAILURE";
export const FETCH_ALL_TASKS_BY_MEMBERSHIP_REQUEST = "FETCH_ALL_TASKS_BY_MEMBERSHIP_REQUEST";
export const FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS = "FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS";
export const FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE = "FETCH_ALL_TASKS_BY_MEMBERSHIP_FAILURE";
export const ACTIVATE_CREATE_COPY_TASKS_MODE = "ACTIVATE_CREATE_COPY_TASKS_MODE"
export const DEACTIVATE_CREATE_COPY_TASKS_MODE = "DEACTIVATE_CREATE_COPY_TASKS_MODE"
\ No newline at end of file
......@@ -18,7 +18,9 @@ import {
DELETE_DATETIMETASK_FAILURE,
DELETE_DATETIMETASK_SUCCESS,
DELETE_DATETIMETASK_REQUEST,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS,
DEACTIVATE_CREATE_COPY_TASKS_MODE,
ACTIVATE_CREATE_COPY_TASKS_MODE
} from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner'
......@@ -295,3 +297,12 @@ export const addTaskToUserTasksTable = (task) => {
}
/** end */
export const activateCreateCopyTasksMode = (task, navigate) => {
navigate('/')
return {type: ACTIVATE_CREATE_COPY_TASKS_MODE, task}
}
export const deactivateCreateCopyTasksMode = () => {
return {type: DEACTIVATE_CREATE_COPY_TASKS_MODE}
}
\ No newline at end of file
......@@ -18,10 +18,17 @@ import {
DELETE_DATETIMETASK_FAILURE,
DELETE_DATETIMETASK_SUCCESS,
DELETE_DATETIMETASK_REQUEST,
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS,
ACTIVATE_CREATE_COPY_TASKS_MODE,
DEACTIVATE_CREATE_COPY_TASKS_MODE
} from "../actionTypes/tasksTypes";
const initialState = {
copyMode: {
working: false,
task: null,
},
tasks: [],
calendarTasks: [],
loading: false,
error: null,
......@@ -114,6 +121,10 @@ const tasksReduсer = (state = initialState, action) => {
return {...state, loading: true};
case DELETE_DATETIMETASK_FAILURE:
return {...state, loading: false, error: action.error};
case ACTIVATE_CREATE_COPY_TASKS_MODE:
return {...state, copyMode: {working: true, task: action.task}}
case DEACTIVATE_CREATE_COPY_TASKS_MODE:
return {...state, copyMode: {working: false, task: null}}
default:
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