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
64d6dcee
Commit
64d6dcee
authored
Dec 04, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#85
Реализовал логику получение недели
parent
39724752
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
4 deletions
+57
-4
App.js
planner-front/src/App.js
+4
-3
CalendarStandartCell.js
...endarBody/CalendarStandartCell.js/CalendarStandartCell.js
+1
-1
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+29
-0
CalendarHelpers.js
planner-front/src/helpers/CalendarHelpers.js
+23
-0
No files found.
planner-front/src/App.js
View file @
64d6dcee
...
...
@@ -10,6 +10,7 @@ import ForgottenPassword from "./containers/ForgottenPassword/ForgottenPassword"
import
Projects
from
"./containers/Projects/Projects"
;
import
FullProject
from
"./containers/FullProject/FullProject"
;
import
NewProject
from
"./containers/NewProject/NewProject"
;
import
WeekCalendar
from
"./containers/WeekCalendar/WeekCalendar"
;
const
ProtectedRoute
=
({
isAllowed
,
roles
,
redirectUrl
,
children
})
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
...
...
@@ -56,7 +57,7 @@ const App = () => {
isAllowed
=
{
user
}
redirectUrl
=
{
"/sign-in"
}
>
<
h1
>
week
page
<
/h1
>
<
WeekCalendar
/
>
<
/ProtectedRoute
>
}
/
>
...
...
@@ -65,7 +66,7 @@ const App = () => {
isAllowed
=
{
user
}
redirectUrl
=
{
"/sign-in"
}
>
<
h1
>
week
page
<
/h1
>
<
WeekCalendar
/
>
<
/ProtectedRoute
>
}
/
>
...
...
@@ -74,7 +75,7 @@ const App = () => {
isAllowed
=
{
user
}
redirectUrl
=
{
"/sign-in"
}
>
<
MonthCalendar
>
month
page
<
/MonthCalendar
>
<
MonthCalendar
><
/MonthCalendar
>
<
/ProtectedRoute
>
}
/
>
...
...
planner-front/src/components/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell.js
View file @
64d6dcee
...
...
@@ -8,7 +8,7 @@ const CalendarStandartCell = ({children, xs, hours, dayNumber, createTaskInCell
const
[
isThisCell
,
setIsThisCell
]
=
useState
(
false
)
const
cellClass
=
{
position
:
'relative'
,
height
:
linesInDay
?.
length
?
`
${
40
*
linesInDay
.
length
+
35
}
px`
:
`
${
35
}
px`
,
height
:
linesInDay
?.
length
?
`
${
40
*
linesInDay
.
length
+
35
}
px`
:
`
${
40
}
px`
,
borderRight
:
'1px solid black'
,
}
useEffect
(()
=>
{
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
0 → 100644
View file @
64d6dcee
import
moment
from
'moment'
;
import
{
useEffect
,
useState
,
useMemo
}
from
'react'
;
import
{
getWeekFromCurrentDate
}
from
'../../helpers/CalendarHelpers'
;
function
WeekCalendar
()
{
const
[
date
,
setDate
]
=
useState
({
year
:
''
,
month
:
''
,
currentDay
:
''
})
useEffect
(()
=>
{
const
year
=
new
Date
().
getFullYear
()
const
month
=
new
Date
().
getMonth
()
const
currentDay
=
moment
().
date
()
setDate
({
year
:
year
,
month
:
month
,
currentDay
:
currentDay
})
},
[])
const
week
=
useMemo
(()
=>
{
return
getWeekFromCurrentDate
(
date
.
year
,
date
.
month
,
date
.
currentDay
)
},
[
date
])
return
(
<>
{
'dasd'
}
<
/
>
);
}
export
default
WeekCalendar
;
\ No newline at end of file
planner-front/src/helpers/CalendarHelpers.js
View file @
64d6dcee
import
moment
from
"moment"
export
const
getDaysInMonth
=
(
dateNow
)
=>
{
if
(
dateNow
.
month
<=
11
&&
dateNow
.
month
>=
0
)
{
const
newDaysInMonth
=
[]
...
...
@@ -32,3 +34,24 @@ export const dateToISOLikeButLocal = (date) => {
return
null
}
}
export
const
getWeekFromCurrentDate
=
(
year
,
month
,
curDay
)
=>
{
const
week
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
]
const
currentDayWeek
=
moment
(
new
Date
(
year
,
month
,
curDay
)).
isoWeekday
()
for
(
let
i
=
1
;
i
<=
7
;
i
++
)
{
if
(
currentDayWeek
>
i
)
{
const
day
=
moment
(
new
Date
(
year
,
month
,
curDay
-
i
)).
date
()
const
dayWeek
=
moment
(
new
Date
(
year
,
month
,
curDay
-
i
)).
isoWeekday
()
week
[
dayWeek
-
1
]
=
day
}
else
if
(
currentDayWeek
===
i
)
{
const
day
=
moment
(
new
Date
(
year
,
month
,
curDay
)).
date
()
const
dayWeek
=
moment
(
new
Date
(
year
,
month
,
curDay
)).
isoWeekday
()
week
[
dayWeek
-
1
]
=
day
}
else
{
const
day
=
moment
(
new
Date
(
year
,
month
,
curDay
+
i
-
moment
(
new
Date
(
year
,
month
,
curDay
)).
isoWeekday
())).
date
()
const
dayWeek
=
i
-
moment
(
new
Date
(
year
,
month
,
curDay
)).
isoWeekday
()
+
moment
(
new
Date
(
year
,
month
,
curDay
)).
isoWeekday
()
week
[
dayWeek
-
1
]
=
day
}
}
return
week
}
\ No newline at end of file
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