Migrated settings module to TS

This commit is contained in:
Alejandro Celaya
2020-08-24 17:32:20 +02:00
parent 0b4a348969
commit fefa4e7848
7 changed files with 40 additions and 40 deletions

View File

@@ -0,0 +1,27 @@
import { handleActions } from 'redux-actions';
import { Action } from 'redux';
export const SET_REAL_TIME_UPDATES = 'shlink/realTimeUpdates/SET_REAL_TIME_UPDATES';
interface RealTimeUpdates {
enabled: boolean;
}
export interface Settings {
realTimeUpdates: RealTimeUpdates;
}
const initialState: Settings = {
realTimeUpdates: {
enabled: true,
},
};
export default handleActions<Settings, any>({
[SET_REAL_TIME_UPDATES]: (state, { realTimeUpdates }: any) => ({ ...state, realTimeUpdates }),
}, initialState);
export const setRealTimeUpdates = (enabled: boolean): Action & Settings => ({
type: SET_REAL_TIME_UPDATES,
realTimeUpdates: { enabled },
});