import { Option, Select } from "@mui/joy"; import { useState } from "react"; import BetaBadge from "@/components/BetaBadge"; import Icon from "@/components/Icon"; import MobileHeader from "@/components/MobileHeader"; import MemberSection from "@/components/Settings/MemberSection"; import MyAccountSection from "@/components/Settings/MyAccountSection"; import PreferencesSection from "@/components/Settings/PreferencesSection"; import SSOSection from "@/components/Settings/SSOSection"; import StorageSection from "@/components/Settings/StorageSection"; import SystemSection from "@/components/Settings/SystemSection"; import useCurrentUser from "@/hooks/useCurrentUser"; import { User_Role } from "@/types/proto/api/v2/user_service"; import { useTranslate } from "@/utils/i18n"; import "@/less/setting.less"; type SettingSection = "my-account" | "preference" | "member" | "system" | "storage" | "sso"; interface State { selectedSection: SettingSection; } const Setting = () => { const t = useTranslate(); const user = useCurrentUser(); const [state, setState] = useState({ selectedSection: "my-account", }); const isHost = user.role === 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")} handleSectionSelectorItemClick("storage")} className={`section-item ${state.selectedSection === "storage" ? "selected" : ""}`} > {t("setting.storage")} 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 Setting;