blob: fe84f9af06d630617e6a1747c1b2c1733b85f44d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import React, { Component } from 'react';
import fetch from 'node-fetch';
import PropTypes from 'prop-types';
import { Alert, Badge } from 'react-bootstrap';
import ManageServerSettings from '../components/manageserver/ManageServerSettings';
export default class ManageServer extends Component {
constructor(props) {
super(props)
this.state = {
loading: true,
data: null
}
this.handleInput = this.handleInput.bind(this);
}
componentDidMount() {
fetch(`http://localhost:8088/v1/get/guild/${this.props.match.params.id}`)
.then(res => res.json())
.then(res => this.setState({
loading: false,
data: res.message ? null : res
}))
.catch(() => this.setState({ loading: false }));
}
handleInput(event) {
const eventId = event.target.id;
const value = event.target.value;
this.setState(prevState => ({
data: {
...prevState.data,
[eventId]: value
}
}));
}
render() {
if (this.state.loading) {
return(
<h1>Loading...</h1>
);
} else if(!this.state.data) {
return(
// <MDBAlert color="warning">This bot is not in this server</MDBAlert>
<Alert variant="warning">Aki is not in this server!</Alert>
);
} else {
return(
<React.Fragment>
<h1><strong>{this.state.data.name}</strong></h1>
<Badge variant="primary">{`${this.state.data.members} Members`}</Badge>
<Badge variant="success">{`Owner: ${this.state.data.owner}`}</Badge>
<hr />
<ManageServerSettings data={this.state.data} handleInput={this.handleInput} guild={this.props.match.params.id} />
</React.Fragment>
)
}
}
}
ManageServer.propTypes = {
user: PropTypes.object
}
|