Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
72e00819
Commit
72e00819
authored
Nov 16, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#38
Убрал предупреждния, чуть оптимизировал
parent
2a92b77a
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
39 deletions
+25
-39
App.js
planner-front/src/App.js
+1
-0
CalendarRow.js
...c/components/MonthCalendarBody/CalendarRow/CalendarRow.js
+0
-1
CalendarRowDay.js
...onents/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
+10
-10
CalendarStandartCell.js
...endarBody/CalendarStandartCell.js/CalendarStandartCell.js
+1
-1
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+5
-17
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+2
-4
СustomSelect.js
planner-front/src/components/UI/СustomSelect/СustomSelect.js
+3
-3
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+2
-2
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+1
-1
No files found.
planner-front/src/App.js
View file @
72e00819
...
...
@@ -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
>
...
...
planner-front/src/components/MonthCalendarBody/CalendarRow/CalendarRow.js
View file @
72e00819
import
{
Grid
}
from
"@mui/material"
;
import
{
memo
}
from
"react"
;
const
CalendarRow
=
({
children
})
=>
{
return
<>
...
...
planner-front/src/components/MonthCalendarBody/CalendarRowDay/CalendarRowDay.js
View file @
72e00819
...
...
@@ -7,20 +7,20 @@ const CalendarRowDay = ({xs, hoursInDay, createTaskInCellHandler, currentTask, h
const
hours
=
useMemo
(()
=>
{
return
hoursInDay
.
map
((
hour
)
=>
parseInt
(
hour
.
split
(
':'
)[
0
]))},
[
hour
Format
])
[
hour
sInDay
])
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
,
hour
s
])
},
[
availableTasks
.
length
,
hourFormat
,
hours
,
hoursInDay
,
sortedTask
s
])
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
}
...
...
planner-front/src/components/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell.js
View file @
72e00819
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
})
=>
{
...
...
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
72e00819
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
)}}
/>
)
}
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
72e00819
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
.
standar
Cell
}
xs
=
{
cellSizes
.
day
Cell
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
hoursInDay
=
{
hoursInDay
}
currentTask
=
{
currentTask
}
...
...
planner-front/src/components/UI/СustomSelect/СustomSelect.js
View file @
72e00819
...
...
@@ -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
}
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
72e00819
...
...
@@ -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
}
...
...
planner-front/src/store/actions/tasksActions.js
View file @
72e00819
...
...
@@ -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
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment