Skip to content

Commit a96fbdf

Browse files
authored
Merge pull request #251 from ItRecode/FE-246
[FE-246]feat: 내 댓글 관리페이지 개발
2 parents 9ecc09b + 889c30b commit a96fbdf

2 files changed

Lines changed: 120 additions & 1 deletion

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react'
2+
import { useNavigate } from 'react-router-dom'
3+
import { parentCategoryID } from 'types/category'
4+
import { IRankingRecordData } from 'types/recordData'
5+
import recordIcons from '@assets/record_icons'
6+
7+
interface RankingItemType extends IRankingRecordData {
8+
index?: number
9+
parentCategoryId: parentCategoryID
10+
}
11+
12+
export default function CommentSection({
13+
recordId,
14+
colorName,
15+
title,
16+
writer,
17+
numOfComment,
18+
iconName,
19+
}: RankingItemType) {
20+
const navigate = useNavigate()
21+
const RecordIcon = recordIcons[`${iconName}`]
22+
23+
const screenAvailWidth = window.screen.availWidth
24+
25+
const titleRelativeWidth =
26+
screenAvailWidth > 370
27+
? 'max-w-[45%]'
28+
: screenAvailWidth > 350
29+
? 'max-w-[40%]'
30+
: 'max-w-[35%]'
31+
32+
return (
33+
<div
34+
className="relative mb-5 flex h-12 w-full cursor-pointer items-center justify-between"
35+
onClick={() => navigate(`/record/${recordId}`)}
36+
>
37+
<div className="flex w-full items-center">
38+
<div
39+
className={`${colorName} flex aspect-square w-12 items-center justify-center rounded-full`}
40+
>
41+
<RecordIcon width={36} height={36} />
42+
</div>
43+
<div className={`ml-2 ${titleRelativeWidth} shrink`}>
44+
<p className="truncate text-base font-semibold">{title}</p>
45+
<div className="flex w-full text-xs">
46+
<p className="max-w-[85%] truncate text-grey-9">{writer}</p>
47+
<p className="ml-1.5 text-primary-2">+{numOfComment}</p>
48+
</div>
49+
</div>
50+
</div>
51+
</div>
52+
)
53+
}
Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,73 @@
1+
import BackButton from '@components/BackButton'
12
import React from 'react'
3+
import { useNavigate } from 'react-router-dom'
4+
import CommentSection from './CommentSection'
5+
6+
interface CommentType {
7+
writer: string
8+
title: string
9+
createdAt: string
10+
id: number
11+
}
212

313
function ManageComment() {
4-
return <div>댓글관리에용</div>
14+
const navigate = useNavigate()
15+
const COMMENTS = [
16+
{ id: 1, writer: '모승', title: '실험인데용', createdAt: '2022.10.01' },
17+
{ id: 2, writer: '모승', title: '실험인데용', createdAt: '2022.10.01' },
18+
{ id: 3, writer: '모승', title: '실험인데용', createdAt: '2022.10.01' },
19+
]
20+
const recordId = 270
21+
const ALL_POSTS = [1, 2, 3, 4, 5]
22+
23+
return (
24+
<div className="px-6 pt-4">
25+
<div className="flex justify-between pb-8">
26+
<BackButton />
27+
<p className="cursor-pointer text-xs font-medium text-primary-2">
28+
선택
29+
</p>
30+
</div>
31+
<div className="flex justify-end">
32+
<p>최신순</p>
33+
</div>
34+
<div>
35+
{ALL_POSTS.map((src) => (
36+
<section key={src} className="mt-4 flex flex-col items-start pr-4">
37+
<p className="mb-4">2022.12.01</p>
38+
<CommentSection
39+
parentCategoryId={1}
40+
recordId={350}
41+
colorName={`bg-icon-purple`}
42+
title={'실험인데요'}
43+
writer={'모송'}
44+
numOfComment={5}
45+
iconName={'gift'}
46+
/>
47+
<section className="flex w-full flex-col gap-2 pl-[56px]">
48+
{COMMENTS.map(({ writer, title, createdAt, id }: CommentType) => (
49+
<div key={id} className="w-full rounded-[8px] bg-grey-2 p-3">
50+
<div className="flex">
51+
<p className=" mr-2 text-xs font-medium">{writer}</p>
52+
<p className="text-xs font-normal text-grey-5">
53+
{createdAt}
54+
</p>
55+
</div>
56+
<p className="text-xs font-normal text-grey-8">{title}</p>
57+
</div>
58+
))}
59+
<p
60+
onClick={() => navigate(`/record/${recordId}`)}
61+
className="cursor-pointer text-xs font-normal text-grey-7"
62+
>
63+
전체보기
64+
</p>
65+
</section>
66+
</section>
67+
))}
68+
</div>
69+
</div>
70+
)
571
}
672

773
export default ManageComment

0 commit comments

Comments
 (0)