diff --git a/src/pages/Sight/SightListPage/index.tsx b/src/pages/Sight/SightListPage/index.tsx index 731791e..5968885 100644 --- a/src/pages/Sight/SightListPage/index.tsx +++ b/src/pages/Sight/SightListPage/index.tsx @@ -51,7 +51,23 @@ export const SightListPage = observer(() => { const columns: GridColDef[] = [ { field: "name", - headerName: "Имя", + headerName: "Название", + flex: 1, + renderCell: (params: GridRenderCellParams) => { + return ( +
+ {params.value ? ( + params.value + ) : ( + + )} +
+ ); + }, + }, + { + field: "short_name", + headerName: "Сокращенное название", flex: 1, renderCell: (params: GridRenderCellParams) => { return ( @@ -124,10 +140,11 @@ export const SightListPage = observer(() => { const query = searchQuery.trim().toLowerCase(); const rows = filteredSights - .filter((sight: any) => !query || (sight.name ?? "").toLowerCase().includes(query)) - .map((sight) => ({ + .filter((sight: any) => !query || (sight.name ?? "").toLowerCase().includes(query) || (sight.short_name ?? "").toLowerCase().includes(query)) + .map((sight: any) => ({ id: sight.id, name: sight.name, + short_name: sight.short_name, city_id: sight.city_id, })); @@ -165,6 +182,7 @@ export const SightListPage = observer(() => { canWriteSights && navigate(`/sight/${params.row.id}/edit`)} checkboxSelection={canWriteSights} disableRowSelectionExcludeModel loading={isLoading} diff --git a/src/shared/store/CreateSightStore/index.tsx b/src/shared/store/CreateSightStore/index.tsx index 6e02423..cd5b516 100644 --- a/src/shared/store/CreateSightStore/index.tsx +++ b/src/shared/store/CreateSightStore/index.tsx @@ -16,6 +16,7 @@ type MediaItem = { type SightLanguageInfo = { name: string; + short_name: string; address: string; left: { heading: string; @@ -61,18 +62,21 @@ const initialSightState: SightBaseInfo = { video_preview: null, ru: { name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], }, en: { name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], }, zh: { name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -494,6 +498,7 @@ class CreateSightStore { longitude: this.sight.longitude, is_default_icon: this.sight.is_default_icon, name: (this.sight[primaryLanguage].name || "").trim(), + short_name: (this.sight[primaryLanguage].short_name || "").trim(), address: this.sight[primaryLanguage].address, thumbnail: this.sight.thumbnail, icon: this.sight.icon, @@ -522,6 +527,7 @@ class CreateSightStore { longitude: this.sight.longitude, is_default_icon: this.sight.is_default_icon, name: (this.sight[lang].name || "").trim(), + short_name: (this.sight[lang].short_name || "").trim(), address: this.sight[lang].address, thumbnail: this.sight.thumbnail, icon: this.sight.icon, diff --git a/src/shared/store/EditSightStore/index.tsx b/src/shared/store/EditSightStore/index.tsx index fd37dc2..b7d0999 100644 --- a/src/shared/store/EditSightStore/index.tsx +++ b/src/shared/store/EditSightStore/index.tsx @@ -10,6 +10,7 @@ import { makeAutoObservable, runInAction } from "mobx"; export type SightLanguageInfo = { id: number; name: string; + short_name: string; address: string; left: { heading: string; @@ -68,6 +69,7 @@ class EditSightStore { ru: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -75,6 +77,7 @@ class EditSightStore { en: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -82,6 +85,7 @@ class EditSightStore { zh: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -204,6 +208,7 @@ class EditSightStore { ru: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -212,6 +217,7 @@ class EditSightStore { en: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -220,6 +226,7 @@ class EditSightStore { zh: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -304,6 +311,11 @@ class EditSightStore { en: (this.sight.en.name || "").trim(), zh: (this.sight.zh.name || "").trim(), }, + short_name: { + ru: (this.sight.ru.short_name || "").trim(), + en: (this.sight.en.short_name || "").trim(), + zh: (this.sight.zh.short_name || "").trim(), + }, address: { ru: this.sight.ru.address, en: this.sight.en.address, diff --git a/src/shared/store/SightsStore/index.tsx b/src/shared/store/SightsStore/index.tsx index c153b6c..e7e9008 100644 --- a/src/shared/store/SightsStore/index.tsx +++ b/src/shared/store/SightsStore/index.tsx @@ -11,6 +11,7 @@ export type Language = "ru" | "en" | "zh"; export type MultilingualContent = { [key in Language]: { name: string; + short_name: string; address: string; }; }; @@ -18,6 +19,7 @@ export type MultilingualContent = { export type Sight = { id: number; name: string; + short_name: string | null; city_id: number; city: string; address: string; @@ -37,6 +39,7 @@ export type Sight = { export type CreateSight = { [key in Language]: { name: string; + short_name: string; address: string; }; }; @@ -45,9 +48,9 @@ class SightsStore { sights: Sight[] = []; sight: Sight | null = null; createSight: CreateSight = { - ru: { name: "", address: "" }, - en: { name: "", address: "" }, - zh: { name: "", address: "" }, + ru: { name: "", short_name: "", address: "" }, + en: { name: "", short_name: "", address: "" }, + zh: { name: "", short_name: "", address: "" }, }; constructor() { @@ -67,6 +70,7 @@ class SightsStore { ) => { const response = await authInstance.post("/sight", { name: this.createSight[languageStore.language].name, + short_name: this.createSight[languageStore.language].short_name, address: this.createSight[languageStore.language].address, city_id: city, latitude: coordinates.latitude, @@ -87,6 +91,7 @@ class SightsStore { `/sight/${id}`, { name: this.createSight[anotherLanguages[0] as Language].name, + short_name: this.createSight[anotherLanguages[0] as Language].short_name, address: this.createSight[anotherLanguages[0] as Language].address, city_id: city, latitude: coordinates.latitude, @@ -98,6 +103,7 @@ class SightsStore { `/sight/${id}`, { name: this.createSight[anotherLanguages[1] as Language].name, + short_name: this.createSight[anotherLanguages[1] as Language].short_name, address: this.createSight[anotherLanguages[1] as Language].address, city_id: city, latitude: coordinates.latitude, @@ -107,9 +113,9 @@ class SightsStore { runInAction(() => { this.createSight = { - ru: { name: "", address: "" }, - en: { name: "", address: "" }, - zh: { name: "", address: "" }, + ru: { name: "", short_name: "", address: "" }, + en: { name: "", short_name: "", address: "" }, + zh: { name: "", short_name: "", address: "" }, }; }); }; @@ -156,14 +162,17 @@ class SightsStore { this.createSight = { ru: { name: "", + short_name: "", address: "", }, en: { name: "", + short_name: "", address: "", }, zh: { name: "", + short_name: "", address: "", }, }; diff --git a/src/shared/store/SnapshotStore/index.ts b/src/shared/store/SnapshotStore/index.ts index dafa003..50b641f 100644 --- a/src/shared/store/SnapshotStore/index.ts +++ b/src/shared/store/SnapshotStore/index.ts @@ -157,6 +157,7 @@ class SnapshotStore { ru: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -164,6 +165,7 @@ class SnapshotStore { en: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], @@ -171,6 +173,7 @@ class SnapshotStore { zh: { id: 0, name: "", + short_name: "", address: "", left: { heading: "", body: "", media: [] }, right: [], diff --git a/src/widgets/SightTabs/CreateInformationTab/index.tsx b/src/widgets/SightTabs/CreateInformationTab/index.tsx index 9b53458..50f0081 100644 --- a/src/widgets/SightTabs/CreateInformationTab/index.tsx +++ b/src/widgets/SightTabs/CreateInformationTab/index.tsx @@ -237,6 +237,21 @@ export const CreateInformationTab = observer( variant="outlined" /> + { + handleChange( + { + short_name: e.target.value, + }, + language + ); + }} + fullWidth + variant="outlined" + /> + + { + handleChange(language as Language, { + short_name: e.target.value, + }); + }} + fullWidth + variant="outlined" + /> +