diff --git a/packages/frontend/src/apis/queries/auth/index.ts b/packages/frontend/src/apis/queries/auth/index.ts new file mode 100644 index 00000000..303df780 --- /dev/null +++ b/packages/frontend/src/apis/queries/auth/index.ts @@ -0,0 +1 @@ +export * from './useGetLoginStatus'; diff --git a/packages/frontend/src/apis/queries/auth/types.ts b/packages/frontend/src/apis/queries/auth/types.ts new file mode 100644 index 00000000..2ec8c5a4 --- /dev/null +++ b/packages/frontend/src/apis/queries/auth/types.ts @@ -0,0 +1,3 @@ +export interface GetLoginStatusResponse { + message: 'Authenticated' | 'Not Authenticated'; +} diff --git a/packages/frontend/src/apis/queries/auth/useGetLoginStatus.ts b/packages/frontend/src/apis/queries/auth/useGetLoginStatus.ts new file mode 100644 index 00000000..4d68f335 --- /dev/null +++ b/packages/frontend/src/apis/queries/auth/useGetLoginStatus.ts @@ -0,0 +1,15 @@ +import { useQuery } from '@tanstack/react-query'; +import { GetLoginStatusResponse } from './types'; +import { instance } from '@/apis/config'; + +const getLoginStatus = async (): Promise => { + const { data } = await instance.get('/api/auth/google/status'); + return data; +}; + +export const useGetLoginStatus = () => { + return useQuery({ + queryKey: ['login_status'], + queryFn: getLoginStatus, + }); +}; diff --git a/packages/frontend/src/components/layouts/Sidebar.tsx b/packages/frontend/src/components/layouts/Sidebar.tsx index bf4a5682..b8195f44 100644 --- a/packages/frontend/src/components/layouts/Sidebar.tsx +++ b/packages/frontend/src/components/layouts/Sidebar.tsx @@ -63,7 +63,7 @@ export const Sidebar = () => {
diff --git a/packages/frontend/src/pages/login/Login.tsx b/packages/frontend/src/pages/login/Login.tsx index 33b0551f..67b13ef3 100644 --- a/packages/frontend/src/pages/login/Login.tsx +++ b/packages/frontend/src/pages/login/Login.tsx @@ -1,7 +1,5 @@ import { Link } from 'react-router-dom'; import google from '@/assets/google.png'; -import kakao from '@/assets/kakao.png'; -import naver from '@/assets/naver.png'; interface LoginButtonProps { to: string; @@ -10,6 +8,8 @@ interface LoginButtonProps { } export const Login = () => { + const googleLoginUrl = '/api/auth/google/login'; + return (
@@ -19,9 +19,11 @@ export const Login = () => {

주춤주춤과 함께해요!

- - - +
diff --git a/packages/frontend/src/pages/my-page/MyPage.tsx b/packages/frontend/src/pages/my-page/MyPage.tsx index b56bab0f..683ac4e9 100644 --- a/packages/frontend/src/pages/my-page/MyPage.tsx +++ b/packages/frontend/src/pages/my-page/MyPage.tsx @@ -1,3 +1,34 @@ +import { Link } from 'react-router-dom'; +import { useGetLoginStatus } from '@/apis/queries/auth'; + export const MyPage = () => { - return
마이페이지
; + const { data: loginStatus } = useGetLoginStatus(); + + return ( +
+

마이페이지

+
+
+
+ {loginStatus?.message === 'Authenticated' ? ( + '내정보' + ) : ( + + 로그인 + + )} +
+
+ 알림 +
+
+
+ 주식 정보 +
+
+
+ ); };