2024-02-07 21:07:41 +05:30
|
|
|
import { useQueryClient } from "@tanstack/react-query"
|
|
|
|
|
import { useDarkMode } from "~hooks/useDarkmode"
|
|
|
|
|
import { useMessageOption } from "~hooks/useMessageOption"
|
|
|
|
|
import { PageAssitDatabase } from "~libs/db"
|
2024-02-15 00:26:13 +05:30
|
|
|
import { Select } from "antd"
|
|
|
|
|
import { SUPPORTED_LANGUAGES } from "~utils/supporetd-languages"
|
2024-02-25 18:55:29 +05:30
|
|
|
import { MoonIcon, SunIcon } from "lucide-react"
|
2024-02-07 21:07:41 +05:30
|
|
|
|
|
|
|
|
export const SettingOther = () => {
|
2024-02-15 00:26:13 +05:30
|
|
|
const { clearChat, speechToTextLanguage, setSpeechToTextLanguage } =
|
|
|
|
|
useMessageOption()
|
2024-02-07 21:07:41 +05:30
|
|
|
|
|
|
|
|
const queryClient = useQueryClient()
|
|
|
|
|
|
|
|
|
|
const { mode, toggleDarkMode } = useDarkMode()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col space-y-4">
|
|
|
|
|
<div className="flex flex-row justify-between">
|
2024-02-15 00:26:13 +05:30
|
|
|
<span className="text-gray-500 dark:text-gray-400 text-md">
|
|
|
|
|
Speech Recognition Language
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<Select
|
|
|
|
|
placeholder="Select Language"
|
|
|
|
|
allowClear
|
|
|
|
|
showSearch
|
|
|
|
|
options={SUPPORTED_LANGUAGES}
|
|
|
|
|
value={speechToTextLanguage}
|
|
|
|
|
filterOption={(input, option) =>
|
|
|
|
|
option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
|
|
|
|
|
option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
|
|
}
|
|
|
|
|
onChange={(value) => {
|
|
|
|
|
setSpeechToTextLanguage(value)
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row justify-between">
|
|
|
|
|
<span className="text-gray-500 dark:text-gray-400 text-md">
|
2024-02-07 21:07:41 +05:30
|
|
|
Change Theme
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
onClick={toggleDarkMode}
|
2024-02-15 00:26:13 +05:30
|
|
|
className={`inline-flex mt-4 items-center rounded-md border border-transparent bg-black px-2 py-2 text-sm font-medium leading-4 text-white shadow-sm dark:bg-white dark:text-gray-800 disabled:opacity-50 `}>
|
|
|
|
|
{mode === "dark" ? (
|
2024-02-25 18:55:29 +05:30
|
|
|
<SunIcon className="w-4 h-4 mr-2" />
|
2024-02-15 00:26:13 +05:30
|
|
|
) : (
|
2024-02-25 18:55:29 +05:30
|
|
|
<MoonIcon className="w-4 h-4 mr-2" />
|
2024-02-15 00:26:13 +05:30
|
|
|
)}
|
2024-02-07 21:07:41 +05:30
|
|
|
{mode === "dark" ? "Light" : "Dark"}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row justify-between">
|
2024-02-15 00:26:13 +05:30
|
|
|
<span className="text-gray-500 dark:text-gray-400 text-md">
|
2024-02-07 21:07:41 +05:30
|
|
|
Delete Chat History
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
onClick={async () => {
|
|
|
|
|
const confirm = window.confirm(
|
|
|
|
|
"Are you sure you want to delete your chat history? This action cannot be undone."
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (confirm) {
|
|
|
|
|
const db = new PageAssitDatabase()
|
|
|
|
|
await db.deleteChatHistory()
|
|
|
|
|
queryClient.invalidateQueries({
|
|
|
|
|
queryKey: ["fetchChatHistory"]
|
|
|
|
|
})
|
|
|
|
|
clearChat()
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className="bg-red-500 dark:bg-red-600 text-white dark:text-gray-200 px-4 py-2 rounded-md">
|
|
|
|
|
Delete
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|