import React, { useEffect, useState } from 'react'; import { Meteor } from 'meteor/meteor'; import { useReactiveVar } from '@apollo/client'; import { defineMessages, useIntl } from 'react-intl'; import useMeeting from '/imports/ui/core/hooks/useMeeting'; import Auth from '/imports/ui/services/auth'; import ModalSimple from '/imports/ui/components/common/modal/simple/component'; import Button from '/imports/ui/components/common/button/component'; import Styled from './styles'; const BBB_TABLET_APP_CONFIG = Meteor.settings.public.app.bbbTabletApp; const intlMessages = defineMessages({ title: { id: 'app.mobileAppModal.title', description: 'App modal title', }, description: { id: 'app.mobileAppModal.description', description: 'App modal description', }, openStore: { id: 'app.mobileAppModal.openStore', defaultMessage: new Date().getFullYear().toString(), description: 'Open Store button label', }, openApp: { id: 'app.mobileAppModal.openApp', description: 'Open App button label', }, obtainUrlMsg: { id: 'app.mobileAppModal.obtainUrlMsg', description: 'Obtain URL message', }, obtainUrlErrorMsg: { id: 'app.mobileAppModal.obtainUrlErrorMsg', description: 'Obtain URL error message', }, dismissLabel: { id: 'app.mobileAppModal.dismissLabel', description: 'Dismiss button label', }, dismissDesc: { id: 'app.mobileAppModal.dismissDesc', description: 'adds descriptive context to dissmissLabel', }, }); interface MobileAppModalGraphqlContainerProps { isOpen: boolean, onRequestClose: () => void, priority: string, } interface MobileAppModalGraphqlProps extends MobileAppModalGraphqlContainerProps { meetingName: string; sessionToken: string; } const MobileAppModalGraphql: React.FC = (props) => { const { meetingName, sessionToken, isOpen, onRequestClose, priority, } = props; const [url, setUrl] = useState(''); const [urlMessage, setUrlMessage] = useState(''); const intl = useIntl(); useEffect(() => { const url = `/bigbluebutton/api/getJoinUrl?sessionToken=${sessionToken}`; const options = { method: 'GET', headers: { 'Content-Type': 'application/json', }, }; setUrlMessage(intl.formatMessage(intlMessages.obtainUrlMsg)); fetch(url, options) .then((response) => { if (!response.ok) { return Promise.reject(); } return response.json(); }) .then((messages) => { setUrl(messages.response.url); setUrlMessage(''); }) .catch(() => { setUrlMessage(intl.formatMessage(intlMessages.obtainUrlErrorMsg)); }); }, []); return ( {`${intl.formatMessage(intlMessages.description)}`}