AdminD Reload Bug Fix

This commit is contained in:
Abhishek 2021-04-23 18:08:52 +05:30
parent 77ec1b93f5
commit 27246ee3c8
3 changed files with 10 additions and 9 deletions

View File

@ -75,11 +75,11 @@ export const fetchProjectError = error => {
}; };
// Calls the API to fetch a project. // Calls the API to fetch a project.
export const fetchProject = projectId => async dispatch => { export const fetchProject = slug => async dispatch => {
dispatch(fetchProjectRequest()); dispatch(fetchProjectRequest());
try { try {
const response = await getApi(`project/projects/${projectId}`); const response = await getApi(`project/projects/${slug}`);
const projects = response.data; const projects = response.data;
dispatch(fetchProjectSuccess(projects)); dispatch(fetchProjectSuccess(projects));

View File

@ -30,10 +30,8 @@ class Project extends Component {
} }
ready = async () => { ready = async () => {
const { fetchProject } = this.props; const { fetchProject, slug } = this.props;
await fetchProject( await fetchProject(slug);
this.props.currentProject && this.props.currentProject._id
);
}; };
render() { render() {
@ -249,11 +247,13 @@ const mapDispatchToProps = dispatch => {
const mapStateToProps = (state, props) => { const mapStateToProps = (state, props) => {
const project = state.project.project.project || {}; const project = state.project.project.project || {};
const projectUsers = state.project.projectTeam; const projectUsers = state.project.projectTeam;
const { slug } = props.match.params;
const currentProject = state.project.projects.projects.find(el => { const currentProject = state.project.projects.projects.find(el => {
return el.slug === props.match.params.slug; return el.slug === props.match.params.slug;
}); });
return { return {
project, project,
slug,
currentProject, currentProject,
projectUsers, projectUsers,
adminNote: state.adminNote, adminNote: state.adminNote,
@ -274,6 +274,7 @@ Project.propTypes = {
fetchProjectTeam: PropTypes.func.isRequired, fetchProjectTeam: PropTypes.func.isRequired,
projectUsers: PropTypes.object.isRequired, projectUsers: PropTypes.object.isRequired,
paginate: PropTypes.func.isRequired, paginate: PropTypes.func.isRequired,
slug: PropTypes.string,
}; };
Project.displayName = 'Project'; Project.displayName = 'Project';

View File

@ -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, req,
res res
) { ) {
try { try {
const projectId = req.params.projectId; const slug = req.params.slug;
const project = await ProjectService.findOneBy({ const project = await ProjectService.findOneBy({
_id: projectId, slug: slug,
deleted: { $ne: null }, deleted: { $ne: null },
}); });