'use client'; import { useState, useEffect } from 'react'; import { dataStore } from '@/lib/dataStore'; import type { MetroStation } from '@/data/metroStations'; export default function MetroLine() { const [stations, setStations] = useState([]); const [selectedStationId, setSelectedStationId] = useState(null); const [currentStationIndex, setCurrentStationIndex] = useState(0); useEffect(() => { // Metro istasyonlarını yükle const loadedStations = dataStore.getMetroStations(); setStations(loadedStations); // Admin panelinden seçili istasyonu al const adminSelectedId = localStorage.getItem('metro_selected_station'); if (adminSelectedId) { setSelectedStationId(parseInt(adminSelectedId)); // Seçili istasyonun index'ini bul const selectedIndex = loadedStations.findIndex(s => s.id === parseInt(adminSelectedId)); if (selectedIndex !== -1) { // Metro animasyonu başlat let currentIndex = 0; const interval = setInterval(() => { if (currentIndex < selectedIndex) { currentIndex++; setCurrentStationIndex(currentIndex); } else { clearInterval(interval); } }, 2000); // Her 2 saniyede bir ilerle return () => clearInterval(interval); } } }, []); const getStationStyle = (index: number, station: MetroStation) => { if (index === currentStationIndex) { return 'w-16 h-16 bg-[#F59E0B] border-4 border-white shadow-2xl scale-110'; } if (station.status === 'completed' || index < currentStationIndex) { return 'w-14 h-14 bg-green-500 border-4 border-white shadow-lg'; } if (station.status === 'in-progress') { return 'w-14 h-14 bg-blue-500 border-4 border-white shadow-lg'; } return 'w-12 h-12 bg-gray-300 border-4 border-dashed border-gray-400 shadow-lg opacity-60'; }; const getTextStyle = (index: number, station: MetroStation) => { if (index === currentStationIndex) { return 'text-[#F59E0B] font-bold'; } if (station.status === 'completed' || index < currentStationIndex) { return 'text-green-600 font-bold'; } if (station.status === 'in-progress') { return 'text-blue-600 font-bold'; } return 'text-gray-500 font-semibold'; }; const progressPercentage = stations.length > 0 ? (currentStationIndex / (stations.length - 1)) * 100 : 0; if (stations.length === 0) { return
Yükleniyor...
; } return (
{/* Proje Başlığı */}

A2 Metro Hattı İnşaatı

Abidin Paşa - Natoyolu

İnşaat Durumu

{Math.round(progressPercentage)}%

{/* Metro Hat ve İnşaat Çizgisi - Desktop */}
{/* Gri arka plan hattı (tüm hat) */}
{/* Renkli ilerleme çubuğu - duraklar arası geçişle */}
{/* Duraklar Grid - Desktop */}
{stations.map((station, index) => (
{index === currentStationIndex ? ( <> {/* Metro simgesi - animasyonlu */} {/* Pulse efekti */}
) : station.status === 'completed' || index < currentStationIndex ? ( ) : station.status === 'in-progress' ? ( ) : ( )}
{station.name} {index === currentStationIndex ? '🚇 Metro Burada' : station.status === 'completed' || index < currentStationIndex ? '✓ Tamamlandı' : station.status === 'in-progress' ? '🔄 Devam Ediyor' : '◯ Planlı'}
))}
{/* Metro Hat - Mobil (Dikey Liste) */}
{stations.map((station, index) => (
{/* İkon */}
{index === currentStationIndex ? ( ) : station.status === 'completed' || index < currentStationIndex ? ( ) : station.status === 'in-progress' ? ( ) : ( )}
{/* Bilgi */}

{station.name}

{index === currentStationIndex ? '🚇 Metro Burada' : station.status === 'completed' || index < currentStationIndex ? '✓ Tamamlandı' : station.status === 'in-progress' ? '🔄 Devam Ediyor' : '◯ Planlı'}

{/* Bağlantı çizgisi (son istasyon hariç) */} {index < stations.length - 1 && (
)}
))}
{/* Alt Bilgi */}
Tamamlandı
İnşaat Halinde (Metro Burada)
Planlanan
); }