import { ChevronDownIcon } from '../ReactIcons/ChevronDownIcon';
import { useRef, useState } from 'react';
import { useOutsideClick } from '../../hooks/use-outside-click';
const allowedRoles = [
{
name: 'Admin',
value: 'admin',
description: 'Can do everything',
},
{
name: 'Manager',
value: 'manager',
description: 'Can manage team and skills',
},
{
name: 'Member',
value: 'member',
description: 'Can view team and skills',
},
] as const;
export type AllowedRoles = (typeof allowedRoles)[number]['value'];
type RoleDropdownProps = {
className?: string;
selectedRole: string;
setSelectedRole: (role: AllowedRoles) => void;
};
export function RoleDropdown(props: RoleDropdownProps) {
const { selectedRole, setSelectedRole, className = 'w-[120px]' } = props;
const dropdownRef = useRef(null);
const [activeRoleIndex, setActiveRoleIndex] = useState(0);
const [isMenuOpen, setIsMenuOpen] = useState(false);
useOutsideClick(dropdownRef, () => {
setIsMenuOpen(false);
});
return (
{isMenuOpen && (
{allowedRoles.map((allowedRole, roleCounter) => (
))}
)}
);
}