feat: add scrollable menu with fade hints and home button transition
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect, useRef, useMemo } from "react";
|
import React, { useState, useEffect, useRef, useMemo, useLayoutEffect, useCallback } from "react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { useGeolocationStore } from "../../stores";
|
import { useGeolocationStore } from "../../stores";
|
||||||
@@ -46,6 +46,44 @@ const SightFrame = observer(({ media, sight_id, sight_name }) => {
|
|||||||
const idleTimerRef = useRef(null);
|
const idleTimerRef = useRef(null);
|
||||||
|
|
||||||
const textWrapperRef = useRef(null);
|
const textWrapperRef = useRef(null);
|
||||||
|
const menuRef = useRef(null);
|
||||||
|
const [menuNeedsScroll, setMenuNeedsScroll] = useState(false);
|
||||||
|
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
||||||
|
const [canScrollRight, setCanScrollRight] = useState(false);
|
||||||
|
|
||||||
|
const updateScrollState = useCallback(() => {
|
||||||
|
const menu = menuRef.current;
|
||||||
|
if (!menu) return;
|
||||||
|
setCanScrollLeft(menu.scrollLeft > 2);
|
||||||
|
setCanScrollRight(menu.scrollLeft + menu.clientWidth < menu.scrollWidth - 2);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const menu = menuRef.current;
|
||||||
|
if (!menu || !menuNeedsScroll) {
|
||||||
|
setCanScrollLeft(false);
|
||||||
|
setCanScrollRight(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateScrollState();
|
||||||
|
menu.addEventListener('scroll', updateScrollState);
|
||||||
|
return () => menu.removeEventListener('scroll', updateScrollState);
|
||||||
|
}, [menuNeedsScroll, updateScrollState]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const menu = menuRef.current;
|
||||||
|
if (!menu) return;
|
||||||
|
const children = Array.from(menu.querySelectorAll('.sight-frame-menu-point'));
|
||||||
|
if (children.length < 2) {
|
||||||
|
setMenuNeedsScroll(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const style = getComputedStyle(menu);
|
||||||
|
const availableWidth = menu.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
||||||
|
const totalChildrenWidth = children.reduce((sum, el) => sum + el.offsetWidth, 0);
|
||||||
|
const evenGap = (availableWidth - totalChildrenWidth) / (children.length + 1);
|
||||||
|
setMenuNeedsScroll(evenGap < 10);
|
||||||
|
}, [articleSections, selectedSection]);
|
||||||
|
|
||||||
// Автозакрытие fullscreen 3D при бездействии (60 сек)
|
// Автозакрытие fullscreen 3D при бездействии (60 сек)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -674,8 +712,14 @@ const SightFrame = observer(({ media, sight_id, sight_name }) => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="sight-frame-menu" style={selectedSection !== 0 ? { paddingLeft: '50px' } : undefined}>
|
<div className="sight-frame-menu-wrapper">
|
||||||
{selectedSection !== 0 && (
|
<div className="sight-frame-menu-fade left" style={{ opacity: canScrollLeft ? 1 : 0 }} />
|
||||||
|
<div className="sight-frame-menu-fade right" style={{ opacity: canScrollRight ? 1 : 0 }} />
|
||||||
|
<div
|
||||||
|
className="sight-frame-menu"
|
||||||
|
ref={menuRef}
|
||||||
|
style={menuNeedsScroll ? { justifyContent: 'space-between' } : undefined}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
@@ -687,6 +731,10 @@ const SightFrame = observer(({ media, sight_id, sight_name }) => {
|
|||||||
paddingTop: "4.5px",
|
paddingTop: "4.5px",
|
||||||
paddingBottom: "4.5px",
|
paddingBottom: "4.5px",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
|
opacity: selectedSection !== 0 ? 1 : 0,
|
||||||
|
transform: selectedSection !== 0 ? "scale(1)" : "scale(0.5)",
|
||||||
|
transition: "opacity 0.3s ease, transform 0.3s ease",
|
||||||
|
pointerEvents: selectedSection !== 0 ? "auto" : "none",
|
||||||
}}
|
}}
|
||||||
onPointerUp={() => {
|
onPointerUp={() => {
|
||||||
setSelectedSection(0);
|
setSelectedSection(0);
|
||||||
@@ -701,7 +749,6 @@ const SightFrame = observer(({ media, sight_id, sight_name }) => {
|
|||||||
style={{ display: "block" }}
|
style={{ display: "block" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
{contentError ? (
|
{contentError ? (
|
||||||
<p className="error-message">{contentError}</p>
|
<p className="error-message">{contentError}</p>
|
||||||
) : (
|
) : (
|
||||||
@@ -726,6 +773,7 @@ const SightFrame = observer(({ media, sight_id, sight_name }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -362,9 +362,37 @@
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sight-frame-menu-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sight-frame-menu-fade {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 120px;
|
||||||
|
z-index: 3;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sight-frame-menu-fade.left {
|
||||||
|
left: 0;
|
||||||
|
background: linear-gradient(to right, rgba(var(--carrier-right-menu-rgb, 179, 165, 152), 0.95), transparent);
|
||||||
|
border-radius: 0 0 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sight-frame-menu-fade.right {
|
||||||
|
right: 0;
|
||||||
|
background: linear-gradient(to left, rgba(var(--carrier-right-menu-rgb, 179, 165, 152), 0.95), transparent);
|
||||||
|
border-radius: 0 0 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.sight-frame-menu {
|
.sight-frame-menu {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 7px;
|
padding: 7px 60px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -382,6 +410,17 @@
|
|||||||
backdrop-filter: blur(10px);
|
backdrop-filter: blur(10px);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sight-frame-menu::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sight-frame-menu {
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
scrollbar-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sight-frame-menu-point {
|
.sight-frame-menu-point {
|
||||||
@@ -393,6 +432,7 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
flex-shrink: 0;
|
||||||
transition:
|
transition:
|
||||||
background-color 0.1s ease,
|
background-color 0.1s ease,
|
||||||
color 0.1s ease;
|
color 0.1s ease;
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { ArrowLeft } from "lucide-react";
|
import { ArrowLeft } from "lucide-react";
|
||||||
import { LanguageSwitcher } from "@widgets";
|
import { LanguageSwitcher } from "@widgets";
|
||||||
import { articlesStore } from "@shared";
|
import { articlesStore, selectedCityStore } from "@shared";
|
||||||
|
|
||||||
const ArticleCreatePage: React.FC = () => {
|
const ArticleCreatePage: React.FC = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const { articleData } = articlesStore;
|
const { articleData } = articlesStore;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
|
|||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { ArrowLeft } from "lucide-react";
|
import { ArrowLeft } from "lucide-react";
|
||||||
import { LanguageSwitcher } from "@widgets";
|
import { LanguageSwitcher } from "@widgets";
|
||||||
import { articlesStore, languageStore } from "@shared";
|
import { articlesStore, languageStore, selectedCityStore } from "@shared";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
|
||||||
const ArticleEditPage: React.FC = observer(() => {
|
const ArticleEditPage: React.FC = observer(() => {
|
||||||
@@ -11,6 +11,11 @@ const ArticleEditPage: React.FC = observer(() => {
|
|||||||
|
|
||||||
const { articleData, getArticle } = articlesStore;
|
const { articleData, getArticle } = articlesStore;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Устанавливаем русский язык при загрузке страницы
|
// Устанавливаем русский язык при загрузке страницы
|
||||||
languageStore.setLanguage("ru");
|
languageStore.setLanguage("ru");
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
languageStore,
|
languageStore,
|
||||||
isMediaIdEmpty,
|
isMediaIdEmpty,
|
||||||
useSelectedCity,
|
useSelectedCity,
|
||||||
|
selectedCityStore,
|
||||||
SelectMediaDialog,
|
SelectMediaDialog,
|
||||||
UploadMediaDialog,
|
UploadMediaDialog,
|
||||||
PreviewMediaDialog,
|
PreviewMediaDialog,
|
||||||
@@ -93,6 +94,11 @@ export const CarrierCreatePage = observer(() => {
|
|||||||
"thumbnail" | "watermark_lu" | "watermark_rd" | "image" | null
|
"thumbnail" | "watermark_lu" | "watermark_rd" | "image" | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchCities = async () => {
|
const fetchCities = async () => {
|
||||||
if (!authStore.me) {
|
if (!authStore.me) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
languageStore,
|
languageStore,
|
||||||
isMediaIdEmpty,
|
isMediaIdEmpty,
|
||||||
LoadingSpinner,
|
LoadingSpinner,
|
||||||
|
selectedCityStore,
|
||||||
} from "@shared";
|
} from "@shared";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { ImageUploadCard, LanguageSwitcher, DeleteModal } from "@widgets";
|
import { ImageUploadCard, LanguageSwitcher, DeleteModal } from "@widgets";
|
||||||
@@ -103,6 +104,11 @@ export const CarrierEditPage = observer(() => {
|
|||||||
"thumbnail" | "watermark_lu" | "watermark_rd" | "image" | null
|
"thumbnail" | "watermark_lu" | "watermark_rd" | "image" | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid";
|
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid";
|
||||||
import { ruRU } from "@mui/x-data-grid/locales";
|
import { ruRU } from "@mui/x-data-grid/locales";
|
||||||
import { authStore, languageStore, cityStore, countryStore, selectedCityStore, SearchInput } from "@shared";
|
import { authStore, languageStore, cityStore, countryStore, SearchInput } from "@shared";
|
||||||
import { useEffect, useState, useMemo } from "react";
|
import { useEffect, useState, useMemo } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Pencil, Trash2, Minus } from "lucide-react";
|
import { Pencil, Trash2, Minus } from "lucide-react";
|
||||||
@@ -59,21 +59,16 @@ export const CityListPage = observer(() => {
|
|||||||
}, [cities, countryStore.countries, language, isLoading]);
|
}, [cities, countryStore.countries, language, isLoading]);
|
||||||
|
|
||||||
const filteredRows = useMemo(() => {
|
const filteredRows = useMemo(() => {
|
||||||
const { selectedCityId } = selectedCityStore;
|
|
||||||
if (!selectedCityId) return [];
|
|
||||||
|
|
||||||
const query = searchQuery.trim().toLowerCase();
|
const query = searchQuery.trim().toLowerCase();
|
||||||
const result = rows.filter((row) => row.id === selectedCityId);
|
if (!query) return rows;
|
||||||
|
return rows.filter((row) => {
|
||||||
if (!query) return result;
|
|
||||||
return result.filter((row) => {
|
|
||||||
const cityName = (row.name ?? "").toLowerCase();
|
const cityName = (row.name ?? "").toLowerCase();
|
||||||
const countryName = (
|
const countryName = (
|
||||||
countryStore.countries[language]?.data?.find((c) => c.code === row.country)?.name ?? ""
|
countryStore.countries[language]?.data?.find((c) => c.code === row.country)?.name ?? ""
|
||||||
).toLowerCase();
|
).toLowerCase();
|
||||||
return cityName.includes(query) || countryName.includes(query);
|
return cityName.includes(query) || countryName.includes(query);
|
||||||
});
|
});
|
||||||
}, [rows, searchQuery, countryStore.countries, language, selectedCityStore.selectedCityId]);
|
}, [rows, searchQuery, countryStore.countries, language]);
|
||||||
|
|
||||||
const columns: GridColDef[] = [
|
const columns: GridColDef[] = [
|
||||||
{
|
{
|
||||||
@@ -148,7 +143,6 @@ export const CityListPage = observer(() => {
|
|||||||
<CreateButton
|
<CreateButton
|
||||||
label="Создать город"
|
label="Создать город"
|
||||||
path="/city/create"
|
path="/city/create"
|
||||||
disabled={!selectedCityStore.selectedCityId}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -214,8 +208,6 @@ export const CityListPage = observer(() => {
|
|||||||
<Box sx={{ mt: 5, textAlign: "center", color: "text.secondary" }}>
|
<Box sx={{ mt: 5, textAlign: "center", color: "text.secondary" }}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<CircularProgress size={20} />
|
<CircularProgress size={20} />
|
||||||
) : !selectedCityStore.selectedCityId ? (
|
|
||||||
"Выберите город"
|
|
||||||
) : (
|
) : (
|
||||||
"Нет городов"
|
"Нет городов"
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid";
|
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid";
|
||||||
import { ruRU } from "@mui/x-data-grid/locales";
|
import { ruRU } from "@mui/x-data-grid/locales";
|
||||||
import { authStore, countryStore, languageStore, selectedCityStore, SearchInput } from "@shared";
|
import { authStore, countryStore, languageStore, SearchInput } from "@shared";
|
||||||
import { useEffect, useState, useMemo } from "react";
|
import { useEffect, useState, useMemo } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Trash2, Minus } from "lucide-react";
|
import { Trash2, Minus } from "lucide-react";
|
||||||
@@ -74,20 +74,15 @@ export const CountryListPage = observer(() => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const rows = useMemo(() => {
|
const rows = useMemo(() => {
|
||||||
const { selectedCity } = selectedCityStore;
|
|
||||||
if (!selectedCity) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const query = searchQuery.trim().toLowerCase();
|
const query = searchQuery.trim().toLowerCase();
|
||||||
return (countries[language]?.data ?? [])
|
return (countries[language]?.data ?? [])
|
||||||
.filter((country) => country.code === selectedCity.country_code)
|
|
||||||
.filter((country) => !query || (country.name ?? "").toLowerCase().includes(query))
|
.filter((country) => !query || (country.name ?? "").toLowerCase().includes(query))
|
||||||
.map((country) => ({
|
.map((country) => ({
|
||||||
id: country.code,
|
id: country.code,
|
||||||
code: country.code,
|
code: country.code,
|
||||||
name: country.name,
|
name: country.name,
|
||||||
}));
|
}));
|
||||||
}, [countries[language]?.data, searchQuery, selectedCityStore.selectedCity]);
|
}, [countries[language]?.data, searchQuery]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -100,7 +95,6 @@ export const CountryListPage = observer(() => {
|
|||||||
<CreateButton
|
<CreateButton
|
||||||
label="Добавить страну"
|
label="Добавить страну"
|
||||||
path="/country/add"
|
path="/country/add"
|
||||||
disabled={!selectedCityStore.selectedCityId}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -161,8 +155,6 @@ export const CountryListPage = observer(() => {
|
|||||||
<Box sx={{ mt: 5, textAlign: "center", color: "text.secondary" }}>
|
<Box sx={{ mt: 5, textAlign: "center", color: "text.secondary" }}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<CircularProgress size={20} />
|
<CircularProgress size={20} />
|
||||||
) : !selectedCityStore.selectedCityId ? (
|
|
||||||
"Выберите город"
|
|
||||||
) : (
|
) : (
|
||||||
"Нет стран"
|
"Нет стран"
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -37,16 +37,6 @@ export const CreateSightPage = observer(() => {
|
|||||||
return () => selectedCityStore.setIsLocked(false);
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const { selectedCityId, selectedCity } = selectedCityStore;
|
|
||||||
if (selectedCityId && selectedCity && !createSightStore.sight.city_id) {
|
|
||||||
runInAction(() => {
|
|
||||||
createSightStore.sight.city_id = selectedCityId;
|
|
||||||
createSightStore.sight.city = selectedCity.name;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleChange = (_: React.SyntheticEvent, newValue: number) => {
|
const handleChange = (_: React.SyntheticEvent, newValue: number) => {
|
||||||
setValue(newValue);
|
setValue(newValue);
|
||||||
};
|
};
|
||||||
@@ -73,6 +63,14 @@ export const CreateSightPage = observer(() => {
|
|||||||
await authStore.fetchMeCities().catch(() => undefined);
|
await authStore.fetchMeCities().catch(() => undefined);
|
||||||
}
|
}
|
||||||
await getArticles(languageStore.language);
|
await getArticles(languageStore.language);
|
||||||
|
|
||||||
|
const { selectedCityId, selectedCity } = selectedCityStore;
|
||||||
|
if (selectedCityId && selectedCity && !createSightStore.sight.city_id) {
|
||||||
|
runInAction(() => {
|
||||||
|
createSightStore.sight.city_id = selectedCityId;
|
||||||
|
createSightStore.sight.city = selectedCity.name;
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
import { mediaStore, MEDIA_TYPE_LABELS, selectedCityStore } from "@shared";
|
import { mediaStore, MEDIA_TYPE_LABELS, selectedCityStore } from "@shared";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { ArrowLeft, Loader2, Save } from "lucide-react";
|
import { ArrowLeft, Loader2, Save } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
|
|
||||||
@@ -20,6 +20,11 @@ export const MediaCreatePage = observer(() => {
|
|||||||
const [type, setType] = useState("");
|
const [type, setType] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
MEDIA_TYPE_LABELS,
|
MEDIA_TYPE_LABELS,
|
||||||
languageStore,
|
languageStore,
|
||||||
LoadingSpinner,
|
LoadingSpinner,
|
||||||
|
selectedCityStore,
|
||||||
} from "@shared";
|
} from "@shared";
|
||||||
import { MediaViewer } from "@widgets";
|
import { MediaViewer } from "@widgets";
|
||||||
|
|
||||||
@@ -42,6 +43,11 @@ export const MediaEditPage = observer(() => {
|
|||||||
const [mediaType, setMediaType] = useState(media?.media_type ?? 1);
|
const [mediaType, setMediaType] = useState(media?.media_type ?? 1);
|
||||||
const [availableMediaTypes, setAvailableMediaTypes] = useState<number[]>([]);
|
const [availableMediaTypes, setAvailableMediaTypes] = useState<number[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
if (id) {
|
||||||
mediaStore.getOneMedia(id);
|
mediaStore.getOneMedia(id);
|
||||||
|
|||||||
@@ -254,7 +254,6 @@ export const RouteListPage = observer(() => {
|
|||||||
<CreateButton
|
<CreateButton
|
||||||
label="Создать маршрут"
|
label="Создать маршрут"
|
||||||
path="/route/create"
|
path="/route/create"
|
||||||
disabled={!selectedCityStore.selectedCityId}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ export const SightListPage = observer(() => {
|
|||||||
<CreateButton
|
<CreateButton
|
||||||
label="Создать достопримечательность"
|
label="Создать достопримечательность"
|
||||||
path="/sight/create"
|
path="/sight/create"
|
||||||
disabled={!selectedCityStore.selectedCityId}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogActions,
|
DialogActions,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { snapshotStore, authStore, routeStore } from "@shared";
|
import { snapshotStore, authStore, routeStore, selectedCityStore } from "@shared";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { ArrowLeft, Loader2, Save } from "lucide-react";
|
import { ArrowLeft, Loader2, Save } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
@@ -17,6 +17,12 @@ import { runInAction } from "mobx";
|
|||||||
export const SnapshotCreatePage = observer(() => {
|
export const SnapshotCreatePage = observer(() => {
|
||||||
const { createSnapshot, getSnapshotStatus, getStorageInfo, snapshotStatus } = snapshotStore;
|
const { createSnapshot, getSnapshotStatus, getStorageInfo, snapshotStatus } = snapshotStore;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [duplicateWarningOpen, setDuplicateWarningOpen] = useState(false);
|
const [duplicateWarningOpen, setDuplicateWarningOpen] = useState(false);
|
||||||
|
|||||||
@@ -209,7 +209,6 @@ export const StationListPage = observer(() => {
|
|||||||
<CreateButton
|
<CreateButton
|
||||||
label="Создать остановку"
|
label="Создать остановку"
|
||||||
path="/station/create"
|
path="/station/create"
|
||||||
disabled={!selectedCityStore.selectedCityId}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
SelectMediaDialog,
|
SelectMediaDialog,
|
||||||
UploadMediaDialog,
|
UploadMediaDialog,
|
||||||
PreviewMediaDialog,
|
PreviewMediaDialog,
|
||||||
|
selectedCityStore,
|
||||||
} from "@shared";
|
} from "@shared";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { ImageUploadCard } from "@widgets";
|
import { ImageUploadCard } from "@widgets";
|
||||||
@@ -79,6 +80,11 @@ export const UserCreatePage = observer(() => {
|
|||||||
createUserData.roles ?? ["articles_ro", "articles_rw", "media_ro", "media_rw"]
|
createUserData.roles ?? ["articles_ro", "articles_rw", "media_ro", "media_rw"]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mediaStore.getMedia();
|
mediaStore.getMedia();
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
authStore,
|
authStore,
|
||||||
cityStore,
|
cityStore,
|
||||||
MultiSelect,
|
MultiSelect,
|
||||||
|
selectedCityStore,
|
||||||
type User,
|
type User,
|
||||||
type UserCity,
|
type UserCity,
|
||||||
} from "@shared";
|
} from "@shared";
|
||||||
@@ -92,6 +93,11 @@ export const UserEditPage = observer(() => {
|
|||||||
"thumbnail" | "watermark_lu" | "watermark_rd" | "image" | null
|
"thumbnail" | "watermark_lu" | "watermark_rd" | "image" | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
languageStore.setLanguage("ru");
|
languageStore.setLanguage("ru");
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ export const VehicleCreatePage = observer(() => {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { language } = languageStore;
|
const { language } = languageStore;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
carrierStore.getCarriers(language);
|
carrierStore.getCarriers(language);
|
||||||
cityStore.getCities("ru");
|
cityStore.getCities("ru");
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ export const VehicleEditPage = observer(() => {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isLoadingData, setIsLoadingData] = useState(true);
|
const [isLoadingData, setIsLoadingData] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
selectedCityStore.setIsLocked(true);
|
||||||
|
return () => selectedCityStore.setIsLocked(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Устанавливаем русский язык при загрузке страницы
|
// Устанавливаем русский язык при загрузке страницы
|
||||||
languageStore.setLanguage("ru");
|
languageStore.setLanguage("ru");
|
||||||
|
|||||||
@@ -170,7 +170,6 @@ export const VehicleListPage = observer(() => {
|
|||||||
<CreateButton
|
<CreateButton
|
||||||
label="Создать транспортное средство"
|
label="Создать транспортное средство"
|
||||||
path="/vehicle/create"
|
path="/vehicle/create"
|
||||||
disabled={!selectedCityId}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -60,12 +60,6 @@ class SnapshotStore {
|
|||||||
articlesStore.articleData = null;
|
articlesStore.articleData = null;
|
||||||
articlesStore.articleMedia = null;
|
articlesStore.articleMedia = null;
|
||||||
|
|
||||||
countryStore.countries = {
|
|
||||||
ru: { data: [], loaded: false },
|
|
||||||
en: { data: [], loaded: false },
|
|
||||||
zh: { data: [], loaded: false },
|
|
||||||
};
|
|
||||||
|
|
||||||
carrierStore.carriers = {
|
carrierStore.carriers = {
|
||||||
ru: { data: [], loaded: false },
|
ru: { data: [], loaded: false },
|
||||||
en: { data: [], loaded: false },
|
en: { data: [], loaded: false },
|
||||||
|
|||||||
Reference in New Issue
Block a user