Skip to content

Commit 4d22850

Browse files
authored
Merge pull request #177 from dedis/frontend-2022-khadija
Add types in index.tsx
2 parents 14900a8 + 8df5987 commit 4d22850

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

web/frontend/src/index.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,25 @@ class FlashMessage {
6969
return this.level;
7070
}
7171
}
72-
72+
const flashM = new FlashMessage('', 1);
73+
const defaultFlashState = {
74+
getMessages: function (): FlashMessage[] {
75+
return [flashM];
76+
},
77+
addMessage: function (msg: string, level: FlashLevel): void {},
78+
hideMessage: function (index: string): void {},
79+
};
7380
// the flash context handles flash messages across the app
74-
export const FlashContext = createContext<FlashState>(undefined);
81+
export const FlashContext = createContext<FlashState>(defaultFlashState);
7582

7683
// the proxy state provides the proxy address across all the app
7784
export interface ProxyState {
7885
getProxy(): string;
79-
setProxy(p: string);
86+
setProxy(p: string): void;
8087
}
8188

8289
export class ProxyHolder implements ProxyState {
83-
proxy: string;
90+
proxy!: string;
8491

8592
getProxy(): string {
8693
return this.proxy;
@@ -145,7 +152,7 @@ const Failed: FC = ({ children }) => (
145152
// and displays flash messages.
146153
const AppContainer = () => {
147154
const [content, setContent] = useState<ReactElement>(<Loading />);
148-
const [auth, setAuth] = useState<AuthState>(undefined);
155+
const [auth, setAuth] = useState<AuthState>(defaultAuth);
149156

150157
const [flashes, setFlashes] = useState<FlashMessage[]>([]);
151158

@@ -226,7 +233,7 @@ const AppContainer = () => {
226233
await setDefaultProxy();
227234

228235
setContent(<App />);
229-
} catch (e) {
236+
} catch (e: any) {
230237
setContent(<Failed>{e.toString()}</Failed>);
231238
console.log('error:', e);
232239
}

0 commit comments

Comments
 (0)