Skip to content

Commit

Permalink
Merge pull request #214 from ODOICHON/feat/#213
Browse files Browse the repository at this point in the history
Feat/#213 ๋งˆ์ดํŽ˜์ด์ง€ '๋‚ด๊ฐ€ ์“ด ๋Œ“๊ธ€' ๊ตฌํ˜„
  • Loading branch information
JunJongHun authored Dec 2, 2023
2 parents 10fd157 + 1d26d0d commit 63b6e75
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitmessage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
# remove: ํŒŒ์ผ์„ ์‚ญ์ œํ•˜๋Š” ์ž‘์—…๋งŒ ์ˆ˜ํ–‰ํ•œ ๊ฒฝ์šฐ
# !BREAKING CHANGE: ์ปค๋‹ค๋ž€ API ๋ณ€๊ฒฝ์˜ ์ด์œ 
# !HOTFIX: ๊ธ‰ํ•˜๊ฒŒ ์น˜๋ช…์ ์ธ ๋ฒ„๊ทธ๋ฅผ ๊ณ ์ณ์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ

################
3 changes: 2 additions & 1 deletion src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { lazy } from 'react';
import { RouteObject } from 'react-router-dom';
import GlobalLayout from '@/pages/_layout';
import MyCommentsPage from './pages/Mypage/community/comments';

import MyLikesPage from './pages/Mypage/community/likes';
import MyPage from './pages/Mypage';
Expand Down Expand Up @@ -63,7 +64,7 @@ export const routes: RouteObject[] = [
},
{
path: 'community/comment',
element: <div>comment</div>,
element: <MyCommentsPage />,
},
{
path: 'community/likes',
Expand Down
28 changes: 28 additions & 0 deletions src/components/MyPage/MyCommentCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useNavigate } from 'react-router-dom';
import styles from './styles.module.scss';

type MyCommentCardProps = {
boardId: number;
title: string;
commentContent: string;
};

function MyCommentCard({ boardId, title, commentContent }: MyCommentCardProps) {
const navigate = useNavigate();

const handleClick = () => {
navigate(`/community/free_board/${boardId}`);
};

return (
<>
<div role="presentation" className={styles.wrapper} onClick={handleClick}>
<h1 className={styles.title}>๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ: {title}</h1>
<p className={styles.comment}>{commentContent}</p>
</div>
<div className={styles.divider} />
</>
);
}

export default MyCommentCard;
41 changes: 41 additions & 0 deletions src/components/MyPage/MyCommentCard/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.wrapper {
display: flex;
flex-direction: column;
width: 100%;
height: 9.575rem;
padding: 2.25rem 2.25rem 2rem;
font-family: 'Pretendard';
cursor: pointer;
&:hover {
background-color: rgba(0, 0, 0, 0.03);
}
}
.title {
display: flex;
align-items: center;
gap: 0.25rem;
color: #878d91;
font-size: 1.25rem;
}

.comment {
margin-top: 1rem;
font-size: 1rem;
font-weight: 400;
line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; // ๋ผ์ธ์ˆ˜
-webkit-box-orient: vertical;
}

