Merge pull request #255 from Its-treason/bugfix/create-collection-modal-validation

Bugfix: Create collection modal validation
This commit is contained in:
Anoop M D 2023-09-30 01:53:32 +05:30 committed by GitHub
commit a849e4fb7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,9 @@ const CreateCollection = ({ onClose }) => {
.min(1, 'must be atleast 1 characters')
.max(50, 'must be 50 characters or less')
.required('folder name is required'),
collectionLocation: Yup.string().required('location is required')
collectionLocation: Yup.string()
.min(1, 'location is required')
.required('location is required')
}),
onSubmit: (values) => {
dispatch(createCollection(values.collectionName, values.collectionFolderName, values.collectionLocation))
@ -43,7 +45,10 @@ const CreateCollection = ({ onClose }) => {
const browse = () => {
dispatch(browseDirectory())
.then((dirPath) => {
formik.setFieldValue('collectionLocation', dirPath);
// When the user closes the diolog without selecting anything dirPath will be false
if (typeof dirPath === 'string') {
formik.setFieldValue('collectionLocation', dirPath);
}
})
.catch((error) => {
formik.setFieldValue('collectionLocation', '');