import { useRef, useState } from 'react'; import type { TeamMemberDocument } from './TeamMembersPage'; import { useOutsideClick } from '../../hooks/use-outside-click'; import { MoreVerticalIcon } from '../ReactIcons/MoreVerticalIcon.tsx'; export function MemberActionDropdown({ member, onUpdateMember, onDeleteMember, onResendInvite, isDisabled = false, onSendProgressReminder, allowProgressReminder = false, allowUpdateRole = true, }: { onDeleteMember: () => void; onUpdateMember: () => void; onResendInvite: () => void; onSendProgressReminder: () => void; isDisabled: boolean; allowProgressReminder: boolean; allowUpdateRole: boolean; member: TeamMemberDocument; }) { const menuRef = useRef(null); const [isOpen, setIsOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); useOutsideClick(menuRef, () => { setIsOpen(false); }); const actions = [ ...(allowUpdateRole ? [ { name: 'Update Role', handleClick: () => { onUpdateMember(); setIsOpen(false); }, }, ] : []), ...(allowProgressReminder ? [ { name: 'Send Progress Reminder', handleClick: () => { onSendProgressReminder(); setIsOpen(false); }, }, ] : []), ...(['invited'].includes(member.status) ? [ { name: 'Resend Invite', handleClick: () => { onResendInvite(); setIsOpen(false); }, }, ] : []), { name: 'Delete', handleClick: () => { onDeleteMember(); setIsOpen(false); }, }, ]; return (
{isOpen && (
    {actions.map((action, index) => { return (
  • ); })}
)}
); }