added feed
This commit is contained in:
51
src/components/AdCard.jsx
Normal file
51
src/components/AdCard.jsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import PinIcon from "./icons/PinIcon";
|
||||
import CalendarIcon from "./icons/CalendarIcon";
|
||||
import PhoneIcon from "./icons/PhoneIcon";
|
||||
import MapIcon from "./icons/MapIcon";
|
||||
import HeartIcon from "./icons/HeartIcon";
|
||||
|
||||
export default function AdCard({ ad, liked, onLike }) {
|
||||
return (
|
||||
<div className="f-card">
|
||||
<div className="f-card-img">
|
||||
{ad.image
|
||||
? <img src={ad.image} alt={ad.title} />
|
||||
: <span className="f-card-emoji">{ad.emoji || "📋"}</span>
|
||||
}
|
||||
{ad.category && <div className="f-cat-badge">{ad.category}</div>}
|
||||
<div className={`f-type-badge ${ad.type === "loss" ? "f-type-loss" : "f-type-found"}`}>
|
||||
{ad.type === "loss" ? "Потеря" : "Находка"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="f-card-body">
|
||||
<div className="f-card-title">{ad.title}</div>
|
||||
<div className="f-card-desc">{ad.description}</div>
|
||||
<div className="f-card-meta">
|
||||
{ad.location && <div className="f-meta-pill"><PinIcon /> {ad.location}</div>}
|
||||
{ad.date && <div className="f-meta-pill"><CalendarIcon /> {ad.date}</div>}
|
||||
</div>
|
||||
{ad.location && (
|
||||
<button className="f-card-map" onClick={e => e.stopPropagation()}>
|
||||
<MapIcon /> Показать на карте — {ad.location}
|
||||
</button>
|
||||
)}
|
||||
<div className="f-card-foot">
|
||||
{ad.phone
|
||||
? <a className="f-card-phone" href={`tel:${ad.phone}`} onClick={e => e.stopPropagation()}>
|
||||
<PhoneIcon /> {ad.phone}
|
||||
</a>
|
||||
: <span />
|
||||
}
|
||||
<span className="f-card-date">{ad.date || ""}</span>
|
||||
<button
|
||||
className={`f-like-btn${liked ? " liked" : ""}`}
|
||||
onClick={e => { e.stopPropagation(); onLike(ad.id); }}
|
||||
>
|
||||
<HeartIcon filled={liked} />
|
||||
{liked ? (ad.likes || 0) + 1 : (ad.likes || 0)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user