feat: Add system and quick prompts on side panel

This commit is contained in:
n4ze3m
2024-09-14 12:07:54 +05:30
parent 5602714ee2
commit 53d999a596
9 changed files with 115 additions and 31 deletions

View File

@@ -4,20 +4,27 @@ import { BookIcon, ComputerIcon, ZapIcon } from "lucide-react"
import React from "react"
import { useTranslation } from "react-i18next"
import { getAllPrompts } from "@/db"
import { useMessageOption } from "@/hooks/useMessageOption"
export const PromptSelect: React.FC = () => {
type Props = {
setSelectedSystemPrompt: (promptId: string | undefined) => void
setSelectedQuickPrompt: (prompt: string | undefined) => void
selectedSystemPrompt: string | undefined
className?: string
}
export const PromptSelect: React.FC<Props> = ({
setSelectedQuickPrompt,
setSelectedSystemPrompt,
selectedSystemPrompt,
className = "dark:text-gray-300"
}) => {
const { t } = useTranslation("option")
const {
selectedSystemPrompt,
setSelectedQuickPrompt,
setSelectedSystemPrompt
} = useMessageOption()
const { data } = useQuery({
queryKey: ["getAllPromptsForSelect"],
queryFn: getAllPrompts
})
const handlePromptChange = (value?: string) => {
if (!value) {
setSelectedSystemPrompt(undefined)
@@ -79,7 +86,7 @@ export const PromptSelect: React.FC = () => {
placement={"topLeft"}
trigger={["click"]}>
<Tooltip title={t("selectAPrompt")}>
<button type="button" className="dark:text-gray-300">
<button type="button" className={className}>
<BookIcon className="h-5 w-5" />
</button>
</Tooltip>