import { useFormikContext } from 'formik'
import { InitialValuesProductType } from '../../formUtil'
import { MdOutlineDeleteOutline } from 'react-icons/md'

const DeleteIcon = ({index}:{index:number}) => {  
    const {values,setFieldValue} = useFormikContext<InitialValuesProductType>()

     const handleClick = ()=>{   
      
      const newData = values?.variant?.filter((_, i: number) => i !== index); 
        setFieldValue("variant", newData)
        
        }

  return (
    <MdOutlineDeleteOutline size={20} onClick={()=> handleClick()}/>

  )
}

export default DeleteIcon