import React from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // services import { ProjectMemberService } from "services/project"; // ui import { Avatar, AvatarGroup, CustomSearchSelect, UserGroupIcon } from "@plane/ui"; // icons import { ChevronDown } from "lucide-react"; // fetch-keys import { PROJECT_MEMBERS } from "constants/fetch-keys"; type Props = { value: string[] | undefined; onChange: (val: string[]) => void; disabled?: boolean; }; // services const projectMemberService = new ProjectMemberService(); export const SidebarMembersSelect: React.FC = ({ value, onChange, disabled = false }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { data: members } = useSWR( workspaceSlug && projectId ? PROJECT_MEMBERS(projectId as string) : null, workspaceSlug && projectId ? () => projectMemberService.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.display_name}
), })); return (
Members
0 && Array.isArray(value) ? (
{value.map((assigneeId) => { const member = members?.find((m) => m.member.id === assigneeId)?.member; if (!member) return null; return ; })}
) : (
No members {!disabled && }
) } options={options} onChange={onChange} maxHeight="md" multiple />
); };