1 import axios from 'axios';
2 import PropTypes from 'prop-types';
3 import React, { useEffect, useState } from 'react';
4 import { Button } from 'react-bootstrap';
5 import { withTranslation } from 'react-i18next';
7 import Dialog from './Dialog';
8 import Icon from '../common/Icon';
9 import i18n from '../../i18n';
11 const Protocol = ({ id }) => {
12 const [showDialog, setShowDialog] = useState(false);
13 const [protocol, setProtocol] = useState([]);
17 .get(`/api/protocol/${id}`)
19 setProtocol(response.data);
24 window.Echo.private(`Protocol.${id}`)
25 .listen('ProtocolAdded', e => {
28 setProtocol(protocol => [e.protocol, ...protocol]);
32 window.Echo.leave(`Protocol.${id}`);
39 onClick={() => setShowDialog(true)}
40 title={i18n.t('button.protocol')}
41 variant="outline-info"
43 <Icon.PROTOCOL title="" />
46 onHide={() => setShowDialog(false)}
54 Protocol.propTypes = {
58 export default withTranslation()(Protocol);