// frontend/components/dashboard/CommandInput.tsx "use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { Icon } from "@/components/Icon"; import { captureCommand } from "@/lib/dashboard/api"; export function CommandInput() { const [value, setValue] = useState(""); const [busy, setBusy] = useState(false); const router = useRouter(); async function submit() { const raw = value.trim(); if (!raw || busy) return; setBusy(true); try { await captureCommand(raw); // POST /api/inbox/capture window.dispatchEvent( new CustomEvent("ari:toast", { detail: { text: "인박스에 적어뒀어요 — 아리가 분류할게요" }, }), ); router.push("/inbox"); } catch { window.dispatchEvent( new CustomEvent("ari:toast", { detail: { text: "지금은 적어두지 못했어요. 잠시 후 다시 시도해 주세요.", tone: "coral" }, }), ); } finally { setBusy(false); setValue(""); } } return (
); }