diff --git a/src/app/(admin)/admin/members/[id]/page.tsx b/src/app/(admin)/admin/members/[id]/page.tsx index f3f502c..6c581f3 100644 --- a/src/app/(admin)/admin/members/[id]/page.tsx +++ b/src/app/(admin)/admin/members/[id]/page.tsx @@ -56,6 +56,14 @@ import { DialogHeader, DialogTitle, } from '@/components/ui/dialog' +import { + DropdownMenu, + DropdownMenuCheckboxItem, + DropdownMenuContent, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' import { UserAvatar } from '@/components/shared/user-avatar' import { Checkbox } from '@/components/ui/checkbox' import { @@ -80,6 +88,8 @@ import { Link as LinkIcon, Copy, Check, + Plus, + X, } from 'lucide-react' import { getCountryName, getCountryFlag } from '@/lib/countries' import { formatRelativeTime } from '@/lib/utils' @@ -185,6 +195,10 @@ export default function MemberDetailPage() { const [maxAssignments, setMaxAssignments] = useState('') const [showSuperAdminConfirm, setShowSuperAdminConfirm] = useState(false) const [pendingSuperAdminRole, setPendingSuperAdminRole] = useState(false) + const [pendingAdditionalRole, setPendingAdditionalRole] = useState<{ + role: 'JURY_MEMBER' | 'OBSERVER' | 'MENTOR' + action: 'add' | 'remove' + } | null>(null) const [additionalRoles, setAdditionalRoles] = useState([]) useEffect(() => { @@ -691,26 +705,72 @@ export default function MemberDetailPage() {

- Grant additional dashboard access beyond the primary role + Grant additional dashboard access beyond the primary role. + Click the menu to add or remove a role — you'll be + asked to confirm each change.

-
- {(['JURY_MEMBER', 'OBSERVER', 'MENTOR'] as const) - .filter((r) => r !== role) - .map((r) => ( -
@@ -882,6 +942,59 @@ export default function MemberDetailPage() { {/* Super Admin Confirmation Dialog */} + { if (!open) setPendingAdditionalRole(null) }} + > + + + + {pendingAdditionalRole?.action === 'add' ? 'Add' : 'Remove'}{' '} + {pendingAdditionalRole?.role.replace(/_/g, ' ')} role? + + + {pendingAdditionalRole?.action === 'add' ? ( + <> + This will give {name || user?.name || 'this user'}{' '} + the {pendingAdditionalRole.role.replace(/_/g, ' ')} dashboard + in addition to their primary role. They'll be able to + switch between dashboards from the role switcher. Click + “Save changes” below to apply. + + ) : ( + <> + This will revoke the {pendingAdditionalRole?.role.replace(/_/g, ' ')} + {' '}dashboard from {name || user?.name || 'this user'}. + They'll keep their primary role and any other additional + roles. Click “Save changes” below to apply. + + )} + + + + setPendingAdditionalRole(null)}> + Cancel + + { + if (!pendingAdditionalRole) return + const { role: r, action } = pendingAdditionalRole + if (action === 'add') { + setAdditionalRoles((prev) => + prev.includes(r) ? prev : [...prev, r] + ) + } else { + setAdditionalRoles((prev) => prev.filter((x) => x !== r)) + } + setPendingAdditionalRole(null) + }} + > + {pendingAdditionalRole?.action === 'add' ? 'Add role' : 'Remove role'} + + + + +