2022-01-14 21:00:04 +00:00
|
|
|
import { IActionSettings } from '../actions/settings';
|
2020-04-01 19:24:42 +00:00
|
|
|
import { SETTINGS } from '../actions/actionsTypes';
|
|
|
|
|
2022-01-14 21:00:04 +00:00
|
|
|
// TODO UPDATE SETTINGS TYPE
|
|
|
|
export type ISettings = Record<string, any>;
|
2020-04-01 19:24:42 +00:00
|
|
|
|
2022-01-14 21:00:04 +00:00
|
|
|
export const initialState: ISettings = {};
|
|
|
|
|
|
|
|
export default (state = initialState, action: IActionSettings): ISettings => {
|
2020-04-01 19:24:42 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SETTINGS.ADD:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
...action.payload
|
|
|
|
};
|
2021-07-01 19:30:55 +00:00
|
|
|
case SETTINGS.UPDATE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
[action.payload.id]: action.payload.value
|
|
|
|
};
|
2020-04-01 19:24:42 +00:00
|
|
|
case SETTINGS.CLEAR:
|
|
|
|
return initialState;
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|