{params.value ? (
- params.value
+ carriers[language].data.find(
+ (carrier) => carrier.id == params.value
+ )?.short_name
) : (
)}
@@ -105,7 +114,7 @@ export const RouteListPage = observer(() => {
const rows = routes.data.map((route) => ({
id: route.id,
- carrier: route.carrier,
+ carrier_id: route.carrier_id,
route_number: route.route_number,
route_direction: route.route_direction ? "Прямой" : "Обратный",
}));
diff --git a/src/pages/Station/StationCreatePage/index.tsx b/src/pages/Station/StationCreatePage/index.tsx
index 62c487b..c5be96d 100644
--- a/src/pages/Station/StationCreatePage/index.tsx
+++ b/src/pages/Station/StationCreatePage/index.tsx
@@ -8,33 +8,62 @@ import {
InputLabel,
} from "@mui/material";
import { observer } from "mobx-react-lite";
-import { ArrowLeft, Loader2, Save } from "lucide-react";
+import { ArrowLeft, Save } from "lucide-react";
+import { Loader2 } from "lucide-react";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
-import { stationsStore } from "@shared";
-import { useState } from "react";
+import { stationsStore, languageStore, cityStore } from "@shared";
+import { useEffect, useState } from "react";
import { LanguageSwitcher } from "@widgets";
export const StationCreatePage = observer(() => {
const navigate = useNavigate();
- const [name, setName] = useState("");
- const [systemName, setSystemName] = useState("");
- const [direction, setDirection] = useState("");
const [isLoading, setIsLoading] = useState(false);
+ const { language } = languageStore;
+ const {
+ createStationData,
+ setCreateCommonData,
+ createStation,
+ setLanguageCreateStationData,
+ } = stationsStore;
+ const { cities, getCities } = cityStore;
+ const [coordinates, setCoordinates] = useState
("");
+
+ useEffect(() => {
+ if (
+ createStationData.common.latitude !== 0 ||
+ createStationData.common.longitude !== 0
+ ) {
+ setCoordinates(
+ `${createStationData.common.latitude}, ${createStationData.common.longitude}`
+ );
+ }
+ }, [createStationData.common.latitude, createStationData.common.longitude]);
const handleCreate = async () => {
try {
setIsLoading(true);
- await stationsStore.createStation(name, systemName, direction);
+ await createStation();
toast.success("Станция успешно создана");
navigate("/station");
} catch (error) {
+ console.error("Error creating station:", error);
toast.error("Ошибка при создании станции");
} finally {
setIsLoading(false);
}
};
+ useEffect(() => {
+ const fetchCities = async () => {
+ await getCities("ru");
+ await getCities("en");
+ await getCities("zh");
+ };
+
+ fetchCities();
+ }, []);
+
return (
@@ -47,44 +76,123 @@ export const StationCreatePage = observer(() => {
Назад
+