import { motion } from "framer-motion"; import type { ShortLink } from "../lib/types"; import { compactNumber, fullShortUrl, prettyHost, relativeTime, shortUrl, } from "../lib/format"; import { BarChart } from "./BarChart"; import { Button } from "./ui/Button"; interface Props { link: ShortLink; onEdit: (link: ShortLink) => void; onDelete: (link: ShortLink) => void; onCopy: () => void; onManagePin: (link: ShortLink) => void; onShowQr: (link: ShortLink) => void; } const modeLabel: Record = { random: "random", memorable: "memorable", custom: "custom", }; export function UrlCard({ link, onEdit, onDelete, onCopy, onManagePin, onShowQr, }: Props) { const weekTotal = link.last7Days.reduce((s, d) => s + d.count, 0); async function copy() { try { await navigator.clipboard.writeText(fullShortUrl(link.code)); } catch { /* ignore */ } onCopy(); } return ( {/* Left: identity + actions */}
{modeLabel[link.mode]} {link.hasPin && ( 🔒 PIN )} {relativeTime(link.createdAt)}
e.preventDefault()} className="focusable mt-2 inline-block rounded font-mono text-lg font-bold text-ink hover:text-accent" > {shortUrl(link.code)}

→ {prettyHost(link.longUrl)} {new URL(link.longUrl).pathname}

{/* Right: stats */}

Total clicks

{compactNumber(link.totalClicks)}

Last 7 days

+{compactNumber(weekTotal)}

); }