openethereum/js/src/dapps/registry/Records/reducers.js
2016-10-31 23:28:49 +01:00

30 lines
683 B
JavaScript

const initialState = {
hasAccount: false,
pending: false,
name: '', type: '', value: ''
};
export default (state = initialState, action) => {
if (action.type === 'accounts select') {
return { ...state, hasAccount: !!action.address };
}
if (action.type === 'records update start') {
return {
...state,
pending: true,
name: action.name, type: action.entry, value: action.value
};
}
if (action.type === 'records update error' || action.type === 'records update success') {
return {
...state,
pending: false,
name: initialState.name, type: initialState.type, value: initialState.value
};
}
return state;
};