Conversation
❌ Deploy Preview for we-write failed.
|
juyesu
left a comment
There was a problem hiding this comment.
방향성 자체는 굉장히 좋은 것 같습니다! 병합 이전에 추가로 작업해야 하는 내용이 많을까요? 아니면 별도의 브랜치로 진행하실 예정일까요?
| if (!data) { | ||
| throw new Error('User not found'); | ||
| } |
There was a problem hiding this comment.
에러 처리 로직을 위해서 명헌님께서 개발해주신 handleError() 공통 함수를 사용해주셔도 좋을 것 같습니다
| value={{ | ||
| isSignIn, | ||
| myInfo, | ||
| userInfo, |
There was a problem hiding this comment.
반환하는 데이터의 네이밍이 myInfo, userInfo라서 차이를 구분하기 어려울 것 같은데, 명확한 네이밍으로 변경해주시면 좋을 것 같아요!
| }: AuthProviderClientProps) => { | ||
| const { data: myInfo, ...rest } = useGetMyInfo(accessToken ?? ''); | ||
| const { data: userInfo } = useQuery<UserInfoResponse | null>({ | ||
| queryKey: ['userInfo'], |
There was a problem hiding this comment.
queryKey.ts에 상수화시켜놓은 다른 쿼리 키들처럼 해당 키도 상수로 사용하면 좋을 것 같습니다
| isSignIn, | ||
| }: AuthProviderClientProps) => { | ||
| const { data: myInfo, ...rest } = useGetMyInfo(accessToken ?? ''); | ||
| const { data: userInfo } = useQuery<UserInfoResponse | null>({ |
There was a problem hiding this comment.
타입 추론 에러가 발생해서 제네릭을 사용해주신 걸까요?
| if (error) { | ||
| throw new Error(error.message); | ||
| } | ||
| return data; | ||
| }; | ||
|
|
||
| export const signin = async (user: SigninRequest) => { | ||
| const { data, error } = await instanceBaaS.auth.signInWithPassword({ | ||
| email: user.email, | ||
| password: user.password, | ||
| }); | ||
| if (error) { | ||
| throw new Error(error.message); | ||
| } | ||
| const cookieStore = await cookies(); | ||
| cookieStore.set('access_token', data.session.access_token); | ||
| cookieStore.set('refresh_token', data.session.refresh_token); | ||
| return data; | ||
| }; | ||
|
|
||
| export const signout = async () => { | ||
| const cookieStore = await cookies(); | ||
| cookieStore.delete('access_token'); | ||
| cookieStore.delete('refresh_token'); | ||
| }; | ||
|
|
||
| export const getUserInfo = async (): Promise<UserInfoResponse | null> => { | ||
| const cookieStore = await cookies(); | ||
| const accessToken = cookieStore.get('access_token'); | ||
| const refreshToken = cookieStore.get('refresh_token'); | ||
| if (!accessToken || !refreshToken) { | ||
| return null; | ||
| } | ||
| const { data, error } = await instanceBaaS.auth.getUser(accessToken.value); | ||
| const { data: user, error: userError } = await instanceBaaS | ||
| .from('users') | ||
| .select('*') | ||
| .eq('email', data.user?.email ?? '') | ||
| .single(); | ||
| if (error) { | ||
| throw new Error(error.message); | ||
| } | ||
| if (userError) { | ||
| throw new Error(userError.message); | ||
| } |
There was a problem hiding this comment.
이부분들도 변경된 에러 처리 방식을 적용해주시면 감사하겠습니다!
| users: { | ||
| Row: { | ||
| created_at: string; | ||
| email: string; | ||
| favorite: string; | ||
| id: number; | ||
| image: string | null; | ||
| last_seen_at: string | null; | ||
| name: string; | ||
| updated_at: string | null; | ||
| }; | ||
| Insert: { | ||
| created_at?: string; | ||
| email: string; | ||
| favorite: string; | ||
| id?: number; | ||
| image?: string | null; | ||
| last_seen_at?: string | null; | ||
| name: string; | ||
| updated_at?: string | null; | ||
| }; | ||
| Update: { | ||
| created_at?: string; | ||
| email?: string; | ||
| favorite?: string; | ||
| id?: number; | ||
| image?: string | null; | ||
| last_seen_at?: string | null; | ||
| name?: string; | ||
| updated_at?: string | null; | ||
| }; | ||
| Relationships: []; | ||
| }; |
There was a problem hiding this comment.
npx supabase gen types typescript ... 명령어로 CLI 자동 타입 생성을 사용해주신건가요?
| export const signout = async () => { | ||
| const cookieStore = await cookies(); | ||
| cookieStore.delete('access_token'); | ||
| cookieStore.delete('refresh_token'); | ||
| }; |
There was a problem hiding this comment.
usePostSignout.ts에서도 onSuccess 시에 동일하게 쿠키를 삭제하고 있는데 함수에서 이미 쿠키를 삭제한다면 커스텀 훅의 쿠키 삭제 로직은 제거하는게 좋을까요?- supabase 관련 로직이 존재하지 않아서 해당 함수를
lib/supabase/아래에 선언하는 것이 괜찮을지 고민되네요. usePostSignout 내부에서 바로 선언하거나, utils로 위치를 변경하는 방법도 있을 것 같은데 어떻게 생각하실까요?
| password: string; | ||
| passwordCheck: string; | ||
| companyName: string; | ||
| favorite: string; |
There was a problem hiding this comment.
좋아하는 작품? 창작물? 이라는 의미까지 변수명/필드명에 담기면 더욱 명시적일 것 같습니다! (favoriteWorks, favoriteCreations, favoriteContents, ... 등)
변경 사항
구현결과(사진첨부 선택)
변경해야할 부분이 많아서 대공사가 될거 같은데 병합을 하는게 맞을 지 조금 고민이 됩니다.
의견 편하게 말씀해주세요!!