Fix database schema

This commit is contained in:
gpt-engineer-app[bot]
2025-10-17 14:25:03 +00:00
parent badb2cd865
commit 921abb63a1
8 changed files with 737 additions and 44 deletions

View File

@@ -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
});