"use client"; import Link from "next/link"; import { MdAutorenew, MdMic, MdMicOff, MdSend, MdSettings, } from "react-icons/md"; import Button from "../components/ui/Button"; import Card from "../components/ui/Card"; import PageHeading from "../components/ui/PageHeading"; import ChatMessages from "./components/ChatMessages"; import { useQuestion } from "./hooks/useQuestion"; import { useSpeech } from "./hooks/useSpeech"; export default function ChatPage() { const { history, isPending, question, askQuestion, setQuestion, resetHistory, } = useQuestion(); const { isListening, speechSupported, startListening } = useSpeech(); return (
{/* Chat */}
{ e.preventDefault(); if (!isPending) askQuestion(); }} className="w-full flex flex-col md:flex-row items-center justify-center gap-2 " >
setQuestion(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); // Prevents the newline from being entered in the textarea if (!isPending) askQuestion(); // Call the submit function here } }} className="w-full p-2 border border-gray-300 dark:border-gray-500 outline-none rounded dark:bg-gray-800" placeholder="Begin conversation here..." />
{/* Reset Button */} {/* Mic Button */}
); }