feat(auth): implement session token creation and verification for enhanced security
feat(api): require session authentication for admin routes and improve error handling fix(api): streamline project image generation by fetching data directly from the database fix(api): optimize project import/export functionality with session validation and improved error handling fix(api): enhance analytics dashboard and email manager with session token for admin requests fix(components): improve loading states and dynamic imports for better user experience chore(security): update Content Security Policy to avoid unsafe-eval in production chore(deps): update package.json scripts for consistent environment handling in linting and testing
This commit is contained in:
@@ -17,10 +17,24 @@ import {
|
||||
X
|
||||
} from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { EmailManager } from './EmailManager';
|
||||
import { AnalyticsDashboard } from './AnalyticsDashboard';
|
||||
import ImportExport from './ImportExport';
|
||||
import { ProjectManager } from './ProjectManager';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
const EmailManager = dynamic(
|
||||
() => import('./EmailManager').then((m) => m.EmailManager),
|
||||
{ ssr: false, loading: () => <div className="p-6 text-stone-500">Loading emails…</div> }
|
||||
);
|
||||
const AnalyticsDashboard = dynamic(
|
||||
() => import('./AnalyticsDashboard').then((m) => m.default),
|
||||
{ ssr: false, loading: () => <div className="p-6 text-stone-500">Loading analytics…</div> }
|
||||
);
|
||||
const ImportExport = dynamic(
|
||||
() => import('./ImportExport').then((m) => m.default),
|
||||
{ ssr: false, loading: () => <div className="p-6 text-stone-500">Loading tools…</div> }
|
||||
);
|
||||
const ProjectManager = dynamic(
|
||||
() => import('./ProjectManager').then((m) => m.ProjectManager),
|
||||
{ ssr: false, loading: () => <div className="p-6 text-stone-500">Loading projects…</div> }
|
||||
);
|
||||
|
||||
interface Project {
|
||||
id: string;
|
||||
@@ -178,9 +192,24 @@ const ModernAdminDashboard: React.FC<ModernAdminDashboardProps> = ({ isAuthentic
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Load all data (authentication disabled)
|
||||
loadAllData();
|
||||
}, [loadAllData]);
|
||||
// Prioritize the data needed for the initial dashboard render
|
||||
void (async () => {
|
||||
await Promise.all([loadProjects(), loadSystemStats()]);
|
||||
|
||||
const idle = (cb: () => void) => {
|
||||
if (typeof window !== 'undefined' && 'requestIdleCallback' in window) {
|
||||
(window as unknown as { requestIdleCallback: (fn: () => void) => void }).requestIdleCallback(cb);
|
||||
} else {
|
||||
setTimeout(cb, 300);
|
||||
}
|
||||
};
|
||||
|
||||
idle(() => {
|
||||
void loadAnalytics();
|
||||
void loadEmails();
|
||||
});
|
||||
})();
|
||||
}, [loadProjects, loadSystemStats, loadAnalytics, loadEmails]);
|
||||
|
||||
const navigation = [
|
||||
{ id: 'overview', label: 'Dashboard', icon: Home, color: 'blue', description: 'Overview & Statistics' },
|
||||
|
||||
Reference in New Issue
Block a user