feat: error messaging when attempting to create duplicate files or folders in local collections

This commit is contained in:
Anoop M D 2022-10-18 03:44:21 +05:30
parent e98f219448
commit eefef27dec
2 changed files with 15 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import React, { useRef, useEffect } from 'react';
import {useFormik} from 'formik';
import toast from 'react-hot-toast';
import * as Yup from 'yup';
import Modal from 'components/Modal';
import { useDispatch } from 'react-redux';
@ -21,7 +22,8 @@ const NewFolder = ({collection, item, onClose}) => {
}),
onSubmit: (values) => {
dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null))
onClose();
.then(() => onClose())
.catch(() => toast.error("An error occured while adding the request"));
}
});

View File

@ -1,6 +1,7 @@
import React, { useRef, useEffect } from 'react';
import { useFormik } from 'formik';
import * as Yup from 'yup';
import toast from 'react-hot-toast';
import { uuid } from 'utils/common';;
import Modal from 'components/Modal';
import { useDispatch } from 'react-redux';
@ -38,10 +39,14 @@ const NewRequest = ({collection, item, isEphermal, onClose}) => {
requestMethod: values.requestMethod,
collectionUid: collection.uid
}))
dispatch(addTab({
uid: uid,
collectionUid: collection.uid
}));
.then(() => {
dispatch(addTab({
uid: uid,
collectionUid: collection.uid
}));
onClose();
})
.catch(() => toast.error("An error occured while adding the request"));
} else {
dispatch(newHttpRequest({
requestName: values.requestName,
@ -50,9 +55,10 @@ const NewRequest = ({collection, item, isEphermal, onClose}) => {
requestMethod: values.requestMethod,
collectionUid: collection.uid,
itemUid: item ? item.uid : null
}));
}))
.then(() => onClose())
.catch(() => toast.error("An error occured while adding the request"));
}
onClose();
}
});