Skip to content

Commit 0aa96ac

Browse files
authored
Merge pull request dnd-side-project#50 from dnd-side-project/feature/dnd-side-project#10
[FEAT] 카카오 로그인 토큰 설정
2 parents 29e5950 + 7d78137 commit 0aa96ac

File tree

10 files changed

+65
-3
lines changed

10 files changed

+65
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@tanstack/react-query": "^5.84.0",
1616
"class-variance-authority": "^0.7.1",
1717
"clsx": "^2.1.1",
18+
"cookies-next": "^6.1.0",
1819
"framer-motion": "^12.23.12",
1920
"ky": "^1.8.2",
2021
"next": "15.4.4",

src/app/login/page.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client';
2+
import { KakaoLoginButton } from '@/components/ui/KakaoLoginButton';
3+
import { MainLayout } from '@/components/layout';
4+
5+
export default function LoginPage() {
6+
return (
7+
<MainLayout>
8+
<h1>로그인 페이지</h1>
9+
<KakaoLoginButton />
10+
</MainLayout>
11+
);
12+
}

src/components/HouseMemo/CheckList/CheckList.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use client';
2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import { Tabs, TabsList, TabsContent, TabsTrigger } from '@/components/ui/Tabs';
44
import { Dropdown, DropdownContent } from '@/components/ui/Dropdown';
5+
import { useChecklistInfo } from '@/queries/houseMemo/useCheklistInfo';
56

67
// 예시 데이터
78
const checkListData = {
@@ -66,6 +67,10 @@ const checkListData = {
6667
};
6768

6869
export default function CheckList() {
70+
const { data, isLoading, error } = useChecklistInfo();
71+
72+
console.log(data, 'chekList data');
73+
6974
return (
7075
<div>
7176
<Tabs defaultValue="필수 확인">
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use client';
2+
import { getKakaoAuthURL } from '@/utils/kakao';
3+
4+
export const KakaoLoginButton = () => {
5+
const handleLogin = () => {
6+
window.location.href = getKakaoAuthURL();
7+
};
8+
9+
return <button onClick={handleLogin}>카카오 로그인</button>;
10+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { KakaoLoginButton } from './KakaoLoginButton';

src/lib/api/ky.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import ky from 'ky';
2+
import { getCookie } from 'cookies-next';
23

34
const getToken = () => {
4-
// TODO: 나중에 zustand, cookie, localStorage 등에서 토큰 가져오기
55
if (typeof window !== 'undefined') {
6-
return localStorage.getItem('accessToken') || '';
6+
return getCookie('Access') as string | undefined;
77
}
88
return '';
99
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
import { getChecklist } from '@/services/house.memo';
3+
4+
export function useChecklistInfo() {
5+
return useQuery({
6+
queryKey: ['checklist'],
7+
queryFn: getChecklist,
8+
});
9+
}

src/services/house.memo.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ky from 'ky';
2+
import { api } from '@/lib/api/ky';
23

34
export type Place = {
45
id: string;
@@ -42,3 +43,7 @@ export async function fetchPlaces(query: string, page: number): Promise<ApiRespo
4243
})
4344
.json<ApiResponse>();
4445
}
46+
47+
export async function getChecklist() {
48+
return api.get('api/checklist').json();
49+
}

src/utils/kakao.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const getKakaoAuthURL = () => {
2+
const REST_API_KEY = process.env.NEXT_PUBLIC_KAKAO_REST_API_KEY;
3+
const REDIRECT_URI = process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URI;
4+
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${REST_API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code`;
5+
6+
return kakaoURL;
7+
};

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,6 +3133,18 @@ convert-source-map@^2.0.0:
31333133
resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz"
31343134
integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==
31353135

3136+
cookie@^1.0.1:
3137+
version "1.0.2"
3138+
resolved "https://registry.yarnpkg.com/cookie/-/cookie-1.0.2.tgz#27360701532116bd3f1f9416929d176afe1e4610"
3139+
integrity sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==
3140+
3141+
cookies-next@^6.1.0:
3142+
version "6.1.0"
3143+
resolved "https://registry.yarnpkg.com/cookies-next/-/cookies-next-6.1.0.tgz#0bdfe6e78166d494a0b3d30afcdac9456d1164da"
3144+
integrity sha512-8MqWliHg6YRatqlup5HlKCqXM5cFtwq9BVowDpPniPfbTOmrfIEXUQOcRFVXQltV+hyvKDRGJPNtceICkiJ/IA==
3145+
dependencies:
3146+
cookie "^1.0.1"
3147+
31363148
core-js-compat@^3.43.0:
31373149
version "3.44.0"
31383150
resolved "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.44.0.tgz"

0 commit comments

Comments
 (0)