2016-08-15 21:06:12 +00:00
|
|
|
import * as ActionTypes from '../../../constants';
|
|
|
|
|
|
|
|
const sketches = (state = [], action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.SET_PROJECTS:
|
|
|
|
return action.projects;
|
2016-10-12 18:24:53 +00:00
|
|
|
case ActionTypes.DELETE_PROJECT:
|
2017-02-22 19:29:35 +00:00
|
|
|
return state.filter(sketch =>
|
2018-05-05 00:22:39 +00:00
|
|
|
sketch.id !== action.id);
|
2019-06-19 20:21:25 +00:00
|
|
|
case ActionTypes.RENAME_PROJECT: {
|
|
|
|
return state.map((sketch) => {
|
|
|
|
if (sketch.id === action.payload.id) {
|
|
|
|
return { ...sketch, name: action.payload.name };
|
|
|
|
}
|
|
|
|
return { ...sketch };
|
|
|
|
});
|
|
|
|
}
|
2016-08-15 21:06:12 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default sketches;
|