import { Group } from 'common/group' import { Combobox } from '@headlessui/react' import { InfoTooltip } from 'web/components/info-tooltip' import { CheckIcon, PlusCircleIcon, SelectorIcon, } from '@heroicons/react/outline' import clsx from 'clsx' import { CreateGroupButton } from 'web/components/groups/create-group-button' import { useState } from 'react' import { useMemberGroups } from 'web/hooks/use-group' import { User } from 'common/user' export function GroupSelector(props: { selectedGroup?: Group setSelectedGroup: (group: Group) => void creator: User | null | undefined showSelector?: boolean }) { const { selectedGroup, setSelectedGroup, creator, showSelector } = props const [isCreatingNewGroup, setIsCreatingNewGroup] = useState(false) const [query, setQuery] = useState('') const memberGroups = useMemberGroups(creator) const filteredGroups = memberGroups ? query === '' ? memberGroups : memberGroups.filter((group) => { return group.name.toLowerCase().includes(query.toLowerCase()) }) : [] if (!showSelector || !creator) { return ( <>