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() {
...
@@ -17,13 +17,15 @@ function MonthCalendar() {
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
infoForCell
:
{
startHour
:
null
,
endHour
:
null
}
})
const
[
currentTask
,
setCurrentTask
]
=
useState
({
title
:
''
,
description
:
''
,
priority
:
null
,
infoForCell
:
{
startHour
:
null
,
endHour
:
null
}
})
const
[
copyTask
,
setCopyTask
]
=
useState
(
null
)
const
[
copyTask
,
setCopyTask
]
=
useState
(
null
)
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
const
[
cellSizes
,
setCellSizes
]
=
useState
({})
const
[
userId
,
setUserId
]
=
useState
(
''
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setDateNow
({
setDateNow
({
month
:
new
Date
().
getMonth
(),
month
:
new
Date
().
getMonth
(),
year
:
new
Date
().
getFullYear
(),
year
:
new
Date
().
getFullYear
(),
})
})
dispatch
(
fetchCalendarTasks
())
setUserId
(
user
.
id
)
dispatch
(
fetchCalendarTasks
(
user
.
id
))
},
[
dispatch
])
},
[
dispatch
])
...
@@ -66,6 +68,7 @@ function MonthCalendar() {
...
@@ -66,6 +68,7 @@ function MonthCalendar() {
return
{
...
prevState
,
month
:
prevState
.
month
+
1
}
return
{
...
prevState
,
month
:
prevState
.
month
+
1
}
})
})
},
[])
},
[])
const
decrementMonth
=
useCallback
(()
=>
{
const
decrementMonth
=
useCallback
(()
=>
{
setDateNow
((
prevState
)
=>
{
setDateNow
((
prevState
)
=>
{
if
(
prevState
.
month
-
1
===
-
1
)
{
if
(
prevState
.
month
-
1
===
-
1
)
{
...
@@ -137,13 +140,12 @@ function MonthCalendar() {
...
@@ -137,13 +140,12 @@ function MonthCalendar() {
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
const
start
=
dateToISOLikeButLocal
(
new
Date
(
dateNow
.
year
,
dateNow
.
month
,
dayNumber
,
hour
,
0
))
const
newTask
=
{
const
newTask
=
{
...
currentTask
,
...
currentTask
,
dateTimeTaskId
:
currentTask
.
id
,
dateTimeStart
:
start
,
dateTimeStart
:
start
,
dateTimeDue
:
due
dateTimeDue
:
due
}
}
delete
newTask
.
id
delete
newTask
.
id
delete
newTask
.
infoForCell
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
))
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
setCurrentTask
({})
setCurrentTask
({})
}
}
...
@@ -161,7 +163,7 @@ function MonthCalendar() {
...
@@ -161,7 +163,7 @@ function MonthCalendar() {
taskId
:
currentTask
.
mainTaskId
taskId
:
currentTask
.
mainTaskId
}
}
delete
newTask
.
infoForCell
delete
newTask
.
infoForCell
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
))
await
dispatch
(
editCalendarTask
(
newTask
,
currentTask
.
id
,
userId
))
}
else
{
}
else
{
const
newTask
=
{
const
newTask
=
{
...
currentTask
,
...
currentTask
,
...
@@ -172,7 +174,7 @@ function MonthCalendar() {
...
@@ -172,7 +174,7 @@ function MonthCalendar() {
}
}
delete
newTask
.
infoForCell
delete
newTask
.
infoForCell
delete
newTask
.
id
delete
newTask
.
id
await
dispatch
(
addCalendarTask
(
newTask
))
await
dispatch
(
addCalendarTask
(
newTask
,
userId
))
}
}
}
}
...
@@ -194,12 +196,12 @@ function MonthCalendar() {
...
@@ -194,12 +196,12 @@ function MonthCalendar() {
}
}
delete
newTask
.
infoForCell
delete
newTask
.
infoForCell
delete
newTask
.
id
delete
newTask
.
id
await
dispatch
(
addCopyCalendarTask
(
newTask
))
await
dispatch
(
addCopyCalendarTask
(
newTask
,
userId
))
setCopyTask
(
null
)
setCopyTask
(
null
)
}
}
const
deleteTaskHandler
=
async
(
taskId
)
=>
{
const
deleteTaskHandler
=
async
(
taskId
)
=>
{
dispatch
(
deleteCalendarTask
(
taskId
))
dispatch
(
deleteCalendarTask
(
taskId
,
userId
))
}
}
return
(
return
(
...
...
planner-front/src/containers/WeekCalendar/WeekCalendar.js
View file @
d029fe4c
...
@@ -19,7 +19,7 @@ function WeekCalendar() {
...
@@ -19,7 +19,7 @@ function WeekCalendar() {
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
})
dispatch
(
fetchCalendarTasks
())
//
dispatch(fetchCalendarTasks())
},
[])
},
[])
const
hoursInDay
=
useMemo
(()
=>
{
const
hoursInDay
=
useMemo
(()
=>
{
...
...
planner-front/src/store/actions/tasksActions.js
View file @
d029fe4c
...
@@ -38,11 +38,11 @@ const fetchCalendarTasksFailure = (error) => {
...
@@ -38,11 +38,11 @@ const fetchCalendarTasksFailure = (error) => {
return
{
type
:
FETCH_CALENDAR_TASKS_FAILURE
,
error
}
return
{
type
:
FETCH_CALENDAR_TASKS_FAILURE
,
error
}
};
};
export
const
fetchCalendarTasks
=
()
=>
{
export
const
fetchCalendarTasks
=
(
userId
)
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
fetchCalendarTasksRequest
());
dispatch
(
fetchCalendarTasksRequest
());
try
{
try
{
const
response
=
await
axios
.
get
(
"/tasks"
);
const
response
=
await
axios
.
get
(
`/tasks/user/
${
userId
}
`
);
dispatch
(
fetchCalendarTasksSuccess
(
response
.
data
.
tasks
))
dispatch
(
fetchCalendarTasksSuccess
(
response
.
data
.
tasks
))
}
catch
(
error
)
{
}
catch
(
error
)
{
dispatch
(
fetchCalendarTasksFailure
(
error
.
response
.
data
));
dispatch
(
fetchCalendarTasksFailure
(
error
.
response
.
data
));
...
@@ -73,26 +73,26 @@ const addTaskFailure = (error) => {
...
@@ -73,26 +73,26 @@ const addTaskFailure = (error) => {
return
{
type
:
ADD_NEW_TASK_FAILURE
,
error
}
return
{
type
:
ADD_NEW_TASK_FAILURE
,
error
}
};
};
export
const
addCalendarTask
=
(
task
)
=>
{
export
const
addCalendarTask
=
(
task
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
dispatch
(
addTaskRequest
());
try
{
try
{
await
axios
.
post
(
"/tasks"
,
task
);
await
axios
.
post
(
"/tasks"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
}
}
}
}
export
const
addCopyCalendarTask
=
(
task
)
=>
{
export
const
addCopyCalendarTask
=
(
task
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
addTaskRequest
());
dispatch
(
addTaskRequest
());
try
{
try
{
await
axios
.
post
(
"/copy-tasks/make-copy"
,
task
);
await
axios
.
post
(
"/copy-tasks/make-copy"
,
task
);
dispatch
(
addTaskSuccess
())
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
}
...
@@ -137,13 +137,14 @@ export const editTask = (task) => {
...
@@ -137,13 +137,14 @@ export const editTask = (task) => {
}
}
}
}
export
const
editCalendarTask
=
(
task
,
taskId
)
=>
{
export
const
editCalendarTask
=
(
task
,
taskId
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
editTaskRequest
());
dispatch
(
editTaskRequest
());
try
{
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
(
editTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
}
catch
(
error
)
{
dispatch
(
editTaskFailure
(
error
.
response
.
data
));
dispatch
(
editTaskFailure
(
error
.
response
.
data
));
}
}
...
@@ -175,13 +176,13 @@ export const deleteTask = (taskId) => {
...
@@ -175,13 +176,13 @@ export const deleteTask = (taskId) => {
}
}
}
}
export
const
deleteCalendarTask
=
(
taskId
)
=>
{
export
const
deleteCalendarTask
=
(
taskId
,
userId
)
=>
{
return
async
(
dispatch
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteTaskRequest
());
dispatch
(
deleteTaskRequest
());
try
{
try
{
await
axios
.
delete
(
`/copy-tasks/
${
taskId
}
`
);
await
axios
.
delete
(
`/copy-tasks/
${
taskId
}
`
);
dispatch
(
deleteTaskSuccess
())
dispatch
(
deleteTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
(
userId
))
}
catch
(
error
)
{
}
catch
(
error
)
{
dispatch
(
deleteTaskFailure
(
error
.
response
.
data
));
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