From 38b0f4be9a921fa1af4a49817f6b17d738c5b074 Mon Sep 17 00:00:00 2001 From: Fringg Date: Mon, 23 Mar 2026 11:21:25 +0300 Subject: [PATCH] fix: add news link to admin panel, prevent empty news section flash - Add News item to marketing group in AdminPanel with NewspaperIcon - Add news nav/panel translations for all 4 locales (ru, en, zh, fa) - Don't render NewsSection until query confirms articles exist - Remove skeleton that caused brief flash when news list is empty --- src/components/news/NewsSection.tsx | 26 ++++---------------------- src/locales/en.json | 6 ++++-- src/locales/fa.json | 6 ++++-- src/locales/ru.json | 6 ++++-- src/locales/zh.json | 6 ++++-- src/pages/AdminPanel.tsx | 17 +++++++++++++++++ 6 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/components/news/NewsSection.tsx b/src/components/news/NewsSection.tsx index 0795502..c0f46f1 100644 --- a/src/components/news/NewsSection.tsx +++ b/src/components/news/NewsSection.tsx @@ -427,8 +427,9 @@ export default function NewsSection() { if (featuredSlug) handleCardClick(featuredSlug); }, [featuredSlug, handleCardClick]); - // Don't render if no news and not loading - if (!isLoading && items.length === 0) { + // Don't render until we know there are news items. + // This prevents the skeleton from briefly flashing when there are no articles. + if (items.length === 0) { return null; } @@ -463,27 +464,8 @@ export default function NewsSection() { )} - {/* Loading skeleton */} - {isLoading && ( -
- {Array.from({ length: 3 }).map((_, i) => ( -
-
-
-
-
- ))} -
- )} - {/* Grid */} - {!isLoading && items.length > 0 && ( + {items.length > 0 && (
{featured && } {regular.map((item, i) => ( diff --git a/src/locales/en.json b/src/locales/en.json index 8fa7b71..c9f4647 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1110,7 +1110,8 @@ "auditLog": "Audit Log", "salesStats": "Sales Statistics", "landings": "Landings", - "referralNetwork": "Referral Network" + "referralNetwork": "Referral Network", + "news": "News" }, "panel": { "title": "Admin Panel", @@ -1145,7 +1146,8 @@ "auditLogDesc": "Review system activity and access history", "salesStatsDesc": "Sales analytics and trends", "landingsDesc": "Quick purchase landing pages", - "referralNetworkDesc": "Referral graph and campaign visualization" + "referralNetworkDesc": "Referral graph and campaign visualization", + "newsDesc": "Manage news articles and publications" }, "salesStats": { "title": "Sales Statistics", diff --git a/src/locales/fa.json b/src/locales/fa.json index c0b61a0..1ad952b 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -944,7 +944,8 @@ "auditLog": "گزارش بازرسی", "salesStats": "آمار فروش", "landings": "صفحات فرود", - "referralNetwork": "شبکه ارجاع" + "referralNetwork": "شبکه ارجاع", + "news": "اخبار" }, "panel": { "title": "پنل مدیریت", @@ -979,7 +980,8 @@ "auditLogDesc": "بررسی فعالیت سیستم و تاریخچه دسترسی", "salesStatsDesc": "تحلیل فروش و روندها", "landingsDesc": "صفحات خرید سریع", - "referralNetworkDesc": "نمایش بصری گراف ارجاعات و کمپین‌ها" + "referralNetworkDesc": "نمایش بصری گراف ارجاعات و کمپین‌ها", + "newsDesc": "مدیریت مقالات خبری و انتشارات" }, "salesStats": { "title": "آمار فروش", diff --git a/src/locales/ru.json b/src/locales/ru.json index e7ae38d..3ecaa27 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1131,7 +1131,8 @@ "auditLog": "Журнал аудита", "salesStats": "Статистика продаж", "landings": "Лендинги", - "referralNetwork": "Реферальная сеть" + "referralNetwork": "Реферальная сеть", + "news": "Новости" }, "panel": { "title": "Панель администратора", @@ -1166,7 +1167,8 @@ "auditLogDesc": "Просмотр активности системы и истории доступа", "salesStatsDesc": "Аналитика продаж и тренды", "landingsDesc": "Страницы быстрой покупки", - "referralNetworkDesc": "Визуализация графа рефералов и РК" + "referralNetworkDesc": "Визуализация графа рефералов и РК", + "newsDesc": "Управление новостями и статьями" }, "salesStats": { "title": "Статистика продаж", diff --git a/src/locales/zh.json b/src/locales/zh.json index 5a6ffb8..194ca53 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -944,7 +944,8 @@ "auditLog": "审计日志", "salesStats": "销售统计", "landings": "落地页", - "referralNetwork": "推荐网络" + "referralNetwork": "推荐网络", + "news": "新闻" }, "panel": { "title": "管理面板", @@ -979,7 +980,8 @@ "auditLogDesc": "查看系统活动和访问历史", "salesStatsDesc": "销售分析与趋势", "landingsDesc": "快速购买落地页", - "referralNetworkDesc": "推荐图表和广告活动可视化" + "referralNetworkDesc": "推荐图表和广告活动可视化", + "newsDesc": "管理新闻文章和出版物" }, "salesStats": { "title": "销售统计", diff --git a/src/pages/AdminPanel.tsx b/src/pages/AdminPanel.tsx index f3fc46f..83753c4 100644 --- a/src/pages/AdminPanel.tsx +++ b/src/pages/AdminPanel.tsx @@ -259,6 +259,16 @@ const NetworkGraphIcon = () => ( ); +const NewspaperIcon = () => ( + + + +); + const ChevronRightIcon = () => ( @@ -538,6 +548,13 @@ export default function AdminPanel() { iconBg: 'bg-error-500/20', iconColor: 'text-error-400', items: [ + { + to: '/admin/news', + icon: , + title: t('admin.nav.news'), + description: t('admin.panel.newsDesc'), + permission: 'news:read', + }, { to: '/admin/campaigns', icon: ,