import { Control, Controller } from "react-hook-form"; import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Button, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2"; import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificateTemplatesV2Tab/shared/certificate-constants"; import { getSanPlaceholder, getSanTypeLabels, SubjectAltName } from "./certificateUtils"; type SubjectAltNamesFieldProps = { control: Control; allowedSanTypes: CertSubjectAlternativeNameType[]; error?: string; }; export const SubjectAltNamesField = ({ control, allowedSanTypes, error }: SubjectAltNamesFieldProps) => { const sanTypeLabels = getSanTypeLabels(); return ( (
{value.map((san: SubjectAltName, index: number) => ( // eslint-disable-next-line react/no-array-index-key
{ const newValue = [...value]; newValue[index] = { ...san, value: e.target.value }; onChange(newValue); }} placeholder={getSanPlaceholder(san.type)} className="flex-1" /> { const newValue = value.filter((_: any, i: number) => i !== index); onChange(newValue); }} >
))}
)} /> ); };