2022-01-14 21:00:04 +00:00
|
|
|
import { Action } from 'redux';
|
|
|
|
|
2022-03-02 14:49:43 +00:00
|
|
|
import { TSettingsState, TSupportedSettings, TSettingsValues } from '../reducers/settings';
|
2022-01-14 21:00:04 +00:00
|
|
|
import { SETTINGS } from './actionsTypes';
|
|
|
|
|
|
|
|
interface IAddSettings extends Action {
|
2022-03-02 14:49:43 +00:00
|
|
|
payload: TSettingsState;
|
2022-01-14 21:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IUpdateSettings extends Action {
|
2022-03-02 14:49:43 +00:00
|
|
|
payload: { id: TSupportedSettings; value: TSettingsValues };
|
2022-01-14 21:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type IActionSettings = IAddSettings & IUpdateSettings;
|
|
|
|
|
2022-03-02 14:49:43 +00:00
|
|
|
export function addSettings(settings: TSettingsState): IAddSettings {
|
2022-01-14 21:00:04 +00:00
|
|
|
return {
|
|
|
|
type: SETTINGS.ADD,
|
|
|
|
payload: settings
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-02 14:49:43 +00:00
|
|
|
export function updateSettings(id: TSupportedSettings, value: TSettingsValues): IUpdateSettings {
|
2022-01-14 21:00:04 +00:00
|
|
|
return {
|
|
|
|
type: SETTINGS.UPDATE,
|
|
|
|
payload: { id, value }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function clearSettings(): Action {
|
|
|
|
return {
|
|
|
|
type: SETTINGS.CLEAR
|
|
|
|
};
|
|
|
|
}
|