From 395fe77050ed39e954bba18ff351457395905360 Mon Sep 17 00:00:00 2001 From: dhuruvandb Date: Mon, 16 Dec 2024 17:18:35 +0530 Subject: [PATCH] fix: resolve validation issue #1202 --- backend/.env | 2 +- frontend/.env | 2 +- .../ProfileModule/components/ProfileAdminForm.jsx | 8 ++++++++ .../modules/ProfileModule/components/UpdateAdmin.jsx | 11 +++++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/.env b/backend/.env index 360866b0c..29c3113cc 100644 --- a/backend/.env +++ b/backend/.env @@ -1,4 +1,4 @@ -#DATABASE = "mongodb://localhost:27017" +DATABASE = "mongodb+srv://dbdhuruvan2000:WRo9w1j1UrChlzGx@baskardb.tbukgja.mongodb.net/idurar-erp-crm?retryWrites=true&w=majority" #RESEND_API = "your resend_api" #OPENAI_API_KEY = "your open_ai api key" JWT_SECRET= "your_private_jwt_secret_key" diff --git a/frontend/.env b/frontend/.env index e179ff244..b1d37e821 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,5 +1,5 @@ # ----> Remove # comment VITE_FILE_BASE_URL = 'http://localhost:8888/' -VITE_BACKEND_SERVER="http://your_backend_url_server.com/" +VITE_BACKEND_SERVER="http://localhost:8888/" PROD = false \ No newline at end of file diff --git a/frontend/src/modules/ProfileModule/components/ProfileAdminForm.jsx b/frontend/src/modules/ProfileModule/components/ProfileAdminForm.jsx index 78fc327ff..8de37c540 100644 --- a/frontend/src/modules/ProfileModule/components/ProfileAdminForm.jsx +++ b/frontend/src/modules/ProfileModule/components/ProfileAdminForm.jsx @@ -27,6 +27,10 @@ export default function AdminForm({ isUpdateForm = false }) { { required: true, }, + { + pattern: /^[A-Za-z][A-Za-z'-]+$/, + message: 'Please enter a valid First Name', + } ]} > @@ -38,6 +42,10 @@ export default function AdminForm({ isUpdateForm = false }) { { required: true, }, + { + pattern: /^[A-Za-z][A-Za-z'-]+$/, + message: 'Please enter a valid Last Name', + } ]} > diff --git a/frontend/src/modules/ProfileModule/components/UpdateAdmin.jsx b/frontend/src/modules/ProfileModule/components/UpdateAdmin.jsx index d59e1e147..20134d897 100644 --- a/frontend/src/modules/ProfileModule/components/UpdateAdmin.jsx +++ b/frontend/src/modules/ProfileModule/components/UpdateAdmin.jsx @@ -29,7 +29,15 @@ const UpdateAdmin = ({ config }) => { }, [currentAdmin]); const handleSubmit = () => { - form.submit(); + form + .validateFields() + .then((values) => { + onSubmit(values); + updatePanel.close(); + }) + .catch((errorInfo) => { + console.log('Form validation failed:', errorInfo); + }); }; const onSubmit = (fieldsValue) => { @@ -58,7 +66,6 @@ const UpdateAdmin = ({ config }) => { key={`${uniqueId()}`} onClick={() => { handleSubmit(); - updatePanel.close(); }} type="primary" icon={}