2016-06-22 19:58:23 +00:00
|
|
|
import * as ActionTypes from '../../../constants';
|
2016-06-16 20:07:38 +00:00
|
|
|
|
|
|
|
const initialState = {
|
2016-06-23 22:29:55 +00:00
|
|
|
name: 'Hello p5.js'
|
|
|
|
};
|
2016-06-16 20:07:38 +00:00
|
|
|
|
|
|
|
const project = (state = initialState, action) => {
|
2016-06-23 22:29:55 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.SET_PROJECT_NAME:
|
2016-07-15 15:54:47 +00:00
|
|
|
return Object.assign({}, { ...state }, { name: action.name });
|
2016-06-23 22:29:55 +00:00
|
|
|
case ActionTypes.NEW_PROJECT:
|
|
|
|
return {
|
|
|
|
id: action.id,
|
2016-07-15 15:54:47 +00:00
|
|
|
name: action.name,
|
|
|
|
owner: action.owner
|
2016-06-23 22:29:55 +00:00
|
|
|
};
|
|
|
|
case ActionTypes.SET_PROJECT:
|
|
|
|
return {
|
|
|
|
id: action.project.id,
|
2016-07-15 15:54:47 +00:00
|
|
|
name: action.project.name,
|
|
|
|
owner: action.owner
|
2016-06-23 22:29:55 +00:00
|
|
|
};
|
2016-08-12 16:45:26 +00:00
|
|
|
case ActionTypes.RESET_PROJECT:
|
|
|
|
return initialState;
|
2016-08-15 16:42:13 +00:00
|
|
|
case ActionTypes.SHOW_EDIT_PROJECT_NAME:
|
|
|
|
return Object.assign({}, state, { isEditingName: true });
|
|
|
|
case ActionTypes.HIDE_EDIT_PROJECT_NAME:
|
|
|
|
return Object.assign({}, state, { isEditingName: false });
|
2016-06-23 22:29:55 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
2016-06-16 20:07:38 +00:00
|
|
|
|
2016-06-23 22:29:55 +00:00
|
|
|
export default project;
|