From 211b57981c9299a9cdcc110020e5b69b0ca24612 Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Tue, 27 Aug 2024 19:16:59 +0530 Subject: [PATCH] Issue #PS-000 feat: Bug fixes --- public/locales/en/common.json | 29 ++--- src/components/CohortFacilitatorList.tsx | 88 +++++++-------- src/components/CohortLearnerList.tsx | 87 +++++++-------- src/components/ConfirmationModal.tsx | 2 +- src/components/MenuDrawer.tsx | 2 +- src/components/PieChartGraph.tsx | 6 +- src/components/center/DeleteCenterModal.tsx | 93 ++-------------- src/components/center/RenameCenterModal.tsx | 44 ++++---- src/components/common/NoDataFound.tsx | 27 +++++ src/pages/board-enrollment/index.tsx | 4 +- src/pages/centers/[cohortId]/index.tsx | 116 ++++++++------------ 11 files changed, 206 insertions(+), 292 deletions(-) create mode 100644 src/components/common/NoDataFound.tsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 77b34f3e..8d94a99c 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -72,7 +72,7 @@ "SURE_LOGOUT": "Are you sure you want to Logout?", "SURE_UPDATE": "Are you sure you want to update this attendance?", "SURE_REMOVE": "Are you sure you want to remove this learner?", - "SURE_REASSIGN_CENTER": "Are you sure you want to re-assign Center to this user?", + "SURE_REASSIGN_CENTER": "Are you sure you want to re-assign center to this user?", "SURE_CLOSE": "Are you sure you want to close without saving?", "LEARNER_LIST": "Learners List", "FACILITATOR_LIST": "Facilitators List", @@ -94,7 +94,7 @@ "DROPPED_OUT": "Dropped Out", "DELETE_USER": "Delete User Permanently", "DELETE_USER_WITH_REASON": "Delete User", - "USER_DELETED_PERMANENTLY": "User Successfully Deleted!", + "USER_DELETED_PERMANENTLY": "User successfully deleted!", "OBSERVATIONS_FORMS": "Observations and Forms", "OTHER_REASON": "Other Reason", "OTHER_REASON_PLACEHOLDER": "Enter Other Reason", @@ -103,7 +103,7 @@ "CREDENTIALS_EMAILED": "The login credentials will be emailed to the Facilitator at ", "CREDENTIALS_EMAILED_OF_LEARNER": "The login credentials have been send to your email ", "NEW": "New {{role}}", - "USER_CREDENTIAL_SEND_SUCCESSFULLY": "User Credentials Sent Successfully!", + "USER_CREDENTIAL_SEND_SUCCESSFULLY": "User credentials sent successfully!", "CENTER_SESSIONS": "Center Sessions", "SCHEDULE_NEW": "Schedule New", "UPCOMING_EXTRA_SESSION": "Upcoming Extra Sessions (Next {{days}} days)", @@ -118,7 +118,7 @@ "NEW_FACILITATOR": "New Facilitator", "EDIT_FACILITATOR": "Edit Facilitator", "SUBMIT": "Submit", - "LEARNER_CREATED_SUCCESSFULLY": "Leaner has been Successfully Created!", + "LEARNER_CREATED_SUCCESSFULLY": "Leaner has been successfully created!", "FACILITATOR_ADDED_SUCCESSFULLY": "Facilitator added successfully!", "LEARNER_UPDATED_SUCCESSFULLY": "Learner profile updated successfully!", "FACILITATOR_UPDATED_SUCCESSFULLY": "Facilitator profile updated successfully!", @@ -319,14 +319,14 @@ "CENTER_TYPE": "Center Type", "UNIT_NAME": "Unit Name", "NOTE": "Note: This will be the center name", - "CENTER_CREATED": "Center Created Successfully!", + "CENTER_CREATED": "Center created successfully!", "RENAME_CENTER": "Rename Center", "REQUEST_TO_DELETE": "Request to Delete", "RENAME": "Rename", - "CENTER_RENAMED": "Center Renamed Successfully!", + "CENTER_RENAMED": "Center renamed successfully!", "SEND_REQUEST": "Send Request", "REQUEST_TO_DELETE_HAS_BEEN_SENT": "Request to Delete has been sent", - "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "You are sending a request to the State Admin to delete this Center", + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "You are sending a request to the State Admin to delete this center", "THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "The user belongs to the following cohort: ", "PLEASE_REMOVE_THE_USER_FROM_COHORT": "Please remove the user from these cohorts before proceeding with deletion.", "ERROR_EMPTY": "Center name cannot be empty", @@ -352,7 +352,7 @@ "DOUBT_CLEARING": "For doubt clearing, webinars, etc", "TOPIC": "Topic", "SUBTOPIC": "Sub Topic", - "FACILITATORS": " Facilitators Pre-requisites", + "FACILITATORS": "Facilitators Pre-requisites", "TITLE": "Title", "DELETE_SESSION": "Delete Session", "SCHEDULE": "Schedule", @@ -371,7 +371,7 @@ "EXTRA_OFFLINE": "Extra offline", "ENTER_VALID_MEETING_LINK": "Please enter a valid Zoom or Google Meet link.", "ZOOM": "Zoom", - "GOOGLEMEET": "GoogleMeet", + "GOOGLE_MEET": "GOOGLE_MEET", "SET_UP": "Set-Up", "EDIT_THIS_SESSION": "Edit this session", "EDIT_FOLLOWING_SESSIONS": "Edit this and following sessions", @@ -382,8 +382,8 @@ "UPDATE_CHANGES": "Are you sure you want to update the changes?" }, "MANAGE_USERS": { - "CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully", - "CENTERS_REQUEST_FAILED": "Center Requested Failed" + "CENTERS_REQUESTED_SUCCESSFULLY": "Center requested successfully", + "CENTERS_REQUEST_FAILED": "Center Request Failed" }, "FORM": { "FULL_NAME": "Full Name", @@ -408,7 +408,7 @@ "ENTER_YOUR_FATHER_NAME": "Enter Your Father Name", "CLASS_OR_LAST_PASSED_GRADE": "Class (Last passed grade)", "NO_SCHOOLING": "No Schooling", - "REASON_FOR_DROPOUT_FROM_SCHOOL": "Reason for Drop Out From School", + "REASON_FOR_DROPOUT_FROM_SCHOOL": "Reason for dropout from school", "SCHOOL_INACCESSIBLE": "School inaccessible", "FINANCIAL_CONSTRAINTS": "Financial Constraints", "LACK_OF_INTEREST": "Lack of Interest", @@ -483,7 +483,8 @@ "ENTER_VALID_EMAIL": "Enter valid Email", "ENTER_VALID_YEAR": "Enter valid Year", "MUST_BE_LESS_THAN": "{{fieldname}} must be less than {{maxLength}}", - "MUST_BE_GREATER_THAN": "{{fieldname}} must be greater than {{minLength}}" + "MUST_BE_GREATER_THAN": "{{fieldname}} must be greater than {{minLength}}", + "ENTER_VALID_CENTER_NAME": "Enter valid center name" }, "COURSE_PLANNER": { "COURSE_PLANNER": "Course Plan", @@ -512,7 +513,7 @@ "ASSESSMENT_NOT_STARTED_YET": "Assessment not started yet", "NUMBER_OUT_OF_COMPLETED": "{{completedCount}} out of {{totalCount}} completed" }, - "BOARD_ENROOLMENT": { + "BOARD_ENROLMENT": { "BOARD_ENROLLMENT": "Board Enrollment", "BOARD_SELECTION":"Board Selection", "SUBJECTS_SELECTION": "Subjects Selection", diff --git a/src/components/CohortFacilitatorList.tsx b/src/components/CohortFacilitatorList.tsx index ba45159c..3b04b9dd 100644 --- a/src/components/CohortFacilitatorList.tsx +++ b/src/components/CohortFacilitatorList.tsx @@ -1,20 +1,20 @@ -import React, { useEffect } from 'react'; +import LearnersList from '@/components/LearnersListItem'; import { - getMyCohortFacilitatorList, - getMyCohortMemberList, + getMyCohortFacilitatorList } from '@/services/MyClassDetailsService'; +import { Status, limit } from '@/utils/app.constant'; import { capitalizeEachWord, getFieldValue, toPascalCase, } from '@/utils/Helper'; -import LearnersList from '@/components/LearnersListItem'; -import { Status, limit } from '@/utils/app.constant'; -import { showToastMessage } from './Toastify'; +import { Box, Grid } from '@mui/material'; +import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import { Box, Grid, Typography } from '@mui/material'; +import React, { useEffect } from 'react'; +import NoDataFound from './common/NoDataFound'; import Loader from './Loader'; -import { useTheme } from '@mui/material/styles'; +import { showToastMessage } from './Toastify'; interface UserDataProps { name: string; @@ -88,7 +88,7 @@ const CohortLearnerList: React.FC = ({ getCohortMemberList(); }, [cohortId, reloadState]); - const onDelete = () => { }; + const onDelete = () => {}; console.log('userData', userData); const theme = useTheme(); @@ -97,50 +97,38 @@ const CohortLearnerList: React.FC = ({ {loading ? ( ) : ( - <> - - - {userData?.map((data: any) => { - return ( - - - - ); - })} - {!userData?.length && ( - - - {t('COMMON.NO_DATA_FOUND')} - - - )} - - - + }} + > + + {userData?.map((data: any) => { + return ( + + + + ); + })} + {!userData?.length && ( + + )} + + )} ); diff --git a/src/components/CohortLearnerList.tsx b/src/components/CohortLearnerList.tsx index 36893709..7d703283 100644 --- a/src/components/CohortLearnerList.tsx +++ b/src/components/CohortLearnerList.tsx @@ -1,18 +1,18 @@ -import React, { useEffect } from 'react'; +import LearnersListItem from '@/components/LearnersListItem'; import { getMyCohortMemberList } from '@/services/MyClassDetailsService'; +import { Role, Status, limit } from '@/utils/app.constant'; import { capitalizeEachWord, getFieldValue, toPascalCase, } from '@/utils/Helper'; -import LearnersListItem from '@/components/LearnersListItem'; -import { Role, Status, limit } from '@/utils/app.constant'; -import { showToastMessage } from './Toastify'; -import { useTranslation } from 'next-i18next'; import { Box, Grid, Typography } from '@mui/material'; -import Loader from './Loader'; import { useTheme } from '@mui/material/styles'; - +import { useTranslation } from 'next-i18next'; +import React, { useEffect } from 'react'; +import Loader from './Loader'; +import { showToastMessage } from './Toastify'; +import NoDataFound from './common/NoDataFound'; interface UserDataProps { name: string; @@ -99,53 +99,40 @@ const CohortLearnerList: React.FC = ({ {loading ? ( ) : ( - <> - - - - {userData?.map((data: any) => { - return ( - - - - ); - })} - {!userData?.length && ( - - - {t('COMMON.NO_DATA_FOUND')} - - - )} - - - + }} + > + + {userData?.map((data: any) => { + return ( + + + + ); + })} + {!userData?.length && ( + + )} + + )} ); diff --git a/src/components/ConfirmationModal.tsx b/src/components/ConfirmationModal.tsx index 10972715..943e08b0 100644 --- a/src/components/ConfirmationModal.tsx +++ b/src/components/ConfirmationModal.tsx @@ -57,7 +57,7 @@ const ConfirmationModal: React.FC = ({ = ({ router.push(`/board-enrollment`); }} > - {t('BOARD_ENROOLMENT.BOARD_ENROLLMENT')} + {t('BOARD_ENROLMENT.BOARD_ENROLLMENT')} diff --git a/src/components/PieChartGraph.tsx b/src/components/PieChartGraph.tsx index 2ffb5c3d..9d78ba98 100644 --- a/src/components/PieChartGraph.tsx +++ b/src/components/PieChartGraph.tsx @@ -14,9 +14,9 @@ const PieChartGraph = () => { const theme = useTheme(); const data: DataItem[] = [ { name: t('ASSESSMENTS.NOT_STARTED'), value: 4 }, - { name: t('BOARD_ENROOLMENT.BOARD_SELECTION'), value: 5 }, - { name: t('BOARD_ENROOLMENT.SUBJECTS_SELECTION'), value: 10 }, - { name: t('BOARD_ENROOLMENT.REGISTRATION_COMPLETED'), value: 5 }, + { name: t('BOARD_ENROLMENT.BOARD_SELECTION'), value: 5 }, + { name: t('BOARD_ENROLMENT.SUBJECTS_SELECTION'), value: 10 }, + { name: t('BOARD_ENROLMENT.REGISTRATION_COMPLETED'), value: 5 }, ]; diff --git a/src/components/center/DeleteCenterModal.tsx b/src/components/center/DeleteCenterModal.tsx index a90ae39c..4e97e9ef 100644 --- a/src/components/center/DeleteCenterModal.tsx +++ b/src/components/center/DeleteCenterModal.tsx @@ -1,15 +1,6 @@ -import { - Box, - Button, - Divider, - Fade, - Modal, - Radio, - Typography -} from '@mui/material'; -import { styled, useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; import React from 'react'; +import ConfirmationModal from '../ConfirmationModal'; import { showToastMessage } from '../Toastify'; interface CreateBlockModalProps { @@ -17,19 +8,11 @@ interface CreateBlockModalProps { handleClose: () => void; } -const CustomRadio = styled(Radio)(({ theme }) => ({ - color: theme.palette.text.primary, - '&.Mui-checked': { - color: theme.palette.text.primary, - }, -})); - const DeleteCenterModal: React.FC = ({ open, handleClose, }) => { const { t } = useTranslation(); - const theme = useTheme(); const handleDeleteButtonClick = () => { console.log('Delete request sent'); @@ -38,70 +21,16 @@ const DeleteCenterModal: React.FC = ({ }; return ( - - - - - {t('CENTERS.YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN')} - - - - - - - - - + handleDeleteButtonClick} + modalOpen={open} + /> ); }; diff --git a/src/components/center/RenameCenterModal.tsx b/src/components/center/RenameCenterModal.tsx index 1bab7ca9..c5c93b03 100644 --- a/src/components/center/RenameCenterModal.tsx +++ b/src/components/center/RenameCenterModal.tsx @@ -5,12 +5,13 @@ import { Button, Divider, Fade, + FormHelperText, IconButton, Modal, TextField, - Typography + Typography, } from '@mui/material'; -import { styled, useTheme } from '@mui/material/styles'; +import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; import { useRouter } from 'next/router'; import React, { useState } from 'react'; @@ -18,9 +19,10 @@ import { showToastMessage } from '../Toastify'; interface CreateBlockModalProps { open: boolean; - handleClose: () => void; + handleClose: (name: string) => void; reloadState: boolean; setReloadState: React.Dispatch>; + name?: string; } const RenameCenterModal: React.FC = ({ @@ -28,15 +30,16 @@ const RenameCenterModal: React.FC = ({ handleClose, reloadState, setReloadState, + name, }) => { const router = useRouter(); const { t } = useTranslation(); const theme = useTheme(); - const { cohortId }: any = router.query; + const [centerName, setCenterName] = useState(name ?? ''); + const [error, setError] = useState(false); - const [centerName, setCenterName] = useState(''); - const [error, setError] = useState(''); + const pattern = /^[a-zA-Z ]*$/; React.useEffect(() => { if (reloadState) { @@ -48,29 +51,26 @@ const RenameCenterModal: React.FC = ({ event: React.ChangeEvent ) => { const value = event.target.value; - setCenterName(value); - if (!value.trim()) { - setError(t('CENTERS.ERROR_EMPTY')); - } else if (!isNaN(Number(value))) { - setError(t('CENTERS.ERROR_NUMBER')); + console.log('value', event); + // Validate against the pattern + if (!pattern.test(value.trim())) { + setError(true); } else { - setError(''); + setError(false); } + setCenterName(value); }; const handleCreateButtonClick = async () => { if (error) return; console.log('Entered Rename Name:', centerName); - - const name = centerName; - - const response = await renameFacilitator(cohortId, name); + const name = centerName.trim(); + await renameFacilitator(cohortId, name); setReloadState(true); showToastMessage(t('CENTERS.CENTER_RENAMED'), 'success'); - - handleClose(); + handleClose(name); }; return ( @@ -117,6 +117,7 @@ const RenameCenterModal: React.FC = ({ = ({ value={centerName} onChange={handleTextFieldChange} error={!!error} - helperText={error} + inputProps={{ pattern: pattern }} /> {t('CENTERS.NOTE')} + {error && ( + + {t('FORM_ERROR_MESSAGES.ENTER_VALID_CENTER_NAME')} + + )} */} - - - {/* { - router.push('/attendance-overview'); - }} - > - {t('COMMON.REVIEW_ATTENDANCE')} - */} - {/* */} - - - - + + )}