import { useState, useRef, useEffect } from "react"; import { NDKEvent } from "@nostr-dev-kit/ndk"; import { publishQuote } from "../../lib/nostr"; interface QuoteModalProps { event: NDKEvent; authorName: string; authorAvatar?: string; onClose: () => void; onPublished?: () => void; } export function QuoteModal({ event, authorName, authorAvatar, onClose, onPublished }: QuoteModalProps) { const [text, setText] = useState(""); const [publishing, setPublishing] = useState(false); const [error, setError] = useState(null); const textareaRef = useRef(null); useEffect(() => { textareaRef.current?.focus(); }, []); const canPublish = text.trim().length > 0 && !publishing; const handlePublish = async () => { if (!canPublish) return; setPublishing(true); setError(null); try { await publishQuote(text.trim(), event); onPublished?.(); onClose(); } catch (err) { setError(`Failed to publish: ${err}`); setPublishing(false); } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) handlePublish(); if (e.key === "Escape") onClose(); }; const preview = event.content.slice(0, 140) + (event.content.length > 140 ? "…" : ""); return (
{ if (e.target === e.currentTarget) onClose(); }} >
{/* Header */}

Quote note

{/* Compose */}