mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 21:51:14 -05:00
Refactor code to address issues
This commit is contained in:
@@ -36,6 +36,7 @@ import { ParkForm } from '@/components/admin/ParkForm';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
|
||||
export interface FilterState {
|
||||
search: string;
|
||||
@@ -288,6 +289,30 @@ export default function Parks() {
|
||||
return filtered;
|
||||
}, [parks, filters, sort]);
|
||||
|
||||
const generateDescription = () => {
|
||||
if (!parks.length) return 'Browse theme parks worldwide on ThrillWiki';
|
||||
|
||||
const activeFilters = [];
|
||||
if (filters.country.length === 1) activeFilters.push(`in ${filters.country[0]}`);
|
||||
if (filters.parkType.length > 0) activeFilters.push(filters.parkType.join(', '));
|
||||
if (filters.status.length > 0) activeFilters.push(filters.status.join(', '));
|
||||
|
||||
if (activeFilters.length > 0) {
|
||||
return `Browse ${filteredAndSortedParks.length} ${activeFilters.join(' ')} theme parks`;
|
||||
}
|
||||
|
||||
return `Browse ${parks.length} theme parks worldwide`;
|
||||
};
|
||||
|
||||
useOpenGraph({
|
||||
title: 'Theme Parks - ThrillWiki',
|
||||
description: generateDescription(),
|
||||
imageUrl: filteredAndSortedParks[0]?.banner_image_url,
|
||||
imageId: filteredAndSortedParks[0]?.banner_image_id,
|
||||
type: 'website',
|
||||
enabled: !loading
|
||||
});
|
||||
|
||||
const activeFilterCount = useMemo(() => {
|
||||
let count = 0;
|
||||
if (filters.search) count++;
|
||||
|
||||
Reference in New Issue
Block a user