-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#199 ๋ง์ดํ์ด์ง '๋ด๊ฐ ์ข์์ ํ ๊ฒ์๊ธ' ๊ตฌํ
- Loading branch information
Showing
5 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,5 @@ export const QueryKeys = { | |
LIKE: 'LIKE', | ||
MY_HOUSES: 'MY_HOUSES', | ||
MY_SAVES: 'MY_SAVES', | ||
MY_LIKES: 'MY_LIKES', | ||
}; |