import { useState } from "react"; import { useAppSelector } from "../store"; import { generateDialog } from "./Dialog"; import MyAccountSection from "./Settings/MyAccountSection"; import PreferencesSection from "./Settings/PreferencesSection"; import MemberSection from "./Settings/MemberSection"; import "../less/setting-dialog.less"; import Icon from "./Icon"; interface Props extends DialogProps {} type SettingSection = "my-account" | "preferences" | "member"; interface State { selectedSection: SettingSection; } const SettingDialog: React.FC = (props: Props) => { const { destroy } = props; const user = useAppSelector((state) => state.user.user); const [state, setState] = useState({ selectedSection: "my-account", }); const handleSectionSelectorItemClick = (settingSection: SettingSection) => { setState({ selectedSection: settingSection, }); }; return (
Basic
handleSectionSelectorItemClick("my-account")} className={`section-item ${state.selectedSection === "my-account" ? "selected" : ""}`} > 🤠 My account handleSectionSelectorItemClick("preferences")} className={`section-item ${state.selectedSection === "preferences" ? "selected" : ""}`} > 🏟 Preferences
{user?.role === "HOST" ? ( <> Admin
handleSectionSelectorItemClick("member")} className={`section-item ${state.selectedSection === "member" ? "selected" : ""}`} > 👤 Member
) : null}
{state.selectedSection === "my-account" ? ( ) : state.selectedSection === "preferences" ? ( ) : state.selectedSection === "member" ? ( ) : null}
); }; export default function showSettingDialog(): void { generateDialog( { className: "setting-dialog", }, SettingDialog, {} ); }