redux store of builder
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user