import { Box, Tab, Tabs } from "@mui/material"; import { articlesStore, authStore, cityStore, createSightStore, languageStore, } from "@shared"; import { CreateInformationTab, CreateLeftTab, CreateRightTab, LeaveAgree, } from "@widgets"; import { useEffect, useState } from "react"; import { observer } from "mobx-react-lite"; function a11yProps(index: number) { return { id: `sight-tab-${index}`, "aria-controls": `sight-tabpanel-${index}`, }; } import { useBlocker } from "react-router"; 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 }) => needLeaveAgree && currentLocation.pathname !== nextLocation.pathname ); useEffect(() => { const fetchData = async () => { if (!authStore.me) { await authStore.getMeAction().catch(() => undefined); } if (authStore.canRead("cities")) { await getCities("ru"); } else { await authStore.fetchMeCities().catch(() => undefined); } await getArticles(languageStore.language); }; fetchData(); }, []); return (
{blocker.state === "blocked" ? : null}
); });