![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/public_html/src/pages/ |
import { useEffect, useState } from 'react';
import { useSession } from 'next-auth/react';
import { useRouter } from 'next/router';
import LayoutWithSidebar from '../components/LayoutWithSidebar';
import {
Loader2,
User,
Building,
Scale,
Users,
Shield,
AlertTriangle,
Info
} from 'lucide-react';
export default function DashboardDebug() {
const { data: session, status } = useSession();
const router = useRouter();
const [debugInfo, setDebugInfo] = useState<any>({});
useEffect(() => {
// Collect debug information
setDebugInfo({
status,
session: session ? {
user: {
name: session.user?.name,
email: session.user?.email,
role: session.user?.role,
image: session.user?.image
},
expires: session.expires
} : null,
router: {
pathname: router.pathname,
query: router.query,
asPath: router.asPath
},
timestamp: new Date().toISOString()
});
}, [session, status, router]);
if (status === 'loading') {
return (
<LayoutWithSidebar>
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<Loader2 className="h-8 w-8 animate-spin mx-auto mb-4 text-blue-600" />
<h2 className="text-xl font-semibold text-gray-900 mb-2">Loading Dashboard</h2>
<p className="text-gray-600">Checking authentication status...</p>
</div>
</div>
</LayoutWithSidebar>
);
}
return (
<LayoutWithSidebar>
<div className="min-h-screen p-6">
<div className="max-w-4xl mx-auto">
<div className="bg-white rounded-lg shadow-lg p-6 mb-6">
<div className="flex items-center mb-4">
<Info className="h-6 w-6 text-blue-600 mr-2" />
<h1 className="text-2xl font-bold text-gray-900">Dashboard Debug Information</h1>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="bg-gray-50 p-4 rounded-lg">
<h3 className="font-semibold text-gray-900 mb-2">Authentication Status</h3>
<div className="space-y-2 text-sm">
<div><strong>Status:</strong> <span className={`px-2 py-1 rounded ${status === 'authenticated' ? 'bg-green-100 text-green-800' : status === 'unauthenticated' ? 'bg-red-100 text-red-800' : 'bg-yellow-100 text-yellow-800'}`}>{status}</span></div>
<div><strong>Session:</strong> {session ? 'Present' : 'None'}</div>
{session && (
<>
<div><strong>User Name:</strong> {session.user?.name || 'N/A'}</div>
<div><strong>User Email:</strong> {session.user?.email || 'N/A'}</div>
<div><strong>User Role:</strong> {session.user?.role || 'N/A'}</div>
<div><strong>Session Expires:</strong> {session.expires || 'N/A'}</div>
</>
)}
</div>
</div>
<div className="bg-gray-50 p-4 rounded-lg">
<h3 className="font-semibold text-gray-900 mb-2">Router Information</h3>
<div className="space-y-2 text-sm">
<div><strong>Pathname:</strong> {router.pathname}</div>
<div><strong>As Path:</strong> {router.asPath}</div>
<div><strong>Query:</strong> {JSON.stringify(router.query)}</div>
</div>
</div>
</div>
<div className="mt-6 bg-gray-50 p-4 rounded-lg">
<h3 className="font-semibold text-gray-900 mb-2">Debug Data (JSON)</h3>
<pre className="text-xs bg-gray-100 p-3 rounded overflow-auto max-h-64">
{JSON.stringify(debugInfo, null, 2)}
</pre>
</div>
<div className="mt-6 flex space-x-4">
<button
onClick={() => router.push('/dashboard')}
className="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors"
>
Try Main Dashboard
</button>
<button
onClick={() => router.push('/user/dashboard')}
className="bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 transition-colors"
>
Go to User Dashboard
</button>
<button
onClick={() => window.location.reload()}
className="bg-gray-600 text-white px-4 py-2 rounded-lg hover:bg-gray-700 transition-colors"
>
Reload Page
</button>
</div>
</div>
</div>
</div>
</LayoutWithSidebar>
);
}