-
Notifications
You must be signed in to change notification settings - Fork 2
[Feat] 탈퇴한 사용자 '알 수 없음' 처리 #636
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
Changes from all commits
8a1950f
b925b16
fa5b9f6
fa465b8
5ed19aa
530bc49
deb6859
44a52d9
e383aab
e7a5a99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { Navigate, Outlet, useParams } from 'react-router-dom'; | ||
| import { useGetLessonDetail } from '@/pages/class/apis/queries'; | ||
| import { ROUTES_CONFIG } from '@/routes/routesConfig'; | ||
| import { WITHDRAW_USER_NAME } from '@/shared/constants/withdrawUser'; | ||
|
|
||
| export const ReservationGuard = () => { | ||
| const { id } = useParams<{ id: string }>(); | ||
| const lessonId = Number(id); | ||
|
|
||
| const isValidLessonId = Number.isInteger(lessonId) && lessonId > 0; | ||
|
|
||
| const { data, isPending, isError } = useGetLessonDetail(lessonId, { | ||
| enabled: isValidLessonId, | ||
| }); | ||
|
|
||
| if (!isValidLessonId) { | ||
| return <Navigate to={ROUTES_CONFIG.error.path} replace />; | ||
| } | ||
|
|
||
| if (isPending) return null; | ||
|
|
||
| if (isError || !data) { | ||
| return <Navigate to={ROUTES_CONFIG.error.path} replace />; | ||
| } | ||
|
Comment on lines
+16
to
+24
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isValidLessonId와 error/data 조건 처리에 대한 return 값이 같은데 한번에 처리하는 것은 너무 가독성이 별로일까요?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isValidLessonId와 isError / !data는 의미상 역할이 다르다고 생각해서 분리해두는 쪽이 의도를 읽기에는 더 낫다고 판단했습니다! 다만 가드 관련 로직이 점점 필요한 부분에 추가되는 형태가 되고 있어서, |
||
|
|
||
| const { status, bookStatus, teacherNickname, isMyLesson } = data; | ||
|
|
||
| const isButtonEnabled = | ||
| status === 'OPEN' && isMyLesson === false && bookStatus === false && teacherNickname !== WITHDRAW_USER_NAME; | ||
|
|
||
| if (!isButtonEnabled) { | ||
| return <Navigate to={ROUTES_CONFIG.class.path(lessonId.toString())} replace />; | ||
| } | ||
|
|
||
| return <Outlet />; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const WITHDRAW_USER_NAME = '알 수 없음'; |
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.
해당 조건 문자열 비교 이외에 다른 방법은 없을까요??
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 기준으로 탈퇴 여부를 구분할 수 있는 값이
nickname: "알 수 없음",profileImage: null,detail: "탈퇴한 회원입니다."이렇게 세 가지가 있습니다.이 중에서
"탈퇴한 회원입니다."가 의미상 가장 명확하게 탈퇴 여부를 표현하고 있다고 판단해서 현재는 detail 값을 기준으로 분기 처리했습니다.다만 다른 곳에서는
nickname을 기준으로 처리를 하고 있어서 일관성을 위해 이 로직도nickname기준으로 통일하는 것이 더 나을지 고민이 되네요 ..이 부분에 대해 의견 주시면 그에 맞춰 수정하겠습니다 ㅎㅎ