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 workspaceService from "services/workspace.service"; // icons import { UserIcon } from "@heroicons/react/24/outline"; import User from "public/user.png"; // types import { IModule, IUserLite } from "types"; // fetch-keys import { WORKSPACE_MEMBERS } from "constants/fetch-keys"; type Props = { control: Control, any>; submitChanges: (formData: Partial) => void; lead: IUserLite | null; }; export const SidebarLeadSelect: React.FC = ({ control, submitChanges, lead }) => { 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 (

Lead

( { submitChanges({ lead: value }); }} className="flex-shrink-0" > {({ open }) => (
{lead ? ( lead.avatar && lead.avatar !== "" ? (
{lead?.first_name}
) : (
{lead?.first_name && lead.first_name !== "" ? lead.first_name.charAt(0) : lead?.email.charAt(0)}
) ) : (
No user
)} {lead ? lead?.first_name && lead.first_name !== "" ? lead?.first_name : lead?.email : "N/A"}
{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
) ) : (

Loading...

)}
)}
)} />
); };