From 6a0debbd1735b96f7e667a3f470f2419ff48f1b4 Mon Sep 17 00:00:00 2001
From: Sungu Kim <108677235+haegu97@users.noreply.github.com>
Date: Sat, 4 Jan 2025 15:44:01 +0900
Subject: [PATCH 1/5] =?UTF-8?q?=EB=92=A4=EB=A1=9C=EA=B0=80=EA=B8=B0=20?=
=?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=B6=94=EA=B0=80=20=20#245?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/chat/[id]/page.tsx | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx
index 22ea8830..96bde59b 100644
--- a/src/app/chat/[id]/page.tsx
+++ b/src/app/chat/[id]/page.tsx
@@ -2,7 +2,7 @@
import React, { useEffect, useState } from 'react';
import ChatBubbleList from '@/features/chat-room/container/chat-bubble-list/ChatBubbleList';
-import { usePathname } from 'next/navigation';
+import { usePathname, useRouter } from 'next/navigation';
import ChatCard from '@/features/chat/components/chat-card/ChatCard';
import ParticipantCounter from '@/components/participant-counter/ParticipantCounter';
import IconButton from '@/components/icon-button/IconButton';
@@ -26,6 +26,7 @@ import { bookClubs } from '@/api/book-club/react-query';
import { formatDateForUI } from '@/lib/utils/formatDateForUI';
import { getCookie } from '@/features/auth/utils/cookies';
import { initializeSocket } from '@/features/chat/utils/socket';
+import MessageIcon from '../../../../public/icons/MessageIcon';
function ChatRoomPage() {
const pathname = usePathname();
@@ -41,10 +42,16 @@ function ChatRoomPage() {
bookClubs.my()._ctx.joined({ order: 'DESC', page: 1, size: 10 }),
);
- const bookClubDetail = data?.data?.bookClubs?.find(
+ const bookClubDetail = data?.bookClubs?.find(
(club: any) => club.id === Number(chatId),
);
+ const router = useRouter();
+
+ const handleGoBack = () => {
+ router.push('/chat');
+ };
+
useEffect(() => {
const connectSocket = async () => {
const token = getCookie('auth_token');
@@ -181,7 +188,7 @@ function ChatRoomPage() {
}
- onClick={() => console.log('채팅 버튼 클릭')}
+ onClick={handleGoBack}
className="bg-gray-light-02"
/>
채팅
@@ -219,9 +226,17 @@ function ChatRoomPage() {
onProfileClick={() => {}}
/>
-
+
+
+ }
+ aria-label="메시지 전송"
+ className="h-[52px] w-[52px] bg-green-light-01"
+ onClick={handleSubmit}
+ />
+
);
}
From e754da8fd2303fa8271f18525594d9ff71ee5eec Mon Sep 17 00:00:00 2001
From: Sungu Kim <108677235+haegu97@users.noreply.github.com>
Date: Sat, 4 Jan 2025 15:47:17 +0900
Subject: [PATCH 2/5] =?UTF-8?q?=EC=B1=84=ED=8C=85=EB=B0=A9=20=ED=97=A4?=
=?UTF-8?q?=EB=8D=94=20=EB=88=84=EB=A5=B4=EB=A9=B4=20=ED=95=B4=EB=8B=B9=20?=
=?UTF-8?q?=EB=AA=A8=EC=9E=84=20=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4?=
=?UTF-8?q?=EC=A7=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99=ED=95=98=EA=B8=B0=20?=
=?UTF-8?q?=EA=B5=AC=ED=98=84=20#245?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/chat/[id]/page.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx
index 96bde59b..e7782694 100644
--- a/src/app/chat/[id]/page.tsx
+++ b/src/app/chat/[id]/page.tsx
@@ -214,7 +214,7 @@ function ChatRoomPage() {
? formatDateForUI(bookClubDetail.targetDate, 'KOREAN')
: '',
meetingType: bookClubDetail?.meetingType || 'OFFLINE',
- onClick: () => console.log('헤더 클릭'),
+ onClick: () => router.push(`/bookclub/${chatId}`),
}}
/>
From 9183f64f6cb9c2bda76e176f54f64d24ee41bce2 Mon Sep 17 00:00:00 2001
From: Sungu Kim <108677235+haegu97@users.noreply.github.com>
Date: Sat, 4 Jan 2025 15:54:41 +0900
Subject: [PATCH 3/5] =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=9E=85?=
=?UTF-8?q?=EB=A0=A5=20=EB=B6=80=EB=B6=84=20=ED=99=94=EB=A9=B4=20=ED=95=98?=
=?UTF-8?q?=EB=8B=A8=EC=97=90=20=EA=B3=A0=EC=A0=95=20#245?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/chat/[id]/page.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx
index e7782694..e262bfd6 100644
--- a/src/app/chat/[id]/page.tsx
+++ b/src/app/chat/[id]/page.tsx
@@ -226,7 +226,7 @@ function ChatRoomPage() {
onProfileClick={() => {}}
/>
-
+
From affa084a46131d53bb5d73a9e386ac4d2b00b418 Mon Sep 17 00:00:00 2001
From: Sungu Kim <108677235+haegu97@users.noreply.github.com>
Date: Sat, 4 Jan 2025 16:17:07 +0900
Subject: [PATCH 4/5] =?UTF-8?q?=EC=B1=84=ED=8C=85=20=EC=9E=85=EB=A0=A5?=
=?UTF-8?q?=EC=B0=BD=20=ED=99=94=EB=A9=B4=20=EB=84=88=EB=B9=84=EC=97=90=20?=
=?UTF-8?q?=EB=A7=9E=EA=B2=8C=20=EC=88=98=EC=A0=95=20#283?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app/chat/[id]/page.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx
index e262bfd6..f3d7d151 100644
--- a/src/app/chat/[id]/page.tsx
+++ b/src/app/chat/[id]/page.tsx
@@ -226,7 +226,7 @@ function ChatRoomPage() {
onProfileClick={() => {}}
/>
-
+
From 58771c9e8456e8aa98faf5c1912f73ed2eec2751 Mon Sep 17 00:00:00 2001
From: Sungu Kim <108677235+haegu97@users.noreply.github.com>
Date: Sat, 4 Jan 2025 16:48:00 +0900
Subject: [PATCH 5/5] =?UTF-8?q?refreshAccessToken=20=EB=B6=84=EB=A6=AC=20#?=
=?UTF-8?q?283?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/features/auth/api/auth.ts | 25 ---------------------
src/features/auth/api/refreshAccessToken.ts | 24 ++++++++++++++++++++
src/lib/utils/apiClient.ts | 2 +-
src/middleware.ts | 2 +-
4 files changed, 26 insertions(+), 27 deletions(-)
create mode 100644 src/features/auth/api/refreshAccessToken.ts
diff --git a/src/features/auth/api/auth.ts b/src/features/auth/api/auth.ts
index 3445fb3b..01abd80b 100644
--- a/src/features/auth/api/auth.ts
+++ b/src/features/auth/api/auth.ts
@@ -97,28 +97,3 @@ export const signup = async (data: SignUpFormData) => {
throw error;
}
};
-
-export const refreshAccessToken = async (refreshToken: string) => {
- try {
- const response = await fetch(
- `${process.env.NEXT_PUBLIC_API_URL}/auths/refresh`,
- {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ refreshToken }),
- },
- );
-
- if (!response.ok) {
- throw new Error('토큰 갱신 실패');
- }
-
- console.log('리프레시 성공');
- return response.json();
- } catch (error) {
- console.error('토큰 갱신 에러:', error);
- throw error;
- }
-};
diff --git a/src/features/auth/api/refreshAccessToken.ts b/src/features/auth/api/refreshAccessToken.ts
new file mode 100644
index 00000000..453566c9
--- /dev/null
+++ b/src/features/auth/api/refreshAccessToken.ts
@@ -0,0 +1,24 @@
+export const refreshAccessToken = async (refreshToken: string) => {
+ try {
+ const response = await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/auths/refresh`,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ refreshToken }),
+ },
+ );
+
+ if (!response.ok) {
+ throw new Error('토큰 갱신 실패');
+ }
+
+ console.log('리프레시 성공');
+ return response.json();
+ } catch (error) {
+ console.error('토큰 갱신 에러:', error);
+ throw error;
+ }
+};
diff --git a/src/lib/utils/apiClient.ts b/src/lib/utils/apiClient.ts
index 8a019e93..083fde8d 100644
--- a/src/lib/utils/apiClient.ts
+++ b/src/lib/utils/apiClient.ts
@@ -1,7 +1,7 @@
import axios from 'axios';
import { getCookie, deleteCookie } from '@/features/auth/utils/cookies';
import { useAuthStore } from '@/store/authStore';
-import { refreshAccessToken } from '@/features/auth/api/auth';
+import { refreshAccessToken } from '@/features/auth/api/refreshAccessToken';
const apiClient = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_URL,
diff --git a/src/middleware.ts b/src/middleware.ts
index f21e0794..c8defbd5 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
-import { refreshAccessToken } from '@/features/auth/api/auth';
+import { refreshAccessToken } from '@/features/auth/api/refreshAccessToken';
const AUTH_REQUIRED_PATHS = ['/wish', '/profile', '/bookclub/create', '/chat'];
export async function middleware(request: NextRequest) {