-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] : 공고상세페이지 분기, 마이페이지 #57
[feat] : 공고상세페이지 분기, 마이페이지 #57
Conversation
{
"success": true,
"response": {
"boardId": 1,
"shopName": "전남대 후문 스타벅스",
"destination": "전남대 공대7 217호관",
"beverage": [
{
"name": "핫 아메리카노"
},
{
"name": "아이스 아메리카노"
}
],
"tip": 1000,
"request": "빨리 와주세요",
"finishedAt": 1696073040,
"isMatch": true,
"same": true
},
"error": null
}
위 2가지 내용에 따라 분기 처리 되도록 코드를 큰 틀에서 작성해주시면 될 것 같습니다! |
src/pages/PostDetailWriterPage.jsx
Outdated
// 매칭 됐는지 안됐는지(true면 피커정보랑 더보기 없어짐) | ||
const isMatch = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 response 변경사항에 따라, 이 부분은 상위 컴포넌트에서 isMatch & same
을 한꺼번에 받아서 조건에 따라 하위 컴포넌트인 PostDetailWriterPage
를 보여주도록 리팩토링 하면 좋을 것 같습니다 :)
src/pages/PostDetailWriterPage.jsx
Outdated
// 매칭 됐는지 안됐는지(true면 피커정보랑 더보기 없어짐) | ||
const isMatch = false; | ||
|
||
// 삭제 버튼 눌렀을 때 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 아래의 Swal.fire
부분은 제가 따로 만들어놓은 utils/alert.js
라는 Swal
알림 전용 파일이 있어요!
그 부분에다가 따로 빼놓고 사용하시면 좀 더 깔끔해 보이실 거에요!
src/pages/PostDetailWriterPage.jsx
Outdated
const pickerInfo = (isMatch) => { | ||
if (isMatch) { | ||
return ( | ||
<div> | ||
<div className="my-8"> | ||
<div className="text-2xl text-blue py-2">피커정보</div> | ||
<div className="flex"> | ||
<div className="text-zinc-400">도착시간</div> | ||
<div className="ml-5">3000원</div> | ||
</div> | ||
<div className="flex my-1"> | ||
<div className="text-zinc-400">계좌정보</div> | ||
<div className="ml-5">농협 01010101010101010101</div> | ||
</div> | ||
<div className="flex my-1"> | ||
<div className="text-zinc-400">계좌정보</div> | ||
<div className="ml-5">010-1234-5678</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
// eslint-disable-next-line | ||
const threeDot = (isMatch) => { | ||
if (!isMatch) { | ||
return <BsThreeDotsVertical size="25" style={{ color: 'white' }} />; | ||
} | ||
}; | ||
|
||
const matching = () => { | ||
if (isMatch) { | ||
console.log(isMatch); | ||
return ( | ||
<div> | ||
<div className="text-white text-lg">피커가 픽업을 시작했어요!</div> | ||
<div className="text-white text-lg">피커에게 픽업팁을 송금 해주세요.</div> | ||
</div> | ||
); | ||
} | ||
return <div className="mt-1 text-white text-xl">매칭을 기다리고 있어요.</div>; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
매칭이 되어있으면 특정 내용을 보여주고, 매칭이 되어있지 않으면 사라지게 하도록 하기 위해 작성하신 코드 인것 같네요! 그런데 이 부분은 멘토님께서 피드백해주셨을 때 말씀해주셨듯이, 하나의 페이지에서 이러한 정보에 따라 일일이 변화를 주기에는 코드가 복잡해질 수 있다고 하셨던 것 기억나시나요?!
조건에 따른 분기는 상위 컴포넌트에서 처리
하위 컴포넌트에서는 이제 분기이후에 받아온 데이터들을 렌더링
하도록 코드를 짜면 좋을 것 같습니다!
안녕하세요 단빈님. 작성하신 코드는 전부 잘 읽어보았습니다! 공고 상세 페이지에서의 분기 처리저희가 백엔드로부터 데이터를 받아와서 컴포넌트를 상황에 맞게 보여주는데 필요한 정보는 2개가 있습니다.
따라서, 어떻게 하면 깔끔한 구조의 컴포넌트를 만들 수 있을까이 부분은 저도 그렇게 잘 알고있는 건 아니지만, 그래도 다음과 같은 구성으로 하면 어떨까 생각해보았습니다.
별도로 드리고 싶은 말씀!
커밋진행시, 터미널에서
이런식으로 작성해주시면, 단빈님과 다른 팀원분들이 볼 때 좀 더 편하고 빠르게 커밋 내용을 파악할 수 있어 좋아요!
저희 서비스가 돌아가기 위해서는 오더 - 피커 간에 매칭이 정상적으로 이루어져야 합니다!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/pages/PostDetailPage.jsx
Outdated
const pickUpBtn = (isMatched) => { | ||
if (isMatched) { | ||
return ( | ||
<Button bgColor="bg-zinc-300" disabled="disable"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Button bgColor="bg-zinc-300" disabled="disable"> | |
<Button bgColor="bg-zinc-300" disabled> |
disabled
만 입력해도 비활성화처리가 됩니다!
src/pages/PostDetailPage.jsx
Outdated
}; | ||
|
||
// 공고상세페이지 처음 눌렀을 때 뜨는 정보 | ||
const info = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
하드코딩 부분은 useQuery()
를 통해 백엔드로부터 data를 받아오고, 그 data를 하드코딩한 부분에 대체해주시면 됩니다! 막히는 부분이 있다면 사소한거라도 슬랙에 남겨주세요!
src/pages/PostDetailPage.jsx
Outdated
<div className=" text-sm">오더의 장소에 도착할 시간을 알려주세요.</div> | ||
</div> | ||
<div className="mt-6"> | ||
<input className="text-center" type="number" placeholder="15" style={{ border: 1 }} /> 분 후 도착 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
border를 인라인 스타일로 따로 지정하신 이유가 궁금합니다! 보통 Input
컴포넌트는 다 똑같은 스타일이기 때문에 별도로 지정을 안해도 될 것 같다고 생각해서요.
그리고 이건 제가 잘못한 부분인데 여기 input창 넓이를 좀 줄여주실 수 있을까요?(와이어프레임에 방금 반영해뒀어요..ㅠ) 그 부분을 저번에 과제 제출전에 급하게 진혁님이 바꿔주신거라 입력할 정보가 숫자뿐인데도 넓이를 길게 잡아두셔서요...
src/pages/PostDetailPage.jsx
Outdated
const nowPage = (pageNum) => { | ||
if (pageNum === 1) { | ||
return pickerTime(); | ||
} | ||
return info(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분 상위에 페이지 컴포넌트를 하나더 만들어서, pageNum
이 1일때는 pickerTime
컴포넌트를 리턴, 0일때는 info
컴포넌트를 리턴하는 게 좋을 것 같아요!
그럼 일단 info
와 pickerTime
을 컴포넌트로 빼주시고 진행하시면 될 것 같아요~
src/pages/PostDetailPage.jsx
Outdated
const cancel = () => { | ||
setPage(0); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수명을 좀 더 명확하게 짓는 게 어떨까요? 픽업을 취소한다는 의미가 내포되었으면 좋겠어요!
src/pages/PostDetailPage.jsx
Outdated
const pickUpBtnModal = () => { | ||
return Swal.fire({ | ||
title: '이 음료를 픽업하시겠습니까?', | ||
showCancelButton: true, | ||
cancelButtonText: '취소', | ||
confirmButtonText: '수락', | ||
confirmButtonColor: '#0075ff', | ||
heightAuto: true, | ||
}).then((result) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 마찬가지로 utils/alert.js
로 빼주세요! 저도 빼려구요,,!!!
src/pages/PostDetailWriterPage.jsx
Outdated
// eslint-disable-next-line | ||
const threeDot = (isMatch) => { | ||
if (!isMatch) { | ||
return <BsThreeDotsVertical size="25" style={{ color: 'white' }} />; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 eslint를 꺼둔 이유가 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
threeDot
은 매칭 됐을 때 뿐만 아니라 이 글의 작성자가 아닐 때도 보이지 않게 짜주셔야 할 것 같습니다!
src/pages/PostDetailWriterPage.jsx
Outdated
// eslint-disable-next-line | ||
const pickerInfo = (isMatch) => { | ||
if (isMatch) { | ||
return ( | ||
<div> | ||
<div className="my-8"> | ||
<div className="text-2xl text-blue py-2">피커정보</div> | ||
<div className="flex"> | ||
<div className="text-zinc-400">도착시간</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint를 꺼둔 이유가 궁금합니다!
src/pages/PostDetailWriterPage.jsx
Outdated
<div> | ||
<div className="text-white text-lg">피커가 픽업을 시작했어요!</div> | ||
<div className="text-white text-lg">피커에게 픽업팁을 송금 해주세요.</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div> | |
<div className="text-white text-lg">피커가 픽업을 시작했어요!</div> | |
<div className="text-white text-lg">피커에게 픽업팁을 송금 해주세요.</div> | |
</div> | |
<div className="text-white text-lg"> | |
<div>피커가 픽업을 시작했어요!</div> | |
<div>피커에게 픽업팁을 송금 해주세요.</div> | |
</div> |
동일한 스타일을 반복하지 않고 이렇게 쓸 수도 있을 것 같아요!
제거 여러번 해매서 아직 하드코딩 한 부분은 못바꿔서 마이페이지 먼저 해볼려구요..
이거 하는데 좀 헤매서.. 아직 하드코딩은 못바꿨어요..
아직 마이페이지 구현이랑 하드코딩을 못했어요
PR 타입(하나 이상의 PR 타입을 선택해주세요)
작업 사항
관련 이슈