Skip to content

Commit 0ca66e6

Browse files
committed
Merge branch 'dev' into feat/184-signup-button-loading
2 parents d6ecaf3 + 37a9a67 commit 0ca66e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1538
-1238
lines changed

.github/workflows/autoBuild.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ jobs:
2727
# Pull latest code from dev branch
2828
cd /home/ubuntu/react
2929
git pull origin dev
30+
31+
# Create .env file
32+
echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" > .env
33+
echo "VITE_SPOTIFY_CLIENT_ID=${{ secrets.VITE_SPOTIFY_CLIENT_ID }}" >> .env
34+
echo "VITE_SPOTIFY_REDIRECT_URI=${{ secrets.VITE_SPOTIFY_REDIRECT_URI }}" >> .env
35+
echo "VITE_SPOTIFY_CLIENT_SECRET=${{ secrets.VITE_SPOTIFY_CLIENT_SECRET }}" >> .env
36+
echo "VITE_KAKAO_CLIENT_ID=${{ secrets.VITE_KAKAO_CLIENT_ID }}" >> .env
37+
echo "VITE_KAKAO_REDIRECT_URI=${{ secrets.VITE_KAKAO_REDIRECT_URI }}" >> .env
3038
3139
# Install dependencies
3240
npm install

dev-dist/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
7979
*/
8080
workbox.precacheAndRoute([{
8181
"url": "index.html",
82-
"revision": "0.koc340e0a3g"
82+
"revision": "0.08jje88gm9"
8383
}], {});
8484
workbox.cleanupOutdatedCaches();
8585
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

package-lock.json

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"lottie-react": "^2.4.1",
2424
"react": "^19.0.0",
2525
"react-dom": "^19.0.0",
26+
"react-error-boundary": "^5.0.0",
2627
"react-intersection-observer": "^9.15.1",
2728
"react-router": "^7.1.5",
2829
"react-spinners": "^0.15.0",

src/App.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ import KaKaoRedirection from '@/components/KaKaoRedirection';
3030

