From f450f9c4aca502f127096b37fd289cf079660720 Mon Sep 17 00:00:00 2001 From: PEDZEO Date: Sat, 17 Jan 2026 07:32:35 +0300 Subject: [PATCH] Add localization keys for 'add' in English and Russian; enhance AdminBanSystem component with improved category inference and sorting --- src/locales/en.json | 1 + src/locales/ru.json | 1 + src/pages/AdminBanSystem.tsx | 71 ++++++++++++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 6436c47..86f0998 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -15,6 +15,7 @@ "yes": "Yes", "no": "No", "or": "or", + "add": "Add", "and": "and", "edit": "Edit", "delete": "Delete", diff --git a/src/locales/ru.json b/src/locales/ru.json index 2fc81af..af72674 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -15,6 +15,7 @@ "yes": "Да", "no": "Нет", "or": "или", + "add": "Добавить", "and": "и", "edit": "Редактировать", "delete": "Удалить", diff --git a/src/pages/AdminBanSystem.tsx b/src/pages/AdminBanSystem.tsx index a135121..99a87c7 100644 --- a/src/pages/AdminBanSystem.tsx +++ b/src/pages/AdminBanSystem.tsx @@ -938,27 +938,50 @@ export default function AdminBanSystem() { {/* Group settings by category */} {(() => { const grouped: Record = {} + + // Smart categorization: use API category or infer from key prefix + const inferCategory = (key: string, apiCategory: string | null): string => { + if (apiCategory) return apiCategory + if (key.startsWith('punishment_') || key.startsWith('progressive_ban')) return 'punishment' + if (key.startsWith('traffic_')) return 'traffic' + if (key.startsWith('network_')) return 'network' + if (key.startsWith('rate_limit_')) return 'rate_limit' + if (key.startsWith('notify_') || key.startsWith('daily_report')) return 'notifications' + return 'general' + } + settings.settings.forEach((s) => { - const cat = s.category || 'general' + const cat = inferCategory(s.key, s.category) if (!grouped[cat]) grouped[cat] = [] grouped[cat].push(s) }) - return Object.entries(grouped).map(([category, items]) => ( + // Sort categories in logical order + const categoryOrder = ['general', 'punishment', 'progressive_bans', 'traffic', 'network', 'notifications', 'rate_limit'] + const sortedCategories = Object.keys(grouped).sort((a, b) => { + const aIdx = categoryOrder.indexOf(a) + const bIdx = categoryOrder.indexOf(b) + if (aIdx === -1 && bIdx === -1) return a.localeCompare(b) + if (aIdx === -1) return 1 + if (bIdx === -1) return -1 + return aIdx - bIdx + }) + + return sortedCategories.map((category) => (

{formatCategory(category)}

- {items.map((setting) => ( -
+ {grouped[category].map((setting) => ( +
{formatSettingKey(setting.key)}
{setting.description && (
{setting.description}
)}
-
+
{setting.type === 'bool' ? (