fix: Update map with tables fixes
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
// @shared/stores/editSightStore.ts
|
||||
import { authInstance, Language, languageInstance, mediaStore } from "@shared";
|
||||
import {
|
||||
articlesStore,
|
||||
authInstance,
|
||||
Language,
|
||||
languageInstance,
|
||||
mediaStore,
|
||||
} from "@shared";
|
||||
import { makeAutoObservable, runInAction } from "mobx";
|
||||
|
||||
export type SightLanguageInfo = {
|
||||
@@ -82,11 +88,7 @@ class EditSightStore {
|
||||
|
||||
hasLoadedCommon = false;
|
||||
getSightInfo = async (id: number, language: Language) => {
|
||||
if (this.sight[language].id === id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await authInstance.get(`/sight/${id}`);
|
||||
const response = await languageInstance(language).get(`/sight/${id}`);
|
||||
const data = response.data;
|
||||
|
||||
if (data.left_article != 0 && data.left_article != null) {
|
||||
@@ -376,6 +378,18 @@ class EditSightStore {
|
||||
|
||||
deleteLeftArticle = async (id: number) => {
|
||||
await authInstance.delete(`/article/${id}`);
|
||||
|
||||
runInAction(() => {
|
||||
articlesStore.articles.ru = articlesStore.articles.ru.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
articlesStore.articles.en = articlesStore.articles.en.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
articlesStore.articles.zh = articlesStore.articles.zh.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
});
|
||||
this.sight.common.left_article = 0;
|
||||
this.sight.ru.left.heading = "";
|
||||
this.sight.en.left.heading = "";
|
||||
@@ -556,6 +570,8 @@ class EditSightStore {
|
||||
media: mediaIds.data,
|
||||
});
|
||||
});
|
||||
|
||||
return article_id; // Return the linked article ID
|
||||
};
|
||||
|
||||
deleteRightArticleMedia = async (article_id: number, media_id: string) => {
|
||||
@@ -639,6 +655,29 @@ class EditSightStore {
|
||||
body: articleZhData.body,
|
||||
media: [],
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
articlesStore.articles.ru.push({
|
||||
id: id,
|
||||
heading: articleRuData.heading,
|
||||
body: articleRuData.body,
|
||||
service_name: articleRuData.heading,
|
||||
});
|
||||
articlesStore.articles.en.push({
|
||||
id: id,
|
||||
heading: articleEnData.heading,
|
||||
body: articleEnData.body,
|
||||
service_name: articleEnData.heading,
|
||||
});
|
||||
articlesStore.articles.zh.push({
|
||||
id: id,
|
||||
heading: articleZhData.heading,
|
||||
body: articleZhData.body,
|
||||
service_name: articleZhData.heading,
|
||||
});
|
||||
});
|
||||
|
||||
return id; // Return the ID of the newly created article
|
||||
};
|
||||
|
||||
createLinkWithRightArticle = async (
|
||||
|
||||
Reference in New Issue
Block a user