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-03-02 14:18:01 +00:00
|
|
|
export type TSettings = string | number | boolean | string[];
|
2022-01-20 17:41:04 +00:00
|
|
|
|
|
|
|
export type ISettings = Record<string, TSettings>;
|
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;
|
|
|
|
}
|
|
|
|
};
|