diff --git a/client/src/components/HoldingList/HoldingList.tsx b/client/src/components/HoldingList/HoldingList.tsx index 6a2a51cc..f0610297 100644 --- a/client/src/components/HoldingList/HoldingList.tsx +++ b/client/src/components/HoldingList/HoldingList.tsx @@ -37,17 +37,19 @@ const HoldingList: React.FC = ({ currentListType, onChangeListTy ) : isError || isCompanyDataError ? (
Error fetching data
) : ( - stockHolds.map((stockHold: StockItemProps['stockData']) => ( - companyData ? ( + stockHolds.map((stockHold: StockItemProps['stockData']) => { + const matchedCompany = companyData ? companyData.find(company => company.companyId === stockHold.companyId) : undefined; + + return matchedCompany ? ( - ) : null - )) + ) : null; + }) )} diff --git a/client/src/components/HoldingList/StockItem.tsx b/client/src/components/HoldingList/StockItem.tsx index 7f1aab0e..6555fe17 100644 --- a/client/src/components/HoldingList/StockItem.tsx +++ b/client/src/components/HoldingList/StockItem.tsx @@ -21,7 +21,7 @@ export type StockItemProps = { stockPrice: string; stockChangeAmount: string; stockChangeRate: string; -}[]; + }; setShowChangePrice: (value: boolean) => void; showChangePrice: boolean; }; @@ -31,7 +31,7 @@ export type StockItemProps = { const StockItem: React.FC = ({ companyData, stockData, setShowChangePrice, showChangePrice }) => { const { stockCount, reserveSellStockCount, totalPrice, percentage, stockReturn } = stockData; const totalStocksHeld = stockCount + reserveSellStockCount; - const company = companyData ? companyData[0] : undefined; + const company = companyData ? companyData : undefined; const { code = '', @@ -83,6 +83,8 @@ const StockItem: React.FC = ({ companyData, stockData, setShowCh ); }; +export default StockItem; + const ItemContainer = styled.div` display: flex; justify-content: space-between; @@ -181,4 +183,4 @@ const ThickDivider = styled.div` background-color: #aaa; margin: 8px 0; `; -export default StockItem; + diff --git a/client/src/components/watchlist/WatchList.tsx b/client/src/components/watchlist/WatchList.tsx index fc129d4d..a0cbeaae 100644 --- a/client/src/components/watchlist/WatchList.tsx +++ b/client/src/components/watchlist/WatchList.tsx @@ -35,6 +35,11 @@ const WatchList: React.FC = ({ currentListType, onChangeListType // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedCompanyId]); + // + useEffect(() => { + localStorage.setItem('searchedCompanyIds', JSON.stringify(searchedCompanyIds)); + }, [searchedCompanyIds]); + return (