static-cms/core/src/reducers/globalUI.ts
Daniel Lautzenheiser 421ecf17e6
Feature/website overhaul (#49)
* Reorganize repo
* Overhaul website design and rewrite in NextJS and Typescript
* Delete website-publish.yml
2022-10-25 09:18:18 -04: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;