import { FC } from "react"; import { useParams } from "next/navigation"; import { useFormContext, useFieldArray, Controller } from "react-hook-form"; import useSWR from "swr"; import { IJiraImporterForm } from "@plane/types"; // services import { Avatar, CustomSelect, CustomSearchSelect, Input, ToggleSwitch } from "@plane/ui"; import { WORKSPACE_MEMBERS } from "@/constants/fetch-keys"; import { WorkspaceService } from "@/services/workspace.service"; // ui // types // fetch keys const workspaceService = new WorkspaceService(); export const JiraImportUsers: FC = () => { const { workspaceSlug } = useParams(); // form info const { control, watch, formState: { errors }, } = useFormContext(); const { fields } = useFieldArray({ control, name: "data.users", }); const { data: members } = useSWR( workspaceSlug ? WORKSPACE_MEMBERS(workspaceSlug?.toString() ?? "") : null, workspaceSlug ? () => workspaceService.fetchWorkspaceMembers(workspaceSlug?.toString() ?? "") : null ); const options = members ?.map((member) => { if (!member?.member) return; return { value: member.member.email, query: member.member.display_name ?? "", content: (
{member.member.display_name}
), }; }) .filter((member) => !!member) as | { value: string; query: string; content: JSX.Element; }[] | undefined; return (

Users

Update, invite or choose not to invite assignee

} />
{watch("data.invite_users") && (
Name
Import as
{fields.map((user, index) => (

{user.username}

( {Boolean(value) ? value : ("Ignore" as any)}} > Invite by email Map to existing Do not import )} />
{watch(`data.users.${index}.import`) === "invite" && ( ( )} /> )} {watch(`data.users.${index}.import`) === "map" && ( ( )} /> )}
))}
)}
); };