added search in map in navigation bottom
This commit is contained in:
@@ -15,6 +15,7 @@ import FeedTopBar from "../components/feed/FeedTopBar";
|
|||||||
import FeedSearchBar from "../components/feed/FeedSearchBar";
|
import FeedSearchBar from "../components/feed/FeedSearchBar";
|
||||||
|
|
||||||
import FeedContent from "../components/feed/FeedContent";
|
import FeedContent from "../components/feed/FeedContent";
|
||||||
|
import MapView from "../components/MapView";
|
||||||
import { useAuthContext } from "../context/AuthContext";
|
import { useAuthContext } from "../context/AuthContext";
|
||||||
import { useCities } from "../hooks/useCities";
|
import { useCities } from "../hooks/useCities";
|
||||||
import { useFeedPosts } from "../hooks/useFeedPosts";
|
import { useFeedPosts } from "../hooks/useFeedPosts";
|
||||||
@@ -50,6 +51,7 @@ export default function MainFeed() {
|
|||||||
const feedRef = useRef(null);
|
const feedRef = useRef(null);
|
||||||
|
|
||||||
const isSearchView = new URLSearchParams(location.search).get("view") === "search";
|
const isSearchView = new URLSearchParams(location.search).get("view") === "search";
|
||||||
|
const isMapView = new URLSearchParams(location.search).get("view") === "map";
|
||||||
const hasActiveFilters = searchQuery.trim().length > 0 || selectedCities.length > 0;
|
const hasActiveFilters = searchQuery.trim().length > 0 || selectedCities.length > 0;
|
||||||
const hasSearchParams = searchQuery.trim().length > 0 || selectedCities.length > 0;
|
const hasSearchParams = searchQuery.trim().length > 0 || selectedCities.length > 0;
|
||||||
const searchPrompt = isSearchView && !hasSearchParams;
|
const searchPrompt = isSearchView && !hasSearchParams;
|
||||||
@@ -163,20 +165,25 @@ export default function MainFeed() {
|
|||||||
|
|
||||||
const handleHomeClick = useCallback(() => {
|
const handleHomeClick = useCallback(() => {
|
||||||
setActiveNav("home");
|
setActiveNav("home");
|
||||||
if (isSearchView) navigate("/feed");
|
if (isSearchView || isMapView) navigate("/feed");
|
||||||
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}, [isSearchView, navigate]);
|
}, [isSearchView, isMapView, navigate]);
|
||||||
|
|
||||||
const handleSearchClick = useCallback(() => {
|
const handleSearchClick = useCallback(() => {
|
||||||
setActiveNav("home");
|
setActiveNav("home");
|
||||||
setSearchQuery("");
|
setSearchQuery("");
|
||||||
setSelectedCities([]);
|
setSelectedCities([]);
|
||||||
if (!isSearchView) navigate("/feed?view=search");
|
if (!isSearchView) navigate("/feed?view=search");
|
||||||
|
else if (isMapView) navigate("/feed?view=search");
|
||||||
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}, [isSearchView, navigate]);
|
}, [isSearchView, isMapView, navigate]);
|
||||||
|
|
||||||
// Карта с объявлениями — иконка добавлена, функционал ещё не реализован
|
// Карта с объявлениями
|
||||||
const handleMapClick = useCallback(() => {}, []);
|
const handleMapClick = useCallback(() => {
|
||||||
|
setActiveNav("map");
|
||||||
|
if (!isMapView) navigate("/feed?view=map");
|
||||||
|
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
|
}, [isMapView, navigate]);
|
||||||
|
|
||||||
const handleProfileClick = useCallback(() => {
|
const handleProfileClick = useCallback(() => {
|
||||||
if (!isAuthenticated) modals.open("auth");
|
if (!isAuthenticated) modals.open("auth");
|
||||||
@@ -209,7 +216,7 @@ export default function MainFeed() {
|
|||||||
const listError = activeNav === "myads" ? myPosts.error : feed.error;
|
const listError = activeNav === "myads" ? myPosts.error : feed.error;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`f-app${isSearchView ? " f-search-view" : ""}`}>
|
<div className={`f-app${isSearchView ? " f-search-view" : ""}${isMapView ? " f-map-view" : ""}`}>
|
||||||
<Sidebar
|
<Sidebar
|
||||||
open={sidebarOpen}
|
open={sidebarOpen}
|
||||||
activeNav={activeNav}
|
activeNav={activeNav}
|
||||||
@@ -242,7 +249,11 @@ export default function MainFeed() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="f-wrap">
|
<div className="f-wrap">
|
||||||
<div className="f-feed" ref={feedRef}>
|
{isMapView ? (
|
||||||
|
<MapView />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="f-feed" ref={feedRef}>
|
||||||
<FeedContent
|
<FeedContent
|
||||||
loading={listLoading}
|
loading={listLoading}
|
||||||
cityLoading={cityFeed.cityLoading}
|
cityLoading={cityFeed.cityLoading}
|
||||||
@@ -278,6 +289,8 @@ export default function MainFeed() {
|
|||||||
onLoginClick={() => modals.open("auth")}
|
onLoginClick={() => modals.open("auth")}
|
||||||
onNavClick={setActiveNav}
|
onNavClick={setActiveNav}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -311,7 +324,7 @@ export default function MainFeed() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<BottomNav
|
<BottomNav
|
||||||
activeTab={isSearchView ? "search" : "home"}
|
activeTab={isMapView ? "map" : isSearchView ? "search" : "home"}
|
||||||
hasFilters={hasActiveFilters}
|
hasFilters={hasActiveFilters}
|
||||||
profileData={profileData}
|
profileData={profileData}
|
||||||
onHome={handleHomeClick}
|
onHome={handleHomeClick}
|
||||||
|
|||||||
@@ -410,6 +410,28 @@
|
|||||||
.f-search-panel { display: none; }
|
.f-search-panel { display: none; }
|
||||||
.f-app.f-search-view .f-search-panel { display: block; }
|
.f-app.f-search-view .f-search-panel { display: block; }
|
||||||
|
|
||||||
|
/* Map view */
|
||||||
|
.f-mapview {
|
||||||
|
position: relative;
|
||||||
|
width: 100%; height: 100%;
|
||||||
|
flex: 1; min-height: 0;
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: var(--bg-card);
|
||||||
|
}
|
||||||
|
.f-mapview-canvas {
|
||||||
|
width: 100%; height: 100%;
|
||||||
|
}
|
||||||
|
.f-mapview-status {
|
||||||
|
position: absolute; inset: 0;
|
||||||
|
display: flex; align-items: center; justify-content: center;
|
||||||
|
z-index: 5;
|
||||||
|
background: var(--bg-card);
|
||||||
|
}
|
||||||
|
.f-mapview-error {
|
||||||
|
font-size: .9rem; color: var(--err);
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Feed Wrap + Scroll ── */
|
/* ── Feed Wrap + Scroll ── */
|
||||||
.f-wrap { display: flex; flex: 1; overflow: hidden; min-height: 0; }
|
.f-wrap { display: flex; flex: 1; overflow: hidden; min-height: 0; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user