import { useRef } from 'react'; import { useTranslation } from 'react-i18next'; import ApiIcon from '@mui/icons-material/Api'; import BuildIcon from '@mui/icons-material/Build'; import CloudDownloadIcon from '@mui/icons-material/CloudDownload'; import CodeIcon from '@mui/icons-material/Code'; import GitHubIcon from '@mui/icons-material/GitHub'; import LanguageIcon from '@mui/icons-material/Language'; import MenuBookIcon from '@mui/icons-material/MenuBook'; import MoreHorizIcon from '@mui/icons-material/MoreHoriz'; import NotificationsIcon from '@mui/icons-material/Notifications'; import PhonelinkIcon from '@mui/icons-material/Phonelink'; import PowerIcon from '@mui/icons-material/Power'; import RouterIcon from '@mui/icons-material/Router'; import SearchIcon from '@mui/icons-material/Search'; import SecurityIcon from '@mui/icons-material/Security'; import StorageIcon from '@mui/icons-material/Storage'; import StorefrontIcon from '@mui/icons-material/Storefront'; import SystemUpdateAltIcon from '@mui/icons-material/SystemUpdateAlt'; import WidgetsIcon from '@mui/icons-material/Widgets'; import { SvgIconTypeMap } from '@mui/material'; import { OverridableComponent } from '@mui/material/OverridableComponent'; import { PreferenceSections } from '@services/preferences/interface'; export type ISectionRecord = Record< PreferenceSections, { Icon: OverridableComponent>; hidden?: boolean; ref: React.RefObject; text: string; } >; export function usePreferenceSections(): ISectionRecord { const { t } = useTranslation(['translation', 'agent']); const sections = { [PreferenceSections.wiki]: { text: t('Preference.TiddlyWiki'), Icon: MenuBookIcon, ref: useRef(null), }, [PreferenceSections.general]: { text: t('Preference.General'), Icon: WidgetsIcon, ref: useRef(null), }, [PreferenceSections.sync]: { text: t('Preference.Sync'), Icon: GitHubIcon, ref: useRef(null), }, [PreferenceSections.tidgiMiniWindow]: { text: t('Menu.TidGiMiniWindow'), Icon: PhonelinkIcon, ref: useRef(null), }, [PreferenceSections.externalAPI]: { text: t('Preference.ExternalAPI', { ns: 'agent' }), Icon: ApiIcon, ref: useRef(null), }, [PreferenceSections.aiAgent]: { text: t('Preference.AIAgent', { ns: 'agent' }), Icon: StorageIcon, ref: useRef(null), }, [PreferenceSections.search]: { text: t('Preference.Search'), Icon: SearchIcon, ref: useRef(null), }, [PreferenceSections.notifications]: { text: t('Preference.Notifications'), Icon: NotificationsIcon, ref: useRef(null), }, [PreferenceSections.system]: { text: t('Preference.System'), Icon: BuildIcon, ref: useRef(null), }, [PreferenceSections.network]: { text: t('Preference.Network'), Icon: RouterIcon, ref: useRef(null), }, [PreferenceSections.languages]: { text: t('Preference.Languages'), Icon: LanguageIcon, ref: useRef(null), }, [PreferenceSections.developers]: { text: t('Preference.DeveloperTools'), Icon: CodeIcon, ref: useRef(null), }, [PreferenceSections.downloads]: { text: t('Preference.Downloads'), Icon: CloudDownloadIcon, ref: useRef(null), }, [PreferenceSections.privacy]: { text: t('Preference.PrivacyAndSecurity'), Icon: SecurityIcon, ref: useRef(null), }, [PreferenceSections.performance]: { text: t('Preference.Performance'), Icon: PowerIcon, ref: useRef(null), }, [PreferenceSections.updates]: { text: t('Preference.Updates'), Icon: SystemUpdateAltIcon, ref: useRef(null), }, [PreferenceSections.friendLinks]: { text: t('Preference.FriendLinks'), Icon: StorefrontIcon, ref: useRef(null), }, [PreferenceSections.misc]: { text: t('Preference.Miscellaneous'), Icon: MoreHorizIcon, ref: useRef(null), }, }; return sections; } export interface ISectionProps { requestRestartCountDown?: () => void; sections: ISectionRecord; }