Skip to content

Commit

Permalink
Merge branch 'develop' into OB-5203
Browse files Browse the repository at this point in the history
  • Loading branch information
web-mi authored Sep 22, 2023
2 parents f6f6b9f + bd6feec commit 4fc8429
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 45 deletions.
6 changes: 4 additions & 2 deletions src/api/appointments/getAppointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { endpoints } from '../../resources/scripts/endpoints';
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from '../fetchData';

export const getAppointment = async (
appointmentId: string
appointmentId: string,
skipAuth: boolean = false
): Promise<AppointmentsDataInterface> => {
const url = endpoints.appointmentsServiceBase + '/' + appointmentId;

return fetchData({
url: url,
method: FETCH_METHODS.GET,
responseHandling: [FETCH_ERRORS.CATCH_ALL_WITH_RESPONSE]
responseHandling: [FETCH_ERRORS.CATCH_ALL_WITH_RESPONSE],
skipAuth: skipAuth
});
};
6 changes: 4 additions & 2 deletions src/api/videocalls/getJwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { endpoints } from '../../resources/scripts/endpoints';
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from '../fetchData';

export const getJwt = async (
appointmentId: string
appointmentId: string,
skipAuth: boolean = false
): Promise<VideoCallJwtDataInterface> => {
const url = endpoints.videocallServiceBase + '/' + appointmentId + '/jwt';

return fetchData({
url: url,
method: FETCH_METHODS.GET,
responseHandling: [FETCH_ERRORS.CATCH_ALL_WITH_RESPONSE]
responseHandling: [FETCH_ERRORS.CATCH_ALL_WITH_RESPONSE],
skipAuth: skipAuth
});
};
33 changes: 22 additions & 11 deletions src/components/videoConference/VideoConference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const VideoConference = () => {
const [quitted, setQuitted] = useState(false);
const [ready, setReady] = useState(false);
const [rejected, setRejected] = useState(false);
const [skipAuth, setSkipAuth] = useState(false);
const [confirmed, setConfirmed] = useState(status === 'confirmed');
const [appointment, setAppointment] =
useState<AppointmentsDataInterface>(null);
Expand All @@ -61,12 +62,14 @@ const VideoConference = () => {
);

const loadAppointment = useCallback(() => {
return appointmentService.getAppointment(appointmentId).then((res) => {
if (res.status !== appointment?.status) {
setAppointment(res);
}
});
}, [appointment?.status, appointmentId]);
return appointmentService
.getAppointment(appointmentId, skipAuth)
.then((res) => {
if (res.status !== appointment?.status) {
setAppointment(res);
}
});
}, [appointment?.status, appointmentId, skipAuth]);

const [startWatcher, stopWatcher, isWatcherRunning] =
useWatcher(loadAppointment);
Expand Down Expand Up @@ -133,17 +136,25 @@ const VideoConference = () => {
setInitialized(true);

Promise.all([
appointmentService.getAppointment(appointmentId),
videocallsService.getJwt(appointmentId)
appointmentService.getAppointment(appointmentId, skipAuth),
videocallsService.getJwt(appointmentId, skipAuth)
])
.then(([appointment, videoCallJwtData]) => {
setAppointment(appointment);
setVideoCallJwtData(videoCallJwtData);
setReady(true);
})
.catch((e) => console.error(e))
.finally(() => setReady(true));
.catch((e) => {
if (e?.status === 401 && skipAuth === false) {
setSkipAuth(true);
setInitialized(false);
} else {
console.error(e);
setReady(true);
}
});
}
}, [appointmentId, initialized]);
}, [appointmentId, initialized, skipAuth]);

useEffect(() => {
if (appointment?.id && !isModerator() && !isWatcherRunning) {
Expand Down
6 changes: 1 addition & 5 deletions src/components/waitingRoom/WaitingRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import { StageLayout } from '../stageLayout/StageLayout';
import { appConfig } from '../../utils/appConfig';
import { Loading } from '../app/Loading';
import { GlobalComponentContext } from '../../globalState/provider/GlobalComponentContext';
import { supportsE2EEncryptionVideoCall } from '../../utils/videoCallHelpers';
import { E2EEncryptionSupportHelp } from '../E2EEncryptionSupportHelp/E2EEncryptionSupportHelp';
export interface WaitingRoomProps {
consultingTypeSlug: string;
consultingTypeId: number;
Expand Down Expand Up @@ -269,9 +267,7 @@ export const WaitingRoom = (props: WaitingRoomProps) => {
};

const getContent = () => {
if (!supportsE2EEncryptionVideoCall()) {
return <E2EEncryptionSupportHelp />;
} else if (isDataProtectionViewActive) {
if (isDataProtectionViewActive) {
return (
<WaitingRoomContent
showRegistrationInfo={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,34 @@ export const ProposedAgencies = ({
}
);

const handleChange = useCallback(
(data: Partial<FormAccordionData>, isTouched = true) => {
onChange(data);
if (isTouched) {
setIsTouched(isTouched);
}
},
[onChange]
);

const handleAgencyChange = useCallback(
(agency: AgencyDataInterface, isTouched = true) => {
handleChange(
{
agency,
consultingType: consultingTypes.find(
(ct) => ct.id === agency?.consultingType
),
...(autoSelectPostcode
? { postcode: agency?.postcode }
: {})
},
isTouched
);
},
[autoSelectPostcode, consultingTypes, handleChange]
);

// If options change, check for still valid preselected agency
useEffect(() => {
if (
Expand All @@ -81,18 +109,18 @@ export const ProposedAgencies = ({
return;
}

return onChange({
agency:
(autoSelectAgency && agencies.length > 0) ||
agencies.length === 1
? agencies[0]
: null
});
return handleAgencyChange(
(autoSelectAgency && agencies.length > 0) || agencies.length === 1
? agencies[0]
: null,
false
);
}, [
agencies,
autoSelectAgency,
formAccordionData.agency,
onChange,
handleAgencyChange,
preSelectedAgency
]);

Expand Down Expand Up @@ -146,24 +174,6 @@ export const ProposedAgencies = ({
onValidityChange
]);

const handleChange = useCallback(
(data: Partial<FormAccordionData>) => {
onChange(data);
setIsTouched(true);
},
[onChange]
);

const handleAgencyChange = (agency: AgencyDataInterface) => {
handleChange({
agency,
consultingType: consultingTypes.find(
(ct) => ct.id === agency?.consultingType
),
...(autoSelectPostcode ? { postcode: agency?.postcode } : {})
});
};

return (
<div
className={`agencySelectionWrapper ${
Expand Down

0 comments on commit 4fc8429

Please sign in to comment.