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 => {
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
}));
});
} else {
axios.post(`${ROOT_URL}/projects`, formParams, { withCredentials: true })
.then(response => {

View file

@ -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) => {