'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import { useStore } from '@/lib/store'; import { isAdmin } from '@/lib/auth'; import { ShieldX, Loader2 } from 'lucide-react'; interface AdminGuardProps { children: React.ReactNode; fallback?: React.ReactNode; } export default function AdminGuard({ children, fallback }: AdminGuardProps) { const { user } = useStore(); const router = useRouter(); const [checking, setChecking] = useState(true); useEffect(() => { // Small delay to allow store to hydrate const timer = setTimeout(() => { setChecking(false); }, 100); return () => clearTimeout(timer); }, []); if (checking) { return (
You don't have permission to access this area.