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
6a7323c0
Commit
6a7323c0
authored
Nov 07, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#28
Продолжаю распределять логику
parent
5b582978
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
73 deletions
+42
-73
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+13
-32
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+20
-35
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+4
-4
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+5
-2
No files found.
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
6a7323c0
...
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
...
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
import
{
useDispatch
}
from
"react-redux"
;
import
{
useDispatch
}
from
"react-redux"
;
import
{
setNewTasksForCells
}
from
"../../store/actions/tasksActions"
;
import
{
setNewTasksForCells
}
from
"../../store/actions/tasksActions"
;
function
MonthCalendarBody
({
month
,
year
,
tasks
})
{
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
})
{
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
,
'6:00'
])
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
,
'6:00'
])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
...
@@ -16,7 +16,7 @@ function MonthCalendarBody({month, year, tasks}) {
...
@@ -16,7 +16,7 @@ function MonthCalendarBody({month, year, tasks}) {
return
new
Date
(
year
,
month
+
1
,
0
).
getDate
();
return
new
Date
(
year
,
month
+
1
,
0
).
getDate
();
}
}
const
getDayOfWeekString
=
(
day
)
=>
{
const
getDayOfWeekString
=
(
day
)
=>
{
return
[
"ВС"
,
"ПН"
,
"ВТ"
,
"СР"
,
"ЧТ"
,
"ПТ"
,
"СБ"
][
day
];
return
[
"ВС"
,
"ПН"
,
"ВТ"
,
"СР"
,
"ЧТ"
,
"ПТ"
,
"СБ"
][
day
];
}
}
...
@@ -24,30 +24,21 @@ function MonthCalendarBody({month, year, tasks}) {
...
@@ -24,30 +24,21 @@ function MonthCalendarBody({month, year, tasks}) {
return
new
Date
(
year
,
month
,
day
).
getDay
()
return
new
Date
(
year
,
month
,
day
).
getDay
()
}
}
const
createTaskInCellHandler
=
(
dayOfWeek
,
dayNumber
,
dayHour
)
=>
{
const
setNewMonthDays
=
()
=>
{
// const newTasks = [...tasksForCell]
const
newDaysInMonth
=
[]
// const newTask = {
for
(
let
i
=
1
;
i
<=
getDaysInMonth
();
i
++
)
{
// id: Date.now(),
const
dayOfWeekNumber
=
getDayOfWeekNumber
(
i
)
// user:"first",
newDaysInMonth
.
push
({
dayNumber
:
i
,
dayOfWeek
:
getDayOfWeekString
(
dayOfWeekNumber
)})
// title:"Новая",
}
// description:"описание задачи11111",
setDaysInMonth
(
newDaysInMonth
)
// priority:"A",
// author:"Ivan",
// executor:"Arman",
// dateTimeStart:`${dayNumber}.${month+1}.${year} ${parseInt(dayHour.split(':')[0])}:00:00`,
// dateTimeDue:`${dayNumber}.${month+1}.${year} ${parseInt(dayHour.split(':')[0]) + 1}:00:00`,
// }
// newTasks.push(newTask)
// exampleTasks.push(newTask)
// setNewTasksWithInfoForCell(newTasks, month, year)
}
}
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
getTaskInDayCell
=
(
tasks
,
day
,
hours
)
=>
{
const
task
=
tasks
.
find
(
task
=>
{
const
task
=
tasks
.
find
(
task
=>
{
if
(
year
===
task
.
startYear
)
{
if
(
year
===
task
.
infoForCell
.
startYear
)
{
if
(
month
+
1
===
task
.
startMonth
)
{
if
(
month
+
1
===
task
.
infoForCell
.
startMonth
)
{
if
(
day
.
dayNumber
===
task
.
startDay
&&
task
.
startDayOfWeek
===
day
.
dayOfWeek
)
{
if
(
day
.
dayNumber
===
task
.
infoForCell
.
startDay
&&
task
.
infoForCell
.
startDayOfWeek
===
day
.
dayOfWeek
)
{
if
((
task
.
endHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
])
||
task
.
startHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
]))
&&
(
task
.
endHour
>=
parseInt
(
hours
.
split
(
':'
)[
0
])))
{
if
((
task
.
infoForCell
.
endHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
])
||
task
.
infoForCell
.
startHour
<=
parseInt
(
hours
.
split
(
':'
)[
0
]))
&&
(
task
.
infoForCell
.
endHour
>=
parseInt
(
hours
.
split
(
':'
)[
0
])))
{
return
task
return
task
}
}
}
}
...
@@ -57,16 +48,6 @@ function MonthCalendarBody({month, year, tasks}) {
...
@@ -57,16 +48,6 @@ function MonthCalendarBody({month, year, tasks}) {
return
task
return
task
}
}
const
setNewMonthDays
=
()
=>
{
const
newDaysInMonth
=
[]
for
(
let
i
=
1
;
i
<=
getDaysInMonth
(
month
,
year
);
i
++
)
{
const
dayOfWeekNumber
=
getDayOfWeekNumber
(
month
,
year
,
i
)
newDaysInMonth
.
push
({
dayNumber
:
i
,
dayOfWeek
:
getDayOfWeekString
(
dayOfWeekNumber
)})
}
setDaysInMonth
(
newDaysInMonth
)
}
const
onChangeCellTaskTitle
=
(
e
,
task
)
=>
{
const
onChangeCellTaskTitle
=
(
e
,
task
)
=>
{
const
value
=
e
.
target
.
value
;
const
value
=
e
.
target
.
value
;
const
name
=
e
.
target
.
name
;
const
name
=
e
.
target
.
name
;
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
6a7323c0
...
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
...
@@ -3,7 +3,7 @@ import { useEffect, useState } 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
{
fetchTasks
,
setNewTasksForCells
}
from
'../../store/actions/tasksActions'
;
import
{
fetchTasks
}
from
'../../store/actions/tasksActions'
;
function
MonthCalendar
()
{
function
MonthCalendar
()
{
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
...
@@ -32,40 +32,6 @@ function MonthCalendar() {
...
@@ -32,40 +32,6 @@ function MonthCalendar() {
return
[
"Январь"
,
"Февраль"
,
"Март"
,
"Апрель"
,
"Май"
,
"Июнь"
,
"Июль"
,
"Август"
,
"Сентябрь"
,
"Октябрь"
,
"Ноябрь"
,
"Декабрь"
][
month
];
return
[
"Январь"
,
"Февраль"
,
"Март"
,
"Апрель"
,
"Май"
,
"Июнь"
,
"Июль"
,
"Август"
,
"Сентябрь"
,
"Октябрь"
,
"Ноябрь"
,
"Декабрь"
][
month
];
}
}
const
getDayOfWeekString
=
(
day
)
=>
{
return
[
"ВС"
,
"ПН"
,
"ВТ"
,
"СР"
,
"ЧТ"
,
"ПТ"
,
"СБ"
][
day
];
}
const
getDayOfWeekNumber
=
(
day
)
=>
{
return
new
Date
(
year
,
month
,
day
).
getDay
()
}
const
setNewTasksWithInfoForCell
=
(
tasks
)
=>
{
const
newArr
=
tasks
.
map
((
task
)
=>
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
const
dateStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
0
]
const
timeStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
1
]
const
timeEnd
=
task
.
dateTimeDue
.
split
(
'T'
)[
1
]
const
dayStart
=
parseInt
(
dateStart
.
split
(
'-'
)[
2
])
const
dayOfWeekStartNumber
=
getDayOfWeekNumber
(
dayStart
)
const
dayOfWeekStartString
=
getDayOfWeekString
(
dayOfWeekStartNumber
)
const
monthStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
1
])
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
return
{...
task
,
startDay
:
dayStart
,
startDayOfWeek
:
dayOfWeekStartString
,
startHour
:
timeStartHour
,
startMonth
:
monthStartNumber
,
startYear
:
yearStartNumber
,
endHour
:
timeEndHour
,
}
}
})
dispatch
(
setNewTasksForCells
(
newArr
))
}
const
incrementMonth
=
()
=>
{
const
incrementMonth
=
()
=>
{
setMonth
((
prevState
)
=>
{
setMonth
((
prevState
)
=>
{
if
(
prevState
+
1
===
12
)
{
if
(
prevState
+
1
===
12
)
{
...
@@ -86,6 +52,24 @@ function MonthCalendar() {
...
@@ -86,6 +52,24 @@ function MonthCalendar() {
})
})
}
}
const
createTaskInCellHandler
=
(
dayOfWeek
,
dayNumber
,
dayHour
)
=>
{
// const newTasks = [...tasksForCell]
// const newTask = {
// id: Date.now(),
// user:"first",
// title:"Новая",
// description:"описание задачи11111",
// priority:"A",
// author:"Ivan",
// executor:"Arman",
// dateTimeStart:`${dayNumber}.${month+1}.${year} ${parseInt(dayHour.split(':')[0])}:00:00`,
// dateTimeDue:`${dayNumber}.${month+1}.${year} ${parseInt(dayHour.split(':')[0]) + 1}:00:00`,
// }
// newTasks.push(newTask)
// exampleTasks.push(newTask)
// setNewTasksWithInfoForCell(newTasks)
}
return
(
return
(
<>
<>
<
Container
>
<
Container
>
...
@@ -104,6 +88,7 @@ function MonthCalendar() {
...
@@ -104,6 +88,7 @@ function MonthCalendar() {
month
=
{
month
}
month
=
{
month
}
year
=
{
year
}
year
=
{
year
}
tasks
=
{
tasks
}
tasks
=
{
tasks
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
/
>
/
>
<
/Container
>
<
/Container
>
<
/
>
<
/
>
...
...
planner-front/src/store/actions/tasksActions.js
View file @
6a7323c0
...
@@ -30,16 +30,16 @@ export const fetchTasks = () => {
...
@@ -30,16 +30,16 @@ export const fetchTasks = () => {
dateTimeStart
:
"2022-11-11T11:35:30.937Z"
,
dateTimeStart
:
"2022-11-11T11:35:30.937Z"
,
description
:
"lol"
,
description
:
"lol"
,
id
:
"2fd828a2-3778-45fd-a11a-00d799db9142"
,
id
:
"2fd828a2-3778-45fd-a11a-00d799db9142"
,
title
:
"task"
,
title
:
"task
1
"
,
},
{
},
{
accomplish
:
"opened"
,
accomplish
:
"opened"
,
author
:
{
id
:
'f0e4a3bf-78fb-465b-9f28-620790750418'
,
name
:
'timur'
,
surname
:
'ermolaev'
,
displayName
:
'ermolaev t.'
,
email
:
'loool@mail.ru'
},
author
:
{
id
:
'f0e4a3bf-78fb-465b-9f28-620790750418'
,
name
:
'timur'
,
surname
:
'ermolaev'
,
displayName
:
'ermolaev t.'
,
email
:
'loool@mail.ru'
},
createdAt
:
"2022-11-07T11:35:30.937Z"
,
createdAt
:
"2022-11-07T11:35:30.937Z"
,
dateTimeDue
:
"2022-11-25T1
4:35:3
0.937Z"
,
dateTimeDue
:
"2022-11-25T1
6:00:0
0.937Z"
,
dateTimeStart
:
"2022-11-25T1
1
:35:30.937Z"
,
dateTimeStart
:
"2022-11-25T1
5
:35:30.937Z"
,
description
:
"lol"
,
description
:
"lol"
,
id
:
"2fd828a2-3778-45fd-a11a-00d799db9142"
,
id
:
"2fd828a2-3778-45fd-a11a-00d799db9142"
,
title
:
"task"
,
title
:
"task
2
"
,
},
},
]
]
dispatch
(
fetchTasksSuccess
(
arr
))
dispatch
(
fetchTasksSuccess
(
arr
))
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
6a7323c0
...
@@ -23,15 +23,18 @@ const tasksReduсer = (state = initialState, action) => {
...
@@ -23,15 +23,18 @@ const tasksReduсer = (state = initialState, action) => {
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
yearStartNumber
=
parseInt
(
dateStart
.
split
(
'-'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeStartHour
=
parseInt
(
timeStart
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
const
timeEndHour
=
parseInt
(
timeEnd
.
split
(
':'
)[
0
])
return
{...
task
,
return
{...
task
,
infoForCell
:
{
startDay
:
dayStart
,
startDay
:
dayStart
,
startDayOfWeek
:
dayOfWeekStartString
,
startDayOfWeek
:
dayOfWeekStartString
,
startHour
:
timeStartHour
,
startHour
:
timeStartHour
,
startMonth
:
monthStartNumber
,
startMonth
:
monthStartNumber
,
startYear
:
yearStartNumber
,
startYear
:
yearStartNumber
,
endHour
:
timeEndHour
,
endHour
:
timeEndHour
,
}
}
}
}
}
else
{
return
null
}
})
})
return
{...
state
,
loading
:
false
,
tasks
:
newArr
};
return
{...
state
,
loading
:
false
,
tasks
:
newArr
};
case
FETCH_TASKS_FAILURE
:
case
FETCH_TASKS_FAILURE
:
...
...
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