diff options
author | Michael Foiani <sotech117@michaels-mbp-3.lan> | 2021-04-20 07:55:53 -0400 |
---|---|---|
committer | Michael Foiani <sotech117@michaels-mbp-3.lan> | 2021-04-20 07:55:53 -0400 |
commit | c4f075343f557f278b1bacb4b92891e646f8fb2a (patch) | |
tree | 96677b3a39e978f24aa63ed8d1b2e802d8a4b819 /react-frontend/src/components/HubSearch.js | |
parent | 30cf6cfc8e1dac90d4b95e2d880fbee0d2831a97 (diff) |
Finished up the front end functionality. Some issues with the backend (small NaN issues), and some elements need a little more love (styling) before demo.
Diffstat (limited to 'react-frontend/src/components/HubSearch.js')
-rw-r--r-- | react-frontend/src/components/HubSearch.js | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/react-frontend/src/components/HubSearch.js b/react-frontend/src/components/HubSearch.js deleted file mode 100644 index 827ea6d..0000000 --- a/react-frontend/src/components/HubSearch.js +++ /dev/null @@ -1,64 +0,0 @@ -// React and component imports -import { useEffect, useState } from "react"; -import InvestorInfo from "./InvestorInfo.js"; - -// CSS import -import '../css/UserCheckin.css'; -import Hub from "./HubList.js"; -import Search from "./HubSearch.js"; - -/** - * Component that build the checkin list and displays checkin info. - * @returns {import('react').HtmlHTMLAttributes} A div with the hubs - * in a vertical layout. - */ -function HubSearch(props) { - const [queryString, setQueryString] = useState("", (s) => s.toLowerCase()); - const [displayedItems, setDisplayedItems] = useState([]); - - /** - * Method that determines whehter the Hub should be showed. - * @returns {Boolean} True if to be shown, false if not. - */ - const toInclude = holder => { - // TODO: add number search or differentiate between it - // TODO: add sus score range.... - if (!holder) { - return false; - }; - - // const matchingId = holder.id.toString().includes(queryString.toLowerCase()); - const matchingName = holder.name.toLowerCase().includes(queryString); - return matchingName; - } - - /** - * Filters the items to be shown, then created the iteams and sets the state with the items. - */ - const filterItems = () => { - console.log(queryString); - const criteria = props.data.filter(holder => toInclude(holder)); - setDisplayedItems(criteria.map(hub => <p>{hub.name}</p>)) - } - - /** - * Hook to update the items on change of the search string. - */ - useEffect(() => filterItems(), [queryString]); - - // TODO: maybe have a quick explanation of what search gives... - // TODO: have number of ceos that make it... - // TODO: weighted search or sort after search.... - // TODO: highlight part of string that matched... - return ( - <div className="User-checkin"> - <div className="Checkins"> - <h2>Search</h2> - <input type="text" onChange={(e) => setQueryString(e.target.value)}></input> - <ul className='Checkin-list'>{displayedItems}</ul>; - </div> - </div> - ); -} - -export default HubSearch;
\ No newline at end of file |