upd: list pengaduan dashboard

This commit is contained in:
2025-11-07 12:06:46 +08:00
parent 14ec81d98d
commit e0456b2dba
3 changed files with 267 additions and 109 deletions

View File

@@ -0,0 +1,21 @@
export function getLastUpdated(date: string | Date): string {
const now = new Date();
const updated = new Date(date);
const diffMs = now.getTime() - updated.getTime();
const diffMinutes = Math.floor(diffMs / (1000 * 60));
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
if (diffMinutes < 1) return "baru saja";
if (diffMinutes < 60) return `${diffMinutes} menit lalu`;
if (diffHours < 24) return `${diffHours} jam lalu`;
if (diffDays < 7) return `${diffDays} hari lalu`;
// kalau sudah lebih dari seminggu, tampilkan tanggal
return updated.toLocaleDateString("id-ID", {
day: "numeric",
month: "long",
year: "numeric",
});
}