Skip to content

Commit

Permalink
Merge pull request #132 from AkshataKatwal16/admin
Browse files Browse the repository at this point in the history
Issue feat: pass email and role in language constant for send credential
  • Loading branch information
itsvick authored Aug 13, 2024
2 parents 1bdaabb + 137b1f9 commit d857d5b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -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


11 changes: 7 additions & 4 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 10 additions & 3 deletions src/components/CommonUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +58,9 @@ const CommonUserModal: React.FC<UserModalProps> = ({
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
Expand Down Expand Up @@ -452,9 +455,13 @@ const CommonUserModal: React.FC<UserModalProps> = ({
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");
}}
>
Expand Down
3 changes: 2 additions & 1 deletion src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
};

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(
Expand Down Expand Up @@ -120,6 +120,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
return errors?.map((error: any) => {
switch (error.name) {
case "required": {
console.log(submittedButtonStatus)
error.message = submittedButtonStatus
? t("FORM_ERROR_MESSAGES.THIS_IS_REQUIRED_FIELD")
: "";
Expand Down
17 changes: 3 additions & 14 deletions src/components/SendCredentialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const SendCredentialModal: React.FC<SendCredentialModalProps> = ({
}}
component="h2"
>
{t('COMMON.NEW', { role: 'Learner' })}
{t('COMMON.NEW', { role: userType })}
</Typography>
</Box>
<CloseIcon
Expand Down Expand Up @@ -104,21 +104,10 @@ const SendCredentialModal: React.FC<SendCredentialModalProps> = ({
>
{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')}
</Typography>
</Box>
<Box sx={{ padding: '0 1rem' }}>
<Typography
variant="h2"
sx={{
color: theme.palette.warning['400'],
fontSize: '14px',
}}
component="h2"
>
{email}
: userType===FormContextType.TEAM_LEADER?t('COMMON.CREDENTIALS_EMAILED_OF_TEAM_LEADER', {email}): t('COMMON.CREDENTIALS_EMAILED_OF_FACILITATOR', {email})}
</Typography>
</Box>

</Box>

<>
Expand Down

0 comments on commit d857d5b

Please sign in to comment.