From 1ab7b1b9ad8f0aae722a9387d89c9565f54e6b1b Mon Sep 17 00:00:00 2001 From: aykhanahmadli Date: Thu, 7 Nov 2024 17:26:00 +0100 Subject: [PATCH 1/2] fix for videochat page --- .../features/video-call/video-call.queries.ts | 4 +- .../app/src/pages/ReviewPaperwork.tsx | 6 +-- .../app/src/pages/VideoChatPage.tsx | 40 ++++++++++++++----- packages/telemed-intake/app/vite.config.ts | 3 ++ 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/packages/telemed-intake/app/src/features/video-call/video-call.queries.ts b/packages/telemed-intake/app/src/features/video-call/video-call.queries.ts index 0a25044d..1feee572 100644 --- a/packages/telemed-intake/app/src/features/video-call/video-call.queries.ts +++ b/packages/telemed-intake/app/src/features/video-call/video-call.queries.ts @@ -6,6 +6,7 @@ import { PromiseReturnType } from 'ottehr-utils'; export const useJoinCall = ( apiClient: ZapEHRAPIClient | null, onSuccess: (data: PromiseReturnType>) => void, + setError: (err: Error) => void, // eslint-disable-next-line @typescript-eslint/explicit-function-return-type ) => { return useQuery( @@ -21,7 +22,8 @@ export const useJoinCall = ( }, { onSuccess, - onError: (err) => { + onError: (err: Error) => { + setError(err); console.error('Error during executing joinCall: ', err); }, }, diff --git a/packages/telemed-intake/app/src/pages/ReviewPaperwork.tsx b/packages/telemed-intake/app/src/pages/ReviewPaperwork.tsx index 06743f6f..9777604a 100644 --- a/packages/telemed-intake/app/src/pages/ReviewPaperwork.tsx +++ b/packages/telemed-intake/app/src/pages/ReviewPaperwork.tsx @@ -16,9 +16,9 @@ import { isPaperworkPageComplete } from '../utils/paperworkCompleted'; const ReviewPaperwork = (): JSX.Element => { const navigate = useNavigate(); - const { appointmentID, scheduleType, visitType } = getSelectors(useAppointmentStore, [ + const { appointmentID, visitService, visitType } = getSelectors(useAppointmentStore, [ 'appointmentID', - 'scheduleType', + 'visitService', 'visitType', ]); const fileURLs = useFilesStore((state) => state.fileURLs); @@ -91,7 +91,7 @@ const ReviewPaperwork = (): JSX.Element => { onSuccess: async () => { usePaperworkStore.setState({ paperworkQuestions: undefined, completedPaperwork: undefined }); useFilesStore.setState({ fileURLs: undefined }); - if (scheduleType === 'provider' && visitType === 'now') { + if (visitService === 'telemedicine' && visitType === 'now') { navigate(`${IntakeFlowPageRoute.WaitingRoom.path}?appointment_id=${appointmentID}`); } else { navigate(IntakeFlowPageRoute.ThankYou.path); diff --git a/packages/telemed-intake/app/src/pages/VideoChatPage.tsx b/packages/telemed-intake/app/src/pages/VideoChatPage.tsx index 81aca4ea..c5c70676 100644 --- a/packages/telemed-intake/app/src/pages/VideoChatPage.tsx +++ b/packages/telemed-intake/app/src/pages/VideoChatPage.tsx @@ -1,5 +1,5 @@ -import { FC } from 'react'; -import { Container } from '@mui/material'; +import { FC, useState } from 'react'; +import { Container, Typography, useTheme } from '@mui/material'; import { useSearchParams } from 'react-router-dom'; import { getSelectors } from 'ottehr-utils'; import { IntakeFlowPageRoute } from '../App'; @@ -17,6 +17,10 @@ const VideoChatPage: FC = () => { const videoCallState = getSelectors(useVideoCallStore, ['meetingData']); const meetingManager = useMeetingManager(); + const theme = useTheme(); + + const [error, setError] = useState(null); + const apiClient = useZapEHRAPIClient(); const [searchParams] = useSearchParams(); const urlAppointmentID = searchParams.get('appointmentID'); @@ -25,18 +29,32 @@ const VideoChatPage: FC = () => { useAppointmentStore.setState(() => ({ appointmentID: urlAppointmentID })); } - useJoinCall(apiClient, async (response) => { - useVideoCallStore.setState({ meetingData: response }); + useJoinCall( + apiClient, + async (response) => { + useVideoCallStore.setState({ meetingData: response }); - const meetingSessionConfiguration = new MeetingSessionConfiguration(response.Meeting, response.Attendee); - const options = { - deviceLabels: DeviceLabels.AudioAndVideo, - }; + const meetingSessionConfiguration = new MeetingSessionConfiguration(response.Meeting, response.Attendee); + const options = { + deviceLabels: DeviceLabels.AudioAndVideo, + }; - await meetingManager.join(meetingSessionConfiguration, options); + await meetingManager.join(meetingSessionConfiguration, options); - await meetingManager.start(); - }); + await meetingManager.start(); + }, + setError, + ); + + if (error) { + return ( + + + {error.message} + + + ); + } if (!videoCallState.meetingData) { return ( diff --git a/packages/telemed-intake/app/vite.config.ts b/packages/telemed-intake/app/vite.config.ts index 3b97c3cc..d3c628c7 100644 --- a/packages/telemed-intake/app/vite.config.ts +++ b/packages/telemed-intake/app/vite.config.ts @@ -53,6 +53,9 @@ export default (env) => { open: 'patient-portal', }, plugins, + define: { + global: 'window', + }, }), ); }; From 0ceb60aa30d155a1c35b84093408b7ce37b9dec0 Mon Sep 17 00:00:00 2001 From: aykhanahmadli Date: Thu, 7 Nov 2024 19:52:52 +0100 Subject: [PATCH 2/2] change error text --- packages/telemed-intake/app/src/pages/VideoChatPage.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/telemed-intake/app/src/pages/VideoChatPage.tsx b/packages/telemed-intake/app/src/pages/VideoChatPage.tsx index c5c70676..1d5d0adc 100644 --- a/packages/telemed-intake/app/src/pages/VideoChatPage.tsx +++ b/packages/telemed-intake/app/src/pages/VideoChatPage.tsx @@ -1,5 +1,5 @@ import { FC, useState } from 'react'; -import { Container, Typography, useTheme } from '@mui/material'; +import { Container, Typography } from '@mui/material'; import { useSearchParams } from 'react-router-dom'; import { getSelectors } from 'ottehr-utils'; import { IntakeFlowPageRoute } from '../App'; @@ -17,8 +17,6 @@ const VideoChatPage: FC = () => { const videoCallState = getSelectors(useVideoCallStore, ['meetingData']); const meetingManager = useMeetingManager(); - const theme = useTheme(); - const [error, setError] = useState(null); const apiClient = useZapEHRAPIClient(); @@ -49,7 +47,7 @@ const VideoChatPage: FC = () => { if (error) { return ( - + {error.message}