/** * SasquatchActionCard — the "review & confirm" card for a drafted action. * * Sasquatch proposes a draft; the user can tweak the key field(s), then Publish * or Cancel. Nothing is signed or published until Publish is tapped. */ import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Loader2, Check, X, Wand2 } from 'lucide-react'; import { summarizeDraft, type SasquatchDraft, } from '@/hooks/useSasquatchActions'; interface Props { draft: SasquatchDraft; onPublish: (draft: SasquatchDraft) => Promise; onCancel: () => void; /** Set once resolved so the card locks into a done/cancelled state. */ status: 'pending' | 'publishing' | 'done' | 'cancelled'; resultLabel?: string; } export function SasquatchActionCard({ draft, onPublish, onCancel, status, resultLabel }: Props) { const [edited, setEdited] = useState(draft); const summary = summarizeDraft(edited); if (status === 'done') { return (
{resultLabel ?? 'Done!'}
); } if (status === 'cancelled') { return (
Cancelled — nothing was published.
); } const busy = status === 'publishing'; return (
Draft — review & confirm

{summary.title}

{/* Editable key field(s) */} {edited.type === 'post_status' ? ( setEdited({ ...edited, text: e.target.value })} disabled={busy} className="h-9 bg-black/40 border-white/10 text-white text-sm" placeholder="Status text" /> ) : (
setEdited({ ...edited, title: e.target.value })} disabled={busy} className="col-span-2 h-9 bg-black/40 border-white/10 text-white text-sm" placeholder="Title" /> setEdited({ ...edited, price: e.target.value ? Number(e.target.value) : undefined })} disabled={busy} type="number" inputMode="numeric" className="h-9 bg-black/40 border-white/10 text-white text-sm" placeholder="Price (sats)" /> setEdited({ ...edited, condition: e.target.value })} disabled={busy} className="h-9 bg-black/40 border-white/10 text-white text-sm" placeholder="Condition" />
)} {/* Read-only summary lines */}
    {summary.lines.map((l, i) => (
  • • {l}
  • ))}
); }