import React from 'react' import { useTranslation } from '../../i18n' import { PermissionLevel } from '../../store/permissionsStore' import { CATEGORIES, LEVEL_LABELS, usePermissionsAdmin } from './usePermissionsAdmin' import { Save, Loader2, RotateCcw, ShieldCheck } from 'lucide-react' import CustomSelect from '../shared/CustomSelect' import { DialogSection, fs } from '../shared/DialogShell' import { SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, SettingsCard, StatusPill } from '../Settings/settingsKit' export default function PermissionsPanel(): React.ReactElement { const { t } = useTranslation() const { entryMap, values, loading, saving, dirty, handleChange, handleSave, handleReset } = usePermissionsAdmin() if (loading) { return (
) } return ( } >
{CATEGORIES.map(cat => ( {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 ( {!isDefault && {t('perm.customized')}} handleChange(key, val as PermissionLevel)} options={entry.allowedLevels.map(l => ({ value: l, label: t(LEVEL_LABELS[l] || l), }))} style={{ minWidth: 180 }} /> } /> ) })} ))}
) }