"use client" import { useMemo } from "react" import { usePathname } from "next/navigation" import { ShieldAlert } from "lucide-react" import { useAuth } from "@/context/auth-context" const BLOCKED_STATUSES = new Set(["suspended", "restricted", "banned"]) export function AccountStatusGuard() { const pathname = usePathname() const { user, isLoadingAuth, logout } = useAuth() const status = useMemo(() => String((user as any)?.status || "active").toLowerCase().trim(), [user]) const skipGuard = pathname.startsWith("/auth/") || pathname === "/admin/login" if (skipGuard || isLoadingAuth || !user) return null if (!BLOCKED_STATUSES.has(status)) return null const title = status === "banned" ? "Account Banned" : "Account Suspended" const message = status === "banned" ? "Your account is banned. You cannot use OpenLearnX with this account. Contact admin for support." : "Your account is suspended. Contact admin to restore access." return (

{title}

Status: {status}

{message}

Contact admin.

) }