mirror of
https://gitlab.com/comunic/comunicconsole
synced 2025-07-07 18:42:49 +00:00
Can get current account information
This commit is contained in:
@ -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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user