"use client"; import { useState } from "react"; type Note = { id: string; title: string; content: string; color: string; pinned: boolean; createdAt: Date; updatedAt: Date; }; const COLORS: Record = { "#fef08a": "bg-yellow-200/10 border-yellow-500/30", "#86efac": "bg-emerald-200/10 border-emerald-500/30", "#93c5fd": "bg-blue-200/10 border-blue-500/30", "#f9a8d4": "bg-pink-200/10 border-pink-500/30", "#c4b5fd": "bg-violet-200/10 border-violet-500/30", }; export default function NoteCard({ note, onEdit, onDelete, onPin, }: { note: Note; onEdit: () => void; onDelete: () => void; onPin: () => void; }) { const [showActions, setShowActions] = useState(false); const cls = COLORS[note.color] ?? "bg-zinc-800/50 border-zinc-700"; const ago = timeAgo(note.updatedAt); return (
setShowActions((v) => !v)} >

{note.pinned ? "📌 " : ""}{note.title}

{ e.stopPropagation(); onPin(); }} title={note.pinned ? "Unpin" : "Pin"}> {note.pinned ? "◇" : "◆"} { e.stopPropagation(); onEdit(); }} title="Edit">✎ { e.stopPropagation(); onDelete(); }} title="Delete">✕
{note.content && (

{note.content}

)}
{ago}
); } function Btn({ onClick, title, children }: { onClick: (e: React.MouseEvent) => void; title: string; children: React.ReactNode }) { return ( ); } function timeAgo(d: Date | string): string { const t = new Date(d).getTime(); if (isNaN(t)) return ""; const diff = Date.now() - t; const mins = Math.floor(diff / 60000); if (mins < 1) return "just now"; if (mins < 60) return `${mins}m ago`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}h ago`; return `${Math.floor(hrs / 24)}d ago`; }