.divider {
width: 100%;
height: 1px;
background-color: #a9afb3;
border-radius: 8px;
&:last-child {
display: none;
}
}
19 changes: 14 additions & 5 deletions src/components/MyPage/MySaveCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ export default function MySaveCard({ saveData }: MySaveCardProps) {
className={styles.wrapper}
onClick={() => handleEditButtonClick(detailData?.data)}
>
<h1 className={styles.title}>
{saveData.title}
<img src={clipImage} alt="ํด๋ฆฝ์ด๋ฏธ์ง€" />
</h1>
<p>{dayjs(saveData.createdAt).format('YYYY.MM.DD')}</p>
<div className={styles.descWrapper}>
<h1 className={styles.title}>
{saveData.title === '' ? '[์ž„์‹œ์ €์žฅ]' : saveData.title}
{saveData.imageUrl !== '' && <img src={clipImage} alt="ํด๋ฆฝ์ด๋ฏธ์ง€" />}
</h1>
<p>{dayjs(saveData.createdAt).format('YYYY.MM.DD')}</p>
</div>
{saveData.imageUrl !== '' && (
<img
className={styles.thumbnail}
src={saveData.imageUrl}
alt="thumbnail"
/>
)}
</li>
);
}
14 changes: 11 additions & 3 deletions src/components/MyPage/MySaveCard/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
.wrapper {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
height: 9.375rem;
height: 18rem;
padding: 2.25rem 2rem;
background-color: white;
cursor: pointer;
&:hover {
background-color: rgba(0, 0, 0, 0.03);
}
}
.descWrapper {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.title {
display: flex;
align-items: center;
Expand All @@ -21,3 +24,8 @@
width: 1.25rem;
}
}
.thumbnail {
height: 100%;
object-fit: contain;
aspect-ratio: 1/1;
}
68 changes: 68 additions & 0 deletions src/pages/Mypage/community/comments/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 MyCommentCard from '@/components/MyPage/MyCommentCard';
import { QueryKeys, restFetcher } from '@/queryClient';
import { MyCommentPageType } from '@/types/Board/communityType';
import { ApiResponseWithDataType } from '@/types/apiResponseType';
import styles from './styles.module.scss';

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

const { data: commentsData, isLoading } = useQuery<
ApiResponseWithDataType<MyCommentPageType>
>([QueryKeys.COMMUNITY_BOARD, QueryKeys.MY_COMMENTS, 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}>
์ด {commentsData?.data.totalElements}๊ฐœ
</div>
<div className={styles.divider} />
</article>
<ul>
{isLoading && <Loading />}
{commentsData && commentsData.data.content.length > 0 ? (
commentsData?.data.content.map((content) => (
<MyCommentCard
key={content.commentContent}
boardId={content.boardId}
title={content.title}
commentContent={content.commentContent}
/>
))
) : (
<NoPosts
text="์•„์ง์€ ๊ธ€์ด ์—†์–ด์š”."
subText="๊ธ€์„ ์ž‘์„ฑํ•ด์„œ ์ž์œ ๋กญ๊ฒŒ ์˜ค๋„์ด์ดŒ ์ด์•ผ๊ธฐ๋ฅผ ํ•ด๋ณด์•„์š”!"
/>
)}
</ul>
<div className={styles.paginationWrapper}>
{commentsData && commentsData.data.content.length > 0 && (
<Pagination
totalPage={commentsData.data.totalPages}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
/>
)}
</div>
</section>
);
}
37 changes: 37 additions & 0 deletions src/pages/Mypage/community/comments/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@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;
font-weight: 500;
}

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

.paginationWrapper {
margin-top: 6rem;
}
2 changes: 1 addition & 1 deletion src/pages/Mypage/community/write/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function MyWritePage() {
</article>
<article className={styles.countWrapper}>
<div className={styles.count}>
์ด {boardListData?.data.totalElements}
์ด {boardListData?.data.totalElements}๊ฐœ
</div>
<div className={styles.divider} />
</article>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Mypage/community/write/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
font-family: 'Pretendard';
font-size: 1.5rem;
margin-bottom: 1rem;
font-weight: 500;
}

.divider {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Mypage/trade/saves/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
& > h3 {
margin-bottom: 1rem;
font-size: 1.5rem;
font-weight: 600;
font-weight: 500;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ export const QueryKeys = {
LIKE: 'LIKE',
MY_HOUSES: 'MY_HOUSES',
MY_SAVES: 'MY_SAVES',
MY_COMMENTS: 'MY_COMMENTS',
MY_LIKES: 'MY_LIKES',
};
12 changes: 12 additions & 0 deletions src/types/Board/communityType.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BoardPageType } from './boardType';
import {
IntroBoardDetailType,
IntroBoardPageType,
Expand All @@ -9,3 +10,14 @@ export type CommunityBoardType = IntroBoardType;
export type CommunityBoardDetailType = IntroBoardDetailType;

export type CommunityBoardPageType = IntroBoardPageType;

export type MyCommentType = {
commentId: number;
boardId: number;
title: string;
commentContent: string;
// category: string;
// prefixCategory: string;
};

export type MyCommentPageType = BoardPageType<MyCommentType>;

0 comments on commit 63b6e75

Please sign in to comment.