diff --git a/src/components/homepage/ContentTabs.tsx b/src/components/homepage/ContentTabs.tsx index e2f5fe2a..2a85686d 100644 --- a/src/components/homepage/ContentTabs.tsx +++ b/src/components/homepage/ContentTabs.tsx @@ -35,6 +35,7 @@ export function ContentTabs() { const [highestRatedRides, setHighestRatedRides] = useState([]); const [openingSoon, setOpeningSoon] = useState>([]); const [closingSoon, setClosingSoon] = useState>([]); + const [recentlyClosed, setRecentlyClosed] = useState>([]); const [loading, setLoading] = useState(true); useEffect(() => { @@ -295,6 +296,34 @@ export function ContentTabs() { .sort((a, b) => new Date(a.closing_date).getTime() - new Date(b.closing_date).getTime()) .slice(0, 24); + // Recently Closed (closed in last year) + const { data: parksClosed } = await supabase + .from('parks') + .select(`*, location:locations(*), operator:companies!parks_operator_id_fkey(*)`) + .not('closing_date', 'is', null) + .lt('closing_date', new Date().toISOString().split('T')[0]) + .gte('closing_date', dateThreshold) + .in('status', ['closed', 'permanently_closed']) + .order('closing_date', { ascending: false }) + .limit(20); + + const { data: ridesClosed } = await supabase + .from('rides') + .select(`*, park:parks!inner(name, slug, location:locations(*))`) + .not('closing_date', 'is', null) + .lt('closing_date', new Date().toISOString().split('T')[0]) + .gte('closing_date', dateThreshold) + .in('status', ['closed', 'removed', 'permanently_closed']) + .order('closing_date', { ascending: false }) + .limit(20); + + const combinedClosed = [ + ...(parksClosed || []).map(p => ({ ...p, entityType: 'park' as const })), + ...(ridesClosed || []).map(r => ({ ...r, entityType: 'ride' as const })) + ] + .sort((a, b) => new Date(b.closing_date).getTime() - new Date(a.closing_date).getTime()) + .slice(0, 24); + setTrendingParks(trending || []); setRecentParks(recent || []); setTrendingRides(trendingRidesData || []); @@ -305,6 +334,7 @@ export function ContentTabs() { setHighestRatedRides(topRatedRides || []); setOpeningSoon(combinedOpening); setClosingSoon(combinedClosing); + setRecentlyClosed(combinedClosed); } catch (error: unknown) { logger.error('Failed to fetch content', { error: getErrorMessage(error) }); } finally { @@ -346,7 +376,7 @@ export function ContentTabs() {
- + Trending Parks @@ -362,9 +392,6 @@ export function ContentTabs() { Recent Changes - - Recently Opened - Top Parks @@ -374,9 +401,15 @@ export function ContentTabs() { Opening Soon + + Recently Opened + Closing Soon + + Recently Closed +
@@ -604,6 +637,39 @@ export function ContentTabs() {
)} + + +
+

Recently Closed

+

Parks and rides that closed in the last year

+
+
+ {recentlyClosed.length > 0 ? ( +
+ {recentlyClosed.map((entity: any) => ( + entity.entityType === 'park' ? ( +
+ + + Closed {new Date(entity.closing_date).getFullYear()} + +
+ ) : ( +
+ + + Closed {new Date(entity.closing_date).getFullYear()} + +
+ ) + ))} +
+ ) : ( +
+ No parks or rides closed in the last year. +
+ )} +