// react import React from "react"; // next import Image from "next/image"; // swr import useSWR from "swr"; // react-hook-form import { Control, Controller } from "react-hook-form"; // services import workspaceService from "lib/services/workspace.service"; // hooks import useUser from "lib/hooks/useUser"; // headless ui import { Listbox, Transition } from "@headlessui/react"; // ui import { Spinner } from "ui"; // icons import { ArrowPathIcon, ChevronDownIcon } from "@heroicons/react/24/outline"; import User from "public/user.png"; // types import { IIssue } from "types"; // constants import { classNames } from "constants/common"; import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; type Props = { control: Control; submitChanges: (formData: Partial) => void; }; const SelectAssignee: React.FC = ({ control, submitChanges }) => { const { activeWorkspace } = useUser(); const { data: people } = useSWR( activeWorkspace ? WORKSPACE_MEMBERS(activeWorkspace.slug) : null, activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null ); return (

Assignees

( { submitChanges({ assignees_list: value }); }} className="flex-shrink-0" > {({ open }) => (
{value && Array.isArray(value) ? ( <> {value.length > 0 ? ( value.map((assignee, index: number) => { const person = people?.find( (p) => p.member.id === assignee )?.member; return (
{person && person.avatar && person.avatar !== "" ? (
{person.first_name}
) : (
{person?.first_name.charAt(0)}
)}
); }) ) : (
No user
)} ) : null}
{people ? ( people.length > 0 ? ( people.map((option) => ( `${ active || selected ? "bg-indigo-50" : "" } flex items-center gap-2 text-gray-900 cursor-pointer select-none p-2 truncate` } 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
) ) : ( )}
)}
)} />
); }; export default SelectAssignee;