From 21a2b25add963f9e96abc7233dc852ca61b90df6 Mon Sep 17 00:00:00 2001 From: catarak Date: Tue, 28 Jun 2016 19:35:56 -0400 Subject: [PATCH] fix project saving bug --- client/modules/IDE/actions/project.js | 18 +++++++++--------- server/controllers/project.controller.js | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index e656907d..af2b580d 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -10,7 +10,7 @@ export function getProject(id) { .then(response => { browserHistory.push(`/projects/${id}`); dispatch({ - type: ActionTypes.SET_PROJECT_NAME, + type: ActionTypes.SET_PROJECT, project: response.data }); }) @@ -34,17 +34,17 @@ export function saveProject() { const state = getState(); const formParams = Object.assign({}, state.project); formParams.file = state.file; - if (state.id) { - axios.put(`${ROOT_URL}/projects/${state.id}`, formParams, { withCredentials: true }) + if (state.project.id) { + axios.put(`${ROOT_URL}/projects/${state.project.id}`, formParams, { withCredentials: true }) .then(() => { dispatch({ type: ActionTypes.PROJECT_SAVE_SUCCESS - }) - .catch((response) => dispatch({ - type: ActionTypes.PROJECT_SAVE_FAIL, - error: response.data - })); - }); + }); + }) + .catch((response) => dispatch({ + type: ActionTypes.PROJECT_SAVE_FAIL, + error: response.data + })); } else { axios.post(`${ROOT_URL}/projects`, formParams, { withCredentials: true }) .then(response => { diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index 30c06d93..376e3a8f 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -22,7 +22,7 @@ export function createProject(req, res) { } export function updateProject(req, res) { - Project.update({ _id: req.params.project_id }, + Project.findByIdAndUpdate(req.params.project_id, { $set: req.body }, (err, updatedProject) => {