diff --git a/src/components/events/EventCards.jsx b/src/components/events/EventCards.jsx
new file mode 100644
index 00000000..2a3b5c40
--- /dev/null
+++ b/src/components/events/EventCards.jsx
@@ -0,0 +1,64 @@
+import { Grid, Typography, CircularProgress, Box } from "@mui/material";
+import EventCard from "components/events/EventCard";
+
+export function EventCards({
+ events,
+ loading,
+ noEventsMessage,
+ loadingIndicator = true,
+}) {
+ if (loading) {
+ return (
+
+ {loadingIndicator ? : null}
+
+ );
+ }
+
+ return (
+
+ {events?.length ? (
+ events.map((event) => (
+
+
+
+ ))
+ ) : (
+
+ {noEventsMessage}
+
+ )}
+
+ );
+}
+
+export function LoadingIndicator() {
+ return (
+
+
+
+ );
+}
diff --git a/src/components/events/EventsGrid.jsx b/src/components/events/EventsGrid.jsx
index 175a15f3..ac188451 100644
--- a/src/components/events/EventsGrid.jsx
+++ b/src/components/events/EventsGrid.jsx
@@ -2,8 +2,7 @@ import { getClient } from "gql/client";
import { GET_ALL_EVENTS } from "gql/queries/events";
import { GET_CLUB } from "gql/queries/clubs";
-import { Grid, Typography } from "@mui/material";
-import EventCard from "components/events/EventCard";
+import { EventCards } from "./EventCards";
export default async function EventsGrid({
type = "all", // must be one of: {recent, club, all}
@@ -32,33 +31,11 @@ export default async function EventsGrid({
);
return (
-
- {updatedEvents?.filter(filter).length ? (
- updatedEvents
- ?.slice(0, limit)
- ?.filter(filter)
- ?.map((event) => (
-
-
-
- ))
- ) : (
-
- No events found.
-
- )}
-
+
);
}
diff --git a/src/components/events/PaginatedEventGrid.jsx b/src/components/events/PaginatedEventGrid.jsx
index 1cfc2e3d..21887277 100644
--- a/src/components/events/PaginatedEventGrid.jsx
+++ b/src/components/events/PaginatedEventGrid.jsx
@@ -2,13 +2,10 @@
import { useEffect, useState, useCallback, useRef } from "react";
import {
- Box,
- Grid,
Typography,
Divider,
- CircularProgress,
} from "@mui/material";
-import EventCard from "components/events/EventCard";
+import { EventCards, LoadingIndicator } from "./EventCards";
export default function PaginatedEventGrid({
limit = 24, // Default limit if pagination is enabled
@@ -196,30 +193,11 @@ export default function PaginatedEventGrid({
Ongoing Events
-
- {futureEvents?.filter(ongoingEventsFilter)?.length ? (
- futureEvents?.filter(ongoingEventsFilter)?.map((event) => (
-
-
-
- ))
- ) : (
-
- {loadingFuture ? : "No events found."}
-
- )}
-
+
{targetState?.includes("upcoming") && (
<>
@@ -228,38 +206,11 @@ export default function PaginatedEventGrid({
Upcoming Events
-
- {futureEvents?.filter(upcomingEventsFilter)?.length ? (
- futureEvents?.filter(upcomingEventsFilter)?.map((event) => (
-
-
-
- ))
- ) : (
-
- {loadingFuture ? (
- targetState?.includes("completed") ? (
-
- ) : (
- ""
- )
- ) : (
- "No events found."
- )}
-
- )}
-
+
>
)}
@@ -270,47 +221,18 @@ export default function PaginatedEventGrid({
Completed Events
-
- {completedevents?.length ? (
- completedevents?.map((event) => (
-
-
-
- ))
- ) : (
-
- {loadingPast ? "" : "No events found."}
-
- )}
-
+
>
)}
{/* "Load more" trigger */}
- {loadingPast && (
- // center the circular progress
-
-
-
- )}
+ {loadingPast && }
>
);