feat: Implement admin user management page with create/delete functionality, add a super-admin-only sidebar link, and expose isSuperAdmin in AuthContext.

This commit is contained in:
pradeepkumar
2026-03-20 17:04:59 +05:30
parent 8043d66898
commit 37326db652
3 changed files with 240 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import { usePathname } from 'next/navigation';
import { useState, useEffect, useCallback } from 'react';
import { supportChatService } from '@/services/support-chat.service';
import { adminSocketService } from '@/services/socket.service';
import { useAuth } from '@/context/AuthContext';
const menuItems = [
{
@@ -137,6 +138,7 @@ const menuItems = [
export default function Sidebar() {
const pathname = usePathname();
const { isSuperAdmin } = useAuth();
const [unreadCount, setUnreadCount] = useState(0);
const fetchUnreadCount = useCallback(async () => {
@@ -229,6 +231,23 @@ export default function Sidebar() {
</li>
);
})}
{isSuperAdmin && (
<li>
<Link
href="/dashboard/admin-users"
className={`flex items-center px-4 py-3 rounded-lg transition-all duration-200 ${
pathname === '/dashboard/admin-users'
? 'bg-[#f5a623] text-white shadow-sm'
: 'text-[#c4d9d4] hover:bg-[#003a57] hover:text-white'
}`}
>
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
</svg>
<span className="ml-3 font-medium font-serif text-sm">Admin Users</span>
</Link>
</li>
)}
</ul>
</nav>
</aside>