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,44 @@
import { useQuery } from '@tanstack/react-query';
import { supabase } from '@/lib/supabaseClient';
export interface CoasterStat {
id: string;
ride_id: string;
stat_name: string;
stat_value: number;
unit?: string | null;
category?: string | null;
description?: string | null;
display_order: number;
created_at: string;
}
export function useCoasterStats(rideId: string | undefined) {
return useQuery({
queryKey: ['coaster-stats', rideId],
queryFn: async () => {
if (!rideId) return [];
const { data, error} = await supabase
.from('ride_coaster_stats')
.select('*')
.eq('ride_id', rideId)
.order('display_order');
if (error) throw error;
return (data || []).map((stat) => ({
id: stat.id,
ride_id: stat.ride_id,
stat_name: stat.stat_name,
stat_value: stat.stat_value,
unit: stat.unit || null,
category: stat.category || null,
description: stat.description || null,
display_order: stat.display_order,
created_at: stat.created_at,
})) as CoasterStat[];
},
enabled: !!rideId
});
}