#101 fix fetch projects after delete

parent 959d2099
......@@ -143,17 +143,32 @@ router.post('/add-user/', authAdminProject, async (req: Request, res: Response):
/** Remove user from specific project by userId */
router.delete('/remove-user/:userId', authAdminProject,async (req: Request, res: Response):Promise<Response>=> {
console.log('req ', req)
const {projectId} = req.body.data;
console.log('req.body ', req.body)
const {projectId} = req.body;
const {userId }=req.params;
console.log('projectId ', projectId, 'userId ',userId )
try{
await dataSource
.createQueryBuilder()
.delete()
.from(Member)
.where("user= :userId", { userId })
.andWhere("project=:projectId",{projectId})
.execute()
const projectMember = await dataSource
.getRepository(Member)
.findOne({
relations:{
user:true,
project:true
},
where:{
user:{
id:userId
},
project:{
id:projectId
}
}
})
console.log('projectMember ', projectMember)
if(!projectMember) return res.status(404).send({message:"this member is not present"})
await Member.delete({id:projectMember.id})
console.log('projectMember deleted successfully')
return res.send({message:"User removed from project successfully" })
} catch(e){
return res.send({message:'Failed to remove user from project'})
......
......@@ -40,9 +40,9 @@ const deleteMemberRequest = () => {
dispatch(deleteMemberRequest());
try {
const response = await axios.delete(`/projects/remove-user/${memberId}`, { data: { projectId: projectId}});
console.log(response.data)
console.log("deleteMember ", response.data)
dispatch(deleteMemberSuccess())
dispatch(fetchProject())
dispatch(fetchProject(projectId))
} catch (error) {
dispatch(deleteMemberFailure(error.response.data));
}
......
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