Skip to content

Commit

Permalink
[Feat] 구매수량 설정 제한 기능 복구
Browse files Browse the repository at this point in the history
- 최대 구매 가능수량 초과한 값으로는 구매량 설정 못하도록 하는 로직 다시 복구
- 관련한 알림창 띄우는 것보다 초기에 설정을 못하도록 셋팅을 해놓은 것이 더 낫다고 생각되어 다시 복구기로 결정함
- 해당 기능 삭제 후 CSS 관련된 일부 수정 작업이 이루어진 상황이라, Git Reset이 아닌 다시 Commit 남기는 방법을 선택함

Issues #17
  • Loading branch information
novice1993 committed Sep 10, 2023
1 parent 336df77 commit 76e7535
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion client/src/components/StockOrderSection/VolumeSetteing.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from "react";
import { useSelector, useDispatch } from "react-redux";
import { styled } from "styled-components";
import { StateProps } from "../../models/stateProps";
Expand Down Expand Up @@ -26,7 +27,14 @@ const VolumeSetting = () => {
const maximumBuyingVolume = Math.trunc(dummyMoney / orderPrice);

const handlePlusOrderVolume = () => {
dispatch(plusStockOrderVolume());
// 매수 -> 증가 버튼 클릭 시, 최대 구매수량 보다 낮으면 개수 1증가
if (!orderType) {
orderVolume < maximumBuyingVolume && dispatch(plusStockOrderVolume());
}
// 매도 -> 증가 버튼 클릭 시, 보유 주식수량 보다 낮으면 개수 1증가
if (orderType) {
orderVolume < dummyholdingStock && dispatch(plusStockOrderVolume());
}
};

const handleMinusOrderVolume = () => {
Expand All @@ -49,6 +57,13 @@ const VolumeSetting = () => {
}
};

// 지정가 증가 -> (현재 주문수량 > 최대 주문가능 수량)일 경우 -> 현재 주문수량을 최대 주문수량으로 변경
useEffect(() => {
if (maximumBuyingVolume < orderVolume) {
dispatch(setStockOrderVolume(maximumBuyingVolume));
}
}, [maximumBuyingVolume]);

return (
<Container>
<TitleContainer orderType={orderType}>
Expand Down

0 comments on commit 76e7535

Please sign in to comment.