Commit 261266f1 authored by Ermolaev Timur's avatar Ermolaev Timur

#135 Добавил инактивные клетки, которые дальше дедлайна

parent 54ec2d57
...@@ -81,6 +81,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask, ...@@ -81,6 +81,7 @@ const CalendarRowDay = ({ xs, hoursInDay, createTaskInCellHandler, currentTask,
copyTask={copyTask} copyTask={copyTask}
createCopyTask={createCopyTask} createCopyTask={createCopyTask}
month={month} month={month}
year={year}
> >
</CalendarStandartCell> </CalendarStandartCell>
) )
......
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import { memo, useEffect, useState } from "react"; import { memo, useCallback, useEffect, useMemo, useState } from "react";
import DefaultTask from "../DefaultTask/DefaultTask"; import DefaultTask from "../DefaultTask/DefaultTask";
const heightCell = 40 const heightCell = 40
const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCellHandler, handleOpen, modal, dragTaskHandler, linesInDay, week, copyTask, createCopyTask, month, year, copyMode }) => { const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCellHandler, handleOpen, modal, dragTaskHandler, linesInDay, week, copyTask, createCopyTask, month, year, copyMode, copyModeTask }) => {
const [isThisCell, setIsThisCell] = useState(false) const [isThisCell, setIsThisCell] = useState(false)
const [top, setTop] = useState(0) const [top, setTop] = useState(0)
const cellClass = { const isDeadLine = useMemo(()=>{
position: 'relative', if (copyTask?.dateTimeDeadLine) {
height: linesInDay?.length ? `${heightCell * linesInDay.length + 5}px` : `${45}px`, if (new Date(copyTask?.dateTimeDeadLine).getTime() - new Date(year, month, dayNumber, parseInt(hours?.split(':')[0])).getTime() < 0 ) {
borderRight: '1px solid black', return true
borderBottom: week ? '1px solid black' : null, }
transition: week ? '0.3s' : null, } else {
'&:hover': { if (copyModeTask?.dateTimeDeadLine) {
transition: '0.3s', if (new Date(copyModeTask?.dateTimeDeadLine).getTime() - new Date(year, month, dayNumber, parseInt(hours?.split(':')[0])).getTime() < 0 ) {
cursor: children ? null : '#d6d2d2', return true
background: children ? null : '#d6d2d2' }
}, } else {
} return false
}
}
},[copyTask, copyModeTask, year, month, dayNumber, hours])
console.log(copyTask)
const cellClass = useMemo(() => {
const backgroundColor = isDeadLine ? '#fa9b9be3' : 'null'
return ({
position: 'relative',
height: linesInDay?.length ? `${heightCell * linesInDay.length + 5}px` : `${45}px`,
borderRight: '1px solid black',
borderBottom: week ? '1px solid black' : null,
padding: week ? '2px' : null,
transition: week ? '0.3s' : null,
backgroundColor: backgroundColor,
'&:hover': {
transition: '0.3s',
cursor: children ? null : '#d6d2d2',
background: children ? null : '#d6d2d2'
}
})
}, [children, linesInDay?.length, week, isDeadLine])
useEffect(() => { useEffect(() => {
if (!modal) { if (!modal) {
...@@ -25,23 +48,23 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell ...@@ -25,23 +48,23 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
} }
}, [modal]) }, [modal])
const dragOverHandler = (e) => { const dragOverHandler = useCallback((e) => {
e.preventDefault(); e.preventDefault();
e.target.style.background = children ? null : '#d6d2d2' e.target.style.background = children ? null : '#d6d2d2'
} }, [children])
const dragLeaveHandler = (e) => { const dragLeaveHandler = useCallback((e) => {
e.preventDefault(); e.preventDefault();
e.target.style.background = null e.target.style.background = null
} }, [])
const dropHandler = (e) => { const dropHandler = useCallback((e) => {
e.stopPropagation() e.stopPropagation()
e.preventDefault(); e.preventDefault();
e.target.style.background = null e.target.style.background = null
dragTaskHandler(dayNumber, parseInt(hours.split(':')[0]), month, year) dragTaskHandler(dayNumber, parseInt(hours.split(':')[0]), month, year)
} }, [dayNumber, hours, month, year, dragTaskHandler])
const onClickHandler = (e) => { const onClickHandler = useCallback((e) => {
if (!week) { if (!week) {
if (e.nativeEvent.offsetY <= 5) { if (e.nativeEvent.offsetY <= 5) {
setTop(40 * Math.ceil((e.nativeEvent.offsetY) / 40 - 1)) setTop(40 * Math.ceil((e.nativeEvent.offsetY) / 40 - 1))
...@@ -56,22 +79,51 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell ...@@ -56,22 +79,51 @@ const CalendarStandartCell = ({ children, xs, hours, dayNumber, createTaskInCell
setIsThisCell(true); setIsThisCell(true);
handleOpen(e) handleOpen(e)
} }
} }, [week, copyTask, copyMode, dayNumber, hours, month, year, createTaskInCellHandler, createCopyTask, handleOpen])
return <> const returnCells = useMemo(() => {
<Grid if (copyTask || copyMode) {
item xs={xs} if (isDeadLine) {
sx={cellClass} return (<Grid
onClick={(e) => { onClickHandler(e) }} item xs={xs}
onDragOver={(e) => { dragOverHandler(e) }} sx={cellClass}
onDragLeave={(e) => { dragLeaveHandler(e) }} >
onDrop={(e) => { dropHandler(e) }} </Grid>)
> } else {
{children} return (<Grid
{isThisCell ? item xs={xs}
<DefaultTask week={week} top={top} /> : null} sx={cellClass}
onClick={(e) => { onClickHandler(e) }}
onDragOver={(e) => { dragOverHandler(e) }}
onDragLeave={(e) => { dragLeaveHandler(e) }}
onDrop={(e) => { dropHandler(e) }}
>
{children}
{isThisCell ?
<DefaultTask week={week} top={top} /> : null}
</Grid>)
}
}
return (<>
<Grid
item xs={xs}
sx={cellClass}
onClick={(e) => { onClickHandler(e) }}
onDragOver={(e) => { dragOverHandler(e) }}
onDragLeave={(e) => { dragLeaveHandler(e) }}
onDrop={(e) => { dropHandler(e) }}
>
{children}
{isThisCell ?
<DefaultTask week={week} top={top} /> : null}
</Grid>
</>)
</Grid> }, [cellClass, children, copyMode, copyTask, dragOverHandler, dropHandler, isThisCell, onClickHandler, top, week, xs, dragLeaveHandler, isDeadLine])
return <>
{returnCells}
</> </>
}; };
......
...@@ -87,6 +87,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat ...@@ -87,6 +87,7 @@ function CalendarColumnDayWeek({ hoursInDay, tasks, month, year, day, hourFormat
year={year} year={year}
dragTaskHandler={dragTaskHandler} dragTaskHandler={dragTaskHandler}
copyMode={copyMode.working} copyMode={copyMode.working}
copyModeTask={copyMode.task}
> >
</CalendarStandartCell> </CalendarStandartCell>
) )
......
...@@ -49,6 +49,7 @@ const tasksReduсer = (state = initialState, action) => { ...@@ -49,6 +49,7 @@ const tasksReduсer = (state = initialState, action) => {
mainTaskId: task.id, mainTaskId: task.id,
executor: task.executor, executor: task.executor,
author: task.author, author: task.author,
dateTimeDeadLine: task.dateTimeDeadLine,
priority: task.priority, priority: task.priority,
title: task.title, title: task.title,
description: task.description description: task.description
......
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