Reverted to commit 06ed528d76

This commit is contained in:
gpt-engineer-app[bot]
2025-10-11 15:58:56 +00:00
parent 1df9ada8ae
commit f37b99a5f9
33 changed files with 2509 additions and 140 deletions

View File

@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { Header } from '@/components/layout/Header';
import { getBannerUrls } from '@/lib/cloudflareImageUtils';
@@ -41,19 +41,25 @@ export default function ParkDetail() {
const [photoCount, setPhotoCount] = useState<number>(0);
const [statsLoading, setStatsLoading] = useState(true);
const { isModerator } = useUserRole();
useEffect(() => {
if (slug) {
fetchParkData();
}
}, [slug]);
const fetchPhotoCount = useCallback(async (parkId: string) => {
try {
const { count, error } = await supabase
.from('photos')
.select('id', { count: 'exact', head: true })
.eq('entity_type', 'park')
.eq('entity_id', parkId);
// Track page view when park is loaded
useEffect(() => {
if (park?.id) {
trackPageView('park', park.id);
if (error) throw error;
setPhotoCount(count || 0);
} catch (error) {
console.error('Error fetching photo count:', error);
setPhotoCount(0);
} finally {
setStatsLoading(false);
}
}, [park?.id]);
const fetchParkData = async () => {
}, []);
const fetchParkData = useCallback(async () => {
try {
// Fetch park details
const {
@@ -79,25 +85,20 @@ export default function ParkDetail() {
} finally {
setLoading(false);
}
};
}, [slug, fetchPhotoCount]);
const fetchPhotoCount = async (parkId: string) => {
try {
const { count, error } = await supabase
.from('photos')
.select('id', { count: 'exact', head: true })
.eq('entity_type', 'park')
.eq('entity_id', parkId);
if (error) throw error;
setPhotoCount(count || 0);
} catch (error) {
console.error('Error fetching photo count:', error);
setPhotoCount(0);
} finally {
setStatsLoading(false);
useEffect(() => {
if (slug) {
fetchParkData();
}
};
}, [slug, fetchParkData]);
// Track page view when park is loaded
useEffect(() => {
if (park?.id) {
trackPageView('park', park.id);
}
}, [park?.id]);
const getStatusColor = (status: string) => {
switch (status) {
case 'operating':