mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 15:31:13 -05:00
feat: Implement comprehensive plan
This commit is contained in:
@@ -96,7 +96,7 @@ export function useManufacturers() {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('companies')
|
||||
.select('name')
|
||||
.select('id, name')
|
||||
.eq('company_type', 'manufacturer')
|
||||
.order('name');
|
||||
|
||||
@@ -105,7 +105,7 @@ export function useManufacturers() {
|
||||
setManufacturers(
|
||||
(data || []).map(company => ({
|
||||
label: company.name,
|
||||
value: company.name.toLowerCase().replace(/\s+/g, '_')
|
||||
value: company.id
|
||||
}))
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -122,6 +122,47 @@ export function useManufacturers() {
|
||||
return { manufacturers, loading };
|
||||
}
|
||||
|
||||
export function useRideModels(manufacturerId?: string) {
|
||||
const [rideModels, setRideModels] = useState<ComboboxOption[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!manufacturerId) {
|
||||
setRideModels([]);
|
||||
return;
|
||||
}
|
||||
|
||||
async function fetchRideModels() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('ride_models')
|
||||
.select('id, name')
|
||||
.eq('manufacturer_id', manufacturerId)
|
||||
.order('name');
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
setRideModels(
|
||||
(data || []).map(model => ({
|
||||
label: model.name,
|
||||
value: model.id
|
||||
}))
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error fetching ride models:', error);
|
||||
setRideModels([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
fetchRideModels();
|
||||
}, [manufacturerId]);
|
||||
|
||||
return { rideModels, loading };
|
||||
}
|
||||
|
||||
export function useCompanyHeadquarters() {
|
||||
const [headquarters, setHeadquarters] = useState<ComboboxOption[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user