-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] 보유현금 및 최대 매도가능 수량 설정 관련 기능 구현
- 주식주문 시 필요한 회원별 보유현금 데이터 렌더링 및 처리 가능 - 매도 거래 관련 최대 거래량 설정 시 현재 각 회원이 보유한 회사별 주식만큼만 설정할 수 있도록 설정 (보유 주식 중 거래량이 없어 거래대기로 분류된 주식 수도 차감) Issues #17
- Loading branch information
1 parent
97b5a6b
commit 015e94d
Showing
9 changed files
with
166 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useQuery } from "react-query"; | ||
import { useSelector } from "react-redux"; | ||
import axios from "axios"; | ||
import { StateProps } from "../models/stateProps"; | ||
|
||
// 🔴 API 수정 전으로 임시 파라미터 설정해놓음 | ||
const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/cash/3"; | ||
|
||
const useGetCash = () => { | ||
const isLogin = useSelector((state: StateProps) => state.login); | ||
const { data, isLoading, isError } = useQuery("cash", getCashData, { | ||
enabled: isLogin === 1, | ||
}); | ||
|
||
return { cashData: data, cashLoading: isLoading, cashError: isError }; | ||
}; | ||
|
||
export default useGetCash; | ||
|
||
const getCashData = async () => { | ||
const token = localStorage.getItem("authToken"); | ||
const options = { | ||
headers: { | ||
Authorization: `${token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}; | ||
|
||
const response = await axios.get(url, options); | ||
const cash = await response.data.money; | ||
return cash; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useQuery } from "react-query"; | ||
import { useSelector } from "react-redux"; | ||
import axios from "axios"; | ||
import { StateProps } from "../models/stateProps"; | ||
|
||
const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/stock/stockholds"; | ||
|
||
const useGetHoldingStock = () => { | ||
const isLogin = useSelector((state: StateProps) => state.login); | ||
const { data, isLoading, isError } = useQuery("holdingStock", getHoldingStock, { | ||
enabled: isLogin === 1, | ||
}); | ||
return { holdingStockData: data, holdingStockLoading: isLoading, holdingStockError: isError }; | ||
}; | ||
|
||
export default useGetHoldingStock; | ||
|
||
const getHoldingStock = async () => { | ||
const authToken = localStorage.getItem("authToken"); | ||
const options = { | ||
headers: { | ||
Authorization: `${authToken}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}; | ||
|
||
const response = await axios.get(url, options); | ||
const holdingStock = await response.data; | ||
return holdingStock; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useQuery } from "react-query"; | ||
import { useSelector } from "react-redux"; | ||
import axios from "axios"; | ||
import { StateProps } from "../models/stateProps"; | ||
|
||
const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/stock/stockorders"; | ||
|
||
const useGetStockOrderRecord = () => { | ||
const isLogin = useSelector((state: StateProps) => state.login); | ||
const { data, isLoading, isError } = useQuery("record", getOrderRecord, { | ||
enabled: isLogin === 1, | ||
}); | ||
|
||
return { orderRecordData: data, orderRecordLoading: isLoading, orderRecordError: isError }; | ||
}; | ||
|
||
export default useGetStockOrderRecord; | ||
|
||
const getOrderRecord = async () => { | ||
const authToken = localStorage.getItem("authToken"); | ||
const options = { | ||
headers: { | ||
Authorization: `${authToken}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}; | ||
|
||
const response = await axios.get(url, options); | ||
const orderRecord = await response.data; | ||
return orderRecord; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters