// Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; import { ControlBarButton, Phone, Modal, ModalBody, ModalHeader, ModalButton, ModalButtonGroup, } from 'amazon-chime-sdk-component-library-react'; import { endMeeting } from '../../api/ChimeAPI'; import { StyledP } from './Styled'; import { useAppState } from '../../providers/AppStateProvider'; import routes from '../../constants/routes'; const EndMeetingControl: React.FC = () => { const [showModal, setShowModal] = useState(false); const toggleModal = (): void => setShowModal(!showModal); const { meetingId } = useAppState(); const history = useHistory(); const leaveMeeting = async (): Promise => { history.push(routes.CHAT); }; const endMeetingForAll = async (): Promise => { try { if (meetingId) { await endMeeting(meetingId); history.push(routes.CHAT); } } catch (e) { console.log('Could not end meeting', e); } }; return ( <> } onClick={toggleModal} label="Leave" /> {showModal && ( Leave meeting or you can end the meeting for all. The meeting cannot be used once it ends. , , , ]} /> )} ); }; export default EndMeetingControl;