Changeset 4a64cf0 for reactapp/src/Pages


Ignore:
Timestamp:
07/29/22 21:31:30 (2 years ago)
Author:
unknown <mlviktor23@…>
Branches:
main
Children:
3a44163
Parents:
7cb8c3c
Message:

implemented addOpinion and replyToOpinion functions, reorganized api

File:
1 moved

Legend:

Unmodified
Added
Removed
  • reactapp/src/Pages/Professor.js

    r7cb8c3c r4a64cf0  
    55  let params = useParams();
    66
    7   let [professor, setProfessor] = useState();
     7  let [professor, setProfessor] = useState(null);
     8  let [loaded, setLoaded] = useState(null);
    89
    910  useEffect(() => {
    10     const url = "http://192.168.0.17:8080/professor/1";
     11    const url = `http://192.168.0.17:8080/public/professor/${params.professorId}`;
    1112
    1213    const fetchData = async () => {
     
    1516        const json = await response.json();
    1617        setProfessor(json);
     18        setLoaded(true);
    1719      } catch (error) {
    1820        console.log("error", error);
     
    2325  }, []);
    2426
    25   return (
    26     <div>
     27  if (loaded) {
     28    return (
    2729      <div>
    2830        <div>{professor.professorName}</div>
    2931        <div>{professor.faculty.facultyName}</div>
     32        <Outlet />
    3033      </div>
    31       <Outlet />
    32     </div>
    33   );
     34    );
     35  } else {
     36    return (
     37      <div>
     38        <p>loading</p>
     39        <Outlet />
     40      </div>
     41    );
     42  }
    3443}
    3544
Note: See TracChangeset for help on using the changeset viewer.