Skip to content

Commit

Permalink
Merge pull request #455 from Aar-if/eighty
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 28, 2024
2 parents 699ffdb + 5e2b898 commit 77e77f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/pages/course-planner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const CoursePlanner = () => {
const setStateassociations = coursePlannerStore(
(state) => state.setStateassociations
);
const setArray = taxonomyStore((state) => state.setArray);
const theme = useTheme<any>();
const { t } = useTranslation();
const { dir, isRTL } = useDirection();
Expand Down Expand Up @@ -90,7 +91,9 @@ const CoursePlanner = () => {
console.log('No subjects found in localStorage.');
setSubjects([]);
}
}, []);

useEffect(() => {
const fetchTaxonomyResultsOne = async () => {
try {
// Define the URL for the API
Expand Down Expand Up @@ -358,7 +361,7 @@ const CoursePlanner = () => {
};

fetchTaxonomyResultsOne();
}, [value]);
}, []);

const addQueryParams = (newParams: any) => {
// Merge existing query params with new ones
Expand Down Expand Up @@ -544,12 +547,13 @@ const CoursePlanner = () => {
JSON.stringify(overallCommonSubjects)
);
setSubjects(overallCommonSubjects);
setArray(overallCommonSubjects);
} catch (error) {
console.error('Failed to fetch cohort search results:', error);
}
};
fetchTaxonomyResults();
}, [value]);
}, [value, typeOptions]);

const handleChange = (event: SelectChangeEvent<string>) => {
const newValue = event.target.value as string;
Expand Down
25 changes: 15 additions & 10 deletions src/store/taxonomyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@ import { persist } from 'zustand/middleware';
const taxonomyStore = create(
persist(
(set) => ({
state: "",
board:"",
medium:"",
grade:"",
type:"",
taxonomySubject:"",
state: '',
board: '',
medium: '',
grade: '',
type: '',
taxonomySubject: '',
stateassociations: [],
center:"",
array: [],
center: '',
setState: (newState) => set(() => ({ state: newState })),
setBoard: (newBoard) => set(() => ({ board: newBoard })),
setMedium: (newMedium) => set(() => ({ medium: newMedium })),
setGrade: (newGrade) => set(() => ({ grade: newGrade })),
setType: (newType) => set(() => ({ type: newType })),
setTaxonomySubject: (newTaxonomySubject) => set(() => ({ taxonomySubject: newTaxonomySubject })),
setTaxonomySubject: (newTaxonomySubject) =>
set(() => ({ taxonomySubject: newTaxonomySubject })),
setStateassociations: (newStateassociations) =>
set((state) => ({ stateassociations: newStateassociations })),
setCenter: (newCenter) => set(() => ({ center: newCenter})),
setCenter: (newCenter) => set(() => ({ center: newCenter })),
setArray: (newArray) => set((state) => ({ array: newArray })),
setCenter: (newCenter) => set(() => ({ center: newCenter })),
}),

{
name: 'taxonomyTeacher',
getStorage: () => localStorage
getStorage: () => localStorage,
// storage: typeof window !== 'undefined' ? localStorage : undefined,
}
)
Expand Down

0 comments on commit 77e77f2

Please sign in to comment.