mirror of
https://github.com/StanGirard/quivr.git
synced 2024-09-11 13:15:41 +03:00
fix(chat): remove duplicate components
This commit is contained in:
parent
39766fadc9
commit
fff64b3792
@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
@ -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>
|
|
||||||
);
|
|
Loading…
Reference in New Issue
Block a user