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
d029fe4c
Commit
d029fe4c
authored
Dec 12, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#103
сделал отображение только своих задач
parent
8f1aa7fe
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
19 deletions
+22
-19
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+9
-7
WeekCalendar.js
planner-front/src/containers/WeekCalendar/WeekCalendar.js
+1
-1
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+12
-11
No files found.
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
d029fe4c
...
...
@@ -17,13 +17,15 @@ function MonthCalendar() {
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
infoForCell
:
{
startHour
:
null
,
endHour
:
null
}
})
const
[
copyTask
,
setCopyTask
]
=
useState
(
null
)
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
const
[
userId
,
setUserId
]
=
useState
(
''
)
useEffect
(()
=>
{
setDateNow
({
month
:
new
Date
().
getMonth
(),
year
:
new
Date
().
getFullYear
(),
})
dispatch
(
fetchCalendarTasks
())
setUserId
(
user
.
id
)
dispatch
(
fetchCalendarTasks
(
user
.
id
))
},
[
dispatch
])
...
...
@@ -66,6 +68,7 @@ function MonthCalendar() {
return
{
...
prevState
,
month
:
prevState
.
month
+
1
}
})
},
[])
const
decrementMonth
=
useCallback
(()
=>
{
setDateNow
((
prevState
)
=>
{
if
(
prevState
.
month
-
1
===
-
1
)
{
...
...
@@ -137,13 +140,12 @@ function MonthCalendar() {
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
const
newTask
=
{
...
currentTask
,
dateTimeTaskId
:
currentTask
.
id
,
dateTimeStart
:
start
,
dateTimeDue
:
due
}
delete
newTask
.
id
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
))
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
setCurrentTask
({})
}
...
...
@@ -161,7 +163,7 @@ function MonthCalendar() {
taskId
:
currentTask
.
mainTaskId
}
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
))
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
}
else
{
const
newTask
=
{
...
currentTask
,
...
...
@@ -172,7 +174,7 @@ function MonthCalendar() {
}
delete
newTask
.
infoForCell
delete
newTask
.
id
await
dispatch
(
addCalendarTask
(
newTask
))
await
dispatch
(
addCalendarTask
(
newTask
,
userId
))
}
}
...
...
@@ -194,12 +196,12 @@ function MonthCalendar() {
}
delete
newTask
.
infoForCell
delete
newTask
.
id
await
dispatch
(
addCopyCalendarTask
(
newTask
))
await
dispatch
(
addCopyCalendarTask
(
newTask
,
userId
))
setCopyTask
(
null
)
}
const
deleteTaskHandler
=
async
(
taskId
)
=>
{
dispatch
(
deleteCalendarTask
(
taskId
))
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
}
return
(
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
d029fe4c
...
...
@@ -19,7 +19,7 @@ function WeekCalendar() {
const
month
=
new
Date
().
getMonth
()
const
currentDay
=
moment
().
date
()
setDate
({
year
:
year
,
month
:
month
,
currentDay
:
currentDay
})
dispatch
(
fetchCalendarTasks
())
//
dispatch(fetchCalendarTasks())
},
[])
const
hoursInDay
=
useMemo
(()
=>
{
...
...
planner-front/src/store/actions/tasksActions.js
View file @
d029fe4c
...
...
@@ -38,11 +38,11 @@ const fetchCalendarTasksFailure = (error) => {
return
{
type
:
FETCH_CALENDAR_TASKS_FAILURE
,
error
}
};
export
const
fetchCalendarTasks
=
()
=>
{
export
const
fetchCalendarTasks
=
(
userId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
fetchCalendarTasksRequest
());
try
{
const
response
=
await
axios
.
get
(
"/tasks"
);
const
response
=
await
axios
.
get
(
`/tasks/user/
${
userId
}
`
);
dispatch
(
fetchCalendarTasksSuccess
(
response
.
data
.
tasks
))
}
catch
(
error
)
{
dispatch
(
fetchCalendarTasksFailure
(
error
.
response
.
data
));
...
...
@@ -73,26 +73,26 @@ const addTaskFailure = (error) => {
return
{
type
:
ADD_NEW_TASK_FAILURE
,
error
}
};
export
const
addCalendarTask
=
(
task
)
=>
{
export
const
addCalendarTask
=
(
task
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
await
axios
.
post
(
"/tasks"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
}
export
const
addCopyCalendarTask
=
(
task
)
=>
{
export
const
addCopyCalendarTask
=
(
task
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
try
{
await
axios
.
post
(
"/copy-tasks/make-copy"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
...
...
@@ -137,13 +137,14 @@ export const editTask = (task) => {
}
}
export
const
editCalendarTask
=
(
task
,
taskId
)
=>
{
export
const
editCalendarTask
=
(
task
,
taskId
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
editTaskRequest
());
try
{
await
axios
.
put
(
`/copy-tasks/change-copy/
${
taskId
}
`
,
task
);
const
response
=
await
axios
.
put
(
`/copy-tasks/change-copy/
${
taskId
}
`
,
task
);
console
.
log
(
response
.
data
)
dispatch
(
editTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
dispatch
(
editTaskFailure
(
error
.
response
.
data
));
}
...
...
@@ -175,13 +176,13 @@ export const deleteTask = (taskId) => {
}
}
export
const
deleteCalendarTask
=
(
taskId
)
=>
{
export
const
deleteCalendarTask
=
(
taskId
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteTaskRequest
());
try
{
await
axios
.
delete
(
`/copy-tasks/
${
taskId
}
`
);
dispatch
(
deleteTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
dispatch
(
deleteTaskFailure
(
error
.
response
.
data
));
}
...
...
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