From 79ef9e3579b52a2960c4d28b83e01d3405419693 Mon Sep 17 00:00:00 2001 From: puakehaulani Date: Thu, 25 Feb 2021 20:28:24 -0800 Subject: [PATCH 1/5] ternary added to autocorrect to wait for db to load --- client/src/components/Search/index.js | 85 ++++++++++++++------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/client/src/components/Search/index.js b/client/src/components/Search/index.js index 1523d64..1e17e5b 100644 --- a/client/src/components/Search/index.js +++ b/client/src/components/Search/index.js @@ -63,53 +63,58 @@ export default function Search() { return ( <> -
- item.Symbol + "/" + item["Company Name"]} - items={searchList} - renderItem={(item, isHighlighted) => -
- {item.Symbol} {item["Company Name"]} - {/* {setNameResult(item["Company Name"])} */} -
- } - inputProps={{ placeholder: 'Search' }} - value={searchInput} - onChange={handleChange} - onSelect={(item) => { - // console.log(item.split("/")); - // console.log(item.split("/")[0]); - // console.log(item.split("/")[1]); - // setSymbolResult(item) - API.getIntraMarketData(item.split("/")[0], "60min") - .then(res => { - if (res["data"]["Error Message"]) { - setIsSymbol(false) - } else { - setIsSymbol(true) - } - // console.log(res); + { searchListFromDB ? ( +
+ item.Symbol + "/" + item["Company Name"]} + items={searchList} + renderItem={(item, isHighlighted) => +
+ {item.Symbol} {item["Company Name"]} + {/* {setNameResult(item["Company Name"])} */} +
+ } + inputProps={{ placeholder: 'Search' }} + value={searchInput} + onChange={handleChange} + onSelect={(item) => { + // console.log(item.split("/")); + // console.log(item.split("/")[0]); + // console.log(item.split("/")[1]); + // setSymbolResult(item) + API.getIntraMarketData(item.split("/")[0], "60min") + .then(res => { + if (res["data"]["Error Message"]) { + setIsSymbol(false) + } else { + setIsSymbol(true) + } + // console.log(res); + }) + .then(err => { + if (err !== undefined) { + setIsSymbol(false) + } + }) + setSearchResult({ + "symbol": item.split("/")[0], + "companyName": item.split("/")[1] }) - .then(err => { - if (err !== undefined) { - setIsSymbol(false) - } - }) - setSearchResult({ - "symbol": item.split("/")[0], - "companyName": item.split("/")[1] - }) - }} - /> -
+ }} + /> +
+ ) + : + (<>) + } {isSymbol ? ( <> - ) : (
Search by Company name or Symbol
)} + ) : (
Search by Company name or Symbol
)} ) From 63360e17b5aa36528eb1470873ad74cb9014708a Mon Sep 17 00:00:00 2001 From: puakehaulani Date: Thu, 25 Feb 2021 20:47:02 -0800 Subject: [PATCH 2/5] nickname state reload --- client/src/components/Nav/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/components/Nav/index.js b/client/src/components/Nav/index.js index 66ae172..52b276c 100644 --- a/client/src/components/Nav/index.js +++ b/client/src/components/Nav/index.js @@ -22,6 +22,10 @@ export default function Nav() { // console.log(currentUser) }, []) + useEffect(() => { + + }, [nickname] + ) const handleLogout = async () => { setError('') From 589eb89e7574242822c13a86b972bd9366805058 Mon Sep 17 00:00:00 2001 From: Girma Ebssa Date: Thu, 25 Feb 2021 21:07:13 -0800 Subject: [PATCH 3/5] changes watch button watching for companies on watchlist and makes it disabled --- .../components/ChartCompanyinfoMain/index.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/client/src/components/ChartCompanyinfoMain/index.js b/client/src/components/ChartCompanyinfoMain/index.js index 145950c..460234c 100644 --- a/client/src/components/ChartCompanyinfoMain/index.js +++ b/client/src/components/ChartCompanyinfoMain/index.js @@ -78,6 +78,7 @@ export default function Infopage(promps) { const [currentValueState, setCurrentValueState] = useState(); const [operatorForCurrentValue, setOperatorForCurrentValue] = useState("+"); const [isClicked, setIsClicked] = useState(false) + const [isOnWatchList, setIsOnWatchList] = useState([]) const { currentUser} = useAuth(); const history = useHistory(); @@ -89,12 +90,16 @@ export default function Infopage(promps) { companyName: companyNameState }) .then(data => console.log(data)) - setIsClicked(true); - // history.push("/gamestock/user") - // console.log(` - // symbol: ${ticker}, - // companyName: ${companyNameState} - // `) + setIsClicked(true); + } + + function OnWatchList(email){ + let watchArr = [] + API.getAllOnWatchList(email) + .then(data => { + data.data.map(company => watchArr.push(company.symbol)) + setIsOnWatchList(watchArr) + }) } // Fetch Martke Data from API (Alpha Vantage) function GetMarketData(userInput) { @@ -136,7 +141,7 @@ export default function Infopage(promps) { // console.log("First") setPropsState(promps) // API.getTest().then((res) => console.log(res)); - + OnWatchList(currentUser.email) // Get the data from a User when they click a company from Search PAGE let userInput = promps // console.log(userInput); @@ -379,6 +384,7 @@ export default function Infopage(promps) { return ( <> + {/* {console.log(isOnWatchList)} */} {loading ? (
Loding...
) : (
@@ -398,7 +404,7 @@ export default function Infopage(promps) { to="/gamestock/user" className={location.pathname === "/gamestock/user" ? "nav-link active" : "nav-link"} > - + From 2c8e8c1b63cea2ddad0e373baf949235b31ab64a Mon Sep 17 00:00:00 2001 From: Girma Ebssa Date: Thu, 25 Feb 2021 21:08:10 -0800 Subject: [PATCH 4/5] makes style changes --- client/src/components/ForgotPassword/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/ForgotPassword/index.js b/client/src/components/ForgotPassword/index.js index 3e81a9b..839940f 100644 --- a/client/src/components/ForgotPassword/index.js +++ b/client/src/components/ForgotPassword/index.js @@ -40,7 +40,7 @@ export default function ForgotPassword() {
- Log In + Log In
From 1a7024003670f3b885cdf6f8b8b0bd70c93ef869 Mon Sep 17 00:00:00 2001 From: Girma Ebssa Date: Thu, 25 Feb 2021 21:08:54 -0800 Subject: [PATCH 5/5] updates userpage when stocklist and watchlist changes --- client/src/components/MyStockList/index.js | 5 +++++ client/src/components/MyWatchList/index.js | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/src/components/MyStockList/index.js b/client/src/components/MyStockList/index.js index 557ac6b..55dbb82 100644 --- a/client/src/components/MyStockList/index.js +++ b/client/src/components/MyStockList/index.js @@ -63,6 +63,11 @@ export default function MyStockList() { // Put Currten Value with symbols and shares which are from Stock DB to setMyStockLists }, []) + + useEffect(() => { + + }, [myStockLists]) + return ( <>

Stocks

diff --git a/client/src/components/MyWatchList/index.js b/client/src/components/MyWatchList/index.js index cf460c8..9a04359 100644 --- a/client/src/components/MyWatchList/index.js +++ b/client/src/components/MyWatchList/index.js @@ -32,7 +32,13 @@ export default function MyWatchList() { .then(watchLists => { // console.log(watchLists.data) if(watchLists.data.length){ - WatchArr = [...watchLists.data]; + WatchArr = [...watchLists.data]; + for(let i = 0; i < WatchArr.length; i++) { + // console.log("each stock array", StockArr[i]) + API.getCurrentPrice(WatchArr[i].symbol) + // .then(data => console.log(data.data["Global Quote"]["05. price"])) + .then(data => WatchArr[i].price = data.data["Global Quote"]["05. price"]) + } watchLists.data.map(stock => { API.getIntraMarketData(stock.symbol, "15min") .then(marketData => { @@ -72,6 +78,10 @@ export default function MyWatchList() { useEffect(() => { loadWatchList() }, []) + + useEffect(() => { + + }, [myWatchLists]) return ( <> @@ -96,7 +106,7 @@ export default function MyWatchList() { - ${parseFloat((company["graphData"].currentValue)).toFixed(2)} + ${parseFloat(company.price).toFixed(2)}