From 137b1f91c5ec9eefbc0b810a40e05bf6903a2f9f Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 13 Aug 2024 16:47:28 +0530 Subject: [PATCH] Issue feat: pass email and role in language constant for send credential --- .env | 3 ++- public/locales/en/common.json | 11 +++++++---- src/components/CommonUserModal.tsx | 13 ++++++++++--- src/components/DynamicForm.tsx | 3 ++- src/components/SendCredentialModal.tsx | 17 +++-------------- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.env b/.env index da14627a..447177d3 100644 --- a/.env +++ b/.env @@ -1,6 +1,7 @@ # NEXT_PUBLIC_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/user/v1 NEXT_PUBLIC_BASE_URL=https://backend.prathamdigital.org/user/v1 NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com -NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/notification-service +NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://notification.prathamdigital.org +# NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/notification-service diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 2d722e4c..559cb4c8 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -95,10 +95,13 @@ "ALL_BLOCKS": "All Blocks", "SEND_CREDENTIALS": "Send Credentials", - "CREDENTIALS_EMAILED_OF_FACILITATOR": "The login credentials will be emailed to the Facilitator at ", - "CREDENTIALS_EMAILED_OF_TEAM_LEADER": "The login credentials will be emailed to the Team Leader at ", - "CREDENTIALS_EMAILED_OF_LEARNER": "The login credentials have been send to your email ", - "OKAY": "okay" + "CREDENTIALS_EMAILED_OF_FACILITATOR": "The login credentials will be emailed to the Facilitator at {{email}} ", + "CREDENTIALS_EMAILED_OF_TEAM_LEADER": "The login credentials will be emailed to the Team Leader at {{email}}", + "CREDENTIALS_EMAILED_OF_LEARNER": "The login credentials have been send to your email ", + "OKAY":"okay", + "NEW": "New {{role}}" + + }, "LOGIN_PAGE": { "USERNAME": "Username", diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index 0c9f1a3b..f49f4911 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -25,6 +25,7 @@ import AreaSelection from "./AreaSelection"; import { showToastMessage } from "./Toastify"; import SendCredentialModal from './SendCredentialModal'; import { sendCredentialService } from "@/services/NotificationService"; +import { useQuery } from "@tanstack/react-query"; interface UserModalProps { open: boolean; @@ -57,7 +58,9 @@ const CommonUserModal: React.FC = ({ const adminInformation = useSubmittedButtonStore( (state: any) => state?.adminInformation ); - + const submittedButtonStatus = useSubmittedButtonStore( + (state: any) => state.submittedButtonStatus + ); const [createFacilitator, setCreateFacilitator] = React.useState(false); const setSubmittedButtonStatus = useSubmittedButtonStore( (state: any) => state.setSubmittedButtonStatus @@ -452,9 +455,13 @@ const CommonUserModal: React.FC = ({ color="primary" disabled={!submitButtonEnable} onClick={() => { - if(userType!==FormContextType.STUDENT && !isEditModal) - setOpenModal(true) + setSubmittedButtonStatus(true); + if(userType!==FormContextType.STUDENT && !isEditModal && submittedButtonStatus) + { + setOpenModal(true) + + } console.log("Submit button was clicked"); }} > diff --git a/src/components/DynamicForm.tsx b/src/components/DynamicForm.tsx index 38e6542f..28cdf507 100644 --- a/src/components/DynamicForm.tsx +++ b/src/components/DynamicForm.tsx @@ -62,7 +62,7 @@ const DynamicForm: React.FC = ({ }; const handleError = (errors: any) => { - console.log("handle error1", errors); + console.log("handle error1"); if (errors.length > 0) { const property = errors[0].property?.replace(/^root\./, ""); const errorField = document.querySelector( @@ -120,6 +120,7 @@ const DynamicForm: React.FC = ({ return errors?.map((error: any) => { switch (error.name) { case "required": { + console.log(submittedButtonStatus) error.message = submittedButtonStatus ? t("FORM_ERROR_MESSAGES.THIS_IS_REQUIRED_FIELD") : ""; diff --git a/src/components/SendCredentialModal.tsx b/src/components/SendCredentialModal.tsx index 0c3f2819..d7b83a95 100644 --- a/src/components/SendCredentialModal.tsx +++ b/src/components/SendCredentialModal.tsx @@ -69,7 +69,7 @@ const SendCredentialModal: React.FC = ({ }} component="h2" > - {t('COMMON.NEW', { role: 'Learner' })} + {t('COMMON.NEW', { role: userType })} = ({ > {userType===FormContextType.STUDENT ? t('COMMON.CREDENTIALS_EMAILED_OF_LEARNER') - : userType===FormContextType.TEAM_LEADER?t('COMMON.CREDENTIALS_EMAILED_OF_TEAM_LEADER'): t('COMMON.CREDENTIALS_EMAILED_OF_FACILITATOR')} - - - - - {email} + : userType===FormContextType.TEAM_LEADER?t('COMMON.CREDENTIALS_EMAILED_OF_TEAM_LEADER', {email}): t('COMMON.CREDENTIALS_EMAILED_OF_FACILITATOR', {email})} + <>