Skip to content

Commit

Permalink
[Add] 주식주문 관련 회원정보 불러오는 로직 일부 수정
Browse files Browse the repository at this point in the history
- 주식주문 관련 정보 중 보유자금, 거래내역 등 로그인과 결부된 데이터 fetching 관련된 로직 일부 수정
- 사유 : fetching 로직의 문제가 아닌 현재 구현된 로그인 방식이 문제의 원인이므로 (Access Token이 만료되었음에도 갱신 없이 자동 로그인 되고 있었음) fetching 관련된 로직은 이전의 코드로 다시 복구 (더 깔끔하고 간결하기 때문에)
- 중간에 타 commit이 포함되어 있어 Git reset이 아닌 복구 후 commit 남기는 방법을 택함 (일부 코드 몇줄만 수정하면 되므로)

Issues #17
  • Loading branch information
novice1993 committed Sep 13, 2023
1 parent d9fbc3e commit 91c32ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
11 changes: 2 additions & 9 deletions client/src/hooks/useGetCash.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect } from "react";
import { useQuery } from "react-query";
import { useSelector } from "react-redux";
import axios from "axios";
Expand All @@ -10,14 +9,8 @@ const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080
const useGetCash = () => {
const isLogin = useSelector((state: StateProps) => state.login);

useEffect(() => {
if (isLogin === 1) {
refetch();
}
}, [isLogin]);

const { data, isLoading, isError, refetch } = useQuery("cash", getCashData, {
enabled: false,
const { data, isLoading, isError } = useQuery("cash", getCashData, {
enabled: isLogin === 1,
});

return { cashData: data, cashLoading: isLoading, cashError: isError };
Expand Down
11 changes: 2 additions & 9 deletions client/src/hooks/useGetHoldingStock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect } from "react";
import { useQuery } from "react-query";
import { useSelector } from "react-redux";
import axios from "axios";
Expand All @@ -9,14 +8,8 @@ const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080
const useGetHoldingStock = () => {
const isLogin = useSelector((state: StateProps) => state.login);

useEffect(() => {
if (isLogin === 1) {
refetch();
}
}, [isLogin]);

const { data, isLoading, isError, refetch } = useQuery("holdingStock", getHoldingStock, {
enabled: false,
const { data, isLoading, isError } = useQuery("holdingStock", getHoldingStock, {
enabled: isLogin === 1,
});
return { holdingStockData: data, holdingStockLoading: isLoading, holdingStockError: isError };
};
Expand Down
10 changes: 2 additions & 8 deletions client/src/hooks/useGetStockOrderRecord.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect } from "react";
import { useQuery } from "react-query";
import { useSelector } from "react-redux";
import axios from "axios";
Expand All @@ -9,13 +8,8 @@ const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080
const useGetStockOrderRecord = () => {
const isLogin = useSelector((state: StateProps) => state.login);

useEffect(() => {
if (isLogin === 1) {
refetch();
}
}, [isLogin]);
const { data, isLoading, isError, refetch } = useQuery("orderRecord", getOrderRecord, {
enabled: false,
const { data, isLoading, isError } = useQuery("orderRecord", getOrderRecord, {
enabled: isLogin === 1,
});

return { orderRecordData: data, orderRecordLoading: isLoading, orderRecordError: isError };
Expand Down

0 comments on commit 91c32ad

Please sign in to comment.