Commit 959d2099 authored by Ibadullina Inabat's avatar Ibadullina Inabat

на доработке кнопка удаления участника

parent 8f1aa7fe
......@@ -143,7 +143,8 @@ 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>=> {
const {projectId} = req.body;
console.log('req ', req)
const {projectId} = req.body.data;
const {userId }=req.params;
try{
await dataSource
......
......@@ -52,7 +52,7 @@ const MemberForm = ({ onSubmit, members }) => {
useEffect(() => {
dispatch(fetchProject(params.id))
}, [members, dispatch, params]);
}, []);
// console.log(user)
// const onChange = (e) => {
// const value = e.target.value;
......
import { Card, CardActions, CardContent, Grid, IconButton, Tooltip } from "@mui/material";
import { Link } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
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 }) => {
const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId }) => {
console.log(displayName)
const dispatch = useDispatch();
const user = useSelector(state => state.users)
console.log(user)
let params = useParams()
console.log(params)
console.log(userId)
const { projects, project } = useSelector(state => state.projects);
const deleteHandle = (userId, projectId) => {
dispatch(deleteMember(userId, params.id));
};
return <>
<Grid item xs={12} sm={12} md={6} lg={4}>
<Card>
......@@ -30,7 +37,7 @@ const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor
<Tooltip title="Удалить">
<IconButton
onClick={(id) => {
// deleteHandle(task.id);
deleteHandle(userId);
}}
>
<DeleteIcon style={{ marginTop: "-5px" }} />
......
......@@ -12,6 +12,7 @@ const ProjectMembersList = ({members, roleProjectOfAuthor}) => {
id={member.id}
key={member.id}
roleProjectOfAuthor={roleProjectOfAuthor}
userId={member.user.id}
/>
})}
</Grid>
......
......@@ -35,11 +35,12 @@ const deleteMemberRequest = () => {
return {type: DELETE_MEMBER_FAILURE, error}
};
export const deleteMember = (memberId) => {
export const deleteMember = (memberId, projectId) => {
return async (dispatch) => {
dispatch(deleteMemberRequest());
try {
await axios.delete(`/tasks/${memberId}`);
const response = await axios.delete(`/projects/remove-user/${memberId}`, { data: { projectId: projectId}});
console.log(response.data)
dispatch(deleteMemberSuccess())
dispatch(fetchProject())
} catch (error) {
......
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