2022-02-02 17:46:05 +00:00
|
|
|
import { TActionsShare } from '../actions/share';
|
|
|
|
import { SHARE } from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
export interface IShareServer {
|
2022-03-16 20:40:32 +00:00
|
|
|
server?: string;
|
|
|
|
version?: string;
|
2022-02-02 17:46:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type TShareSettings = Record<string, string | number | boolean>;
|
|
|
|
|
|
|
|
export interface IShareUser {
|
2022-03-16 20:40:32 +00:00
|
|
|
id?: string;
|
|
|
|
token?: string;
|
|
|
|
username?: string;
|
|
|
|
roles?: string[];
|
2022-02-02 17:46:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IShare {
|
2022-02-09 21:16:20 +00:00
|
|
|
user: IShareUser;
|
|
|
|
server: IShareServer;
|
2022-02-02 17:46:05 +00:00
|
|
|
settings: TShareSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: IShare = {
|
2022-03-16 20:40:32 +00:00
|
|
|
user: {},
|
|
|
|
server: {},
|
2022-02-02 17:46:05 +00:00
|
|
|
settings: {}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function share(state = initialState, action: TActionsShare): IShare {
|
|
|
|
switch (action.type) {
|
|
|
|
case SHARE.SELECT_SERVER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
server: action.server
|
|
|
|
};
|
|
|
|
case SHARE.SET_USER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
user: action.user
|
|
|
|
};
|
|
|
|
case SHARE.SET_SETTINGS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
settings: action.settings
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|