feat: Add translation on 3 languages for sight page

This commit is contained in:
2025-06-01 00:34:59 +03:00
parent 0d9bbb140f
commit 87386c6a73
22 changed files with 768 additions and 732 deletions

View File

@ -1,9 +1,8 @@
import {
articlesStore,
authInstance,
languageInstance,
languageStore,
editSightStore,
SightBaseInfo,
} from "@shared";
import { computed, makeAutoObservable, runInAction } from "mobx";
@ -59,48 +58,40 @@ class SightsStore {
});
};
getSight = async (id: number) => {
const response = await authInstance.get(`/sight/${id}`);
// getSight = async (id: number) => {
// const response = await authInstance.get(`/sight/${id}`);
runInAction(() => {
this.sight = response.data;
editSightStore.sightInfo = {
...editSightStore.sightInfo,
id: response.data.id,
city_id: response.data.city_id,
city: response.data.city,
latitude: response.data.latitude,
longitude: response.data.longitude,
thumbnail: response.data.thumbnail,
watermark_lu: response.data.watermark_lu,
watermark_rd: response.data.watermark_rd,
left_article: response.data.left_article,
preview_media: response.data.preview_media,
video_preview: response.data.video_preview,
[languageStore.language]: {
info: {
name: response.data.name,
address: response.data.address,
description: response.data.description,
},
left: {
heading: editSightStore.sightInfo[languageStore.language].left
.loaded
? editSightStore.sightInfo[languageStore.language].left.heading
: articlesStore.articles[languageStore.language].find(
(article) => article.id === response.data.left_article
)?.heading,
body: editSightStore.sightInfo[languageStore.language].left.loaded
? editSightStore.sightInfo[languageStore.language].left.body
: articlesStore.articles[languageStore.language].find(
(article) => article.id === response.data.left_article
)?.body,
},
},
};
console.log(editSightStore.sightInfo);
});
};
// runInAction(() => {
// this.sight = response.data;
// editSightStore.sightInfo = {
// ...editSightStore.sightInfo,
// id: response.data.id,
// city_id: response.data.city_id,
// city: response.data.city,
// latitude: response.data.latitude,
// longitude: response.data.longitude,
// thumbnail: response.data.thumbnail,
// watermark_lu: response.data.watermark_lu,
// watermark_rd: response.data.watermark_rd,
// left_article: response.data.left_article,
// preview_media: response.data.preview_media,
// video_preview: response.data.video_preview,
// [languageStore.language]: {
// info: {
// name: response.data.name,
// address: response.data.address,
// },
// left: {
// heading: articlesStore.articles[languageStore.language].find(
// (article) => article.id === response.data.left_article
// )?.heading,
// body: articlesStore.articles[languageStore.language].find(
// },
// },
// };
// });
// };
createSightAction = async (
city: number,
@ -160,12 +151,32 @@ class SightsStore {
language: Language,
content: Partial<CreateSight[Language]>
) => {
runInAction(() => {
this.createSight[language] = {
...this.createSight[language],
this.createSight[language] = {
...this.createSight[language],
...content,
};
};
updateSight = (
language: Language,
content: Partial<SightBaseInfo[Language]>,
common: boolean
) => {
if (common) {
// @ts-ignore
this.sight!.common = {
// @ts-ignore
...this.sight!.common,
...content,
};
});
} else {
// @ts-ignore
this.sight![language] = {
// @ts-ignore
...this.sight![language],
...content,
};
}
};
clearCreateSight = () => {