import React, { useState } from "react"; import { Box, FormHelperText, Input, Tag, TagCloseButton, TagLabel } from "@chakra-ui/react"; import { TiWarning } from "react-icons/ti"; const ChipSelector = ({chips, setChips, type}) => { const [text, setText] = useState(""); const [validationError, setValidationError] = useState(""); function removeChip(chipToRemove) { const updatedChips = chips.filter((chip, index) => index !== chipToRemove); setChips(updatedChips); } function handlePressEnter(e) { if (e.key === "Enter") e.preventDefault(); if (e.key !== "Enter" || !text) return; if (chips.includes(text)) { return setValidationError("Cannot add the same input more than once"); } setChips((prevState) => [...prevState, text]); setText(""); setValidationError(""); } return (