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}
|
||||
/>
|
||||
|
||||
@@ -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, onAuthRequired }) {
|
||||
export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, onDelete, onMarkFound, isOwner, onImageClick, onLocationClick, onAuthRequired }) {
|
||||
const { t } = useTranslation();
|
||||
const [showCalendar, setShowCalendar] = useState(false);
|
||||
const [descExpanded, setDescExpanded] = useState(false);
|
||||
@@ -131,7 +131,18 @@ export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, on
|
||||
</div>
|
||||
|
||||
<div className="f-card-meta">
|
||||
{address && <div className="f-meta-pill"><PinIcon/> {address}</div>}
|
||||
{address && (
|
||||
<div
|
||||
className="f-meta-pill f-loc-pill"
|
||||
title={t('postCard.showOnMap', { address })}
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
onLocationClick?.(ad);
|
||||
}}
|
||||
>
|
||||
<PinIcon/> {address}
|
||||
</div>
|
||||
)}
|
||||
{createdAt && (
|
||||
<div
|
||||
className="f-meta-pill f-date-pill"
|
||||
|
||||
Reference in New Issue
Block a user