Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' of github.com:tekdi/teachers-app into re…
Browse files Browse the repository at this point in the history
…lease-1.0.0
  • Loading branch information
itsvick committed Nov 11, 2024
2 parents e6ea277 + a6f91c8 commit 0eccc88
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
49 changes: 24 additions & 25 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
26 changes: 6 additions & 20 deletions src/components/AllowNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
};

Expand Down
20 changes: 16 additions & 4 deletions src/components/MenuDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({
const isDesktop = useMediaQuery(theme.breakpoints.up('md'));
const [isOpen, setIsOpen] = useState(open);
const [academicYearList, setAcademicYearList] = useState<AcademicYear[]>([]);
const [modifiedAcademicYearList, setModifiedAcademicYearList] = useState<AcademicYear[]>([]);
const [selectedSessionId, setSelectedSessionId] = useState<string>('');

const { i18n, t } = useTranslation();
Expand All @@ -66,10 +67,21 @@ const MenuDrawer: React.FC<DrawerProps> = ({
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([]);
Expand Down Expand Up @@ -237,7 +249,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({
},
}}
>
{academicYearList.map(({ id, session }) => (
{modifiedAcademicYearList?.map(({ id, session }) => (
<MenuItem key={id} value={id}>
{session}
</MenuItem>
Expand Down
7 changes: 5 additions & 2 deletions src/components/center/CreateCenterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ const CreateCenterModal: React.FC<CreateBlockModalProps> = ({
).values()
);
const cohortData = await createCohort(cohortDetails);
if (cohortData) {
if (cohortData.hasOwnProperty('cohortId')) {
showToastMessage(t('CENTERS.CENTER_CREATED'), 'success');
const telemetryInteract = {
context: {
env: 'teaching-center',
cdata: [],
},
edata: {
id:'create-center-successfully',
id: 'create-center-successfully',
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
Expand All @@ -168,6 +168,9 @@ const CreateCenterModal: React.FC<CreateBlockModalProps> = ({
onCenterAdded();
handleClose();
localStorage.removeItem('BMGSData');
} else {
showToastMessage(t('CENTERS.DUPLICATE_CENTER'), 'error');
handleClose();
}
}
};
Expand Down

0 comments on commit 0eccc88

Please sign in to comment.