fix: Fix bugs
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { authInstance } from "@shared";
|
||||
import { authInstance, languageInstance } from "@shared";
|
||||
import { makeAutoObservable, runInAction } from "mobx";
|
||||
|
||||
type City = {
|
||||
@ -11,7 +11,9 @@ type City = {
|
||||
|
||||
class CityStore {
|
||||
cities: City[] = [];
|
||||
ruCities: City[] = [];
|
||||
city: City | null = null;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
@ -24,6 +26,14 @@ class CityStore {
|
||||
});
|
||||
};
|
||||
|
||||
getRuCities = async () => {
|
||||
const response = await languageInstance("ru").get("/city");
|
||||
|
||||
runInAction(() => {
|
||||
this.ruCities = response.data;
|
||||
});
|
||||
};
|
||||
|
||||
deleteCity = async (id: number) => {
|
||||
await authInstance.delete(`/city/${id}`);
|
||||
|
||||
|
@ -106,10 +106,17 @@ class CreateSightStore {
|
||||
try {
|
||||
this.needLeaveAgree = true;
|
||||
const articleRes = await authInstance.post("/article", {
|
||||
translation: {
|
||||
ru: articleRuData,
|
||||
en: articleEnData,
|
||||
zh: articleZhData,
|
||||
translations: {
|
||||
heading: {
|
||||
ru: articleRuData.heading,
|
||||
en: articleEnData.heading,
|
||||
zh: articleZhData.heading,
|
||||
},
|
||||
body: {
|
||||
ru: articleRuData.body,
|
||||
en: articleEnData.body,
|
||||
zh: articleZhData.body,
|
||||
},
|
||||
},
|
||||
});
|
||||
const { id } = articleRes.data; // New article's ID
|
||||
|
@ -265,18 +265,16 @@ class EditSightStore {
|
||||
this.sight.common.left_article != null
|
||||
) {
|
||||
await authInstance.patch(`/article/${this.sight.common.left_article}`, {
|
||||
translation: {
|
||||
ru: {
|
||||
heading: this.sight.ru.left.heading,
|
||||
body: this.sight.ru.left.body,
|
||||
translations: {
|
||||
heading: {
|
||||
ru: this.sight.ru.left.heading,
|
||||
en: this.sight.en.left.heading,
|
||||
zh: this.sight.zh.left.heading,
|
||||
},
|
||||
en: {
|
||||
heading: this.sight.en.left.heading,
|
||||
body: this.sight.en.left.body,
|
||||
},
|
||||
zh: {
|
||||
heading: this.sight.zh.left.heading,
|
||||
body: this.sight.zh.left.body,
|
||||
body: {
|
||||
ru: this.sight.ru.left.body,
|
||||
en: this.sight.en.left.body,
|
||||
zh: this.sight.zh.left.body,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -284,39 +282,36 @@ class EditSightStore {
|
||||
|
||||
await authInstance.patch(`/sight/${this.sight.common.id}`, {
|
||||
...this.sight.common,
|
||||
translation: {
|
||||
ru: {
|
||||
name: this.sight.ru.name,
|
||||
address: this.sight.ru.address,
|
||||
translations: {
|
||||
name: {
|
||||
ru: this.sight.ru.name,
|
||||
en: this.sight.en.name,
|
||||
zh: this.sight.zh.name,
|
||||
},
|
||||
en: {
|
||||
name: this.sight.en.name,
|
||||
address: this.sight.en.address,
|
||||
},
|
||||
zh: {
|
||||
name: this.sight.zh.name,
|
||||
address: this.sight.zh.address,
|
||||
address: {
|
||||
ru: this.sight.ru.address,
|
||||
en: this.sight.en.address,
|
||||
zh: this.sight.zh.address,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
for (const article of this.sight.ru.right) {
|
||||
for (let index = 0; index < this.sight.ru.right.length; index++) {
|
||||
const article = this.sight.ru.right[index];
|
||||
if (article.id == 0 || article.id == null) {
|
||||
continue;
|
||||
}
|
||||
await authInstance.patch(`/article/${article.id}`, {
|
||||
translation: {
|
||||
ru: {
|
||||
heading: article.heading,
|
||||
body: article.body,
|
||||
translations: {
|
||||
heading: {
|
||||
ru: this.sight.ru.right[index].heading,
|
||||
en: this.sight.en.right[index].heading,
|
||||
zh: this.sight.zh.right[index].heading,
|
||||
},
|
||||
en: {
|
||||
heading: article.heading,
|
||||
body: article.body,
|
||||
},
|
||||
zh: {
|
||||
heading: article.heading,
|
||||
body: article.body,
|
||||
body: {
|
||||
ru: this.sight.ru.right[index].body,
|
||||
en: this.sight.en.right[index].body,
|
||||
zh: this.sight.zh.right[index].body,
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -604,10 +599,17 @@ class EditSightStore {
|
||||
body: "Новый текст (ZH)",
|
||||
};
|
||||
const articleId = await authInstance.post("/article", {
|
||||
translation: {
|
||||
ru: articleRuData,
|
||||
en: articleEnData,
|
||||
zh: articleZhData,
|
||||
translations: {
|
||||
heading: {
|
||||
ru: articleRuData.heading,
|
||||
en: articleEnData.heading,
|
||||
zh: articleZhData.heading,
|
||||
},
|
||||
body: {
|
||||
ru: articleRuData.body,
|
||||
en: articleEnData.body,
|
||||
zh: articleZhData.body,
|
||||
},
|
||||
},
|
||||
});
|
||||
const { id } = articleId.data;
|
||||
|
Reference in New Issue
Block a user