-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/118/auth api #137
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/118/auth api #137
Conversation
Walkthrough์ด ๋ณ๊ฒฝ ์ฌํญ์ ์ฌ์ฉ์ ์ธ์ฆ ๋ฐ ๋ก๊ทธ์์ ๊ธฐ๋ฅ์ ๊ฐ์ ํ๊ธฐ ์ํด ์ฌ๋ฌ API ๋ฐ ์ฟผ๋ฆฌ ํ
์ ์ถ๊ฐํ๊ณ ์์ ํ๋ ๋ด์ฉ์ ํฌํจํฉ๋๋ค. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LogoutAPI
participant AuthStore
User->>LogoutAPI: POST /auths/logout
LogoutAPI->>AuthStore: clearToken()
AuthStore-->>User: Token cleared
Possibly related PRs
Suggested labels
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the toolโs configuration or disable the tool if itโs a critical failure. ๐ง eslint
src/components/common/header/header.stories.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't determine the plugin "react-hooks" uniquely.
Please remove the "plugins" setting from either config or remove either plugin installation. If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ๐ Recent review detailsConfiguration used: CodeRabbit UI ๐ Files selected for processing (1)
๐ง Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? ๐ชง TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 18
๐งน Outside diff range and nitpick comments (22)
src/components/client-provider.tsx (2)
33-33: ํ ํฐ ์ฒ๋ฆฌ ๋ฐฉ์์ ๊ฐ์ ์ ์
token.replace(/^Bearer\s/, '')๋ฅผ ์ฌ์ฉํ์ฌ ํ ํฐ์์ 'Bearer '๋ฅผ ์ ๊ฑฐํ๊ณ ์์ต๋๋ค. ํ ํฐ ํฌ๋งท์ด ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ผ๋ฏ๋ก, ์๋ฒ์์ ์์ ์ก์ธ์ค ํ ํฐ๋ง ์ ๋ฌ๋ฐ๋๋ก API๋ฅผ ์์ ํ๊ฑฐ๋, ํ ํฐ ํ์ฑ ๋ก์ง์ ๋ณด๋ค ๊ฒฌ๊ณ ํ๊ฒ ๋ง๋๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์.
19-19:staleTime๊ฐ์ ์์๋ก ๋ถ๋ฆฌํ์ฌ ๊ด๋ฆฌ๋งค์ง ๋๋ฒ๋ฅผ ํผํ๊ธฐ ์ํด
staleTime์ ์๊ฐ์ ์์๋ก ๋ถ๋ฆฌํ๋ฉด ์ฝ๋์ ๊ฐ๋ ์ฑ๊ณผ ์ ์ง๋ณด์์ฑ์ด ํฅ์๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด:- staleTime: 60 * 1000, // 1๋ถ ๋์ ๋ฐ์ดํฐ ์ ์ง + const ONE_MINUTE_IN_MS = 60 * 1000; + staleTime: ONE_MINUTE_IN_MS, // 1๋ถ ๋์ ๋ฐ์ดํฐ ์ ์งsrc/_queries/auth/logout-queries.ts (1)
5-9: ์ฝ๋ฐฑ ํจ์ ์ถ๊ฐ ๊ฒํ ํ์๊ตฌํ์ด ๊น๋ํ๊ณ ํ์ ์ด ์ ์ ์๋์ด ์์ต๋๋ค. ํ์ง๋ง ๋ก๊ทธ์์ ํ์ ์ฒ๋ฆฌ๋ฅผ ์ํด ๋ค์๊ณผ ๊ฐ์ ์ฝ๋ฐฑ ์ถ๊ฐ๋ฅผ ๊ณ ๋ คํด๋ณด์๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค:
- ์ฑ๊ณต ์ ์ฌ์ฉ์ ์ํ ์ด๊ธฐํ
- ์๋ฌ ์ฒ๋ฆฌ
- ๋ก๊ทธ์์ ํ ๋ฆฌ๋ค์ด๋ ์
๋ค์๊ณผ ๊ฐ์ด ์์ ํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
export function usePostLogoutQuery() { return useMutation<void, ApiError>({ mutationFn: logout, + onSuccess: () => { + // ์ฌ์ฉ์ ์ํ ์ด๊ธฐํ + // ํํ์ด์ง๋ก ๋ฆฌ๋ค์ด๋ ์ + }, + onError: (error) => { + // ์๋ฌ ์ฒ๋ฆฌ + }, }); }src/_queries/auth/user-queries.ts (1)
8-8: ์บ์ ํค ์์ํ ๊ถ์ฅ์ฟผ๋ฆฌ ํค๋ฅผ ์์๋ก ๋ถ๋ฆฌํ์ฌ ๊ด๋ฆฌํ๋ฉด ์ ์ง๋ณด์์ฑ์ด ํฅ์๋ฉ๋๋ค.
+const USER_QUERY_KEY = ['user'] as const; + export function useUser() { const { token } = authStore.getState(); return useQuery({ - queryKey: ['user'], + queryKey: USER_QUERY_KEY, queryFn: getUser, enabled: !!token, }); }src/hooks/use-handle-auth-success.ts (2)
Line range hint
6-9: ํ ํฐ ๊ฒ์ฆ ๋ก์ง์ด ์ ์ ํฉ๋๋ค.null ์ฒดํฌ๋ฅผ ํตํด ํ ํฐ์ ์กด์ฌ ์ฌ๋ถ๋ฅผ ํ์ธํ๊ณ ์์ต๋๋ค. ํ์ง๋ง ํ ํฐ์ ํ์์ด๋ ๋ง๋ฃ ์ฌ๋ถ์ ๋ํ ์ถ๊ฐ์ ์ธ ๊ฒ์ฆ์ด ํ์ํ ์ ์์ต๋๋ค.
ํ ํฐ ๊ฒ์ฆ์ ๊ฐํํ๊ธฐ ์ํด ๋ค์๊ณผ ๊ฐ์ ์์ ์ ์ ์ํฉ๋๋ค:
return async function handleAuthSuccess(token: string | null) { if (!token) { throw new Error('ํ ํฐ์ด ์์ต๋๋ค'); } + if (typeof token !== 'string' || token.trim() === '') { + throw new Error('์ ํจํ์ง ์์ ํ ํฐ ํ์์ ๋๋ค'); + }
13-16: ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๊ฐ์ ๋์์ต๋๋ค๋ง, ๋ณด์ ๋ก๊น ์ด ํ์ํฉ๋๋ค.ํ์ฌ ๊ตฌํ์ ์๋ฌ ๋ฐ์ ์ ์ผ๋ฐ์ ์ธ ๋ฉ์์ง๋ง ํ์ํ๊ณ ์์ต๋๋ค. ๊ฐ๋ฐ ํ๊ฒฝ์์์ ๋๋ฒ๊น ์ ์ํด ๋ณด์์ ์ผ๋ก ์์ ํ ๋ก๊น ์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ์์ ์ ์ ์ํฉ๋๋ค:
try { const accessToken = token.replace(/^Bearer\s/, ''); setToken(accessToken); } catch (error) { + console.error('Auth state update failed:', error instanceof Error ? error.message : 'Unknown error'); throw new Error('์ฌ์ฉ์ ์ํ ์ ๋ฐ์ดํธ ์คํจ'); }src/_queries/auth/reissue-queries.ts (1)
9-9: ํ ํฐ ํ์ ์์ ์ฑ ๊ฐ์ ์ด ํ์ํฉ๋๋ค.ํ์ฌ
token์ดnull์ ํ์ฉํ๋๋ฐ, ์ด๋ ๋ฐํ์ ์๋ฌ์ ์์ธ์ด ๋ ์ ์์ต๋๋ค. ํ ํฐ์ด ํญ์ ๋ฌธ์์ด์ด์ด์ผ ํ๋ค๋ฉด ํ์ ์ ๋ ์๊ฒฉํ๊ฒ ์ ์ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.๋ค์๊ณผ ๊ฐ์ด ํ์ ์ ์์ ํด๋ณด์ธ์:
-return useMutation<{ token: string | null }, ApiError>({ +return useMutation<{ token: string }, ApiError>({src/_queries/auth/login-queries.ts (1)
Line range hint
1-15: ์ธ์ฆ ๋ก์ง์ด ์ ๊ตฌํ๋์ด ์์ต๋๋ค.
- React Query์ useMutation์ ์ ์ ํ ํ์ฉํ์์ต๋๋ค.
- API ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๋ช ํํ ํ์ ํ๋์ด ์์ต๋๋ค.
- ํ ํฐ ์ฒ๋ฆฌ ๋ก์ง์ด handleAuthSuccess๋ก ์ ๋ถ๋ฆฌ๋์ด ์์ต๋๋ค.
์ถํ ์ธ์ฆ ์คํจ ์์ ์ฒ๋ฆฌ๋ ๊ณ ๋ คํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. onError ํธ๋ค๋ฌ๋ฅผ ์ถ๊ฐํ์ฌ ์ฌ์ฉ์์๊ฒ ์ ์ ํ ํผ๋๋ฐฑ์ ์ ๊ณตํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
src/store/use-auth-store.tsx (2)
10-25: ํ์ ์์ ์ฑ์ ๊ฐ์ ํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.ํ์ฌ ๊ตฌํ์ ์ ๋์ด์์ง๋ง, ํ์ ์์ ์ฑ์ ๋์ฑ ๊ฐํํ ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํด๋ณด๋ ๊ฒ์ ์ด๋จ๊น์?
- setToken: (token) => set({ token }), + setToken: (token: string) => set({ token }),
27-29: ์ ํธ๋ฆฌํฐ ํจ์์ ๋ํ ๋ฌธ์ํ๊ฐ ํ์ํฉ๋๋ค.์ ํ์ ๊ธฐ๋ฐ์ ์คํ ์ด ์ ๊ทผ ๋ฐฉ์์ ์ข์ง๋ง, ์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ํ ๋ฌธ์ํ๊ฐ ์์ผ๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด JSDoc์ ์ถ๊ฐํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
+/** + * ์ธ์ฆ ์คํ ์ด์ ์ํ๋ฅผ ์ ํ์ ์ผ๋ก ๊ตฌ๋ ํ๊ธฐ ์ํ ํ + * @param selector ์ํ ์ ํ์ ํจ์ + * @returns ์ ํ๋ ์ํ ๊ฐ + * @example + * const token = useAuthStore(state => state.token); + */ export function useAuthStore<T>(selector: (state: AuthState) => T) { return useStore(authStore, selector); }src/hooks/use-logout.ts (1)
6-9: ํ์ ์์ ์ฑ ๊ฐ์ ํ์ํจ์์ ์ํ์ ๋ํ ๋ช ์์ ์ธ ํ์ ์ ์๊ฐ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ํ์ ์ ์ถ๊ฐํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
-export function useLogout() { +export function useLogout(): { handleLogout: () => void } { const { mutate: postLogout } = usePostLogoutQuery(); - const clearToken = useAuthStore((state) => state.clearToken); + const clearToken = useAuthStore((state: { clearToken: () => void }) => state.clearToken); const queryClient = useQueryClient();src/app/(auth)/login/page.tsx (3)
3-3: ์์๋ก ๊ธฐ๋ณธ ๋ฆฌ๋ค์ด๋ ํธ ๊ฒฝ๋ก ์ถ์ถ ๊ถ์ฅ๋ฆฌ๋ค์ด๋ ํธ ๊ธฐ๋ณธ๊ฐ
'/'๋ฅผ ์์๋ก ์ถ์ถํ๋ฉด ์ฝ๋์ ์ฌ์ฌ์ฉ์ฑ๊ณผ ์ ์ง๋ณด์์ฑ์ด ํฅ์๋ ๊ฒ ๊ฐ์ต๋๋ค.๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
+const DEFAULT_REDIRECT_PATH = '/'; export default function LoginPage() { - const [redirect, setRedirect] = useState('/'); + const [redirect, setRedirect] = useState(DEFAULT_REDIRECT_PATH); const searchParams = useSearchParams();Also applies to: 11-12
18-21: useEffect ๋ก์ง ์ต์ ํ ์ ์early return ํจํด์ ์ ์ฉํ๋ฉด ์ฝ๋์ ๊ฐ๋ ์ฑ์ด ํฅ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
useEffect(() => { const redirectParam = searchParams.get('redirect'); - if (redirectParam) setRedirect(redirectParam); + if (!redirectParam) return; + setRedirect(redirectParam); }, [searchParams]);
24-26: ๋ก๋ฉ ์ํ ๊ด๋ฆฌ ์ถ๊ฐ ๊ถ์ฅ์ฌ์ฉ์ ๊ฒฝํ ํฅ์์ ์ํด ๋ก๊ทธ์ธ ์งํ ์ค ๋ก๋ฉ ์ํ๋ฅผ ํ์ํ๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ๊ตฌํ์ ์ ์๋๋ฆฝ๋๋ค:
+ const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (data: LoginFormValues) => { + setIsLoading(true); postLogin(data, { onSuccess: () => { router.push(redirect); }, onError: (error) => { if (error.status === 401) { setError('email', { type: 'manual', message: '์ด๋ฉ์ผ ๋๋ ๋น๋ฐ๋ฒํธ๊ฐ ์ผ์นํ์ง ์์ต๋๋ค.', }); setError('password', { type: 'manual', message: '์ด๋ฉ์ผ ๋๋ ๋น๋ฐ๋ฒํธ๊ฐ ์ผ์นํ์ง ์์ต๋๋ค.', }); } + setIsLoading(false); }, }); };src/app/(auth)/signup/page.tsx (1)
28-28: ์ฌ์ฉ์ ๊ฒฝํ ๊ฐ์ ์ ์ํ ๋ก๋ฉ ์ํ ๊ด๋ฆฌ๊ฐ ํ์ํฉ๋๋ค.ํ์๊ฐ์ ์ ์ถ ์ ์ฌ์ฉ์์๊ฒ ์งํ ์ํ๋ฅผ ํ์ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ๊ตฌํ์ ์ ์ํฉ๋๋ค:
+ const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async (data: SignupFormValues) => { + setIsSubmitting(true); postSignup(requestData, { onSuccess: () => { router.push(redirect); }, onError: (error) => { // ... error handling }, + onSettled: () => { + setIsSubmitting(false); + } }); };src/components/common/header/header.stories.tsx (1)
Line range hint
19-33: ์ธ์ฆ ์ํ ๊ด๋ฆฌ ๋ก์ง ๊ฐ์ ์ด ํ์ํฉ๋๋ค.ํ์ฌ ๊ตฌํ์์ ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ฌํญ๋ค์ ์ ์๋๋ฆฝ๋๋ค:
- ์๋ฌ ์ฒ๋ฆฌ ๋ก์ง์ด ์์ต๋๋ค
- ํ ์คํธ ์ฌ์ฉ์ ๋ฐ์ดํฐ๊ฐ ํ๋์ฝ๋ฉ๋์ด ์์ต๋๋ค
- ์ํ ๋ณ๊ฒฝ ์ ์คํจ ์ผ์ด์ค์ ๋ํ ์ฒ๋ฆฌ๊ฐ ์์ต๋๋ค
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํด๋ณด์๋ ๊ฒ์ ์ด๋จ๊น์?:
const testUser = { id: 1, nickname: 'ํฌ๋ฃจํฌ๋ฃจ', email: '[email protected]', profileImageUrl: 'https://i.pinimg.com/736x/3f/e4/f4/3fe4f4f3aee36ec57aa072cce2e016b3.jpg', }; - const toggleAuth = () => { + const toggleAuth = async () => { + try { if (isAuth) { - queryClient.removeQueries({ queryKey: ['user'] }); + await queryClient.removeQueries({ queryKey: ['user'] }); } else { - queryClient.setQueryData(['user'], testUser); + await queryClient.setQueryData(['user'], testUser); } + } catch (error) { + console.error('์ธ์ฆ ์ํ ๋ณ๊ฒฝ ์ค ์ค๋ฅ ๋ฐ์:', error); + // ์๋ฌ ์ฒ๋ฆฌ ๋ก์ง ์ถ๊ฐ + } };์ถ๊ฐ๋ก ํ ์คํธ ์ฌ์ฉ์ ๋ฐ์ดํฐ๋ ๋ณ๋์ ์์ ํ์ผ๋ก ๋ถ๋ฆฌํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
src/utils/api.ts (1)
Line range hint
28-34: ๋ณด์ ๊ฐ์ ์ฌํญ ์ ์ํ์ฌ ๊ตฌํ์ ๊ธฐ๋ณธ์ ์ธ ๋ณด์ ์๊ตฌ์ฌํญ์ ์ถฉ์กฑํ์ง๋ง, ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ๊ณ ๋ คํด๋ณด์ธ์:
- ํ ํฐ ๋ง๋ฃ ์๊ฐ ํ์ธ ๋ก์ง ์ถ๊ฐ
- ํ ํฐ ํ์ ์ ํจ์ฑ ๊ฒ์ฆ
- Authorization ํค๋๊ฐ ํ์ํ์ง ์์ ์๋ํฌ์ธํธ์ ๋ํ ์ฒ๋ฆฌ
๋ค์๊ณผ ๊ฐ์ด ํ ํฐ ๊ฒ์ฆ ๋ก์ง์ ์ถ๊ฐํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
const { token } = authStore.getState(); + const isValidToken = token && isTokenValid(token); const fetchOptions: RequestInit = { ...options, signal, headers: { ...options.headers, - Authorization: token ? `Bearer ${token}` : '', + ...(isValidToken && { Authorization: `Bearer ${token}` }), }, credentials: 'include', };src/app/(auth)/login/_component/login-form.tsx (2)
26-27: ํผ ์ํ ๊ด๋ฆฌ ๊ฐ์ ์ ์
useWatch๋ฅผ ์ฌ์ฉํ ๊ฐ๋ณ ํ๋ ๋ชจ๋ํฐ๋ง์ด ๊ตฌํ๋์ด ์์ต๋๋ค๋ง, ์ฑ๋ฅ ์ต์ ํ๋ฅผ ์ํด ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ๊ณ ๋ คํด๋ณด์ธ์.- const email = useWatch({ control, name: 'email' }); - const password = useWatch({ control, name: 'password' }); + const { email, password } = useWatch({ + control, + name: ['email', 'password'] + });
81-85: ๋ฒํผ ์คํ์ผ๋ง ๊ฐ์ ์ ์์ธ๋ผ์ธ ์คํ์ผ๋ง์ด ์ฌ์ฉ๋๊ณ ์์ด ์ ์ง๋ณด์๊ฐ ์ด๋ ค์ธ ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด Tailwind ํด๋์ค๋ฅผ ๋ถ๋ฆฌํ์ฌ ๊ด๋ฆฌํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค:
- className={`w-full font-semibold ${isValid ? 'bg-blue-500 text-white' : 'bg-gray-100 text-gray-300'}`} + className={clsx( + 'w-full font-semibold', + isValid ? 'bg-blue-500 text-white' : 'bg-gray-100 text-gray-300' + )}๋ํ ๋ฒํผ์ ๋นํ์ฑํ ์ํ์ ๋ํ ์๊ฐ์ ํผ๋๋ฐฑ์ ์ํด
cursor-not-allowedํด๋์ค ์ถ๊ฐ๋ฅผ ๊ณ ๋ คํด๋ณด์ธ์.src/app/(auth)/signup/_component/signup-form.tsx (3)
2-3: ํ ์ฌ์ฉ ๋ฐฉ์์ ๊ฐ์ ์ด ํ์ธ๋์์ต๋๋ค.
useWatch์useDebouncedValue๋ฅผ ์ฌ์ฉํ ๊ตฌํ์ด ์ ์ ํด ๋ณด์ ๋๋ค. ๋ค๋ง, ๋๋ฐ์ด์ค ์๊ฐ์ด 1์ด๋ก ์ค์ ๋์ด ์์ด ์ฌ์ฉ์ ๊ฒฝํ์ ์ํฅ์ ์ค ์ ์์ต๋๋ค.๋ค์๊ณผ ๊ฐ์ด ๋๋ฐ์ด์ค ์๊ฐ์ ์กฐ์ ํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์:
- const [debouncedNickname, cancelDebouncedNickname] = useDebouncedValue(nickname, 1000); - const [debouncedEmail, cancelDebouncedEmail] = useDebouncedValue(email, 1000); - const [debouncedPassword, cancelDebouncedPassword] = useDebouncedValue(password, 1000); - const [debouncedConfirmPassword, cancelDebouncedConfirmPassword] = useDebouncedValue( - confirmPassword, - 1000, - ); + const [debouncedNickname, cancelDebouncedNickname] = useDebouncedValue(nickname, 500); + const [debouncedEmail, cancelDebouncedEmail] = useDebouncedValue(email, 500); + const [debouncedPassword, cancelDebouncedPassword] = useDebouncedValue(password, 500); + const [debouncedConfirmPassword, cancelDebouncedConfirmPassword] = useDebouncedValue( + confirmPassword, + 500, + );Also applies to: 25-25, 29-40
61-67: ํผ ์ ์ถ ์ฒ๋ฆฌ๊ฐ ์ ์ ํ ๊ตฌํ๋์์ต๋๋ค.๋๋ฐ์ด์ค๋ ๊ฐ๋ค์ ์ทจ์ํ๋ ์ฒ๋ฆฌ๊ฐ ์ ๋์ด์์ต๋๋ค. ๋ค๋ง, ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๋๋ฝ๋์ด ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์:
const handleFormSubmit = handleSubmit(async (data) => { try { await onSubmit(data); cancelDebouncedNickname(); cancelDebouncedEmail(); cancelDebouncedPassword(); cancelDebouncedConfirmPassword(); } catch (error) { console.error('ํ์๊ฐ์ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค:', error); // ์๋ฌ ์ฒ๋ฆฌ ๋ก์ง ์ถ๊ฐ } });
136-140: ๋ฒํผ ์คํ์ผ๋ง ๊ฐ์ ์ด ํ์ํฉ๋๋ค.ํ์ฌ ์คํ์ผ๋ง์ด ์ธ๋ผ์ธ์ผ๋ก ๋์ด์์ด ์ ์ง๋ณด์๊ฐ ์ด๋ ค์ธ ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ํด๋์ค๋ค์์ ๋ถ๋ฆฌํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค:
const buttonClassName = clsx( 'w-full font-semibold', isValid ? 'bg-blue-500 text-white' : 'bg-gray-100 text-gray-300' ); return ( <Button disabled={!isValid} type="submit" className={buttonClassName} > ํ์๊ฐ์ </Button> );
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
๐ Files selected for processing (24)
src/_apis/auth/logout-apis.ts(1 hunks)src/_apis/auth/reissue-apis.ts(1 hunks)src/_queries/auth/login-queries.ts(1 hunks)src/_queries/auth/logout-queries.ts(1 hunks)src/_queries/auth/reissue-queries.ts(1 hunks)src/_queries/auth/signup-queries.ts(1 hunks)src/_queries/auth/user-apis.ts(0 hunks)src/_queries/auth/user-queries.ts(1 hunks)src/app/(auth)/layout.tsx(2 hunks)src/app/(auth)/login/_component/login-form.tsx(3 hunks)src/app/(auth)/login/page.tsx(2 hunks)src/app/(auth)/signup/_component/signup-form.tsx(3 hunks)src/app/(auth)/signup/page.tsx(2 hunks)src/app/(crew)/_components/hero/hero-crew.tsx(2 hunks)src/app/(crew)/crew/detail/[id]/_components/create-gathering/index.tsx(1 hunks)src/components/client-provider.tsx(1 hunks)src/components/common/header/container.tsx(2 hunks)src/components/common/header/header.stories.tsx(3 hunks)src/components/common/header/presenter.tsx(1 hunks)src/hooks/use-auth.ts(1 hunks)src/hooks/use-handle-auth-success.ts(2 hunks)src/hooks/use-logout.ts(1 hunks)src/store/use-auth-store.tsx(1 hunks)src/utils/api.ts(2 hunks)
๐ค Files with no reviewable changes (1)
- src/_queries/auth/user-apis.ts
โ Files skipped from review due to trivial changes (1)
- src/_queries/auth/signup-queries.ts
๐ Additional comments (26)
src/hooks/use-auth.ts (1)
4-4: useUser ํ
์ ๋ฐํ๊ฐ ํ์
ํ์ธ์ด ํ์ํฉ๋๋ค.
useUser ํ ์์ ๋ฐํ๋๋ data์ ๊ตฌ์ฒด์ ์ธ ํ์ ์ด ๋ช ์๋์ด ์์ง ์์ต๋๋ค. ํ์ ์์ ์ฑ์ ์ํด ํ์ธ์ด ํ์ํฉ๋๋ค.
โ Verification successful
useUser ํ ์ ํ์ ์ด ์ ์ ํ ์ ์๋์ด ์์ต๋๋ค.
useUser ํ ์ ๋ค์๊ณผ ๊ฐ์ด ํ์ ์์ ์ฑ์ด ํ๋ณด๋์ด ์์ต๋๋ค:
- User ์ธํฐํ์ด์ค๊ฐ src/types/auth.ts์ ๋ช ํํ๊ฒ ์ ์๋์ด ์์ (id, email, nickname, profileImageUrl ํฌํจ)
- getUser ํจ์๊ฐ Promise ํ์ ์ ๋ฐํํ๋๋ก ๋ช ์๋์ด ์์
- useQuery๋ฅผ ํตํด User ํ์ ์ด ์๋์ผ๋ก ์ถ๋ก ๋จ
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: useUser ํ
์ ๊ตฌํ ๋ฐ ํ์
์ ์ ํ์ธ
# useUser ๊ตฌํ ํ์ธ
ast-grep --pattern 'export function useUser() {
$$$
}'
# ๊ด๋ จ ํ์
์ ์ ๊ฒ์
rg -t typescript "type.*User.*=|interface.*User.*{" -g "!*.test.*" -g "!*.spec.*"
Length of output: 727
Script:
#!/bin/bash
# useUser ํ
์ ๋ฐํ ํ์
๊ณผ getUser ํจ์์ ๊ตฌํ ํ์ธ
rg "getUser" -A 5 -B 5
# ์ฌ์ฉ์ ๊ด๋ จ ํ์
์ ์ ๊ฒ์ (์์ ๋ ์ ๊ท์)
rg "type\s+User|interface\s+User" -g "*.ts" -g "!*.test.*" -g "!*.spec.*"
# user-queries.ts ํ์ผ ์ ์ฒด ๋ด์ฉ ํ์ธ
fd -e ts "user-queries" --exec cat {}
Length of output: 1808
Script:
#!/bin/bash
# User ์ธํฐํ์ด์ค ์ ์ ํ์ธ
cat src/types/auth.ts
# useQuery์ ๋ฐํ ํ์
ํ์ธ์ ์ํด ๊ด๋ จ import ๊ฒ์
rg "from '@tanstack/react-query'" -B 2 -A 2
Length of output: 8654
src/_apis/auth/logout-apis.ts (2)
1-10: ๊ตฌํ์ด ๊น๋ํ๊ณ ๋ช
ํํฉ๋๋ค!
๋ก๊ทธ์์ API ๊ตฌํ์ด ๊ฐ๋จํ๊ณ ์ดํดํ๊ธฐ ์ฝ๊ฒ ๋์ด์์ต๋๋ค.
3-10: ๋ณด์ ๊ด๋ จ ๊ณ ๋ ค์ฌํญ ๊ฒํ ํ์
๋ก๊ทธ์์ ์์ฒญ ์ ์ธ์ฆ ํ ํฐ์ด ํ์ํ ์ ์์ต๋๋ค. ํ์ฌ ๊ตฌํ์์๋ Authorization ํค๋๊ฐ ๋๋ฝ๋์ด ์์ต๋๋ค.
๋ค์ ์คํฌ๋ฆฝํธ๋ก fetchApi ์ ํธ๋ฆฌํฐ์ ๊ตฌํ์ ํ์ธํด๋ณด๊ฒ ์ต๋๋ค:
src/_queries/auth/logout-queries.ts (1)
1-9: ๋ก๊ทธ์์ API ์๋ํฌ์ธํธ ๊ตฌํ ํ์ธ ํ์
๋ก๊ทธ์์ API๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌํ๋์ด ์๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
โ Verification successful
Let me check the implementation of the logout API by examining the logout-apis.ts file.
๋ก๊ทธ์์ API๊ฐ ์ ์์ ์ผ๋ก ๊ตฌํ๋์ด ์์์ ํ์ธํ์ต๋๋ค
๋ก๊ทธ์์ API๋ /auths/logout ์๋ํฌ์ธํธ๋ก POST ์์ฒญ์ ๋ณด๋ด๋๋ก ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌํ๋์ด ์์ผ๋ฉฐ, fetchApi ์ ํธ๋ฆฌํฐ๋ฅผ ํตํด ์ ์ ํ ํค๋์ ํจ๊ป ํธ์ถ๋๊ณ ์์ต๋๋ค. ๋ํ ํด๋น API๋ logout-queries.ts์์๋ง ์ฌ์ฉ๋์ด ์ ์ ํ ๋ฒ์๋ก ์ ํ๋์ด ์์ต๋๋ค.
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: ๋ก๊ทธ์์ API ๊ตฌํ ํ์ธ
# logout-apis.ts ํ์ผ ๊ฒ์
echo "๋ก๊ทธ์์ API ๊ตฌํ ํ์ธ:"
fd -e ts -e js "logout-apis" src
# ๋ก๊ทธ์์ ์๋ํฌ์ธํธ ์ฌ์ฉ ํ์ธ
echo "\n๋ก๊ทธ์์ ์๋ํฌ์ธํธ ์ฌ์ฉ ํํฉ:"
rg -A 3 "/auths/logout" src
Length of output: 414
Script:
#!/bin/bash
# Check the implementation of logout-apis.ts
echo "๋ก๊ทธ์์ API ๊ตฌํ ๋ด์ฉ:"
cat src/_apis/auth/logout-apis.ts
# Check where the logout API is being used
echo "\n๋ก๊ทธ์์ API ์ฌ์ฉ ์์น:"
rg -l "logout-apis" src
Length of output: 397
src/_queries/auth/user-queries.ts (2)
1-3: LGTM! ํ์ํ ์์กด์ฑ๋ค์ด ์ ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
ํ์์ ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ด๋ถ ๋ชจ๋๋ค์ด ๋ช ํํ๊ฒ ์ํฌํธ๋์ด ์์ต๋๋ค.
1-12: ์์กด์ฑ ๊ฒ์ฆ ํ์
getUser API์ authStore์ ๊ตฌํ์ ํ์ธํ์ฌ ์ผ๊ด์ฑ ์๊ฒ ๋์ํ๋์ง ๊ฒ์ฆ์ด ํ์ํฉ๋๋ค.
โ Verification successful
Let me gather more information about the fetchApi function and the User type to ensure complete verification.
Let me check one final aspect - the complete implementation of fetchApi to verify the token handling:
์์กด์ฑ ๊ฒ์ฆ ์๋ฃ: ๊ตฌํ์ด ์ผ๊ด์ฑ ์๊ฒ ๋์ํฉ๋๋ค
getUserAPI๋fetchApi๋ฅผ ํตํด ์ธ์ฆ ํ ํฐ์ ์๋์ผ๋ก ์ฒ๋ฆฌํฉ๋๋คauthStore๋ ํ ํฐ์ ์ธ์ ์คํ ๋ฆฌ์ง์ ์์ ํ๊ฒ ์ ์ฅํ๊ณ ๊ด๋ฆฌํฉ๋๋คUserํ์ ์ด ๋ช ํํ๊ฒ ์ ์๋์ด ์์ผ๋ฉฐ API ์๋ต๊ณผ ์ผ์นํฉ๋๋คuseUserํ ์enabled์ต์ ์ด ํ ํฐ ์กด์ฌ ์ฌ๋ถ์ ๋ฐ๋ผ ์ ์ ํ ์ฟผ๋ฆฌ๋ฅผ ์ ์ดํฉ๋๋ค
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the implementation of getUser API and authStore
# Check getUser API implementation
echo "Checking getUser API implementation..."
rg -A 10 "export.*getUser" "src/_apis"
# Check authStore implementation
echo "Checking authStore implementation..."
rg -A 10 "export.*authStore" "src/store"
Length of output: 1492
Script:
#!/bin/bash
# Check fetchApi implementation
echo "Checking fetchApi implementation..."
rg -A 5 "export.*fetchApi"
# Check User type definition
echo "Checking User type definition..."
rg -A 5 "type User"
rg -A 5 "interface User"
Length of output: 909
Script:
#!/bin/bash
# Check complete fetchApi implementation including token handling
echo "Checking complete fetchApi implementation..."
rg -A 20 "export.*fetchApi" "src/utils/api.ts"
Length of output: 664
src/hooks/use-handle-auth-success.ts (1)
4-4: ์ํ ๊ด๋ฆฌ ๋ก์ง์ด ๋จ์ํ๋์์ต๋๋ค.
์ด์ ์ ์ฌ์ฉ์ ๋ฐ์ดํฐ fetch ๋ก์ง์ด ์ ๊ฑฐ๋๊ณ ํ ํฐ ์ค์ ๋ง ๋จ์ ๊ฒ์ด ํ์ธ๋ฉ๋๋ค. ํ์ง๋ง ์ฌ์ฉ์ ์ ๋ณด๊ฐ ํ์ํ ์์ ์ ๋ํ ์ฒ๋ฆฌ ๋ฐฉ์์ด ๋ช ํํ์ง ์์ต๋๋ค.
๋ค์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ์ฌ ์ฌ์ฉ์ ์ ๋ณด ์กฐํ ๋ก์ง์ด ๋ค๋ฅธ ๊ณณ์ผ๋ก ์ด๋๋์๋์ง ํ์ธํ๊ฒ ์ต๋๋ค:
โ Verification successful
์ฌ์ฉ์ ์ ๋ณด ๊ด๋ฆฌ๊ฐ ์ ์ ํ ๋ถ๋ฆฌ๋์ด ์์ต๋๋ค.
ํ ํฐ ์ค์ ๋ก์ง์ด ๋จ์ํ๋ ๊ฒ์ ์๋๋ ์ค๊ณ๋ก ํ์ธ๋ฉ๋๋ค. ์ฌ์ฉ์ ์ ๋ณด๋ ๋ค์๊ณผ ๊ฐ์ด ์ฒด๊ณ์ ์ผ๋ก ๊ด๋ฆฌ๋๊ณ ์์ต๋๋ค:
useUser์ฟผ๋ฆฌ๋ฅผ ํตํด ํ ํฐ ๊ธฐ๋ฐ์ ์ฌ์ฉ์ ์ ๋ณด ์กฐํ- ํ๋กํ ์นด๋ ์ปดํฌ๋ํธ์์ ์ฌ์ฉ์ ์ ๋ณด ์ํ ๊ด๋ฆฌ ๋ฐ ์ ๋ฐ์ดํธ
- ์ธ์ฆ ์คํ ์ด์์ ํ ํฐ ๊ด๋ฆฌ ๋ก์ง ๋ถ๋ฆฌ
์ด๋ฌํ ๊ตฌ์กฐ๋ ๊ด์ฌ์ฌ ๋ถ๋ฆฌ ์์น์ ์ ๋ถํฉํ๋ฉฐ, ๊ฐ ๊ธฐ๋ฅ์ด ๋ช ํํ๊ฒ ๋ชจ๋ํ๋์ด ์์ต๋๋ค.
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: ์ฌ์ฉ์ ์ ๋ณด ์กฐํ ๋ก์ง ๊ฒ์
# ์ฌ์ฉ์ ์ ๋ณด ๊ด๋ จ ์ฟผ๋ฆฌ ํ์ผ ๊ฒ์
rg -l "useQuery.*user" src/_queries/
# ์ฌ์ฉ์ ์ ๋ณด ์กฐํ API ์๋ํฌ์ธํธ ๊ฒ์
rg -l "api.*user" src/
Length of output: 159
Script:
#!/bin/bash
# Check user query implementation and its usage
rg -A 10 "useQuery.*user" src/_queries/auth/user-queries.ts
# Check where these queries are being used
rg "useGetUser|useGetUserProfile" src/
# Check the auth store implementation
rg -A 10 "useAuthStore" src/
Length of output: 7090
Script:
#!/bin/bash
# Check auth store implementation details
cat src/store/use-auth-store.tsx
# Check user query implementation
cat src/_queries/auth/user-queries.ts
# Check profile card implementation for user data handling
cat src/app/\(crew\)/my-page/_components/profile-card/container.tsx
Length of output: 4146
src/_apis/auth/reissue-apis.ts (1)
1-1: fetchApi ์ ํธ๋ฆฌํฐ์ ์๋ฌ ์ฒ๋ฆฌ ๊ฒ์ฆ ํ์
fetchApi ์ ํธ๋ฆฌํฐ๊ฐ ๋คํธ์ํฌ ์ค๋ฅ, ํ์์์, ์๋ฒ ์๋ฌ ๋ฑ์ ์ ์ ํ ์ฒ๋ฆฌํ๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
โ Verification successful
fetchApi ์ ํธ๋ฆฌํฐ์ ์๋ฌ ์ฒ๋ฆฌ๊ฐ ์ ์ ํ ๊ตฌํ๋์ด ์์
fetchApi ์ ํธ๋ฆฌํฐ๋ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ ์ฒ๋ฆฌ ๊ธฐ๋ฅ์ด ์ ๊ตฌํ๋์ด ์์ต๋๋ค:
- ํ์์์ ์ฒ๋ฆฌ (5์ด ๊ธฐ๋ณธ๊ฐ)
- HTTP ์๋ต ์ํ ํ์ธ
- ์์ธํ ์๋ฌ ๋ฉ์์ง ์ฒ๋ฆฌ
- ๋น ์๋ต ์ฒ๋ฆฌ
- API ์๋ฌ ๊ฐ์ฒด๋ฅผ ํตํ ์ผ๊ด๋ ์๋ฌ ์ฒ๋ฆฌ
๋ฐ๋ผ์ reissue-apis.ts์์ ์์ ํ๊ฒ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify error handling in fetchApi utility
ast-grep --pattern 'export function fetchApi($$$) {
$$$
catch($_) {
$$$
}
$$$
}'
Length of output: 94
Script:
#!/bin/bash
# Search for fetchApi implementation with ripgrep for better context
rg "export.*fetchApi" -A 20
Length of output: 905
Script:
#!/bin/bash
# Search for error handling in fetchApi implementation
rg "export.*fetchApi" -A 30 -B 2
Length of output: 1578
Script:
#!/bin/bash
# Get the complete error handling implementation
rg "export.*fetchApi" -A 40
Length of output: 1961
src/_queries/auth/reissue-queries.ts (1)
1-5: ์ฝ๋๊ฐ ๊น๋ํ๊ณ ํ์ํ ์์กด์ฑ๋ง ๊ฐ์ ธ์ค๊ณ ์์ต๋๋ค!
ํ์ํ ๋ชจ๋๋ค์ด ์ ์ ํ๊ฒ ์ํฌํธ๋์ด ์์ผ๋ฉฐ, ๊ฒฝ๋ก ๊ท์น๋ ์ ์ง์ผ์ง๊ณ ์์ต๋๋ค.
src/_queries/auth/login-queries.ts (1)
3-3: ์๋ ๊ฒฝ๋ก์์ ์ ๋ ๊ฒฝ๋ก๋ก์ ๋ณ๊ฒฝ์ด ์ฌ๋ฐ๋ฅด๊ฒ ์ด๋ฃจ์ด์ก๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
์ ๋ ๊ฒฝ๋ก๋ก์ ๋ณ๊ฒฝ์ ์ข์ ๋ฐฉํฅ์ด์ง๋ง, ๋ค๋ฅธ ํ์ผ๋ค์์๋ ์ผ๊ด์ฑ ์๊ฒ ์ ์ฉ๋์๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
โ Verification successful
์ํฌํธ ๊ฒฝ๋ก ๋ณ๊ฒฝ์ด ์ฌ๋ฐ๋ฅด๊ฒ ์ ์ฉ๋์์ต๋๋ค
useHandleAuthSuccess ํ
์ด src/hooks ๋๋ ํ ๋ฆฌ๋ก ์ด๋๋์๊ณ , ๋ชจ๋ ๊ด๋ จ ํ์ผ๋ค(login-queries.ts, reissue-queries.ts, signup-queries.ts)์์ ์ผ๊ด๋๊ฒ @/src/hooks/use-handle-auth-success ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ์ด๋ ๋ค์๊ณผ ๊ฐ์ ์ด์ ๋ก ์ ์ ํ ๋ณ๊ฒฝ์
๋๋ค:
- ํ
ํ์ผ์ด
utils๋๋ ํ ๋ฆฌ์์ ๋ ์ ์ ํ ์์น์ธhooks๋๋ ํ ๋ฆฌ๋ก ์ด๋๋จ - ๋ชจ๋ ์ฐธ์กฐ๊ฐ ์๋ก์ด ์์น๋ฅผ ๋ฐ์ํ๋๋ก ์ ๋ฐ์ดํธ๋จ
- ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ์ฌ ์ผ๊ด์ฑ ์๋ ์ํฌํธ ๊ตฌ์กฐ ์ ์ง
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: ํ๋ก์ ํธ ์ ์ฒด์์ useHandleAuthSuccess ์ํฌํธ ํจํด์ ํ์ธํฉ๋๋ค.
# useHandleAuthSuccess ์ํฌํธ ์ฌ์ฉ ํํฉ ํ์ธ
rg "import.*useHandleAuthSuccess" --type ts
Length of output: 381
Script:
#!/bin/bash
# ์ด์ ์ปค๋ฐ์์์ useHandleAuthSuccess ์ํฌํธ ํจํด์ ํ์ธํฉ๋๋ค
git log -p | rg "[-+].*import.*useHandleAuthSuccess" --multiline
# useHandleAuthSuccess ํ
์ ์ค์ ์์น ํ์ธ
fd "use-handle-auth-success.ts"
Length of output: 1497
Script:
#!/bin/bash
# hooks ๋๋ ํ ๋ฆฌ์ utils ๋๋ ํ ๋ฆฌ์์ use-handle-auth-success.ts ํ์ผ ์ฐพ๊ธฐ
fd "use-handle-auth-success.ts" src/hooks src/utils
# ํ์ฌ ๋ธ๋์น์ ํ์ผ ๊ตฌ์กฐ ํ์ธ
ls -R src/hooks src/utils 2>/dev/null
Length of output: 304
src/components/common/header/container.tsx (2)
3-5: ๊ด์ฌ์ฌ ๋ถ๋ฆฌ๊ฐ ์ ๋์ด์๋ ํ
๊ตฌ์กฐ์
๋๋ค!
๊ฐ ํ ์ด ๋ช ํํ ์ฑ ์์ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, ํ๋ก์ ํธ ๊ตฌ์กฐ๋ ์ ์ ๋ฆฌ๋์ด ์์ต๋๋ค:
useUser: ์ฌ์ฉ์ ์ ๋ณด ๊ด๋ฆฌuseAuth: ์ธ์ฆ ์ํ ๊ด๋ฆฌuseLogout: ๋ก๊ทธ์์ ์ฒ๋ฆฌ
16-18: ์ธ์ฆ ์์คํ
ํตํฉ ๊ฒ์ฆ์ด ํ์ํฉ๋๋ค.
๋ก๊ทธ์์ ์ฒ๋ฆฌ ํ ์ ์ ํ ์ํ ์ด๊ธฐํ์ ํ ํฐ ์ญ์ ๊ฐ ์ด๋ฃจ์ด์ง๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
โ Verification successful
Let me gather more information about the authentication state management and cleanup.
์ธ์ฆ ์์คํ ์ด ์ ์ ํ๊ฒ ํตํฉ๋์ด ์์์ ํ์ธํ์ต๋๋ค.
๋ก๊ทธ์์ ์ฒ๋ฆฌ ์ ๋ค์๊ณผ ๊ฐ์ ์ ์์ ์ธ ์ ๋ฆฌ ์์ ์ด ์ํ๋ฉ๋๋ค:
- ์๋ฒ์ ๋ก๊ทธ์์ ์์ฒญ ์ ์ก
- ํ ํฐ ์ด๊ธฐํ (
clearToken()) - ์ฌ์ฉ์ ์ ๋ณด ์ฟผ๋ฆฌ ์ ๊ฑฐ (
queryClient.removeQueries) - ํ ํ์ด์ง๋ก ๋ฆฌ๋ค์ด๋ ์
์ถ๊ฐ๋ก ์ธ์ฆ ์ํ ๊ด๋ฆฌ๋ ์ ์ ํ ๊ตฌํ๋์ด ์์ต๋๋ค:
useAuthStore๋ฅผ ํตํ ์ค์ํ๋ ํ ํฐ ๊ด๋ฆฌ- ํ ํฐ ์ค์ /์ ๊ฑฐ ๊ธฐ๋ฅ ๊ตฌํ
- ์ธ์ฆ ์ฑ๊ณต/์คํจ ์ฒ๋ฆฌ ๋ก์ง
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# ์ธ์ฆ ๊ด๋ จ ๋ก์ง ๊ฒ์ฆ
# ๋ก๊ทธ์์ ์ฒ๋ฆฌ ๋ก์ง ํ์ธ
echo "๋ก๊ทธ์์ ์ฒ๋ฆฌ ๋ก์ง ํ์ธ:"
rg -A 5 "useLogout" "src/hooks/"
# ํ ํฐ ๊ด๋ฆฌ ๋ก์ง ํ์ธ
echo "ํ ํฐ ๊ด๋ฆฌ ๋ก์ง ํ์ธ:"
rg -A 5 "token" "src/_apis/"
Length of output: 1508
Script:
#!/bin/bash
# ์ธ์ฆ ์ํ ๊ด๋ฆฌ ๋ฐ ์ด๊ธฐํ ๋ก์ง ํ์ธ
# useLogout ํ
์ ์ ์ฒด ๊ตฌํ ํ์ธ
echo "๋ก๊ทธ์์ ํ
๊ตฌํ:"
ast-grep --pattern 'export function useLogout() {
$$$
}'
# ์ธ์ฆ ์ํ ์ ์ฅ์ ํ์ธ
echo "์ธ์ฆ ์ํ ์ ์ฅ์:"
rg -A 10 "useAuthStore" "src/"
# ์ฟผ๋ฆฌ ํด๋ผ์ด์ธํธ ์ด๊ธฐํ ๊ด๋ จ
echo "์ฟผ๋ฆฌ ์ด๊ธฐํ ๋ก์ง:"
rg -A 5 "queryClient.clear" "src/"
Length of output: 8146
src/store/use-auth-store.tsx (2)
1-8: ์ธํฐํ์ด์ค ๋จ์ํ๊ฐ ์ ๋์์ต๋๋ค!
์ํ ๊ด๋ฆฌ๋ฅผ ํ ํฐ ์ค์ฌ์ผ๋ก ๋จ์ํํ ๊ฒ์ด ์ข์ ์ ๊ทผ์
๋๋ค. createStore๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ์์ผ๋ก ์ ํํ๊ณ ์ธํฐํ์ด์ค๋ฅผ ํ ํฐ ๊ด๋ฆฌ์ ์ง์ค์ํจ ๊ฒ์ด ๊น๋ํฉ๋๋ค.
1-29: ํ ํฐ ์ ๋ฆฌ ๋ก์ง ๊ฒ์ฆ์ด ํ์ํฉ๋๋ค.
๋ก๊ทธ์์ ์ ํ ํฐ์ด ์ฌ๋ฐ๋ฅด๊ฒ ์ ๊ฑฐ๋๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
๋ค์ ์คํฌ๋ฆฝํธ๋ก ๊ด๋ จ ๋ก์ง์ ํ์ธํด๋ณด๊ฒ ์ต๋๋ค:
โ Verification successful
ํ ํฐ ์ ๋ฆฌ ๋ก์ง์ด ์ ์ ํ๊ฒ ๊ตฌํ๋์ด ์์ต๋๋ค.
๋ก๊ทธ์์ ํ๋ก์ธ์ค๊ฐ ๋ค์๊ณผ ๊ฐ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌํ๋์ด ์์์ ํ์ธํ์ต๋๋ค:
- ์๋ฒ API ํธ์ถ์ ํตํ ๋ก๊ทธ์์ ์ฒ๋ฆฌ
- ์ฑ๊ณต ์
clearToken()์ ํตํ ํ ํฐ ์ ๊ฑฐ - ์ฌ์ฉ์ ๊ด๋ จ ์ฟผ๋ฆฌ ๋ฐ์ดํฐ ์ ๋ฆฌ
- ํ ํ์ด์ง๋ก ๋ฆฌ๋ค์ด๋ ์
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# ๋ก๊ทธ์์ ๊ด๋ จ ํ ํฐ ์ ๋ฆฌ ๋ก์ง ํ์ธ
rg -l "clearToken|logout" src/
Length of output: 194
Script:
#!/bin/bash
# ๋ก๊ทธ์์ ๊ด๋ จ ์ฝ๋ ์์ธ ํ์ธ
echo "=== use-logout.ts ==="
rg -A 10 "clearToken|logout" src/hooks/use-logout.ts
echo -e "\n=== logout-apis.ts ==="
rg -A 10 "clearToken|logout" src/_apis/auth/logout-apis.ts
echo -e "\n=== logout-queries.ts ==="
rg -A 10 "clearToken|logout" src/_queries/auth/logout-queries.ts
echo -e "\n=== header/container.tsx ==="
rg -A 10 "clearToken|logout" src/components/common/header/container.tsx
Length of output: 1789
src/hooks/use-logout.ts (1)
19-19: ์ฟผ๋ฆฌ ์ ๊ฑฐ ๋ฒ์๊ฐ ๋๋ฌด ๊ด๋ฒ์ํ ์ ์์
['user'] ํค๋ฅผ ์ฌ์ฉํ๋ ๋ชจ๋ ์ฟผ๋ฆฌ๋ฅผ ์ ๊ฑฐํ๋ ๊ฒ์ ์๋ํ์ง ์์ ๋ถ์์ฉ์ ์ผ์ผํฌ ์ ์์ต๋๋ค.
๋ ๊ตฌ์ฒด์ ์ธ ์ฟผ๋ฆฌ ํค๋ฅผ ์ฌ์ฉํ๊ฑฐ๋, ๋ก๊ทธ์์๊ณผ ๊ด๋ จ๋ ์ฟผ๋ฆฌ๋ง ์ ๊ฑฐํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์.
โ Verification successful
['user'] ์ฟผ๋ฆฌํค ์ ๊ฑฐ๋ ์ ์ ํฉ๋๋ค
์ฝ๋๋ฒ ์ด์ค ๋ถ์ ๊ฒฐ๊ณผ, ['user'] ์ฟผ๋ฆฌํค๋ ์ค์ง ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ๊ด๋ฆฌํ๋ ์ฉ๋๋ก๋ง ์ฌ์ฉ๋๊ณ ์์ต๋๋ค:
useUserํ ์์ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์กฐํํ ๋ ์ฌ์ฉClientProvider์์ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์๋ก๊ณ ์นจํ ๋ ์ฌ์ฉ- ๋ก๊ทธ์์ ๋ฐ ์ธ์ฆ ์ํ ํ ๊ธ ์ ์บ์ ์ ๊ฑฐ์ ์ฌ์ฉ
๋ฐ๋ผ์ ๋ก๊ทธ์์ ์ ํด๋น ์ฟผ๋ฆฌ๋ฅผ ์ ๊ฑฐํ๋ ๊ฒ์ ์๋๋ ๋์์ด๋ฉฐ, ๋ถ์์ฉ์ด ๋ฐ์ํ ์ฐ๋ ค๊ฐ ์์ต๋๋ค.
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: user ๊ด๋ จ ์ฟผ๋ฆฌ ํค ์ฌ์ฉ ํจํด ํ์ธ
# user ์ฟผ๋ฆฌ ํค๋ฅผ ์ฌ์ฉํ๋ ๋ชจ๋ ํ์ผ ๊ฒ์
rg "queryKey.*user" src/_queries/ -A 2 -B 2
Length of output: 345
Script:
#!/bin/bash
# ๋ก๊ทธ์์ ๊ด๋ จ ์ฝ๋์ user ์ฟผ๋ฆฌ ์ฌ์ฉ ํจํด์ ๋ ์์ธํ ๋ถ์
# 1. useLogout ํ
์ ์ ์ฒด ๊ตฌํ ํ์ธ
echo "=== useLogout hook implementation ==="
cat src/hooks/use-logout.ts
# 2. user-queries.ts ํ์ผ์ ์ ์ฒด ๋ด์ฉ ํ์ธ
echo -e "\n=== user-queries.ts implementation ==="
cat src/_queries/auth/user-queries.ts
# 3. ๋ค๋ฅธ ํ์ผ์์ user ์ฟผ๋ฆฌํค ์ฌ์ฉ ์ฌ๋ถ ํ์ธ (src/_queries ์ธ ๋๋ ํ ๋ฆฌ)
echo -e "\n=== Other usages of user queryKey ==="
rg "queryKey.*user" --glob !src/_queries/** -A 2 -B 2
Length of output: 2466
src/app/(crew)/crew/detail/[id]/_components/create-gathering/index.tsx (1)
5-5: ์ธ์ฆ ๊ด๋ฆฌ ๋ฐฉ์์ ๊ฐ์ ์ด ํ์ธ๋์์ต๋๋ค.
์คํ ์ด ๊ธฐ๋ฐ ์ธ์ฆ์์ ํ ๊ธฐ๋ฐ ์ธ์ฆ์ผ๋ก์ ์ ํ์ด ์ ์ด๋ฃจ์ด์ก์ต๋๋ค. ์ด๋ ์ํ ๊ด๋ฆฌ์ ์บก์ํ๋ฅผ ๊ฐ์ ํ๋ ์ข์ ๋ณ๊ฒฝ์ฌํญ์ ๋๋ค.
src/app/(crew)/_components/hero/hero-crew.tsx (2)
3-4: ์ธ์ฆ ๊ด๋ จ ํ
์ฌ์ฉ์ด ์ ์ ํฉ๋๋ค.
useAuth ์ปค์คํ
ํ
์ ์ฌ์ฉํ์ฌ ์ธ์ฆ ์ํ๋ฅผ ๊ด๋ฆฌํ๋ ๋ฐฉ์์ด ์ ๊ตฌํ๋์ด ์์ต๋๋ค. ํ์ฌ ๊ฒฝ๋ก๋ฅผ ์ ์ฅํ๊ธฐ ์ํ usePathname์ ์ฌ์ฉ๋ ์ ์ ํฉ๋๋ค.
Also applies to: 8-9
26-26: ๋ฆฌ๋ค์ด๋ ์
๋ก์ง์ด ๋ณด์์ ์ผ๋ก ์์ ํฉ๋๋ค.
์ธ์ฆ๋์ง ์์ ์ฌ์ฉ์๋ฅผ ์ํ ๋ฆฌ๋ค์ด๋ ์
์ฒ๋ฆฌ๊ฐ ์ ๊ตฌํ๋์ด ์์ต๋๋ค. ํ์ฌ ๊ฒฝ๋ก๋ฅผ redirect ํ๋ผ๋ฏธํฐ๋ก ์ ๋ฌํ์ฌ ๋ก๊ทธ์ธ ํ ์๋ ํ์ด์ง๋ก ๋์์ฌ ์ ์๋๋ก ํ๋ ๊ฒ์ด UX ์ธก๋ฉด์์ ์ข์ต๋๋ค.
๋ค๋ฅธ ํ์ด์ง์์๋ ๋์ผํ ๋ฆฌ๋ค์ด๋ ์ ํจํด์ด ์ฌ์ฉ๋๋์ง ํ์ธํ๊ฒ ์ต๋๋ค:
โ Verification successful
๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์ ๊ตฌํ์ด ์ผ๊ด๋๊ณ ์์ ํฉ๋๋ค.
์ฝ๋๋ฒ ์ด์ค ์ ์ฒด์์ ๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์ ํจํด์ ๊ฒํ ํ ๊ฒฐ๊ณผ:
- ๋ชจ๋ ๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์
์ด
/login?redirect=ํ์์ ์ผ๊ด๋๊ฒ ์ฌ์ฉ - ํ์ฌ ๊ฒฝ๋ก(
currentPath)๋ฅผ ์์ ํ๊ฒ ์ธ์ฝ๋ฉํ์ฌ ์ ๋ฌ - ์ธ์ฆ ์ํ(
isAuth)๋ฅผ ์ ์ ํ ํ์ธํ์ฌ ์กฐ๊ฑด๋ถ ๋ฆฌ๋ค์ด๋ ์ ์ฒ๋ฆฌ
๋ค์ ์์น์์ ๋์ผํ ํจํด์ด ํ์ธ๋์์ต๋๋ค:
src/app/(crew)/_components/hero/hero-crew.tsxsrc/app/(crew)/crew/detail/[id]/_components/gathering-list-section.tsxsrc/components/common/header/presenter.tsxsrc/app/(auth)/signup/page.tsx
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: ๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์
ํจํด์ ์ผ๊ด์ฑ ํ์ธ
# ๋ฆฌ๋ค์ด๋ ์
ํจํด ๊ฒ์
rg "login\?redirect=" --type tsx
Length of output: 62
Script:
#!/bin/bash
# Description: ๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์
ํจํด์ ์ผ๊ด์ฑ ํ์ธ
# ๋ฆฌ๋ค์ด๋ ์
ํจํด ๊ฒ์ (ํ์ผ ํ์ฅ์ ์์ )
rg "login\?redirect=" -t ts -t tsx -t jsx
# ์ ์ฒด์ ์ธ ๋ก๊ทธ์ธ ๊ด๋ จ URL ํจํด ๊ฒ์
rg "\/login.*redirect" -t ts -t tsx -t jsx
# currentPath๋ฅผ ์ฌ์ฉํ๋ ํจํด ๊ฒ์
rg "currentPath" -t ts -t tsx -t jsx -A 2 -B 2
Length of output: 275
Script:
#!/bin/bash
# Description: ๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์
ํจํด์ ์ผ๊ด์ฑ ํ์ธ
# ๋ชจ๋ ํ์ผ์์ ๋ก๊ทธ์ธ ๋ฆฌ๋ค์ด๋ ์
ํจํด ๊ฒ์
rg "login.*redirect"
# currentPath ์ฌ์ฉ ํจํด ๊ฒ์
rg "currentPath" -A 2 -B 2
# ๋ก๊ทธ์ธ ๊ด๋ จ ํ์ผ ์ฐพ๊ธฐ
fd "login" --type f
Length of output: 3756
src/app/(auth)/layout.tsx (1)
1-1: Suspense ์ปดํฌ๋ํธ ์ถ๊ฐ ์น์ธ
๋น๋๊ธฐ ์์ ์ ์ฒ๋ฆฌํ๊ธฐ ์ํ Suspense ์ปดํฌ๋ํธ ์ถ๊ฐ๋ ์ ์ ํด ๋ณด์ ๋๋ค.
src/app/(auth)/signup/page.tsx (1)
3-3: ์์กด์ฑ ๋ฐ ํ
์ค์ ์ด ์ ์ ํฉ๋๋ค.
ํ์ํ ํ ๋ค์ด ์ฌ๋ฐ๋ฅด๊ฒ ์ํฌํธ๋์๊ณ , redirect ์ํ๊ฐ ์ ์ ํ๊ฒ ์ด๊ธฐํ๋์์ต๋๋ค.
Also applies to: 6-6, 11-12
src/components/common/header/header.stories.tsx (2)
2-3: ์ํ ๊ด๋ฆฌ ๋ฐฉ์์ ๊ฐ์ ์ด ์ ์ด๋ฃจ์ด์ก์ต๋๋ค!
store ๊ธฐ๋ฐ ์ํ ๊ด๋ฆฌ์์ React Query๋ฅผ ํ์ฉํ ๋ฐฉ์์ผ๋ก ์ ํํ ๊ฒ์ด ์ข์ ๊ฐ์ ์ ๋๋ค. ์ด๋ ์๋ฒ ์ํ ๊ด๋ฆฌ๋ฅผ ๋์ฑ ํจ์จ์ ์ผ๋ก ๋ง๋ค์ด์ค ๊ฒ์ ๋๋ค.
19-20: ์ธ์ฆ ๊ด๋ จ ํ
์ ๊ตฌํ ํ์ธ์ด ํ์ํฉ๋๋ค.
useAuth ํ ๊ณผ ๊ด๋ จ ์ฟผ๋ฆฌ ๊ตฌํ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋์ด์๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
โ Verification successful
์ธ์ฆ ๊ด๋ จ ํ ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌํ๋์ด ์์ต๋๋ค.
useAuth์ useUser ํ ์ด ์ ์ ํ๊ฒ ๊ตฌํ๋์ด ์์ผ๋ฉฐ, ๋ค์๊ณผ ๊ฐ์ด ์ ์์ ์ผ๋ก ๋์ํ๊ณ ์์ต๋๋ค:
- useAuth ํ ์ useUser์ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ธ์ฆ ์ํ๋ฅผ ์ ๊ณต
- useUser ํ ์ ํ ํฐ ๊ธฐ๋ฐ์ผ๋ก ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์กฐํ
- Header ์ปดํฌ๋ํธ์์ ์ธ์ฆ ์ํ์ ์ฌ์ฉ์ ์ ๋ณด๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ฌ์ฉ๋จ
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify auth hooks implementation
# Check useAuth hook implementation
echo "Checking useAuth hook implementation..."
rg -A 10 "export.*useAuth"
# Check user queries implementation
echo "Checking user queries implementation..."
rg -A 10 "useUser.*=.*"
Length of output: 655
Script:
#!/bin/bash
# Check user query implementation details
echo "Checking user query implementation..."
rg -A 10 "useUser"
# Check auth store implementation
echo "Checking auth store implementation..."
rg -A 10 "type AuthState"
# Check query client usage with auth
echo "Checking query client usage with auth..."
rg -A 5 "useQueryClient.*auth"
Length of output: 2651
src/utils/api.ts (2)
Line range hint 3-15: API ์๋ฌ ์ฒ๋ฆฌ ๊ตฌํ์ด ์ ๋์ด์์ต๋๋ค
์๋ฌ ์ฒ๋ฆฌ ๊ตฌํ์ด ๋ค์๊ณผ ๊ฐ์ ์ ์์ ์ฐ์ํฉ๋๋ค:
- ์์ธํ ์ ํจ์ฑ ๊ฒ์ฌ ์๋ฌ ์ฒ๋ฆฌ
- HTTP ์ํ ์ฝ๋ ๊ด๋ฆฌ
- ํ์ ์์ ์ฑ ํ๋ณด
1-1: ์คํ ์ด ์ฌ์ฉ ๋ฐฉ์ ๋ณ๊ฒฝ์ ๋ํ ๊ฒํ ํ์
useAuthStore์์ authStore๋ก์ ๋ณ๊ฒฝ์ด ์ปดํฌ๋ํธ์ ๋ฐ์์ฑ์ ์ํฅ์ ๋ฏธ์น ์ ์์ต๋๋ค. ํนํ ๋ค์ ์ฌํญ๋ค์ ํ์ธํด์ฃผ์ธ์:
- ์ปดํฌ๋ํธ ๋ฆฌ๋ ๋๋ง์ด ํ์ํ ์ํฉ์์ ์ํ ๋ณ๊ฒฝ์ด ์ ๋๋ก ๊ฐ์ง๋๋์ง
- ๋ค๋ฅธ ํ์ผ๋ค์์๋ ๋์ผํ ๋ฐฉ์์ผ๋ก ์คํ ์ด๋ฅผ ์ฌ์ฉํ๊ณ ์๋์ง
Also applies to: 27-27
โ Verification successful
Let me analyze the results:
useAuthStoreis consistently used in React components and hooks for reactive state management- Direct
authStore.getState()is used in utility files (api.tsanduser-queries.ts) which are not React components - This pattern is intentional - hooks are used where reactivity is needed (components) and direct store access where it's not (utilities)
I can now provide the final response:
์คํ ์ด ์ฌ์ฉ ํจํด์ด ์ ์ ํ๊ฒ ๊ตฌํ๋์ด ์์ต๋๋ค
ํ์ฌ ๊ตฌํ์ ๋ค์๊ณผ ๊ฐ์ด ์๋๋ ํจํด์ ๋ฐ๋ฅด๊ณ ์์ต๋๋ค:
- React ์ปดํฌ๋ํธ์ ํ
์์๋ ๋ฐ์ํ ์ํ ๊ด๋ฆฌ๋ฅผ ์ํด
useAuthStore๋ฅผ ์ฌ์ฉ - ์ ํธ๋ฆฌํฐ ํจ์์ API ๊ด๋ จ ๋ก์ง์์๋
authStore.getState()๋ฅผ ์ง์ ์ฌ์ฉ
์ด๋ ์ผ๋ฐ์ ์ธ Zustand ํจํด์ ๋ฐ๋ฅด๋ ์ฌ๋ฐ๋ฅธ ๊ตฌํ์ ๋๋ค.
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: ์คํ ์ด ์ฌ์ฉ ๋ฐฉ์์ ์ผ๊ด์ฑ ํ์ธ
# useAuthStore ์ฌ์ฉ ํจํด ๊ฒ์
echo "useAuthStore ์ฌ์ฉ ํํฉ:"
rg "useAuthStore" -A 2
# authStore ์ง์ ์ฌ์ฉ ํจํด ๊ฒ์
echo "\nauthStore ์ง์ ์ฌ์ฉ ํํฉ:"
rg "authStore\.getState" -A 2
Length of output: 3353
src/app/(auth)/login/_component/login-form.tsx (2)
1-3: ์๋ก์ด ํ
์ฌ์ฉ์ ๋ํ ๊ฒํ
useDebouncedValue๋ฅผ ์ฌ์ฉํ ๋๋ฐ์ด์ฑ ์ฒ๋ฆฌ๋ ๋ถํ์ํ API ํธ์ถ์ ๋ฐฉ์งํ๋ ์ข์ ์ ๊ทผ ๋ฐฉ์์
๋๋ค.
29-35: ๋๋ฐ์ด์ค ๋ก์ง ๊ฒ์ฆ ํ์
๋๋ฐ์ด์ค ์๊ฐ์ด 1์ด๋ก ์ค์ ๋์ด ์๋๋ฐ, ์ด๋ ์ฌ์ฉ์ ๊ฒฝํ์ ์ํฅ์ ์ค ์ ์์ต๋๋ค. ์ค์ ์ฌ์ฉ์ ํ ์คํธ๋ฅผ ํตํด ์ ์ ํ ์๊ฐ์ ๊ฒ์ฆํด์ฃผ์ธ์.
๋ ๋์ ์ฌ์ฉ์ ๊ฒฝํ์ ์ํด ๋ค์ ์ฌํญ๋ค์ ๊ณ ๋ คํด๋ณด์ธ์:
- ๋๋ฐ์ด์ค ์๊ฐ์ 500ms๋ก ์ค์ด๋ ๊ฒ
- ํ๊ฒฝ ๋ณ์๋ก ๋๋ฐ์ด์ค ์๊ฐ์ ์ค์ ํ์ฌ ์ฝ๊ฒ ์กฐ์ ํ ์ ์๋๋ก ํ๋ ๊ฒ
| retry: (failureCount, error) => { | ||
| if (error.message === 'ํ ํฐ์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.') { | ||
| return false; | ||
| } | ||
| return failureCount <= 1; | ||
| }, |
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.
์๋ฌ ์ฒ๋ฆฌ ์กฐ๊ฑด์ ์์ ์ฑ ๊ฐ์ ํ์
ํ์ฌ retry ์ต์
์์ error.message๋ฅผ ์ง์ ๋น๊ตํ๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ error ๊ฐ์ฒด์ message ์์ฑ์ด ํญ์ ์กด์ฌํ๋ค๊ณ ๋ณด์ฅํ ์ ์์ต๋๋ค. error์ ํ์
์ ํ์ธํ๊ฑฐ๋ instanceof ๋ฑ์ ์ฌ์ฉํ์ฌ ๋ณด๋ค ์์ ์ ์ธ ์๋ฌ ์ฒ๋ฆฌ๋ฅผ ๊ตฌํํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
| onError: async (error, query) => { | ||
| if (error.message === 'ํ ํฐ์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.') { | ||
| const { token } = await reissue(); | ||
| if (token) setToken(token.replace(/^Bearer\s/, '')); | ||
| await Promise.all([ | ||
| queryClient.refetchQueries({ queryKey: query.queryKey }), | ||
| queryClient.refetchQueries({ queryKey: ['user'] }), | ||
| ]); | ||
| } | ||
| }, |
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.
onError ํธ๋ค๋ฌ์ ์์ธ ์ฒ๋ฆฌ ๊ฐํ ํ์
reissue ํจ์ ํธ์ถ์ด ์คํจํ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ ์์ธ ์ฒ๋ฆฌ๊ฐ ํ์ํฉ๋๋ค. ์ฌ๋ฐ๊ธ์ ์คํจํ๋ฉด ๋ฌดํ ๋ฃจํ์ ๋น ์ง ์ ์์ผ๋ฏ๋ก, ์ฌ์๋ ํ์๋ฅผ ์ ํํ๊ฑฐ๋ ์ฌ์ฉ์์๊ฒ ์ธ์ฆ์ด ๋ง๋ฃ๋์์์ ์๋ฆฌ๋ ๋ก์ง์ ์ถ๊ฐํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.
| } | ||
| }, |
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.
๐ ๏ธ Refactor suggestion
์์์น ๋ชปํ ์๋ฌ์ ๋ํ ์ฒ๋ฆฌ ํ์
ํ์ฌ if (error.message === 'ํ ํฐ์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.') ์กฐ๊ฑด์ ํด๋นํ์ง ์๋ ์๋ฌ๋ ๋ฌด์๋๊ณ ์์ต๋๋ค. ์์์น ๋ชปํ ์๋ฌ์ ๋ํด์๋ ๋ก๊น
ํ๊ฑฐ๋ ์ฌ์ฉ์์๊ฒ ์๋ฆด ์ ์๋๋ก ์ฒ๋ฆฌํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
| import { useUser } from '../_queries/auth/user-queries'; | ||
|
|
||
| export function useAuth() { | ||
| const { data: user } = useUser(); | ||
| const isAuth = !!user; | ||
| return { isAuth }; | ||
| } |
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.
๐ ๏ธ Refactor suggestion
๊ธฐ๋ณธ ๊ตฌํ์ ์ข์ผ๋ ๊ฐ์ ์ด ํ์ํฉ๋๋ค.
ํ ์ ๊ธฐ๋ณธ ๊ตฌํ์ ๊ฐ๋จํ๊ณ ๋ช ํํ๋, ๋ค์ ์ฌํญ๋ค์ ๊ณ ๋ คํด ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค:
- ํ์ ์์ ์ฑ ํฅ์์ ์ํด ๋ฐํ ํ์ ์ ๋ช ์์ ์ผ๋ก ์ ์ํด ์ฃผ์ธ์.
- useUser ์ฟผ๋ฆฌ ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๋๋ฝ๋์ด ์์ต๋๋ค.
- JSDoc ๋ฌธ์ํ๋ฅผ ์ถ๊ฐํ๋ฉด ์ข๊ฒ ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํด ๋ณด์๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
+interface AuthHookReturn {
+ isAuth: boolean;
+}
+
+/**
+ * ์ฌ์ฉ์ ์ธ์ฆ ์ํ๋ฅผ ํ์ธํ๋ ํ
+ * @returns {AuthHookReturn} ์ธ์ฆ ์ํ ๊ฐ์ฒด
+ */
export function useAuth() {
- const { data: user } = useUser();
+ const { data: user, error } = useUser();
+
+ if (error) {
+ console.error('์ธ์ฆ ์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์:', error);
+ }
+
const isAuth = !!user;
- return { isAuth };
+ return { isAuth } as AuthHookReturn;
}๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { useUser } from '../_queries/auth/user-queries'; | |
| export function useAuth() { | |
| const { data: user } = useUser(); | |
| const isAuth = !!user; | |
| return { isAuth }; | |
| } | |
| interface AuthHookReturn { | |
| isAuth: boolean; | |
| } | |
| /** | |
| * ์ฌ์ฉ์ ์ธ์ฆ ์ํ๋ฅผ ํ์ธํ๋ ํ | |
| * @returns {AuthHookReturn} ์ธ์ฆ ์ํ ๊ฐ์ฒด | |
| */ | |
| export function useAuth() { | |
| const { data: user, error } = useUser(); | |
| if (error) { | |
| console.error('์ธ์ฆ ์ํ ํ์ธ ์ค ์ค๋ฅ ๋ฐ์:', error); | |
| } | |
| const isAuth = !!user; | |
| return { isAuth } as AuthHookReturn; | |
| } |
| export function useUser() { | ||
| const { token } = authStore.getState(); | ||
| return useQuery({ | ||
| queryKey: ['user'], | ||
| queryFn: getUser, | ||
| enabled: !!token, | ||
| }); | ||
| } |
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.
๐ ๏ธ Refactor suggestion
ํ ํฐ ์ ํจ์ฑ ๊ฒ์ฆ ๊ฐํ ํ์
ํ์ฌ ๊ตฌํ์ ํ ํฐ์ ์กด์ฌ ์ฌ๋ถ๋ง ํ์ธํ๊ณ ์์ต๋๋ค. ๋ณด์ ๊ฐํ๋ฅผ ์ํด ๋ค์ ์ฌํญ๋ค์ ๊ณ ๋ คํด์ฃผ์ธ์:
- ํ ํฐ ๋ง๋ฃ ์ฌ๋ถ ํ์ธ
- ํ ํฐ ํ์ ๊ฒ์ฆ
- ์๋ฌ ์ฒ๋ฆฌ ๋ก์ง ์ถ๊ฐ
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
export function useUser() {
const { token } = authStore.getState();
+ const isValidToken = token && !isTokenExpired(token);
return useQuery({
queryKey: ['user'],
queryFn: getUser,
- enabled: !!token,
+ enabled: isValidToken,
+ retry: false,
+ onError: (error) => {
+ if (error.response?.status === 401) {
+ authStore.getState().logout();
+ }
+ },
});
}Committable suggestion skipped: line range outside the PR's diff.
| <Link | ||
| href={redirect !== '/' ? `/login?redirect=${redirect}` : '/login'} | ||
| className="text-blue-500 underline" | ||
| > |
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.
๐ ๏ธ Refactor suggestion
URL ์ธ์ฝ๋ฉ์ด ํ์ํฉ๋๋ค.
๋ฆฌ๋ค์ด๋ ํธ URL์ ํน์ ๋ฌธ์๊ฐ ํฌํจ๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ URL ์ธ์ฝ๋ฉ์ด ํ์ํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์์ ํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
<Link
- href={redirect !== '/' ? `/login?redirect=${redirect}` : '/login'}
+ href={redirect !== '/' ? `/login?redirect=${encodeURIComponent(redirect)}` : '/login'}
className="text-blue-500 underline"
>๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <Link | |
| href={redirect !== '/' ? `/login?redirect=${redirect}` : '/login'} | |
| className="text-blue-500 underline" | |
| > | |
| <Link | |
| href={redirect !== '/' ? `/login?redirect=${encodeURIComponent(redirect)}` : '/login'} | |
| className="text-blue-500 underline" | |
| > |
| useEffect(() => { | ||
| const redirectParam = searchParams.get('redirect'); | ||
| if (redirectParam) setRedirect(redirectParam); | ||
| }, [searchParams]); |
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.
๋ฆฌ๋ค์ด๋ ํธ URL์ ์ ํจ์ฑ ๊ฒ์ฆ์ด ํ์ํฉ๋๋ค.
ํ์ฌ ๊ตฌํ์์๋ ๋ฆฌ๋ค์ด๋ ํธ URL์ ๋ํ ์ ํจ์ฑ ๊ฒ์ฆ์ด ์์ด ์ ์ฌ์ ์ธ ๋ณด์ ์ํ์ด ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์์ ํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
useEffect(() => {
const redirectParam = searchParams.get('redirect');
- if (redirectParam) setRedirect(redirectParam);
+ if (redirectParam && redirectParam.startsWith('/') && !redirectParam.includes('//')) {
+ setRedirect(redirectParam);
+ }
}, [searchParams]);๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| const redirectParam = searchParams.get('redirect'); | |
| if (redirectParam) setRedirect(redirectParam); | |
| }, [searchParams]); | |
| useEffect(() => { | |
| const redirectParam = searchParams.get('redirect'); | |
| if (redirectParam && redirectParam.startsWith('/') && !redirectParam.includes('//')) { | |
| setRedirect(redirectParam); | |
| } | |
| }, [searchParams]); |
| const handleFormSubmit = handleSubmit(async (data) => { | ||
| onSubmit(data); | ||
| cancelDebouncedEmail(); | ||
| cancelDebouncedPassword(); | ||
| }); |
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 handleFormSubmit = handleSubmit(async (data) => {
+ cancelDebouncedEmail();
+ cancelDebouncedPassword();
onSubmit(data);
- cancelDebouncedEmail();
- cancelDebouncedPassword();
});๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const handleFormSubmit = handleSubmit(async (data) => { | |
| onSubmit(data); | |
| cancelDebouncedEmail(); | |
| cancelDebouncedPassword(); | |
| }); | |
| const handleFormSubmit = handleSubmit(async (data) => { | |
| cancelDebouncedEmail(); | |
| cancelDebouncedPassword(); | |
| onSubmit(data); | |
| }); |
| href={isAuth ? href : `/login?redirect=${href}`} | ||
| className={`${ | ||
| pathname.startsWith(href) ? 'text-white' : 'text-blue-300' | ||
| } ml-4 text-sm font-semibold md:text-lg`} |
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.
๐ ๏ธ Refactor suggestion
๋ฆฌ๋ค์ด๋ ํธ ํ๋ผ๋ฏธํฐ์ ์์ ํ ์ฒ๋ฆฌ๊ฐ ํ์ํฉ๋๋ค
๋ณ๊ฒฝ๋ ์ธ์ฆ ํ๋ฆ์ ์ ์ ํ๊ฒ ๊ตฌํ๋์์ต๋๋ค. ํ์ง๋ง ๋ฆฌ๋ค์ด๋ ํธ URL์ ์์ ํ ์ฒ๋ฆฌ๋ฅผ ์ํด ์ธ์ฝ๋ฉ์ด ํ์ํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์์ ํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
-href={isAuth ? href : `/login?redirect=${href}`}
+href={isAuth ? href : `/login?redirect=${encodeURIComponent(href)}`}์ด๋ ๊ฒ ์์ ํ๋ฉด:
- URL์ ํฌํจ๋ ์ ์๋ ํน์ ๋ฌธ์๋ค์ด ์์ ํ๊ฒ ์ฒ๋ฆฌ๋ฉ๋๋ค
- ๋ฆฌ๋ค์ด๋ ํธ ํ๋ผ๋ฏธํฐ๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ ๋ฌ๋ฉ๋๋ค
๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| href={isAuth ? href : `/login?redirect=${href}`} | |
| className={`${ | |
| pathname.startsWith(href) ? 'text-white' : 'text-blue-300' | |
| } ml-4 text-sm font-semibold md:text-lg`} | |
| href={isAuth ? href : `/login?redirect=${encodeURIComponent(href)}`} | |
| className={`${ | |
| pathname.startsWith(href) ? 'text-white' : 'text-blue-300' | |
| } ml-4 text-sm font-semibold md:text-lg`} |
| useEffect(() => { | ||
| if (debouncedNickname) trigger('nickname'); | ||
| }, [nickname, trigger]); | ||
|
|
||
| useEffect(() => { | ||
| if (debouncedEmail) trigger('email'); | ||
| }, [email, trigger]); | ||
|
|
||
| useEffect(() => { | ||
| if (password) { | ||
| if (debouncedPassword) { | ||
| trigger('password'); | ||
| trigger('confirmPassword'); | ||
| } | ||
| }, [password, trigger]); | ||
|
|
||
| useEffect(() => { | ||
| if (debouncedConfirmPassword) trigger('confirmPassword'); | ||
| }, [confirmPassword, trigger]); |
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.
๐ ๏ธ Refactor suggestion
์ ํจ์ฑ ๊ฒ์ฆ ๋ก์ง์ด ์ค๋ณต๋์ด ์์ต๋๋ค.
๊ฐ ํ๋๋ง๋ค ๋น์ทํ useEffect ํ
์ด ๋ฐ๋ณต๋๊ณ ์์ต๋๋ค. ์ด๋ ์ฝ๋์ ์ ์ง๋ณด์์ฑ์ ์ ํ์ํฌ ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ํ๋์ useEffect๋ก ํตํฉํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค:
useEffect(() => {
const fields = {
nickname: debouncedNickname,
email: debouncedEmail,
password: debouncedPassword,
confirmPassword: debouncedConfirmPassword,
};
Object.entries(fields).forEach(([field, value]) => {
if (value) {
trigger(field as keyof SignupFormValues);
if (field === 'password') {
trigger('confirmPassword');
}
}
});
}, [debouncedNickname, debouncedEmail, debouncedPassword, debouncedConfirmPassword, trigger]);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.
Actionable comments posted: 0
๐งน Outside diff range and nitpick comments (4)
src/app/(crew)/my-page/_components/profile-card/container.tsx (4)
20-21: ์ฃผ์ ์ฒ๋ฆฌ๋ ์ฝ๋ ์ ๊ฑฐ ํ์๋ ์ด์ ์ฌ์ฉํ์ง ์๋ ์ฃผ์ ์ฒ๋ฆฌ๋ ์ฝ๋๋ ์ ๊ฑฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๋ ์ฝ๋์ ๊ฐ๋ ์ฑ์ ํฅ์์ํค๊ณ ์ ์ง๋ณด์๋ฅผ ์ฉ์ดํ๊ฒ ๋ง๋ญ๋๋ค.
- // const { rehydrated, setUser } = useAuthStore(); - // const [user, setLocalUser] = useState<User | null>(null);
Line range hint
27-50: ์ธ์ฆ ๋ก์ง ๊ฐ์ ์ด ํ์ํฉ๋๋ค.ํ์ฌ ๊ตฌํ์์ ๋ช ๊ฐ์ง ์ ์ฌ์ ์ธ ๋ฌธ์ ์ ์ด ์์ต๋๋ค:
- ๋ถํ์ํ API ํธ์ถ์ด ๋ฐ์ํ ์ ์์ต๋๋ค.
useUserํ ์์ ์ด๋ฏธ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ค๊ณ ์๋๋ฐ,fetchUpdatedUser๋ฅผ ๋ค์ ํธ์ถํ๊ณ ์์ต๋๋ค.- ์๋ฌ ์ฒ๋ฆฌ๊ฐ ์ค๋ณต๋ ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ๋ฆฌํฉํ ๋งํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
useEffect(() => { const checkAuthAndLoadUser = async () => { - if (!isAuth) { - router.push('/login'); - return; - } - - setIsLoading(true); - - try { - const updatedUser = await fetchUpdatedUser(); - setProfileImageUrl(updatedUser.profileImageUrl); - } catch { - toast.error('์ ์ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ค๋ ๋ฐ ์คํจํ์ต๋๋ค.'); - } finally { - setIsLoading(false); - } + if (!isAuth) { + router.push('/login'); + return; + } + + if (user) { + setProfileImageUrl(user.profileImageUrl); + setIsLoading(false); + } }; checkAuthAndLoadUser(); - }, [isAuth, router]); + }, [isAuth, router, user]);
77-78: ์ํ ์ ๋ฐ์ดํธ ๋ก์ง ๊ฐ์ ํ์ํ๋กํ ์ด๋ฏธ์ง ์ ๋ฐ์ดํธ ํ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ค์ ๊ฐ์ ธ์ค๋ ๋ก์ง์ด ์ค๋ณต๋ฉ๋๋ค.
useUserํ ์ ์บ์ ๋ฌดํจํ๋ฅผ ํตํด ์ด๋ฅผ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ๋ ํจ์จ์ ์ผ ์ ์์ต๋๋ค.
92-94: ๋ถํ์ํ ์ฃผ์ ์ ๊ฑฐ ๋ฐ ๋ก์ง ๊ฐ์ ํ์์ฌ์ฉํ์ง ์๋ ์ฃผ์ ์ฒ๋ฆฌ๋ ์ฝ๋๋ฅผ ์ ๊ฑฐํ๊ณ , ์ํ ์ ๋ฐ์ดํธ ๋ก์ง์ ๋จ์ํํ ํ์๊ฐ ์์ต๋๋ค.
- // setLocalUser(updatedUser); - // setUser(updatedUser);
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
๐ Files selected for processing (2)
src/app/(crew)/crew/detail/[id]/_components/detail-crew-container.tsx(2 hunks)src/app/(crew)/my-page/_components/profile-card/container.tsx(5 hunks)
๐ Additional comments (4)
src/app/(crew)/my-page/_components/profile-card/container.tsx (1)
11-19: ํ
์ฌ์ฉ ๋ฐฉ์์ ๊ฐ์ ์ด ํ์ธ๋์์ต๋๋ค.
์ํ ๊ด๋ฆฌ๊ฐ ๋ ๊ฐ๋จํ๊ณ ๋ช
ํํด์ก์ต๋๋ค. useAuth์ useUser ํ
์ ๋ถ๋ฆฌํ์ฌ ์ฌ์ฉํจ์ผ๋ก์จ ๊ด์ฌ์ฌ ๋ถ๋ฆฌ๊ฐ ์ ์ด๋ฃจ์ด์ก์ต๋๋ค.
src/app/(crew)/crew/detail/[id]/_components/detail-crew-container.tsx (3)
8-8: ์ธ์ฆ ์ํ ๊ด๋ฆฌ ๋ฐฉ์์ด ๊ฐ์ ๋์์ต๋๋ค.
๊ธฐ์กด์ store ๊ธฐ๋ฐ ์ํ ๊ด๋ฆฌ์์ ์ฟผ๋ฆฌ ๊ธฐ๋ฐ์ผ๋ก ์ ํํ ๊ฒ์ด ์ข์ ๋ณ๊ฒฝ์ฌํญ์ผ๋ก ๋ณด์ ๋๋ค. ์ด๋ ์๋ฒ ์ํ์ ํด๋ผ์ด์ธํธ ์ํ๋ฅผ ๋ ๋ช ํํ๊ฒ ๋ถ๋ฆฌํ ์ ์๊ฒ ํด์ค๋๋ค.
27-27: ๐ ๏ธ Refactor suggestion
์ฌ์ฉ์ ๋ฐ์ดํฐ ์ฒ๋ฆฌ ๋ฐฉ์ ๊ฒํ ๊ฐ ํ์ํฉ๋๋ค.
useUser ํ ์์ ๋ฐํ๋๋ ๋ฐ์ดํฐ์ ๋ก๋ฉ ์ํ์ ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๋๋ฝ๋์ด ์์ต๋๋ค. ๋ฐ์ดํฐ๊ฐ ์๋ ๊ฒฝ์ฐ์ ๋ํ ์ฒ๋ฆฌ๊ฐ ํ์ํ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์ ์คํฌ๋ฆฝํธ๋ก ๋ค๋ฅธ ์ปดํฌ๋ํธ์์์ useUser ํ ์ฌ์ฉ ํจํด์ ํ์ธํด๋ณด๊ฒ ์ต๋๋ค:
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
- const { data: user } = useUser();
+ const { data: user, error, isLoading } = useUser();
+
+ if (isLoading) {
+ return <p>์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ถ๋ฌ์ค๋ ์ค...</p>;
+ }
+
+ if (error) {
+ return <p>์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค.</p>;
+ }Line range hint 29-34: ํ์
๊ฒ์ฌ ๋ก์ง์ ๋จ์ํํ ์ ์์ต๋๋ค.
ํ์ฌ ๊ตฌํ๋ ํ์ ๊ฐ๋์ ID ์ถ์ถ ๋ก์ง์ด ๋ถํ์ํ๊ฒ ๋ณต์กํด ๋ณด์ ๋๋ค. useUser ํ ์ ๋ฐํ ํ์ ์ ๋ช ํํ ์ ์ํ๋ฉด ์ด๋ฐ ๋ณต์กํ ํ์ ๊ฒ์ฌ๊ฐ ํ์ํ์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ๋จ์ํํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
- const isDataWrappedUser = (value: unknown): value is { data: User } => {
- return typeof value === 'object' && value !== null && 'data' in value;
- };
-
- const currentUserId = isDataWrappedUser(user) ? user.data.id : user?.id;
+ const currentUserId = user?.id;์ด๋ฅผ ์ํด์๋ useUser ํ ์ ๋ฐํ ํ์ ์ด ์ผ๊ด๋๊ฒ ์ ์๋์ด ์์ด์ผ ํฉ๋๋ค.
๋ค์ ์คํฌ๋ฆฝํธ๋ก useUser ํ ์ ์ ์๋ฅผ ํ์ธํด๋ณด๊ฒ ์ต๋๋ค:
|
๐storybook: https://67206cc6ff9d7a05a3528ff8-nsbqdmnyce.chromatic.com/ |
HaeJungg
left a comment
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.
์๊ณ ํ์ จ์ต๋๋ค๐๐ ๋ก๊ทธ์ธ ๋ก๊ทธ์์์ด ์ ค ํ๋ ๊ฑฐ๊ฐ์์...๐ฅน
yulrang
left a comment
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.
๊ณ ์๋ง์์ด์ ใ ใ ใ
๐ Issue Ticket
Ticket
โ๏ธ Description
โ Checklist
PR
Test
Summary by CodeRabbit
๋ฆด๋ฆฌ์ค ๋ ธํธ
์ ๊ท ๊ธฐ๋ฅ
๋ฒ๊ทธ ์์
๋ฌธ์ํ