Skip to content

Commit

Permalink
[Fix]보유종목 리스트 활성화
Browse files Browse the repository at this point in the history
삼성전자만 보이는 에러 해결
companyId가 매칭되는 것을 보여주는 기능 구현
Issues #19
  • Loading branch information
김병현 authored and 김병현 committed Sep 16, 2023
1 parent 57bf623 commit 422b09d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
12 changes: 7 additions & 5 deletions client/src/components/HoldingList/HoldingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ const HoldingList: React.FC<WatchListProps> = ({ currentListType, onChangeListTy
) : isError || isCompanyDataError ? (
<div>Error fetching data</div>
) : (
stockHolds.map((stockHold: StockItemProps['stockData']) => (
companyData ? (
stockHolds.map((stockHold: StockItemProps['stockData']) => {
const matchedCompany = companyData ? companyData.find(company => company.companyId === stockHold.companyId) : undefined;

return matchedCompany ? (
<StockItem
key={stockHold.companyId}
stockData={stockHold}
companyData={companyData}
companyData={matchedCompany}
setShowChangePrice={setShowChangePrice}
showChangePrice={showChangePrice}
/>
) : null
))
) : null;
})
)}
</StockList>
</WatchListContainer>
Expand Down
8 changes: 5 additions & 3 deletions client/src/components/HoldingList/StockItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type StockItemProps = {
stockPrice: string;
stockChangeAmount: string;
stockChangeRate: string;
}[];
};
setShowChangePrice: (value: boolean) => void;
showChangePrice: boolean;
};
Expand All @@ -31,7 +31,7 @@ export type StockItemProps = {
const StockItem: React.FC<StockItemProps> = ({ 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 = '',
Expand Down Expand Up @@ -83,6 +83,8 @@ const StockItem: React.FC<StockItemProps> = ({ companyData, stockData, setShowCh
);
};

export default StockItem;

const ItemContainer = styled.div`
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -181,4 +183,4 @@ const ThickDivider = styled.div`
background-color: #aaa;
margin: 8px 0;
`;
export default StockItem;

5 changes: 5 additions & 0 deletions client/src/components/watchlist/WatchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const WatchList: React.FC<WatchListProps> = ({ currentListType, onChangeListType
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedCompanyId]);

//
useEffect(() => {
localStorage.setItem('searchedCompanyIds', JSON.stringify(searchedCompanyIds));
}, [searchedCompanyIds]);

return (
<WatchListContainer>
<Header
Expand Down

0 comments on commit 422b09d

Please sign in to comment.