2022-03-07 13:44:49 +01:00
|
|
|
import React from 'react';
|
2022-01-18 19:55:08 +01:00
|
|
|
import {useFormik} from 'formik';
|
|
|
|
import * as Yup from 'yup';
|
2022-01-13 18:57:27 +01:00
|
|
|
import Modal from '../../Modal';
|
|
|
|
|
|
|
|
const CreateCollection = ({handleConfirm, handleCancel, actions, dispatch}) => {
|
2022-01-18 19:55:08 +01:00
|
|
|
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();
|
|
|
|
|
2022-01-13 18:57:27 +01:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
size="sm"
|
|
|
|
title='Create Collection'
|
2022-01-18 19:55:08 +01:00
|
|
|
handleConfirm={onSubmit}
|
2022-01-13 18:57:27 +01:00
|
|
|
handleCancel={handleCancel}
|
|
|
|
>
|
2022-01-18 19:55:08 +01:00
|
|
|
<form className="grafnode-form" onSubmit={formik.handleSubmit}>
|
|
|
|
<div>
|
|
|
|
<label htmlFor="collectionName" className="block font-semibold">Name</label>
|
|
|
|
<input
|
|
|
|
id="collection-name" type="text" name="collectionName"
|
|
|
|
className="block textbox mt-2 w-full"
|
|
|
|
onChange={formik.handleChange}
|
|
|
|
value={formik.values.collectionName || ''}
|
|
|
|
/>
|
|
|
|
{formik.touched.collectionName && formik.errors.collectionName ? (
|
|
|
|
<div className="text-red-500">{formik.errors.collectionName}</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
2022-01-13 18:57:27 +01:00
|
|
|
</form>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CreateCollection;
|