import { FC } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { useFormContext, useFieldArray, Controller } from "react-hook-form"; // fetch keys import { WORKSPACE_MEMBERS_WITH_EMAIL } from "constants/fetch-keys"; // services import { WorkspaceService } from "services/workspace.service"; // components import { CustomSelect, CustomSearchSelect, Avatar } from "components/ui"; import { Input, ToggleSwitch } from "@plane/ui"; // types import { IJiraImporterForm } from "types"; const workspaceService = new WorkspaceService(); export const JiraImportUsers: FC = () => { const router = useRouter(); const { workspaceSlug } = router.query; // form info const { control, watch, formState: { errors }, } = useFormContext(); const { fields } = useFieldArray({ control, name: "data.users", }); const { data: members } = useSWR( workspaceSlug ? WORKSPACE_MEMBERS_WITH_EMAIL(workspaceSlug?.toString() ?? "") : null, workspaceSlug ? () => workspaceService.workspaceMembersWithEmail(workspaceSlug?.toString() ?? "") : null ); const options = members?.map((member) => ({ value: member.member.email, query: member.member.display_name ?? "", content: (
{member.member.display_name}
), })); 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" && ( ( )} /> )}
))}
)}
); };