Skip to content

Commit ea435da

Browse files
Merge pull request #63 from dib3474/feature/my-page
마이페이지 채팅, 좋아요, 리뷰 축제 보기 추가
2 parents d5aaa91 + 72489e6 commit ea435da

31 files changed

Lines changed: 858 additions & 422 deletions

File tree

src/App.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
66
import { AuthProvider } from '@/context/AuthContext';
77
import { ToastContainer } from 'react-toastify';
88
import { ErrorBoundary } from 'react-error-boundary';
9-
import ErrorComponent from './components/common/ErrorComponent';
9+
import ErrorComponent from '@/components/error/ErrorComponent';
10+
import { WebSocketProvider } from '@/context/WebSocketContext';
1011

1112
const App = () => {
1213
return (
@@ -15,9 +16,11 @@ const App = () => {
1516
>
1617
<QueryClientProvider client={queryClient}>
1718
<AuthProvider>
18-
<BrowserRouter>
19-
<Routes />
20-
</BrowserRouter>
19+
<WebSocketProvider>
20+
<BrowserRouter>
21+
<Routes />
22+
</BrowserRouter>
23+
</WebSocketProvider>
2124
</AuthProvider>
2225
<ToastContainer />
2326
{import.meta.env.VITE_ENABLE_RQ_DEVTOOLS === 'true' && <ReactQueryDevtools />}

src/apis/chat/getMyChats.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { apiInstance, type ApiErrorResponse } from '@/apis/apiInstance';
2+
import type { ApiResponseList } from '@/apis/apiResponse';
3+
import API_ENDPOINTS from '@/constants/apiEndpoints';
4+
import type { AxiosResponse } from 'axios';
5+
6+
export interface MyChat {
7+
roomId: number;
8+
roomName: string;
9+
festivalId: number;
10+
posterInfo: string;
11+
existNewMessage: boolean;
12+
}
13+
14+
export const getMyChats = async (
15+
page = 0,
16+
size = 5,
17+
): Promise<AxiosResponse<ApiResponseList<MyChat>, ApiErrorResponse>> => {
18+
return await apiInstance.get<ApiResponseList<MyChat>>(API_ENDPOINTS.MY_CHATS, {
19+
params: {
20+
page,
21+
size,
22+
},
23+
});
24+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { apiInstance, type ApiErrorResponse } from '@/apis/apiInstance';
2+
import type { ApiResponseList } from '@/apis/apiResponse';
3+
import API_ENDPOINTS from '@/constants/apiEndpoints';
4+
import type { Festival } from '@/types/FestivalType';
5+
import type { AxiosResponse } from 'axios';
6+
7+
export const getMyReviewFestivals = async (
8+
page = 0,
9+
size = 5,
10+
): Promise<AxiosResponse<ApiResponseList<Festival>, ApiErrorResponse>> => {
11+
return await apiInstance.get<ApiResponseList<Festival>>(API_ENDPOINTS.MY_REVIEWS_FESTIVAL, {
12+
params: { page, size },
13+
});
14+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { apiInstance, type ApiErrorResponse } from '@/apis/apiInstance';
2+
import type { ApiResponseList } from '@/apis/apiResponse';
3+
import API_ENDPOINTS from '@/constants/apiEndpoints';
4+
import type { Festival } from '@/types/FestivalType';
5+
import type { AxiosResponse } from 'axios';
6+
7+
export const getMyWishFestivals = async (
8+
page = 0,
9+
size = 5,
10+
): Promise<AxiosResponse<ApiResponseList<Festival>, ApiErrorResponse>> => {
11+
return await apiInstance.get<ApiResponseList<Festival>>(API_ENDPOINTS.MY_WISHES_FESTIVAL, {
12+
params: { page, size },
13+
});
14+
};

src/components/common/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ROUTE_PATH } from '@/constants/routes';
88
import { Link, useNavigate } from 'react-router-dom';
99
import Settings from '@/components/icon/SettingIcon';
1010

11-
interface HeaderProps {
11+
export interface HeaderProps {
1212
variant?: 'logo' | 'page' | 'all' | 'mypage';
1313
title?: string;
1414
}
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Button from '@/components/common/Button';
2-
import useNav from '@/hooks/useNav';
32

43
interface ErrorComponentProps {
54
title?: string;
65
message?: string;
76
showBackButton?: boolean;
87
onRetry?: () => void;
98
isGlobal?: boolean;
9+
className?: string;
1010
}
1111

1212
/**
@@ -25,9 +25,8 @@ const ErrorComponent = ({
2525
showBackButton = true,
2626
onRetry,
2727
isGlobal = false,
28+
className,
2829
}: ErrorComponentProps) => {
29-
const { goBack } = useNav();
30-
3130
// 기본값 설정
3231
const displayTitle = title || (isGlobal ? '문제가 발생했습니다' : '오류가 발생했습니다');
3332
const displayMessage =
@@ -42,7 +41,7 @@ const ErrorComponent = ({
4241
: 'flex flex-col items-center justify-center h-[calc(100vh-110px)]';
4342

4443
return (
45-
<div className={containerClass}>
44+
<div className={`${containerClass} ${className}`}>
4645
<div className="text-center flex flex-col gap-10">
4746
<div className="flex flex-col gap-1">
4847
<h2 className="text-xl font-semibold mb-2">{displayTitle}</h2>
@@ -66,7 +65,12 @@ const ErrorComponent = ({
6665
</Button>
6766
) : (
6867
showBackButton && (
69-
<Button variant={onRetry ? 'secondary' : 'primary'} onClick={goBack} fullWidth>
68+
<Button
69+
variant={onRetry ? 'secondary' : 'primary'}
70+
// 에러 컴포넌트가 라우터에서 벗어나면 이전 페이지로 돌아가는 것이 불가능해지므로 이 방법을 사용했습니다.
71+
onClick={() => window.history.back()}
72+
fullWidth
73+
>
7074
이전 페이지로 돌아가기
7175
</Button>
7276
)

src/components/error/ErrorPage.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Container from '@/components/common/Container';
2+
import Header from '@/components/common/Header';
3+
import ErrorComponent from '@/components/error/ErrorComponent';
4+
import Footer from '@/components/common/Footer';
5+
import type { HeaderProps } from '@/components/common/Header';
6+
7+
interface ErrorPageProps {
8+
title?: string;
9+
message?: string;
10+
variant: HeaderProps['variant'];
11+
}
12+
13+
/**
14+
* 에러 페이지
15+
* @param title - 에러 페이지 제목
16+
* @param message - 에러 페이지 메시지
17+
* @param variant - 에러 페이지 변형 타입
18+
* @returns 에러 페이지
19+
*/
20+
const ErrorPage = ({ title, message, variant }: ErrorPageProps) => {
21+
return (
22+
<Container>
23+
<Header variant={variant} title={title} />
24+
<ErrorComponent title={title} message={message} />
25+
<Footer />
26+
</Container>
27+
);
28+
};
29+
30+
export default ErrorPage;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import LoadingSpinner from '@/components/loading/LoadingSpinner';
2+
import Container from '@/components/common/Container';
3+
import Footer from '@/components/common/Footer';
4+
import Header from '@/components/common/Header';
5+
import type { HeaderProps } from '@/components/common/Header';
6+
7+
interface LoadingPageProps {
8+
title?: string;
9+
message?: string;
10+
variant: HeaderProps['variant'];
11+
}
12+
13+
/**
14+
* 로딩 페이지
15+
* @param title - 로딩 페이지 제목
16+
* @param message - 로딩 페이지 메시지
17+
* @param variant - 로딩 페이지 변형 타입
18+
* @returns 로딩 페이지
19+
*/
20+
const LoadingPage = ({ title, message, variant }: LoadingPageProps) => {
21+
return (
22+
<Container>
23+
<Header variant={variant} title={title} />
24+
<LoadingSpinner size="lg" className="h-[calc(100dvh-110px)]" message={message} />
25+
<Footer />
26+
</Container>
27+
);
28+
};
29+
30+
export default LoadingPage;

src/constants/apiEndpoints.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const API_ENDPOINTS = {
99
FESTIVAL_CHAT_ROOM_MESSAGES: '/api/chatRooms/:chatRoomId/messages',
1010
FESTIVAL_SEARCH: '/api/festivals',
1111
FESTIVAL_PICK: '/api/recommendations',
12-
CHAT: '/stomp',
12+
STOMP: '/stomp',
1313
// OAuth 로그인
1414
GOOGLE_LOGIN: '/oauth2/authorization/google',
1515
KAKAO_LOGIN: '/oauth2/authorization/kakao',
@@ -23,6 +23,12 @@ const API_ENDPOINTS = {
2323
LOGOUT: '/api/users/logout',
2424
// 회원탈퇴
2525
DELETE_USER: '/api/users',
26+
// 내가 참여한 채팅 방 조회
27+
MY_CHATS: '/api/chatRooms/me',
28+
// 내가 좋아요한 축제 목록 조회
29+
MY_WISHES_FESTIVAL: '/api/festivals/wishedBy/me',
30+
// 내가 작성한 리뷰의 축제 목록 조회
31+
MY_REVIEWS_FESTIVAL: '/api/festivals/reviewedBy/me',
2632
// 내가 작성한 리뷰
2733
MY_REVIEWS: '/api/reviews/my',
2834
// 리뷰 (조회/수정/삭제)

0 commit comments

Comments
 (0)