Files
CS307-Team24/twistter-frontend/src/redux/reducers/uiReducer.js

30 lines
686 B
JavaScript

import { SET_ERRORS, CLEAR_ERRORS, LOADING_UI } from '../types';
const initialState = {
loading: false,
errors: null
};
export default function(state = initialState, action) {
switch(action.type) {
case SET_ERRORS:
return {
...state,
loading: false,
errors: action.payload
};
case CLEAR_ERRORS:
return {
...state,
loading: false,
errors: null
};
case LOADING_UI:
return {
...state,
loading: true
}
default:
return state;
}
}