2022-12-15 13:44:49 -05:00

30 lines
642 B
TypeScript

import type { AnyAction } from 'redux';
export type GlobalUIState = {
isFetching: boolean;
};
const defaultState: GlobalUIState = {
isFetching: false,
};
/**
* Reducer for some global UI state that we want to share between components
*/
const globalUI = (state: GlobalUIState = defaultState, action: AnyAction): GlobalUIState => {
// Generic, global loading indicator
if (action.type.includes('REQUEST')) {
return {
isFetching: true,
};
} else if (action.type.includes('SUCCESS') || action.type.includes('FAILURE')) {
return {
isFetching: false,
};
}
return state;
};
export default globalUI;