This commit is contained in:
Şahan Hasret
2025-11-21 17:46:30 +03:00
parent c0b7fb463e
commit 76c31274d5
46 changed files with 3675 additions and 1043 deletions

View File

@@ -10,34 +10,36 @@ export default function MetroLine() {
const [currentStationIndex, setCurrentStationIndex] = useState(0);
useEffect(() => {
// Metro istasyonlarını yükle
const loadedStations = dataStore.getMetroStations();
setStations(loadedStations);
// Metro istasyonlarını yükle (async)
dataStore.getMetroStations().then(loadedStations => {
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
// 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);
return () => clearInterval(interval);
}
}
}
});
}, []);
const getStationStyle = (index: number, station: MetroStation) => {
// Seçili istasyonun index'ini bul
const selectedIndex = selectedStationId