Skip to content

Commit d1aabd1

Browse files
committed
[#50] 경매 완료 시 정보 표시
1 parent d246483 commit d1aabd1

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

src/components/Nfting/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
startAuction,
77
participateAuction,
88
checkAuction,
9+
justCheckAuction,
910
} from 'reducers/auction';
1011
import useInterval from 'hooks/useInterval';
1112
import { Nfting, Images, Detail, Border } from './styles';
@@ -16,6 +17,10 @@ function auctionNft({ props, status }) {
1617
console.log('=======props', props);
1718
console.log('=======props', props.auction);
1819

20+
// if (status === 'FINISH') {
21+
// console.log('hello');
22+
// dispatch(checkAuction(props.id, props.email));
23+
// }
1924
useInterval(
2025
() => {
2126
dispatch(checkAuction(props.id, props.email));
@@ -24,6 +29,14 @@ function auctionNft({ props, status }) {
2429
status === 'START' ? 3000 : null,
2530
);
2631

32+
useEffect(() => {
33+
console.log('useEffect 들어옴');
34+
if (status === 'FINISH') {
35+
console.log('hello');
36+
dispatch(justCheckAuction(props.id));
37+
}
38+
}, [status]);
39+
2740
const auctionStat = () => {
2841
if (status === 'READY') {
2942
if (userInfo.email === props.email) {

src/reducers/auction.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ export const initialState = {
8484
checkAuctionDone: false,
8585
checkAuctionError: null,
8686

87+
// 경매 결과 조회
88+
justCheckAuctionLoading: false,
89+
justCheckAuctionDone: false,
90+
justChekcAuctionError: null,
91+
8792
// 경매 종료
8893
terminateAuctionLoading: false,
8994
terminateAuctionDone: false,
@@ -158,6 +163,11 @@ export const CHECK_AUCTION_REQUEST = 'CHECK_AUCTION_REQUEST';
158163
export const CHECK_AUCTION_SUCCESS = 'CHECK_AUCTION_SUCCESS';
159164
export const CHECK_AUCTION_FAILURE = 'CHECK_AUCTION_FAILURE';
160165

166+
// 경매 결과 조회
167+
export const JUST_CHECK_AUCTION_REQUEST = 'JUST_CHECK_AUCTION_REQUEST';
168+
export const JUST_CHECK_AUCTION_SUCCESS = 'JUST_CHECK_AUCTION_SUCCESS';
169+
export const JUST_CHECK_AUCTION_FAILURE = 'JUST_CHECK_AUCTION_FAILURE';
170+
161171
// 경매종료
162172
export const TERMINATE_AUCTION_REQUEST = 'TERMINATE_AUCTION_REQUEST';
163173
export const TERMINATE_AUCTION_SUCCESS = 'TERMINATE_AUCTION_SUCCESS';
@@ -215,6 +225,11 @@ export const checkAuction = (data, owner) => ({
215225
owner,
216226
});
217227

228+
export const justCheckAuction = data => ({
229+
type: JUST_CHECK_AUCTION_REQUEST,
230+
data,
231+
});
232+
218233
export const terminateAuction = data => ({
219234
type: TERMINATE_AUCTION_REQUEST,
220235
data,
@@ -470,6 +485,22 @@ const auctionReducer = (state = initialState, action) =>
470485
draft.checkAuctionLoading = false;
471486
draft.checkAuctionError = action.error;
472487
break;
488+
489+
case JUST_CHECK_AUCTION_REQUEST:
490+
draft.justCheckAuctionLoading = true;
491+
draft.justCheckAuctionDone = false;
492+
draft.justChekcAuctionError = action.error;
493+
break;
494+
case JUST_CHECK_AUCTION_SUCCESS:
495+
draft.justCheckAuctionLoading = false;
496+
draft.justCheckAuctionDone = true;
497+
draft.singleAuction.curStatus = action.data;
498+
break;
499+
case JUST_CHECK_AUCTION_FAILURE:
500+
draft.justCheckAuctionLoading = false;
501+
draft.justChekcAuctionError = action.error;
502+
break;
503+
473504
case TERMINATE_AUCTION_REQUEST:
474505
draft.terminateAuctionLoading = true;
475506
draft.terminateAuctionDone = false;

src/sagas/auction.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ import {
7777
TERMINATE_AUCTION_FAILURE,
7878
TERMINATE_AUCTION_SUCCESS,
7979
TERMINATE_AUCTION_REQUEST,
80+
JUST_CHECK_AUCTION_REQUEST,
81+
JUST_CHECK_AUCTION_SUCCESS,
8082
} from '../reducers/auction';
8183

8284
// home 모든 경매템 로드
@@ -455,18 +457,21 @@ function* checkAuction(action) {
455457
}
456458
}
457459

460+
function* justCheckAuction(action) {
461+
const result = yield call(checkAuctionAPI, action.data);
462+
yield put({
463+
type: JUST_CHECK_AUCTION_SUCCESS,
464+
data: result.data,
465+
});
466+
}
467+
458468
function terminateAuctionAPI(data) {
459469
console.log(data);
460470
const response = instance({
461471
method: 'post',
462472
url: 'main/NFT/auction/finish',
463473
data,
464474
});
465-
// const dummy = {
466-
// data: {
467-
// status: 'complete',
468-
// },
469-
// };
470475
return response;
471476
}
472477

@@ -544,6 +549,11 @@ function* watchCheckAuction() {
544549
yield takeLatest(CHECK_AUCTION_REQUEST, checkAuction);
545550
}
546551

552+
// 경매 상태 로딩
553+
function* watchJustCheckAuction() {
554+
yield takeLatest(JUST_CHECK_AUCTION_REQUEST, justCheckAuction);
555+
}
556+
547557
// 경매 종료 로딩
548558
function* watchTerminateAuction() {
549559
yield takeLatest(TERMINATE_AUCTION_REQUEST, terminateAuction);
@@ -563,6 +573,7 @@ export default function* auctionSaga() {
563573
fork(watchStartAuctions),
564574
fork(watchParticipateAuctions),
565575
fork(watchCheckAuction),
576+
fork(watchJustCheckAuction),
566577
fork(watchTerminateAuction),
567578
]);
568579
}

0 commit comments

Comments
 (0)