feat: add sight short_name and sight features
This commit is contained in:
@@ -51,7 +51,23 @@ export const SightListPage = observer(() => {
|
||||
const columns: GridColDef[] = [
|
||||
{
|
||||
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,
|
||||
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(() => {
|
||||
<DataGrid
|
||||
rows={rows}
|
||||
columns={columns}
|
||||
onRowDoubleClick={(params) => canWriteSights && navigate(`/sight/${params.row.id}/edit`)}
|
||||
checkboxSelection={canWriteSights}
|
||||
disableRowSelectionExcludeModel
|
||||
loading={isLoading}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: "",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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: [],
|
||||
|
||||
@@ -237,6 +237,21 @@ export const CreateInformationTab = observer(
|
||||
variant="outlined"
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label={`Сокращенное название (${language.toUpperCase()})`}
|
||||
value={data.short_name || ""}
|
||||
onChange={(e) => {
|
||||
handleChange(
|
||||
{
|
||||
short_name: e.target.value,
|
||||
},
|
||||
language
|
||||
);
|
||||
}}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label="Адрес"
|
||||
value={data.address}
|
||||
|
||||
@@ -241,6 +241,18 @@ export const InformationTab = observer(
|
||||
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
|
||||
label="Адрес"
|
||||
value={sight[language].address}
|
||||
|
||||
Reference in New Issue
Block a user