Add correct edit right widget
This commit is contained in:
@@ -22,7 +22,7 @@ type SightLanguageInfo = {
|
||||
media_type: number;
|
||||
}[];
|
||||
};
|
||||
right: { heading: string; body: string }[];
|
||||
right: { id: number; heading: string; body: string; media: [] }[];
|
||||
};
|
||||
|
||||
type SightCommonInfo = {
|
||||
@@ -90,19 +90,43 @@ class CreateSightStore {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
createNewRightArticle = () => {
|
||||
this.sight.ru.right.push({
|
||||
createNewRightArticle = async () => {
|
||||
const articleId = await languageInstance("ru").post("/article", {
|
||||
heading: "Введите русский заголовок",
|
||||
body: "Введите русский текст",
|
||||
});
|
||||
this.sight.en.right.push({
|
||||
const { id } = articleId.data;
|
||||
await languageInstance("en").patch(`/article/${id}`, {
|
||||
heading: "Enter the English heading",
|
||||
body: "Enter the English text",
|
||||
});
|
||||
this.sight.zh.right.push({
|
||||
await languageInstance("zh").patch(`/article/${id}`, {
|
||||
heading: "Введите китайский заголовок",
|
||||
body: "Введите китайский текст",
|
||||
});
|
||||
await authInstance.post(`/sight/${this.sight.id}/article`, {
|
||||
article_id: id,
|
||||
page_num: this.sight.ru.right.length + 1,
|
||||
});
|
||||
|
||||
this.sight.ru.right.push({
|
||||
id: id,
|
||||
heading: "Введите русский заголовок",
|
||||
body: "Введите русский текст",
|
||||
media: [],
|
||||
});
|
||||
this.sight.en.right.push({
|
||||
id: id,
|
||||
heading: "Enter the English heading",
|
||||
body: "Enter the English text",
|
||||
media: [],
|
||||
});
|
||||
this.sight.zh.right.push({
|
||||
id: id,
|
||||
heading: "Введите китайский заголовок",
|
||||
body: "Введите китайский текст",
|
||||
media: [],
|
||||
});
|
||||
};
|
||||
|
||||
updateLeftInfo = (language: Language, heading: string, body: string) => {
|
||||
@@ -444,6 +468,32 @@ class CreateSightStore {
|
||||
filename: media.filename,
|
||||
});
|
||||
};
|
||||
|
||||
unlinkRightAritcle = async (id: number) => {
|
||||
this.sight.ru.right = this.sight.ru.right.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
this.sight.en.right = this.sight.en.right.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
this.sight.zh.right = this.sight.zh.right.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
};
|
||||
|
||||
deleteRightArticle = async (id: number) => {
|
||||
await authInstance.delete(`/article/${id}`);
|
||||
|
||||
this.sight.ru.right = this.sight.ru.right.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
this.sight.en.right = this.sight.en.right.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
this.sight.zh.right = this.sight.zh.right.filter(
|
||||
(article) => article.id !== id
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export const createSightStore = new CreateSightStore();
|
||||
|
||||
Reference in New Issue
Block a user