-
Notifications
You must be signed in to change notification settings - Fork 5
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
[FE] 로그인 상태라면 행사 생성시 로그인 페이지를 띄우지 않음 #857
base: fe-dev
Are you sure you want to change the base?
Changes from all commits
5436939
b103f7c
8b749ec
97bd779
405a296
9b8cc62
8a6221f
df6b79f
4f8071b
4bac639
711e33a
e629535
4efbe3e
7cd4fb5
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// TODO: (@weadie) 반복되서 쓰이는 이 api/events가 추후 수정 가능성이 있어서 일단 편집하기 편하게 이 변수를 재사용하도록 했습니다. | ||
export const USER_API_PREFIX = '/api/events'; | ||
export const ADMIN_API_PREFIX = '/api/admin/events'; | ||
export const MEMBER_API_PREFIX = '/api/users'; | ||
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. 순간 제가 추가해둔 코드가 반영된 줄 알고 확인하고 와써욪.. 동일한 생각을 하셨군여 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. ㅋㅋㅋㅋㅋㅋㅋㅋ역시 다 똑같은 생각을 하고있었습니다 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import {UserInfo} from 'types/serviceType'; | ||
|
||
import {BASE_URL} from '@apis/baseUrl'; | ||
import {ADMIN_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix'; | ||
import {ADMIN_API_PREFIX, MEMBER_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix'; | ||
import {requestGet, requestGetWithoutResponse, requestPostWithoutResponse} from '@apis/fetcher'; | ||
import {WithEventId} from '@apis/withId.type'; | ||
|
||
|
@@ -42,3 +44,11 @@ export const requestGetKakaoLogin = async (code: string) => { | |
|
||
return null; | ||
}; | ||
|
||
export const requestGetUserInfo = async () => { | ||
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. 저는 user와 관련된 부분은 user.ts 파일을 생성하여 작성해줬는데요! 이 코드 또한 user.ts 파일로 가도 좋을 것 같네용! 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. 오 좋네요 API PREFIX도 나눠두었으니까 파일을 나눠도 괜찮겠습니다 |
||
return await requestGet<UserInfo>({ | ||
baseUrl: BASE_URL.HD, | ||
endpoint: `${MEMBER_API_PREFIX}/mine`, | ||
errorHandlingStrategy: 'unsubscribe', | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {Event, EventCreationData, EventId, EventName, User} from 'types/serviceType'; | ||
import {WithErrorHandlingStrategy} from '@errors/RequestGetError'; | ||
|
||
import {ADMIN_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix'; | ||
import {ADMIN_API_PREFIX, MEMBER_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix'; | ||
import {requestGet, requestPatch, requestPostWithResponse} from '@apis/fetcher'; | ||
import {WithEventId} from '@apis/withId.type'; | ||
|
||
|
@@ -47,7 +47,7 @@ export type RequestPatchUser = Partial<User>; | |
|
||
export const requestPatchUser = async (args: RequestPatchUser) => { | ||
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. 이 부분 또한 저도 웨디와 동일하게 변경해줬어요! |
||
return requestPatch({ | ||
endpoint: `/api/users`, | ||
endpoint: MEMBER_API_PREFIX, | ||
body: { | ||
...args, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ const QUERY_KEYS = { | |
images: 'images', | ||
kakaoClientId: 'kakao-client-id', | ||
kakaoLogin: 'kakao-login', | ||
userInfo: 'user-info', | ||
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. 저랑 이 내용 겹칠 것 같아서 충돌 잘 해결해봐요! |
||
}; | ||
|
||
export default QUERY_KEYS; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {useQuery} from '@tanstack/react-query'; | ||
import {useEffect} from 'react'; | ||
|
||
import {requestGetUserInfo} from '@apis/request/auth'; | ||
|
||
import QUERY_KEYS from '@constants/queryKeys'; | ||
|
||
export type UseRequestGetUserInfo = ReturnType<typeof useRequestGetUserInfo>; | ||
|
||
const useRequestGetUserInfo = () => { | ||
const {data, ...rest} = useQuery({ | ||
queryKey: [QUERY_KEYS.userInfo], | ||
queryFn: () => requestGetUserInfo(), | ||
// quernFn은 ErrorCatcher 구독을 하지 않으며 오류가 났을 경우 로그인 화면을 띄워야하므로 initialData를 설정했습니다. | ||
throwOnError: false, | ||
initialData: { | ||
isGuest: true, | ||
nickname: '', | ||
profileImage: '', | ||
accountNumber: '', | ||
bankName: '', | ||
}, | ||
initialDataUpdatedAt: 0, | ||
}); | ||
|
||
return { | ||
...data, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useRequestGetUserInfo; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,19 @@ export const authHandler = [ | |
return new HttpResponse(null, {status: 200}); | ||
}), | ||
|
||
http.get(`${MOCK_API_PREFIX}/api/users/mine`, () => { | ||
return HttpResponse.json( | ||
{ | ||
nickname: '크리스마스', | ||
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. 진짜 크리스마스가 얼마 남지 않았네요;; 벌써;;;; 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. All I Want For Christmas Is You~~~ |
||
isGuest: false, | ||
profileImage: '', | ||
bankName: '', | ||
accountNumber: '', | ||
}, | ||
{status: 200}, | ||
); | ||
}), | ||
|
||
// POST /api/eventId/login (requestPostToken) | ||
http.post<{eventId: string}, {password: string}>( | ||
`${MOCK_API_PREFIX}${USER_API_PREFIX}/:eventId/login`, | ||
|
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 호출이 필요하게 되었으므로 다시 돌려놓는 것이 옳다고 생각합니다.
랜딩 페이지 진입 속도 증가 vs 정산 시작하기 버튼 누를 때 메인에 오래 머물기 어떤 것이 더 치명적일 지 생각했을 때 저도 후자라고 생각하기 때문이에요