Remove Latest news section from the admin dashboard.
Drop the news list and news stat card so the dashboard only shows category, banner, static, and currency counts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
/**
|
||||
* Dashboard: content count cards and the latest news list.
|
||||
* Dashboard: content count cards.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const CARDS = [
|
||||
{ id: "stat-news", endpoint: "/api/v1/admin/news", listKey: "news" },
|
||||
{ id: "stat-categories", endpoint: "/api/v1/admin/categories", listKey: "categories" },
|
||||
{ id: "stat-banners", endpoint: "/api/v1/admin/banner", listKey: "banners" },
|
||||
{ id: "stat-static", endpoint: "/api/v1/admin/static", listKey: "statics" },
|
||||
@@ -29,35 +28,5 @@
|
||||
valueEl.textContent = "—";
|
||||
}
|
||||
});
|
||||
|
||||
loadLatestNews();
|
||||
});
|
||||
|
||||
async function loadLatestNews() {
|
||||
const container = document.getElementById("latest-news");
|
||||
if (!container) return;
|
||||
try {
|
||||
const data = await Api.get("/api/v1/admin/news", { limit: 6, page: 1 });
|
||||
const items = (data && data.news) || [];
|
||||
if (!items.length) {
|
||||
container.innerHTML =
|
||||
'<li class="py-4 text-base-content/60">No news yet.</li>';
|
||||
return;
|
||||
}
|
||||
container.innerHTML = items
|
||||
.map(
|
||||
(item) => `
|
||||
<li class="flex items-center gap-3 py-3">
|
||||
${item.imagePath ? `<img src="${UI.escapeHtml(item.imagePath)}" alt="" class="h-10 w-14 rounded object-cover" loading="lazy">` : ""}
|
||||
<div class="min-w-0 flex-1">
|
||||
<a href="/admin/news/${item.Id}/edit" class="block truncate font-medium hover:text-primary">${UI.escapeHtml(langText(item.title))}</a>
|
||||
<span class="text-sm text-base-content/60">${UI.escapeHtml(UI.formatDate(item.dateRelease))}</span>
|
||||
</div>
|
||||
</li>`
|
||||
)
|
||||
.join("");
|
||||
} catch (error) {
|
||||
container.innerHTML = `<li class="py-4 text-error">${UI.escapeHtml(error.message)}</li>`;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user