import React from "react"; import Image from "next/image"; import { useRouter } from "next/router"; import useSWR from "swr"; // react-hook-form import { Control, Controller } from "react-hook-form"; // headless ui import { Listbox, Transition } from "@headlessui/react"; // services import { UserGroupIcon } from "@heroicons/react/24/outline"; import workspaceService from "services/workspace.service"; // hooks // ui import { AssigneesList } from "components/ui/avatar"; import { Spinner } from "components/ui"; // types import { IIssue, UserAuth } from "types"; // constants import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; type Props = { control: Control; submitChanges: (formData: Partial) => void; userAuth: UserAuth; }; export const SidebarAssigneeSelect: React.FC = ({ control, submitChanges, userAuth }) => { 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 ); const isNotAllowed = userAuth.isGuest || userAuth.isViewer; return (

Assignees

( { submitChanges({ assignees_list: value }); }} className="flex-shrink-0" disabled={isNotAllowed} > {({ open }) => (
{value && Array.isArray(value) ? ( ) : null}
{people ? ( people.length > 0 ? ( people.map((option) => ( `${active || selected ? "bg-indigo-50" : ""} ${ selected ? "font-medium" : "" } 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 assignees found
) ) : ( )}
)}
)} />
); };