diff --git a/README.md b/README.md
index 1a410ae..f687bb7 100644
--- a/README.md
+++ b/README.md
@@ -170,7 +170,7 @@ src/
│ ├── admin/ PostsTab, AdvertisingCreate/EditModal, CampaignCreate/EditModal, ...
│ ├── landing/ Hero, Navbar, StepsSection, RadarBeacon, FinalCta, Footer, Icon
│ ├── icons/ NavIcons + Calendar/Close/Globe/Menu/Moon/Phone/Pin/Sun/Trash
-│ └── … AuthModal, Toast, MapView, PostDetailModal, ImageViewer, AdCard, AdSlot, ...
+│ └── … AuthModal, Toast, MapView, PostDetailModal, AdCard, AdSlot, ...
│
├── styles/
│ ├── index.css # Точка входа CSS
diff --git a/src/components/ImageViewer.jsx b/src/components/ImageViewer.jsx
deleted file mode 100644
index 20c5b41..0000000
--- a/src/components/ImageViewer.jsx
+++ /dev/null
@@ -1,142 +0,0 @@
-import { useState, useCallback, useEffect, useRef, useMemo } from "react";
-import { useTranslation } from 'react-i18next';
-import CloseIcon from "./icons/CloseIcon";
-import CheckIcon from "./icons/CheckIcon";
-import Toast from "./Toast";
-import { getImageUrl } from "../config/authConstants";
-import { CATEGORY_PET } from "../config/feedConstants";
-import { getFoundAt, formatFoundDate } from "../utils/foundAt";
-import { useContactSeller } from "../hooks/useContactSeller";
-import { useAuthContext } from "../context/AuthContext";
-
-export default function ImageViewer({ images, initialIndex = 0, onClose, postData }) {
- const { t, i18n } = useTranslation();
- const [index, setIndex] = useState(initialIndex);
- const touchStart = useRef(null);
- const swiped = useRef(false);
- const { isAuthenticated } = useAuthContext();
- const { contactSeller, error: contactError, clearError } = useContactSeller(postData);
-
- const urls = useMemo(() => images.map(u => getImageUrl(u)), [images]);
-
- const next = useCallback(() => {
- setIndex(i => (i + 1) % urls.length);
- }, [urls.length]);
-
- const prev = useCallback(() => {
- setIndex(i => (i - 1 + urls.length) % urls.length);
- }, [urls.length]);
-
- const handleImgClick = useCallback(() => {
- next();
- }, [next]);
-
- useEffect(() => {
- const handleKey = (e) => {
- if (e.key === "Escape") onClose();
- if (e.key === "ArrowRight") next();
- if (e.key === "ArrowLeft") prev();
- };
- window.addEventListener("keydown", handleKey);
- return () => window.removeEventListener("keydown", handleKey);
- }, [onClose, next, prev]);
-
- useEffect(() => {
- setIndex(initialIndex);
- }, [initialIndex]);
-
- const handleTouchStart = useCallback((e) => {
- touchStart.current = { x: e.touches[0].clientX, y: e.touches[0].clientY };
- }, []);
-
- const handleTouchEnd = useCallback((e) => {
- if (!touchStart.current) return;
- const dx = e.changedTouches[0].clientX - touchStart.current.x;
- const dy = e.changedTouches[0].clientY - touchStart.current.y;
- const isHorizontal = Math.abs(dx) > Math.abs(dy);
- if (isHorizontal && Math.abs(dx) > 50) {
- swiped.current = true;
- if (dx > 0) prev();
- else next();
- setTimeout(() => { swiped.current = false; }, 400);
- }
- touchStart.current = null;
- }, [prev, next]);
-
- const handleContact = useCallback(() => {
- // Закрываем вьюер перед переходом в чат
- contactSeller(onClose);
- }, [contactSeller, onClose]);
-
- const isClosed = postData?.status === 'CLOSED';
- const showContact = isAuthenticated && postData && !postData.isOwner && !isClosed;
- // Статус «найдено» держим на каждом слайде: перелистывая карусель, человек
- // не должен терять из виду, что вещь/питомец уже вернулся к владельцу.
- const foundText = postData?.category === CATEGORY_PET
- ? t('postCard.petFoundStatus')
- : t('postCard.foundStatus');
- const foundDate = isClosed ? formatFoundDate(getFoundAt(postData), i18n.language) : null;
- const foundTitle = foundDate
- ? t('postCard.foundStatusWithDate', { status: foundText, date: foundDate })
- : foundText;
-
- if (!urls.length) return null;
-
- return (
-
e.target === e.currentTarget && !swiped.current && onClose()}
- >
-
-
-
- {isClosed && (
-
-
- {foundText}
-
- )}
-
-
-

-
-
- {showContact && (
-
- )}
-
- {urls.length > 1 && (
-
- {urls.map((_, i) => (
-
- )}
-
-
- {contactError && (
-
- )}
-
- );
-}
\ No newline at end of file
diff --git a/src/components/PostDetailModal.jsx b/src/components/PostDetailModal.jsx
index 17e2164..7345802 100644
--- a/src/components/PostDetailModal.jsx
+++ b/src/components/PostDetailModal.jsx
@@ -6,7 +6,7 @@ import { useAuthContext } from "../context/AuthContext";
import PostOnFeed from "../pages/PostOnFeed";
import CloseIcon from "./icons/CloseIcon";
-export default function PostDetailModal({ postId, onClose, onImageClick, onLocationClick, onAuthRequired }) {
+export default function PostDetailModal({ postId, onClose, onLocationClick, onAuthRequired }) {
const { t } = useTranslation();
const { user } = useAuthContext();
const [post, setPost] = useState(null);
@@ -62,7 +62,6 @@ export default function PostDetailModal({ postId, onClose, onImageClick, onLocat
{
- if (images?.length) setViewer({ images, index, ad });
- }, []);
-
const contentStyle = useMemo(() => ({ opacity: busyId === null ? 1 : 0.75 }), [busyId]);
if (!isAdmin) return null;
@@ -234,7 +228,6 @@ export default function PostsTab({ isAdmin, mode = "all" }) {
onDelete={handleDelete}
onMarkFound={(id) => setStatus(id, "CLOSED")}
onReopen={(id) => setStatus(id, "ACTIVE")}
- onImageClick={handleImageClick}
/>
))}
@@ -261,15 +254,6 @@ export default function PostsTab({ isAdmin, mode = "all" }) {
/>
)}
- {viewer && (
- setViewer(null)}
- />
- )}
-
{toast && setToast(null)} />}
>
);
diff --git a/src/components/feed/FeedContent.jsx b/src/components/feed/FeedContent.jsx
index 69c3024..0f0b64a 100644
--- a/src/components/feed/FeedContent.jsx
+++ b/src/components/feed/FeedContent.jsx
@@ -17,7 +17,6 @@ export default function FeedContent({
onDelete,
onMarkFound,
onReopen,
- onImageClick,
onLocationClick,
onAuthRequired,
showAds = false,
@@ -91,7 +90,6 @@ export default function FeedContent({
onMarkFound={activeNav === "myads" ? onMarkFound : undefined}
onReopen={activeNav === "myads" ? onReopen : undefined}
isOwner={activeNav === "myads"}
- onImageClick={onImageClick}
onLocationClick={onLocationClick}
onAuthRequired={onAuthRequired}
/>
diff --git a/src/hooks/useContactSeller.js b/src/hooks/useContactSeller.js
index bf42019..8a2183e 100644
--- a/src/hooks/useContactSeller.js
+++ b/src/hooks/useContactSeller.js
@@ -5,7 +5,7 @@ import { useChats } from "./useChats";
/**
* useContactSeller — общая логика открытия/создания чата с автором объявления.
- * Используется в PostOnFeed (карточка в ленте) и ImageViewer (просмотр фото).
+ * Используется в PostOnFeed (карточка в ленте).
*
* @param {object} post — объявление: { id, userId, title, images, emoji }
* @returns {{
diff --git a/src/hooks/useModals.jsx b/src/hooks/useModals.jsx
index 1750156..95ec71c 100644
--- a/src/hooks/useModals.jsx
+++ b/src/hooks/useModals.jsx
@@ -4,7 +4,7 @@ import { useState, useCallback } from "react";
* Управляет всеми модалками MainFeed через единое состояние,
* чтобы гарантировать что открыта максимум одна модалка сразу.
*
- * Типы: "create" | "edit" | "profile" | "auth" | "rules" | "viewer"
+ * Типы: "create" | "edit" | "profile" | "auth" | "rules" | "postDetail"
*/
export function useModals() {
const [modal, setModal] = useState(null); // { type, payload }
diff --git a/src/locales/en.json b/src/locales/en.json
index d86ab16..e647b0c 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -142,7 +142,7 @@
"loading": "Loading ads...",
"loadError": "Failed to load feed",
"emptyMyAdsTitle": "You have no ads",
- "emptyMyAdsSub": "Create your first one — click the button above",
+ "emptyMyAdsSub": "Create your first one — click the button + bellow",
"emptyAllTitle": "No ads yet",
"emptyAllSub": "Be the first — post an ad
about a loss or find",
"searchPromptTitle": "Enter search parameters",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index 2c33805..c20ca26 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -142,7 +142,7 @@
"loading": "Загружаем объявления...",
"loadError": "Не удалось загрузить ленту",
"emptyMyAdsTitle": "У вас нет объявлений",
- "emptyMyAdsSub": "Создайте первое — нажмите кнопку выше",
+ "emptyMyAdsSub": "Создайте первое — нажмите кнопку + ниже",
"emptyAllTitle": "Объявлений пока нет",
"emptyAllSub": "Будьте первым — разместите объявление
о потере или находке",
"searchPromptTitle": "Введите параметры поиска",
diff --git a/src/pages/MainFeed.tsx b/src/pages/MainFeed.tsx
index d3dd8bb..ddb1428 100644
--- a/src/pages/MainFeed.tsx
+++ b/src/pages/MainFeed.tsx
@@ -7,7 +7,6 @@ import Sidebar from "../components/Sidebar";
import BottomNav from "../components/nav/BottomNav";
import RightSidebar from "../components/RightSidebar";
import CreateUpdatePostLegacy from "./CreateUpdatePost";
-import ImageViewer from "../components/ImageViewer";
import CityFilterLegacy from "../components/CityFilter";
import { ProfileModal } from "../components/profile";
import AuthModal from "../components/AuthModal";
@@ -240,10 +239,6 @@ export default function MainFeed() {
activeNav === "home" && selectedCities.length === 0 && feed.hasMore && !feed.loading && !feed.loadingMore
);
- const handleImageClick = useCallback((images: string[], index: number, ad: Record) => {
- if (images?.length) modals.open("viewer", { images, index, ad });
- }, [modals]);
-
const handleCreatePost = useCallback(() => {
if (!isAuthenticated) modals.open("auth");
else modals.open("create");
@@ -491,7 +486,6 @@ export default function MainFeed() {
onDelete={actions.handleDelete}
onMarkFound={actions.handleMarkFound}
onReopen={actions.handleReopen}
- onImageClick={handleImageClick}
onLocationClick={handleLocationClick}
onAuthRequired={() => modals.open("auth")}
t={t}
@@ -552,22 +546,10 @@ export default function MainFeed() {
{modals.isOpen("rules") && }
- {modals.isOpen("viewer") && (
-
- )}
-
{modals.isOpen("postDetail") && (
) => {
- modals.open("viewer", { images, index, ad });
- }}
onLocationClick={(ad: Record) => {
modals.close();
void handleLocationClick(ad);
diff --git a/src/pages/PostOnFeed.jsx b/src/pages/PostOnFeed.jsx
index 65a0462..f7d98df 100644
--- a/src/pages/PostOnFeed.jsx
+++ b/src/pages/PostOnFeed.jsx
@@ -14,7 +14,7 @@ import RewardPopup from "../components/feed/RewardPopup";
import Toast from "../components/Toast";
import {useTranslation} from 'react-i18next';
-export default function PostOnFeed({ ad, onEdit, onDelete, onMarkFound, onReopen, isOwner, authorLabel, allowEditClosed, onImageClick, onLocationClick, onAuthRequired, compact }) {
+export default function PostOnFeed({ ad, onEdit, onDelete, onMarkFound, onReopen, isOwner, authorLabel, allowEditClosed, onLocationClick, onAuthRequired, compact }) {
const { t, i18n } = useTranslation();
const [showCalendar, setShowCalendar] = useState(false);
const [showReward, setShowReward] = useState(false);
@@ -25,7 +25,6 @@ export default function PostOnFeed({ ad, onEdit, onDelete, onMarkFound, onReopen
const rewardAnchorRef = useRef(null);
const descRef = useRef(null);
const imgTouchStartRef = useRef(null);
- const imgSwipedRef = useRef(false);
const { isAuthenticated } = useAuthContext();
const { contactSeller, error: contactError, clearError } = useContactSeller(ad);
@@ -50,15 +49,17 @@ export default function PostOnFeed({ ad, onEdit, onDelete, onMarkFound, onReopen
};
const images = Array.isArray(ad.images) ? ad.images : [];
- const hasMultipleImages = images.length > 1;
- // Карусель только для карточек ленты (не для компактного вида в детальной
- // модалке, где фото показывается целиком и overflow не скрыт).
- const carousel = hasMultipleImages && !compact;
+ // Карусель включается для любого объявления с несколькими фото: листать
+ // можно и в ленте, и в детальной модалке. Полноэкранного просмотрщика нет.
+ const carousel = images.length > 1;
// Листание фото прямо в карточке: на телефоне — свайпом, на десктопе —
- // стрелками и точками. Полноэкранный просмотр по-прежнему открывается по клику.
+ // стрелками и точками. Листание зациклено: с последнего кадра переходим на
+ // первый и наоборот.
const goToImage = (target) => {
- setImgIndex(Math.max(0, Math.min(images.length - 1, target)));
+ const len = images.length;
+ if (!len) return;
+ setImgIndex(((target % len) + len) % len);
};
const handleImgTouchStart = (e) => {
@@ -75,19 +76,12 @@ export default function PostOnFeed({ ad, onEdit, onDelete, onMarkFound, onReopen
// Реагируем только на явно горизонтальный жест — вертикальный скролл ленты
// не должен переключать фото.
if (Math.abs(dx) > 40 && Math.abs(dx) > Math.abs(dy)) {
- imgSwipedRef.current = true;
- setImgIndex(i => Math.max(0, Math.min(images.length - 1, dx < 0 ? i + 1 : i - 1)));
- window.setTimeout(() => { imgSwipedRef.current = false; }, 350);
+ const len = images.length;
+ const step = dx < 0 ? 1 : -1;
+ setImgIndex(i => (i + step + len) % len);
}
};
- const handleImgAreaClick = (e) => {
- e.stopPropagation();
- // После свайпа браузер может дослать click — не открываем просмотр.
- if (imgSwipedRef.current) return;
- if (onImageClick) onImageClick(images, imgIndex, ad);
- };
-
const address = ad.address || ad.city || ad.district || ad.location;
const createdAt = ad.createdAt
? new Date(ad.createdAt).toLocaleDateString("ru-RU")
@@ -135,7 +129,6 @@ export default function PostOnFeed({ ad, onEdit, onDelete, onMarkFound, onReopen
diff --git a/src/styles/modal.css b/src/styles/modal.css
index 16ec0f2..421a8d6 100644
--- a/src/styles/modal.css
+++ b/src/styles/modal.css
@@ -583,7 +583,10 @@ select.f-m-field::selection { background: transparent; }
}
.f-post-detail-modal .f-card-img {
max-height: none;
- overflow: visible;
+ /* Раньше было overflow: visible для полноэкранного просмотра. Теперь фото
+ листается прямо в карточке (карусель), поэтому кадры должны обрезаться
+ по «окну». */
+ overflow: hidden;
flex-shrink: 0;
}
.f-post-detail-modal .f-card-img img {
@@ -591,6 +594,13 @@ select.f-m-field::selection { background: transparent; }
height: auto;
object-fit: contain;
}
+/* Карусель в модалке: трек и кадры заполняют квадратное «окно», фото
+ вписывается целиком (contain). */
+.f-post-detail-modal .f-card-img .f-card-img-track { height: 100%; }
+.f-post-detail-modal .f-card-img .f-card-img-slide {
+ height: 100%;
+ object-fit: contain;
+}
.f-post-detail-modal .f-card-caption {
padding: 8px 14px;
}