import React, { useState, useEffect } from "react"; import { useParams, Outlet } from "react-router-dom"; import JSOG from "jsog"; import { ProfessorCard, ProfessorCardName, ProfessorCardSeparator, ProfessorCardDetails, } from "../Components/Styled/ProfessorCard.style"; import { EntityUl, EntityLi, EntityParam, EntityTypeSelector, } from "../Components/Styled/EntityList.style"; import SubjectsAccordion from "../Components/SubjectsAccordion"; import { CurrentPageNav } from "../Components/Styled/Main.style"; import LoadingSpinner from "../Components/Styled/LoadingSpinner.style"; const Faculty = () => { let params = useParams(); const [loadedProfessors, setLoadedProfessors] = useState(false); const [loadedStudyProgrammes, setLoadedStudyProgrammes] = useState(false); const [professors, setProfessors] = useState(null); const [studyProgrammes, setStudyProgrammes] = useState(null); const [fetchError, setFetchError] = useState(false); const [entityType, setEntityType] = useState(0); useEffect(() => { const urlProfessors = `http://192.168.0.29:8080/public/professors?facultyId=${params.facultyId}`; const urlStudyProgrammes = `http://192.168.0.29:8080/public/study_programmes?facultyId=${params.facultyId}`; const fetchDataProfessors = async () => { try { const response = await fetch(urlProfessors); let cyclicGraph = await response.json(); let jsogStructure = JSOG.encode(cyclicGraph); cyclicGraph = JSOG.decode(jsogStructure); setProfessors(cyclicGraph); setLoadedProfessors(true); } catch (error) { setFetchError(true); } }; const fetchDataStudyProgrammes = async () => { try { const response2 = await fetch(urlStudyProgrammes); let cyclicGraph2 = await response2.json(); let jsogStructure2 = JSOG.encode(cyclicGraph2); cyclicGraph2 = JSOG.decode(jsogStructure2); setStudyProgrammes(cyclicGraph2); setLoadedStudyProgrammes(true); } catch (error) { setFetchError(true); } }; fetchDataProfessors(); fetchDataStudyProgrammes(); }, [params.facultyId]); return loadedProfessors && professors.length != 0 ? ( entityType === 0 ? ( <> »{" "} {professors[0].faculty.university.universityName} {" "} » {professors[0].faculty.facultyName} {professors[0].faculty.facultyName} {professors[0].faculty.university.universityName}
Прикажи професори setEntityType(1)} > Прикажи предмети
{professors.map((professor) => { let totalPosts = professor.relatedOpinions.length; return ( {professor.professorName} {totalPosts !== 1 ? ( totalPosts !== 0 ? ( {totalPosts} {" "} мислења ) : ( {totalPosts} {" "} мислења ) ) : ( {totalPosts}{" "} мислење )} ); })}
) : ( loadedStudyProgrammes && ( <> »{" "} {professors[0].faculty.university.universityName} {" "} » {professors[0].faculty.facultyName} {professors[0].faculty.facultyName} {professors[0].faculty.university.universityName}
setEntityType(0)} > Прикажи професори Прикажи предмети
{studyProgrammes.map((studyProgramme) => { return ( ); })}
) ) ) : !fetchError && !loadedProfessors ? (
) : (

Страницата не е пронајдена.

); }; export default Faculty;