fix project saving bug

This commit is contained in:
catarak 2016-06-28 19:35:56 -04:00
parent 2481cc3f85
commit 21a2b25add
2 changed files with 10 additions and 10 deletions

View file

@ -10,7 +10,7 @@ export function getProject(id) {
.then(response => { .then(response => {
browserHistory.push(`/projects/${id}`); browserHistory.push(`/projects/${id}`);
dispatch({ dispatch({
type: ActionTypes.SET_PROJECT_NAME, type: ActionTypes.SET_PROJECT,
project: response.data project: response.data
}); });
}) })
@ -34,17 +34,17 @@ export function saveProject() {
const state = getState(); const state = getState();
const formParams = Object.assign({}, state.project); const formParams = Object.assign({}, state.project);
formParams.file = state.file; formParams.file = state.file;
if (state.id) { if (state.project.id) {
axios.put(`${ROOT_URL}/projects/${state.id}`, formParams, { withCredentials: true }) axios.put(`${ROOT_URL}/projects/${state.project.id}`, formParams, { withCredentials: true })
.then(() => { .then(() => {
dispatch({ dispatch({
type: ActionTypes.PROJECT_SAVE_SUCCESS type: ActionTypes.PROJECT_SAVE_SUCCESS
}) });
.catch((response) => dispatch({ })
type: ActionTypes.PROJECT_SAVE_FAIL, .catch((response) => dispatch({
error: response.data type: ActionTypes.PROJECT_SAVE_FAIL,
})); error: response.data
}); }));
} else { } else {
axios.post(`${ROOT_URL}/projects`, formParams, { withCredentials: true }) axios.post(`${ROOT_URL}/projects`, formParams, { withCredentials: true })
.then(response => { .then(response => {

View file

@ -22,7 +22,7 @@ export function createProject(req, res) {
} }
export function updateProject(req, res) { export function updateProject(req, res) {
Project.update({ _id: req.params.project_id }, Project.findByIdAndUpdate(req.params.project_id,
{ {
$set: req.body $set: req.body
}, (err, updatedProject) => { }, (err, updatedProject) => {