3131
function App() {
3232
const location = useLocation();
33-
// 실제 로그인 여부를 체크하는 함수 (임시로 false, 실제 인증 로직 적용 필요)
34-
// const isAuthenticated = true;
33+
3534
const { isAuthenticated } = useAuthStore();
3635
const spotifyAuth = useSpotifyAuth();
3736
const { isChatLoadingSheetOpen } = useSheetStore();
3837
// soundlink 로그인한 경우에만 spotify 로그인 후 토큰 가져오기
3938
useEffect(() => {
4039
if (isAuthenticated) {
41-
// isAuthenticated가 true일 때만 필요한 동작 실행
4240
console.log('Spotify Auth Initialized:', spotifyAuth);
4341
}
4442
}, [isAuthenticated]);
@@ -78,7 +76,7 @@ function App() {
7876
<Route path="/chat" element={<Chat />} />
7977
<Route path="/post" element={<Post />} />
8078
<Route path="/post/:postId/edit" element={<Post />} />
81-
<Route path="/chatroom" element={<ChatRoom />} />
79+
<Route path="/chatroom/:chatRoomId" element={<ChatRoom />} />
8280
<Route path="/mypage" element={<UserProfile isMyPage={true} />} />
8381
<Route path="/mypage/edit" element={<EditProfile />} />
8482
<Route path="/mypage/blocklist" element={<BlockList />} />

src/apis/auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import axios from 'axios';
22
import { axiosInstance } from './axios';
33
import { useAuthStore } from '@/store/authStore';
44

5+
const API_BASE_URL =
6+
import.meta.env.MODE === 'development'
7+
? '/api/auth/token' // ✅ 개발 환경에서는 프록시를 사용
8+
: import.meta.env.VITE_API_URL + '/api/auth/token'; // ✅ 배포 환경에서는 직접 API 호출
9+
510
// 로그인
611
export const login = async (loginId: string, password: string) => {
712
const { data } = await axiosInstance.post('/auth/login', {
@@ -25,7 +30,7 @@ export const postLogout = async () => {
2530

2631
// 토큰 재발급
2732
export const reissueToken = async () => {
28-
const { data } = await axios.post('/api/auth/token', {
33+
const { data } = await axios.post(`${API_BASE_URL}`, {
2934
withCredentials: true,
3035
});
3136

src/apis/axios.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,36 @@ import axios from 'axios';
22
import { useAuthStore } from '@/store/authStore';
33
import { reissueToken } from '@/apis/auth';
44

5+
const API_BASE_URL =
6+
import.meta.env.MODE === 'development'
7+
? '/api' // ✅ 개발 환경에서는 프록시를 사용
8+
: import.meta.env.VITE_API_URL + '/api'; // ✅ 배포 환경에서는 직접 API 호출
9+
510
export const axiosInstance = axios.create({
6-
baseURL: '/api',
11+
baseURL: API_BASE_URL,
712
withCredentials: true, // RT 자동 포함
813
});
14+
export const axiosChatInstance = axios.create({
15+
baseURL: '/chatapi',
16+
});
17+
18+
// 요청 인터셉터
19+
axiosChatInstance.interceptors.request.use(
20+
async (config) => {
21+
// 토큰 가져오기
22+
const token = useAuthStore.getState().accessToken;
23+
// 토큰이 있으면 요청 헤더에 추가
24+
if (token) {
25+
config.headers.Authorization = `Bearer ${token}`;
26+
// console.log('요청 헤더에 Authorization 추가됨:', config.headers);
27+
}
28+
return config;
29+
},
30+
(error) => {
31+
console.log('요청 인터셉터 에러', error);
32+
Promise.reject(error);
33+
},
34+
);
935

1036
// 요청 인터셉터
1137
axiosInstance.interceptors.request.use(
@@ -50,14 +76,3 @@ axiosInstance.interceptors.response.use(
5076
return Promise.reject(error);
5177
},
5278
);
53-
54-
// .env에 추가하기
55-
// VITE_API_URL=http://43.203.98.65:8080
56-
57-
// 사용예시
58-
// const login = async () => {
59-
// const data = await axiosInstance.post('/user/login', {
60-
// loginId: 'test1234',
61-
// password: 'test1234!',
62-
// });
63-
// };

src/apis/chat.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,39 @@
1-
import { axiosInstance } from './axios';
1+
import { axiosChatInstance, axiosInstance } from './axios';
22

33
//채팅 목록 불러오기(지난 대화 기록 페이지)
44
export const loadChatList = async () => {
55
const { data } = await axiosInstance.get(`/chat/room-list`);
66
return data;
77
};
8-
9-
//채팅방 기록 불러오기(시간 끝난 채팅방 채팅 기록)
10-
//수신,송신자 정보 / messageList 정보
11-
export const loadChatMessages = async (roomId: number) => {
12-
const { data } = await axiosInstance.get(`/chat/messages/${roomId}`);
13-
return data;
14-
};
158
//채팅 요청
169
export const requestChat = async (emotionRecordId: number) => {
17-
const { data } = await axiosInstance.post(`/chat/request`, emotionRecordId, {
18-
headers: {
19-
'Content-Type': 'application/json',
20-
},
21-
});
10+
const { data } = await axiosInstance.post(`/chat/request?recordId=${emotionRecordId}`, {});
2211
return data;
2312
};
2413
//채팅 요청 취소
2514
export const cancelChatRequest = async (emotionRecordId: number) => {
26-
const { data } = await axiosInstance.delete(`/chat/request`, {
27-
headers: {
28-
'Content-Type': 'application/json',
29-
},
30-
data: JSON.stringify(emotionRecordId),
31-
});
15+
const { data } = await axiosInstance.delete(`/chat/request?recordId=${emotionRecordId}`, {});
3216
return data;
3317
};
3418
//채팅방 생성
3519
export const createChatroom = async (emotionRecordId: number) => {
36-
const { data } = await axiosInstance.post(
37-
`/chat/create?recordId=${emotionRecordId}`,
38-
{},
39-
);
20+
const { data } = await axiosInstance.post(`/chat/create?recordId=${emotionRecordId}`, {});
4021
return data;
4122
};
4223
//채팅방 닫기
4324
export const closeChatroom = async (chatRoomId: number) => {
4425
const { data } = await axiosInstance.post(`/chat/close?chatRoomId=${chatRoomId}`, {});
4526
return data;
4627
};
28+
//채팅방 기록 불러오기
29+
export const loadChatHistory = async (chatRoomId: number) => {
30+
const { data } = await axiosChatInstance.get(`/chat/history/${chatRoomId}`);
31+
return data;
32+
};
33+
//채팅방 상세 정보
34+
export const loadChatRoomDetail = async (chatRoomId: number) => {
35+
const { data } = await axiosInstance.get(`/chat/room/detail`, {
36+
params: { chatRoomId: chatRoomId },
37+
});
38+
return data;
39+
};

src/assets/lottie/loading.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/components/ChatConnectLoadingSheet.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ export default function ChatConnectLoadingSheet() {
5050

5151
const formattedTime = dayjs.duration(timeLeft, 'seconds').format('mm:ss');
5252

53+
const isReceiver = true;
54+
5355
//채팅 요청 취소(요청 보낸 사람)
5456
const cancel = async () => {
55-
if (!currentRecord) {
57+
if (!currentRecord?.recordId) {
5658
console.log('record가 존재하지 않습니다');
5759
return;
5860
}
@@ -68,29 +70,33 @@ export default function ChatConnectLoadingSheet() {
6870
};
6971

7072
//채팅방 생성 (요청 받는 사람 입장에서 생성?)
73+
//sse로 받은 recordId로 채팅방 생성
74+
//sse로 받은 상대 정보로 '보내는 사람' 바꾸기
7175
const createChat = async () => {
7276
try {
73-
const data = await createChatroom(17);
77+
//1 = recordId
78+
const data = await createChatroom(1);
7479
console.log(data);
80+
const chatRoomId = data.data.chatRoomId;
7581

76-
if (data.code === 200) {
77-
navigate('/chatroom');
78-
closeAllSheets();
79-
}
80-
//500 이면 이미 방 있음 => 기존 채팅방으로
82+
//200
83+
//409 이면 이미 채팅방 있음 => 기존 채팅방으로
84+
navigate(`/chatroom/${chatRoomId}`);
85+
closeAllSheets();
8186
} catch (error) {
8287
console.log(error);
8388
}
8489
};
8590

8691
//채팅 요정 거절
92+
//거절 하면 거절한 사람은 바로 시트 닫기.
93+
//요청 거절당한 사람은 connectFail = true
8794
const refuseRequest = () => {
8895
closeSheet('isChatLoadingSheetOpen');
8996
};
9097

91-
//채팅 신청한 사람이 상대가 수락했다는 sse 받으면 closeAllSheet, chatroom으로 이동
92-
93-
const isReceiver = true;
98+
//채팅 신청한 사람은 상대가 수락했다는 sse 받으면 closeAllSheet, chatroom으로 이동
99+
//sse로 채팅방 번호 받기
94100

95101
if (connetFail) {
96102
return (

0 commit comments

Comments
 (0)