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 => {
27 setProtocol(protocol => [e.protocol, ...protocol]);
31 window.Echo.leave(`Protocol.${id}`);
38 onClick={() => setShowDialog(true)}
39 title={i18n.t('button.protocol')}
40 variant="outline-info"
42 <Icon.PROTOCOL title="" />
45 onHide={() => setShowDialog(false)}
53 Protocol.propTypes = {
57 export default withTranslation()(Protocol);