import { FC } from "react"; // next import { useRouter } from "next/router"; // swr import useSWR from "swr"; // react-hook-form 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 { ToggleSwitch, Input, CustomSelect, CustomSearchSelect, Avatar } from "components/ui"; import { IJiraImporterForm } from "types"; export const JiraImportUsers: FC = () => { const { control, watch, register, formState: { errors }, } = useFormContext(); const { fields } = useFieldArray({ control, name: "data.users", }); const router = useRouter(); const { workspaceSlug } = router.query; 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" && ( ( )} /> )}
))}
)}
); };