Skip to content

Commit

Permalink
#3099-error check
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Dec 27, 2024
1 parent 2b1f55a commit 3d2c816
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EmptyPageBlockDisplay from './EmptyPageBlockDisplay';
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
import GeneralAnnouncementCard from './GeneralAnnouncementCard';
import { useRemoveUserAnnouncement, useUserAnnouncements } from '../../../hooks/announcements.hooks';
import ErrorPage from '../../ErrorPage';

const NoGeneralAnnouncementsDisplay = () => {
return (
Expand All @@ -17,10 +18,16 @@ const NoGeneralAnnouncementsDisplay = () => {
};

const GeneralAnnouncements: React.FC = () => {
const { data: unreadAnnouncements, isLoading } = useUserAnnouncements();
const {
data: unreadAnnouncements,
isLoading,
isError: announcementsIsError,
error: announcementsError
} = useUserAnnouncements();
const { mutateAsync: removeAnnouncement, isLoading: removeAnnouncementIsLoading } = useRemoveUserAnnouncement();

if (isLoading || removeAnnouncementIsLoading || !unreadAnnouncements) return <LoadingIndicator />;
if (announcementsIsError) return <ErrorPage message={announcementsError.message} />;

const removeAnnouncementWrapper = async (announcement: Announcement) => {
await removeAnnouncement(announcement);
Expand Down

0 comments on commit 3d2c816

Please sign in to comment.