mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
fix: add placeholders for dashboard data to prevent 500 errors
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user