import MAdminSchoolHolidayCatalog from './MAdminSchoolHolidayCatalog' import MAdminPaddleRegionsPanel from './MAdminPaddleRegionsPanel' import { useState } from 'react' import { ArrowUp, Bell, Blocks, Briefcase, Bug, ChevronDown, ChevronLeft, Database, FileText, Github, HardDrive, Map, Plug, Puzzle, ScrollText, Settings as SettingsIcon, Shield, SlidersHorizontal, UserCog, UserPlus, Users, } from 'lucide-react' import type { LucideIcon } from 'lucide-react' import { useTranslation } from '../../../i18n' import { useCountUp } from '../../../hooks/useCountUp' import { useAdmin } from '../../../pages/admin/useAdmin' import MAdminAddonManager from './MAdminAddonManager' import MAdminMcpTokensPanel from './MAdminMcpTokensPanel' import MAdminPluginsPanel from './MAdminPluginsPanel' import MAdminAuditLogPanel from './MAdminAuditLogPanel' import MAdminBackupPanel from './MAdminBackupPanel' import MAdminCategoryManager from './MAdminCategoryManager' import MAdminDefaultUserSettings from './MAdminDefaultUserSettings' import MAdminDevNotificationsPanel from './MAdminDevNotificationsPanel' import MAdminGitHubPanel from './MAdminGitHubPanel' import MAdminPackingTemplateManager from './MAdminPackingTemplateManager' import MAdminNotificationsSection from './MAdminNotificationsSection' import MAdminSettingsSection from './MAdminSettingsSection' import MAdminSheets from './MAdminSheets' import MAdminStoragePanel from './MAdminStoragePanel' import MAdminUsersSection from './MAdminUsersSection' import { MAdminButton } from './MAdminUi' import { managedAdminTabs } from '../../../managed' import { useIsSplit } from '../../../hooks/sizeClass' import MSectionNav, { MSectionRow, type MSection } from '../../components/MSectionNav' // Stat card of the 2×2 grid (design §6.3): 34px icon tile, 19px/800 number, // small tracking label. Count-up animation matches the desktop stat cards. function MAdminStat({ label, value, icon: Icon }: { label: string; value: number; icon: LucideIcon }) { const animated = useCountUp(value, 900) return (
{animated}
{label}
) } /** * Mobile admin screen (design §6): section switcher pill with the 11-entry * dropdown, update banner, stats grid and the users section; every other * desktop admin section stays reachable through the dropdown. */ export default function MAdmin() { const { t, locale } = useTranslation() const admin = useAdmin() const { demoMode, mcpEnabled, devMode, managed, navigate, activeTab, setActiveTab, stats, serverTimezone, bagTrackingEnabled, collabFeatures, setShowCreateUser, updateInfo, setShowUpdateModal, saveDemoBaseline, toggleBagTracking, toggleCollabFeature, } = admin const [sectionsOpen, setSectionsOpen] = useState(false) // With room for two panes the sections stand in a list beside the page, as in // settings, instead of behind the header's dropdown. const split = useIsSplit() // Same sections and gating as the desktop sidebar, ordered and iconed like // the design's dropdown (§6.1). const sections: MSection[] = [ { id: 'users', label: t('admin.tabs.users'), icon: Users }, { id: 'defaults', label: t('admin.tabs.defaults'), icon: UserCog }, { id: 'config', label: t('admin.tabs.config'), icon: SlidersHorizontal }, { id: 'settings', label: t('admin.tabs.settings'), icon: SettingsIcon }, { id: 'addons', label: t('admin.tabs.addons'), icon: Blocks }, ...(managed ? [] : [{ id: 'plugins', label: t('admin.tabs.plugins'), icon: Puzzle }]), ...(managed ? [] : [{ id: 'storage', label: t('admin.tabs.storage'), icon: HardDrive }]), { id: 'notifications', label: t('admin.tabs.notifications'), icon: Bell }, ...(mcpEnabled ? [{ id: 'mcp-tokens', label: t('admin.tabs.mcpTokens'), icon: Plug }] : []), // Same two the desktop list drops: releases and backup schedule belong to // whoever operates the install. ...(managed ? [] : [{ id: 'github', label: t('admin.tabs.github'), icon: Github }]), ...(managed ? [] : [{ id: 'backup', label: t('admin.tabs.backup'), icon: Database }]), { id: 'audit', label: t('admin.tabs.audit'), icon: ScrollText }, ...(devMode ? [{ id: 'dev-notifications', label: 'Dev: Notifications', icon: Bug }] : []), // The install's own tabs (managed/index.tsx), after the built-in ones as on the desktop. ...managedAdminTabs.map(tab => ({ id: tab.id, label: tab.label, icon: tab.Icon })), ] const activeSection = sections.find((s) => s.id === activeTab) ?? sections[0] return ( // Flow screen: scrolls with the document (#1809), so no height and no // scroll container of its own.
{split && ( void navigate('/dashboard')} sections={sections} activeId={activeSection.id} onPick={setActiveTab} action={ } /> )}
{/* Header: back · section switcher · create user */} {!split && (
)} {/* Section dropdown */} {sectionsOpen && !split && (
{sections.map((section) => ( { setActiveTab(section.id) setSectionsOpen(false) }} /> ))}
)} {/* Update banner (§6.2) — real update check, shown on every section */} {updateInfo && (
{t('admin.update.available')}
{t('mobileAdmin.updateLine', { version: `v${updateInfo.latest}`, current: `v${updateInfo.current}` })}
setShowUpdateModal(true)}>{t('mobileAdmin.updateAction')}
)} {/* Demo baseline (demo instances only) */} {demoMode && (
{t('admin.demoBaseline.title')}
{t('admin.demoBaseline.hint')}
{t('admin.demoBaseline.button')}
)} {/* Stats grid (§6.3) */} {stats && (
)} {/* Active section */} {activeTab === 'users' && } {activeTab === 'settings' && } {activeTab === 'notifications' && } {activeTab === 'defaults' && } {activeTab === 'config' && (
)} {activeTab === 'addons' && (
)} {activeTab === 'plugins' && } {activeTab === 'storage' && } {activeTab === 'mcp-tokens' && } {activeTab === 'github' && } {activeTab === 'backup' && } {activeTab === 'audit' && } {activeTab === 'dev-notifications' && } {managedAdminTabs.map(tab => activeTab === tab.id ?
{tab.mobileElement ?? tab.element}
: null, )}
) }