mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 21:51:14 -05:00
Fix database schema
This commit is contained in:
@@ -27,25 +27,47 @@ export function useTechnicalSpecifications(
|
||||
: 'ride_model_technical_specifications';
|
||||
const idColumn = entityType === 'ride' ? 'ride_id' : 'ride_model_id';
|
||||
|
||||
const { data, error } = await (supabase as any)
|
||||
.from(tableName)
|
||||
.select('*')
|
||||
.eq(idColumn, entityId)
|
||||
.order('display_order');
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
return (data || []).map((spec: any) => ({
|
||||
id: spec.id,
|
||||
entity_type: entityType,
|
||||
entity_id: entityId,
|
||||
spec_name: spec.spec_name,
|
||||
spec_value: spec.spec_value,
|
||||
spec_unit: spec.spec_unit || null,
|
||||
category: spec.category || null,
|
||||
display_order: spec.display_order,
|
||||
created_at: spec.created_at,
|
||||
})) as TechnicalSpecification[];
|
||||
if (entityType === 'ride') {
|
||||
const { data, error } = await supabase
|
||||
.from('ride_technical_specifications')
|
||||
.select('*')
|
||||
.eq('ride_id', entityId)
|
||||
.order('display_order');
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
return (data || []).map((spec) => ({
|
||||
id: spec.id,
|
||||
entity_type: 'ride' as const,
|
||||
entity_id: entityId,
|
||||
spec_name: spec.spec_name,
|
||||
spec_value: spec.spec_value,
|
||||
spec_unit: spec.unit || null,
|
||||
category: spec.category || null,
|
||||
display_order: spec.display_order,
|
||||
created_at: spec.created_at,
|
||||
})) as TechnicalSpecification[];
|
||||
} else {
|
||||
const { data, error } = await supabase
|
||||
.from('ride_model_technical_specifications')
|
||||
.select('*')
|
||||
.eq('ride_model_id', entityId)
|
||||
.order('display_order');
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
return (data || []).map((spec) => ({
|
||||
id: spec.id,
|
||||
entity_type: 'ride_model' as const,
|
||||
entity_id: entityId,
|
||||
spec_name: spec.spec_name,
|
||||
spec_value: spec.spec_value,
|
||||
spec_unit: spec.unit || null,
|
||||
category: spec.category || null,
|
||||
display_order: spec.display_order,
|
||||
created_at: spec.created_at,
|
||||
})) as TechnicalSpecification[];
|
||||
}
|
||||
},
|
||||
enabled: !!entityId
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user