diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 2b2e3a5e..a31fbf9c 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -95,6 +95,11 @@ "OBSERVATIONS_FORMS": "Observations and Forms", "OTHER_REASON": "Other Reason", "OTHER_REASON_PLACEHOLDER": "Enter Other Reason", + "BACK": "Back", + "SEND_CREDENTIALS": "Send Credentials", + "CREDENTIALS_EMAILED": "The login credentials will be emailed to the user at", + "NEW": "New {{role}}", + "USER_CREDENTIAL_SEND_SUCCESSFULLY": "User Credentials Sent Successfully!", "CENTER_SESSIONS": "Center Sessions", "SCHEDULE_NEW": "Schedule New", "UPCOMING_EXTRA_SESSION": "Upcoming Extra Sessions", diff --git a/src/components/SendCredentialModal.tsx b/src/components/SendCredentialModal.tsx new file mode 100644 index 00000000..5e3e6d95 --- /dev/null +++ b/src/components/SendCredentialModal.tsx @@ -0,0 +1,111 @@ +import { Box, Button, Divider, Modal, Typography } from '@mui/material'; +import React, { useState } from 'react'; +import { useTheme } from '@mui/material/styles'; +import { useTranslation } from 'next-i18next'; +import CloseIcon from '@mui/icons-material/Close'; +import { showToastMessage } from './Toastify'; + +interface SendCredentialModalProps { + open: boolean; + onClose: () => void; +} +const SendCredentialModal: React.FC = ({ + open, + onClose, +}) => { + const { t } = useTranslation(); + const theme = useTheme(); + const style = { + position: 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '65%', + boxShadow: 24, + bgcolor: '#fff', + borderRadius: '16px', + '@media (min-width: 600px)': { + width: '450px', + }, + }; + + const handleAction = () => { + onClose(); + showToastMessage(t('COMMON.USER_CREDENTIAL_SEND_SUCCESSFULLY'), 'success'); + }; + + return ( + + + + + + {t('COMMON.NEW', { role: 'Learner' })} + + + + + + {/* {isButtonAbsent ? ( */} + + + {t('COMMON.CREDENTIALS_EMAILED')} + + user's email + + <> + + + + + + + + + + + ); +}; + +export default SendCredentialModal; diff --git a/src/pages/addLearner.tsx b/src/pages/addLearner.tsx index 054b48cf..3355a6e6 100644 --- a/src/pages/addLearner.tsx +++ b/src/pages/addLearner.tsx @@ -1,16 +1,22 @@ import DynamicForm from '@/components/DynamicForm'; import React from 'react'; import { schema, uiSchema } from '@/utils/schema'; +// import { schema, uiSchema } from '@/components/GeneratedSchemas'; import { IChangeEvent } from '@rjsf/core'; import ISubmitEvent from '@rjsf/core'; import { Box } from '@mui/material'; import { RJSFSchema } from '@rjsf/utils'; +import SendCredentialModal from '@/components/SendCredentialModal'; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; const addLearner = () => { + const [openModal, setOpenModal] = React.useState(false); + const handleSubmit = ( data: IChangeEvent, event: React.FormEvent ) => { + setOpenModal(true); const target = event.target as HTMLFormElement; const elementsArray = Array.from(target.elements); @@ -37,6 +43,10 @@ const addLearner = () => { console.log('Form errors:', errors); }; + const handleCloseModal = () => { + setOpenModal(false); + }; + return ( { widgets={{}} showErrorList={true} /> + + ); }; +export async function getStaticProps({ locale }: any) { + return { + props: { + ...(await serverSideTranslations(locale, ['common'])), + // Will be passed to the page component as props + }, + }; +} export default addLearner;