diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 71f1217b..0e44afec 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -137,8 +137,9 @@ "AND_COUNT_MORE": "and {{count}} more", "RETURN_TO_LOGIN": "Return to Login", "NO_CENTER_FOUND": "No Center found", - "FILTER_BY":"Filter By", - "ALL":"All" + "FILTER_BY": "Filter By", + "ALL": "All", + "ACTIVE": "Active" }, "LOGIN_PAGE": { "USERNAME": "Username", @@ -359,6 +360,7 @@ "UNIT_NAME": "Unit Name", "NOTE": "Note: This will be the center name", "CENTER_CREATED": "Center created successfully!", + "DUPLICATE_CENTER": "Cohort already exists", "RENAME_CENTER": "Rename Center", "REQUEST_TO_DELETE": "Request to Delete", "RENAME": "Rename", @@ -590,27 +592,24 @@ }, "OBSERVATION": { "OBSERVATION_START": "Start Observation", - "OBSERVATION_DETAILS":"Observation Details", - "ADD_ENTITY":"Add {{entityType}} in observation list", - "SEARCH_ENTITY":"Search {{entityType}} name", - "OBSERVATIONS":"{{name}} Observations", - "SEARCH_OBSERVATIONS":"Search Observations", - "CONTINUE":"Continue", - "SUBMITTED":"Submitted", - "FORM_SAVED_SUCCESSFULLY":"Form changes saved successfully", - "FORM_SUBMIT_SUCCESSFULLY":"Form submitted successfully", - "NOT_STARTED":"Not Started", - "COMPLETED":"Completed", - "INPROGRESS":"In-Progress", - "NO_DATA_FOUND":"No {{entity}} found", - "NO_RESULT_FOUND":"No Observations found for {{entity}}", - "NO_OBSERVATION_EXPIRED":"No observation expired for {{entity}}", - "DAYS_LEFT":"Days left", - "THIS_OBSERVATION_EXPIRED":"This observation is expired", - "DUE_DATE":"Due date", - "SURVEY_FORMS":"Survey forms" - - -} - + "OBSERVATION_DETAILS": "Observation Details", + "ADD_ENTITY": "Add {{entityType}} in observation list", + "SEARCH_ENTITY": "Search {{entityType}} name", + "OBSERVATIONS": "{{name}} Observations", + "SEARCH_OBSERVATIONS": "Search Observations", + "CONTINUE": "Continue", + "SUBMITTED": "Submitted", + "FORM_SAVED_SUCCESSFULLY": "Form changes saved successfully", + "FORM_SUBMIT_SUCCESSFULLY": "Form submitted successfully", + "NOT_STARTED": "Not Started", + "COMPLETED": "Completed", + "INPROGRESS": "In-Progress", + "NO_DATA_FOUND": "No {{entity}} found", + "NO_RESULT_FOUND": "No Observations found for {{entity}}", + "NO_OBSERVATION_EXPIRED": "No observation expired for {{entity}}", + "DAYS_LEFT": "Days left", + "THIS_OBSERVATION_EXPIRED": "This observation is expired", + "DUE_DATE": "Due date", + "SURVEY_FORMS": "Survey Forms" + } } diff --git a/src/components/AllowNotification.tsx b/src/components/AllowNotification.tsx index 5c1da1e8..c4e4831e 100644 --- a/src/components/AllowNotification.tsx +++ b/src/components/AllowNotification.tsx @@ -11,6 +11,12 @@ const AllowNotification = () => { useEffect(() => { const handlePermissionChange = () => { setPermissionStatus(Notification.permission); + + // Automatically remove deviceID if permission is reset to default + if (Notification.permission === 'default') { + localStorage.removeItem('deviceID'); + console.log('Notification permission reset and deviceID removed'); + } }; navigator.permissions @@ -72,26 +78,6 @@ const AllowNotification = () => { fetchToken(); }, [permissionStatus]); - useEffect(() => { - const handlePermissionChange = () => { - setPermissionStatus(Notification.permission); - }; - - navigator.permissions - .query({ name: 'notifications' }) - .then((permission) => { - permission.addEventListener('change', handlePermissionChange); - }); - - return () => { - navigator.permissions - .query({ name: 'notifications' }) - .then((permission) => { - permission.removeEventListener('change', handlePermissionChange); - }); - }; - }, []); - return null; }; diff --git a/src/components/MenuDrawer.tsx b/src/components/MenuDrawer.tsx index f5eededa..32318955 100644 --- a/src/components/MenuDrawer.tsx +++ b/src/components/MenuDrawer.tsx @@ -48,6 +48,7 @@ const MenuDrawer: React.FC = ({ const isDesktop = useMediaQuery(theme.breakpoints.up('md')); const [isOpen, setIsOpen] = useState(open); const [academicYearList, setAcademicYearList] = useState([]); + const [modifiedAcademicYearList, setModifiedAcademicYearList] = useState([]); const [selectedSessionId, setSelectedSessionId] = useState(''); const { i18n, t } = useTranslation(); @@ -66,10 +67,21 @@ const MenuDrawer: React.FC = ({ if (typeof window !== 'undefined' && window.localStorage) { const storedList = localStorage.getItem('academicYearList'); try { - setAcademicYearList(storedList ? JSON.parse(storedList) : []); + const parsedList = storedList ? JSON.parse(storedList) : []; + setAcademicYearList(parsedList); + + const modifiedList = parsedList?.map((item: { isActive: any; session: any; }) => { + if (item.isActive) { + return { ...item, session: `${item.session} (${t('COMMON.ACTIVE')})` }; + } + return item; + }); + + setModifiedAcademicYearList(modifiedList); + const selectedAcademicYearId = localStorage.getItem('academicYearId'); - setSelectedSessionId(selectedAcademicYearId ?? ''); - console.log('Retrieved academicYearList:', academicYearList); + setSelectedSessionId(selectedAcademicYearId ?? ''); + console.log('Retrieved academicYearList:', parsedList); } catch (error) { console.error('Error parsing stored academic year list:', error); setAcademicYearList([]); @@ -237,7 +249,7 @@ const MenuDrawer: React.FC = ({ }, }} > - {academicYearList.map(({ id, session }) => ( + {modifiedAcademicYearList?.map(({ id, session }) => ( {session} diff --git a/src/components/center/CreateCenterModal.tsx b/src/components/center/CreateCenterModal.tsx index 45da03c1..f637504a 100644 --- a/src/components/center/CreateCenterModal.tsx +++ b/src/components/center/CreateCenterModal.tsx @@ -149,7 +149,7 @@ const CreateCenterModal: React.FC = ({ ).values() ); const cohortData = await createCohort(cohortDetails); - if (cohortData) { + if (cohortData.hasOwnProperty('cohortId')) { showToastMessage(t('CENTERS.CENTER_CREATED'), 'success'); const telemetryInteract = { context: { @@ -157,7 +157,7 @@ const CreateCenterModal: React.FC = ({ cdata: [], }, edata: { - id:'create-center-successfully', + id: 'create-center-successfully', type: Telemetry.CLICK, subtype: '', pageid: 'centers', @@ -168,6 +168,9 @@ const CreateCenterModal: React.FC = ({ onCenterAdded(); handleClose(); localStorage.removeItem('BMGSData'); + } else { + showToastMessage(t('CENTERS.DUPLICATE_CENTER'), 'error'); + handleClose(); } } };