Commit 52ea0c06 authored by Ermolaev Timur's avatar Ermolaev Timur

#38 Небольшие изменения

parent 312070bd
import { Grid, TextField, Typography } from "@mui/material"; import { Grid, TextField, Typography } from "@mui/material";
import React, { memo, useState, useEffect} from "react"; import React, { memo, useState, useEffect, useMemo} from "react";
const TaskDefault = ({task, onClickTaskHandler}) => { const TaskDefault = ({task, onClickTaskHandler}) => {
return(<Grid return(<Grid
sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '10px', borderBottom: '1px solid rgb(29, 161, 51)', borderRadius: '10px', margin:"5px 10px"}} sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', borderBottom: '1px solid rgb(29, 161, 51)', borderRadius: '10px', margin:"5px 10px"}}
onClick={onClickTaskHandler} onClick={onClickTaskHandler}
> >
<span> <span>
...@@ -15,7 +15,7 @@ const TaskDefault = ({task, onClickTaskHandler}) => { ...@@ -15,7 +15,7 @@ const TaskDefault = ({task, onClickTaskHandler}) => {
const TaskWithNoStartAndAllEnd = ({task, onClickTaskHandler}) => { const TaskWithNoStartAndAllEnd = ({task, onClickTaskHandler}) => {
return(<Grid return(<Grid
sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', padding: '10px', borderBottom: '1px solid rgb(29, 161, 51)', borderTopLeftRadius: '10px', borderBottomLeftRadius: '10px', margin:"5px -1px 5px 10px", position:'relative'}} sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', padding: '5px', borderBottom: '1px solid rgb(29, 161, 51)', borderTopLeftRadius: '10px', borderBottomLeftRadius: '10px', margin:"5px -1px 5px 10px", position:'relative'}}
onClick={onClickTaskHandler} onClick={onClickTaskHandler}
> >
<span> <span>
...@@ -25,7 +25,7 @@ const TaskWithNoStartAndAllEnd = ({task, onClickTaskHandler}) => { ...@@ -25,7 +25,7 @@ const TaskWithNoStartAndAllEnd = ({task, onClickTaskHandler}) => {
} }
const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => { const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => {
return(<Grid return(<Grid
sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '10px', borderBottom: '1px solid rgb(29, 161, 51)', borderTopRightRadius: '10px', borderBottomRightRadius: '10px', margin:"5px 10px 5px -1px"}} sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', borderBottom: '1px solid rgb(29, 161, 51)', borderTopRightRadius: '10px', borderBottomRightRadius: '10px', margin:"5px 10px 5px -1px"}}
onClick={onClickTaskHandler} onClick={onClickTaskHandler}
> >
<span> <span>
...@@ -35,7 +35,7 @@ const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => { ...@@ -35,7 +35,7 @@ const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => {
} }
const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => { const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => {
return(<Grid return(<Grid
sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '10px', borderBottom: '1px solid rgb(29, 161, 51)', margin:"5px -1px"}} sx={{backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', borderBottom: '1px solid rgb(29, 161, 51)', margin:"5px -1px"}}
onClick={onClickTaskHandler} onClick={onClickTaskHandler}
> >
<span> <span>
...@@ -50,8 +50,9 @@ const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => { ...@@ -50,8 +50,9 @@ const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => {
const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourFormat, handleOpen, currentTask}) => { const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourFormat, handleOpen, currentTask}) => {
const [thisCellCurrentTask, setThisCellCurrentTask] = useState({}) const [thisCellCurrentTask, setThisCellCurrentTask] = useState({})
const hour = parseInt(hours.split(':')[0]) const hour = parseInt(hours.split(':')[0])
const getTaskInDayCell = (tasks, day, hours) => { const tasksCell = useMemo(() => {
let hourDiffEnd let hourDiffEnd
if (hourFormat) { if (hourFormat) {
hourDiffEnd = hour + 1 hourDiffEnd = hour + 1
...@@ -77,9 +78,7 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma ...@@ -77,9 +78,7 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
return durattionSecondDate - durattionFirstDate; return durattionSecondDate - durattionFirstDate;
}); });
return tasksCell return tasksCell
} }, [hourFormat, month, tasks])
const tasksCell = getTaskInDayCell(tasks, day, hours)
useEffect(()=>{ useEffect(()=>{
if (!currentTask.title) { if (!currentTask.title) {
...@@ -98,7 +97,7 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma ...@@ -98,7 +97,7 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
{tasksCell.length ? tasksCell.map((task, i)=> {tasksCell.length ? tasksCell.map((task, i)=>
{ {
if (hourFormat && task.infoForCell.endHour > hour && task.infoForCell.startHour === hour || (!hourFormat && task.infoForCell.endHour > hour + 1 && task.infoForCell.startHour === hour)) { if (hourFormat && task.infoForCell.endHour > hour && task.infoForCell.startHour === hour || (!hourFormat && task.infoForCell.endHour > hour + 1 && (task.infoForCell.startHour === hour))) {
return ( return (
<TaskWithNoStartAndAllEnd <TaskWithNoStartAndAllEnd
key={task.id} key={task.id}
...@@ -117,21 +116,21 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma ...@@ -117,21 +116,21 @@ const CalendarTask = ({year, month, tasks, day, hours, setCurrentTask, hourForma
) )
} }
if (hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.startHour < hour || (!hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.startHour < hour && (task.infoForCell.endHour === hour || task.infoForCell.endHour === hour + 1 && task.infoForCell.startHour + 1 !== hour))) { if (hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.startHour < hour || (!hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.startHour < hour && (task.infoForCell.endHour === hour || task.infoForCell.endHour === hour + 1 && task.infoForCell.startHour + 1 !== hour))) {
return ( return (<>
<TaskWithAllStartAndNoEnd <TaskWithAllStartAndNoEnd
key={task.id} key={task.id}
task={task} task={task}
onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}} onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}}
/> />
) </>)
} }
return ( return (<>
<TaskDefault <TaskDefault
key={task.id} key={task.id}
task={task} task={task}
onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}} onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}}
/> />
)} </>)}
) )
: null} : null}
</>) </>)
......
...@@ -10,6 +10,7 @@ import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalenda ...@@ -10,6 +10,7 @@ import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalenda
function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth}) { function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, currentTask, setCurrentTask, hourFormat, setHourFormat, onChangeCurrentTaskHandler, sendNewTaskHandler, deleteTaskHandler, cellSizes, hoursInDay, daysInMonth}) {
const [modal, setModal] = useState({open:false, y: 0, x: 0,}); const [modal, setModal] = useState({open:false, y: 0, x: 0,});
const [allCellsTasks, setAllCellsTasks] = useState([])
const handleOpen = (e) => { const handleOpen = (e) => {
setModal( { setModal( {
open: true, open: true,
...@@ -27,7 +28,6 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current ...@@ -27,7 +28,6 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
}; };
return ( return (
<> <>
<CalendarRow <CalendarRow
......
...@@ -11,7 +11,8 @@ import { ...@@ -11,7 +11,8 @@ import {
FETCH_CALENDAR_TASKS_FAILURE, FETCH_CALENDAR_TASKS_FAILURE,
FETCH_CALENDAR_TASKS_REQUEST, FETCH_CALENDAR_TASKS_REQUEST,
FETCH_CALENDAR_TASKS_SUCCESS, FETCH_CALENDAR_TASKS_SUCCESS,
FETCH_ALL_TASKS_SUCCESS} from "../actionTypes/tasksTypes"; FETCH_ALL_TASKS_SUCCESS,
} from "../actionTypes/tasksTypes";
import axios from '../../axiosPlanner' import axios from '../../axiosPlanner'
const fetchCalendarTasksRequest = () => { const fetchCalendarTasksRequest = () => {
......
...@@ -11,7 +11,8 @@ import { ...@@ -11,7 +11,8 @@ import {
DELETE_TASK_SUCCESS, DELETE_TASK_SUCCESS,
DELETE_TASK_REQUEST, DELETE_TASK_REQUEST,
DELETE_TASK_FAILURE, DELETE_TASK_FAILURE,
FETCH_ALL_TASKS_SUCCESS} from "../actionTypes/tasksTypes"; FETCH_ALL_TASKS_SUCCESS,
} from "../actionTypes/tasksTypes";
const initialState = { const initialState = {
calendarTasks: [], calendarTasks: [],
......
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