import { useEffect, useRef, useState } from "react"; import type { QuestionRequest } from "@/lib/bridge"; import appr from "@/dsh/approval/ApprovalPanel.module.css"; type Props = { req: QuestionRequest; onAnswer: (answer: string) => void; onSkip: () => void; }; export function QuestionCard({ req, onAnswer, onSkip }: Props) { const [text, setText] = useState(""); const rootRef = useRef(null); useEffect(() => { rootRef.current?.focus(); }, [req.id]); return (
Waiting for your answer
{req.question}
{req.options.length > 0 ? (
{req.options.map((opt) => ( ))}
) : null} 0 ? "Or type a custom answer…" : "Type your answer…" } onChange={(e) => setText(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter" && text.trim()) onAnswer(text.trim()); }} />
); }