Skip to content

Commit

Permalink
Show error page if keyset not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jingyi-gao-ttd committed Oct 6, 2023
1 parent a2538af commit 660b22d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/web/screens/sharingPermissions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useContext, useEffect, useState } from 'react';
import { useContext, useEffect, useState } from 'react';

import { ClientType } from '../../api/services/adminServiceHelpers';
import { Collapsible } from '../components/Core/Collapsible';
Expand All @@ -14,6 +14,8 @@ import {
GetSharingList,
} from '../services/participant';
import { preloadAllSitesList, preloadAvailableSiteList } from '../services/site';
import { ApiError } from '../utils/apiError';
import { useAsyncError } from '../utils/errorHandler';
import { PortalRoute } from './routeUtils';

import './sharingPermissions.scss';
Expand All @@ -24,6 +26,7 @@ function SharingPermissions() {
const [sharedSiteIds, setSharedSiteIds] = useState<number[]>([]);
const [sharedTypes, setSharedTypes] = useState<ClientType[]>([]);
const [statusPopup, setStatusPopup] = useState<StatusNotificationType>();
const throwError = useAsyncError();

const handleSaveSharingType = async (selectedTypes: ClientType[]) => {
try {
Expand Down Expand Up @@ -95,15 +98,18 @@ function SharingPermissions() {
}
};

const loadSharingList = useCallback(async () => {
const response = await GetSharingList();
setSharedSiteIds(response.allowed_sites);
setSharedTypes(response.allowed_types ?? []);
}, []);

useEffect(() => {
const loadSharingList = async () => {
try {
const response = await GetSharingList();
setSharedSiteIds(response.allowed_sites);
setSharedTypes(response.allowed_types ?? []);
} catch (e: unknown) {
if (e instanceof ApiError) throwError(e);
}
};
loadSharingList();
}, [loadSharingList]);
}, [throwError]);

return (
<div className='sharingPermissions'>
Expand Down

0 comments on commit 660b22d

Please sign in to comment.