fix(chat): remove duplicate components

This commit is contained in:
iMADi-ARCH 2023-06-10 15:59:01 +05:30
parent 39766fadc9
commit fff64b3792
4 changed files with 0 additions and 98 deletions

View File

@ -1,47 +0,0 @@
"use client";
import { Dispatch, SetStateAction } from "react";
import Button from "../../components/ui/Button";
import { ConfigButton } from "./ConfigButton";
import { MicButton } from "./MicButton";
export function ChatInput({
isPending,
question,
askQuestion,
setQuestion,
}: {
isPending: boolean;
history: [string, string][];
question: string;
setQuestion: Dispatch<SetStateAction<string>>;
askQuestion: () => Promise<void>;
}) {
return (
<form
onSubmit={(e) => {
e.preventDefault();
if (!isPending) askQuestion();
}}
className="w-full flex items-center justify-center gap-2"
>
<textarea
autoFocus
value={question}
onChange={(e) => 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..."
/>
<Button type="submit" isLoading={isPending}>
{isPending ? "Thinking..." : "Chat"}
</Button>
<MicButton setQuestion={setQuestion} />
<ConfigButton />
</form>
);
}

View File

@ -1,14 +0,0 @@
"use client";
import Link from "next/link";
import { MdSettings } from "react-icons/md";
import Button from "../../components/ui/Button";
export function ConfigButton() {
return (
<Link href={"/config"}>
<Button className="px-3" variant={"tertiary"}>
<MdSettings className="text-2xl" />
</Button>
</Link>
);
}

View File

@ -1,24 +0,0 @@
"use client";
import { MdMic, MdMicOff } from "react-icons/md";
import Button from "../../components/ui/Button";
import { useSpeech } from ".././hooks/useSpeech";
export function MicButton() {
const { isListening, speechSupported, startListening } = useSpeech();
return (
<Button
className="px-3"
variant={"tertiary"}
type="button"
onClick={startListening}
disabled={!speechSupported}
>
{isListening ? (
<MdMicOff className="text-2xl" />
) : (
<MdMic className="text-2xl" />
)}
</Button>
);
}

View File

@ -1,13 +0,0 @@
import Link from "next/link";
import { BsPlusSquare } from "react-icons/bs";
export const NewChatButton = () => (
<Link href="/chat">
<button
type="button"
className="w-full block mb-4 pl-4 pr-4 py-2 bg-gray-400 text-white rounded-lg flex items-center justify-center"
>
<BsPlusSquare className="h-6 w-6 mr-2" /> New Chat
</button>
</Link>
);