Skip to content

Commit ebba2a9

Browse files
committed
[#35] 작품 상세페이지 관련 기능 세분화 및 새로운 작품 상세페이지로 들어갈 때 텍스트 스위칭 버그 수정
- 경매시작 / 입찰 / 구매확정 버튼 생성 - 기타 상황에 대해서도 안내 메세지 생성 - clearAuction action 생성 및 추가
1 parent 3d3492a commit ebba2a9

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

src/components/Common/Header/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Header() {
2323
});
2424

2525
const GoToPage = name => {
26-
history.replace(name);
26+
history.push(name);
2727
};
2828

2929
return (

src/components/Nfting/index.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,33 @@ function auctionNft({ props }) {
1717
} if (props.auction === 'START') { // 경매 중
1818
// 입찰
1919
return 2;
20-
} if (props.auction === 'DONE') { // 경매 완료
20+
} if (props.auction === 'FINISH') { // 경매 완료
2121
// "경매가 완료된 작품입니다."
2222
return 3;
23+
// 최고가 사람 === 나 {return 4} : 구매확정표시
2324
}
2425
return null;
2526
};
2627

28+
const handleButtonClick = (state) => {
29+
console.log(state);
30+
switch (state) {
31+
case 0:
32+
if (window.confirm('경매를 시작하겠습니까?')) {
33+
alert('경매가 시작되었습니다.');
34+
}
35+
break;
36+
case 2:
37+
if (userInfo.email === props.email) {
38+
window.confirm('본인작품에 입찰 하실 수 없습니다');
39+
} else if (window.confirm('경매에 참여하시겠습니까?')) {
40+
alert('입찰에 성공하셨습니다.');
41+
}
42+
break;
43+
default:
44+
}
45+
};
46+
2747
return (
2848
<>
2949
<Nfting>
@@ -71,20 +91,21 @@ function auctionNft({ props }) {
7191
{/* 판매자일 때 */}
7292
{auctionStat() === 0 ? (
7393
<div className="detail__button">
74-
<button type="button">경매시작</button>
94+
<button type="button" onClick={() => handleButtonClick(0)}>경매시작</button>
7595
</div>
7696
) : auctionStat() === 1 ? (
7797
<div className="detail__button">
7898
{/* <button type="button">구매확정</button> */}
79-
아직 경매시작 전 입니다.
99+
<span>⚠️ 경매시작 전 입니다.</span>
80100
</div>
81101
) : auctionStat() === 2 ? (
82102
<div className="detail__button">
83-
<button type="button">입찰</button>
103+
<button type="button" onClick={() => handleButtonClick(2)}>입찰</button>
84104
</div>
85105
) : auctionStat() === 3 ? (
86106
<div className="detail__button">
87-
<button type="button">경매가 종료된 작품입니다.</button>
107+
{/* <button type="button">경매가 종료된 작품입니다.</button> */}
108+
<span>경매가 종료된 작품입니다.</span>
88109
</div>
89110
) : null}
90111
</Border>

src/components/Nfting/styles.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,9 @@ export const Border = styled.div`
122122
text-align: right;
123123
line-height: 2;
124124
}
125+
.detail__button {
126+
span {
127+
font-weight: 600;
128+
}
129+
}
125130
`;

src/pages/auction/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect } from 'react';
22
import Header from 'components/Common/Header';
33
import { useSelector, useDispatch } from 'react-redux';
44
import Nfting from 'components/Nfting';
5-
import { LOAD_ONE_AUCTION_REQUEST } from 'reducers/auction';
5+
import { LOAD_ONE_AUCTION_REQUEST, clearAuction } from 'reducers/auction';
66

77
function auctionPost({ match }) {
88
const dispatch = useDispatch();
@@ -13,6 +13,9 @@ function auctionPost({ match }) {
1313
type: LOAD_ONE_AUCTION_REQUEST,
1414
data: match.params.id,
1515
});
16+
return () => {
17+
dispatch(clearAuction());
18+
};
1619
}, [match.params.id]);
1720

1821
return (

src/reducers/auction.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ export const CONFIRM_PURCHASE_REQUEST = 'CONFIRM_PURCHASE_REQUEST';
133133
export const CONFIRM_PURCHASE_SUCCESS = 'CONFIRM_PURCHASE_SUCCESS';
134134
export const CONFIRM_PURCHASE_FAILURE = 'CONFIRM_PURCHASE_FAILURE';
135135

136+
// 경매 작품 내용 비우기
137+
export const CLEAR_AUCTION = 'CLEAR_AUCTION';
138+
136139
export const addAuction = data => ({
137140
type: ADD_AUCTION_REQUEST,
138141
data,
@@ -160,6 +163,10 @@ export const confirmPurchase = data => ({
160163
data,
161164
});
162165

166+
export const clearAuction = () => ({
167+
type: CLEAR_AUCTION,
168+
});
169+
163170
const auctionReducer = (state = initialState, action) =>
164171
produce(state, draft => {
165172
switch (action.type) {
@@ -369,6 +376,9 @@ const auctionReducer = (state = initialState, action) =>
369376
draft.confirmPurchaseLoading = false;
370377
draft.confirmPurchaseError = action.error;
371378
break;
379+
case CLEAR_AUCTION:
380+
draft.singleAuction = {};
381+
break;
372382
default:
373383
break;
374384
}

0 commit comments

Comments
 (0)