import MaterialIcon, { AvailableUnfilledIcon, } from '@/shared/components/material-icon' import { ReactElement, useMemo, useState } from 'react' import { Nav, NavLink, TabContainer, TabContent, TabPane, } from 'react-bootstrap-5' import { useTranslation } from 'react-i18next' import EditorSettings from './editor-settings/editor-settings' import AppearanceSettings from './appearance-settings/appearance-settings' import CompilerSettings from './compiler-settings/compiler-settings' export type SettingsEntry = SettingsLink | SettingsTab type SettingsTab = { icon: AvailableUnfilledIcon key: string component: ReactElement title: string } type SettingsLink = { key: string icon: AvailableUnfilledIcon href: string title: string } export const SettingsModalBody = () => { const { t } = useTranslation() const settingsTabs: SettingsEntry[] = useMemo( () => [ { key: 'editor', title: t('editor'), icon: 'code', component: , }, { key: 'compiler', title: t('compiler'), icon: 'picture_as_pdf', component: , }, { key: 'appearance', title: t('appearance'), icon: 'brush', component: , }, { key: 'account_settings', title: t('account_settings'), icon: 'settings', href: '/user/settings', }, ], [t] ) const [activeTab, setActiveTab] = useState( settingsTabs[0]?.key ) return (
{settingsTabs .filter(t => 'component' in t) .map(({ key, component }) => ( {component} ))}
) } const SettingsNavLink = ({ entry }: { entry: SettingsEntry }) => { if ('href' in entry) { return ( {entry.title}
) } else { return ( <> {entry.title} ) } }