import { Option, Select } from "@mui/joy"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { useGlobalStore, useUserStore } from "../store/module"; import Icon from "./Icon"; import { generateDialog } from "./Dialog"; import BetaBadge from "./BetaBadge"; import MyAccountSection from "./Settings/MyAccountSection"; import PreferencesSection from "./Settings/PreferencesSection"; import MemberSection from "./Settings/MemberSection"; import SystemSection from "./Settings/SystemSection"; import StorageSection from "./Settings/StorageSection"; import SSOSection from "./Settings/SSOSection"; import "../less/setting-dialog.less"; type Props = DialogProps; type SettingSection = "my-account" | "preference" | "member" | "system" | "storage" | "sso"; interface State { selectedSection: SettingSection; } const SettingDialog: React.FC = (props: Props) => { const { destroy } = props; const { t } = useTranslation(); const globalStore = useGlobalStore(); const userStore = useUserStore(); const user = userStore.state.user; const [state, setState] = useState({ selectedSection: "my-account", }); const isHost = user?.role === "HOST"; const handleSectionSelectorItemClick = (settingSection: SettingSection) => { setState({ selectedSection: settingSection, }); }; const getSettingSectionList = () => { let settingList: SettingSection[] = ["my-account", "preference"]; if (isHost) { settingList = settingList.concat(["member", "system", "storage", "sso"]); } return settingList; }; return (
{t("common.basic")}
handleSectionSelectorItemClick("my-account")} className={`section-item ${state.selectedSection === "my-account" ? "selected" : ""}`} > {t("setting.my-account")} handleSectionSelectorItemClick("preference")} className={`section-item ${state.selectedSection === "preference" ? "selected" : ""}`} > {t("setting.preference")}
{isHost ? ( <> {t("common.admin")}
handleSectionSelectorItemClick("member")} className={`section-item ${state.selectedSection === "member" ? "selected" : ""}`} > {t("setting.member")} handleSectionSelectorItemClick("system")} className={`section-item ${state.selectedSection === "system" ? "selected" : ""}`} > {t("setting.system")} {globalStore.isDev() && ( handleSectionSelectorItemClick("storage")} className={`section-item ${state.selectedSection === "storage" ? "selected" : ""}`} > {t("setting.storage")} )} {globalStore.isDev() && ( handleSectionSelectorItemClick("sso")} className={`section-item ${state.selectedSection === "sso" ? "selected" : ""}`} > {t("setting.sso")} )}
) : null}
{state.selectedSection === "my-account" ? ( ) : state.selectedSection === "preference" ? ( ) : state.selectedSection === "member" ? ( ) : state.selectedSection === "system" ? ( ) : state.selectedSection === "storage" ? ( ) : state.selectedSection === "sso" ? ( ) : null}
); }; export default function showSettingDialog(): void { generateDialog( { className: "setting-dialog", dialogName: "setting-dialog", }, SettingDialog, {} ); }