Skip to content

Commit e04d448

Browse files
LakshSinglacatarak
authored andcommitted
[WIP] Updating rename functionality
1 parent b8416e6 commit e04d448

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

client/modules/IDE/actions/project.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,31 @@ export function setProjectSavedTime(updatedAt) {
309309
value: updatedAt
310310
};
311311
}
312+
313+
export function changeProjectName(id, newName) {
314+
return (dispatch, getState) => {
315+
const state = getState();
316+
axios.put(`${ROOT_URL}/projects/${id}`, { name: newName }, { withCredentials: true })
317+
.then((response) => {
318+
if (response.status === 200) {
319+
dispatch({
320+
type: ActionTypes.RENAME_PROJECT,
321+
payload: { id: response.data.id, name: response.data.name }
322+
});
323+
if (state.project.id === response.data.id) {
324+
dispatch({
325+
type: ActionTypes.SET_PROJECT_NAME,
326+
name: response.data.name
327+
});
328+
}
329+
}
330+
})
331+
.catch((response) => {
332+
console.log(response);
333+
dispatch({
334+
type: ActionTypes.PROJECT_SAVE_FAIL,
335+
error: response.data
336+
});
337+
});
338+
};
339+
}

0 commit comments

Comments
 (0)