From 27246ee3c8c94a7fd1eb6ed9b8713e73c64c81a7 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 23 Apr 2021 18:08:52 +0530 Subject: [PATCH] AdminD Reload Bug Fix --- admin-dashboard/src/actions/project.js | 4 ++-- admin-dashboard/src/pages/Project.js | 9 +++++---- backend/backend/api/project.js | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/admin-dashboard/src/actions/project.js b/admin-dashboard/src/actions/project.js index 7f0e5e184d..231e95a5e5 100644 --- a/admin-dashboard/src/actions/project.js +++ b/admin-dashboard/src/actions/project.js @@ -75,11 +75,11 @@ export const fetchProjectError = error => { }; // Calls the API to fetch a project. -export const fetchProject = projectId => async dispatch => { +export const fetchProject = slug => async dispatch => { dispatch(fetchProjectRequest()); try { - const response = await getApi(`project/projects/${projectId}`); + const response = await getApi(`project/projects/${slug}`); const projects = response.data; dispatch(fetchProjectSuccess(projects)); diff --git a/admin-dashboard/src/pages/Project.js b/admin-dashboard/src/pages/Project.js index 6b73a78719..848fcbb2af 100644 --- a/admin-dashboard/src/pages/Project.js +++ b/admin-dashboard/src/pages/Project.js @@ -30,10 +30,8 @@ class Project extends Component { } ready = async () => { - const { fetchProject } = this.props; - await fetchProject( - this.props.currentProject && this.props.currentProject._id - ); + const { fetchProject, slug } = this.props; + await fetchProject(slug); }; render() { @@ -249,11 +247,13 @@ const mapDispatchToProps = dispatch => { const mapStateToProps = (state, props) => { const project = state.project.project.project || {}; const projectUsers = state.project.projectTeam; + const { slug } = props.match.params; const currentProject = state.project.projects.projects.find(el => { return el.slug === props.match.params.slug; }); return { project, + slug, currentProject, projectUsers, adminNote: state.adminNote, @@ -274,6 +274,7 @@ Project.propTypes = { fetchProjectTeam: PropTypes.func.isRequired, projectUsers: PropTypes.object.isRequired, paginate: PropTypes.func.isRequired, + slug: PropTypes.string, }; Project.displayName = 'Project'; diff --git a/backend/backend/api/project.js b/backend/backend/api/project.js index 88e76baf54..d89821e7a1 100755 --- a/backend/backend/api/project.js +++ b/backend/backend/api/project.js @@ -839,14 +839,14 @@ router.get('/projects/allProjects', getUser, isUserMasterAdmin, async function( } }); -router.get('/projects/:projectId', getUser, isUserMasterAdmin, async function( +router.get('/projects/:slug', getUser, isUserMasterAdmin, async function( req, res ) { try { - const projectId = req.params.projectId; + const slug = req.params.slug; const project = await ProjectService.findOneBy({ - _id: projectId, + slug: slug, deleted: { $ne: null }, });