Improve admin analytics and user management UI
Refactored admin users page to use client-side fetching, loading states, and search functionality. Enhanced AdminAnalytics with a best month (YTD) card and removed debug logging. Improved SystemStatusCard formatting and removed console logs. Fixed profit chart period selection logic. Minor formatting fix in nav-item component.
This commit is contained in:
@@ -20,10 +20,13 @@ function formatDuration(seconds: number) {
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
if (bytes < 0) return '0 Bytes'; // Handle negative values
|
||||
const k = 1024;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
|
||||
const i = Math.max(0, Math.floor(Math.log(bytes) / Math.log(k))); // Ensure i is at least 0
|
||||
// Clamp i to valid array index
|
||||
const clampedI = Math.min(i, sizes.length - 1);
|
||||
return Math.round(bytes / Math.pow(k, clampedI) * 100) / 100 + ' ' + sizes[clampedI];
|
||||
}
|
||||
|
||||
export default function SystemStatusCard() {
|
||||
@@ -36,7 +39,6 @@ export default function SystemStatusCard() {
|
||||
(async () => {
|
||||
try {
|
||||
const res = await fetchClient<Status>("/admin/system-status");
|
||||
console.log(`Here is your mother fuckin data: ${JSON.stringify(res)}`);
|
||||
if (mounted) setData(res);
|
||||
} catch (e: any) {
|
||||
if (mounted) setError(e?.message || "Failed to load status");
|
||||
|
||||
Reference in New Issue
Block a user