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
e23db0d3
Commit
e23db0d3
authored
Nov 12, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#35
Оптимизировал хедер
parent
f89b7a3f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
122 deletions
+201
-122
MonthAndYearInfo.js
.../MonthCalendarHeader/MonthAndYearInfo/MonthAndYearInfo.js
+40
-0
MonthDecrementButton.js
...hAndYearInfo/MonthDecrementButton/MonthDecrementButton.js
+27
-0
MonthIncrementButton.js
...hAndYearInfo/MonthIncrementButton/MonthIncrementButton.js
+27
-0
MonthCalendarHeader.js
...src/components/MonthCalendarHeader/MonthCalendarHeader.js
+27
-77
СustomSelect.js
planner-front/src/components/UI/СustomSelect/СustomSelect.js
+36
-0
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+44
-45
No files found.
planner-front/src/components/MonthCalendarHeader/MonthAndYearInfo/MonthAndYearInfo.js
0 → 100644
View file @
e23db0d3
import
{
Box
,
Typography
}
from
'@mui/material'
;
import
{
memo
}
from
'react'
;
import
MonthDecrementButton
from
'./MonthDecrementButton/MonthDecrementButton'
;
import
MonthIncrementButton
from
'./MonthIncrementButton/MonthIncrementButton'
;
function
MonthAndYearInfo
({
getCurrentMonthString
,
year
,
incrementMonth
,
decrementMonth
})
{
return
(
<>
<
Box
sx
=
{{
flexGrow
:
1
,
display
:
'flex'
,
alignItems
:
'center'
,
gap
:
'10px'
}}
>
<
MonthDecrementButton
decrementMonth
=
{
decrementMonth
}
/
>
<
Box
sx
=
{{
flexBasis
:
'150px'
}}
>
<
Typography
variant
=
"h6"
sx
=
{{
display
:
'flex'
,
justifyContent
:
'center'
,
}}
>
{
getCurrentMonthString
}
<
/Typography
>
<
Typography
align
=
'center'
>
{
year
}
<
/Typography
>
<
/Box
>
<
MonthIncrementButton
incrementMonth
=
{
incrementMonth
}
/>
<
/Box
>
<
/>
)
;
}
export
default
memo
(
MonthAndYearInfo
);
\ No newline at end of file
planner-front/src/components/MonthCalendarHeader/MonthAndYearInfo/MonthDecrementButton/MonthDecrementButton.js
0 → 100644
View file @
e23db0d3
import
ArrowBackIcon
from
'@mui/icons-material/ArrowBack'
;
import
{
memo
}
from
'react'
;
const
arrowClass
=
{
borderRadius
:
'50%'
,
cursor
:
'pointer'
,
transition
:
'0.5s'
,
"&:hover"
:
{
background
:
'rgb(48, 154, 252, 0.65)'
,
transition
:
'0.5s'
,
transform
:
'scale(1.2)'
}
}
function
MonthDecrementButton
({
decrementMonth
})
{
return
(
<>
<
ArrowBackIcon
sx
=
{
arrowClass
}
onClick
=
{
decrementMonth
}
/>
<
/>
)
;
}
export
default
memo
(
MonthDecrementButton
);
\ No newline at end of file
planner-front/src/components/MonthCalendarHeader/MonthAndYearInfo/MonthIncrementButton/MonthIncrementButton.js
0 → 100644
View file @
e23db0d3
import
ArrowForwardIcon
from
'@mui/icons-material/ArrowForward'
;
import
{
memo
}
from
'react'
;
const
arrowClass
=
{
borderRadius
:
'50%'
,
cursor
:
'pointer'
,
transition
:
'0.5s'
,
"&:hover"
:
{
background
:
'rgb(48, 154, 252, 0.65)'
,
transition
:
'0.5s'
,
transform
:
'scale(1.2)'
}
}
function
MonthIncrementButton
({
incrementMonth
})
{
return
(
<>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{
incrementMonth
}
/>
<
/>
)
;
}
export
default
memo
(
MonthIncrementButton
);
\ No newline at end of file
planner-front/src/components/MonthCalendarHeader/MonthCalendarHeader.js
View file @
e23db0d3
import
{
AppBar
,
FormControl
,
InputLabel
,
MenuItem
,
Select
,
Toolbar
,
Typography
}
from
'@mui/material'
;
import
{
AppBar
,
Toolbar
}
from
'@mui/material'
;
import
ArrowBackIcon
from
'@mui/icons-material/ArrowBack'
;
import
ArrowForwardIcon
from
'@mui/icons-material/ArrowForward'
;
import
{
Box
}
from
'@mui/system'
;
import
{
Box
}
from
'@mui/system'
;
import
MonthAndYearInfo
from
'./MonthAndYearInfo/MonthAndYearInfo'
;
import
С
ustomSelect
from
'../UI/СustomSelect/СustomSelect'
const
arrowClass
=
{
const
workers
=
[{
value
:
''
,
text
:
'--выберите сотрудника'
},
{
value
:
'Василий'
,
text
:
'Василий'
},
{
value
:
'Никита'
,
text
:
'Никита'
}]
borderRadius
:
'50%'
,
const
types
=
[{
value
:
'Месяц'
,
text
:
'Месяц'
},
{
value
:
'Неделя'
,
text
:
'Неделя'
}]
cursor
:
'pointer'
,
transition
:
'0.5s'
,
"&:hover"
:
{
background
:
'rgb(48, 154, 252, 0.65)'
,
transition
:
'0.5s'
,
transform
:
'scale(1.2)'
}
}
function
MonthCalendarHeader
({
month
,
getCurrentMonthString
,
decrementMonth
,
incrementMonth
,
calendarType
,
onChangeWorkerHandler
,
onChangeCalendarTypeHandler
,
worker
,
year
})
{
function
MonthCalendarHeader
({
getCurrentMonthString
,
decrementMonth
,
incrementMonth
,
calendarType
,
onChangeWorkerHandler
,
onChangeCalendarTypeHandler
,
worker
,
year
})
{
return
(
return
(
<>
<>
<
Box
sx
=
{{
flexGrow
:
1
}}
>
<
Box
sx
=
{{
flexGrow
:
1
}}
>
<
AppBar
position
=
"static"
>
<
AppBar
position
=
"static"
>
<
Toolbar
>
<
Toolbar
>
<
Box
sx
=
{{
<
MonthAndYearInfo
flexGrow
:
1
,
getCurrentMonthString
=
{
getCurrentMonthString
}
display
:
'flex'
,
decrementMonth
=
{
decrementMonth
}
alignItems
:
'center'
,
incrementMonth
=
{
incrementMonth
}
gap
:
'10px'
year
=
{
year
}
}}
/
>
>
<
С
ustomSelect
<
ArrowBackIcon
value
=
{
worker
}
onClick
=
{()
=>
{
decrementMonth
()}}
onChange
=
{(
e
)
=>
{
onChangeWorkerHandler
(
e
)}}
sx
=
{
arrowClass
}
label
=
{
'Сотрудник'
}
/
>
id
=
{
'worker'
}
<
Box
sx
=
{{
flexBasis
:
'150px'
}}
>
items
=
{
workers
}
<
Typography
/
>
variant
=
"h6"
sx
=
{{
display
:
'flex'
,
justifyContent
:
'center'
,
}}
>
{
getCurrentMonthString
(
month
)}
<
/Typography
>
<
Typography
align
=
'center'
>
{
year
}
<
/Typography
>
<
/Box
>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{()
=>
{
incrementMonth
()}}
/>
<
/Box
>
<
FormControl
variant
=
"standard"
sx
=
{{
m
:
1
,
minWidth
:
120
}}
>
<
InputLabel
id
=
"worker-select-label"
>
Сотрудник
<
/InputLabel
>
<
Select
labelId
=
"worker-select-label"
id
=
"worker-select"
value
=
{
worker
}
onChange
=
{(
e
)
=>
{
onChangeWorkerHandler
(
e
)}}
label
=
"Worker"
>
<
MenuItem
value
=
""
>
<
em
>--
Выберите
сотрудника
--<
/em
>
<
/MenuItem
>
<
MenuItem
value
=
{
"Василий"
}
>
Василий
<
/MenuItem
>
<
MenuItem
value
=
{
"Никита"
}
>
Никита
<
/MenuItem
>
<
MenuItem
value
=
{
"Артем"
}
>
Артем
<
/MenuItem
>
<
/Select
>
<
/FormControl
>
<
FormControl
variant
=
"standard"
sx
=
{{
m
:
1
,
minWidth
:
120
}}
>
<
InputLabel
id
=
"calendar-type-label"
>
Календарь
<
/InputLabel
>
<
Select
labelId
=
"calendar-type-label"
id
=
"calendar-type"
value
=
{
calendarType
}
onChange
=
{(
e
)
=>
{
onChangeCalendarTypeHandler
(
e
)}}
label
=
"Type"
>
<
MenuItem
value
=
{
"Месяц"
}
>
Месяц
<
/MenuItem
>
<
MenuItem
value
=
{
"Неделя"
}
>
Неделя
<
/MenuItem
>
<
/Select
>
<
/FormControl
>
<
С
ustomSelect
value
=
{
calendarType
}
onChange
=
{(
e
)
=>
{
onChangeCalendarTypeHandler
(
e
)}}
label
=
{
'Календарь'
}
id
=
{
'calendar-type'
}
items
=
{
types
}
/
>
<
/Toolbar
>
<
/Toolbar
>
<
/AppBar
>
<
/AppBar
>
<
/Box
>
<
/Box
>
...
...
planner-front/src/components/UI/СustomSelect/СustomSelect.js
0 → 100644
View file @
e23db0d3
import
{
FormControl
,
InputLabel
,
MenuItem
,
Select
}
from
'@mui/material'
;
import
{
memo
}
from
'react'
;
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
>
<
Select
labelId
=
{
id
+
'-select'
+
'-label'
}
id
=
{
id
+
'-select'
}
value
=
{
value
}
onChange
=
{
onChange
}
label
=
{
label
}
>
{
items
.
map
((
item
,
i
)
=>
{
return
(
<
MenuItem
key
=
{
i
}
value
=
{
item
?.
value
}
>
{
item
?.
text
}
<
/MenuItem
>
)
})}
<
/Select
>
<
/FormControl
>
<
/>
)
;
}
export
default
memo
(
С
ustomSelect
,
(
prevProps
,
nextProps
)
=>
{
if
(
prevProps
.
value
!==
nextProps
.
value
)
{
return
false
}
else
{
return
true
}
});
\ No newline at end of file
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
e23db0d3
import
{
useEffect
,
use
State
}
from
'react'
;
import
{
useEffect
,
use
Callback
,
useState
,
useMemo
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
{
addTask
,
deleteTask
,
editTask
,
fetchCalendarTasks
}
from
'../../store/actions/tasksActions'
;
import
{
addTask
,
deleteTask
,
editTask
,
fetchCalendarTasks
}
from
'../../store/actions/tasksActions'
;
function
dateToISOLikeButLocal
(
date
)
{
const
offsetMs
=
date
.
getTimezoneOffset
()
*
60
*
1000
;
const
msLocal
=
date
.
getTime
()
-
offsetMs
;
const
dateLocal
=
new
Date
(
msLocal
);
const
iso
=
dateLocal
.
toISOString
();
return
iso
;
}
function
MonthCalendar
()
{
function
MonthCalendar
()
{
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
{
calendarTasks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
{
calendarTasks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
[
hourFormat
,
setHourFormat
]
=
useState
(
false
);
const
[
hourFormat
,
setHourFormat
]
=
useState
(
false
);
const
[
month
,
setMonth
]
=
useState
(
''
)
const
[
dateNow
,
setDateNow
]
=
useState
({
month
:
''
,
year
:
''
})
const
[
year
,
setYear
]
=
useState
(
''
)
const
[
worker
,
setWorker
]
=
useState
(
''
);
const
[
worker
,
setWorker
]
=
useState
(
''
);
const
[
calendarType
,
setCalendarType
]
=
useState
(
'Месяц'
);
const
[
calendarType
,
setCalendarType
]
=
useState
(
'Месяц'
);
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
dateTimeStart
:
''
,
dateTimeDue
:
''
})
const
[
currentTask
,
setCurrentTask
]
=
useState
({})
useEffect
(()
=>
{
useEffect
(()
=>
{
setMonth
(
new
Date
().
getMonth
())
setDateNow
({
setYear
(
new
Date
().
getFullYear
())
month
:
new
Date
().
getMonth
(),
year
:
new
Date
().
getFullYear
(),
})
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
())
},
[
dispatch
])
},
[
dispatch
])
const
onChangeWorkerHandler
=
(
event
)
=>
{
const
onChangeWorkerHandler
=
useCallback
(
(
event
)
=>
{
setWorker
(
event
.
target
.
value
);
setWorker
(
event
.
target
.
value
);
};
}
,
[])
;
const
onChangeCalendarTypeHandler
=
(
event
)
=>
{
const
onChangeCalendarTypeHandler
=
useCallback
(
(
event
)
=>
{
setCalendarType
(
event
.
target
.
value
);
setCalendarType
(
event
.
target
.
value
);
};
}
,
[])
;
const
getCurrentMonthString
=
(
month
)
=>
{
const
getCurrentMonthString
=
useMemo
((
)
=>
{
return
[
"Январь"
,
"Февраль"
,
"Март"
,
"Апрель"
,
"Май"
,
"Июнь"
,
"Июль"
,
"Август"
,
"Сентябрь"
,
"Октябрь"
,
"Ноябрь"
,
"Декабрь"
][
month
];
return
[
"Январь"
,
"Февраль"
,
"Март"
,
"Апрель"
,
"Май"
,
"Июнь"
,
"Июль"
,
"Август"
,
"Сентябрь"
,
"Октябрь"
,
"Ноябрь"
,
"Декабрь"
][
dateNow
.
month
];
}
}
,
[
dateNow
.
month
])
const
incrementMonth
=
()
=>
{
const
incrementMonth
=
useCallback
(()
=>
{
setMonth
((
prevState
)
=>
{
setDateNow
((
prevState
)
=>
{
if
(
prevState
+
1
===
12
)
{
if
(
prevState
.
month
+
1
===
12
)
{
setYear
(
prevState
=>
prevState
+
1
)
return
{
month
:
0
,
year
:
prevState
.
year
+
1
}
return
0
}
}
return
prevState
+
1
return
{...
prevState
,
month
:
prevState
.
month
+
1
}
})
})
}
}
,
[])
const
decrementMonth
=
()
=>
{
const
decrementMonth
=
useCallback
(()
=>
{
setMonth
((
prevState
)
=>
{
setDateNow
((
prevState
)
=>
{
if
(
prevState
-
1
===
-
1
)
{
if
(
prevState
.
month
-
1
===
-
1
)
{
setYear
(
prevState
=>
prevState
-
1
)
return
{
month
:
11
,
year
:
prevState
.
year
-
1
}
return
11
}
}
return
prevState
-
1
return
{...
prevState
,
month
:
prevState
.
month
-
1
}
})
})
}
}
,
[])
function
dateToISOLikeButLocal
(
date
)
{
const
onChangeCurrentTaskHandler
=
useCallback
((
e
)
=>
{
const
offsetMs
=
date
.
getTimezoneOffset
()
*
60
*
1000
;
const
msLocal
=
date
.
getTime
()
-
offsetMs
;
const
dateLocal
=
new
Date
(
msLocal
);
const
iso
=
dateLocal
.
toISOString
();
return
iso
;
}
const
onChangeCurrentTaskHandler
=
(
e
)
=>
{
const
{
name
,
value
}
=
e
.
target
;
const
{
name
,
value
}
=
e
.
target
;
setCurrentTask
((
prevState
)
=>
{
setCurrentTask
((
prevState
)
=>
{
return
{
return
{
...
@@ -68,9 +68,9 @@ function MonthCalendar() {
...
@@ -68,9 +68,9 @@ function MonthCalendar() {
[
name
]:
value
[
name
]:
value
}
}
});
});
};
}
,
[])
;
const
createTaskInCellHandler
=
(
dayNumber
,
dayHour
)
=>
{
const
createTaskInCellHandler
=
useCallback
(
(
dayNumber
,
dayHour
)
=>
{
const
hour
=
parseInt
(
dayHour
.
split
(
':'
)[
0
])
const
hour
=
parseInt
(
dayHour
.
split
(
':'
)[
0
])
let
hourDue
let
hourDue
if
(
hourFormat
)
{
if
(
hourFormat
)
{
...
@@ -82,11 +82,11 @@ function MonthCalendar() {
...
@@ -82,11 +82,11 @@ function MonthCalendar() {
title
:
"Задача"
,
title
:
"Задача"
,
description
:
"описание"
,
description
:
"описание"
,
priority
:
null
,
priority
:
null
,
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hour
,
0
)),
dateTimeStart
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
year
,
month
,
dayNumber
,
hourDue
,
59
)),
dateTimeDue
:
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hourDue
,
59
)),
}
}
setCurrentTask
((
newTask
))
setCurrentTask
((
newTask
))
}
}
,
[])
const
sendNewTaskHandler
=
async
()
=>
{
const
sendNewTaskHandler
=
async
()
=>
{
...
@@ -116,8 +116,7 @@ function MonthCalendar() {
...
@@ -116,8 +116,7 @@ function MonthCalendar() {
return
(
return
(
<>
<>
<
MonthCalendarHeader
<
MonthCalendarHeader
month
=
{
month
}
year
=
{
dateNow
.
year
}
year
=
{
year
}
getCurrentMonthString
=
{
getCurrentMonthString
}
getCurrentMonthString
=
{
getCurrentMonthString
}
decrementMonth
=
{
decrementMonth
}
decrementMonth
=
{
decrementMonth
}
incrementMonth
=
{
incrementMonth
}
incrementMonth
=
{
incrementMonth
}
...
@@ -127,8 +126,8 @@ function MonthCalendar() {
...
@@ -127,8 +126,8 @@ function MonthCalendar() {
calendarType
=
{
calendarType
}
calendarType
=
{
calendarType
}
/
>
/
>
<
MonthCalendarBody
<
MonthCalendarBody
month
=
{
month
}
month
=
{
dateNow
.
month
}
year
=
{
year
}
year
=
{
dateNow
.
year
}
tasks
=
{
calendarTasks
}
tasks
=
{
calendarTasks
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
setCurrentTask
=
{
setCurrentTask
}
setCurrentTask
=
{
setCurrentTask
}
...
...
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