added edit card and get number

This commit is contained in:
SlimusMinus
2026-05-29 01:16:45 +03:00
parent 684ce8f56b
commit 5198e284a3
6 changed files with 175 additions and 89 deletions

View File

@@ -4,7 +4,8 @@ import PhoneIcon from "./icons/PhoneIcon";
import MapIcon from "./icons/MapIcon";
import HeartIcon from "./icons/HeartIcon";
export default function AdCard({ ad, liked, onLike }) {
export default function AdCard({ ad, liked, onLike, onEdit }) {
console.log("ad object:", ad);
return (
<div className="f-card">
<div className="f-card-img">
@@ -13,8 +14,8 @@ export default function AdCard({ ad, liked, onLike }) {
: <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 className={`f-type-badge ${ad.type === "LOSS" ? "f-type-loss" : "f-type-found"}`}>
{ad.type === "LOSS" ? "Потеря" : "Находка"}
</div>
</div>
<div className="f-card-body">
@@ -37,13 +38,23 @@ export default function AdCard({ ad, liked, onLike }) {
: <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 style={{ display: "flex", gap: 6 }}>
{onEdit && (
<button
className="f-like-btn"
onClick={e => { e.stopPropagation(); onEdit(ad); }}
>
✏️
</button>
)}
<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>
</div>