Skip to content

Commit

Permalink
Merge pull request #411 from Aar-if/modern
Browse files Browse the repository at this point in the history
Issue #000 Bug:  Course Planner Fixes and improvements
  • Loading branch information
itsvick authored Nov 23, 2024
2 parents 267b2bb + 283e0b7 commit 429f695
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
9 changes: 9 additions & 0 deletions src/components/ManageCentersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ const ManageCentersModal: React.FC<ManageUsersModalProps> = ({
},
};

React.useEffect(() => {
if (typeof window !== 'undefined') {
const classData: string | null = localStorage.getItem('className');
if (classData) {
setSelectedValue(classData);
}
}
}, []);

React.useEffect(() => {
if (centers) {
setCheckedCenters(centers?.map((center) => center?.name));
Expand Down
1 change: 1 addition & 0 deletions src/components/center/centerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const CenterList: React.FC<CenterListProps> = ({
onClick={() => {
router.push(`/centers/${center?.cohortId}`);
localStorage.setItem('classId', center?.cohortId);
localStorage.setItem('className', center?.cohortName);
}}
sx={{
cursor: 'pointer',
Expand Down
24 changes: 11 additions & 13 deletions src/pages/course-planner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
filterAndMapAssociationsNew,
findCommonAssociations,
getAssociationsByCodeNew,
getOptionsByCategory
getOptionsByCategory,
} from '@/utils/Helper';
import withAccessControl from '@/utils/hoc/withAccessControl';
import { CoursePlannerData, ICohort } from '@/utils/Interfaces';
Expand All @@ -22,6 +22,7 @@ import {
InputLabel,
MenuItem,
Select,
SelectChangeEvent,
Typography,
} from '@mui/material';
import { useTheme } from '@mui/material/styles';
Expand Down Expand Up @@ -73,12 +74,15 @@ const CoursePlanner = () => {
const [manipulatedCohortData, setManipulatedCohortData] =
useState<Array<ICohort>>(cohortsData);

const handleChange = (event: any) => {
setValue(event.target.value);
setType(event.target.value);
const handleChange = (event: SelectChangeEvent<string>) => {
const newValue = event.target.value as string;
if (newValue !== value) {
setValue(newValue);
setType(newValue);
}
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const env = cleanedUrl.split('/')[0];

const telemetryInteract = {
context: {
Expand Down Expand Up @@ -111,11 +115,6 @@ const CoursePlanner = () => {
);
};

const handleCohortChange = (event: any) => {
setSelectedValue(event.target.value);
addQueryParams({ center: event.target.value });
};

useEffect(() => {
if (classId) {
setSelectedValue(classId);
Expand Down Expand Up @@ -507,7 +506,7 @@ const CoursePlanner = () => {
};

fetchTaxonomyResults();
}, [value, selectedValue]);
}, [value, subjects]);

const isStateEmpty = !tStore.state;
const isBoardEmpty = !tStore.board;
Expand Down Expand Up @@ -658,8 +657,7 @@ const CoursePlanner = () => {
position: 'relative',
display: 'inline-flex',
}}
>
</Box>
></Box>

<Box
sx={{
Expand Down

0 comments on commit 429f695

Please sign in to comment.