diff --git a/.gitignore b/.gitignore index d7de12f3..a5209e50 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,9 @@ dist-ssr *.njsproj *.sln *.sw? + +.env +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/src/constants/index.ts b/src/constants/index.ts new file mode 100644 index 00000000..6cc1e6e2 --- /dev/null +++ b/src/constants/index.ts @@ -0,0 +1 @@ +export * from './login'; diff --git a/src/constants/login.ts b/src/constants/login.ts new file mode 100644 index 00000000..f1e67425 --- /dev/null +++ b/src/constants/login.ts @@ -0,0 +1,24 @@ +export const socialLoginProvider = { + apple: { + url: 'https://appleid.apple.com/auth/authorize', + config: { + client_id: import.meta.env.VITE_APPLE_CLIENT_ID, + redirect_uri: import.meta.env.VITE_APPLE_REDIRECT_URL, + response_type: 'code id_token', + state: 'origin:web', + scope: 'name email', + response_mode: 'form_post', + m: 11, + v: '1.5.4', + // TODO: 임시 속성들. 추후 논의 후 수정해야 함 + }, + }, + kakao: { + url: 'https://kauth.kakao.com/oauth/authorize', + config: { + client_id: import.meta.env.VITE_KAKAO_CLIENT_ID, + redirect_uri: import.meta.env.VITE_KAKAO_REDIRECT_URL, + response_type: 'code', + }, + }, +}; diff --git a/src/pages/LoginPage.tsx b/src/pages/LoginPage.tsx index 6f708ad4..0ebbe644 100644 --- a/src/pages/LoginPage.tsx +++ b/src/pages/LoginPage.tsx @@ -1,14 +1,38 @@ +import { socialLoginProvider } from '@/constants'; +import { SocialLoginProviderType } from '@/types'; + export default function LoginPage() { - const KAKAO_REST_API_KEY = ''; // TODO: 임시 KEY - const KAKAO_REDIRECT_URI = 'http://localhost:5173/redirect'; // TODO: 임시 URL - const kakaoLoginLink = `https://kauth.kakao.com/oauth/authorize?client_id=${KAKAO_REST_API_KEY}&redirect_uri=${KAKAO_REDIRECT_URI}&response_type=code`; + const makeQueryString = ( + config: Record, + ) => { + return Object.entries(config) + .map(([key, value]) => `${key}=${encodeURIComponent(value)}`) + .join('&'); + }; + + const makeSocialLoginUrl = (provider: SocialLoginProviderType) => { + const { url, config } = socialLoginProvider[provider]; + const queryString = makeQueryString(config); + + return `${url}?${queryString}`; + }; + + const handleKakaoLogin = () => { + window.location.href = makeSocialLoginUrl('kakao'); + }; + + const handleAppleLogin = () => { + window.location.href = makeSocialLoginUrl('apple'); + }; - const handleLogin = () => (window.location.href = kakaoLoginLink); return (
- +
); } diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index 7514a86a..eecc7084 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -1,30 +1,16 @@ -import reactLogo from '@/assets/react.svg'; import { useTmap } from '@/hooks/useTmap'; -import viteLogo from '/vite.svg'; - function MainPage() { - - const { tmapModuleRef, mapContainerRef } = useTmap({ + const { /*tmapModuleRef, */ mapContainerRef } = useTmap({ mapId: 'tmap', latitude: 37.5652045, longitude: 126.98702028, }); return ( -
-
- - Vite logo - - - React logo - -
+
+
+
); } diff --git a/src/pages/RedirectionPage.tsx b/src/pages/RedirectionPage.tsx deleted file mode 100644 index f1bd6101..00000000 --- a/src/pages/RedirectionPage.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function RedirectionPage() { - return ( -
-

Redirection Page

-
- ); -} diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 00000000..6cc1e6e2 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1 @@ +export * from './login'; diff --git a/src/types/login.ts b/src/types/login.ts new file mode 100644 index 00000000..d8ba4564 --- /dev/null +++ b/src/types/login.ts @@ -0,0 +1 @@ +export type SocialLoginProviderType = 'apple' | 'kakao'; diff --git a/vite-env.d.ts b/vite-env.d.ts new file mode 100644 index 00000000..0f74149d --- /dev/null +++ b/vite-env.d.ts @@ -0,0 +1,10 @@ +interface ImportMetaEnv { + readonly VITE_KAKAO_CLIENT_ID: string; + readonly VITE_KAKAO_REDIRECTION_URL: string; + readonly VITE_APPLE_CLIENT_ID: string; + readonly VITE_APPLE_REDIRECT_URL: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +}