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([]);
16 const ctrl = new AbortController();
18 .get(`/api/protocol/${id}`, { signal: ctrl.signal })
20 setProtocol(response.data);
28 window.Echo.private(`Protocol.${id}`)
29 .listen('ProtocolAdded', e => {
31 setProtocol(protocol => [e.protocol, ...protocol]);
35 window.Echo.leave(`Protocol.${id}`);
42 onClick={() => setShowDialog(true)}
43 title={i18n.t('button.protocol')}
44 variant="outline-info"
46 <Icon.PROTOCOL title="" />
49 onHide={() => setShowDialog(false)}
57 Protocol.propTypes = {
61 export default withTranslation()(Protocol);