diff --git a/src/pages/course-planner/index.tsx b/src/pages/course-planner/index.tsx index 90cfe918..c66f193b 100644 --- a/src/pages/course-planner/index.tsx +++ b/src/pages/course-planner/index.tsx @@ -42,6 +42,7 @@ const CoursePlanner = () => { const setStateassociations = coursePlannerStore( (state) => state.setStateassociations ); + const setArray = taxonomyStore((state) => state.setArray); const theme = useTheme(); const { t } = useTranslation(); const { dir, isRTL } = useDirection(); @@ -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 @@ -358,7 +361,7 @@ const CoursePlanner = () => { }; fetchTaxonomyResultsOne(); - }, [value]); + }, []); const addQueryParams = (newParams: any) => { // Merge existing query params with new ones @@ -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) => { const newValue = event.target.value as string; diff --git a/src/store/taxonomyStore.js b/src/store/taxonomyStore.js index 30b54cfa..cc8d91cf 100644 --- a/src/store/taxonomyStore.js +++ b/src/store/taxonomyStore.js @@ -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, } )