main
Last change
on this file since 4a64cf0 was 4a64cf0, checked in by unknown <mlviktor23@…>, 2 years ago |
implemented addOpinion and replyToOpinion functions, reorganized api
|
-
Property mode
set to
100644
|
File size:
964 bytes
|
Rev | Line | |
---|
[7cb8c3c] | 1 | import React, { useEffect, useState } from "react";
|
---|
| 2 | import { Link, Outlet, useParams } from "react-router-dom";
|
---|
| 3 |
|
---|
| 4 | function Professor() {
|
---|
| 5 | let params = useParams();
|
---|
| 6 |
|
---|
[4a64cf0] | 7 | let [professor, setProfessor] = useState(null);
|
---|
| 8 | let [loaded, setLoaded] = useState(null);
|
---|
[7cb8c3c] | 9 |
|
---|
| 10 | useEffect(() => {
|
---|
[4a64cf0] | 11 | const url = `http://192.168.0.17:8080/public/professor/${params.professorId}`;
|
---|
[7cb8c3c] | 12 |
|
---|
| 13 | const fetchData = async () => {
|
---|
| 14 | try {
|
---|
| 15 | const response = await fetch(url);
|
---|
| 16 | const json = await response.json();
|
---|
| 17 | setProfessor(json);
|
---|
[4a64cf0] | 18 | setLoaded(true);
|
---|
[7cb8c3c] | 19 | } catch (error) {
|
---|
| 20 | console.log("error", error);
|
---|
| 21 | }
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | fetchData();
|
---|
| 25 | }, []);
|
---|
| 26 |
|
---|
[4a64cf0] | 27 | if (loaded) {
|
---|
| 28 | return (
|
---|
[7cb8c3c] | 29 | <div>
|
---|
| 30 | <div>{professor.professorName}</div>
|
---|
| 31 | <div>{professor.faculty.facultyName}</div>
|
---|
[4a64cf0] | 32 | <Outlet />
|
---|
[7cb8c3c] | 33 | </div>
|
---|
[4a64cf0] | 34 | );
|
---|
| 35 | } else {
|
---|
| 36 | return (
|
---|
| 37 | <div>
|
---|
| 38 | <p>loading</p>
|
---|
| 39 | <Outlet />
|
---|
| 40 | </div>
|
---|
| 41 | );
|
---|
| 42 | }
|
---|
[7cb8c3c] | 43 | }
|
---|
| 44 |
|
---|
| 45 | export default Professor;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.