47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import React from "react";
|
|
import { render } from "react-dom";
|
|
import SignIn from "./SignIn";
|
|
import Games from "./GameSetup";
|
|
import Store from "./interface/Store"
|
|
import * as Act from "./interface/Actions";
|
|
import "./Style/style.css";
|
|
|
|
export default class Index extends React.Component {
|
|
constructor() {
|
|
super()
|
|
this.state = { accs: Store.getAccess() }
|
|
this.getAuth = this.getAuth.bind(this)
|
|
//this.leaving = this.leaving.bind(this)
|
|
}
|
|
|
|
componentDidMount() {
|
|
//window.addEventListener('beforeunload', this.leaving);
|
|
Store.on("authChange", this.getAuth)
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
//window.removeEventListener('beforeunload', this.leaving);
|
|
Store.removeListener("authChange", this.getAuth)
|
|
}
|
|
|
|
//leaving() {
|
|
// Act.apiCall('logout', { });
|
|
//}
|
|
|
|
getAuth() {
|
|
this.setState({ accs: Store.getAccess() })
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div>
|
|
{this.state.accs.status > 0
|
|
? <Games />
|
|
: <SignIn msg={this.state.accs.msg}/>
|
|
}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
render(<Index />, document.getElementById('page')) |