Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Videochat page updates #565

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PromiseReturnType } from 'ottehr-utils';
export const useJoinCall = (
apiClient: ZapEHRAPIClient | null,
onSuccess: (data: PromiseReturnType<ReturnType<ZapEHRAPIClient['joinCall']>>) => void,
setError: (err: Error) => void,
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
) => {
return useQuery(
Expand All @@ -21,7 +22,8 @@ export const useJoinCall = (
},
{
onSuccess,
onError: (err) => {
onError: (err: Error) => {
setError(err);
console.error('Error during executing joinCall: ', err);
},
},
Expand Down
6 changes: 3 additions & 3 deletions packages/telemed-intake/app/src/pages/ReviewPaperwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
38 changes: 27 additions & 11 deletions packages/telemed-intake/app/src/pages/VideoChatPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC } from 'react';
import { Container } from '@mui/material';
import { FC, useState } from 'react';
import { Container, Typography } from '@mui/material';
import { useSearchParams } from 'react-router-dom';
import { getSelectors } from 'ottehr-utils';
import { IntakeFlowPageRoute } from '../App';
Expand All @@ -17,6 +17,8 @@ const VideoChatPage: FC = () => {
const videoCallState = getSelectors(useVideoCallStore, ['meetingData']);
const meetingManager = useMeetingManager();

const [error, setError] = useState<Error | null>(null);

const apiClient = useZapEHRAPIClient();
const [searchParams] = useSearchParams();
const urlAppointmentID = searchParams.get('appointmentID');
Expand All @@ -25,18 +27,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();
},
setError,
);

await meetingManager.start();
});
if (error) {
return (
<CustomContainer useEmptyBody title="" bgVariant={IntakeFlowPageRoute.VideoCall.path}>
<Typography sx={{ color: 'primary.contrast' }} variant="h6">
{error.message}
</Typography>
</CustomContainer>
);
}

if (!videoCallState.meetingData) {
return (
Expand Down
3 changes: 3 additions & 0 deletions packages/telemed-intake/app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export default (env) => {
open: 'patient-portal',
},
plugins,
define: {
global: 'window',
},
}),
);
};
Loading