mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 08:51:13 -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}`);
|
navigate(`/parks/${searchResult.slug || searchResult.id}`);
|
||||||
break;
|
break;
|
||||||
case 'ride':
|
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;
|
break;
|
||||||
case 'company':
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export function useSearch(options: UseSearchOptions = {}) {
|
|||||||
subtitle: `at ${ride.park?.name || 'Unknown Park'}`,
|
subtitle: `at ${ride.park?.name || 'Unknown Park'}`,
|
||||||
image: ride.image_url,
|
image: ride.image_url,
|
||||||
rating: ride.average_rating,
|
rating: ride.average_rating,
|
||||||
|
slug: ride.slug,
|
||||||
data: ride
|
data: ride
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -129,6 +130,7 @@ export function useSearch(options: UseSearchOptions = {}) {
|
|||||||
title: company.name,
|
title: company.name,
|
||||||
subtitle: company.company_type?.replace('_', ' ').replace(/\b\w/g, l => l.toUpperCase()) || 'Company',
|
subtitle: company.company_type?.replace('_', ' ').replace(/\b\w/g, l => l.toUpperCase()) || 'Company',
|
||||||
image: company.logo_url,
|
image: company.logo_url,
|
||||||
|
slug: company.slug,
|
||||||
data: company
|
data: company
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user