feat: add sight short_name and sight features
This commit is contained in:
@@ -51,7 +51,23 @@ export const SightListPage = observer(() => {
|
|||||||
const columns: GridColDef[] = [
|
const columns: GridColDef[] = [
|
||||||
{
|
{
|
||||||
field: "name",
|
field: "name",
|
||||||
headerName: "Имя",
|
headerName: "Название",
|
||||||
|
flex: 1,
|
||||||
|
renderCell: (params: GridRenderCellParams) => {
|
||||||
|
return (
|
||||||
|
<div className="w-full h-full flex items-center">
|
||||||
|
{params.value ? (
|
||||||
|
params.value
|
||||||
|
) : (
|
||||||
|
<Minus size={20} className="text-red-500" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "short_name",
|
||||||
|
headerName: "Сокращенное название",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
renderCell: (params: GridRenderCellParams) => {
|
renderCell: (params: GridRenderCellParams) => {
|
||||||
return (
|
return (
|
||||||
@@ -124,10 +140,11 @@ export const SightListPage = observer(() => {
|
|||||||
|
|
||||||
const query = searchQuery.trim().toLowerCase();
|
const query = searchQuery.trim().toLowerCase();
|
||||||
const rows = filteredSights
|
const rows = filteredSights
|
||||||
.filter((sight: any) => !query || (sight.name ?? "").toLowerCase().includes(query))
|
.filter((sight: any) => !query || (sight.name ?? "").toLowerCase().includes(query) || (sight.short_name ?? "").toLowerCase().includes(query))
|
||||||
.map((sight) => ({
|
.map((sight: any) => ({
|
||||||
id: sight.id,
|
id: sight.id,
|
||||||
name: sight.name,
|
name: sight.name,
|
||||||
|
short_name: sight.short_name,
|
||||||
city_id: sight.city_id,
|
city_id: sight.city_id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -165,6 +182,7 @@ export const SightListPage = observer(() => {
|
|||||||
<DataGrid
|
<DataGrid
|
||||||
rows={rows}
|
rows={rows}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
onRowDoubleClick={(params) => canWriteSights && navigate(`/sight/${params.row.id}/edit`)}
|
||||||
checkboxSelection={canWriteSights}
|
checkboxSelection={canWriteSights}
|
||||||
disableRowSelectionExcludeModel
|
disableRowSelectionExcludeModel
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type MediaItem = {
|
|||||||
|
|
||||||
type SightLanguageInfo = {
|
type SightLanguageInfo = {
|
||||||
name: string;
|
name: string;
|
||||||
|
short_name: string;
|
||||||
address: string;
|
address: string;
|
||||||
left: {
|
left: {
|
||||||
heading: string;
|
heading: string;
|
||||||
@@ -61,18 +62,21 @@ const initialSightState: SightBaseInfo = {
|
|||||||
video_preview: null,
|
video_preview: null,
|
||||||
ru: {
|
ru: {
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -494,6 +498,7 @@ class CreateSightStore {
|
|||||||
longitude: this.sight.longitude,
|
longitude: this.sight.longitude,
|
||||||
is_default_icon: this.sight.is_default_icon,
|
is_default_icon: this.sight.is_default_icon,
|
||||||
name: (this.sight[primaryLanguage].name || "").trim(),
|
name: (this.sight[primaryLanguage].name || "").trim(),
|
||||||
|
short_name: (this.sight[primaryLanguage].short_name || "").trim(),
|
||||||
address: this.sight[primaryLanguage].address,
|
address: this.sight[primaryLanguage].address,
|
||||||
thumbnail: this.sight.thumbnail,
|
thumbnail: this.sight.thumbnail,
|
||||||
icon: this.sight.icon,
|
icon: this.sight.icon,
|
||||||
@@ -522,6 +527,7 @@ class CreateSightStore {
|
|||||||
longitude: this.sight.longitude,
|
longitude: this.sight.longitude,
|
||||||
is_default_icon: this.sight.is_default_icon,
|
is_default_icon: this.sight.is_default_icon,
|
||||||
name: (this.sight[lang].name || "").trim(),
|
name: (this.sight[lang].name || "").trim(),
|
||||||
|
short_name: (this.sight[lang].short_name || "").trim(),
|
||||||
address: this.sight[lang].address,
|
address: this.sight[lang].address,
|
||||||
thumbnail: this.sight.thumbnail,
|
thumbnail: this.sight.thumbnail,
|
||||||
icon: this.sight.icon,
|
icon: this.sight.icon,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { makeAutoObservable, runInAction } from "mobx";
|
|||||||
export type SightLanguageInfo = {
|
export type SightLanguageInfo = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
short_name: string;
|
||||||
address: string;
|
address: string;
|
||||||
left: {
|
left: {
|
||||||
heading: string;
|
heading: string;
|
||||||
@@ -68,6 +69,7 @@ class EditSightStore {
|
|||||||
ru: {
|
ru: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -75,6 +77,7 @@ class EditSightStore {
|
|||||||
en: {
|
en: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -82,6 +85,7 @@ class EditSightStore {
|
|||||||
zh: {
|
zh: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -204,6 +208,7 @@ class EditSightStore {
|
|||||||
ru: {
|
ru: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -212,6 +217,7 @@ class EditSightStore {
|
|||||||
en: {
|
en: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -220,6 +226,7 @@ class EditSightStore {
|
|||||||
zh: {
|
zh: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -304,6 +311,11 @@ class EditSightStore {
|
|||||||
en: (this.sight.en.name || "").trim(),
|
en: (this.sight.en.name || "").trim(),
|
||||||
zh: (this.sight.zh.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: {
|
address: {
|
||||||
ru: this.sight.ru.address,
|
ru: this.sight.ru.address,
|
||||||
en: this.sight.en.address,
|
en: this.sight.en.address,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export type Language = "ru" | "en" | "zh";
|
|||||||
export type MultilingualContent = {
|
export type MultilingualContent = {
|
||||||
[key in Language]: {
|
[key in Language]: {
|
||||||
name: string;
|
name: string;
|
||||||
|
short_name: string;
|
||||||
address: string;
|
address: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -18,6 +19,7 @@ export type MultilingualContent = {
|
|||||||
export type Sight = {
|
export type Sight = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
short_name: string | null;
|
||||||
city_id: number;
|
city_id: number;
|
||||||
city: string;
|
city: string;
|
||||||
address: string;
|
address: string;
|
||||||
@@ -37,6 +39,7 @@ export type Sight = {
|
|||||||
export type CreateSight = {
|
export type CreateSight = {
|
||||||
[key in Language]: {
|
[key in Language]: {
|
||||||
name: string;
|
name: string;
|
||||||
|
short_name: string;
|
||||||
address: string;
|
address: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -45,9 +48,9 @@ class SightsStore {
|
|||||||
sights: Sight[] = [];
|
sights: Sight[] = [];
|
||||||
sight: Sight | null = null;
|
sight: Sight | null = null;
|
||||||
createSight: CreateSight = {
|
createSight: CreateSight = {
|
||||||
ru: { name: "", address: "" },
|
ru: { name: "", short_name: "", address: "" },
|
||||||
en: { name: "", address: "" },
|
en: { name: "", short_name: "", address: "" },
|
||||||
zh: { name: "", address: "" },
|
zh: { name: "", short_name: "", address: "" },
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -67,6 +70,7 @@ class SightsStore {
|
|||||||
) => {
|
) => {
|
||||||
const response = await authInstance.post("/sight", {
|
const response = await authInstance.post("/sight", {
|
||||||
name: this.createSight[languageStore.language].name,
|
name: this.createSight[languageStore.language].name,
|
||||||
|
short_name: this.createSight[languageStore.language].short_name,
|
||||||
address: this.createSight[languageStore.language].address,
|
address: this.createSight[languageStore.language].address,
|
||||||
city_id: city,
|
city_id: city,
|
||||||
latitude: coordinates.latitude,
|
latitude: coordinates.latitude,
|
||||||
@@ -87,6 +91,7 @@ class SightsStore {
|
|||||||
`/sight/${id}`,
|
`/sight/${id}`,
|
||||||
{
|
{
|
||||||
name: this.createSight[anotherLanguages[0] as Language].name,
|
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,
|
address: this.createSight[anotherLanguages[0] as Language].address,
|
||||||
city_id: city,
|
city_id: city,
|
||||||
latitude: coordinates.latitude,
|
latitude: coordinates.latitude,
|
||||||
@@ -98,6 +103,7 @@ class SightsStore {
|
|||||||
`/sight/${id}`,
|
`/sight/${id}`,
|
||||||
{
|
{
|
||||||
name: this.createSight[anotherLanguages[1] as Language].name,
|
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,
|
address: this.createSight[anotherLanguages[1] as Language].address,
|
||||||
city_id: city,
|
city_id: city,
|
||||||
latitude: coordinates.latitude,
|
latitude: coordinates.latitude,
|
||||||
@@ -107,9 +113,9 @@ class SightsStore {
|
|||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.createSight = {
|
this.createSight = {
|
||||||
ru: { name: "", address: "" },
|
ru: { name: "", short_name: "", address: "" },
|
||||||
en: { name: "", address: "" },
|
en: { name: "", short_name: "", address: "" },
|
||||||
zh: { name: "", address: "" },
|
zh: { name: "", short_name: "", address: "" },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -156,14 +162,17 @@ class SightsStore {
|
|||||||
this.createSight = {
|
this.createSight = {
|
||||||
ru: {
|
ru: {
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ class SnapshotStore {
|
|||||||
ru: {
|
ru: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -164,6 +165,7 @@ class SnapshotStore {
|
|||||||
en: {
|
en: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
@@ -171,6 +173,7 @@ class SnapshotStore {
|
|||||||
zh: {
|
zh: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "",
|
name: "",
|
||||||
|
short_name: "",
|
||||||
address: "",
|
address: "",
|
||||||
left: { heading: "", body: "", media: [] },
|
left: { heading: "", body: "", media: [] },
|
||||||
right: [],
|
right: [],
|
||||||
|
|||||||
@@ -237,6 +237,21 @@ export const CreateInformationTab = observer(
|
|||||||
variant="outlined"
|
variant="outlined"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
label={`Сокращенное название (${language.toUpperCase()})`}
|
||||||
|
value={data.short_name || ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleChange(
|
||||||
|
{
|
||||||
|
short_name: e.target.value,
|
||||||
|
},
|
||||||
|
language
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
fullWidth
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Адрес"
|
label="Адрес"
|
||||||
value={data.address}
|
value={data.address}
|
||||||
|
|||||||
@@ -241,6 +241,18 @@ export const InformationTab = observer(
|
|||||||
variant="outlined"
|
variant="outlined"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
label={`Сокращенное название (${language.toUpperCase()})`}
|
||||||
|
value={sight[language].short_name || ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleChange(language as Language, {
|
||||||
|
short_name: e.target.value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
fullWidth
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Адрес"
|
label="Адрес"
|
||||||
value={sight[language].address}
|
value={sight[language].address}
|
||||||
|
|||||||
Reference in New Issue
Block a user