p5.js-web-editor/client/modules/IDE/reducers/project.js

31 lines
702 B
JavaScript
Raw Normal View History

2016-06-22 21:58:23 +02:00
import * as ActionTypes from '../../../constants';
const initialState = {
2016-06-24 00:29:55 +02:00
name: 'Hello p5.js'
};
const project = (state = initialState, action) => {
2016-06-24 00:29:55 +02:00
switch (action.type) {
case ActionTypes.SET_PROJECT_NAME:
2016-07-15 17:54:47 +02:00
return Object.assign({}, { ...state }, { name: action.name });
2016-06-24 00:29:55 +02:00
case ActionTypes.NEW_PROJECT:
return {
id: action.id,
2016-07-15 17:54:47 +02:00
name: action.name,
owner: action.owner
2016-06-24 00:29:55 +02:00
};
case ActionTypes.SET_PROJECT:
return {
id: action.project.id,
2016-07-15 17:54:47 +02:00
name: action.project.name,
owner: action.owner
2016-06-24 00:29:55 +02:00
};
case ActionTypes.RESET_PROJECT:
return initialState;
2016-06-24 00:29:55 +02:00
default:
return state;
}
};
2016-06-24 00:29:55 +02:00
export default project;