-
Notifications
You must be signed in to change notification settings - Fork 0
/
globalUIState.ts
62 lines (56 loc) · 1.68 KB
/
globalUIState.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import Cookies from "js-cookie";
import { ILingoContents } from "../../lingos/interfaces";
import { getDefaultLang } from '../../windowVars';
// import { changeLang } from "../actions/globalUIAction";
import { fromStorage, StorageKey } from "../libs/storage";
import { changeLang } from "../slices/globalUISlice";
import { EWaitingFor } from './../enums/system';
import { State } from "./index";
export interface PopUpDialog {
popup: boolean;
content: string;
closeButton: boolean;
goHomeButton: boolean;
}
export interface GlobalUIState extends State {
lang: string;
openSystemDialog: boolean;
reconnectDialog: boolean;
errorCode: number;
popUpDialog: PopUpDialog;
waitingList: EWaitingFor[];
languageConfig: ILingoContents;
supportedLanguages: string[];
}
export const createGlobalUIState = (): GlobalUIState => {
let langStr = Cookies.get(StorageKey.LANGUAGE);
if (!langStr || langStr === "") {
langStr = fromStorage(StorageKey.LANGUAGE, getDefaultLang());
}
const lang = langStr;
changeLang(lang);
const openSystemDialog = false;
const reconnectDialog = false;
const errorCode = 0;
const popUpDialog: PopUpDialog = {
popup: false,
content: '',
closeButton: false,
goHomeButton: false,
};
let state: GlobalUIState = {
lang,
openSystemDialog,
reconnectDialog,
errorCode,
popUpDialog,
waitingList: [],
languageConfig: {
"en": null,
"tc": null,
"sc": null,
},
supportedLanguages: [],
};
return state;
};