update
This commit is contained in:
@@ -1,54 +1,23 @@
|
||||
import { Component } from "react";
|
||||
import { useEffect, useState } from 'react';
|
||||
import userService from '../services/user.service';
|
||||
|
||||
import UserService from "../services/user.service";
|
||||
import EventBus from "../common/EventBus";
|
||||
export default function BoardAdmin() {
|
||||
const [content, setContent] = useState('');
|
||||
|
||||
type Props = {};
|
||||
|
||||
type State = {
|
||||
content: string;
|
||||
}
|
||||
|
||||
export default class BoardAdmin extends Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
content: ""
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
UserService.getAdminBoard().then(
|
||||
response => {
|
||||
this.setState({
|
||||
content: response.data
|
||||
});
|
||||
useEffect(() => {
|
||||
userService.getAdminBoard().then(
|
||||
(res) => setContent(String(res.data ?? '')),
|
||||
(error: unknown) => {
|
||||
setContent(error instanceof Error ? error.message : String(error));
|
||||
},
|
||||
error => {
|
||||
this.setState({
|
||||
content:
|
||||
(error.response &&
|
||||
error.response.data &&
|
||||
error.response.data.message) ||
|
||||
error.message ||
|
||||
error.toString()
|
||||
});
|
||||
|
||||
if (error.response && error.response.status === 401) {
|
||||
EventBus.dispatch("logout");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="container">
|
||||
<header className="jumbotron">
|
||||
<h3>{this.state.content}</h3>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="container">
|
||||
<header className="jumbotron">
|
||||
<h3>{content}</h3>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user