From 3730880ceca6aa9fac8ffea59b4456cbcfe68e5f Mon Sep 17 00:00:00 2001 From: Nikunj Maniya Date: Tue, 24 Sep 2024 10:31:53 +0530 Subject: [PATCH] fix: Search Email Regex move into Patterns file --- src/components/shared/frame/UserList/index.tsx | 3 ++- src/types/Patterns.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/shared/frame/UserList/index.tsx b/src/components/shared/frame/UserList/index.tsx index 6f204e8c8..31e567e3b 100644 --- a/src/components/shared/frame/UserList/index.tsx +++ b/src/components/shared/frame/UserList/index.tsx @@ -33,6 +33,7 @@ import type { TenantUser } from 'features/admin/userApiSlice' import './style.scss' import { setSearchInput } from 'features/appManagement/actions' import { appManagementSelector } from 'features/appManagement/slice' +import Patterns from 'types/Patterns' interface FetchHookArgsType { appId?: string @@ -87,7 +88,7 @@ export const UserList = ({ const searchInputData = useSelector(appManagementSelector) const validateSearchText = (expr: string) => { - const validateExpr = /^[ A-Za-z0-9._!@+-]*$/.test(expr) + const validateExpr = Patterns.EMAIL_SEARCH.test(expr) if (validateExpr) dispatch(setSearchInput({ open: true, text: expr })) return validateExpr } diff --git a/src/types/Patterns.ts b/src/types/Patterns.ts index 0aca2433d..9191d27f6 100644 --- a/src/types/Patterns.ts +++ b/src/types/Patterns.ts @@ -120,6 +120,7 @@ export const Patterns = { POSTAL_CODE: /^(?!.*\s$)(?=[a-zA-Z\d-]{0,10}[-\s]?[a-zA-Z\d-]{0,10}$)[a-zA-Z\d\s-]{2,10}$/, }, + EMAIL_SEARCH: /^[ A-Za-z0-9._!@+-]*$/, } export const isEmpty = (expr: string) => !expr || expr.trim() === ''