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