redux store of builder

This commit is contained in:
Delucse
2020-09-18 16:19:18 +02:00
parent 1c2b025493
commit 458770e0c4
4 changed files with 144 additions and 1 deletions
+48
View File
@@ -0,0 +1,48 @@
import { BUILDER_CHANGE, BUILDER_TITLE, BUILDER_ID, BUILDER_ADD_STEP, BUILDER_DELETE_STEP, BUILDER_CHANGE_STEP,BUILDER_CHANGE_ORDER, BUILDER_DELETE_PROPERTY } from '../actions/types';
const initialState = {
change: 0,
title: '',
id: 0,
steps: [
{
id: 1,
type: 'instruction',
headline: '',
text: '',
hardware: [],
requirements: []
}
]
};
export default function(state = initialState, action){
switch(action.type){
case BUILDER_CHANGE:
return {
...state,
change: state.change += 1
};
case BUILDER_TITLE:
return {
...state,
title: action.payload
};
case BUILDER_ID:
return {
...state,
id: action.payload
};
case BUILDER_ADD_STEP:
case BUILDER_DELETE_STEP:
case BUILDER_CHANGE_STEP:
case BUILDER_CHANGE_ORDER:
case BUILDER_DELETE_PROPERTY:
return {
...state,
steps: action.payload
};
default:
return state;
}
}