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

add error screen for events #2255

Closed
wants to merge 3 commits into from
Closed
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
15 changes: 13 additions & 2 deletions src/views/Events/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import EventIcon from '@mui/icons-material/Event';
import FilterListIcon from '@mui/icons-material/FilterList';
import Autocomplete from '@mui/material/Autocomplete';
import EventList from 'components/EventList';
import GordonError from 'components/Error';
import GordonLoader from 'components/Loader';
import { useWindowSize } from 'hooks';
import { useEffect, useMemo, useState } from 'react';
Expand All @@ -32,6 +33,8 @@ const Events = () => {
const [includePast, setIncludePast] = useState(false);
const [loading, setLoading] = useState(true);
const [filters, setFilters] = useState([]);
const [noEventsLoaded, setNoEventsLoaded] = useState(false);
const [loadError, setLoadError] = useState([]);
const [hasInitializedEvents, setHasInitializedEvents] = useState(false);
const futureEvents = useMemo(() => gordonEvent.getFutureEvents(allEvents), [allEvents]);
const [width] = useWindowSize();
Expand All @@ -48,6 +51,7 @@ const Events = () => {
} else {
allEvents = await gordonEvent.getAllGuestEvents();
}

setAllEvents(allEvents);
setHasInitializedEvents(true);

Expand All @@ -73,7 +77,12 @@ const Events = () => {
setLoading(false);
};

loadEvents();
try {
loadEvents();
} catch (error) {
setNoEventsLoaded(true);
setLoadError(error);
}
}, [isAuthenticated, location.search]);

useEffect(() => {
Expand Down Expand Up @@ -122,7 +131,9 @@ const Events = () => {

let content;

if (loading || !hasInitializedEvents) {
if (noEventsLoaded) {
content = <GordonError error={loadError} />;
} else if (!noEventsLoaded && (loading || !hasInitializedEvents)) {
content = <GordonLoader />;
} else {
content = <EventList events={filteredEvents} loading={loading} />;
Expand Down
Loading