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
4c9591fc
Commit
4c9591fc
authored
Dec 12, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#101
fix fetch projects after delete
parent
959d2099
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
projects.ts
planner-api/src/routers/projects.ts
+25
-10
projectsActions.js
planner-front/src/store/actions/projectsActions.js
+2
-2
No files found.
planner-api/src/routers/projects.ts
View file @
4c9591fc
...
@@ -143,17 +143,32 @@ router.post('/add-user/', authAdminProject, async (req: Request, res: Response):
...
@@ -143,17 +143,32 @@ router.post('/add-user/', authAdminProject, async (req: Request, res: Response):
/** Remove user from specific project by userId */
/** Remove user from specific project by userId */
router
.
delete
(
'/remove-user/:userId'
,
authAdminProject
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
delete
(
'/remove-user/:userId'
,
authAdminProject
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
console
.
log
(
'req
'
,
req
)
console
.
log
(
'req
.body '
,
req
.
body
)
const
{
projectId
}
=
req
.
body
.
data
;
const
{
projectId
}
=
req
.
body
;
const
{
userId
}
=
req
.
params
;
const
{
userId
}
=
req
.
params
;
try
{
console
.
log
(
'projectId '
,
projectId
,
'userId '
,
userId
)
await
dataSource
.
createQueryBuilder
()
try
{
.
delete
()
const
projectMember
=
await
dataSource
.
from
(
Member
)
.
getRepository
(
Member
)
.
where
(
"user= :userId"
,
{
userId
})
.
findOne
({
.
andWhere
(
"project=:projectId"
,{
projectId
})
relations
:{
.
execute
()
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"
})
return
res
.
send
({
message
:
"User removed from project successfully"
})
}
catch
(
e
){
}
catch
(
e
){
return
res
.
send
({
message
:
'Failed to remove user from project'
})
return
res
.
send
({
message
:
'Failed to remove user from project'
})
...
...
planner-front/src/store/actions/projectsActions.js
View file @
4c9591fc
...
@@ -40,9 +40,9 @@ const deleteMemberRequest = () => {
...
@@ -40,9 +40,9 @@ const deleteMemberRequest = () => {
dispatch
(
deleteMemberRequest
());
dispatch
(
deleteMemberRequest
());
try
{
try
{
const
response
=
await
axios
.
delete
(
`/projects/remove-user/
${
memberId
}
`
,
{
data
:
{
projectId
:
projectId
}});
const
response
=
await
axios
.
delete
(
`/projects/remove-user/
${
memberId
}
`
,
{
data
:
{
projectId
:
projectId
}});
console
.
log
(
response
.
data
)
console
.
log
(
"deleteMember "
,
response
.
data
)
dispatch
(
deleteMemberSuccess
())
dispatch
(
deleteMemberSuccess
())
dispatch
(
fetchProject
())
dispatch
(
fetchProject
(
projectId
))
}
catch
(
error
)
{
}
catch
(
error
)
{
dispatch
(
deleteMemberFailure
(
error
.
response
.
data
));
dispatch
(
deleteMemberFailure
(
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