import { useRouter } from "next/router"; import useSWR from "swr"; // services import { ProjectService } from "services/project"; // ui import { Avatar, AvatarGroup, CustomSearchSelect } from "@plane/ui"; import { User2 } from "lucide-react"; // fetch-keys import { PROJECT_MEMBERS } from "constants/fetch-keys"; export type Props = { projectId: string; value: string[]; onChange: (value: string[]) => void; }; const projectService = new ProjectService(); export const IssueAssigneeSelect: React.FC = ({ projectId, value = [], onChange }) => { const router = useRouter(); const { workspaceSlug } = router.query; const { data: members } = useSWR( workspaceSlug && projectId ? PROJECT_MEMBERS(projectId as string) : null, workspaceSlug && projectId ? () => projectService.fetchProjectMembers(workspaceSlug as string, projectId as string) : null ); const options = members?.map((member) => ({ value: member.member.id, query: member.member.display_name ?? "", content: (
{member.member.is_bot ? member.member.first_name : member.member.display_name}
), })); return ( {value && value.length > 0 && Array.isArray(value) ? (
{value.map((assigneeId) => { const member = members?.find((m) => m.member.id === assigneeId)?.member; if (!member) return null; return ; })}
) : (
Assignee
)} } multiple noChevron /> ); };