mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
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
This commit is contained in:
@@ -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() {
|
||||
)}
|
||||
</motion.div>
|
||||
|
||||
{/* Loading skeleton */}
|
||||
{isLoading && (
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className={cn(
|
||||
'animate-pulse rounded-2xl bg-dark-900 p-7',
|
||||
i === 0 && 'col-span-full',
|
||||
)}
|
||||
>
|
||||
<div className="mb-4 h-4 w-24 rounded bg-dark-800" />
|
||||
<div className="mb-3 h-6 w-3/4 rounded bg-dark-800" />
|
||||
<div className="h-4 w-1/2 rounded bg-dark-800" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Grid */}
|
||||
{!isLoading && items.length > 0 && (
|
||||
{items.length > 0 && (
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
{featured && <FeaturedCard item={featured} onClick={handleFeaturedClick} />}
|
||||
{regular.map((item, i) => (
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -944,7 +944,8 @@
|
||||
"auditLog": "گزارش بازرسی",
|
||||
"salesStats": "آمار فروش",
|
||||
"landings": "صفحات فرود",
|
||||
"referralNetwork": "شبکه ارجاع"
|
||||
"referralNetwork": "شبکه ارجاع",
|
||||
"news": "اخبار"
|
||||
},
|
||||
"panel": {
|
||||
"title": "پنل مدیریت",
|
||||
@@ -979,7 +980,8 @@
|
||||
"auditLogDesc": "بررسی فعالیت سیستم و تاریخچه دسترسی",
|
||||
"salesStatsDesc": "تحلیل فروش و روندها",
|
||||
"landingsDesc": "صفحات خرید سریع",
|
||||
"referralNetworkDesc": "نمایش بصری گراف ارجاعات و کمپینها"
|
||||
"referralNetworkDesc": "نمایش بصری گراف ارجاعات و کمپینها",
|
||||
"newsDesc": "مدیریت مقالات خبری و انتشارات"
|
||||
},
|
||||
"salesStats": {
|
||||
"title": "آمار فروش",
|
||||
|
||||
@@ -1131,7 +1131,8 @@
|
||||
"auditLog": "Журнал аудита",
|
||||
"salesStats": "Статистика продаж",
|
||||
"landings": "Лендинги",
|
||||
"referralNetwork": "Реферальная сеть"
|
||||
"referralNetwork": "Реферальная сеть",
|
||||
"news": "Новости"
|
||||
},
|
||||
"panel": {
|
||||
"title": "Панель администратора",
|
||||
@@ -1166,7 +1167,8 @@
|
||||
"auditLogDesc": "Просмотр активности системы и истории доступа",
|
||||
"salesStatsDesc": "Аналитика продаж и тренды",
|
||||
"landingsDesc": "Страницы быстрой покупки",
|
||||
"referralNetworkDesc": "Визуализация графа рефералов и РК"
|
||||
"referralNetworkDesc": "Визуализация графа рефералов и РК",
|
||||
"newsDesc": "Управление новостями и статьями"
|
||||
},
|
||||
"salesStats": {
|
||||
"title": "Статистика продаж",
|
||||
|
||||
@@ -944,7 +944,8 @@
|
||||
"auditLog": "审计日志",
|
||||
"salesStats": "销售统计",
|
||||
"landings": "落地页",
|
||||
"referralNetwork": "推荐网络"
|
||||
"referralNetwork": "推荐网络",
|
||||
"news": "新闻"
|
||||
},
|
||||
"panel": {
|
||||
"title": "管理面板",
|
||||
@@ -979,7 +980,8 @@
|
||||
"auditLogDesc": "查看系统活动和访问历史",
|
||||
"salesStatsDesc": "销售分析与趋势",
|
||||
"landingsDesc": "快速购买落地页",
|
||||
"referralNetworkDesc": "推荐图表和广告活动可视化"
|
||||
"referralNetworkDesc": "推荐图表和广告活动可视化",
|
||||
"newsDesc": "管理新闻文章和出版物"
|
||||
},
|
||||
"salesStats": {
|
||||
"title": "销售统计",
|
||||
|
||||
@@ -259,6 +259,16 @@ const NetworkGraphIcon = () => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
const NewspaperIcon = () => (
|
||||
<svg className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 01-2.25 2.25M16.5 7.5V18a2.25 2.25 0 002.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 002.25 2.25h13.5M6 7.5h3v3H6v-3z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
const ChevronRightIcon = () => (
|
||||
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
||||
@@ -538,6 +548,13 @@ export default function AdminPanel() {
|
||||
iconBg: 'bg-error-500/20',
|
||||
iconColor: 'text-error-400',
|
||||
items: [
|
||||
{
|
||||
to: '/admin/news',
|
||||
icon: <NewspaperIcon />,
|
||||
title: t('admin.nav.news'),
|
||||
description: t('admin.panel.newsDesc'),
|
||||
permission: 'news:read',
|
||||
},
|
||||
{
|
||||
to: '/admin/campaigns',
|
||||
icon: <MegaphoneIcon />,
|
||||
|
||||
Reference in New Issue
Block a user