mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 03:11:12 -05:00
Fix search to use slugs
This commit is contained in:
@@ -123,10 +123,37 @@ export function AutocompleteSearch({
|
||||
navigate(`/parks/${searchResult.slug || searchResult.id}`);
|
||||
break;
|
||||
case 'ride':
|
||||
navigate(`/rides/${searchResult.id}`);
|
||||
const parkSlug = (searchResult.data as any).park?.slug;
|
||||
const rideSlug = searchResult.slug;
|
||||
if (parkSlug && rideSlug) {
|
||||
navigate(`/parks/${parkSlug}/rides/${rideSlug}`);
|
||||
} else {
|
||||
navigate(`/rides/${searchResult.id}`);
|
||||
}
|
||||
break;
|
||||
case 'company':
|
||||
navigate(`/companies/${searchResult.id}`);
|
||||
const companyType = (searchResult.data as any).company_type;
|
||||
const companySlug = searchResult.slug;
|
||||
if (companyType && companySlug) {
|
||||
switch (companyType) {
|
||||
case 'operator':
|
||||
navigate(`/operators/${companySlug}`);
|
||||
break;
|
||||
case 'property_owner':
|
||||
navigate(`/owners/${companySlug}`);
|
||||
break;
|
||||
case 'manufacturer':
|
||||
navigate(`/manufacturers/${companySlug}`);
|
||||
break;
|
||||
case 'designer':
|
||||
navigate(`/designers/${companySlug}`);
|
||||
break;
|
||||
default:
|
||||
navigate(`/companies/${searchResult.id}`);
|
||||
}
|
||||
} else {
|
||||
navigate(`/companies/${searchResult.id}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ export function useSearch(options: UseSearchOptions = {}) {
|
||||
subtitle: `at ${ride.park?.name || 'Unknown Park'}`,
|
||||
image: ride.image_url,
|
||||
rating: ride.average_rating,
|
||||
slug: ride.slug,
|
||||
data: ride
|
||||
});
|
||||
});
|
||||
@@ -129,6 +130,7 @@ export function useSearch(options: UseSearchOptions = {}) {
|
||||
title: company.name,
|
||||
subtitle: company.company_type?.replace('_', ' ').replace(/\b\w/g, l => l.toUpperCase()) || 'Company',
|
||||
image: company.logo_url,
|
||||
slug: company.slug,
|
||||
data: company
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user