import React from 'react' import { useTranslation } from '../../../i18n' import { PermissionLevel } from '../../../store/permissionsStore' import { CATEGORIES, LEVEL_LABELS, usePermissionsAdmin } from '../../../components/Admin/usePermissionsAdmin' import { Save, RotateCcw } from 'lucide-react' import { MAdminButton, MAdminCard } from './MAdminUi' import MSkeleton from '../../components/MSkeleton' export default function MAdminPermissionsPanel(): React.ReactElement { const { t } = useTranslation() const { entryMap, values, loading, saving, dirty, handleChange, handleSave, handleReset } = usePermissionsAdmin() if (loading) { return ( ) } return ( {/* The title gets the full width and the actions a row of their own: beside a long title they ran into its second line. */}
{t('perm.title')}
{t('perm.subtitle')}
{t('perm.resetDefaults')} {!saving && } {t('common.save')}
{CATEGORIES.map(cat => (
{t(`perm.cat.${cat.id}`)}
{cat.keys.map(key => { const entry = entryMap.get(key) if (!entry) return null const currentLevel = values[key] || entry.defaultLevel const isDefault = currentLevel === entry.defaultLevel return (
{t(`perm.action.${key}`)}
{t(`perm.actionHint.${key}`)}
{!isDefault && ( {t('perm.customized')} )}
) })}
))}
) }