quivr/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/BrainManagementTabs.tsx

86 lines
2.6 KiB
TypeScript
Raw Normal View History

2023-07-25 10:54:34 +03:00
import { Content, List, Root } from "@radix-ui/react-tabs";
import { useTranslation } from "react-i18next";
2023-07-25 10:54:34 +03:00
import Button from "@/lib/components/ui/Button";
import { BrainTabTrigger, KnowledgeTab, PeopleTab } from "./components";
import ConfirmationDeleteModal from "./components/Modals/ConfirmationDeleteModal";
import { SettingsTab } from "./components/SettingsTab/SettingsTab";
2023-07-25 10:54:34 +03:00
import { useBrainManagementTabs } from "./hooks/useBrainManagementTabs";
export const BrainManagementTabs = (): JSX.Element => {
const { t } = useTranslation(["translation", "config", "delete_brain"]);
const {
selectedTab,
setSelectedTab,
brainId,
handleDeleteBrain,
isDeleteModalOpen,
setIsDeleteModalOpen,
} = useBrainManagementTabs();
if (brainId === undefined) {
return <div />;
}
2023-07-25 10:54:34 +03:00
return (
<Root
className="flex flex-col w-full h-full shadow-md 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 md:p-10"
2023-08-31 19:25:06 +03:00
value={selectedTab}
2023-07-25 10:54:34 +03:00
>
<List
className="flex flex-col md:flex-row justify-between space-y-2 md:space-y-0 mb-4"
aria-label={t("subtitle", { ns: "config" })}
>
2023-07-25 10:54:34 +03:00
<BrainTabTrigger
selected={selectedTab === "settings"}
label={t("settings", { ns: "config" })}
2023-07-25 10:54:34 +03:00
value="settings"
onChange={setSelectedTab}
/>
<BrainTabTrigger
selected={selectedTab === "people"}
label={t("people", { ns: "config" })}
2023-07-25 10:54:34 +03:00
value="people"
onChange={setSelectedTab}
/>
<BrainTabTrigger
selected={selectedTab === "knowledge"}
label={t("knowledge", { ns: "config" })}
2023-07-25 10:54:34 +03:00
value="knowledge"
onChange={setSelectedTab}
/>
</List>
<div className="flex-1 p-4 md:p-20">
<Content value="settings">
<SettingsTab brainId={brainId} />
</Content>
<Content value="people">
<PeopleTab brainId={brainId} />
</Content>
<Content value="knowledge">
<KnowledgeTab brainId={brainId} />
</Content>
</div>
<div className="flex justify-center mt-4">
<Button
className="px-8 md: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>
);
};
export default BrainManagementTabs;