import React from 'react'; import {useFormik} from 'formik'; import * as Yup from 'yup'; import Modal from '../../Modal'; const CreateCollection = ({handleConfirm, handleCancel, actions, dispatch}) => { const formik = useFormik({ enableReinitialize: true, initialValues: { collectionName: '' }, validationSchema: Yup.object({ collectionName: Yup.string() .min(3, 'must be atleast 3 characters') .max(50, 'must be 50 characters or less') .required('name is required') }), onSubmit: (values) => { handleConfirm(values); } }); const onSubmit = () => formik.handleSubmit(); return (
{formik.touched.collectionName && formik.errors.collectionName ? (
{formik.errors.collectionName}
) : null}
); }; export default CreateCollection;