Changeset d654c74 for reactapp/src


Ignore:
Timestamp:
08/06/22 14:09:43 (2 years ago)
Author:
unknown <mlviktor23@…>
Branches:
main
Children:
3e98cea
Parents:
74b8c52 (diff), 0df6b9e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'main' of https://github.com/neeznamm/profesori.mk

Location:
reactapp/src
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • reactapp/src/App.js

    r74b8c52 rd654c74  
    11import { Outlet } from "react-router-dom";
    22import { MainWrapper, MainTitle } from "./Components/Main.style";
     3import Search from "./Components/Search.js";
    34
    45export default function App() {
     
    1516        }
    1617      </style>
    17       <MainTitle>profesori.mk</MainTitle>
     18      <MainTitle>profesori.mk</MainTitle> <Search />
    1819      <Outlet />
    1920    </MainWrapper>
  • reactapp/src/Components/Main.style.js

    r74b8c52 rd654c74  
    1717  text-decoration: underline 3px;
    1818  margin-bottom: 30px;
     19  width: fit-content;
     20  float: left;
    1921`;
  • reactapp/src/Components/ProfessorCard.style.js

    r74b8c52 rd654c74  
    66  padding: 10px;
    77  margin-bottom: 30px;
     8  margin-top: 140px;
    89`;
    910
  • reactapp/src/Components/Search.js

    r74b8c52 rd654c74  
     1import React, { useEffect, useState } from "react";
     2import JSOG from "jsog";
     3import { transliterate } from "../Util/transliterate";
     4import {
     5  SearchDropdownResultSmall,
     6  SearchDropdownTextSmall,
     7  SearchDropdownSmall,
     8  SearchDropdownResultLinkSmall,
     9  SearchSmall,
     10} from "./Search.style";
     11function Search() {
     12  const [query, setQuery] = useState("");
     13  const [professors, setProfessors] = useState([]);
     14
     15  useEffect(() => {
     16    const url = `http://192.168.0.17:8080/public/professors/nameContains/${transliterate(
     17      query
     18    )}`;
     19
     20    const fetchData = async () => {
     21      try {
     22        const response = await fetch(url);
     23        var cyclicGraph = await response.json();
     24        var jsogStructure = JSOG.encode(cyclicGraph); // has { '@ref': 'ID' } links instead of cycles
     25        cyclicGraph = JSOG.decode(jsogStructure);
     26        setProfessors(cyclicGraph);
     27        //setLoaded(true);
     28      } catch (error) {
     29        console.log("Error", error);
     30      }
     31    };
     32
     33    if (query.length > 2) fetchData();
     34  }, [query]);
     35
     36  return (
     37    <div
     38      style={{
     39        position: "relative",
     40        width: "fit-content",
     41        float: "right",
     42      }}
     43    >
     44      <SearchSmall
     45        placeholder="Пребарувај..."
     46        onChange={(e) => setQuery(e.target.value)}
     47      />
     48      <SearchDropdownSmall
     49        display={query.length > 2 && professors.length > 0 ? "block" : "none"}
     50      >
     51        {query.length > 2 &&
     52          professors.slice(0, 7).map((professor) => (
     53            <SearchDropdownResultSmall key={professor.professorId}>
     54              <SearchDropdownResultLinkSmall
     55                href={"/professor/" + professor.professorId}
     56              >
     57                <SearchDropdownTextSmall weight="bold" size="medium">
     58                  {professor.professorName}
     59                </SearchDropdownTextSmall>
     60                <SearchDropdownTextSmall weight="normal" size="smaller">
     61                  {professor.faculty.facultyName}
     62                </SearchDropdownTextSmall>
     63              </SearchDropdownResultLinkSmall>
     64            </SearchDropdownResultSmall>
     65          ))}
     66      </SearchDropdownSmall>
     67    </div>
     68  );
     69}
     70
     71export default Search;
  • reactapp/src/Pages/Professor.js

    r74b8c52 rd654c74  
    33import JSOG from "jsog";
    44import OpinionTree from "../Components/OpinionTree";
    5 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
    6 import {
    7   solid,
    8   regular,
    9   brands,
    10 } from "@fortawesome/fontawesome-svg-core/import.macro";
    115
    126import {
     
    7064    return (
    7165      <div>
    72         <p>loading</p>
     66        <p style={{ marginTop: "140px" }}>се вчитува...</p>
    7367        <Outlet />
    7468      </div>
Note: See TracChangeset for help on using the changeset viewer.