2023-07-25 10:54:34 +03:00
|
|
|
import { Content, List, Root } from "@radix-ui/react-tabs";
|
2023-08-07 15:13:41 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-07-25 10:54:34 +03:00
|
|
|
|
2023-08-08 19:18:05 +03:00
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
|
|
|
2023-07-25 11:13:00 +03:00
|
|
|
import { BrainTabTrigger, PeopleTab } from "./components";
|
2023-08-08 19:18:05 +03:00
|
|
|
import ConfirmationDeleteModal from "./components/Modals/ConfirmationDeleteModal";
|
2023-07-26 00:12:46 +03:00
|
|
|
import { SettingsTab } from "./components/SettingsTab/SettingsTab";
|
2023-07-25 10:54:34 +03:00
|
|
|
import { useBrainManagementTabs } from "./hooks/useBrainManagementTabs";
|
|
|
|
|
|
|
|
export const BrainManagementTabs = (): JSX.Element => {
|
2023-08-08 19:18:05 +03:00
|
|
|
const { t } = useTranslation(["translation", "config", "delete_brain"]);
|
|
|
|
const {
|
|
|
|
selectedTab,
|
|
|
|
setSelectedTab,
|
|
|
|
brainId,
|
|
|
|
handleDeleteBrain,
|
|
|
|
isDeleteModalOpen,
|
|
|
|
setIsDeleteModalOpen,
|
|
|
|
} = useBrainManagementTabs();
|
2023-07-25 11:13:00 +03:00
|
|
|
|
|
|
|
if (brainId === undefined) {
|
|
|
|
return <div />;
|
|
|
|
}
|
2023-07-25 10:54:34 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Root
|
2023-07-25 11:13:00 +03:00
|
|
|
className="shadow-md min-h-[50%] dark:shadow-primary/25 hover:shadow-xl transition-shadow rounded-xl overflow-hidden bg-white dark:bg-black border border-black/10 dark:border-white/25 p-4 pt-10"
|
2023-08-31 19:25:06 +03:00
|
|
|
value={selectedTab}
|
2023-07-25 10:54:34 +03:00
|
|
|
>
|
2023-08-08 19:18:05 +03:00
|
|
|
<List
|
|
|
|
className="flex justify-between"
|
|
|
|
aria-label={t("subtitle", { ns: "config" })}
|
|
|
|
>
|
2023-07-25 10:54:34 +03:00
|
|
|
<BrainTabTrigger
|
|
|
|
selected={selectedTab === "settings"}
|
2023-08-07 15:13:41 +03:00
|
|
|
label={t("settings", { ns: "config" })}
|
2023-07-25 10:54:34 +03:00
|
|
|
value="settings"
|
|
|
|
onChange={setSelectedTab}
|
|
|
|
/>
|
|
|
|
<BrainTabTrigger
|
|
|
|
selected={selectedTab === "people"}
|
2023-08-07 15:13:41 +03:00
|
|
|
label={t("people", { ns: "config" })}
|
2023-07-25 10:54:34 +03:00
|
|
|
value="people"
|
|
|
|
onChange={setSelectedTab}
|
|
|
|
/>
|
|
|
|
<BrainTabTrigger
|
|
|
|
selected={selectedTab === "knowledge"}
|
2023-08-07 15:13:41 +03:00
|
|
|
label={t("knowledge", { ns: "config" })}
|
2023-07-25 10:54:34 +03:00
|
|
|
value="knowledge"
|
|
|
|
onChange={setSelectedTab}
|
|
|
|
/>
|
|
|
|
</List>
|
2023-07-25 11:13:00 +03:00
|
|
|
|
|
|
|
<div className="p-20 pt-5">
|
|
|
|
<Content value="settings">
|
2023-07-26 00:12:46 +03:00
|
|
|
<SettingsTab brainId={brainId} />
|
2023-07-25 11:13:00 +03:00
|
|
|
</Content>
|
|
|
|
<Content value="people">
|
|
|
|
<PeopleTab brainId={brainId} />
|
|
|
|
</Content>
|
2023-07-26 00:12:46 +03:00
|
|
|
<Content value="knowledge">
|
2023-08-07 15:13:41 +03:00
|
|
|
<p>{t("comingSoon")}</p>
|
2023-07-26 00:12:46 +03:00
|
|
|
</Content>
|
2023-07-25 11:13:00 +03:00
|
|
|
</div>
|
2023-08-08 19:18:05 +03:00
|
|
|
<div className="flex justify-center">
|
|
|
|
<Button
|
|
|
|
className="px-20 py-2 bg-red-500 text-white rounded-md"
|
|
|
|
onClick={() => setIsDeleteModalOpen(true)}
|
|
|
|
>
|
|
|
|
{t("deleteButton", { ns: "delete_brain" })}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
<ConfirmationDeleteModal
|
|
|
|
isOpen={isDeleteModalOpen}
|
|
|
|
setOpen={setIsDeleteModalOpen}
|
|
|
|
onDelete={handleDeleteBrain}
|
|
|
|
/>
|
2023-07-25 10:54:34 +03:00
|
|
|
</Root>
|
|
|
|
);
|
|
|
|
};
|