diff --git a/components/page/irl/events/irl-all-events.tsx b/components/page/irl/events/irl-all-events.tsx index 69bc06ff..ebf16884 100644 --- a/components/page/irl/events/irl-all-events.tsx +++ b/components/page/irl/events/irl-all-events.tsx @@ -23,7 +23,7 @@ interface EventDetailsProps { const IrlAllEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, handleDataNotFound }: EventDetailsProps) => { - let eventsToShow = getEventsToShow() || []; + let eventsToShow = eventDetails.events || []; const [isExpanded, setExpanded] = useState(false); const [itemsToShow, setItemsToShow] = useState(4); const dialogRef = useRef(null); @@ -31,34 +31,6 @@ const IrlAllEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, hand const analytics = useIrlAnalytics(); const router = useRouter(); - function getEventsToShow() { - if (eventDetails) { - // Determine events to show based on upcoming or past - const events = eventDetails.events; - - if (events && events.length > 0) { - // Sort events based on startDate first, then by duration (endDate - startDate) - const sortedEvents = events.sort((a: any, b: any) => { - // First, compare by start date (earlier start first) - const startDateComparison = new Date(a.startDate).getTime() - new Date(b.startDate).getTime(); - - if (startDateComparison !== 0) { - return startDateComparison; - } - - // If start dates are equal, compare by duration (longer duration first) - const durationA = new Date(a.endDate).getTime() - new Date(a.startDate).getTime(); - const durationB = new Date(b.endDate).getTime() - new Date(b.startDate).getTime(); - - return durationB - durationA; - }); - - // Set eventsToShow based on the sorted events - return sortedEvents; - } - } - } - const toggleDescription = () => { setItemsToShow(isExpanded ? 4 : itemsToShow + 4); if (itemsToShow >= eventsToShow?.length - 4) { diff --git a/components/page/irl/events/irl-past-events.tsx b/components/page/irl/events/irl-past-events.tsx index 339f0826..ea90741d 100644 --- a/components/page/irl/events/irl-past-events.tsx +++ b/components/page/irl/events/irl-past-events.tsx @@ -43,7 +43,6 @@ const IrlPastEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, han const [searchText, setSearchText] = useState(''); - // Sort pastEvents in descending order by end date if it's not upcoming const eventsToShow = events; // Determine the selected event based on searchParams diff --git a/components/page/irl/events/irl-upcoming-events.tsx b/components/page/irl/events/irl-upcoming-events.tsx index 975f043c..81d6c39e 100644 --- a/components/page/irl/events/irl-upcoming-events.tsx +++ b/components/page/irl/events/irl-upcoming-events.tsx @@ -22,7 +22,7 @@ interface EventDetailsProps { const IrlUpcomingEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, handleDataNotFound }: EventDetailsProps) => { const eventType = isUpcoming ? 'Upcoming Events' : 'Past Events'; - let eventsToShow = getEventsToShow() || []; + let eventsToShow = eventDetails.upcomingEvents || []; const [isExpanded, setExpanded] = useState(false); const [itemsToShow, setItemsToShow] = useState(4); const dialogRef = useRef(null); @@ -30,34 +30,6 @@ const IrlUpcomingEvents = ({ eventDetails, isLoggedIn, isUpcoming, searchParams, const analytics = useIrlAnalytics(); const router = useRouter(); - function getEventsToShow() { - if (eventDetails) { - // Determine events to show based on upcoming or past - const events = isUpcoming ? eventDetails.upcomingEvents : []; - - if (events && events.length > 0) { - // Sort events based on startDate first, then by duration (endDate - startDate) - const sortedEvents = events.sort((a: any, b: any) => { - // First, compare by start date (earlier start first) - const startDateComparison = new Date(a.startDate).getTime() - new Date(b.startDate).getTime(); - - if (startDateComparison !== 0) { - return startDateComparison; - } - - // If start dates are equal, compare by duration (longer duration first) - const durationA = new Date(a.endDate).getTime() - new Date(a.startDate).getTime(); - const durationB = new Date(b.endDate).getTime() - new Date(b.startDate).getTime(); - - return durationB - durationA; - }); - - // Set eventsToShow based on the sorted events - return sortedEvents; - } - } - } - const toggleDescription = () => { setItemsToShow(isExpanded ? 4 : itemsToShow + 4); if (itemsToShow >= eventsToShow?.length - 4) { diff --git a/services/irl.service.ts b/services/irl.service.ts index 53fa580f..c8b03c90 100644 --- a/services/irl.service.ts +++ b/services/irl.service.ts @@ -15,13 +15,6 @@ export const getAllLocations = async () => { } const result = await response.json(); - result.sort((a: { priority: number }, b: { priority: number }) => a.priority - b.priority); - - result.forEach((item: { pastEvents: any[] }) => { - if (Array.isArray(item.pastEvents)) { - item.pastEvents = sortPastEvents(item.pastEvents); - } - }); const filteredResult = result.filter( (item: { pastEvents: IPastEvents[]; upcomingEvents: IUpcomingEvents[]; }) =>