mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 07:51:12 -05:00
Fix: Remove zero count display
This commit is contained in:
@@ -18,10 +18,13 @@ const ParkOwners = () => {
|
||||
const { data: parkOwners, isLoading } = useQuery({
|
||||
queryKey: ['park-owners'],
|
||||
queryFn: async () => {
|
||||
// Get companies that are property owners
|
||||
// Get companies that are property owners with park counts
|
||||
const { data, error } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.select(`
|
||||
*,
|
||||
parks:parks!property_owner_id(count)
|
||||
`)
|
||||
.in('id',
|
||||
await supabase
|
||||
.from('parks')
|
||||
@@ -32,7 +35,14 @@ const ParkOwners = () => {
|
||||
.order('name');
|
||||
|
||||
if (error) throw error;
|
||||
return data as Company[];
|
||||
|
||||
// Transform the data to include park_count
|
||||
const transformedData = data?.map(company => ({
|
||||
...company,
|
||||
park_count: company.parks?.[0]?.count || 0
|
||||
})) || [];
|
||||
|
||||
return transformedData as (Company & { park_count: number })[];
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user