Commit ff13887b authored by Ermolaev Timur's avatar Ermolaev Timur

Merge branch 'task-157-fix/delete_project_page' into 'development'

Task 157 fix/delete project page

See merge request !127
parents ecd467fb 9bb4de5d
...@@ -49,7 +49,6 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> { ...@@ -49,7 +49,6 @@ router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
/**create new project */ /**create new project */
router.post('/',auth, async (req:Request, res:Response): Promise<Response> => { router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'}) if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'})
const {user, title,color}= req.body; const {user, title,color}= req.body;
...@@ -86,6 +85,7 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => { ...@@ -86,6 +85,7 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
}) })
/**get project with all FK & tasks with all FK, by project ID */ /**get project with all FK & tasks with all FK, by project ID */
router.get("/:id",async (req:Request, res:Response): Promise<Response> => { router.get("/:id",async (req:Request, res:Response): Promise<Response> => {
const project = await dataSource const project = await dataSource
.createQueryBuilder() .createQueryBuilder()
.select("project") .select("project")
......
...@@ -27,8 +27,6 @@ const FullProject = ({ projectId }) => { ...@@ -27,8 +27,6 @@ const FullProject = ({ projectId }) => {
useEffect(() => { useEffect(() => {
if (projectId) { if (projectId) {
dispatch(fetchProject(projectId)) dispatch(fetchProject(projectId))
} else {
dispatch(fetchProject(params.id))
} }
dispatch(fetchUsers()) dispatch(fetchUsers())
}, [params.id, dispatch, projectId]); }, [params.id, dispatch, projectId]);
......
...@@ -32,8 +32,9 @@ const Projects = () => { ...@@ -32,8 +32,9 @@ const Projects = () => {
}, []) }, [])
const createNewProjectHandler = useCallback(() => { const createNewProjectHandler = useCallback(() => {
dispatch(createProject({ title: projectTitle, user: user.id }, navigate)) dispatch(createProject({ title: projectTitle, user: user.id }))
}, [dispatch, projectTitle, user.id, navigate]) setModal(false)
}, [dispatch, projectTitle, user.id])
const deleteProjectHandler = useCallback((e, projectId) => { const deleteProjectHandler = useCallback((e, projectId) => {
e.stopPropagation(); e.stopPropagation();
...@@ -49,7 +50,7 @@ const Projects = () => { ...@@ -49,7 +50,7 @@ const Projects = () => {
}, []) }, [])
console.log(currentProject)
return <> return <>
<Grid container justifyContent='space-between'> <Grid container justifyContent='space-between'>
...@@ -62,7 +63,7 @@ const Projects = () => { ...@@ -62,7 +63,7 @@ const Projects = () => {
/> />
<Grid item xs={7} > <Grid item xs={7} >
{currentProject ? <FullProject projectId={currentProject?.id} /> : null} {currentProject ? <FullProject projectId={currentProject?.id ? currentProject?.id : null} /> : null}
</Grid> </Grid>
</Grid> </Grid>
......
...@@ -96,12 +96,12 @@ export const fetchProject = (id) => { ...@@ -96,12 +96,12 @@ export const fetchProject = (id) => {
} }
}; };
export const createProject = (projectData, navigate) => { export const createProject = (projectData) => {
return async (dispatch) => { return async (dispatch) => {
try { try {
const response = await axios.post("/projects", projectData); await axios.post("/projects", projectData);
dispatch(createProjectSuccess()); dispatch(createProjectSuccess());
navigate("/projects/" + response.data.project.id) dispatch(fetchProjects())
dispatch(showNotification("Проект успешно создан")) dispatch(showNotification("Проект успешно создан"))
} catch (e) { } catch (e) {
console.log(e); console.log(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