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
7843e98f
Commit
7843e98f
authored
Dec 12, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#100
Разделил логику более в правильном виде, чуть поправил красоту кода
parent
d4298065
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
102 deletions
+103
-102
CalendarRowDayWeek.js
...WeekCalendarBody/CalendarRowDayWeek/CalendarRowDayWeek.js
+10
-18
Helpers.js
...t/src/components/WeekCalendar/WeekCalendarBody/Helpers.js
+1
-1
WeekCalendarBody.js
...ponents/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
+40
-31
WeekCalendarHeader.js
...nts/WeekCalendar/WeekCalendarHeader/WeekCalendarHeader.js
+16
-16
WeekCalendarHeaderInfo.js
...arHeader/WeekCalendarHeaderInfo/WeekCalendarHeaderInfo.js
+23
-23
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+13
-13
No files found.
planner-front/src/components/WeekCalendar/WeekCalendarBody/CalendarRowDayWeek/CalendarRowDayWeek.js
View file @
7843e98f
...
@@ -2,24 +2,16 @@ import { Grid } from "@mui/material";
...
@@ -2,24 +2,16 @@ import { Grid } from "@mui/material";
import
CalendarRow
from
"../../../MonthCalendar/MonthCalendarBody/CalendarRow/CalendarRow"
;
import
CalendarRow
from
"../../../MonthCalendar/MonthCalendarBody/CalendarRow/CalendarRow"
;
import
CalendarStandartCell
from
"../../../MonthCalendar/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell"
;
import
CalendarStandartCell
from
"../../../MonthCalendar/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell"
;
function
CalendarRowDayWeek
({
week
,
hoursInDay
})
{
function
CalendarRowDayWeek
({
week
,
hoursInDay
})
{
return
(
<>
return
(
<>
<
Grid
item
xs
=
{
11.005
}
>
{
hoursInDay
?.
map
((
hour
,
i
)
=>
{
<
CalendarRow
week
=
{
true
}
>
{
week
?.
map
((
weekDay
,
i
)
=>
{
return
(
<
Grid
item
key
=
{
i
}
xs
=
{
12
/
week
.
length
}
>
{
hoursInDay
?.
map
((
hour
,
i
)
=>
{
return
(
return
(
<
CalendarStandartCell
key
=
{
i
}
week
=
{
true
}
>
<
CalendarStandartCell
key
=
{
i
}
week
=
{
true
}
>
<
/CalendarStandartCell>
)
<
/CalendarStandartCell>
)
})}
})}
<
/Grid>
)
})}
<
/>
)
;
<
/CalendarRow
>
<
/Grid
>
<
/>
)
;
}
}
export
default
CalendarRowDayWeek
;
export
default
CalendarRowDayWeek
;
\ No newline at end of file
planner-front/src/components/WeekCalendar/WeekCalendarBody/Helpers.js
View file @
7843e98f
export
const
getCurrentWeekDayString
=
(
dayNumber
)
=>
{
export
const
getCurrentWeekDayString
=
(
dayNumber
)
=>
{
if
(
dayNumber
<=
6
&&
dayNumber
>=
0
)
{
if
(
dayNumber
<=
6
&&
dayNumber
>=
0
)
{
return
[
"ПН"
,
"ВТ"
,
"СР"
,
"ЧТ"
,
"ПТ"
,
"СБ"
,
"ВС"
][
dayNumber
];
return
[
"ПН"
,
"ВТ"
,
"СР"
,
"ЧТ"
,
"ПТ"
,
"СБ"
,
"ВС"
][
dayNumber
];
}
else
{
}
else
{
return
null
return
null
}
}
...
...
planner-front/src/components/WeekCalendar/WeekCalendarBody/WeekCalendarBody.js
View file @
7843e98f
...
@@ -6,26 +6,26 @@ import CalendarStandartCell from "../../MonthCalendar/MonthCalendarBody/Calendar
...
@@ -6,26 +6,26 @@ import CalendarStandartCell from "../../MonthCalendar/MonthCalendarBody/Calendar
import
CalendarRowDayWeek
from
"./CalendarRowDayWeek/CalendarRowDayWeek"
;
import
CalendarRowDayWeek
from
"./CalendarRowDayWeek/CalendarRowDayWeek"
;
import
{
getCurrentWeekDayString
}
from
"./Helpers"
;
import
{
getCurrentWeekDayString
}
from
"./Helpers"
;
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
})
{
function
WeekCalendarBody
({
week
,
hoursInDay
,
hourFormat
,
setHourFormat
,
})
{
return
(
return
(
<>
<>
<
Box
style
=
{{
marginBottom
:
'30px'
}}
>
<
Box
style
=
{{
marginBottom
:
'30px'
}}
>
<
Box
style
=
{{
position
:
'sticky'
,
top
:
'0px'
,
zIndex
:
'10'
,
backgroundColor
:
'lightgrey'
}}
>
<
Box
style
=
{{
position
:
'sticky'
,
top
:
'0px'
,
zIndex
:
'10'
,
backgroundColor
:
'lightgrey'
}}
>
<
CalendarRow
<
CalendarRow
>
>
<
CalendarSmallCell
xs
=
{
1
}
>
<
CalendarSmallCell
xs
=
{
1
}
>
<
FormControlLabel
<
FormControlLabel
control
=
{
<
Switch
color
=
"primary"
checked
=
{
hourFormat
}
onChange
=
{()
=>
{
setHourFormat
(()
=>!
hourFormat
)}}
/>
}
control
=
{
<
Switch
color
=
"primary"
checked
=
{
hourFormat
}
onChange
=
{()
=>
{
setHourFormat
(()
=>
!
hourFormat
)
}}
/>
}
label
=
"1 час"
label
=
"1 час"
labelPlacement
=
"end"
labelPlacement
=
"end"
/>
/>
<
/CalendarSmallCell
>
<
/CalendarSmallCell
>
{
week
?.
map
((
weekDay
,
i
)
=>
{
{
week
?.
map
((
weekDay
,
i
)
=>
{
return
(
return
(
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
11
/
week
.
length
}
>
<
CalendarStandartCell
key
=
{
i
}
xs
=
{
11
/
week
.
length
}
>
<
span
style
=
{{
display
:
'block'
,
fontWeight
:
"600"
}}
>
{
weekDay
}
<
/span
>
<
span
style
=
{{
display
:
'block'
,
fontWeight
:
"600"
}}
>
{
weekDay
}
<
/span
>
<
span
style
=
{{
marginBottom
:
'10px'
}}
>
{
getCurrentWeekDayString
(
i
)}
<
/span
>
<
span
style
=
{{
marginBottom
:
'10px'
}}
>
{
getCurrentWeekDayString
(
i
)}
<
/span
>
<
/CalendarStandartCell
>
<
/CalendarStandartCell
>
)
)
})}
})}
...
@@ -35,7 +35,7 @@ function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat,}) {
...
@@ -35,7 +35,7 @@ function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat,}) {
<
Grid
container
>
<
Grid
container
>
<
CalendarRow
week
=
{
true
}
>
<
CalendarRow
week
=
{
true
}
>
<
Grid
item
xs
=
{
0.995
}
flexDirection
=
'column'
>
<
Grid
item
xs
=
{
0.995
}
flexDirection
=
'column'
>
{
hoursInDay
?.
map
((
hour
,
i
)
=>
{
{
hoursInDay
?.
map
((
hour
,
i
)
=>
{
return
(
return
(
<
CalendarSmallCell
key
=
{
i
}
week
=
{
true
}
>
<
CalendarSmallCell
key
=
{
i
}
week
=
{
true
}
>
{
hour
}
{
hour
}
...
@@ -43,10 +43,19 @@ function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat,}) {
...
@@ -43,10 +43,19 @@ function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat,}) {
})}
})}
<
/Grid
>
<
/Grid
>
<
Grid
item
xs
=
{
11.005
}
>
<
CalendarRow
week
=
{
true
}
>
{
week
?.
map
((
weekDay
,
i
)
=>
{
return
(
<
Grid
item
key
=
{
i
}
xs
=
{
12
/
week
.
length
}
>
<
CalendarRowDayWeek
<
CalendarRowDayWeek
week
=
{
week
}
hoursInDay
=
{
hoursInDay
}
hoursInDay
=
{
hoursInDay
}
/
>
/
>
<
/Grid
>
)
})}
<
/CalendarRow
>
<
/Grid
>
<
/CalendarRow
>
<
/CalendarRow
>
<
/Grid
>
<
/Grid
>
...
...
planner-front/src/components/WeekCalendar/WeekCalendarHeader/WeekCalendarHeader.js
View file @
7843e98f
import
{
AppBar
,
Toolbar
}
from
'@mui/material'
;
import
{
AppBar
,
Toolbar
}
from
'@mui/material'
;
import
{
Box
}
from
'@mui/system'
;
import
{
Box
}
from
'@mui/system'
;
import
WeekCalendarHeaderInfo
from
'./WeekCalendarHeaderInfo/WeekCalendarHeaderInfo'
;
import
WeekCalendarHeaderInfo
from
'./WeekCalendarHeaderInfo/WeekCalendarHeaderInfo'
;
function
WeekCalendarHeader
({
decrementWeek
,
incrementWeek
,
weekInfo
})
{
function
WeekCalendarHeader
({
decrementWeek
,
incrementWeek
,
weekInfo
})
{
return
(
return
(
<>
<>
...
...
planner-front/src/components/WeekCalendar/WeekCalendarHeader/WeekCalendarHeaderInfo/WeekCalendarHeaderInfo.js
View file @
7843e98f
import
ArrowDecrementButton
from
'../../../UI/ArrowDecrementButton/ArrowDecrementButton'
;
import
ArrowDecrementButton
from
'../../../UI/ArrowDecrementButton/ArrowDecrementButton'
;
import
ArrowIncrementButton
from
'../../../UI/ArrowIncrementButton/ArrowIncrementButton'
;
import
ArrowIncrementButton
from
'../../../UI/ArrowIncrementButton/ArrowIncrementButton'
;
import
{
Box
}
from
'@mui/system'
;
import
{
Box
}
from
'@mui/system'
;
import
{
Typography
}
from
'@mui/material'
;
import
{
Typography
}
from
'@mui/material'
;
function
WeekCalendarHeaderInfo
({
decrementWeek
,
incrementWeek
,
weekInfo
})
{
function
WeekCalendarHeaderInfo
({
decrementWeek
,
incrementWeek
,
weekInfo
})
{
return
(
return
(
<>
<>
<
Box
sx
=
{{
width
:
'40%'
,
marginBottom
:
'15px'
}}
>
<
Box
sx
=
{{
width
:
'40%'
,
marginBottom
:
'15px'
}}
>
<
h2
>
Цель
недели
:
Наладить
режим
сна
<
/h2
>
<
h2
>
Цель
недели
:
Наладить
режим
сна
<
/h2
>
<
Box
sx
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
Box
sx
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
ArrowDecrementButton
<
ArrowDecrementButton
onClick
=
{()
=>
{
decrementWeek
()
}}
onClick
=
{()
=>
{
decrementWeek
()
}}
/
>
/
>
<
Typography
<
Typography
variant
=
"h6"
variant
=
"h6"
...
@@ -26,7 +26,7 @@ function WeekCalendarHeaderInfo({decrementWeek, incrementWeek, weekInfo}) {
...
@@ -26,7 +26,7 @@ function WeekCalendarHeaderInfo({decrementWeek, incrementWeek, weekInfo}) {
{
weekInfo
}
{
weekInfo
}
<
/Typography
>
<
/Typography
>
<
ArrowIncrementButton
<
ArrowIncrementButton
onClick
=
{()
=>
{
incrementWeek
()
}}
onClick
=
{()
=>
{
incrementWeek
()
}}
/
>
/
>
<
/Box
>
<
/Box
>
<
/Box
>
<
/Box
>
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
7843e98f
...
@@ -7,45 +7,45 @@ import { getWeekInfoString, getWeekFromCurrentDate } from '../../helpers/Calenda
...
@@ -7,45 +7,45 @@ import { getWeekInfoString, getWeekFromCurrentDate } from '../../helpers/Calenda
function
WeekCalendar
()
{
function
WeekCalendar
()
{
const
[
date
,
setDate
]
=
useState
({
year
:
''
,
month
:
''
,
currentDay
:
''
})
const
[
date
,
setDate
]
=
useState
({
year
:
''
,
month
:
''
,
currentDay
:
''
})
const
[
hourFormat
,
setHourFormat
]
=
useState
(
false
);
const
[
hourFormat
,
setHourFormat
]
=
useState
(
false
);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
year
=
new
Date
().
getFullYear
()
const
year
=
new
Date
().
getFullYear
()
const
month
=
new
Date
().
getMonth
()
const
month
=
new
Date
().
getMonth
()
const
currentDay
=
moment
().
date
()
const
currentDay
=
moment
().
date
()
setDate
({
year
:
year
,
month
:
month
,
currentDay
:
currentDay
})
setDate
({
year
:
year
,
month
:
month
,
currentDay
:
currentDay
})
},
[])
},
[])
const
hoursInDay
=
useMemo
(()
=>
{
const
hoursInDay
=
useMemo
(()
=>
{
let
arr
let
arr
if
(
hourFormat
)
{
if
(
hourFormat
)
{
arr
=
[
'8:00'
,
'9:00'
,
'10:00'
,
'11:00'
,
'12:00'
,
'13:00'
,
'14:00'
,
'15:00'
,
'16:00'
,
'17:00'
,
'18:00'
,
'19:00'
,
'20:00'
,
'21:00'
,
'22:00'
]
arr
=
[
'8:00'
,
'9:00'
,
'10:00'
,
'11:00'
,
'12:00'
,
'13:00'
,
'14:00'
,
'15:00'
,
'16:00'
,
'17:00'
,
'18:00'
,
'19:00'
,
'20:00'
,
'21:00'
,
'22:00'
]
}
else
{
}
else
{
arr
=
[
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
]
arr
=
[
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
]
}
}
return
arr
return
arr
},
[
hourFormat
])
},
[
hourFormat
])
const
week
=
useMemo
(()
=>
{
const
week
=
useMemo
(()
=>
{
return
getWeekFromCurrentDate
(
date
.
year
,
date
.
month
,
date
.
currentDay
)
return
getWeekFromCurrentDate
(
date
.
year
,
date
.
month
,
date
.
currentDay
)
},
[
date
])
},
[
date
])
const
incrementWeek
=
useCallback
(()
=>
{
const
incrementWeek
=
useCallback
(()
=>
{
setDate
((
prevState
)
=>
{
setDate
((
prevState
)
=>
{
const
newDate
=
new
Date
(
prevState
.
year
,
prevState
.
month
,
prevState
.
currentDay
+
7
)
const
newDate
=
new
Date
(
prevState
.
year
,
prevState
.
month
,
prevState
.
currentDay
+
7
)
return
{
year
:
newDate
.
getFullYear
(),
month
:
newDate
.
getMonth
(),
currentDay
:
moment
(
newDate
).
date
()
}
return
{
year
:
newDate
.
getFullYear
(),
month
:
newDate
.
getMonth
(),
currentDay
:
moment
(
newDate
).
date
()
}
})
})
},
[])
},
[])
const
decrementWeek
=
useCallback
(()
=>
{
const
decrementWeek
=
useCallback
(()
=>
{
setDate
((
prevState
)
=>
{
setDate
((
prevState
)
=>
{
const
newDate
=
new
Date
(
prevState
.
year
,
prevState
.
month
,
prevState
.
currentDay
-
7
)
const
newDate
=
new
Date
(
prevState
.
year
,
prevState
.
month
,
prevState
.
currentDay
-
7
)
return
{
year
:
newDate
.
getFullYear
(),
month
:
newDate
.
getMonth
(),
currentDay
:
moment
(
newDate
).
date
()
}
return
{
year
:
newDate
.
getFullYear
(),
month
:
newDate
.
getMonth
(),
currentDay
:
moment
(
newDate
).
date
()
}
})
})
},
[])
},
[])
const
weekInfo
=
useMemo
(()
=>
{
const
weekInfo
=
useMemo
(()
=>
{
return
getWeekInfoString
(
week
,
date
)
return
getWeekInfoString
(
week
,
date
)
},
[
date
,
week
])
},
[
date
,
week
])
...
...
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