|
| 1 | +import { Button } from '@/components/ui/button'; |
| 2 | +import { useEffect, useState } from 'react'; |
| 3 | +import { useNavigate, useParams } from 'react-router'; |
| 4 | +import EventDetailContent from '../components/EventDetailContent'; |
| 5 | +import GuestSummaryList from '../components/GuestSummaryList'; |
| 6 | +import type { Events } from '../types/schema'; |
| 7 | + |
| 8 | +// SVG 아이콘 컴포넌트 |
| 9 | +const IconChevronLeft = () => ( |
| 10 | + <svg |
| 11 | + width="24" |
| 12 | + height="24" |
| 13 | + viewBox="0 0 24 24" |
| 14 | + fill="none" |
| 15 | + stroke="currentColor" |
| 16 | + strokeWidth="2" |
| 17 | + strokeLinecap="round" |
| 18 | + strokeLinejoin="round" |
| 19 | + > |
| 20 | + <path d="m15 18-6-6 6-6" /> |
| 21 | + </svg> |
| 22 | +); |
| 23 | + |
| 24 | +export default function JoinEvent() { |
| 25 | + const { id } = useParams<{ id: string }>(); |
| 26 | + const navigate = useNavigate(); |
| 27 | + const [schedule, setSchedule] = useState<Events | null>(null); |
| 28 | + const [displayGuests, setDisplayGuests] = useState< |
| 29 | + { name: string; img: string | undefined }[] |
| 30 | + >([]); |
| 31 | + |
| 32 | + useEffect(() => { |
| 33 | + // 데이터 하드코딩 |
| 34 | + const mockEvent: Events = { |
| 35 | + id: Number(id) || 1, |
| 36 | + title: '제2회 기획 세미나', |
| 37 | + description: |
| 38 | + '일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 일정설명 ...', |
| 39 | + location: '서울대', |
| 40 | + start_at: '2026-02-02T18:00:00Z', |
| 41 | + end_at: '2026-02-02T20:00:00Z', |
| 42 | + capacity: 10, |
| 43 | + waitlist_enabled: true, |
| 44 | + registration_deadline: '2026-02-02T17:00:00Z', |
| 45 | + created_by: 123, // 관리자 ID |
| 46 | + created_at: '2026-01-14T00:00:00Z', |
| 47 | + updated_at: '2026-01-14T00:00:00Z', |
| 48 | + }; |
| 49 | + |
| 50 | + // 관리자 확인 로직 |
| 51 | + // if (!isLoggedIn || !isAdmin(mockData.ownerName)) { |
| 52 | + // alert('접근 권한이 없습니다. 관리자만 접근 가능합니다.'); |
| 53 | + // navigate('/'); // 혹은 로그인 페이지로 이동 |
| 54 | + // return; |
| 55 | + // } |
| 56 | + |
| 57 | + setSchedule(mockEvent); |
| 58 | + |
| 59 | + setDisplayGuests([ |
| 60 | + { name: '이름1', img: undefined }, // profile_image가 null인 경우 |
| 61 | + { name: '이름2', img: 'https://via.placeholder.com/40' }, |
| 62 | + { name: '이름3', img: undefined }, |
| 63 | + { name: '이름4', img: undefined }, |
| 64 | + ]); |
| 65 | + }, [id]); |
| 66 | + |
| 67 | + if (!schedule) return null; |
| 68 | + |
| 69 | + return ( |
| 70 | + <div className="min-h-screen bg-white flex flex-col relative pb-20"> |
| 71 | + {/* 상단 네비게이션 */} |
| 72 | + <div className="w-full flex justify-center"> |
| 73 | + <div className="max-w-2xl min-w-[320px] w-[90%] flex items-center px-6 py-8"> |
| 74 | + <Button |
| 75 | + variant="ghost" |
| 76 | + size="icon" |
| 77 | + onClick={() => navigate(-1)} |
| 78 | + className="rounded-full" |
| 79 | + > |
| 80 | + <IconChevronLeft /> |
| 81 | + </Button> |
| 82 | + <h1 className="text-2xl sm:text-3xl font-bold flex-1 ml-4 truncate text-black"> |
| 83 | + {schedule.title} |
| 84 | + </h1> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + |
| 88 | + {/* 메인 콘텐츠 */} |
| 89 | + <div className="max-w-2xl min-w-[320px] mx-auto w-[90%] px-6 flex flex-col gap-10"> |
| 90 | + {/* 일정 정보 */} |
| 91 | + <EventDetailContent schedule={schedule} /> |
| 92 | + |
| 93 | + {/* 신청하기 버튼*/} |
| 94 | + <Button className="w-full h-16 rounded-2xl bg-black text-white text-xl font-bold"> |
| 95 | + 신청하기 |
| 96 | + </Button> |
| 97 | + |
| 98 | + {/* 참여자 명단 섹션 */} |
| 99 | + <GuestSummaryList |
| 100 | + guests={displayGuests} |
| 101 | + totalCount={8} |
| 102 | + eventId={schedule.id} |
| 103 | + /> |
| 104 | + </div> |
| 105 | + </div> |
| 106 | + ); |
| 107 | +} |
0 commit comments