lint: Delete useless comments
This commit is contained in:
@@ -59,7 +59,6 @@ export const RouteCreatePage = observer(() => {
|
||||
articlesStore.getArticleList();
|
||||
}, [language]);
|
||||
|
||||
// Фильтруем перевозчиков только из выбранного города
|
||||
const filteredCarriers = useMemo(() => {
|
||||
const carriers =
|
||||
carrierStore.carriers[language as keyof typeof carrierStore.carriers]
|
||||
@@ -281,7 +280,6 @@ export const RouteCreatePage = observer(() => {
|
||||
const lines = routeCoords.split("\n");
|
||||
const lastLine = lines[lines.length - 1];
|
||||
|
||||
// Если мы на последней строке и она не пустая
|
||||
if (lastLine && lastLine.trim()) {
|
||||
e.preventDefault();
|
||||
const newValue = routeCoords + "\n";
|
||||
@@ -348,7 +346,6 @@ export const RouteCreatePage = observer(() => {
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{/* Видео-превью как на странице редактирования */}
|
||||
<VideoPreviewCard
|
||||
title="Видеозаставка"
|
||||
videoId={videoPreview}
|
||||
@@ -420,23 +417,17 @@ export const RouteCreatePage = observer(() => {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Модальное окно выбора или создания статьи */}
|
||||
<ArticleSelectOrCreateDialog
|
||||
open={isSelectArticleDialogOpen}
|
||||
onClose={() => setIsSelectArticleDialogOpen(false)}
|
||||
onSelectArticle={handleArticleSelect}
|
||||
/>
|
||||
|
||||
{/* Модальное окно выбора видео */}
|
||||
<SelectMediaDialog
|
||||
open={isSelectVideoDialogOpen}
|
||||
onClose={() => setIsSelectVideoDialogOpen(false)}
|
||||
onSelectMedia={handleVideoSelect}
|
||||
mediaType={2}
|
||||
/>
|
||||
|
||||
{/* Модальное окно предпросмотра видео */}
|
||||
{videoPreview && videoPreview !== "" && (
|
||||
<Dialog
|
||||
open={isVideoPreviewOpen}
|
||||
@@ -463,8 +454,6 @@ export const RouteCreatePage = observer(() => {
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
)}
|
||||
|
||||
{/* Модальное окно загрузки видео */}
|
||||
<UploadMediaDialog
|
||||
open={isUploadVideoDialogOpen}
|
||||
onClose={() => {
|
||||
|
||||
@@ -48,7 +48,6 @@ export const RouteEditPage = observer(() => {
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
// Устанавливаем русский язык при загрузке страницы
|
||||
const response = await routeStore.getRoute(Number(id));
|
||||
routeStore.setEditRouteData(response);
|
||||
languageStore.setLanguage("ru");
|
||||
@@ -273,7 +272,6 @@ export const RouteEditPage = observer(() => {
|
||||
const lines = coordinates.split("\n");
|
||||
const lastLine = lines[lines.length - 1];
|
||||
|
||||
// Если мы на последней строке и она не пустая
|
||||
if (lastLine && lastLine.trim()) {
|
||||
e.preventDefault();
|
||||
const newValue = coordinates + "\n";
|
||||
@@ -414,8 +412,6 @@ export const RouteEditPage = observer(() => {
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{/* Правая часть - Видео (30%) */}
|
||||
|
||||
<VideoPreviewCard
|
||||
title="Видеозаставка"
|
||||
videoId={editRouteData.video_preview}
|
||||
@@ -466,23 +462,17 @@ export const RouteEditPage = observer(() => {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Модальное окно выбора или создания статьи */}
|
||||
<ArticleSelectOrCreateDialog
|
||||
open={isSelectArticleDialogOpen}
|
||||
onClose={() => setIsSelectArticleDialogOpen(false)}
|
||||
onSelectArticle={handleArticleSelect}
|
||||
/>
|
||||
|
||||
{/* Модальное окно выбора видео */}
|
||||
<SelectMediaDialog
|
||||
open={isSelectVideoDialogOpen}
|
||||
onClose={() => setIsSelectVideoDialogOpen(false)}
|
||||
onSelectMedia={handleVideoSelect}
|
||||
mediaType={2}
|
||||
/>
|
||||
|
||||
{/* Модальное окно предпросмотра видео */}
|
||||
<Dialog
|
||||
open={isVideoPreviewOpen}
|
||||
onClose={() => setIsVideoPreviewOpen(false)}
|
||||
@@ -507,8 +497,6 @@ export const RouteEditPage = observer(() => {
|
||||
<Button onClick={() => setIsVideoPreviewOpen(false)}>Закрыть</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
{/* Модальное окно загрузки видео */}
|
||||
<UploadMediaDialog
|
||||
open={isUploadVideoDialogOpen}
|
||||
onClose={() => {
|
||||
|
||||
@@ -116,9 +116,7 @@ export const RouteListPage = observer(() => {
|
||||
<button onClick={() => navigate(`/route-preview/${params.row.id}`)}>
|
||||
<Map size={20} className="text-purple-500" />
|
||||
</button>
|
||||
{/* <button onClick={() => navigate(`/route/${params.row.id}`)}>
|
||||
<Eye size={20} className="text-green-500" />
|
||||
</button> */}
|
||||
|
||||
<button
|
||||
onClick={() => {
|
||||
setIsDeleteModalOpen(true);
|
||||
|
||||
@@ -51,7 +51,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
// Режим редактирования: если выбрана статья для редактирования
|
||||
const [selectedArticleId, setSelectedArticleId] = useState<number | null>(
|
||||
null
|
||||
);
|
||||
@@ -68,7 +67,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
}[]
|
||||
>([]);
|
||||
|
||||
// Состояния для создания новой статьи
|
||||
const [newArticleData, setNewArticleData] = useState({
|
||||
ru: { heading: "", body: "" },
|
||||
en: { heading: "", body: "" },
|
||||
@@ -90,7 +88,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
useState(false);
|
||||
const [fileToUpload, setFileToUpload] = useState<File | null>(null);
|
||||
|
||||
// Определяем, редактируем ли мы существующую статью или создаем новую
|
||||
const currentArticleId = selectedArticleId || tempArticleId;
|
||||
const currentArticleData = selectedArticleId
|
||||
? editedArticleData
|
||||
@@ -98,15 +95,12 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
const currentMedia = selectedArticleId
|
||||
? editedArticleMedia
|
||||
: createdArticleMedia;
|
||||
// Режим редактирования: если выбрана статья или мы на вкладке создания
|
||||
const isEditMode =
|
||||
selectedArticleId !== null || tempArticleId !== null || tabValue === 1;
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
// Начинаем всегда с русского в модалке
|
||||
setModalLanguage("ru");
|
||||
// Загружаем списки статей для всех языков локально для модалки
|
||||
(async () => {
|
||||
await Promise.all([
|
||||
getArticles("ru"),
|
||||
@@ -135,14 +129,12 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
}
|
||||
}, [open, getArticles]);
|
||||
|
||||
// При закрытии модалки возвращаем глобальный язык в 'ru'
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
languageStore.setLanguage("ru");
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
// Загрузка статьи для редактирования
|
||||
const loadArticleForEdit = async (articleId: number) => {
|
||||
try {
|
||||
const [ruArticle, enArticle, zhArticle, mediaResponse] =
|
||||
@@ -208,7 +200,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
},
|
||||
});
|
||||
|
||||
// Обновляем данные статьи
|
||||
await loadArticleForEdit(currentArticleId);
|
||||
|
||||
toast.success("Статья успешно сохранена");
|
||||
@@ -259,7 +250,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
const { id } = response.data;
|
||||
setTempArticleId(id);
|
||||
|
||||
// Обновляем кэш статей сразу после создания
|
||||
const ruHeading = newArticleData.ru.heading || "Новый заголовок (RU)";
|
||||
const enHeading = newArticleData.en.heading || "New Heading (EN)";
|
||||
const zhHeading = newArticleData.zh.heading || "Новый заголовок (ZH)";
|
||||
@@ -268,7 +258,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
const zhBody = newArticleData.zh.body || "Новый текст (ZH)";
|
||||
|
||||
runInAction(() => {
|
||||
// articleList используется в списке выбора — обновляем его
|
||||
articlesStore.articleList.ru.data.unshift({
|
||||
id,
|
||||
heading: ruHeading,
|
||||
@@ -287,13 +276,9 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
body: zhBody,
|
||||
service_name: zhHeading,
|
||||
} as any);
|
||||
|
||||
// помечаем как загруженные, чтобы не перезатирать свежие данные
|
||||
articlesStore.articleList.ru.loaded = true;
|
||||
articlesStore.articleList.en.loaded = true;
|
||||
articlesStore.articleList.zh.loaded = true;
|
||||
|
||||
// Также поддержим общий список articles, если он где-то используется
|
||||
if (articlesStore.articles) {
|
||||
articlesStore.articles.ru.unshift({
|
||||
id,
|
||||
@@ -332,7 +317,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
}
|
||||
}
|
||||
|
||||
// Загружаем медиа статьи
|
||||
const mediaResponse = await authInstance.get(`/article/${id}/media`);
|
||||
if (mediaResponse.data && mediaResponse.data.length > 0) {
|
||||
setCreatedArticleMedia(
|
||||
@@ -350,7 +334,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
|
||||
toast.success("Статья успешно создана");
|
||||
|
||||
// Сразу выбираем созданную статью как активную и закрываем диалог
|
||||
onSelectArticle(id);
|
||||
onClose();
|
||||
} catch (error) {
|
||||
@@ -532,7 +515,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
});
|
||||
setCreatedArticleMedia([]);
|
||||
}
|
||||
// При нажатии «Назад» переключаем язык модалки и глобальный язык в RU
|
||||
setModalLanguage("ru");
|
||||
languageStore.setLanguage("ru");
|
||||
};
|
||||
@@ -541,7 +523,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
article?.service_name?.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
);
|
||||
|
||||
// Ховер-предпросмотр для списка статей
|
||||
const [hoveredArticleId, setHoveredArticleId] = useState<string | null>(
|
||||
null
|
||||
);
|
||||
@@ -579,7 +560,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
getArticleMedia,
|
||||
]);
|
||||
|
||||
// Данные для предпросмотра
|
||||
const previewData = {
|
||||
heading: currentArticleData[modalLanguage].heading || "",
|
||||
body: currentArticleData[modalLanguage].body || "",
|
||||
@@ -594,7 +574,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
}
|
||||
: null;
|
||||
|
||||
// Данные предпросмотра для режима выбора (по ховеру)
|
||||
const selectionPreviewHeading =
|
||||
(articlesStore.articleData as any)?.[modalLanguage]?.heading ||
|
||||
(articlesStore.articleData as any)?.heading ||
|
||||
@@ -632,7 +611,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
<Box
|
||||
sx={{ display: "flex", gap: 2, flex: 1, overflow: "hidden" }}
|
||||
>
|
||||
{/* Левая часть - список */}
|
||||
<Paper className="w-[66%] flex flex-col">
|
||||
<Box
|
||||
sx={{
|
||||
@@ -699,7 +677,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
</Box>
|
||||
</Paper>
|
||||
|
||||
{/* Правая часть - предпросмотр */}
|
||||
<Paper
|
||||
elevation={3}
|
||||
sx={{
|
||||
@@ -809,7 +786,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
</Box>
|
||||
</>
|
||||
) : (
|
||||
// Режим редактирования или создания - в стиле LeftWidgetTab
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
@@ -890,7 +866,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* MediaArea - используем для всех случаев, с фиктивным articleId для создания */}
|
||||
<MediaArea
|
||||
articleId={currentArticleId || 0}
|
||||
mediaIds={currentMedia}
|
||||
@@ -1017,7 +992,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
Отмена
|
||||
</Button>
|
||||
|
||||
{/* Кнопка создания - только если мы на вкладке создания и статья еще не создана */}
|
||||
{tabValue === 1 && !tempArticleId && !selectedArticleId && (
|
||||
<Button
|
||||
variant="contained"
|
||||
@@ -1028,7 +1002,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
{isCreating ? "Создание..." : "Создать статью"}
|
||||
</Button>
|
||||
)}
|
||||
{/* Кнопки для редактирования - если статья создана или выбрана */}
|
||||
{(tempArticleId || selectedArticleId) && (
|
||||
<>
|
||||
{selectedArticleId && (
|
||||
@@ -1044,7 +1017,6 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
// Выбираем текущую и возвращаем язык в RU
|
||||
handleSelectAndClose();
|
||||
languageStore.setLanguage("ru");
|
||||
}}
|
||||
@@ -1056,14 +1028,12 @@ export const ArticleSelectOrCreateDialog = observer(
|
||||
)}
|
||||
</DialogActions>
|
||||
|
||||
{/* Модальное окно выбора медиа */}
|
||||
<SelectMediaDialog
|
||||
open={isSelectMediaDialogOpen}
|
||||
onClose={() => setIsSelectMediaDialogOpen(false)}
|
||||
onSelectMedia={handleMediaSelect}
|
||||
/>
|
||||
|
||||
{/* Модальное окно загрузки медиа */}
|
||||
<UploadMediaDialog
|
||||
open={isUploadMediaDialogOpen}
|
||||
onClose={() => {
|
||||
|
||||
Reference in New Issue
Block a user