diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx
index 959559ad5..7a30f9ff3 100644
--- a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx
+++ b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx
@@ -32,7 +32,8 @@ import {
TypeKeys,
ReadonlyInputType,
} from '../types';
-import { ethers } from "ethers";
+import { MdError } from 'react-icons/md';
+import useToast from '../reusables/NewToast';
import { tokenFetchHandler } from '../helpers/tokenHelpers';
@@ -78,6 +79,7 @@ const AddCriteria = ({
});
const { env } = useChatData();
const theme = useContext(ThemeContext);
+ const groupInfoToast = useToast()
const isMobile = useMediaQuery(device.mobileL);
@@ -374,7 +376,11 @@ const AddCriteria = ({
if (Object.keys(errors).length) {
setValidationErrors(errors);
} else {
- criteriaState.addNewRule(rule);
+ const isSuccess = criteriaState.addNewRule(rule);
+ if(!isSuccess){
+ showError("Selected Criteria was already added")
+ return
+ }
if (handlePrevious) {
handlePrevious();
}
@@ -495,6 +501,15 @@ const AddCriteria = ({
})()
},[contract,selectedCategoryValue,selectedChainValue])
+ const showError = (errorMessage: string) => {
+ groupInfoToast.showMessageToast({
+ toastTitle: 'Error',
+ toastMessage: errorMessage,
+ toastType: 'ERROR',
+ getToastIcon: (size) => ,
+ });
+ };
+
return (
>;
addNewCondtion: () => void;
- addNewRule: (newRule: Rule) => void;
+ addNewRule: (newRule: Rule) => boolean;
deleteRule: (idx: number) => void;
deleteEntryOptionsDataArray: (idx: number) => void;
selectEntryOptionsDataArrayForUpdate: (idx: number) => void;
diff --git a/packages/uiweb/src/lib/hooks/chat/useCriteriaState.ts b/packages/uiweb/src/lib/hooks/chat/useCriteriaState.ts
index e677f4251..1a31b8e82 100644
--- a/packages/uiweb/src/lib/hooks/chat/useCriteriaState.ts
+++ b/packages/uiweb/src/lib/hooks/chat/useCriteriaState.ts
@@ -30,7 +30,40 @@ export const useCriteriaState = (
useState(-1);
const [updateCriteriaIdx, setUpdateCriteriaIdx] = useState(-1);
+
+ const isDuplicateRule = (rule:Rule)=>{
+ const newRule = JSON.stringify(rule)
+
+ // check on current conditions
+ for(let i=0; i {
+ if(isDuplicateRule(newRule)){
+ return false
+ }
+
if (selectedCriteria === -1) {
setSelectedCriteria(entryOptionTypeArray.length);
}
@@ -44,6 +77,8 @@ export const useCriteriaState = (
// add new
setSelectedRule((prev) => [...prev, newRule]);
}
+
+ return true
};
const deleteRule = (idx: number) => {