Changeset d654c74 for reactapp/src/Components
- Timestamp:
- 08/06/22 14:09:43 (2 years ago)
- 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. - Location:
- reactapp/src/Components
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/Components/Main.style.js
r74b8c52 rd654c74 17 17 text-decoration: underline 3px; 18 18 margin-bottom: 30px; 19 width: fit-content; 20 float: left; 19 21 `; -
reactapp/src/Components/ProfessorCard.style.js
r74b8c52 rd654c74 6 6 padding: 10px; 7 7 margin-bottom: 30px; 8 margin-top: 140px; 8 9 `; 9 10 -
reactapp/src/Components/Search.js
r74b8c52 rd654c74 1 import React, { useEffect, useState } from "react"; 2 import JSOG from "jsog"; 3 import { transliterate } from "../Util/transliterate"; 4 import { 5 SearchDropdownResultSmall, 6 SearchDropdownTextSmall, 7 SearchDropdownSmall, 8 SearchDropdownResultLinkSmall, 9 SearchSmall, 10 } from "./Search.style"; 11 function 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 71 export default Search;
Note:
See TracChangeset
for help on using the changeset viewer.