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