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>=>{
/**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;
......@@ -5,17 +5,21 @@ import { useDispatch, useSelector } from "react-redux";
import DeleteIcon from "@mui/icons-material/Delete";
import { deleteMember } from "../../../store/actions/projectsActions";
const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId }) => {
const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId, members }) => {
console.log(displayName)
const dispatch = useDispatch();
const user = useSelector(state => state.users)
let params = useParams()
console.log(params)
console.log(members)
console.log(userId)
const { projects, project } = useSelector(state => state.projects);
const deleteHandle = (userId, projectId) => {
dispatch(deleteMember(userId, params.id));
if (members.length > 1) {
dispatch(deleteMember(userId, params.id))
} else {
alert("Нельзя удалить автора проекта")
}
};
return <>
......
......@@ -13,6 +13,7 @@ const ProjectMembersList = ({members, roleProjectOfAuthor}) => {
key={member.id}
roleProjectOfAuthor={roleProjectOfAuthor}
userId={member?.user?.id}
members={members}
/>
})}
</Grid>
......
......@@ -12,7 +12,7 @@ const FullProject = () => {
const { projects, project } = useSelector(state => state.projects);
const users = useSelector(state => state.users.users);
const user = useSelector(state => state.users.user);
const dispatch = useDispatch();
const params = useParams()
......@@ -24,7 +24,7 @@ const FullProject = () => {
dispatch(fetchUsers())
}, [dispatch]);
console.log(users)
console.log(user)
useEffect(() => {
dispatch(fetchProject(params.id))
......@@ -55,8 +55,8 @@ const FullProject = () => {
<strong>
<br></br>
<div style={{display: 'flex', direction: 'column'}}>
Участники проекта:
<NewMember members={project?.project?.members} />
Участники проекта: {(project?.project?.members[0]?.user.displayName === user.displayName) ? <NewMember members={project?.project?.members} /> : null}
</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