-
Notifications
You must be signed in to change notification settings - Fork 0
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: 마이페이지 리팩토링 #222
feat: 마이페이지 리팩토링 #222
Changes from all commits
58310dc
51f2684
ec25d8a
36a482e
3a4d40d
960c36d
e6b2550
924526f
78727a0
ebfa79c
c52c727
3a7917d
542fc9d
a14fcc3
086e8ac
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,26 +1,11 @@ | ||
import { AxiosError } from 'axios'; | ||
|
||
import { authClient } from '@/apis'; | ||
import { AuthErrorData } from '@/home/types/Auth.type'; | ||
import { GetPasswordResponse } from '@/home/types/password.type'; | ||
import { SessionTokenType } from '@/home/types/password.type'; | ||
import { api } from '@/service/TokenService'; | ||
|
||
interface getPasswordProps { | ||
password: string; | ||
} | ||
|
||
export const getUserPasswordMatch = async ( | ||
props: getPasswordProps | ||
): Promise<GetPasswordResponse> => { | ||
const { password } = props; | ||
|
||
try { | ||
const res = await authClient.get('/auth/verification/password', { | ||
params: { password }, | ||
headers: api.headers, | ||
}); | ||
return { data: res.data }; | ||
} catch (error: unknown) { | ||
return { error: error as AxiosError<AuthErrorData> }; | ||
} | ||
export const getUserPasswordMatch = async (password: string): Promise<SessionTokenType> => { | ||
const res = await authClient.get('/auth/verification/password', { | ||
params: { password }, | ||
headers: api.headers, | ||
}); | ||
return res.data; | ||
}; |
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. 저 근데 뒤늦게 든 의문이!! PrivateRoute가 훅이어야 할 이유가 있나요?? 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. 아하!! 좋아요좋아요 어푸룹 하겠ㅅ습니다 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Navigate, Outlet } from 'react-router-dom'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
import { LogInState } from '@/home/recoil/LogInState'; | ||
import { api } from '@/service/TokenService'; | ||
|
||
import { useResetUserInfo } from './useResetUserInfo'; | ||
|
||
export const usePrivateRoute = () => { | ||
const isLoggedIn = useRecoilValue(LogInState); | ||
const accessToken = api.getAccessToken(); | ||
|
||
const resetUserInfo = useResetUserInfo(); | ||
|
||
const PrivateRoute = (): React.ReactNode => { | ||
if (!isLoggedIn || !accessToken) { | ||
resetUserInfo(); | ||
return <Navigate to="/login" />; | ||
} | ||
return <Outlet />; | ||
}; | ||
|
||
return { PrivateRoute }; | ||
}; |
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. 라인 138-139도 로그인 필요한 페이지인데 여기서 껴주실 수 있나요 뒷북 쏘 쏘리 // before
<Route path="register" element={<Register />} />
<Route path="myDrawers" element={<MyDrawer />} /> //after
<Route element={<PrivateRoute />}>
<Route path="register" element={<Register />} />
<Route path="myDrawers" element={<MyDrawer />} />
</Route> 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. a14fcc3 반영했습니다 |
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.
hidden 붙은 컴포넌트들이 대충 요쯤에 있는 거라는 건 알아냈는데
역할을 모르겠어요
도와달라
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.
피그마 기준으로 봤을 때, 상단 SOOMSIL 로고를 제외하고 비밀번호 변경 사각형 컴포넌트 기준으로 중앙 정렬을 하고 있더라구요.
그래서 요소를 상대위치로 정렬하기 위해 밑에도 SOOMSIL 로고 크기만큼 컴포넌트를 넣고 center로 정렬 했습니다.
어차피 반응형으로 안하는 것 같긴 하지만..