diff --git a/packages/api/src/types/Events.ts b/packages/api/src/types/Events.ts index 2ea07899..69fe8a37 100644 --- a/packages/api/src/types/Events.ts +++ b/packages/api/src/types/Events.ts @@ -9,6 +9,7 @@ export type GetEventResponse = { description: string | null; fields: unknown; status: 'OPEN' | 'CLOSED' | 'UPCOMING' | null; + eventDisplayRank: number | null; }; export type GetEventsResponse = GetEventResponse[]; diff --git a/packages/berlin/src/components/events/Events.tsx b/packages/berlin/src/components/events/Events.tsx index 1e11699b..e2a24d36 100644 --- a/packages/berlin/src/components/events/Events.tsx +++ b/packages/berlin/src/components/events/Events.tsx @@ -2,14 +2,14 @@ import { useNavigate } from 'react-router-dom'; // API -import { GetEventResponse } from 'api'; +import { GetEventsResponse } from 'api'; // Components import { Body } from '../typography/Body.styled'; import { Subtitle } from '../typography/Subtitle.styled'; type EventsProps = { - events: GetEventResponse[] | undefined; + events: GetEventsResponse | null | undefined; errorMessage: string; }; @@ -20,8 +20,14 @@ export default function Events({ events, errorMessage }: EventsProps) { navigate(`/events/${eventId}/cycles`); }; - return events?.length ? ( - events.map((event) => { + const sortedEvents = events?.sort((a, b) => { + const rankA = a.eventDisplayRank ?? Number.MAX_SAFE_INTEGER; + const rankB = b.eventDisplayRank ?? Number.MAX_SAFE_INTEGER; + return rankA - rankB; + }); + + return sortedEvents?.length ? ( + sortedEvents.map((event) => { return (
('upcoming'); const { user } = useUser(); const { data: events } = useQuery({ queryKey: ['events'], @@ -23,26 +20,13 @@ function Events() { enabled: !!user?.id, }); - const openEvents = useMemo(() => events?.filter((event) => event.status === 'OPEN'), [events]); - const closedEvents = useMemo( - () => events?.filter((events) => events.status === 'CLOSED'), - [events], - ); - - const tabNames = ['upcoming', 'past']; - const tabs = { - upcoming: , - past: , - }; - return (
Events -
- +
);