Show which listing each chat is about

The chat list and header show the listing's type, city and closed/deleted
status; the header info button opens the full listing in PostDetailModal
with a "show on map" action. Deleted or unpublished listings are marked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SlimusMinus
2026-10-28 21:17:58 +03:00
parent 3811c5a133
commit 33bd002f98
12 changed files with 319 additions and 22 deletions

View File

@@ -13,6 +13,9 @@ import { getImageUrl } from "../config/authConstants";
import ChatHeader from "../components/chat/ChatHeader";
import MessageBubble from "../components/chat/MessageBubble";
import ChatInputBar from "../components/chat/ChatInputBar";
import ChatPostMeta from "../components/chat/ChatPostMeta";
import PostDetailModal from "../components/PostDetailModal";
import { POST_STATUS_CLOSED } from "../config/postConstants";
import Toast from "../components/Toast";
/**
@@ -37,6 +40,7 @@ export default function ChatPage({ embedded = false, onActivity } = {}) {
const [input, setInput] = useState("");
const [loadError, setLoadError] = useState("");
const [sendError, setSendError] = useState("");
const [showPost, setShowPost] = useState(false);
const messagesEndRef = useRef(null);
const pageRef = useRef(null);
@@ -149,6 +153,17 @@ export default function ChatPage({ embedded = false, onActivity } = {}) {
const post = draft ? draft.post : getPostForChat(chatId);
const postImg = getImageUrl(post?.images?.[0]);
const postId = post?.id ?? draft?.postId;
// «Перейти к объявлению» — на карту с фокусом на нём (тот же URL, что у
// кнопки адреса в ленте). Без координат на карте фокусироваться не на чем.
const hasCoords = (ad) => ad?.latitude != null && ad?.longitude != null
&& Number.isFinite(Number(ad.latitude)) && Number.isFinite(Number(ad.longitude));
const openOnMap = (ad) => {
if (!hasCoords(ad)) return;
const params = new URLSearchParams({ view: "map", post: String(ad.id), lat: String(ad.latitude), lng: String(ad.longitude) });
navigate(`/feed?${params.toString()}`);
};
const content = (
<>
@@ -156,6 +171,9 @@ export default function ChatPage({ embedded = false, onActivity } = {}) {
<ChatHeader
title={post?.title || t('chat.title')}
onBack={() => navigate("/chats")}
subtitle={<ChatPostMeta post={post} t={t} className="chat-header-meta" />}
onInfo={postId != null ? () => setShowPost(true) : undefined}
infoLabel={t('chat.postInfo')}
avatar={postImg ? (
<img src={postImg} alt="" className="chat-header-avatar-img" />
) : (
@@ -183,6 +201,24 @@ export default function ChatPage({ embedded = false, onActivity } = {}) {
/>
</div>
{showPost && (
<PostDetailModal
postId={postId}
onClose={() => setShowPost(false)}
onLocationClick={openOnMap}
compact={false}
hideContact
fallbackTitle={post?.title}
footer={(ad) => ad.status !== POST_STATUS_CLOSED && hasCoords(ad) && (
<div className="chat-post-modal-actions">
<button type="button" className="chat-post-open-btn" onClick={() => openOnMap(ad)}>
{t('chat.showOnMap')}
</button>
</div>
)}
/>
)}
{sendError && (
<Toast
message={sendError}