fix: Fix bugs
This commit is contained in:
@ -24,7 +24,7 @@ export const EditSightPage = observer(() => {
|
|||||||
const { getArticles } = articlesStore;
|
const { getArticles } = articlesStore;
|
||||||
const { language } = languageStore;
|
const { language } = languageStore;
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const { getCities } = cityStore;
|
const { getRuCities } = cityStore;
|
||||||
|
|
||||||
let blocker = useBlocker(
|
let blocker = useBlocker(
|
||||||
({ currentLocation, nextLocation }) =>
|
({ currentLocation, nextLocation }) =>
|
||||||
@ -40,7 +40,7 @@ export const EditSightPage = observer(() => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
await getSightInfo(+id, language);
|
await getSightInfo(+id, language);
|
||||||
await getArticles(language);
|
await getArticles(language);
|
||||||
await getCities();
|
await getRuCities();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { authInstance } from "@shared";
|
import { authInstance, languageInstance } from "@shared";
|
||||||
import { makeAutoObservable, runInAction } from "mobx";
|
import { makeAutoObservable, runInAction } from "mobx";
|
||||||
|
|
||||||
type City = {
|
type City = {
|
||||||
@ -11,7 +11,9 @@ type City = {
|
|||||||
|
|
||||||
class CityStore {
|
class CityStore {
|
||||||
cities: City[] = [];
|
cities: City[] = [];
|
||||||
|
ruCities: City[] = [];
|
||||||
city: City | null = null;
|
city: City | null = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
@ -24,6 +26,14 @@ class CityStore {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getRuCities = async () => {
|
||||||
|
const response = await languageInstance("ru").get("/city");
|
||||||
|
|
||||||
|
runInAction(() => {
|
||||||
|
this.ruCities = response.data;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
deleteCity = async (id: number) => {
|
deleteCity = async (id: number) => {
|
||||||
await authInstance.delete(`/city/${id}`);
|
await authInstance.delete(`/city/${id}`);
|
||||||
|
|
||||||
|
@ -106,10 +106,17 @@ class CreateSightStore {
|
|||||||
try {
|
try {
|
||||||
this.needLeaveAgree = true;
|
this.needLeaveAgree = true;
|
||||||
const articleRes = await authInstance.post("/article", {
|
const articleRes = await authInstance.post("/article", {
|
||||||
translation: {
|
translations: {
|
||||||
ru: articleRuData,
|
heading: {
|
||||||
en: articleEnData,
|
ru: articleRuData.heading,
|
||||||
zh: articleZhData,
|
en: articleEnData.heading,
|
||||||
|
zh: articleZhData.heading,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
ru: articleRuData.body,
|
||||||
|
en: articleEnData.body,
|
||||||
|
zh: articleZhData.body,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { id } = articleRes.data; // New article's ID
|
const { id } = articleRes.data; // New article's ID
|
||||||
|
@ -265,18 +265,16 @@ class EditSightStore {
|
|||||||
this.sight.common.left_article != null
|
this.sight.common.left_article != null
|
||||||
) {
|
) {
|
||||||
await authInstance.patch(`/article/${this.sight.common.left_article}`, {
|
await authInstance.patch(`/article/${this.sight.common.left_article}`, {
|
||||||
translation: {
|
translations: {
|
||||||
ru: {
|
heading: {
|
||||||
heading: this.sight.ru.left.heading,
|
ru: this.sight.ru.left.heading,
|
||||||
body: this.sight.ru.left.body,
|
en: this.sight.en.left.heading,
|
||||||
|
zh: this.sight.zh.left.heading,
|
||||||
},
|
},
|
||||||
en: {
|
body: {
|
||||||
heading: this.sight.en.left.heading,
|
ru: this.sight.ru.left.body,
|
||||||
body: this.sight.en.left.body,
|
en: this.sight.en.left.body,
|
||||||
},
|
zh: this.sight.zh.left.body,
|
||||||
zh: {
|
|
||||||
heading: this.sight.zh.left.heading,
|
|
||||||
body: this.sight.zh.left.body,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -284,39 +282,36 @@ class EditSightStore {
|
|||||||
|
|
||||||
await authInstance.patch(`/sight/${this.sight.common.id}`, {
|
await authInstance.patch(`/sight/${this.sight.common.id}`, {
|
||||||
...this.sight.common,
|
...this.sight.common,
|
||||||
translation: {
|
translations: {
|
||||||
ru: {
|
name: {
|
||||||
name: this.sight.ru.name,
|
ru: this.sight.ru.name,
|
||||||
address: this.sight.ru.address,
|
en: this.sight.en.name,
|
||||||
|
zh: this.sight.zh.name,
|
||||||
},
|
},
|
||||||
en: {
|
address: {
|
||||||
name: this.sight.en.name,
|
ru: this.sight.ru.address,
|
||||||
address: this.sight.en.address,
|
en: this.sight.en.address,
|
||||||
},
|
zh: this.sight.zh.address,
|
||||||
zh: {
|
|
||||||
name: this.sight.zh.name,
|
|
||||||
address: this.sight.zh.address,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const article of this.sight.ru.right) {
|
for (let index = 0; index < this.sight.ru.right.length; index++) {
|
||||||
|
const article = this.sight.ru.right[index];
|
||||||
if (article.id == 0 || article.id == null) {
|
if (article.id == 0 || article.id == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await authInstance.patch(`/article/${article.id}`, {
|
await authInstance.patch(`/article/${article.id}`, {
|
||||||
translation: {
|
translations: {
|
||||||
ru: {
|
heading: {
|
||||||
heading: article.heading,
|
ru: this.sight.ru.right[index].heading,
|
||||||
body: article.body,
|
en: this.sight.en.right[index].heading,
|
||||||
|
zh: this.sight.zh.right[index].heading,
|
||||||
},
|
},
|
||||||
en: {
|
body: {
|
||||||
heading: article.heading,
|
ru: this.sight.ru.right[index].body,
|
||||||
body: article.body,
|
en: this.sight.en.right[index].body,
|
||||||
},
|
zh: this.sight.zh.right[index].body,
|
||||||
zh: {
|
|
||||||
heading: article.heading,
|
|
||||||
body: article.body,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -604,10 +599,17 @@ class EditSightStore {
|
|||||||
body: "Новый текст (ZH)",
|
body: "Новый текст (ZH)",
|
||||||
};
|
};
|
||||||
const articleId = await authInstance.post("/article", {
|
const articleId = await authInstance.post("/article", {
|
||||||
translation: {
|
translations: {
|
||||||
ru: articleRuData,
|
heading: {
|
||||||
en: articleEnData,
|
ru: articleRuData.heading,
|
||||||
zh: articleZhData,
|
en: articleEnData.heading,
|
||||||
|
zh: articleZhData.heading,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
ru: articleRuData.body,
|
||||||
|
en: articleEnData.body,
|
||||||
|
zh: articleZhData.body,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { id } = articleId.data;
|
const { id } = articleId.data;
|
||||||
|
@ -44,7 +44,7 @@ export const LanguageSwitcher = observer(() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed bottom-0 left-1/2 -translate-x-1/2 flex gap-2 p-4 z-10 ">
|
<div className="fixed bottom-0 left-1/2 -translate-x-1/2 flex gap-2 p-4 z-100000000">
|
||||||
{/* Added some styling for better visualization */}
|
{/* Added some styling for better visualization */}
|
||||||
{LANGUAGES.map((lang) => (
|
{LANGUAGES.map((lang) => (
|
||||||
<Button
|
<Button
|
||||||
|
@ -31,7 +31,7 @@ import { toast } from "react-toastify";
|
|||||||
|
|
||||||
export const CreateInformationTab = observer(
|
export const CreateInformationTab = observer(
|
||||||
({ value, index }: { value: number; index: number }) => {
|
({ value, index }: { value: number; index: number }) => {
|
||||||
const { cities } = cityStore;
|
const { ruCities } = cityStore;
|
||||||
const [mediaId, setMediaId] = useState<string>("");
|
const [mediaId, setMediaId] = useState<string>("");
|
||||||
const [isPreviewMediaOpen, setIsPreviewMediaOpen] = useState(false);
|
const [isPreviewMediaOpen, setIsPreviewMediaOpen] = useState(false);
|
||||||
const [isUploadMediaOpen, setIsUploadMediaOpen] = useState(false);
|
const [isUploadMediaOpen, setIsUploadMediaOpen] = useState(false);
|
||||||
@ -120,7 +120,10 @@ export const CreateInformationTab = observer(
|
|||||||
paddingBottom: "70px" /* Space for save button */,
|
paddingBottom: "70px" /* Space for save button */,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div className="flex gap-10 items-center mb-5 max-w-[80%]">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
|
<h1 className="text-3xl break-words">{sight[language].name}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -172,9 +175,9 @@ export const CreateInformationTab = observer(
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
options={cities ?? []}
|
options={ruCities ?? []}
|
||||||
value={
|
value={
|
||||||
cities.find((city) => city.id === sight.city_id) ?? null
|
ruCities.find((city) => city.id === sight.city_id) ?? null
|
||||||
}
|
}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
onChange={(_, value) => {
|
onChange={(_, value) => {
|
||||||
@ -271,7 +274,7 @@ export const CreateInformationTab = observer(
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<ImageUploadCard
|
<ImageUploadCard
|
||||||
title="Водяной знак (леввый верхний)"
|
title="Водяной знак (левый верхний)"
|
||||||
imageKey="watermark_lu"
|
imageKey="watermark_lu"
|
||||||
imageUrl={sight.watermark_lu}
|
imageUrl={sight.watermark_lu}
|
||||||
onImageClick={() => {
|
onImageClick={() => {
|
||||||
|
@ -109,7 +109,10 @@ export const CreateLeftTab = observer(
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div className="flex gap-10 items-center mb-5 max-w-[80%]">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
|
<h1 className="text-3xl break-words">{sight[language].name}</h1>
|
||||||
|
</div>
|
||||||
<Paper
|
<Paper
|
||||||
elevation={2}
|
elevation={2}
|
||||||
sx={{
|
sx={{
|
||||||
@ -210,7 +213,7 @@ export const CreateLeftTab = observer(
|
|||||||
|
|
||||||
<ReactMarkdownEditor
|
<ReactMarkdownEditor
|
||||||
value={sight[language].left.body}
|
value={sight[language].left.body}
|
||||||
onChange={(value) =>
|
onChange={(value: any) =>
|
||||||
updateSightInfo(
|
updateSightInfo(
|
||||||
{
|
{
|
||||||
left: {
|
left: {
|
||||||
|
@ -256,7 +256,10 @@ export const CreateRightTab = observer(
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div className="flex gap-10 items-center mb-5 max-w-[80%]">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
|
<h1 className="text-3xl break-words">{sight[language].name}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Box sx={{ display: "flex", flexGrow: 1, gap: 2.5 }}>
|
<Box sx={{ display: "flex", flexGrow: 1, gap: 2.5 }}>
|
||||||
{/* Left Column: Navigation & Article List */}
|
{/* Left Column: Navigation & Article List */}
|
||||||
|
@ -32,7 +32,7 @@ import { toast } from "react-toastify";
|
|||||||
|
|
||||||
export const InformationTab = observer(
|
export const InformationTab = observer(
|
||||||
({ value, index }: { value: number; index: number }) => {
|
({ value, index }: { value: number; index: number }) => {
|
||||||
const { cities } = cityStore;
|
const { ruCities } = cityStore;
|
||||||
|
|
||||||
const [mediaId, setMediaId] = useState<string>("");
|
const [mediaId, setMediaId] = useState<string>("");
|
||||||
const [isPreviewMediaOpen, setIsPreviewMediaOpen] = useState(false);
|
const [isPreviewMediaOpen, setIsPreviewMediaOpen] = useState(false);
|
||||||
@ -113,7 +113,11 @@ export const InformationTab = observer(
|
|||||||
paddingBottom: "70px" /* Space for save button */,
|
paddingBottom: "70px" /* Space for save button */,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div className="flex gap-10 items-center mb-5 max-w-[80%]">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
|
<h1 className="text-3xl break-words">{sight[language].name}</h1>
|
||||||
|
</div>
|
||||||
|
<LanguageSwitcher />
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -159,9 +163,9 @@ export const InformationTab = observer(
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
options={cities ?? []}
|
options={ruCities ?? []}
|
||||||
value={
|
value={
|
||||||
cities.find((city) => city.id === sight.common.city_id) ??
|
ruCities.find((city) => city.id === sight.common.city_id) ??
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
|
@ -121,7 +121,10 @@ export const LeftWidgetTab = observer(
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div className="flex gap-10 items-center mb-5 max-w-[80%]">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
|
<h1 className="text-3xl break-words">{sight[language].name}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Paper
|
<Paper
|
||||||
elevation={2}
|
elevation={2}
|
||||||
@ -223,7 +226,7 @@ export const LeftWidgetTab = observer(
|
|||||||
|
|
||||||
<ReactMarkdownEditor
|
<ReactMarkdownEditor
|
||||||
value={data?.left?.body}
|
value={data?.left?.body}
|
||||||
onChange={(value) =>
|
onChange={(value: any) =>
|
||||||
updateSightInfo(languageStore.language, {
|
updateSightInfo(languageStore.language, {
|
||||||
left: {
|
left: {
|
||||||
heading: sight[languageStore.language].left.heading,
|
heading: sight[languageStore.language].left.heading,
|
||||||
|
@ -199,7 +199,10 @@ export const RightWidgetTab = observer(
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div className="flex gap-10 items-center mb-5 max-w-[80%]">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
|
<h1 className="text-3xl break-words">{sight[language].name}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Box sx={{ display: "flex", flexGrow: 1, gap: 2.5 }}>
|
<Box sx={{ display: "flex", flexGrow: 1, gap: 2.5 }}>
|
||||||
<Box className="flex flex-col w-[75%] gap-2">
|
<Box className="flex flex-col w-[75%] gap-2">
|
||||||
|
Reference in New Issue
Block a user