-
Notifications
You must be signed in to change notification settings - Fork 1
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] 어드민 - API 연동 #139
[Feat] 어드민 - API 연동 #139
Conversation
빌드를 성공했습니다! 🎉 |
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.
수고 많으셨어용 ㅠㅠ 화이팅🩷
admin/src/pages/Lottery/index.tsx
Outdated
<Button buttonSize="sm" onClick={() => navigate("/lottery/participant-list")}> | ||
참여자 리스트 보러가기 | ||
</Button> | ||
<Button | ||
buttonSize="sm" | ||
onClick={() => | ||
navigate("/lottery/winner-list", { | ||
state: { id: lottery.lotteryEventId }, | ||
}) | ||
} | ||
> | ||
<Button buttonSize="sm" onClick={() => navigate("/lottery/winner")}> | ||
당첨자 추첨하기 | ||
</Button> | ||
<Button buttonSize="sm" onClick={() => navigate("/lottery/winner-list")}> | ||
당첨자 보러가기 | ||
</Button> |
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.
여기 공통 로직 분리하는 건 너무 사치일까용..?
const buttons = [
{ path: "/lottery/participant-list", label: "참여자 리스트 보러가기" },
{ path: "/lottery/winner", label: "당첨자 추첨하기" },
{ path: "/lottery/winner-list", label: "당첨자 보러가기" },
];
....
{buttons.map((button, idx) => (
<Button
key={idx}
buttonSize="sm"
onClick={() => navigate({button.path})}
>
{button.label}
</Button>
))}
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.
중간에 state 넣는건 생각 못했다만...
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 만으로 충분히 공통 로직을 묶어준 느낌이라서 buttons 배열로까지는 안 묶어줘두 될 것 같아요! 오히려 코드가 더 길어지기도 하구용,,,
export function getDateDifference(startDate: string, endDate: string) { | ||
const dateRegex = /^\d{4}-\d{2}-\d{2}$/; | ||
|
||
if (!startDate || !endDate || !startDate.match(dateRegex) || !endDate.match(dateRegex)) { | ||
return ""; | ||
} | ||
|
||
const start = new Date(startDate); | ||
const end = new Date(endDate); | ||
|
||
const differenceInTime = end.getTime() - start.getTime(); | ||
const differenceInDays = Math.ceil(differenceInTime / (1000 * 3600 * 24)); | ||
|
||
return `${differenceInDays}일`; | ||
} |
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.
이런식으로 시간 차이 구하는 로직 따로 빼서 사용하는 것도 좋은 방식인 것 같아용!
빌드를 성공했습니다! 🎉 |
빌드를 성공했습니다! 🎉 |
빌드를 성공했습니다! 🎉 |
빌드를 성공했습니다! 🎉 |
빌드를 성공했습니다! 🎉 |
🖥️ Preview
close #137
✏️ 한 일
❗️ 발생한 이슈 (해결 방안)
실제 API 연동은 아니고 명세서 기반으로 mock Promise 만들어서 연동해뒀습니다. 추후 API 완성되는대로 연결 테스트 해보겠습니다.
❓ 논의가 필요한 사항