-
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 연동 #159
[Feat] 어드민 API 연동 #159
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.
이미지 업로드랑 무한스크롤 작업 하느라 고생많으셨습니다!! 🥹
타입스크립트 정말 잘하시는 것 같아용,, 많이 배워갑니다 :)
const handleChangeDate = (changeIdx: number, newDate: string) => { | ||
const selectedItem = rushList[changeIdx]; | ||
const selectedTime = selectedItem.startTime || "00:00"; | ||
const selectedDateTime = new Date(`${newDate}T${selectedTime}`).getTime(); | ||
const currentTime = new Date().getTime(); | ||
const endDateTime = new Date(`${newDate}T${selectedItem.endTime || "23:59"}`).getTime(); |
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.
new Date().getTime() -> 몇군데 보이는데 여기두 client에서 만든 getMsTime 유틸 적용 가능할까여?
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.
de33a99 오호 좋아용 반영했습니다!
if (selectedFile instanceof File) { | ||
const formData = new FormData(); | ||
formData.append("image", selectedFile); | ||
postImage(formData); |
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.
요기 비동기함수 같은데 await 붙이지 않은 이유가 있는걸까용?
RushSelectForm에서는 postImage 호출할 때 await 붙어있는 것 같아서여!
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.
동기적으로 동작할 필요가 없는 곳에서는 await 붙일 필요가 없으니까 안 붙여줬어요! RushSelectForm에서 postImage 할 때도 안 붙여도 되는데 코드 짜다가 잘못 들어갔나보네욥,,ㅎ
.map((file, index) => { | ||
if (!(file instanceof File)) { | ||
return null; | ||
} | ||
const formData = new FormData(); | ||
formData.append("image", file); | ||
return { formData, index }; | ||
}) | ||
.filter((item): item is { formData: FormData; index: number } => item !== null); |
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.
저희 전에 index를 idx로 맞추기로 했었는데, 혹싀 index라고 쓴 이유가 있나용??
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.
어드민이라고 별 생각없이 했나봐욥,, 수정했습니다! f0b236d
|
||
export default function useFetch<T, P = void>(fetch: (params: P) => Promise<T>, showError = true) { | ||
export default function useFetch<T, P = void>( | ||
fetch: (params: P, token: string) => Promise<T>, |
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.
client에서는 토큰 인자를 따로 넣지 않았던 것 같은데 여기는 넣어준 이유가 뭔가용?? admin에서는 항상 인증 토큰이 필요하기 때문인가요??
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.
넵 어드민은 로그인 API 제외하고는 인증 토큰이 필요해서 넣어줬어용
admin/src/utils/validateDateTime.ts
Outdated
return "시작 날짜와 시간은 현재 시간보다 빠를 수 없습니다!"; | ||
} | ||
if (startDateTime > endDateTime) { | ||
return "시작 날짜와 시간이 종료 날짜와 시간보다 빠를 수 없습니다!"; |
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/utils/validateDateTime.ts
Outdated
|
||
if (key === "endDate" || key === "endTime") { | ||
if (endDateTime < startDateTime) { | ||
return "종료 날짜와 시간이 시작 날짜와 시간보다 느릴 수 없습니다!"; |
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.
if (startDateTime < currentDateTime) {
return "시작 날짜와 시간은 현재 시간보다 빠를 수 없습니다!";
}
위 문구가 맞는 말이라면 이 부분도 아래처럼 고쳐야지 않을까 싶네용
(endDateTime < startDateTime) -> 여기서 종료 부분이 시작 부분보다 숫자가 빠르다고 설정되어있으니까 아래처럼 쓰는게 맞을 것 같아영
"종료 날짜와 시간이 시작 날짜와 시간보다 빠를 수 없습니다!"
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.
말해준 부분들 둘 다 수정했어요! 31f8bf3
@@ -45,10 +57,9 @@ export default function useInfiniteFetch<T>({ | |||
const lastPage = await fetch(currentPageParam); | |||
const nextPageParam = getNextPageParam(currentPageParam, lastPage); | |||
|
|||
setData([...data, ...lastPage.participants]); | |||
setData([...data, ...getDataList(lastPage)]); |
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.
setData(prevData => [...prevData, ...getDataList(lastPage)]);
예전에 효정님 코드가 생각났는데 좀 더 정확한 상태 유지를 위해서 prevData 써서 이전 상태 기반으로 업데이트 해주면 어떨까용?
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.
이거 요런식으로 고치면 처음에 불러오는 page 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.
헉 그렇군용,, 좋습니다 !! :)
admin/src/hooks/useInfiniteFetch.ts
Outdated
const getDataList = (lastPage: R) => { | ||
if (isInfiniteParticipantListData<T>(lastPage)) { | ||
setTotalLength(lastPage.totalParticipants); | ||
return lastPage.participantsList; | ||
} else if (isInfiniteExpectationListData<T>(lastPage)) { | ||
setTotalLength(lastPage.totalExpectations); | ||
return lastPage.expectations; | ||
} | ||
|
||
return []; | ||
}; |
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.
여기 getDataList도 useCallback로 묶어주는건 어떤가용?
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.
좋은 생각이에욤 반영했습니당 69886df
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.
LotteryParticipantList랑 LotteryWinnerList에 중복 코드가 매우 많은데 공통으로 분리해서 사용할 수 있는 방법도 고려해보면 좋을 것 같아여!
빌드를 성공했습니다! 🎉 |
🖥️ Preview
close #148
✏️ 한 일
❗️ 발생한 이슈 (해결 방안)
Modal 내부 무한 스크롤이 발생하지 않는 문제가 있어서 요렇게 해결했습니당 >> wiki
❓ 논의가 필요한 사항