mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-09 08:32:48 +00:00
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { IUserEventLog } from '../../model';
|
|
import { UserEventLogService } from '../../services';
|
|
|
|
interface IState {
|
|
userEventLogs: IUserEventLog[];
|
|
}
|
|
|
|
export class UserEventLog extends React.Component<unknown, IState> {
|
|
constructor(props: unknown) {
|
|
super(props);
|
|
this.state = {
|
|
userEventLogs: [],
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
UserEventLogService.getUserEventLogs().then((userEventLogs) => {
|
|
this.setState({
|
|
userEventLogs,
|
|
});
|
|
});
|
|
}
|
|
|
|
renderUserEventLogs() {
|
|
return this.state.userEventLogs.map(({ id, user, content, created_at }, index) => {
|
|
return (
|
|
<tr key={index}>
|
|
<td>{id}</td>
|
|
<td>{created_at}</td>
|
|
<td>{user.username}</td>
|
|
<td>{content}</td>
|
|
</tr>
|
|
);
|
|
});
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="content">
|
|
<div className="card">
|
|
<div className="card__header">User Event Log</div>
|
|
<table className="table">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Timestamp</th>
|
|
<th>User</th>
|
|
<th>Content</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>{this.renderUserEventLogs()}</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|