Skip to content

Commit 3253bc3

Browse files
committed
🎨Make components for duplicated logices
1 parent 2e3fca7 commit 3253bc3

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { ScrollArea } from '@/components/ui/scroll-area';
2+
import { useNavigate } from 'react-router';
3+
import type { Events } from '../types/schema';
4+
import { formatEventDate } from '../utils/date';
5+
6+
interface Props {
7+
schedule: Events;
8+
}
9+
10+
// 아이콘
11+
const IconChevronLeft = () => (
12+
<svg
13+
width="24"
14+
height="24"
15+
viewBox="0 0 24 24"
16+
fill="none"
17+
stroke="currentColor"
18+
strokeWidth="2"
19+
strokeLinecap="round"
20+
strokeLinejoin="round"
21+
>
22+
<path d="m15 18-6-6 6-6" />
23+
</svg>
24+
);
25+
26+
export default function EventDetailContent({ schedule }: Props) {
27+
const navigate = useNavigate();
28+
29+
return (
30+
<div className="w-full flex flex-col items-start gap-10">
31+
{/* 1. 일시 및 장소 */}
32+
<div className="text-left space-y-3 w-full">
33+
<p className="text-lg sm:text-xl font-bold text-black">
34+
일시 {formatEventDate(schedule.start_at)}
35+
</p>
36+
<p className="text-lg sm:text-xl font-bold text-black">
37+
장소 {schedule.location || '미정'}
38+
</p>
39+
</div>
40+
41+
{/* 2. 신청 현황 버튼 */}
42+
<button
43+
onClick={() => navigate('guests')}
44+
className="flex items-center text-lg font-bold group hover:opacity-70 transition-opacity"
45+
>
46+
{schedule.capacity}명 중{' '}
47+
<span className="text-black ml-2 font-extrabold">
48+
{/* 신청 인원 필드 필요 */}8명 신청
49+
</span>
50+
<div className="rotate-180 ml-2 group-hover:translate-x-1 transition-transform text-black">
51+
<IconChevronLeft />
52+
</div>
53+
</button>
54+
55+
{/* 3. 상세 설명 */}
56+
<ScrollArea className="h-40 w-full rounded-md border-none">
57+
<p className="text-base text-gray-500 leading-relaxed whitespace-pre-wrap pr-4">
58+
{schedule.description}
59+
</p>
60+
</ScrollArea>
61+
62+
{/* 4. 마감 정보 (버튼 상단 문구) */}
63+
<p className="text-lg font-bold text-black">
64+
{schedule.registration_deadline
65+
? `${formatEventDate(schedule.registration_deadline)} 모집 마감`
66+
: '상시 모집'}
67+
</p>
68+
</div>
69+
);
70+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
2+
import { Button } from '@/components/ui/button';
3+
import { useNavigate } from 'react-router';
4+
5+
interface Guest {
6+
name: string;
7+
img?: string;
8+
}
9+
10+
interface Props {
11+
guests: Guest[];
12+
totalCount: number;
13+
eventId: number | null;
14+
}
15+
16+
export default function GuestSummaryList({
17+
guests,
18+
totalCount,
19+
eventId,
20+
}: Props) {
21+
const navigate = useNavigate();
22+
23+
return (
24+
<div className="w-full">
25+
{/* 참여자 명단 헤더 */}
26+
<div className="flex justify-between items-center mb-8 px-2">
27+
<h2 className="font-bold text-2xl text-black">
28+
참여자 명단({totalCount})
29+
</h2>
30+
<Button
31+
variant="link"
32+
onClick={() => navigate(`/event/${eventId}/guests`)}
33+
className="text-base font-bold text-black p-0 h-auto"
34+
>
35+
더보기
36+
</Button>
37+
</div>
38+
39+
{/* 명단 박스 */}
40+
<div className="border-2 border-black p-10 bg-white">
41+
<div className="grid grid-cols-4 gap-8">
42+
{guests.map((p, idx) => (
43+
<div key={idx} className="flex flex-col items-center gap-4">
44+
<Avatar className="w-16 h-16 border-none">
45+
<AvatarImage src={p.img} />
46+
<AvatarFallback className="bg-black text-white text-xs">
47+
{p.name.slice(0, 2)}
48+
</AvatarFallback>
49+
</Avatar>
50+
<span className="text-sm font-bold text-gray-700 truncate w-full text-center">
51+
{p.name}
52+
</span>
53+
</div>
54+
))}
55+
</div>
56+
</div>
57+
</div>
58+
);
59+
}

0 commit comments

Comments
 (0)