forked from zaidmukaddam/scira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-view.tsx
185 lines (172 loc) · 6.64 KB
/
list-view.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
/* eslint-disable @next/next/no-img-element */
import React from 'react';
import { cn } from "@/lib/utils";
import { Button } from '@/components/ui/button';
import PlaceholderImage from './placeholder-image';
interface Location {
lat: number;
lng: number;
}
interface Photo {
thumbnail: string;
small: string;
medium: string;
large: string;
original: string;
caption?: string;
}
interface Place {
name: string;
location: Location;
place_id: string;
vicinity: string;
rating?: number;
reviews_count?: number;
price_level?: string;
description?: string;
photos?: Photo[];
is_closed?: boolean;
next_open_close?: string;
type?: string;
cuisine?: string;
source?: string;
phone?: string;
website?: string;
hours?: string[];
distance?: string;
bearing?: string;
}
interface PlaceCardProps {
place: Place;
onClick: () => void;
variant?: 'overlay' | 'list';
}
const PlaceCard: React.FC<PlaceCardProps> = ({
place,
onClick,
variant = 'list'
}) => {
const isOverlay = variant === 'overlay';
return (
<div
onClick={onClick}
className={cn(
"bg-black text-white rounded-lg transition-transform",
isOverlay ? 'bg-opacity-90 backdrop-blur-sm' : 'hover:bg-opacity-80',
'cursor-pointer p-4'
)}
>
<div className="flex gap-4">
<div className="w-24 h-24 rounded-lg overflow-hidden flex-shrink-0">
{place.photos?.[0]?.medium ? (
<img
src={place.photos[0].medium}
alt={place.name}
className="w-full h-full object-cover"
/>
) : (
<PlaceholderImage />
)}
</div>
<div className="flex-1 min-w-0">
<h3 className="text-xl font-medium mb-1">{place.name}</h3>
<div className="flex items-center gap-2 mb-1">
<span className={cn(
"text-sm font-medium",
place.is_closed ? "text-red-500" : "text-green-500"
)}>
{place.is_closed ? "Closed" : "Open now"}
</span>
{place.next_open_close && (
<>
<span className="text-neutral-400">·</span>
<span className="text-sm text-neutral-400">until {place.next_open_close}</span>
</>
)}
{place.type && (
<>
<span className="text-neutral-400">·</span>
<span className="text-sm text-neutral-400 capitalize">{place.type}</span>
</>
)}
</div>
<div className="flex items-center gap-2 text-sm mb-2">
{place.rating && (
<span>{place.rating.toFixed(1)}</span>
)}
{place.reviews_count && (
<span className="text-neutral-400">({place.reviews_count} reviews)</span>
)}
{place.price_level && (
<>
<span className="text-neutral-400">·</span>
<span>{place.price_level}</span>
</>
)}
</div>
{place.description && (
<p className="text-sm text-neutral-400 line-clamp-2 mb-3">
{place.description}
</p>
)}
<div className="flex gap-2">
<Button
variant="secondary"
size="sm"
className="bg-neutral-800 hover:bg-neutral-700 text-white"
onClick={(e) => {
e.stopPropagation();
window.open(
`https://www.google.com/maps/dir/?api=1&destination=${place.location.lat},${place.location.lng}`,
'_blank'
);
}}
>
Directions
</Button>
{place.website && (
<Button
variant="secondary"
size="sm"
className="bg-neutral-800 hover:bg-neutral-700 text-white"
onClick={(e) => {
e.stopPropagation();
window.open(place.website, '_blank');
}}
>
Website
</Button>
)}
{place.phone && (
<Button
variant="secondary"
size="sm"
className="bg-neutral-800 hover:bg-neutral-700 text-white"
onClick={(e) => {
e.stopPropagation();
window.open(`tel:${place.phone}`, '_blank');
}}
>
Call
</Button>
)}
{place.place_id && (
<Button
variant="secondary"
size="sm"
className="bg-neutral-800 hover:bg-neutral-700 text-white"
onClick={(e) => {
e.stopPropagation();
window.open(`https://www.tripadvisor.com/${place.place_id}`, '_blank');
}}
>
TripAdvisor
</Button>
)}
</div>
</div>
</div>
</div>
);
};
export default PlaceCard;