import { useState } from "react"; import { useTranslation } from "react-i18next"; import { useUserStore } from "../store/module"; import Icon from "./Icon"; import { generateDialog } from "./Dialog"; 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 "../less/setting-dialog.less"; type Props = DialogProps; type SettingSection = "my-account" | "preferences" | "storage" | "member" | "system"; interface State { selectedSection: SettingSection; } const SettingDialog: React.FC = (props: Props) => { const { destroy } = props; const { t } = useTranslation(); const userStore = useUserStore(); const user = userStore.state.user; const [state, setState] = useState({ selectedSection: "my-account", }); const handleSectionSelectorItemClick = (settingSection: SettingSection) => { setState({ selectedSection: settingSection, }); }; return (
{t("common.basic")}
handleSectionSelectorItemClick("my-account")} className={`section-item ${state.selectedSection === "my-account" ? "selected" : ""}`} > 🤠 {t("setting.my-account")} handleSectionSelectorItemClick("preferences")} className={`section-item ${state.selectedSection === "preferences" ? "selected" : ""}`} > 🏟 {t("setting.preference")}
{user?.role === "HOST" ? ( <> {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")}
) : null}
{state.selectedSection === "my-account" ? ( ) : state.selectedSection === "preferences" ? ( ) : state.selectedSection === "storage" ? ( ) : state.selectedSection === "member" ? ( ) : state.selectedSection === "system" ? ( ) : null}
); }; export default function showSettingDialog(): void { generateDialog( { className: "setting-dialog", dialogName: "setting-dialog", }, SettingDialog, {} ); }