fix: add placeholders for dashboard data to prevent 500 errors

This commit is contained in:
rustmailer
2026-03-11 23:18:16 +08:00
parent 396383aa97
commit f3c46f97b9
2 changed files with 19 additions and 1 deletions
+17
View File
@@ -57,6 +57,23 @@ export interface DashboardStats {
commit_hash: string //Git commit hash used to build this system version
}
export const INITIAL_DASHBOARD_STATS: DashboardStats = {
account_count: 0,
email_count: 0,
total_size_bytes: 0,
storage_usage_bytes: 0,
index_usage_bytes: 0,
recent_activity: [],
top_senders: [],
top_accounts: [],
with_attachment_count: 0,
without_attachment_count: 0,
top_largest_emails: [],
system_version: '0.0.0',
commit_hash: 'n/a'
};
export interface TimeBucket {
timestamp_ms: number; // Timestamp in milliseconds
count: number; // Number of emails in this time bucket
+2 -1
View File
@@ -25,7 +25,7 @@ import { XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pi
import { Mail, HardDrive, Database, Users, Inbox, Info } from 'lucide-react';
import { formatBytes, formatNumber } from '@/lib/utils';
import { useQuery } from '@tanstack/react-query';
import { get_dashboard_stats, TimeBucket } from '@/api/system/api';
import { get_dashboard_stats, INITIAL_DASHBOARD_STATS, TimeBucket } from '@/api/system/api';
import { Main } from '@/components/layout/main';
import { FixedHeader } from '@/components/layout/fixed-header';
import { useTranslation } from 'react-i18next';
@@ -108,6 +108,7 @@ export default function MailArchiveDashboard() {
queryKey: ['dashboard-stats'],
enabled: !!token,
queryFn: get_dashboard_stats,
placeholderData: INITIAL_DASHBOARD_STATS,
});
const { t, i18n } = useTranslation();