Files
main-tbbank/backend/web/admin/assets/js/dashboard.js
GuwandykA dbb6f7bda9 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>
2026-08-07 11:30:20 +05:00

33 lines
1.0 KiB
JavaScript

/**
* Dashboard: content count cards.
*/
(function () {
"use strict";
const CARDS = [
{ 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" },
{ id: "stat-currency", endpoint: "/api/v1/admin/currency", listKey: "currencies" },
];
document.addEventListener("DOMContentLoaded", () => {
if (document.body.dataset.page !== "dashboard") return;
if (!Auth.requireAuth()) return;
Auth.loadProfile();
Auth.bindLogoutButtons();
CARDS.forEach(async (card) => {
const valueEl = document.querySelector("#" + card.id + " [data-stat-value]");
if (!valueEl) return;
try {
const data = await Api.get(card.endpoint, { limit: 1, page: 1 });
valueEl.textContent = (data && data.count) || 0;
} catch (_) {
valueEl.textContent = "—";
}
});
});
})();