Skip to content

Commit

Permalink
Merge pull request #253 from 100-hours-a-week/feature/veronica
Browse files Browse the repository at this point in the history
Feature/veronica
  • Loading branch information
lucy726j authored Oct 1, 2024
2 parents d56b6d8 + 3856f9b commit 2954b8e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/Component/Game/GameTradeSwipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,31 @@ const GameTradeSwipe = ({
if (!selectedStock && options.length > 0) {
setSelectedStock(options[0]);
setCurrentPrice(stockData[0].current || 0); // 초기값을 0으로 설정

// 첫번째 종목이 보유 주식에 있으면 수량 설정
const holdingStock = holdingList.find(
(holding) => holding.stockId === options[0].stockId
);
if (holdingStock) {
setQuantity(holdingStock.quantity);
} else {
setQuantity(0);
}
} else if (selectedStock) {
// 선택한 종목에 맞는 가격을 설정
const selectedStockData = stockData.find(
(stock) => stock.stockId === selectedStock.stockId
);
setCurrentPrice(selectedStockData?.current || 0); // undefined 방지
// 선택된 종목이 보유 주식에 있으면 수량 설정
const holdingStock = holdingList.find(
(holding) => holding.stockId === selectedStock.stockId
);
if (holdingStock) {
setQuantity(holdingStock.quantity); // 보유한 수량으로 설정
} else {
setQuantity(0); // 보유하지 않은 경우 0으로 설정
}
}
}
}, [stockData, selectedStock]);
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Game/StocksTableStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
width: 85%;
height: 400px;
border-radius: 20px;
box-shadow: 0px 0px 17px rgb(213, 213, 213);
box-shadow: 0px 0px 10px rgb(213, 213, 213);
padding: 20px 20px;
display: flex;
align-items: center;
Expand Down
8 changes: 7 additions & 1 deletion src/Component/Game/TradeChoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ const TradeChoice = ({
}
};

const handleMaxPurchaseQuantityClick = () => {
handleMaxPurchaseQuantity();
setIsSelected(true); // 수량 선택 상태 유지
};

return (
<TradeChoiceContainer>
{/* 종목 부분 */}
Expand Down Expand Up @@ -163,7 +168,7 @@ const TradeChoice = ({
>
<MaxPurchaseBtn
isSelected={isSelected}
onClick={handleMaxPurchaseQuantity}
onClick={handleMaxPurchaseQuantityClick}
>
최대로 구매하기
</MaxPurchaseBtn>
Expand Down Expand Up @@ -242,6 +247,7 @@ const CurrentPrice = styled.div<{ isSelected: boolean }>`
const CurrentQuantity = styled.div<{ isSelected: boolean }>`
font-size: 13px;
color: ${(props) => (props.isSelected ? "#615EFC" : "#656565")};
margin-right: 10px;
`;

const MaxPurchaseBtn = styled.button<{ isSelected: boolean }>`
Expand Down

0 comments on commit 2954b8e

Please sign in to comment.