Commit 196709fe authored by Ermolaev Timur's avatar Ermolaev Timur

#141 Добавил отображение юзеров в колонках ролей

parent 7c007486
...@@ -9,7 +9,6 @@ import MonthCalendar from './containers/MonthCalendar/MonthCalendar'; ...@@ -9,7 +9,6 @@ import MonthCalendar from './containers/MonthCalendar/MonthCalendar';
import ForgottenPassword from "./containers/ForgottenPassword/ForgottenPassword"; import ForgottenPassword from "./containers/ForgottenPassword/ForgottenPassword";
import Projects from "./containers/Projects/Projects"; import Projects from "./containers/Projects/Projects";
import FullProject from "./containers/FullProject/FullProject"; import FullProject from "./containers/FullProject/FullProject";
import NewProject from "./containers/NewProject/NewProject";
import WeekCalendar from "./containers/WeekCalendar/WeekCalendar"; import WeekCalendar from "./containers/WeekCalendar/WeekCalendar";
import UsersTasks from "./containers/UsersTasks/UsersTasks"; import UsersTasks from "./containers/UsersTasks/UsersTasks";
......
...@@ -44,7 +44,6 @@ const MemberForm = ({ onSubmit, members }) => { ...@@ -44,7 +44,6 @@ const MemberForm = ({ onSubmit, members }) => {
onSubmit(members); onSubmit(members);
setOpen(false); setOpen(false);
}; };
console.log(state);
useEffect(() => { useEffect(() => {
dispatch(fetchProject(params.id)) dispatch(fetchProject(params.id))
......
import { Card, CardContent, Grid, IconButton, Tooltip } from "@mui/material";
import { useParams } from "react-router-dom";
import { useDispatch } from "react-redux";
import DeleteIcon from "@mui/icons-material/Delete";
import { deleteMember } from "../../../store/actions/projectsActions";
const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId, members, authorOfProject }) => {
console.log(displayName)
const dispatch = useDispatch();
let params = useParams()
console.log(members)
console.log(userId)
const deleteHandle = (userId, projectId) => {
dispatch(deleteMember(userId, params.id))
};
return <>
<Grid item xs={12} sm={12} md={6} lg={4}>
<Card>
<CardContent>
<strong>
<br></br>
{displayName}
</strong>
<strong>
<br></br>
роль: {roleProject}
</strong>
<strong>
{(members.filter(e => e.user.displayName === authorOfProject).length > 0) ?
(<strong>
<Tooltip title="Удалить">
<IconButton
onClick={(id) => {
deleteHandle(userId);
}}
> {(displayName !== authorOfProject) ? <DeleteIcon style={{ marginTop: "-5px" }} /> : null}
</IconButton>
</Tooltip>
</strong>) : null}
</strong>
</CardContent>
</Card>
</Grid>
</>
};
export default ProjectMembersItem;
import {Grid} from "@mui/material"; import {Grid} from "@mui/material";
import ProjectMembersItem from "../ProjectMembersItem/ProjectMembersItem"; import ProjectMembersItem from "../ProjectUserItem/ProjectUserItem";
const ProjectMembersList = ({members, roleProjectOfAuthor, authorOfProject}) => { const ProjectMembersList = ({members, roleProjectOfAuthor, authorOfProject}) => {
console.log("members ", members) console.log("members ", members)
......
import { Grid } from "@mui/material";
import DeleteIcon from "@mui/icons-material/Delete";
import { deleteMember } from "../../../store/actions/projectsActions";
import { memo } from "react";
const ProjectMembersItem = ({ user }) => {
const style = {
width: '90%',
border: '1px solid black',
borderRadius: '5px',
padding: '15px 15px',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center'
}
return <>
<Grid sx={style}>
{user?.displayName}
<DeleteIcon
/>
</Grid>
</>
};
export default memo(ProjectMembersItem);
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import { memo } from "react";
import ProjectUserItem from "../../ProjectUserItem/ProjectUserItem";
const style = { const styleColumn = {
border: '3px solid black', border: '3px solid black',
borderRadius: '10px', borderRadius: '10px',
height: '60vh', height: '60vh',
flexBasis: 60 / 3 + '%', flexBasis: 60 / 3 + '%',
overflow: 'scroll', overflow: 'auto',
overflowX: 'hidden', overflowX: 'hidden',
} }
const ProjectUsersColumn = ({ role }) => { const styleList = {
display: 'flex',
gap: '10px',
flexDirection: 'column',
alignItems: 'center',
}
const ProjectUsersColumn = ({ role, members }) => {
return ( return (
<Box sx={style}> <Box sx={styleColumn}>
<Typography variant="h4" textAlign={'center'}> <Typography variant="h4" textAlign={'center'} sx={{marginBottom: '20px'}}>
{role.text} {role.text}
</Typography> </Typography>
<Box sx={styleList}>
{members.map((member) => {
if (member.roleProject === role.value) {
return (
<ProjectUserItem
key={member.id}
user={member?.user}
/>
)
} else {
return null
}
})}
</Box>
</Box> </Box>
); );
}; };
export default ProjectUsersColumn; export default memo(ProjectUsersColumn);
\ No newline at end of file \ No newline at end of file
import {Box} from "@mui/material"; import {Box} from "@mui/material";
import { memo } from "react";
import ProjectUsersColumn from "./ProjectUsersColumn/ProjectUsersColumn"; import ProjectUsersColumn from "./ProjectUsersColumn/ProjectUsersColumn";
...@@ -12,7 +13,7 @@ const style = { ...@@ -12,7 +13,7 @@ const style = {
} }
const ProjectUsersColumnsWrapper = ({}) => { const ProjectUsersColumnsWrapper = ({members}) => {
return ( return (
<Box sx={style} justifyContent={'space-between'}> <Box sx={style} justifyContent={'space-between'}>
{projectRoles.map((role, i)=>{ {projectRoles.map((role, i)=>{
...@@ -20,6 +21,7 @@ const ProjectUsersColumnsWrapper = ({}) => { ...@@ -20,6 +21,7 @@ const ProjectUsersColumnsWrapper = ({}) => {
<ProjectUsersColumn <ProjectUsersColumn
key={i} key={i}
role={role} role={role}
members={members}
/> />
) )
})} })}
...@@ -27,4 +29,4 @@ const ProjectUsersColumnsWrapper = ({}) => { ...@@ -27,4 +29,4 @@ const ProjectUsersColumnsWrapper = ({}) => {
); );
}; };
export default ProjectUsersColumnsWrapper; export default memo(ProjectUsersColumnsWrapper);
\ No newline at end of file \ No newline at end of file
import { Box, Grid } from "@mui/material"; import { Box, Grid } from "@mui/material";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { useEffect } from "react"; import { useEffect, useMemo, useState } from "react";
import { fetchProject } from "../../store/actions/projectsActions"; import { fetchProject } from "../../store/actions/projectsActions";
import { fetchUsers } from "../../store/actions/usersActions"; import { fetchUsers, fetchUsersAllFields } from "../../store/actions/usersActions";
import ProjectMembersList from "../../components/ProjectComponents/ProjectMembersList/ProjectMembersList"; import ProjectMembersList from "../../components/ProjectComponents/ProjectMembersList/ProjectMembersList";
import NewMember from "../NewMember/NewMember"; import NewMember from "../NewMember/NewMember";
import ProjectUsersColumnsWrapper from "../../components/ProjectComponents/ProjectUsersColumnsWrapper/ProjectUsersColumnsWrapper"; import ProjectUsersColumnsWrapper from "../../components/ProjectComponents/ProjectUsersColumnsWrapper/ProjectUsersColumnsWrapper";
...@@ -11,20 +11,22 @@ import ProjectUsersColumnsWrapper from "../../components/ProjectComponents/Proje ...@@ -11,20 +11,22 @@ import ProjectUsersColumnsWrapper from "../../components/ProjectComponents/Proje
const FullProject = () => { const FullProject = () => {
const { projects, project } = useSelector(state => state.projects); const { project } = useSelector(state => state.projects);
const users = useSelector(state => state.users.users);
const user = useSelector(state => state.users.user); const user = useSelector(state => state.users.user);
const dispatch = useDispatch(); const dispatch = useDispatch();
const params = useParams() const params = useParams()
useEffect(() => {
dispatch(fetchUsers())
}, [dispatch]);
useEffect(() => { useEffect(() => {
dispatch(fetchProject(params.id)) dispatch(fetchProject(params.id))
}, [params.id, dispatch]); }, [params.id, dispatch]);
const members = useMemo(()=>{
return project?.project?.members || []
},[project])
console.log(members)
return <> return <>
<Grid item xs={12} sm={12} md={6} lg={4}> <Grid item xs={12} sm={12} md={6} lg={4}>
<Box> <Box>
...@@ -59,7 +61,9 @@ const FullProject = () => { ...@@ -59,7 +61,9 @@ const FullProject = () => {
{/* <ProjectMembersList users={users} project={project} members={project?.project?.members} roleProjectOfAuthor={project?.project?.members[0]?.roleProject} authorOfProject={project?.project?.members[0]?.user.displayName} /> */} {/* <ProjectMembersList users={users} project={project} members={project?.project?.members} roleProjectOfAuthor={project?.project?.members[0]?.roleProject} authorOfProject={project?.project?.members[0]?.user.displayName} /> */}
<ProjectUsersColumnsWrapper/> <ProjectUsersColumnsWrapper
members={members}
/>
</strong> </strong>
</Box> </Box>
......
...@@ -14,7 +14,6 @@ const NewMember = ({members}) => { ...@@ -14,7 +14,6 @@ const NewMember = ({members}) => {
const onSubmit = async (memberData) => { const onSubmit = async (memberData) => {
await dispatch(createMember(memberData, navigate)); await dispatch(createMember(memberData, navigate));
navigate("/projects/" + memberData.projectId) navigate("/projects/" + memberData.projectId)
console.log("memberData ", memberData)
}; };
......
...@@ -51,8 +51,7 @@ export const deleteMember = (memberId, projectId) => { ...@@ -51,8 +51,7 @@ export const deleteMember = (memberId, projectId) => {
return async (dispatch) => { return async (dispatch) => {
dispatch(deleteMemberRequest()); dispatch(deleteMemberRequest());
try { try {
const response = await axios.delete(`/projects/remove-user/${memberId}`, { data: { projectId: projectId } }); await axios.delete(`/projects/remove-user/${memberId}`, { data: { projectId: projectId } });
console.log("deleteMember ", response.data)
dispatch(deleteMemberSuccess()) dispatch(deleteMemberSuccess())
dispatch(fetchProject(projectId)) dispatch(fetchProject(projectId))
} catch (error) { } catch (error) {
...@@ -92,7 +91,6 @@ export const fetchProject = (id) => { ...@@ -92,7 +91,6 @@ export const fetchProject = (id) => {
try { try {
const response = await axios.get("/projects/" + id); const response = await axios.get("/projects/" + id);
dispatch(fetchProjectSuccess(response.data)); dispatch(fetchProjectSuccess(response.data));
console.log("fetch project ", response.data)
} catch (e) { } catch (e) {
dispatch(fetchProjectsError(e)); dispatch(fetchProjectsError(e));
} }
......
...@@ -118,7 +118,6 @@ export const fetchUsers = () => { ...@@ -118,7 +118,6 @@ export const fetchUsers = () => {
try { try {
const response = await axios.get("/users"); const response = await axios.get("/users");
dispatch(fetchUsersSuccess(response.data.users)); dispatch(fetchUsersSuccess(response.data.users));
console.log(response.data.users)
} catch (e) { } catch (e) {
dispatch(fetchUsersFailure(e)); dispatch(fetchUsersFailure(e));
} }
......
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