diff --git a/frontend/src/App.js b/frontend/src/App.js index a819df2..7be4c5a 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -7,10 +7,10 @@ import StockGraph from './StockGraphing'; function App() { const [activeTab, setActiveTab] = useState('Overall Portfolio'); // default active tab - const [selectedTicker, setSelectedTicker] = useState(null); + const [selectedStock, setSelectedStock] = useState(null); - const handleStockSelection = (ticker) => { - setSelectedTicker(ticker); // Update the selected stock ticker + const handleStockSelection = (stock) => { + setSelectedStock(stock); }; return ( @@ -36,14 +36,20 @@ function App() {
-

{selectedTicker ? `${selectedTicker} Holdings` : 'Overall Portfolio'}

+

{selectedStock ? `${selectedStock.name}` : 'Overall Portfolio'}

+ {selectedStock && ( +
+

Current Value: ${selectedStock.value_held.toFixed(2)} {selectedStock.profit_loss_percentage.toFixed(2)}%

+

Shares Held: {selectedStock.shares_held}

+ {/* Add other details you want to display */} +
+ )}
- {selectedTicker && } + {selectedStock && } - - { /* Add the rest of your components here */} + {/* Rest of your components */} ); } diff --git a/frontend/src/StockHoldings.js b/frontend/src/StockHoldings.js index 52b1258..49b9e34 100644 --- a/frontend/src/StockHoldings.js +++ b/frontend/src/StockHoldings.js @@ -34,9 +34,10 @@ function StockHoldings({ onStockSelect }) { } }; - const handleStockClick = (ticker) => { + // Updated handleStockClick to pass the entire stock object + const handleStockClick = (stock) => { if (onStockSelect) { - onStockSelect(ticker); // Use the passed onStockSelect function + onStockSelect(stock); // Pass the entire stock object } }; @@ -87,24 +88,24 @@ function StockHoldings({ onStockSelect }) { return (
-

Current Stock Holdings

- {holdings.map((stock, index) => ( - - ))} -
- ); + + + ))} + +); } export default StockHoldings;