Merge branch 'development' of…

Merge branch 'development' of ssh://git.attractor-school.com:30022/apollo64/crm-team-one into task-105-feature/tbl_tasks_users
parents 1051ea6e 33e225e7
...@@ -272,6 +272,39 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{ ...@@ -272,6 +272,39 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
/**check other users tasks that are related to the user through common projects, by user token*/
router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Response>=>{
const {user} = req.body
const projects = await dataSource
.getRepository(Project)
.find(
{ relations:{
members:true,
tasks:{
author:true,
executor:true
}
},
where:{
members:{
user:{
id:user.id
}
}
}})
if (!projects) return res.status(404).send({Message:'projects not found'})
let tasks:Task[] = []
if (projects.length>0) {
for (let project of projects){
if (project?.tasks) {
tasks=tasks.concat(project.tasks)
}
}
}
return res.send({projects, tasks})
})
export default router; export default router;
...@@ -5,17 +5,21 @@ import { useDispatch, useSelector } from "react-redux"; ...@@ -5,17 +5,21 @@ import { useDispatch, useSelector } from "react-redux";
import DeleteIcon from "@mui/icons-material/Delete"; import DeleteIcon from "@mui/icons-material/Delete";
import { deleteMember } from "../../../store/actions/projectsActions"; import { deleteMember } from "../../../store/actions/projectsActions";
const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId }) => { const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId, members }) => {
console.log(displayName) console.log(displayName)
const dispatch = useDispatch(); const dispatch = useDispatch();
const user = useSelector(state => state.users) const user = useSelector(state => state.users)
let params = useParams() let params = useParams()
console.log(params) console.log(members)
console.log(userId) console.log(userId)
const { projects, project } = useSelector(state => state.projects); const { projects, project } = useSelector(state => state.projects);
const deleteHandle = (userId, projectId) => { const deleteHandle = (userId, projectId) => {
dispatch(deleteMember(userId, params.id)); if (members.length > 1) {
dispatch(deleteMember(userId, params.id))
} else {
alert("Нельзя удалить автора проекта")
}
}; };
return <> return <>
......
...@@ -13,6 +13,7 @@ const ProjectMembersList = ({members, roleProjectOfAuthor}) => { ...@@ -13,6 +13,7 @@ const ProjectMembersList = ({members, roleProjectOfAuthor}) => {
key={member.id} key={member.id}
roleProjectOfAuthor={roleProjectOfAuthor} roleProjectOfAuthor={roleProjectOfAuthor}
userId={member?.user?.id} userId={member?.user?.id}
members={members}
/> />
})} })}
</Grid> </Grid>
......
...@@ -12,7 +12,7 @@ const FullProject = () => { ...@@ -12,7 +12,7 @@ const FullProject = () => {
const { projects, project } = useSelector(state => state.projects); const { projects, project } = useSelector(state => state.projects);
const users = useSelector(state => state.users.users); const users = useSelector(state => state.users.users);
const user = useSelector(state => state.users.user);
const dispatch = useDispatch(); const dispatch = useDispatch();
const params = useParams() const params = useParams()
...@@ -24,7 +24,7 @@ const FullProject = () => { ...@@ -24,7 +24,7 @@ const FullProject = () => {
dispatch(fetchUsers()) dispatch(fetchUsers())
}, [dispatch]); }, [dispatch]);
console.log(users) console.log(user)
useEffect(() => { useEffect(() => {
dispatch(fetchProject(params.id)) dispatch(fetchProject(params.id))
...@@ -55,8 +55,8 @@ const FullProject = () => { ...@@ -55,8 +55,8 @@ const FullProject = () => {
<strong> <strong>
<br></br> <br></br>
<div style={{display: 'flex', direction: 'column'}}> <div style={{display: 'flex', direction: 'column'}}>
Участники проекта: Участники проекта: {(project?.project?.members[0]?.user.displayName === user.displayName) ? <NewMember members={project?.project?.members} /> : null}
<NewMember members={project?.project?.members} />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment