comunicconsole/src/ui/widgets/InitWidget.tsx

48 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-05-10 19:03:42 +02:00
/**
* Initialization widget
*
* @author Pierre Hubert
*/
import React from "react";
2021-05-11 17:57:29 +02:00
import { AccountHelper } from "../../helpers/AccountHelper";
import { LoginRoute } from "../routes/LoginRoute";
2021-05-10 19:03:42 +02:00
import { AsyncWidget } from "./AsyncWidget";
2021-05-11 17:57:29 +02:00
interface InitWidgetState {
signedIn: boolean,
}
2021-05-10 19:03:42 +02:00
2021-05-11 17:57:29 +02:00
export class InitWidget extends React.Component<{}, InitWidgetState> {
2021-05-10 19:03:42 +02:00
constructor(props: any) {
super(props);
2021-05-11 17:57:29 +02:00
this.state = {
signedIn: false
};
2021-05-10 19:03:42 +02:00
this.init = this.init.bind(this);
this.build = this.build.bind(this);
}
async init() {
2021-05-11 17:57:29 +02:00
this.setState({ signedIn: false });
if (AccountHelper.hasAccessToken) {
throw Error("UNIMPLEMENTED!");
}
2021-05-10 19:03:42 +02:00
}
render() {
return (<AsyncWidget
errorMessage = "Failed to initialize application!"
load = {this.init}
onBuild = {this.build}
></AsyncWidget>);
}
build() {
2021-05-11 17:57:29 +02:00
return this.state.signedIn ? null : (<LoginRoute></LoginRoute>);
2021-05-10 19:03:42 +02:00
}
}