]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/chat-bot-logs/Dialog.js
add myustery circus link
[alttp.git] / resources / js / components / chat-bot-logs / Dialog.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Alert, Button, Modal } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
5
6 import List from './List';
7 import i18n from '../../i18n';
8
9 class Dialog extends React.Component {
10
11         componentDidMount() {
12                 this.timer = setInterval(() => {
13                         this.forceUpdate();
14                 }, 30000);
15         }
16
17         componentWillUnmount() {
18                 clearInterval(this.timer);
19         }
20
21         render() {
22                 const {
23                         log,
24                         onHide,
25                         show,
26                 } = this.props;
27                 return <Modal className="chat-bot-log-dialog" onHide={onHide} show={show} size="lg">
28                         <Modal.Header closeButton>
29                                 <Modal.Title>
30                                         {i18n.t('chatBotLog.heading')}
31                                 </Modal.Title>
32                         </Modal.Header>
33                         {log && log.length ?
34                                 <List log={log} />
35                         :
36                                 <Modal.Body>
37                                         <Alert variant="info">
38                                                 {i18n.t('chatBotLog.empty')}
39                                         </Alert>
40                                 </Modal.Body>
41                         }
42                         <Modal.Footer>
43                                 <Button onClick={onHide} variant="secondary">
44                                         {i18n.t('button.close')}
45                                 </Button>
46                         </Modal.Footer>
47                 </Modal>;
48         }
49
50 }
51
52 Dialog.propTypes = {
53         log: PropTypes.arrayOf(PropTypes.shape({
54         })),
55         onHide: PropTypes.func,
56         show: PropTypes.bool,
57 };
58
59 Dialog.defaultProps = {
60         log: null,
61         onHide: null,
62         show: false,
63 };
64
65 export default withTranslation()(Dialog);