- Timestamp:
- 07/31/22 22:16:22 (2 years ago)
- Branches:
- main
- Children:
- 0df6b9e
- Parents:
- a4b5062
- Location:
- reactapp
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/package-lock.json
ra4b5062 r080a3f3 24 24 "react-scripts": "5.0.1", 25 25 "styled-components": "^5.3.5", 26 "transliteration": "^2.3.5", 26 27 "web-vitals": "^2.1.4" 27 28 } … … 15705 15706 } 15706 15707 }, 15708 "node_modules/transliteration": { 15709 "version": "2.3.5", 15710 "resolved": "https://registry.npmjs.org/transliteration/-/transliteration-2.3.5.tgz", 15711 "integrity": "sha512-HAGI4Lq4Q9dZ3Utu2phaWgtm3vB6PkLUFqWAScg/UW+1eZ/Tg6Exo4oC0/3VUol/w4BlefLhUUSVBr/9/ZGQOw==", 15712 "dependencies": { 15713 "yargs": "^17.5.1" 15714 }, 15715 "bin": { 15716 "slugify": "dist/bin/slugify", 15717 "transliterate": "dist/bin/transliterate" 15718 }, 15719 "engines": { 15720 "node": ">=6.0.0" 15721 } 15722 }, 15723 "node_modules/transliteration/node_modules/yargs": { 15724 "version": "17.5.1", 15725 "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", 15726 "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", 15727 "dependencies": { 15728 "cliui": "^7.0.2", 15729 "escalade": "^3.1.1", 15730 "get-caller-file": "^2.0.5", 15731 "require-directory": "^2.1.1", 15732 "string-width": "^4.2.3", 15733 "y18n": "^5.0.5", 15734 "yargs-parser": "^21.0.0" 15735 }, 15736 "engines": { 15737 "node": ">=12" 15738 } 15739 }, 15740 "node_modules/transliteration/node_modules/yargs-parser": { 15741 "version": "21.0.1", 15742 "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", 15743 "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", 15744 "engines": { 15745 "node": ">=12" 15746 } 15747 }, 15707 15748 "node_modules/tryer": { 15708 15749 "version": "1.0.1", … … 28021 28062 } 28022 28063 }, 28064 "transliteration": { 28065 "version": "2.3.5", 28066 "resolved": "https://registry.npmjs.org/transliteration/-/transliteration-2.3.5.tgz", 28067 "integrity": "sha512-HAGI4Lq4Q9dZ3Utu2phaWgtm3vB6PkLUFqWAScg/UW+1eZ/Tg6Exo4oC0/3VUol/w4BlefLhUUSVBr/9/ZGQOw==", 28068 "requires": { 28069 "yargs": "^17.5.1" 28070 }, 28071 "dependencies": { 28072 "yargs": { 28073 "version": "17.5.1", 28074 "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", 28075 "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", 28076 "requires": { 28077 "cliui": "^7.0.2", 28078 "escalade": "^3.1.1", 28079 "get-caller-file": "^2.0.5", 28080 "require-directory": "^2.1.1", 28081 "string-width": "^4.2.3", 28082 "y18n": "^5.0.5", 28083 "yargs-parser": "^21.0.0" 28084 } 28085 }, 28086 "yargs-parser": { 28087 "version": "21.0.1", 28088 "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", 28089 "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==" 28090 } 28091 } 28092 }, 28023 28093 "tryer": { 28024 28094 "version": "1.0.1", -
reactapp/package.json
ra4b5062 r080a3f3 19 19 "react-scripts": "5.0.1", 20 20 "styled-components": "^5.3.5", 21 "transliteration": "^2.3.5", 21 22 "web-vitals": "^2.1.4" 22 23 }, -
reactapp/src/App.js
ra4b5062 r080a3f3 1 1 import { Outlet } from "react-router-dom"; 2 2 import { MainWrapper, MainTitle } from "./Components/Main.style"; 3 import Search from "./Components/Search.js"; 3 4 4 5 export default function App() { … … 16 17 </style> 17 18 <MainTitle>profesori.mk</MainTitle> 19 <Search /> 18 20 <Outlet /> 19 21 </MainWrapper> -
reactapp/src/Components/Search.js
ra4b5062 r080a3f3 1 import React, { useEffect, useState } from "react"; 2 import JSOG from "jsog"; 3 import { transliterate } from "../Util/transliterate"; 4 import { 5 SearchDropdownContentSmall, 6 SearchDropdownSmall, 7 } from "./Search.style"; 8 function Search() { 9 const [query, setQuery] = useState(""); 10 const [professors, setProfessors] = useState([]); 11 12 useEffect(() => { 13 const url = `http://192.168.0.17:8080/public/professors/nameContains/${transliterate( 14 query 15 )}`; 16 17 const fetchData = async () => { 18 try { 19 const response = await fetch(url); 20 var cyclicGraph = await response.json(); 21 var jsogStructure = JSOG.encode(cyclicGraph); // has { '@ref': 'ID' } links instead of cycles 22 cyclicGraph = JSOG.decode(jsogStructure); 23 setProfessors(cyclicGraph); 24 //setLoaded(true); 25 } catch (error) { 26 console.log("Error", error); 27 } 28 }; 29 30 if (query.length > 2) fetchData(); 31 }, [query]); 32 33 return ( 34 <div style={{ position: "relative" }}> 35 <input 36 placeholder="Пребарувај..." 37 onChange={(e) => setQuery(e.target.value)} 38 /> 39 40 {query.length > 2 && 41 professors.slice(0, 10).map((professor) => ( 42 <SearchDropdownSmall> 43 <div key={professor.professorId}> 44 <SearchDropdownContentSmall weight="bold" size="medium"> 45 {professor.professorName} 46 </SearchDropdownContentSmall> 47 <SearchDropdownContentSmall weight="normal" size="smaller"> 48 {professor.faculty.facultyName} 49 </SearchDropdownContentSmall> 50 </div> 51 </SearchDropdownSmall> 52 ))} 53 </div> 54 ); 55 } 56 57 export default Search;
Note:
See TracChangeset
for help on using the changeset viewer.