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

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

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