Database
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user