Commit 75de717a authored by Ibadullina Inabat's avatar Ibadullina Inabat

добавлены проверки вв раздел проекты по ТЗ

parent 186d716f
......@@ -77,7 +77,7 @@ const MemberForm = ({ onSubmit, members }) => {
id="free-solo-demo"
freeSolo
options={users}
getOptionLabel={(item) => item.displayName || ""}
getOptionLabel={(item) => (members[0]?.user?.displayName !== item.displayName) ? (item.displayName || "") : ""}
onChange={memberChangeHandler}
name={"userId"}
value={state.user}
......
......@@ -31,8 +31,11 @@ const ProjectForm = ({onSubmit}) => {
e.preventDefault();
let project = {title: state.title}
console.log(project);
if (project.title === "") {
alert("Нельзя создать проект без названия")
} else {
onSubmit(project);
}
};
const inputChangeHandler = (e) => {
......
......@@ -5,7 +5,7 @@ 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, members }) => {
const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor, userId, members, authorOfProject }) => {
console.log(displayName)
const dispatch = useDispatch();
const user = useSelector(state => state.users)
......@@ -36,15 +36,14 @@ const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor,
</strong>
<strong>
{roleProjectOfAuthor === "admin" ?
{(members.filter(e => e.user.displayName === authorOfProject).length > 0) ?
(<strong>
<Tooltip title="Удалить">
<IconButton
onClick={(id) => {
deleteHandle(userId);
}}
>
<DeleteIcon style={{ marginTop: "-5px" }} />
> {(displayName !== authorOfProject) ? <DeleteIcon style={{ marginTop: "-5px" }} /> : null}
</IconButton>
</Tooltip>
</strong>) : null}
......
import {Grid} from "@mui/material";
import ProjectMembersItem from "../ProjectMembersItem/ProjectMembersItem";
const ProjectMembersList = ({members, roleProjectOfAuthor}) => {
const ProjectMembersList = ({members, roleProjectOfAuthor, authorOfProject}) => {
console.log("members ", members)
return (
<Grid item container direction="column" spacing={1}>
......@@ -14,6 +14,7 @@ const ProjectMembersList = ({members, roleProjectOfAuthor}) => {
roleProjectOfAuthor={roleProjectOfAuthor}
userId={member?.user?.id}
members={members}
authorOfProject={authorOfProject}
/>
})}
</Grid>
......
......@@ -60,7 +60,7 @@ const FullProject = () => {
</div>
<ProjectMembersList users={users} project={project} members={project?.project?.members} roleProjectOfAuthor={project?.project?.members[0]?.roleProject} />
<ProjectMembersList users={users} project={project} members={project?.project?.members} roleProjectOfAuthor={project?.project?.members[0]?.roleProject} authorOfProject={project?.project?.members[0]?.user.displayName}/>
</strong>
<strong>
<br></br>
......
......@@ -53,7 +53,7 @@ export const fetchProjects = () => {
return async dispatch => {
dispatch(fetchProjectsRequest());
try {
const response = await axios.get("/projects");
const response = await axios.get("/projects/my");
dispatch(fetchProjectsSuccess(response.data));
} catch(e) {
dispatch(fetchProjectsError(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