import { Box, Tab, Tabs } from "@mui/material"; import { InformationTab, LeaveAgree, RightWidgetTab } from "@widgets"; import { LeftWidgetTab } from "@widgets"; import { useEffect, useState } from "react"; import { observer } from "mobx-react-lite"; import { articlesStore, cityStore, editSightStore, languageStore, } from "@shared"; import { useBlocker, useParams } from "react-router-dom"; function a11yProps(index: number) { return { id: `sight-tab-${index}`, "aria-controls": `sight-tabpanel-${index}`, }; } export const EditSightPage = observer(() => { const [value, setValue] = useState(0); const { sight, getSightInfo, needLeaveAgree } = editSightStore; const { getArticles } = articlesStore; const { language } = languageStore; const { id } = useParams(); const { getCities } = cityStore; let blocker = useBlocker( ({ currentLocation, nextLocation }) => needLeaveAgree && currentLocation.pathname !== nextLocation.pathname ); const handleChange = (_: React.SyntheticEvent, newValue: number) => { setValue(newValue); }; useEffect(() => { const fetchData = async () => { if (id) { await getSightInfo(+id, language); await getArticles(language); await getCities(); } }; fetchData(); }, [id, language]); return ( {sight.common.id !== 0 && (
)} {blocker.state === "blocked" ? : null}
); });