From 0fe468368387b0deddc2f2e8f9e43d95c18098ad Mon Sep 17 00:00:00 2001 From: itoshi Date: Sat, 7 Jun 2025 15:16:29 +0300 Subject: [PATCH] feat: fix sight edit --- src/pages/CreateSightPage/index.tsx | 11 +- src/pages/EditSightPage/index.tsx | 4 +- src/pages/Sight/SightListPage/index.tsx | 9 +- .../modals/SelectArticleDialog/index.tsx | 147 +++++++------- src/shared/modals/UploadMediaDialog/index.tsx | 10 +- src/shared/store/CreateSightStore/index.tsx | 51 +++-- src/shared/store/EditSightStore/index.tsx | 182 +++++++++++------- src/widgets/ImageUploadCard/index.tsx | 21 +- src/widgets/MediaArea/index.tsx | 4 +- src/widgets/MediaViewer/index.tsx | 31 +-- src/widgets/ReactMarkdownEditor/index.tsx | 16 +- .../SightTabs/CreateInformationTab/index.tsx | 23 ++- src/widgets/SightTabs/CreateLeftTab/index.tsx | 113 ++++++----- .../SightTabs/CreateRightTab/index.tsx | 19 +- .../SightTabs/InformationTab/index.tsx | 24 ++- src/widgets/SightTabs/LeftWidgetTab/index.tsx | 21 +- .../SightTabs/RightWidgetTab/index.tsx | 27 +-- 17 files changed, 438 insertions(+), 275 deletions(-) diff --git a/src/pages/CreateSightPage/index.tsx b/src/pages/CreateSightPage/index.tsx index 416ac69..96cdeea 100644 --- a/src/pages/CreateSightPage/index.tsx +++ b/src/pages/CreateSightPage/index.tsx @@ -1,5 +1,10 @@ import { Box, Tab, Tabs } from "@mui/material"; -import { articlesStore, cityStore, languageStore } from "@shared"; +import { + articlesStore, + cityStore, + createSightStore, + languageStore, +} from "@shared"; import { CreateInformationTab, CreateLeftTab, @@ -22,13 +27,15 @@ export const CreateSightPage = observer(() => { const [value, setValue] = useState(0); const { getCities } = cityStore; const { getArticles } = articlesStore; + const { needLeaveAgree } = createSightStore; + const handleChange = (_: React.SyntheticEvent, newValue: number) => { setValue(newValue); }; let blocker = useBlocker( ({ currentLocation, nextLocation }) => - true && currentLocation.pathname !== nextLocation.pathname + needLeaveAgree && currentLocation.pathname !== nextLocation.pathname ); useEffect(() => { diff --git a/src/pages/EditSightPage/index.tsx b/src/pages/EditSightPage/index.tsx index 6b1131b..63d5887 100644 --- a/src/pages/EditSightPage/index.tsx +++ b/src/pages/EditSightPage/index.tsx @@ -20,7 +20,7 @@ function a11yProps(index: number) { export const EditSightPage = observer(() => { const [value, setValue] = useState(0); - const { sight, getSightInfo } = editSightStore; + const { sight, getSightInfo, needLeaveAgree } = editSightStore; const { getArticles } = articlesStore; const { language } = languageStore; const { id } = useParams(); @@ -28,7 +28,7 @@ export const EditSightPage = observer(() => { let blocker = useBlocker( ({ currentLocation, nextLocation }) => - true && currentLocation.pathname !== nextLocation.pathname + needLeaveAgree && currentLocation.pathname !== nextLocation.pathname ); const handleChange = (_: React.SyntheticEvent, newValue: number) => { diff --git a/src/pages/Sight/SightListPage/index.tsx b/src/pages/Sight/SightListPage/index.tsx index adf635b..bd72138 100644 --- a/src/pages/Sight/SightListPage/index.tsx +++ b/src/pages/Sight/SightListPage/index.tsx @@ -4,7 +4,7 @@ import { useEffect, useState } from "react"; import { observer } from "mobx-react-lite"; import { Pencil, Trash2 } from "lucide-react"; import { useNavigate } from "react-router-dom"; -import { DeleteModal, LanguageSwitcher } from "@widgets"; +import { CreateButton, DeleteModal, LanguageSwitcher } from "@widgets"; export const SightListPage = observer(() => { const { sights, getSights, deleteListSight } = sightsStore; @@ -69,6 +69,13 @@ export const SightListPage = observer(() => {
+
+

Достопримечательности

+ +
- - + - {articlesStore.articleMedia ? ( - - ) : ( - - )} - + minWidth: 320, + maxWidth: 310, - - - {articlesStore.articleData?.heading || "Название cтатьи"} - - - - {articlesStore.articleData?.body && ( - + {articlesStore.articleMedia ? ( + + ) : ( + + )} - )} - + + + + {articlesStore.articleData?.heading || "Название cтатьи"} + + + + {articlesStore.articleData?.body && ( + + + + )} + + diff --git a/src/shared/modals/UploadMediaDialog/index.tsx b/src/shared/modals/UploadMediaDialog/index.tsx index b3daf7f..aaa2978 100644 --- a/src/shared/modals/UploadMediaDialog/index.tsx +++ b/src/shared/modals/UploadMediaDialog/index.tsx @@ -1,4 +1,4 @@ -import { MEDIA_TYPE_LABELS, editSightStore } from "@shared"; +import { MEDIA_TYPE_LABELS, MEDIA_TYPE_VALUES, editSightStore } from "@shared"; import { observer } from "mobx-react-lite"; import { useEffect, useState } from "react"; import { @@ -31,6 +31,7 @@ interface UploadMediaDialogProps { media_type: number; }) => void; afterUploadSight?: (id: string) => void; + hardcodeType?: "thumbnail" | "watermark_lu" | "watermark_rd" | null; } export const UploadMediaDialog = observer( @@ -39,6 +40,7 @@ export const UploadMediaDialog = observer( onClose, afterUpload, afterUploadSight, + hardcodeType, }: UploadMediaDialogProps) => { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); @@ -165,10 +167,12 @@ export const UploadMediaDialog = observer( Тип медиа