import React from "react"; import Image from "next/image"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Control, Controller } from "react-hook-form"; // services import { Listbox, Transition } from "@headlessui/react"; import { UserGroupIcon } from "@heroicons/react/24/outline"; import workspaceService from "services/workspace.service"; // headless ui // ui import { AssigneesList, Spinner } from "components/ui"; // types import { IModule } from "types"; // constants import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; type Props = { control: Control, any>; submitChanges: (formData: Partial) => void; }; const SelectMembers: React.FC = ({ control, submitChanges }) => { const router = useRouter(); const { workspaceSlug } = router.query; const { data: people } = useSWR( workspaceSlug ? WORKSPACE_MEMBERS(workspaceSlug as string) : null, workspaceSlug ? () => workspaceService.workspaceMembers(workspaceSlug as string) : null ); return (

Members

( { submitChanges({ members_list: value }); }} className="flex-shrink-0" > {({ open }) => (
{value && Array.isArray(value) ? ( ) : null}
{people ? ( people.length > 0 ? ( people.map((option) => ( `${ active || selected ? "bg-indigo-50" : "" } flex cursor-pointer select-none items-center gap-2 truncate p-2 text-gray-900` } value={option.member.id} > {option.member.avatar && option.member.avatar !== "" ? (
avatar
) : (
{option.member.first_name && option.member.first_name !== "" ? option.member.first_name.charAt(0) : option.member.email.charAt(0)}
)} {option.member.first_name && option.member.first_name !== "" ? option.member.first_name : option.member.email}
)) ) : (
No members found
) ) : ( )}
)}
)} />
); }; export default SelectMembers;