Files
nahodka-front/src/components/chat/ChatListItem.jsx
SlimusMinus 33bd002f98 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>
2026-10-28 21:17:58 +03:00

42 lines
1.4 KiB
JavaScript

import { getChatDisplayInfo } from "../../utils/chatDisplay";
import TrashIcon from "../icons/TrashIcon";
import ChatPostMeta from "./ChatPostMeta";
export default function ChatListItem({ chat, post, unreadMap, t, onOpen, onDelete }) {
const { title, imgSrc, emoji, unreadCount, preview } = getChatDisplayInfo(chat, post, unreadMap, t);
return (
<div
className={`chat-list-item${unreadCount > 0 ? " unread" : ""}`}
onClick={() => onOpen(chat.id)}
>
<div className="chat-list-avatar">
{imgSrc ? (
<img src={imgSrc} alt="" className="chat-list-avatar-img" />
) : (
emoji || chat.otherUserName?.[0] || chat.otherUser?.name?.[0] || "?"
)}
</div>
<div className="chat-list-info">
<div className="chat-list-name">{title}</div>
<ChatPostMeta post={post} t={t} />
<div className="chat-list-preview">
{preview}
</div>
</div>
{unreadCount > 0 && (
<div className="chat-list-unread-badge">{unreadCount > 99 ? "99+" : unreadCount}</div>
)}
<button
className="chat-list-delete-btn"
title={t('chat.deleteChat')}
onClick={(e) => {
e.stopPropagation();
onDelete(chat.id);
}}
>
<TrashIcon />
</button>
</div>
);
}