added map on post
This commit is contained in:
@@ -54,6 +54,11 @@ export default function MainFeed() {
|
||||
|
||||
const isSearchView = new URLSearchParams(location.search).get("view") === "search";
|
||||
const isMapView = new URLSearchParams(location.search).get("view") === "map";
|
||||
// параметры фокуса карты на конкретном объявлении (?view=map&post=ID&lat=..&lng=..)
|
||||
const mapFocusParams = new URLSearchParams(location.search);
|
||||
const focusPostId = isMapView ? mapFocusParams.get("post") : null;
|
||||
const focusLat = parseFloat(mapFocusParams.get("lat"));
|
||||
const focusLng = parseFloat(mapFocusParams.get("lng"));
|
||||
const hasActiveFilters = searchQuery.trim().length > 0 || selectedCities.length > 0;
|
||||
const hasSearchParams = searchQuery.trim().length > 0 || selectedCities.length > 0;
|
||||
const searchPrompt = isSearchView && !hasSearchParams;
|
||||
@@ -201,6 +206,18 @@ export default function MainFeed() {
|
||||
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}, [isMapView, navigate]);
|
||||
|
||||
// Клик по локации на карточке — карта с фокусом на этом объявлении
|
||||
const handleLocationClick = useCallback((ad) => {
|
||||
const params = new URLSearchParams({ view: "map", post: ad.id });
|
||||
if (ad.latitude != null && ad.longitude != null) {
|
||||
params.set("lat", ad.latitude);
|
||||
params.set("lng", ad.longitude);
|
||||
}
|
||||
setActiveNav("map");
|
||||
navigate(`/feed?${params.toString()}`);
|
||||
feedRef.current?.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}, [navigate]);
|
||||
|
||||
const handleProfileClick = useCallback(() => {
|
||||
if (!isAuthenticated) modals.open("auth");
|
||||
else modals.open("profile");
|
||||
@@ -276,7 +293,7 @@ export default function MainFeed() {
|
||||
|
||||
<div className="f-wrap">
|
||||
{isMapView ? (
|
||||
<MapView />
|
||||
<MapView focusPostId={focusPostId} focusLat={focusLat} focusLng={focusLng} />
|
||||
) : (
|
||||
<>
|
||||
<div className="f-feed" ref={feedRef}>
|
||||
@@ -295,6 +312,7 @@ export default function MainFeed() {
|
||||
onDelete={actions.handleDelete}
|
||||
onMarkFound={actions.handleMarkFound}
|
||||
onImageClick={handleImageClick}
|
||||
onLocationClick={handleLocationClick}
|
||||
onAuthRequired={() => modals.open("auth")}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user