diff --git a/frontend/src/pages/presenters/PresentersPage.jsx b/frontend/src/pages/presenters/PresentersPage.jsx index 1e4f504..456977d 100644 --- a/frontend/src/pages/presenters/PresentersPage.jsx +++ b/frontend/src/pages/presenters/PresentersPage.jsx @@ -5,18 +5,18 @@ import usePresenterPage from './usePresentersPage.js'; import '../../css/Presenters.css'; export default function PresenterPage() { - const { teachers } = usePresenterPage(); + const { renderedData } = usePresenterPage(); const navigate = useNavigate(); const navToPresenterDetailPage = (id) => () => { navigate(`${id}`, { state: { - teachersArray: teachers, + teachersArray: renderedData, }, }); }; - if (teachers) { + if (renderedData) { return ( @@ -30,7 +30,7 @@ export default function PresenterPage() { className="presenters-container" gap={5} > - {teachers.map((item, index) => ( + {renderedData.map((item, index) => ( { getTeachersData(); - }, []); + getPresenterData() + }, [getPresenterData, getTeachersData]); useEffect(() => { - if (teachersData == null) return; - setTeachers(teachersData); - }, [teachersData]); + if (teachersData == null || presenterData == null) return; + setRenderedData(teachersData.concat(presenterData)); + }, [presenterData, teachersData]); return { - teachers, + renderedData, }; } diff --git a/frontend/src/providers/APIProvider/APIProvider.jsx b/frontend/src/providers/APIProvider/APIProvider.jsx index 36fa6be..66c4481 100644 --- a/frontend/src/providers/APIProvider/APIProvider.jsx +++ b/frontend/src/providers/APIProvider/APIProvider.jsx @@ -247,7 +247,7 @@ export function APIProvider({children}) { }, [currentYear, service]) const getTeachersData = useCallback(async () => { - await service.get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.presenter}`) + await service.get(`${URL.baseURL}${URL.services[currentYear]}${URL.endpoints.teacher}`) .then(response => setTeachersData(response.data)) }, [currentYear, service]) @@ -278,7 +278,6 @@ export function APIProvider({children}) { if (!Helper.checkTokenValidity(accessToken)) { updateAccessTokenWithRefreshToken() } - service.defaults.headers.common['Authorization'] = getAccessTokenHeader(); }, [accessToken, refreshToken, service.defaults.headers.common, updateAccessTokenWithRefreshToken])