Bugfix- Import blank directory Exception (#2845)

* typofix: Loc is required

* handle empty dirpath on import collection

* fix: collection import bug fix

---------

Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
Pragadesh-45 2024-08-16 17:49:00 +05:30 committed by GitHub
parent f0b7bf3430
commit b872fdfe6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -115,7 +115,7 @@ const ImportCollectionLocation = ({ onClose, handleSubmit, collectionName, trans
collectionLocation: Yup.string()
.min(1, 'must be at least 1 character')
.max(500, 'must be 500 characters or less')
.required('name is required')
.required('Location is required')
}),
onSubmit: (values) => {
handleSubmit(values.collectionLocation);
@ -124,7 +124,9 @@ const ImportCollectionLocation = ({ onClose, handleSubmit, collectionName, trans
const browse = () => {
dispatch(browseDirectory())
.then((dirPath) => {
formik.setFieldValue('collectionLocation', dirPath);
if (typeof dirPath === 'string' && dirPath.length > 0) {
formik.setFieldValue('collectionLocation', dirPath);
}
})
.catch((error) => {
formik.setFieldValue('collectionLocation', '');