Commit 72e00819 authored by Ermolaev Timur's avatar Ermolaev Timur

#38 Убрал предупреждния, чуть оптимизировал

parent 2a92b77a
...@@ -18,6 +18,7 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => { ...@@ -18,6 +18,7 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => {
const App = () => { const App = () => {
const user = useSelector(state => state.users?.user); const user = useSelector(state => state.users?.user);
console.log(user)
return ( return (
<BrowserRouter> <BrowserRouter>
<Routes> <Routes>
......
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import { memo } from "react";
const CalendarRow = ({children}) => { const CalendarRow = ({children}) => {
return <> return <>
......
...@@ -7,20 +7,20 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -7,20 +7,20 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
const hours = useMemo(()=>{ const hours = useMemo(()=>{
return hoursInDay.map((hour)=>parseInt(hour.split(':')[0]))}, return hoursInDay.map((hour)=>parseInt(hour.split(':')[0]))},
[hourFormat]) [hoursInDay])
const availableTasks = useMemo(() => { const availableTasks = useMemo(() => {
const tasksInDay = tasks.filter(task=> { const tasksInDay = tasks.filter((task)=> {
if (year === task.infoForCell.startYear) { if (year === task.infoForCell.startYear) {
if (month + 1 === task.infoForCell.startMonth) { if (month + 1 === task.infoForCell.startMonth) {
if (day.dayNumber === task.infoForCell.startDay) { if (day.dayNumber === task.infoForCell.startDay) {
return task return task
} } else {return false}
} } else {return false}
} } else {return false}
}) })
return tasksInDay return tasksInDay
}, [tasks, month]) }, [tasks, month, year, day.dayNumber])
const sortedTasks = useMemo(() => { const sortedTasks = useMemo(() => {
if (availableTasks.length) { if (availableTasks.length) {
...@@ -65,7 +65,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -65,7 +65,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
if (!isNaN(line[i])) { if (!isNaN(line[i])) {
for (let a = 0; a < hours.length; a++) { for (let a = 0; a < hours.length; a++) {
const hour = hours[a] const hour = hours[a]
if (task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour + hourDiffEnd || (!hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour)) { if ((task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour + hourDiffEnd) || (!hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour)) {
if (isNaN(line[a])) { if (isNaN(line[a])) {
havePlace = false havePlace = false
break; break;
...@@ -77,7 +77,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -77,7 +77,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
break; break;
} }
line[i] += `-${k}` line[i] += `-${k}`
if (task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour + hourDiffEnd || (!hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour)) { if ((task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour + hourDiffEnd) || (!hourFormat && task.infoForCell.endMinute === 59 && task.infoForCell.endHour === hour)) {
skipLine = true skipLine = true
break; break;
} }
...@@ -93,7 +93,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -93,7 +93,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
} }
} }
return lines return lines
}, [sortedTasks, hours]) }, [availableTasks.length, hourFormat, hours, hoursInDay, sortedTasks])
return <> return <>
<Grid <Grid
...@@ -112,7 +112,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h ...@@ -112,7 +112,7 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
return ( return (
<CalendarStandartCell <CalendarStandartCell
key={i} key={i}
item xs={12/hoursInDay.length} item xs={xs}
createTaskInCellHandler={createTaskInCellHandler} createTaskInCellHandler={createTaskInCellHandler}
hours={hour} hours={hour}
dayNumber={day.dayNumber} dayNumber={day.dayNumber}
......
import { Grid, TextField, Typography } from "@mui/material"; import { Grid} from "@mui/material";
import { memo, useEffect, useState } from "react"; import { memo, useEffect, useState } from "react";
const CalendarStandartCell = ({children, xs, hours, dayNumber, createTaskInCellHandler, handleOpen, modal}) => { const CalendarStandartCell = ({children, xs, hours, dayNumber, createTaskInCellHandler, handleOpen, modal}) => {
......
import { Grid, TextField, Typography } from "@mui/material"; import { Grid} from "@mui/material";
import React, { memo, useState, useEffect, useMemo} from "react"; import React, { memo} from "react";
import { useDispatch } from "react-redux";
import { editCalendarTask } from "../../../store/actions/tasksActions";
const TaskDefault = ({task, onClickTaskHandler}) => { const TaskDefault = ({task, onClickTaskHandler}) => {
...@@ -25,7 +23,7 @@ const TaskWithNoStartAndAllEnd = ({task, onClickTaskHandler}) => { ...@@ -25,7 +23,7 @@ const TaskWithNoStartAndAllEnd = ({task, onClickTaskHandler}) => {
</span> </span>
</Grid>) </Grid>)
} }
const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => { const TaskWithAllStartAndNoEnd = ({onClickTaskHandler}) => {
return(<Grid return(<Grid
sx={{height: '30px',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"}} sx={{height: '30px',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}
...@@ -35,7 +33,7 @@ const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => { ...@@ -35,7 +33,7 @@ const TaskWithAllStartAndNoEnd = ({task, onClickTaskHandler}) => {
</span> </span>
</Grid>) </Grid>)
} }
const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => { const TaskWithAllStartAndAllEnd = ({onClickTaskHandler}) => {
return(<Grid return(<Grid
sx={{height: '30px', backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', borderBottom: '1px solid rgb(29, 161, 51)', margin:"5px -1px"}} sx={{height: '30px', backgroundColor: 'lightgreen', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', borderBottom: '1px solid rgb(29, 161, 51)', margin:"5px -1px"}}
onClick={onClickTaskHandler} onClick={onClickTaskHandler}
...@@ -46,7 +44,7 @@ const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => { ...@@ -46,7 +44,7 @@ const TaskWithAllStartAndAllEnd = ({task, onClickTaskHandler}) => {
</Grid>) </Grid>)
} }
const Empty = ({}) => { const Empty = () => {
return (<Grid return (<Grid
sx={{height: '30px', backgroundColor: 'rgb(0,0,0,0)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', margin:"5px -1px"}} sx={{height: '30px', backgroundColor: 'rgb(0,0,0,0)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', padding: '5px', margin:"5px -1px"}}
> >
...@@ -61,16 +59,8 @@ const Empty = ({}) => { ...@@ -61,16 +59,8 @@ const Empty = ({}) => {
const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTask, linesForCell, sortedTasks}) => { const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTask, linesForCell, sortedTasks}) => {
const [thisCellCurrentTask, setThisCellCurrentTask] = useState({})
const hour = parseInt(hours.split(':')[0]) const hour = parseInt(hours.split(':')[0])
useEffect(()=>{
if (!currentTask.title) {
setThisCellCurrentTask({})
}
}, [currentTask])
const onClickTaskHandler = (e, task) => { const onClickTaskHandler = (e, task) => {
e.stopPropagation(); e.stopPropagation();
setCurrentTask(task); setCurrentTask(task);
...@@ -95,7 +85,6 @@ const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTas ...@@ -95,7 +85,6 @@ const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTas
|| (!hourFormat && task.infoForCell.startHour < hour && task.infoForCell.endHour > hour + 1)) { || (!hourFormat && task.infoForCell.startHour < hour && task.infoForCell.endHour > hour + 1)) {
return (<TaskWithAllStartAndAllEnd return (<TaskWithAllStartAndAllEnd
key={task.id} key={task.id}
task={task}
onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}} onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}}
/>) />)
} }
...@@ -103,7 +92,6 @@ const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTas ...@@ -103,7 +92,6 @@ const CalendarTask = ({hours, setCurrentTask, hourFormat, handleOpen, currentTas
return ( return (
<TaskWithAllStartAndNoEnd <TaskWithAllStartAndNoEnd
key={task.id} key={task.id}
task={task}
onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}} onClickTaskHandler={(e)=>{onClickTaskHandler(e, task)}}
/>) />)
} }
......
import { FormControlLabel, Switch} from "@mui/material"; import { FormControlLabel, Switch} from "@mui/material";
import { memo, useEffect, useState } from "react"; import { useState } from "react";
import CalendarRow from "./CalendarRow/CalendarRow"; import CalendarRow from "./CalendarRow/CalendarRow";
import CalendarSmallCell from "./CalendarSmallCell/CalendarSmallCell"; import CalendarSmallCell from "./CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "./CalendarStandartCell.js/CalendarStandartCell"; import CalendarStandartCell from "./CalendarStandartCell.js/CalendarStandartCell";
import CalendarTask from "./CalendarTask/CalendarTask";
import ModalTask from "../UI/ModalTask/ModalTask"; import ModalTask from "../UI/ModalTask/ModalTask";
import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalendarModalContent"; import MonthCalendarModalContent from "../MonthCalendarModalContent/MonthCalendarModalContent";
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay"; import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
...@@ -11,7 +10,6 @@ import CalendarRowDay from "./CalendarRowDay/CalendarRowDay"; ...@@ -11,7 +10,6 @@ import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
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,
...@@ -56,7 +54,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current ...@@ -56,7 +54,7 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
<CalendarSmallCell xs={cellSizes.smallCell}>{day.dayNumber}</CalendarSmallCell> <CalendarSmallCell xs={cellSizes.smallCell}>{day.dayNumber}</CalendarSmallCell>
<CalendarSmallCell xs={cellSizes.smallCell}>{day.dayOfWeek}</CalendarSmallCell> <CalendarSmallCell xs={cellSizes.smallCell}>{day.dayOfWeek}</CalendarSmallCell>
<CalendarRowDay <CalendarRowDay
xs={cellSizes.standarCell} xs={cellSizes.dayCell}
createTaskInCellHandler={createTaskInCellHandler} createTaskInCellHandler={createTaskInCellHandler}
hoursInDay={hoursInDay} hoursInDay={hoursInDay}
currentTask={currentTask} currentTask={currentTask}
......
...@@ -6,10 +6,10 @@ function СustomSelect({value, onChange, label, variant='standard', items, id}) ...@@ -6,10 +6,10 @@ function СustomSelect({value, onChange, label, variant='standard', items, id})
return ( return (
<> <>
<FormControl variant={variant} sx={{ m: 1, minWidth: 120 }}> <FormControl variant={variant} sx={{ m: 1, minWidth: 120 }}>
<InputLabel id={id + '-select' + '-label'}>{label}</InputLabel> <InputLabel id={`${id}-select-label`}>{label}</InputLabel>
<Select <Select
labelId={id + '-select'+ '-label'} labelId={`${id}-select-label`}
id={id + '-select'} id={`${id}-select`}
value={value} value={value}
onChange={onChange} onChange={onChange}
label={label} label={label}
......
...@@ -30,7 +30,7 @@ function MonthCalendar() { ...@@ -30,7 +30,7 @@ function MonthCalendar() {
const cells = arr.length const cells = arr.length
const xs = 10.8/cells const xs = 10.8/cells
setCellSizes(()=>{ setCellSizes(()=>{
return {smallCell: 0.6, standarCell: xs} return {smallCell: 0.6, standarCell: xs, dayCell: 12/cells}
}) })
return arr return arr
} else { } else {
...@@ -38,7 +38,7 @@ function MonthCalendar() { ...@@ -38,7 +38,7 @@ function MonthCalendar() {
const cells = arr.length const cells = arr.length
const xs = 10.8/cells const xs = 10.8/cells
setCellSizes(()=>{ setCellSizes(()=>{
return {smallCell: 0.6, standarCell: xs} return {smallCell: 0.6, standarCell: xs, dayCell: 12/cells}
}) })
return arr return arr
} }
......
...@@ -69,7 +69,7 @@ const addTaskFailure = (error) => { ...@@ -69,7 +69,7 @@ const addTaskFailure = (error) => {
export const addTask = (task) => { export const addTask = (task) => {
return async (dispatch, getState) => { return async (dispatch, getState) => {
dispatch(addTaskRequest()); dispatch(addTaskRequest());
const token = getState().users?.user?.token; // const token = getState().users?.user?.token;
try { try {
await axios.post("/tasks", task); await axios.post("/tasks", task);
dispatch(addTaskSuccess()) dispatch(addTaskSuccess())
......
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