blob: ba99fe6d5b2fbfefa181650df1df699d4902e67f [file] [log] [blame]
Adrien BĂ©raud4e287b92021-04-24 16:15:56 -04001import React from 'react';
2import Header from '../components/Header'
3import AccountPreferences from '../components/AccountPreferences'
4import Container from '@material-ui/core/Container';
5import CircularProgress from '@material-ui/core/CircularProgress';
6import authManager from '../AuthManager'
7import Account from '../../../model/Account'
8
9const ServerOverview = (props) => {
10
11 this.accountId = props.accountId || props.match.params.accountId
12 this.state = { loaded: false, account: props.account }
13 this.req = undefined
14
15 componentDidMount() {
16 this.controller = new AbortController()
17 if (this.req === undefined) {
18 this.req = authManager.fetch(`/api/serverConfig`, {signal: this.controller.signal})
19 .then(res => res.json())
20 .then(result => {
21 console.log(result)
22 this.setState({loaded: true, account: Account.from(result)})
23 })
24 }
25 }
26
27 componentWillUnmount() {
28 this.controller.abort()
29 this.req = undefined
30 }
31
32 return (
33 <Container maxWidth="sm" className="app" >
34 <Header />
35 {this.state.loaded ? <AccountPreferences account={this.state.account} /> : <CircularProgress />}
36 </Container>
37 )
38}
39
40export default ServerOverview;