diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /client/src/components/App.js | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'client/src/components/App.js')
| -rw-r--r-- | client/src/components/App.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/client/src/components/App.js b/client/src/components/App.js new file mode 100644 index 0000000..270e199 --- /dev/null +++ b/client/src/components/App.js @@ -0,0 +1,61 @@ +import React, { Component } from 'react'; +import { BrowserRouter as Router, Route } from 'react-router-dom'; +import fetch from 'node-fetch'; + +import NavigationBar from './navigation/NavigationBar'; +import ServerSelection from '../pages/ServerSelection'; +import ManageServer from '../pages/ManageServer'; + +export default class App extends Component { + state = { + loading: true, + user: null + } + + componentDidMount() { + fetch('http://localhost:8088/oauth/details', { + credentials: 'include' + }) + .then(res => res.json()) + .then(res => { + if (!res) return this.setState({ loading: false }); + this.setState({ + loading: false, + user: res + }) + }) + .catch(() => this.setState({ loading: false })); + } + + render() { + if (this.state.loading) { + return( + <React.Fragment> + <div className="container"> + <h1>Loading...</h1> + </div> + </React.Fragment> + ); + } else if (!this.state.user) { + window.location.replace('http://localhost:8088/oauth/login'); // OAuth2... + return (<React.Fragment />); + } else { + return( + <React.Fragment> + <Router> + <div className="container"> + <NavigationBar user={this.state.user} /> + + <br /> + + <Route exact path="/" render={(props) => <ServerSelection {...props} user={this.state.user} /> } /> + <Route exact path="/server/:id" render={(props) => <ManageServer {...props} user={this.state.user} /> } /> + + <br /> + </div> + </Router> + </React.Fragment> + ); + } + } +}
\ No newline at end of file |