Changeset 4a64cf0 for reactapp


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

Location:
reactapp/src
Files:
1 edited
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
  • reactapp/src/index.js

    r7cb8c3c r4a64cf0  
    11import ReactDOM from "react-dom/client";
    2 import {
    3   BrowserRouter,
    4   Routes,
    5   Route,
    6 } from "react-router-dom";
     2import { BrowserRouter, Routes, Route } from "react-router-dom";
    73import App from "./App";
    8 import Professor from "./Component/Professor";
     4import Professor from "./Pages/Professor";
    95
    10 const root = ReactDOM.createRoot(
    11   document.getElementById("root")
    12 );
     6const root = ReactDOM.createRoot(document.getElementById("root"));
    137root.render(
    148  <BrowserRouter>
    159    <Routes>
    1610      <Route path="/" element={<App />}>
    17         <Route path="professor" element={<Professor />}>
     11        <Route path="professor">
    1812          <Route path=":professorId" element={<Professor />} />
    1913        </Route>
Note: See TracChangeset for help on using the changeset viewer.