AdminUsersPage.jsx 901 B

1234567891011121314151617181920212223242526272829
  1. "use client";
  2. import React from "react";
  3. import { useAuth } from "@/components/auth/authContext";
  4. import ForbiddenView from "@/components/system/ForbiddenView";
  5. import { canManageUsers as canManageUsersRole } from "@/lib/frontend/auth/roles";
  6. import AdminUsersClient from "@/components/admin/users/AdminUsersClient";
  7. /**
  8. * AdminUsersPage
  9. *
  10. * This component only gates access and then renders the real client UI.
  11. * No conditional hooks issue here because we only call useAuth().
  12. */
  13. export default function AdminUsersPage() {
  14. const { status, user } = useAuth();
  15. const isAuthenticated = status === "authenticated" && user;
  16. // AuthGate already prevents rendering for unauthenticated users,
  17. // but we keep this as a defensive guard.
  18. if (!isAuthenticated) return null;
  19. const allowed = canManageUsersRole(user.role);
  20. if (!allowed) return <ForbiddenView />;
  21. return <AdminUsersClient />;
  22. }