2024-02-17 00:01:07 +05:30
|
|
|
import React, { useState } from "react"
|
2024-02-07 00:11:07 +05:30
|
|
|
|
2024-03-03 23:30:42 +05:30
|
|
|
import { Sidebar } from "../Option/Sidebar"
|
2024-09-27 19:38:29 +05:30
|
|
|
import { Drawer, Tooltip } from "antd"
|
2024-05-31 13:50:05 +05:30
|
|
|
|
2024-03-24 12:43:43 +05:30
|
|
|
import { useTranslation } from "react-i18next"
|
2024-05-31 13:50:05 +05:30
|
|
|
|
2024-05-24 20:00:09 +05:30
|
|
|
import { CurrentChatModelSettings } from "../Common/Settings/CurrentChatModelSettings"
|
2024-05-31 13:50:05 +05:30
|
|
|
import { Header } from "./Header"
|
2024-09-27 19:38:29 +05:30
|
|
|
import { EraserIcon } from "lucide-react"
|
|
|
|
|
import { PageAssitDatabase } from "@/db"
|
|
|
|
|
import { useMessageOption } from "@/hooks/useMessageOption"
|
|
|
|
|
import { useQueryClient } from "@tanstack/react-query"
|
2024-02-07 00:11:07 +05:30
|
|
|
|
|
|
|
|
export default function OptionLayout({
|
|
|
|
|
children
|
|
|
|
|
}: {
|
|
|
|
|
children: React.ReactNode
|
|
|
|
|
}) {
|
|
|
|
|
const [sidebarOpen, setSidebarOpen] = useState(false)
|
2024-09-27 19:38:29 +05:30
|
|
|
const { t } = useTranslation(["option", "common", "settings"])
|
2024-05-23 00:39:44 +05:30
|
|
|
const [openModelSettings, setOpenModelSettings] = useState(false)
|
2024-09-27 19:38:29 +05:30
|
|
|
const { clearChat } = useMessageOption()
|
|
|
|
|
const queryClient = useQueryClient()
|
2024-02-07 00:11:07 +05:30
|
|
|
|
|
|
|
|
return (
|
2024-05-31 13:50:05 +05:30
|
|
|
<>
|
|
|
|
|
<div className="flex flex-col min-h-screen">
|
|
|
|
|
<Header
|
|
|
|
|
setSidebarOpen={setSidebarOpen}
|
|
|
|
|
setOpenModelSettings={setOpenModelSettings}
|
|
|
|
|
/>
|
2024-05-31 22:05:43 +05:30
|
|
|
<main className="flex-1">{children}</main>
|
2024-02-07 00:11:07 +05:30
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Drawer
|
2024-09-27 19:38:29 +05:30
|
|
|
title={
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
{t("sidebarTitle")}
|
|
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
title={t(
|
|
|
|
|
"settings:generalSettings.system.deleteChatHistory.label"
|
|
|
|
|
)}
|
|
|
|
|
placement="right">
|
|
|
|
|
<button
|
|
|
|
|
onClick={async () => {
|
|
|
|
|
const confirm = window.confirm(
|
|
|
|
|
t(
|
|
|
|
|
"settings:generalSettings.system.deleteChatHistory.confirm"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (confirm) {
|
|
|
|
|
const db = new PageAssitDatabase()
|
|
|
|
|
await db.deleteAllChatHistory()
|
|
|
|
|
queryClient.invalidateQueries({
|
|
|
|
|
queryKey: ["fetchChatHistory"]
|
|
|
|
|
})
|
|
|
|
|
clearChat()
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className="text-gray-600 hover:text-gray-800 dark:text-gray-300 dark:hover:text-gray-100">
|
|
|
|
|
<EraserIcon className="size-5" />
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
2024-02-07 00:11:07 +05:30
|
|
|
placement="left"
|
|
|
|
|
closeIcon={null}
|
|
|
|
|
onClose={() => setSidebarOpen(false)}
|
2024-02-07 21:07:41 +05:30
|
|
|
open={sidebarOpen}>
|
2024-03-24 12:43:43 +05:30
|
|
|
<Sidebar onClose={() => setSidebarOpen(false)} />
|
2024-02-07 00:11:07 +05:30
|
|
|
</Drawer>
|
2024-05-23 00:39:44 +05:30
|
|
|
|
|
|
|
|
<CurrentChatModelSettings
|
|
|
|
|
open={openModelSettings}
|
|
|
|
|
setOpen={setOpenModelSettings}
|
2024-10-02 12:30:52 +05:30
|
|
|
useDrawer
|
2024-05-23 00:39:44 +05:30
|
|
|
/>
|
2024-05-31 13:50:05 +05:30
|
|
|
</>
|
2024-02-07 00:11:07 +05:30
|
|
|
)
|
|
|
|
|
}
|