Skip to content
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

페이지 기능: 로그인 페이지 카카오 UI 제작 #174

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/assets/kakao_login_medium_wide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useForm } from 'react-hook-form';
import classNames from 'classnames/bind';
import Link from 'next/link';

import KakaoLoginButton from '@components/home/kakao-login-button/KakaoLoginButton';
import VALIDATION_MESSAGE_MAP from '@constants/validationMessage';
import { ISignIn } from '@remote/api/types/auth';
import useLogin from '@remote/queries/auth/useLogin';
Expand Down Expand Up @@ -37,7 +38,7 @@ function LoginPage() {

/* -- redux test -- */
const userId = useAppSelector((state) => { return state.user.id; });
console.log(userId);
// console.log(userId);

if (isSuccess) {
console.log(userId);
Expand Down Expand Up @@ -82,6 +83,8 @@ function LoginPage() {
<Link href="/find-password">비밀번호 찾기</Link>
</li>
</ul>
<Spacing size={24} />
<KakaoLoginButton />
</main>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.kakaoLoginWrapper {
display: block;
height: 45px;
margin: 0 auto;
cursor: pointer;
}
30 changes: 30 additions & 0 deletions src/components/home/kakao-login-button/KakaoLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import classNames from 'classnames/bind';
import Image from 'next/image';

import KakaoLoginScript from '@shared/kakao-script/KakaoLoginScript';

import styles from './KakaoLoginButton.module.scss';

const cx = classNames.bind(styles);

function KakaoLoginButton() {
// TODO: 인가코드를 이용해서 백엔드에 api 요청하기
const handleLoginKakao = () => {
window.Kakao.Auth.authorize({
redirectUri: process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URI,
});
};

return (
<>
<button className={cx('kakaoLoginWrapper')} type="button" onClick={handleLoginKakao}>
<Image src="/assets/kakao_login_medium_wide.png" alt="카카오 로그인 버튼" width={300} height={45} />
</button>
<KakaoLoginScript />
</>
);
}

export default KakaoLoginButton;
30 changes: 30 additions & 0 deletions src/components/shared/kakao-script/KakaoLoginScript.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */

'use client';

import Script from 'next/script';

declare global {
interface Window {
Kakao: any
}
}

function KakaoLoginScript() {
const onLoad = () => {
window.Kakao.init(process.env.NEXT_PUBLIC_KAKAO_APP_JS_KEY);
};

return (
<Script
strategy="afterInteractive"
type="text/javascript"
src={`https://t1.kakaocdn.net/kakao_js_sdk/${process.env.NEXT_PUBLIC_KAKAO_LOGIN_VERSION}/kakao.min.js`}
onReady={onLoad}
/>
);
}

export default KakaoLoginScript;
2 changes: 1 addition & 1 deletion src/components/shared/map/KakaoMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use client';

import { useEffect, useState } from 'react';
import { useState } from 'react';

import Script from 'next/script';

Expand Down
Loading