added post modal for feed on map
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user