mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 01:31:13 -05:00
Refactor code to address issues
This commit is contained in:
@@ -23,6 +23,7 @@ import { toast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
|
||||
export default function Rides() {
|
||||
useDocumentTitle('Rides & Attractions');
|
||||
@@ -266,6 +267,28 @@ export default function Rides() {
|
||||
return filtered;
|
||||
}, [rides, searchQuery, sortBy, filters]);
|
||||
|
||||
const generateDescription = () => {
|
||||
if (!filteredAndSortedRides.length) return 'Discover thrilling rides and roller coasters worldwide';
|
||||
|
||||
const activeFilters = [];
|
||||
if (filters.categories.length > 0) activeFilters.push(filters.categories.join(', '));
|
||||
if (filters.status !== 'all') activeFilters.push(filters.status);
|
||||
|
||||
if (activeFilters.length > 0) {
|
||||
return `Explore ${filteredAndSortedRides.length} ${activeFilters.join(' ')} rides and attractions`;
|
||||
}
|
||||
|
||||
return `Explore ${filteredAndSortedRides.length} rides and roller coasters worldwide`;
|
||||
};
|
||||
|
||||
useOpenGraph({
|
||||
title: 'Rides & Attractions - ThrillWiki',
|
||||
description: generateDescription(),
|
||||
imageUrl: filteredAndSortedRides[0]?.banner_image_url,
|
||||
imageId: filteredAndSortedRides[0]?.banner_image_id,
|
||||
type: 'website',
|
||||
enabled: !loading
|
||||
});
|
||||
|
||||
const categories = [
|
||||
{ value: 'all', label: 'All Categories' },
|
||||
|
||||
Reference in New Issue
Block a user