Refactor code structure and remove redundant changes

This commit is contained in:
pacnpal
2025-11-09 16:31:34 -05:00
parent 2884bc23ce
commit eb68cf40c6
1080 changed files with 27361 additions and 56687 deletions

View File

@@ -0,0 +1,63 @@
import { useQuery } from '@tanstack/react-query';
import { supabase } from '@/lib/supabaseClient';
import { queryKeys } from '@/lib/queryKeys';
/**
* Hook to fetch featured parks (top rated and most rides)
*/
export function useFeaturedParks() {
const topRated = useQuery({
queryKey: queryKeys.homepage.featuredParks.topRated(),
queryFn: async () => {
const { data, error } = await supabase
.from('parks')
.select(`
*,
location:locations(*),
operator:companies!parks_operator_id_fkey(*)
`)
.order('average_rating', { ascending: false })
.limit(3);
if (error) throw error;
return data || [];
},
staleTime: 10 * 60 * 1000, // 10 minutes - featured parks change rarely
gcTime: 30 * 60 * 1000,
refetchOnWindowFocus: false,
});
const mostRides = useQuery({
queryKey: queryKeys.homepage.featuredParks.mostRides(),
queryFn: async () => {
const { data, error } = await supabase
.from('parks')
.select(`
*,
location:locations(*),
operator:companies!parks_operator_id_fkey(*)
`)
.order('ride_count', { ascending: false })
.limit(3);
if (error) throw error;
return data || [];
},
staleTime: 10 * 60 * 1000, // 10 minutes
gcTime: 30 * 60 * 1000,
refetchOnWindowFocus: false,
});
return {
topRated: {
data: topRated.data,
isLoading: topRated.isLoading,
error: topRated.error,
},
mostRides: {
data: mostRides.data,
isLoading: mostRides.isLoading,
error: mostRides.error,
},
};
}