Can get current account information

This commit is contained in:
2021-05-12 17:31:44 +02:00
parent 05117e71a3
commit cd7cc0e5e4
3 changed files with 90 additions and 33 deletions

View File

@ -1,6 +1,6 @@
/**
* Initialization widget
*
*
* @author Pierre Hubert
*/
@ -10,39 +10,45 @@ import { LoginRoute } from "../routes/LoginRoute";
import { AsyncWidget } from "./AsyncWidget";
interface InitWidgetState {
signedIn: boolean,
signedIn: boolean;
}
export class InitWidget extends React.Component<{}, InitWidgetState> {
constructor(props: any) {
super(props);
constructor(props: any) {
super(props);
this.state = {
signedIn: false,
};
this.state = {
signedIn: false
};
this.init = this.init.bind(this);
this.build = this.build.bind(this);
}
this.init = this.init.bind(this);
this.build = this.build.bind(this);
}
async init() {
this.setState({ signedIn: false });
async init() {
this.setState({ signedIn: false });
if (AccountHelper.hasAccessToken) {
await AccountHelper.refreshCurrentAccountInfo();
this.setState({ signedIn: true });
}
}
if (AccountHelper.hasAccessToken) {
throw Error("UNIMPLEMENTED!");
}
}
render() {
return (
<AsyncWidget
errorMessage="Failed to initialize application!"
load={this.init}
onBuild={this.build}
></AsyncWidget>
);
}
render() {
return (<AsyncWidget
errorMessage = "Failed to initialize application!"
load = {this.init}
onBuild = {this.build}
></AsyncWidget>);
}
build() {
return this.state.signedIn ? null : (<LoginRoute></LoginRoute>);
}
}
build() {
return this.state.signedIn ? (
<div>{AccountHelper.currentAccount.name}</div>
) : (
<LoginRoute></LoginRoute>
);
}
}