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.
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));

View File

@ -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';

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