blob: 3bdfaaa87ca032936990f693269ce27715cbaaa9 [file] [log] [blame]
Adrien Béraudab519ff2022-05-03 15:34:48 -04001import React from 'react'
Adrien Béraud4e287b92021-04-24 16:15:56 -04002import Header from '../components/Header'
3import AccountPreferences from '../components/AccountPreferences'
Adrien Béraudab519ff2022-05-03 15:34:48 -04004import Container from '@mui/material/Container'
5import CircularProgress from '@mui/material/CircularProgress'
Adrien Béraud4e287b92021-04-24 16:15:56 -04006import authManager from '../AuthManager'
7import Account from '../../../model/Account'
8
9const ServerOverview = (props) => {
10
Adrien Béraudab519ff2022-05-03 15:34:48 -040011 this.accountId = props.accountId || props.match.params.accountId
12 this.state = { loaded: false, account: props.account }
13 this.req = undefined
Adrien Béraud4e287b92021-04-24 16:15:56 -040014
Adrien Béraudab519ff2022-05-03 15:34:48 -040015 useEffect(() => {
16 const controller = new AbortController()
17 authManager.fetch(`/api/serverConfig`, {signal: controller.signal})
18 .then(res => res.json())
19 .then(result => {
20 console.log(result)
21 setState({loaded: true, account: Account.from(result)})
22 }).catch(e => console.log(e))
23 return () => controller.abort()
24 }, [accountId])
25
26 /*componentDidMount() {
Adrien Béraud4e287b92021-04-24 16:15:56 -040027 this.controller = new AbortController()
28 if (this.req === undefined) {
29 this.req = authManager.fetch(`/api/serverConfig`, {signal: this.controller.signal})
30 .then(res => res.json())
31 .then(result => {
32 console.log(result)
33 this.setState({loaded: true, account: Account.from(result)})
34 })
35 }
36 }
37
38 componentWillUnmount() {
39 this.controller.abort()
40 this.req = undefined
Adrien Béraudab519ff2022-05-03 15:34:48 -040041 }*/
Adrien Béraud4e287b92021-04-24 16:15:56 -040042
43 return (
44 <Container maxWidth="sm" className="app" >
45 <Header />
46 {this.state.loaded ? <AccountPreferences account={this.state.account} /> : <CircularProgress />}
47 </Container>
48 )
49}
50
Adrien Béraudab519ff2022-05-03 15:34:48 -040051export default ServerOverview