#18 Корректировки 01.11.25 (#19)

Reviewed-on: #19
Reviewed-by: Микаэл Оганесян <15lu.akari@unprism.ru>
Co-authored-by: fisenko <kkzemeow@gmail.com>
Co-committed-by: fisenko <kkzemeow@gmail.com>
This commit is contained in:
2025-11-07 07:16:29 +00:00
parent 79f523e9cb
commit 03fd04a420
46 changed files with 2907 additions and 997 deletions

View File

@@ -7,7 +7,7 @@ type StationLanguageData = {
name: string;
system_name: string;
address: string;
loaded: boolean; // Indicates if this language's data has been loaded/modified
loaded: boolean;
};
type StationCommonData = {
@@ -92,7 +92,6 @@ class StationsStore {
},
};
// This will store the full station data, keyed by ID and then by language
stationPreview: Record<
string,
Record<string, { loaded: boolean; data: Station }>
@@ -264,7 +263,6 @@ class StationsStore {
};
};
// Sets language-specific station data
setLanguageEditStationData = (
language: Language,
data: Partial<StationLanguageData>
@@ -295,7 +293,7 @@ class StationsStore {
`/station/${id}`,
{
name: name || "",
system_name: name || "", // system_name is often derived from name
system_name: name || "",
description: description || "",
address: address || "",
...commonDataPayload,
@@ -303,7 +301,6 @@ class StationsStore {
);
runInAction(() => {
// Update the cached preview data and station lists after successful patch
if (this.stationPreview[id]) {
this.stationPreview[id][language] = {
loaded: true,
@@ -343,11 +340,11 @@ class StationsStore {
runInAction(() => {
this.stations = this.stations.filter((station) => station.id !== id);
// Also clear from stationPreview cache
if (this.stationPreview[id]) {
delete this.stationPreview[id];
}
// Clear from stationLists as well for all languages
for (const lang of ["ru", "en", "zh"] as const) {
if (this.stationLists[lang].data) {
this.stationLists[lang].data = this.stationLists[lang].data.filter(
@@ -421,12 +418,11 @@ class StationsStore {
delete commonDataPayload.icon;
}
// First create station in Russian
const { name, address } = this.createStationData[language];
const description = this.createStationData.common.description;
const response = await languageInstance(language).post("/station", {
name: name || "",
system_name: name || "", // system_name is often derived from name
system_name: name || "",
description: description || "",
address: address || "",
...commonDataPayload,
@@ -438,7 +434,6 @@ class StationsStore {
const stationId = response.data.id;
// Then update for other languages
for (const lang of ["ru", "en", "zh"].filter(
(lang) => lang !== language
) as Language[]) {
@@ -448,7 +443,7 @@ class StationsStore {
`/station/${stationId}`,
{
name: name || "",
system_name: name || "", // system_name is often derived from name
system_name: name || "",
description: description || "",
address: address || "",
...commonDataPayload,
@@ -507,7 +502,6 @@ class StationsStore {
return response.data;
};
// Reset editStationData when navigating away or after saving
resetEditStationData = () => {
this.editStationData = {
ru: {