/** * Quick Capture Widget - idea/brain dump input */ import { useState } from "react"; import { Send, Lightbulb } from "lucide-react"; import type { WidgetProps } from "@mosaic/shared"; export function QuickCaptureWidget({ id: _id, config: _config }: WidgetProps) { const [input, setInput] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const [recentCaptures, setRecentCaptures] = useState([]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!input.trim() || isSubmitting) return; setIsSubmitting(true); const idea = input.trim(); try { // TODO: Replace with actual API call // await api.ideas.create({ content: idea }); // Add to recent captures for visual feedback setRecentCaptures((prev) => [idea, ...prev].slice(0, 3)); setInput(""); } catch (error) { console.error("Failed to capture idea:", error); } finally { setIsSubmitting(false); } }; return (
{/* Header */}
Quick Capture
{/* Input form */}
setInput(e.target.value)} placeholder="Capture an idea..." className="flex-1 px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" disabled={isSubmitting} />
{/* Recent captures */} {recentCaptures.length > 0 && (
Recently captured:
{recentCaptures.map((capture, index) => (
{capture}
))}
)} {/* Tips */} {recentCaptures.length === 0 && (
Capture ideas quickly
They'll be organized later
)}
); }