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
2c813db9
Commit
2c813db9
authored
Dec 20, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#110
create of task in MyTask fixed
parent
e82c76a8
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
152 additions
and
214 deletions
+152
-214
helpers.ts
planner-api/src/helpers.ts
+12
-1
User.ts
planner-api/src/models/User.ts
+2
-0
tasks.ts
planner-api/src/routers/tasks.ts
+64
-90
MyTaskToolBar.js
...r-front/src/components/MyTasksCompoments/MyTaskToolBar.js
+4
-4
NewTaskForm.js
...ner-front/src/components/MyTasksCompoments/NewTaskForm.js
+1
-1
Select.js
planner-front/src/components/UI/Select/Select.js
+8
-3
NewTaskForm.js
...-front/src/components/UsersTasksCompoments/NewTaskForm.js
+3
-9
UsersTaskToolBar.js
...t/src/components/UsersTasksCompoments/UsersTaskToolBar.js
+3
-3
ForgottenPassword.js
...ont/src/containers/ForgottenPassword/ForgottenPassword.js
+1
-0
MyTasks.js
planner-front/src/containers/MyTasks/MyTasks.js
+38
-52
UsersTasks.js
planner-front/src/containers/UsersTasks/UsersTasks.js
+10
-45
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+4
-4
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+2
-2
No files found.
planner-api/src/helpers.ts
View file @
2c813db9
...
...
@@ -176,7 +176,7 @@ export const taskFinderByDateTimeTaskId = async (dateTimeTaskId:string):Promise<
/**member finder by userId and projectId, return one task */
export
const
memberFinderById
=
async
(
userId
:
string
,
projectId
:
string
)
=>
{
export
const
memberFinderById
=
async
(
userId
:
string
,
projectId
:
string
)
:
Promise
<
Member
|
null
>
=>
{
const
member
=
await
dataSource
.
getRepository
(
Member
)
.
findOne
({
...
...
@@ -210,6 +210,17 @@ export let transporter = nodemailer.createTransport({
})
export
const
subtractHours
=
(
date
:
Date
,
hours
:
number
)
=>
{
const
dateCopy
=
new
Date
(
date
);
console
.
log
(
'dateCopy '
,
dateCopy
)
dateCopy
.
setHours
(
dateCopy
.
getHours
()
-
hours
);
console
.
log
(
'dateCopy afterset '
,
dateCopy
)
return
dateCopy
;
}
export
const
FRONTEND_URL
=
'localhost:3000'
;
planner-api/src/models/User.ts
View file @
2c813db9
...
...
@@ -83,6 +83,8 @@ export class User extends BaseEntity implements IUser {
@
OneToMany
(()
=>
Member
,
(
member
:
{
user
:
User
})
=>
member
.
user
,
{
onDelete
:
'CASCADE'
})
members
!
:
Member
[];
// @OneToOne(()=>PasswordRecovery,)
@
BeforeInsert
()
...
...
planner-api/src/routers/tasks.ts
View file @
2c813db9
...
...
@@ -5,7 +5,7 @@ import { User } from '../models/User';
import
{
Member
,
MemberRole
}
from
'../models/Member'
;
import
{
Equal
,
In
,
Not
}
from
'typeorm'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
subtractHours
,
taskFinderById
}
from
'../helpers'
;
import
{
Project
}
from
'../models/Project'
;
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
...
...
@@ -27,6 +27,17 @@ router.get('/', async(req:Request, res:Response):Promise<Response> => {
/**create new task for table MyTask*/
router
.
post
(
'/'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
user
,
title
,
description
,
project
,
executor
,
dateTimeStart
,
dateTimeDue
,
dateTimeDeadLine
,
priority
}
=
req
.
body
;
console
.
log
(
'dateTimeStart '
,
dateTimeStart
,
'dateTimeDue '
,
dateTimeDue
,
'dateTimeDeadLine '
,
dateTimeDeadLine
)
//** if dateTimeDue is null , then dateTimeDeadLine copied to dateTimeDue and dateTimeStart = dateTimeDue - 1 hour*/
let
dateTimeDueFinal
=
dateTimeDue
let
dateTimeStartFinal
=
dateTimeStart
let
dateTimeDeadlineFinal
=
dateTimeDeadLine
if
(
!
dateTimeDue
&&
dateTimeDeadLine
)
{
dateTimeDueFinal
=
dateTimeDeadLine
dateTimeStartFinal
=
subtractHours
(
dateTimeDueFinal
,
1
)
}
console
.
log
(
'dateTimeDueFinal '
,
dateTimeDueFinal
,
'dateTimeStartFinal '
,
dateTimeStartFinal
,
'dateTimeDeadLine '
,
dateTimeDeadLine
,
' dateTimeDeadlineFinal '
,
dateTimeDeadlineFinal
)
const
newTask
=
new
Task
();
newTask
.
title
=
title
;
newTask
.
description
=
description
;
...
...
@@ -77,7 +88,7 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
await
newMember
.
save
();
}
}
newTask
.
dateTimeDeadLine
=
dateTimeDeadLine
;
newTask
.
dateTimeDeadLine
=
dateTimeDeadlineFinal
;
newTask
.
author
=
user
;
if
(
newTask
.
project
.
title
===
"Личные дела"
){
newTask
.
executor
=
user
;
...
...
@@ -86,11 +97,13 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
}
newTask
.
priority
=
priority
;
await
newTask
.
save
();
if
(
dateTimeDeadlineFinal
)
{
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
Final
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
Final
newDateTimeTask
.
task
=
newTask
await
newDateTimeTask
.
save
()
}
return
res
.
send
({
newTask
});
})
...
...
@@ -170,13 +183,12 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
relations
:{
executor
:
true
,
},
where
:
[
where
:
{
executor
:{
id
:
userId
}
},
]
})
return
res
.
send
({
tasks
})
})
...
...
@@ -185,94 +197,54 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
/**check tasks of current user where he is executor(works for tbl MyTasks), search by id*/
router
.
get
(
'/my'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
user
=
req
.
body
.
user
// const tasks = await dataSource
// .getRepository(Task)
// .find({
// relations:{
// // project:true,
// executor:true,
// project:{
// members:{
// user:true
// }
// }
// },
// where:
// {
// executor:{
// id:user.id
// },
// project:{
// members:{
// user:user,
// // roleProject:Not(MemberRole.WATCHER)
// }
// }
// }
// }
// )
const
projectsRawId
=
await
dataSource
.
getRepository
(
Project
)
.
find
({
select
:{
id
:
true
},
where
:{
title
:
Not
(
Equal
(
"Не определено"
)),
members
:{
user
:{
id
:
user
.
id
},
roleProject
:
Not
(
MemberRole
.
WATCHER
)
}
}
}
)
const
projects
=
await
dataSource
.
getRepository
(
Project
)
.
find
({
relations
:{
members
:{
user
:
true
}},
const
projectsList
=
projectsRawId
.
map
(
project
=>
{
return
project
.
id
})
const
tasks
=
await
dataSource
.
getRepository
(
Task
)
.
find
(
{
relations
:{
author
:
true
,
executor
:
true
,
project
:
true
},
where
:{
title
:
Not
(
Equal
(
"Не определено"
)),
members
:{
user
:{
id
:
user
.
id
executor
:{
id
:
user
.
id
},
roleProject
:
Not
(
MemberRole
.
WATCHER
)
}
}
}
)
const
projectsList
=
projects
.
map
(
project
=>
{
return
project
.
id
})
console
.
log
(
'projectsList '
,
projectsList
)
const
tasks
=
await
dataSource
.
getRepository
(
Task
)
.
find
(
{
relations
:{
author
:
true
,
executor
:
true
,
project
:
true
},
where
:{
executor
:{
id
:
user
.
id
},
// project:{
// id:In(projectsList)
// }
}
}
)
// console.log('tasks ', tasks)
// console.log('projects ', projects)
// const projectsList= tasks.map(task=> {return task.project?.id})
// console.log( 'projectsList ', projectsList)
// const projects= await dataSource
// .getRepository(Project)
// .find({relations:{
// members:{
// user:true
// }
// },
// where:{
// id:In(
// projectsList,
// ),
// title:Not(Equal("Не определено"))
// }
// })
// return res.send({
// projects})
return
res
.
send
({
tasks
,
projects
})
})
)
const
projects
=
await
dataSource
.
getRepository
(
Project
)
.
find
({
relations
:{
members
:
true
},
where
:{
id
:
In
(
projectsList
)
}
})
return
res
.
send
({
tasks
,
projects
})
})
/**return tasks & users of projects in which current user is involved, search by token*/
...
...
@@ -336,7 +308,9 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
/**change of task by task id */
router
.
put
(
'/:taskId'
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
{
taskId
}
=
req
.
params
const
{
authorStatus
,
executorStatus
,
title
,
description
,
note
,
archive
,
project
,
dateTimeTaskId
,
dateTimeStart
,
dateTimeDue
,
executor
,
accomplish
,
dateTimeDeadLine
,
dateTimeFactDeadLine
,
priority
}
=
req
.
body
;
const
{
authorStatus
,
executorStatus
,
title
,
description
,
note
,
archive
,
project
,
dateTimeTaskId
,
dateTimeStart
,
dateTimeDue
,
executor
,
accomplish
,
dateTimeDeadLine
,
dateTimeFactDeadLine
,
priority
}
=
req
.
body
;
console
.
log
(
'dateTimeTaskId '
,
dateTimeTaskId
)
const
task
=
await
taskFinderById
(
taskId
)
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
let
dateTimeTask
=
null
;
...
...
planner-front/src/components/MyTasksCompoments/MyTaskToolBar.js
View file @
2c813db9
...
...
@@ -8,18 +8,18 @@ import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect';
import
Add
from
"@mui/icons-material/Add"
;
import
Close
from
"@mui/icons-material/Close"
;
export
default
function
MyTaskToolBar
({
projects
,
onClose
,
project
Name
,
setProjectName
,
formStatus
,
onClick
})
{
export
default
function
MyTaskToolBar
({
projects
,
onClose
,
project
IdListForTaskSelect
,
setProjectIdListForTaskSelect
,
formStatus
,
onClick
})
{
let
projectsFilter
=
<><
/
>
if
(
projects
)
{
if
(
Array
.
isArray
(
projects
)
)
{
projectsFilter
=
<
MultipleSelect
projects
=
{
projects
}
onClose
=
{
onClose
}
projectName
=
{
project
Name
}
setProjectName
=
{
setProject
Name
}
projectName
=
{
project
IdListForTaskSelect
}
setProjectName
=
{
setProject
IdListForTaskSelect
}
/
>
}
...
...
planner-front/src/components/MyTasksCompoments/NewTaskForm.js
View file @
2c813db9
...
...
@@ -35,7 +35,7 @@ export default function NewTaskForm({ projects, setAddTaskForm }) {
dateTimeDeadLine
:
null
,
dateTimeTasks
:
[],
dateTimeDue
:
null
,
project
:
projects
[
0
]
,
project
:
null
,
accomplish
:
"opened"
,
priority
:
"B"
,
author
:
{
id
:
user
.
id
},
...
...
planner-front/src/components/UI/Select/Select.js
View file @
2c813db9
...
...
@@ -6,7 +6,12 @@ import FormControl from "@mui/material/FormControl";
import
Select
from
"@mui/material/Select"
;
export
default
function
BasicSelect
({
value
,
label
,
name
,
onChange
,
task
,
items
})
{
console
.
log
(
'select value '
,
value
)
console
.
log
(
'select label '
,
label
)
console
.
log
(
'select name '
,
name
)
console
.
log
(
'select task '
,
task
)
console
.
log
(
'select items '
,
items
)
// console.log('select value ', value)
return
(
<
Box
sx
=
{{
minWidth
:
60
,
m
:
0
}}
>
<
FormControl
fullWidth
>
...
...
@@ -19,11 +24,11 @@ export default function BasicSelect({value,label,name,onChange,task,items}) {
name
=
{
name
}
onChange
=
{(
e
)
=>
onChange
(
e
,
task
)}
>
{
items
.
map
((
item
,
index
)
=>
(
{
items
?
items
.
map
((
item
,
index
)
=>
(
<
MenuItem
key
=
{
index
}
value
=
{
item
.
value
}
>
{
item
.
title
}
<
/MenuItem
>
))}
))
:
<><
/>
}
<
/Select
>
<
/FormControl
>
<
/Box
>
...
...
planner-front/src/components/UsersTasksCompoments/NewTaskForm.js
View file @
2c813db9
...
...
@@ -40,7 +40,7 @@ export default function NewTaskForm({
dateTimeDeadLine
:
null
,
dateTimeTasks
:
[],
dateTimeDue
:
null
,
project
:
projects
[
0
],
project
:
[
],
accomplish
:
"opened"
,
priority
:
"B"
,
author
:
{
id
:
user
.
id
},
...
...
@@ -240,13 +240,7 @@ export const header = [
disablePadding
:
true
,
label
:
"Приоритет"
,
},
// {
// id: "createdAt",
// numeric: true,
// disablePadding: false,
// label: "Дата создания",
// },
{
{
id
:
"title"
,
numeric
:
false
,
disablePadding
:
false
,
...
...
@@ -266,7 +260,7 @@ export const header = [
label
:
"Исполнитель"
,
},
{
id
:
"dateTimeD
u
e"
,
id
:
"dateTimeD
eadLin
e"
,
numeric
:
true
,
disablePadding
:
false
,
label
:
"Дедлайн"
,
...
...
planner-front/src/components/UsersTasksCompoments/UsersTaskToolBar.js
View file @
2c813db9
...
...
@@ -8,7 +8,7 @@ import MultipleSelect from '../UI/MultipleSelect/MultipleSelect';
import
Add
from
"@mui/icons-material/Add"
;
import
Close
from
"@mui/icons-material/Close"
;
export
default
function
UsersTaskToolBar
({
projects
,
onClose
,
project
Name
,
setProjectName
,
formStatus
,
onClick
})
{
export
default
function
UsersTaskToolBar
({
projects
,
onClose
,
project
IdListForTaskSelect
,
setProjectIdListForTaskSelect
,
formStatus
,
onClick
})
{
let
projectsFilter
=
<><
/
>
...
...
@@ -18,8 +18,8 @@ export default function UsersTaskToolBar({projects,onClose,projectName,setProjec
<
MultipleSelect
projects
=
{
projects
}
onClose
=
{
onClose
}
projectName
=
{
project
Name
}
setProjectName
=
{
setProject
Name
}
projectName
=
{
project
IdListForTaskSelect
}
setProjectName
=
{
setProject
IdListForTaskSelect
}
/
>
}
...
...
planner-front/src/containers/ForgottenPassword/ForgottenPassword.js
View file @
2c813db9
...
...
@@ -7,6 +7,7 @@ import PersonIcon from '@mui/icons-material/Person';
import
styled
from
"@emotion/styled"
;
import
{
Alert
,
Avatar
,
Container
,
Typography
}
from
"@mui/material"
;
import
ResetPasswordForm
from
"../../components/UserForm/ResetPasswordForm"
;
import
axios
from
"axios"
;
const
StyledContainer
=
styled
(
Container
)
`
padding-top: 30px;
...
...
planner-front/src/containers/MyTasks/MyTasks.js
View file @
2c813db9
...
...
@@ -34,7 +34,6 @@ export default function EnhancedTable() {
open
:
false
,
task
:
null
,
});
// const [projects, setProjects] = useState(["1", "2"]);
// useEffect(() => {
// dispatch(fetchAllTasks());
...
...
@@ -42,14 +41,15 @@ export default function EnhancedTable() {
// }, [dispatch]);
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
if
(
tasks
&&
tasks
?.
length
>
0
)
{
setRecievedTasks
(
tasks
);
}
},
[
tasks
?.
length
]);
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
},
[
addTaskForm
,
setAddTaskForm
,
dispatch
]);
},
[
tasks
?.
length
,
addTaskForm
,
setAddTaskForm
,
dispatch
]);
console
.
log
(
'tasks '
,
tasks
,
'projects '
,
projects
)
//
useEffect(() => {
//
dispatch(fetchAllTasks());
//
}, [addTaskForm, setAddTaskForm, dispatch]);
...
...
@@ -112,7 +112,7 @@ export default function EnhancedTable() {
const
onProjectChange
=
(
e
,
task
)
=>
{
const
value
=
e
.
target
.
value
;
const
project
=
uniqueP
rojects
.
find
((
e
)
=>
e
.
id
===
value
);
const
project
=
p
rojects
.
find
((
e
)
=>
e
.
id
===
value
);
const
{
id
}
=
task
;
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
...
...
@@ -183,46 +183,33 @@ export default function EnhancedTable() {
};
// ++++++++фильтрация по проектам+++++++++++++++
const
[
projectName
,
setProjectName
]
=
React
.
useState
([]);
const
[
filterProjectTumbler
,
setFilterProjectTumbler
]
=
React
.
useState
(
false
);
const
onClose
=
(
projectName
)
=>
{
let
tasksFilteredByProject
=
tasks
;
if
(
projectName
.
length
>
0
)
{
tasksFilteredByProject
=
tasks
.
filter
((
task
)
=>
projectName
.
includes
(
task
.
project
?.
title
)
);
}
setRecievedTasks
(
tasksFilteredByProject
);
setFilterProjectTumbler
(
true
);
};
const
rawProjects
=
tasks
?.
map
((
task
)
=>
task
.
project
);
const
filterProjectsNamesFromTasks
=
()
=>
{
if
(
tasks
&&
tasks
?.
length
>
0
)
{
let
rawSetProjectNames
=
[];
for
(
let
project
of
rawProjects
)
{
if
(
project
===
null
)
{
}
else
{
rawSetProjectNames
.
push
(
project
.
title
);
}
}
let
uniqueTitlesProjects
=
[...
new
Set
(
rawSetProjectNames
)];
// setProjects(uniqueTitlesProjects);
}
};
const
uniqueProjects
=
rawProjects
?.
reduce
((
results
,
value
,
index
)
=>
{
const
exist
=
results
.
find
((
v
)
=>
{
return
v
!==
null
&&
v
.
id
===
value
?.
id
;
});
if
(
!
exist
&&
value
!==
null
)
{
results
.
push
(
value
);
}
return
results
;
},
[]);
console
.
log
(
'tasks'
,
tasks
)
const
[
projectIdListForTaskSelect
,
setProjectIdListForTaskSelect
]
=
React
.
useState
([]);
const
[
filterProjectTumbler
,
setFilterProjectTumbler
]
=
React
.
useState
(
false
);
const
onClose
=
(
projectIdListForTaskSelect
)
=>
{
console
.
log
(
'projectIdListForTaskSelect '
,
projectIdListForTaskSelect
)
let
tasksFilteredByProject
=
tasks
if
(
projectIdListForTaskSelect
.
length
>
0
)
{
tasksFilteredByProject
=
tasks
.
filter
(
task
=>
projectIdListForTaskSelect
.
includes
(
task
.
project
?.
id
))
}
console
.
log
(
'tasksFilteredByProject '
,
tasksFilteredByProject
)
setRecievedTasks
(
tasksFilteredByProject
)
setFilterProjectTumbler
(
true
)
}
// const rawProjects = tasks?.map((task) => task.project);
// const uniqueProjects = rawProjects?.reduce((results, value, index) => {
// const exist = results.find((v) => {
// return v !== null && v.id === value?.id;
// });
// if (!exist && value !== null) {
// results.push(value);
// }
// return results;
// }, []);
// console.log('tasks', tasks)
if
(
tasks
&&
...
...
@@ -238,13 +225,13 @@ console.log('tasks', tasks)
formStatus
=
{
addTaskForm
}
projects
=
{
projects
}
onClose
=
{
onClose
}
project
Name
=
{
projectName
}
setProject
Name
=
{
setProjectName
}
project
IdListForTaskSelect
=
{
projectIdListForTaskSelect
}
setProject
IdListForTaskSelect
=
{
setProjectIdListForTaskSelect
}
/
>
{
addTaskForm
?
(
<
NewTaskForm
projects
=
{
uniqueP
rojects
}
projects
=
{
p
rojects
}
setAddTaskForm
=
{()
=>
setAddTaskForm
(
false
)}
/
>
)
:
null
}
...
...
@@ -273,8 +260,7 @@ console.log('tasks', tasks)
onChange
=
{
onChange
}
onModalOpen
=
{
onModalOpen
}
onProjectChange
=
{
onProjectChange
}
uniqueProjects
=
{
uniqueProjects
}
onAuthorChange
=
{
onAuthorChange
}
uniqueProjects
=
{
projects
}
onDateChange
=
{
onDateChange
}
onToggleEditMode
=
{
onToggleEditMode
}
onToggleEditModeDone
=
{
onToggleEditModeDone
}
...
...
planner-front/src/containers/UsersTasks/UsersTasks.js
View file @
2c813db9
...
...
@@ -12,7 +12,7 @@ import { useDispatch, useSelector } from "react-redux";
import
TaskModal
from
"../../components/UsersTasksCompoments/TaskModal/TaskModal"
;
import
moment
from
"moment"
;
import
UsersTaskToolBar
from
"../../components/UsersTasksCompoments/UsersTaskToolBar"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
deleteDateTimeTask
,
fetchAllTasksByMembership
}
from
"../../store/actions/tasksActions"
;
import
{
deleteTask
,
editTask
,
deleteDateTimeTask
,
fetchAllTasksByMembership
}
from
"../../store/actions/tasksActions"
;
import
NewTaskForm
from
"../../components/UsersTasksCompoments/NewTaskForm"
;
import
TableRowTask
from
"../../components/UsersTasksCompoments/TableRowTask/TableRowTask"
;
import
UsersTasksHeader
from
"./UsersTasksHeader/UsersTasksHeader"
;
...
...
@@ -198,12 +198,6 @@ export default function UsersTasks() {
dispatch
(
deleteDateTimeTask
(
dateTimeTaskId
))
}
const
handleEditDateTimeTask
=
(
dateTimeTask
)
=>
{
console
.
log
(
'edit by dateTImeTask'
)
// dispatch(handleEditDateTimeTask(dateTimeTask))
}
const
onModalOpen
=
(
event
,
task
)
=>
{
event
.
stopPropagation
();
setModal
({
...
modal
,
open
:
true
,
id
:
task
.
id
});
...
...
@@ -214,49 +208,21 @@ export default function UsersTasks() {
};
// ++++++++фильтрация по проектам+++++++++++++++
const
[
project
Name
,
setProjectName
]
=
React
.
useState
([]);
const
[
project
IdListForTaskSelect
,
setProjectIdListForTaskSelect
]
=
React
.
useState
([]);
const
[
filterProjectTumbler
,
setFilterProjectTumbler
]
=
React
.
useState
(
false
);
const
onClose
=
(
project
Name
)
=>
{
console
.
log
(
'project
Name '
,
projectName
)
const
onClose
=
(
project
IdListForTaskSelect
)
=>
{
console
.
log
(
'project
IdListForTaskSelect '
,
projectIdListForTaskSelect
)
let
tasksFilteredByProject
=
tasks
if
(
project
Name
.
length
>
0
)
{
tasksFilteredByProject
=
tasks
.
filter
(
task
=>
project
Name
.
includes
(
task
.
project
?.
id
))
if
(
project
IdListForTaskSelect
.
length
>
0
)
{
tasksFilteredByProject
=
tasks
.
filter
(
task
=>
project
IdListForTaskSelect
.
includes
(
task
.
project
?.
id
))
}
console
.
log
(
'tasksFilteredByProject '
,
tasksFilteredByProject
)
setRecievedTasks
(
tasksFilteredByProject
)
setFilterProjectTumbler
(
true
)
}
const
rawProjects
=
tasks
?.
map
(
task
=>
task
.
project
)
// const filterProjectsNamesFromTasks = ()=>{
// if (tasks && tasks?.length > 0) {
// let rawSetProjectNames = []
// for (let project of rawProjects){
// if (project===null){
// } else{
// rawSetProjectNames.push(project.title)
// }
// }
// let uniqueTitlesProjects = [...new Set(rawSetProjectNames)];
// setProjects(uniqueTitlesProjects)
// }
// }
const
uniqueProjects
=
rawProjects
?.
reduce
((
results
,
value
,
index
)
=>
{
const
exist
=
results
.
find
((
v
)
=>
{
return
v
!==
null
&&
v
.
id
===
value
?.
id
});
if
(
!
exist
&&
value
!==
null
)
{
results
.
push
(
value
);
}
return
results
;
},
[]);
if
(
tasks
&&
tasks
?.
length
>
0
&&
...
...
@@ -271,8 +237,8 @@ export default function UsersTasks() {
formStatus
=
{
addTaskForm
}
projects
=
{
projects
}
onClose
=
{
onClose
}
project
Name
=
{
projectName
}
setProject
Name
=
{
setProjectName
}
project
IdListForTaskSelect
=
{
projectIdListForTaskSelect
}
setProject
IdListForTaskSelect
=
{
setProjectIdListForTaskSelect
}
/
>
{
addTaskForm
?
(
...
...
@@ -311,8 +277,7 @@ export default function UsersTasks() {
onProjectChange
=
{
onProjectChange
}
executors
=
{
executors
}
onExecutorChange
=
{
onExecutorChange
}
uniqueProjects
=
{
uniqueProjects
}
// onAuthorChange={onAuthorChange}
uniqueProjects
=
{
projects
}
onDateChange
=
{
onDateChange
}
onToggleEditMode
=
{
onToggleEditMode
}
onToggleEditModeDone
=
{
onToggleEditModeDone
}
...
...
planner-front/src/store/actions/tasksActions.js
View file @
2c813db9
...
...
@@ -30,8 +30,8 @@ const fetchCalendarTasksSuccess = (tasks) => {
return
{
type
:
FETCH_CALENDAR_TASKS_SUCCESS
,
tasks
}
};
const
fetchAllTasksSuccess
=
(
tasks
)
=>
{
return
{
type
:
FETCH_ALL_TASKS_SUCCESS
,
tasks
}
const
fetchAllTasksSuccess
=
(
tasks
,
projects
)
=>
{
return
{
type
:
FETCH_ALL_TASKS_SUCCESS
,
tasks
,
projects
}
};
...
...
@@ -55,8 +55,8 @@ export const fetchAllTasks = () => {
return
async
(
dispatch
)
=>
{
dispatch
(
fetchCalendarTasksRequest
());
try
{
const
response
=
await
axios
.
get
(
"/tasks"
);
dispatch
(
fetchAllTasksSuccess
(
response
.
data
.
tasks
))
const
response
=
await
axios
.
get
(
"/tasks
/my
"
);
dispatch
(
fetchAllTasksSuccess
(
response
.
data
.
tasks
,
response
.
data
.
projects
))
}
catch
(
error
)
{
dispatch
(
fetchCalendarTasksFailure
(
error
.
response
.
data
));
}
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
2c813db9
...
...
@@ -78,8 +78,8 @@ const tasksReduсer = (state = initialState, action) => {
})
return
{...
state
,
loading
:
false
,
calendarTasks
:
newTasksWithInfoForCell
};
case
FETCH_ALL_TASKS_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
task
s
};
case
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
,
projects
:
action
.
project
s
};
case
FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
,
projects
:
action
.
projects
};
case
FETCH_CALENDAR_TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
...
...
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