added post modal for feed on map

This commit is contained in:
SlimusMinus
2026-08-27 01:30:03 +03:00
parent 69e929efbf
commit 408a97e5b2
11 changed files with 512 additions and 27 deletions

View File

@@ -16,6 +16,7 @@ import FeedSearchBar from "../components/feed/FeedSearchBar";
import FeedContent from "../components/feed/FeedContent";
import MapView from "../components/MapView";
import PostDetailModal from "../components/PostDetailModal";
import { useAuthContext } from "../context/AuthContext";
import { useCities } from "../hooks/useCities";
import { useFeedPosts } from "../hooks/useFeedPosts";
@@ -186,6 +187,8 @@ export default function MainFeed() {
const handleHomeClick = useCallback(() => {
setActiveNav("home");
setSearchQuery("");
setSelectedCities([]);
if (isSearchView || isMapView) navigate("/feed");
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
}, [isSearchView, isMapView, navigate]);
@@ -206,6 +209,10 @@ export default function MainFeed() {
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
}, [isMapView, navigate]);
const handleMapPostClick = useCallback((postId) => {
modals.open("postDetail", { postId });
}, [modals]);
// Клик по локации на карточке — карта с фокусом на этом объявлении
const handleLocationClick = useCallback((ad) => {
const params = new URLSearchParams({ view: "map", post: ad.id });
@@ -266,6 +273,8 @@ export default function MainFeed() {
onClose={() => setSidebarOpen(false)}
onNavClick={(key) => {
setActiveNav(key);
setSearchQuery("");
setSelectedCities([]);
if (isMapView || isSearchView) navigate("/feed");
}}
isAuthenticated={isAuthenticated}
@@ -296,7 +305,7 @@ export default function MainFeed() {
<div className="f-wrap">
{isMapView ? (
<MapView focusPostId={focusPostId} focusLat={focusLat} focusLng={focusLng} />
<MapView focusPostId={focusPostId} focusLat={focusLat} focusLng={focusLng} onPostClick={handleMapPostClick} />
) : (
<>
<div className="f-feed" ref={feedRef}>
@@ -336,6 +345,8 @@ export default function MainFeed() {
onLoginClick={() => modals.open("auth")}
onNavClick={(key) => {
setActiveNav(key);
setSearchQuery("");
setSelectedCities([]);
if (isMapView || isSearchView) navigate("/feed");
}}
/>
@@ -373,6 +384,21 @@ export default function MainFeed() {
/>
)}
{modals.isOpen("postDetail") && (
<PostDetailModal
postId={modals.modal.payload.postId}
onClose={modals.close}
onImageClick={(images, index, ad) => {
modals.open("viewer", { images, index, ad });
}}
onLocationClick={(ad) => {
modals.close();
handleLocationClick(ad);
}}
onAuthRequired={() => modals.open("auth")}
/>
)}
<BottomNav
activeTab={isMapView ? "map" : isSearchView ? "search" : "home"}
hasFilters={hasActiveFilters}

View File

@@ -11,7 +11,7 @@ import DateCalendarPopup from "../components/DateCalendarPopup";
import Toast from "../components/Toast";
import {useTranslation} from 'react-i18next';
export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, onDelete, onMarkFound, isOwner, onImageClick, onLocationClick, onAuthRequired }) {
export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, onDelete, onMarkFound, isOwner, onImageClick, onLocationClick, onAuthRequired, compact }) {
const { t } = useTranslation();
const [showCalendar, setShowCalendar] = useState(false);
const [descExpanded, setDescExpanded] = useState(false);
@@ -83,6 +83,7 @@ export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, on
}
</div>
{!compact && (
<div className="f-card-actions">
<div className="f-card-actions-left">
<button type="button"
@@ -135,6 +136,7 @@ export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, on
)}
</div>
</div>
)}
<div className="f-card-caption">
<span
@@ -146,6 +148,7 @@ export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, on
</span>
</div>
{!compact && (
<div className="f-card-meta">
{address && (
<div
@@ -165,6 +168,7 @@ export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, on
</span>
)}
</div>
)}
<div className="f-card-foot">
<div className="f-card-foot-left">
@@ -176,12 +180,10 @@ export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, on
)}
</div>
<div className="f-card-foot-right">
{!isOwner && !isClosed && (
<button type="button" className="f-card-contact"
onClick={handleContact}>
{t('postCard.write')}
</button>
)}
<button type="button" className="f-card-contact"
onClick={handleContact}>
{t('postCard.write')}
</button>
{onMarkFound && isOwner && !isClosed && (
<button type="button" className="f-card-found-btn"
onClick={e => {