Skip to content

Commit

Permalink
Merge pull request #212 from ODOICHON/feat/#199
Browse files Browse the repository at this point in the history
Feat/#199 ๋งˆ์ดํŽ˜์ด์ง€ '๋‚ด๊ฐ€ ์ข‹์•„์š” ํ•œ ๊ฒŒ์‹œ๊ธ€' ๊ตฌํ˜„
  • Loading branch information
JunJongHun authored Dec 2, 2023
2 parents f3b818e + 832cc27 commit 10fd157
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { lazy } from 'react';
import { RouteObject } from 'react-router-dom';
import GlobalLayout from '@/pages/_layout';

import MyLikesPage from './pages/Mypage/community/likes';
import MyPage from './pages/Mypage';
import MyWritePage from './pages/Mypage/community/write';
import MyHomePage from './pages/Mypage/home';
import MySelfPage from './pages/Mypage/trade/myself';
import MySavesPage from './pages/Mypage/trade/saves';
import MyScrapPage from './pages/Mypage/trade/scrap';


const MainPage = lazy(() => import('@/pages/Main'));
const LoginPage = lazy(() => import('@/pages/Login'));
const SignUpPage = lazy(() => import('@/pages/SignUp'));
Expand Down Expand Up @@ -63,8 +66,8 @@ export const routes: RouteObject[] = [
element: <div>comment</div>,
},
{
path: 'community/like',
element: <div>like</div>,
path: 'community/likes',
element: <MyLikesPage />,
},
{
path: 'setting',
Expand Down
2 changes: 1 addition & 1 deletion src/components/MyPage/MyPageNavbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const navList: NavListType[] = [
},
{
title: '๋‚ด๊ฐ€ ์ข‹์•„ํ•œ ๊ฒŒ์‹œ๊ธ€',
path: '/mypage/community/like',
path: '/mypage/community/likes',
},
],
},
Expand Down
75 changes: 75 additions & 0 deletions src/pages/Mypage/community/likes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import Loading from '@/components/Common/Loading';
import NoPosts from '@/components/Common/NoPosts';
import Pagination from '@/components/Common/Pagination';
import CommunityBoard from '@/components/Community/Board';
import { QueryKeys, restFetcher } from '@/queryClient';
import { CommunityBoardPageType } from '@/types/Board/communityType';
import { ApiResponseWithDataType } from '@/types/apiResponseType';
import styles from './styles.module.scss';

export default function MyLikesPage() {
const [currentPage, setCurrentPage] = useState(1);
const fetchBoardList = (page: number) => {
const params = {
page: page - 1,
};
return restFetcher({ method: 'GET', path: 'boards/my/love', params });
};

const { data: boardListData, isLoading } = useQuery<
ApiResponseWithDataType<CommunityBoardPageType>
>([QueryKeys.COMMUNITY_BOARD, QueryKeys.MY_LIKES, currentPage], () =>
fetchBoardList(currentPage),
);

return (
<section className={styles.container}>
<article className={styles.titleWrapper}>
<h1>๋‚ด๊ฐ€ ์ข‹์•„์š”ํ•œ ๊ฒŒ์‹œ๊ธ€</h1>
<p>๋‚ด๊ฐ€ ์ข‹์•„์š”ํ•œ ๊ธ€์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.</p>
</article>
<article className={styles.countWrapper}>
<div className={styles.count}>
์ด {boardListData?.data.totalElements}
</div>
<div className={styles.divider} />
</article>
<ul>
{isLoading && <Loading />}
{boardListData && boardListData.data.content.length > 0 ? (
boardListData?.data.content.map((content) => (
<CommunityBoard
key={content.boardId}
boardId={content.boardId}
category={content.category}
prefixCategory={content.prefixCategory}
title={content.title}
oneLineContent={content.oneLineContent}
imageUrl={content.imageUrl}
commentCount={content.commentCount}
nickName={content.nickName}
createdAt={content.createdAt}
fixed={content.fixed}
/>
))
) : (
<NoPosts
text="์•„์ง์€ ๊ธ€์ด ์—†์–ด์š”."
subText="๊ธ€์„ ์ž‘์„ฑํ•ด์„œ ์ž์œ ๋กญ๊ฒŒ ์˜ค๋„์ด์ดŒ ์ด์•ผ๊ธฐ๋ฅผ ํ•ด๋ณด์•„์š”!"
/>
)}
</ul>
<div className={styles.paginationWrapper}>
{boardListData && boardListData.data.content.length > 0 && (
<Pagination
totalPage={boardListData.data.totalPages}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
/>
)}
</div>
</section>
);
}
36 changes: 36 additions & 0 deletions src/pages/Mypage/community/likes/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@import '@/styles/media.scss';

.container {
width: 100%;
font-family: 'Pretendard';
}

.titleWrapper {
& > h1 {
font-family: 'NanumSquareAcB';
font-size: 2.25rem;
margin-bottom: 1rem;
}
& > p {
font-family: 'NanumSquareAc';
font-size: 1.5rem;
}
}

.countWrapper {
margin-top: 3.375rem;
}

.count {
font-family: 'Pretendard';
font-size: 1.5rem;
margin-bottom: 1rem;
}

.divider {
border: 1px solid #9a9a9a;
}

.paginationWrapper {
margin-top: 6rem;
}
1 change: 1 addition & 0 deletions src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ export const QueryKeys = {
LIKE: 'LIKE',
MY_HOUSES: 'MY_HOUSES',
MY_SAVES: 'MY_SAVES',
MY_LIKES: 'MY_LIKES',
};

0 comments on commit 10fd157

Please sign in to comment.