From d6572647d9d193012286d0bc3b5b0ab78fbb0f40 Mon Sep 17 00:00:00 2001 From: Jeongwoo Park <121204715+lurgi@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:39:29 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20API=20=EB=AA=85=EC=84=B8=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EC=82=AC=ED=95=AD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/domain/auth.ts | 2 +- frontend/src/hooks/useSignIn/index.tsx | 6 ++---- frontend/src/mocks/handlers/authHandlers.ts | 13 +++++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/src/api/domain/auth.ts b/frontend/src/api/domain/auth.ts index 1b496ec96..b7b827f62 100644 --- a/frontend/src/api/domain/auth.ts +++ b/frontend/src/api/domain/auth.ts @@ -5,7 +5,7 @@ const apiClient = new APIClient(AUTH); const authApi = { login: async ({ email, password }: { email: string; password: string }) => - apiClient.post({ + apiClient.post<{ clubId: string }>({ path: '/login', body: { email, password }, }), diff --git a/frontend/src/hooks/useSignIn/index.tsx b/frontend/src/hooks/useSignIn/index.tsx index 17746d6e4..d8f71b4f6 100644 --- a/frontend/src/hooks/useSignIn/index.tsx +++ b/frontend/src/hooks/useSignIn/index.tsx @@ -6,10 +6,8 @@ export default function useSignIn() { const navigate = useNavigate(); const signInMutate = useMutation({ mutationFn: ({ email, password }: { email: string; password: string }) => authApi.login({ email, password }), - onSuccess: () => { - // 로그인 성공 후 수행할 작업이 있다면 여기에 작성 - // queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.USER_DATA] }); - navigate('dashboard/1/posts'); + onSuccess: ({ clubId }) => { + navigate(`dashboard/${clubId}/posts`); }, onError: (error) => { window.alert(error.message); diff --git a/frontend/src/mocks/handlers/authHandlers.ts b/frontend/src/mocks/handlers/authHandlers.ts index 4e05c0c90..60694e734 100644 --- a/frontend/src/mocks/handlers/authHandlers.ts +++ b/frontend/src/mocks/handlers/authHandlers.ts @@ -1,6 +1,5 @@ import { AUTH } from '@api/endPoint'; import { http } from 'msw'; -import { Success } from './response'; interface LoginFormData { email: string; @@ -18,7 +17,17 @@ const authHandlers = [ }); } - return Success(); + const responseBody = JSON.stringify({ + clubId: 1, + }); + + return new Response(responseBody, { + status: 201, + statusText: 'Created', + headers: { + 'Content-Type': 'application/json', + }, + }); }), ];