Skip to content

Commit

Permalink
Merge pull request #171 from seattletrade/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Myau5x authored Feb 26, 2021
2 parents e5c6a28 + 70ea91f commit af10dce
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 51 deletions.
22 changes: 14 additions & 8 deletions client/src/components/ChartCompanyinfoMain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -379,6 +384,7 @@ export default function Infopage(promps) {
return (

<>
{/* {console.log(isOnWatchList)} */}
{loading ? (<div>Loding...</div>) : (
<div style={{ background: "black", height: "400px", margin: "0 -15px" }}>
<div className="pl-3 pt-5" style={{ color: "white" }}>
Expand All @@ -398,7 +404,7 @@ export default function Infopage(promps) {
to="/gamestock/user"
className={location.pathname === "/gamestock/user" ? "nav-link active" : "nav-link"}
>
<button type="button" className="btn btn-danger" onClick={handleClick}>{isClicked ? "watching" : "watch"} </button>
<button disabled={isOnWatchList.includes(ticker)} type="button" className="btn btn-danger" onClick={handleClick}>{isClicked || isOnWatchList.includes(ticker) ? "watching" : "watch"} </button>
</Link>
</Col>
</Row>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ForgotPassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ForgotPassword() {
<Button disabled={loading} className="w-100" type="submit" style={{backgroundColor: "#FD0000"}}>Reset Password</Button>
</Form>
<div className="w-100 text-center mt-3">
<Link to="/gamestock/login">Log In</Link>
<Link to="/gamestock/login" style={{color: "#FD0000"}}>Log In</Link>
</div>
</Card.Body>
</Card>
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/MyStockList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<h4>Stocks</h4>
Expand Down
14 changes: 12 additions & 2 deletions client/src/components/MyWatchList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -72,6 +78,10 @@ export default function MyWatchList() {
useEffect(() => {
loadWatchList()
}, [])

useEffect(() => {

}, [myWatchLists])

return (
<>
Expand All @@ -96,7 +106,7 @@ export default function MyWatchList() {
<StockChart company={company} />
</Col>
<Col className="text-right" style={{ margin: "auto" }}>
${parseFloat((company["graphData"].currentValue)).toFixed(2)}
${parseFloat(company.price).toFixed(2)}
</Col>
<Col className="text-right" style={{ margin: "auto" }}>
<Button onClick={() => handleDelete(currentUser.email, company.symbol)} className="btn btn-sm btn-danger">X</Button>
Expand Down
4 changes: 4 additions & 0 deletions client/src/components/Nav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default function Nav() {
// console.log(currentUser)
}, [])

useEffect(() => {

}, [nickname]
)

const handleLogout = async () => {
setError('')
Expand Down
85 changes: 45 additions & 40 deletions client/src/components/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,53 +63,58 @@ export default function Search() {

return (
<>
<div style={{ zIndex: 10, marginTop: "", position: "absolute" }} >
<Autocomplete
getItemValue={(item) => item.Symbol + "/" + item["Company Name"]}
items={searchList}
renderItem={(item, isHighlighted) =>
<div style={{ background: isHighlighted ? 'lightgray' : 'white' }}
key={item.Symbol}>
{item.Symbol} {item["Company Name"]}
{/* {setNameResult(item["Company Name"])} */}
</div>
}
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 ? (
<div style={{ zIndex: 10, marginTop: "", position: "absolute" }} >
<Autocomplete
getItemValue={(item) => item.Symbol + "/" + item["Company Name"]}
items={searchList}
renderItem={(item, isHighlighted) =>
<div style={{ background: isHighlighted ? 'lightgray' : 'white' }}
key={item.Symbol}>
{item.Symbol} {item["Company Name"]}
{/* {setNameResult(item["Company Name"])} */}
</div>
}
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]
})
}}
/>
</div>
}}
/>
</div>
)
:
(<></>)
}
{isSymbol ? (
<>
<ChartCompanyinfoMain companyName={searchResult["companyName"]} symbol={searchResult["symbol"]} />
<CompanyInformation symbol={searchResult["symbol"]} />
<CompanyNews symbol={searchResult["symbol"]} />
</>
) : (<div style={{textAlign:"center", color:"white", paddingTop:"100px"}}>Search by Company name or Symbol</div>)}
) : (<div style={{ textAlign: "center", color: "white", paddingTop: "100px" }}>Search by Company name or Symbol</div>)}

</>
)
Expand Down

0 comments on commit af10dce

Please sign in to comment.