-
Notifications
You must be signed in to change notification settings - Fork 0
/
CourtDetail.tsx
221 lines (212 loc) · 7.95 KB
/
CourtDetail.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
'use client';
import React from 'react';
import { Button } from '@nextui-org/react';
import { IoIosClose } from 'react-icons/io';
import { FaPhoneAlt, FaParking, FaTag, FaRegDotCircle } from 'react-icons/fa';
import Image from 'next/image';
import { FaLocationDot, FaClock, FaLightbulb } from 'react-icons/fa6';
import { PiChatsCircle } from 'react-icons/pi';
import { CourtIcon } from './icons/CourtIcon';
import { HoopIcon } from './icons/HoopIcon';
import { FeeIcon } from './icons/FeeIcon';
import { InfoIcon } from './icons/InfoIcon';
import { WebsiteIcon } from './icons/WebsiteIcon';
interface CourtDetailsProps {
isVisible: boolean;
onClose: () => void;
selectedPlace: any;
}
// 농구장 사진, 주소(도로명), 코트 종류, 실내외(실내/야외), 코트사이즈, 골대수, 야간 조명, 개방시간, 사용료, 주차 가능, 전화번호, 홈페이지, 기타 정보
// [TODO] 주소 복사 넣기, ✅
// 각 컨텐츠 아이콘 넣기 ✅
// true, false 명확히하기 ✅
// 현재 링크 공유 만들기
const CourtDetails: React.FC<CourtDetailsProps> = ({
isVisible,
onClose,
selectedPlace,
}) => {
const handlePhoneClick = () => {
if (selectedPlace.phoneNum) {
const confirmDial = window.confirm(
`이 전화번호로 연결하시겠습니까? ${selectedPlace.phoneNum}`
);
if (confirmDial) {
window.location.href = `tel:${selectedPlace.phoneNum}`;
}
}
};
const handleCopyAddress = async () => {
if (selectedPlace.address) {
try {
await navigator.clipboard.writeText(selectedPlace.address);
alert('주소가 복사되었습니다.');
} catch (error) {
console.error('주소 복사 중 오류 발생:', error);
alert('주소를 복사하는 데 실패했습니다.');
}
}
};
return (
<div
className={`absolute inset-0 z-40 m-auto h-fit w-full max-w-md rounded-lg bg-background shadow-md
transition-all duration-300 ease-in-out ${isVisible ? '' : 'hidden'}`}
>
<div className="relative max-h-[96vh] w-full overflow-auto rounded-lg text-sm">
<div className="relative h-48 w-full">
<Image
layout="fill"
alt="농구장 사진"
src="/images/han-river-park-court.png"
/>
<Button
isIconOnly
className="bg-gradient absolute right-2 top-2"
onClick={onClose}
aria-label="Close"
>
<IoIosClose size={30} className="text-gray-600" />
</Button>
</div>
<div className="mb-5 px-8 py-4">
<div className="flex justify-between">
<h2 className="mx-1 text-xl font-bold">
{selectedPlace.courtName}
</h2>
<Button
radius="full"
size="sm"
variant="bordered"
startContent={<PiChatsCircle />}
className="border-1"
aria-label="시설 채팅 바로가기"
>
시설 채팅
</Button>
</div>
<div className="my-4 flex w-full justify-center gap-3">
<Button
color="primary"
variant="bordered"
startContent={<FaRegDotCircle />}
radius="full"
className="border-1"
>
출발
</Button>
<Button
color="primary"
radius="full"
startContent={<FaLocationDot />}
>
도착
</Button>
</div>
<hr className="w-90 my-4 h-px bg-gray-300" />
<div className="my-4 flex flex-col gap-4">
<div className="flex gap-2 align-middle">
<FaLocationDot
size={16}
className="dark:text-gray-20 text-gray-400"
/>
<span>{selectedPlace.address}</span>
<button type="button" onClick={handleCopyAddress}>
<span className="text-blue-500">복사</span>
</button>
</div>
<div className="flex gap-2 align-middle">
<FaClock size={14} className="text-gray-400 dark:text-gray-200" />
<span>
개방 시간:{' '}
<span className="text-rose-400">
{selectedPlace.openingHours === true ? '24시간' : '제한'}
</span>
</span>
</div>
<div className="flex gap-2 align-middle">
<FaPhoneAlt
size={15}
className="pointer-events-auto text-gray-400 dark:text-gray-200"
onClick={handlePhoneClick}
/>
<span>
{selectedPlace.phoneNum ? selectedPlace.phoneNum : '-'}
</span>
</div>
<div className="flex gap-2 align-middle">
<FeeIcon className="text-gray-400 dark:text-gray-200" />
<span className="text-info text-blue-500">
이용료: {selectedPlace.fee === true ? '유료' : '무료'}
</span>
</div>
<div className="flex gap-2 align-middle">
<WebsiteIcon className="text-gray-400 dark:text-gray-200" />
<span className="text-blue-500">
{selectedPlace.website !== null ? selectedPlace.website : '-'}
</span>
</div>
<div className="flex gap-2 align-middle">
<CourtIcon className="text-gray-400 dark:text-gray-200" />
<span className="font-medium">
코트 종류: {selectedPlace.courtType}
</span>
</div>
<div className="flex gap-2 align-middle">
<CourtIcon className="text-gray-400 dark:text-gray-200" />
<span className="font-medium">
코트 사이즈: {selectedPlace.courtSize}
</span>
</div>
<div className="flex gap-2 align-middle">
<HoopIcon className="text-gray-400 dark:text-gray-200" />
<span className="font-medium">
골대 수: {selectedPlace.hoopCount}
</span>
</div>
<div className="flex gap-2 align-middle">
<FaLightbulb
size={17}
className="text-gray-400 dark:text-gray-200"
/>
<span>
야간 조명:{' '}
{selectedPlace.nightLighting === true ? '있음' : '없음'}
</span>
</div>
<div className="flex gap-2 align-middle">
<FaParking
size={17}
className="text-gray-400 dark:text-gray-200"
/>
<span>
주차: {selectedPlace.parkingAvailabl === true ? '가능' : '불가'}
</span>
</div>
<div className="flex gap-2 align-middle text-sm">
<FaTag size={17} className="text-gray-400 dark:text-gray-200" />
<span className="rounded-sm bg-gray-100 px-1 text-gray-500 dark:bg-gray-300 dark:text-gray-600">
{selectedPlace.indoorOutdoor}
</span>
<ul className="flex gap-2">
{selectedPlace.convenience.map((tag: string, idx: number) => (
<li
// eslint-disable-next-line react/no-array-index-key
key={idx}
className="rounded-sm bg-gray-100 px-1 text-gray-500 dark:bg-gray-300 dark:text-gray-600"
>
<span>{tag}</span>
</li>
))}
</ul>
</div>
<div className="flex gap-2 align-middle">
<InfoIcon className="text-gray-400 dark:text-gray-200" />
<span className="text-sm">{selectedPlace.additionalInfo}</span>
</div>
</div>
</div>
</div>
</div>
);
};
export default CourtDetails;