| 1 | "use client"; |
| 2 | |
| 3 | import Image from "next/image"; |
| 4 | import { Armchair, ExternalLink, ImageOff } from "lucide-react"; |
| 5 | import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"; |
| 6 | import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; |
| 7 | import { cn } from "@/lib/utils"; |
| 8 | import type { TicketEvent } from "@/lib/types"; |
| 9 | |
| 10 | |
| 11 | export function SeatView({ event }: { event: TicketEvent }) { |
| 12 | const venueQuery = encodeURIComponent(`${event.venue_name ?? event.title} view from seat`); |
| 13 | const viewFromSeatUrl = `https://www.google.com/search?q=${venueQuery}`; |
| 14 | |
| 15 | return ( |
| 16 | <Dialog> |
| 17 | <Tooltip> |
| 18 | <TooltipTrigger asChild> |
| 19 | <DialogTrigger |
| 20 | className={cn( |
| 21 | "inline-flex h-8 w-8 items-center justify-center rounded-[var(--radius)]", |
| 22 | "border border-[var(--color-border-default)] text-[var(--color-fg-tertiary)]", |
| 23 | "transition-colors hover:border-[var(--color-accent-teal)] hover:text-[var(--color-accent-teal)]", |
| 24 | "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-accent-teal)]", |
| 25 | )} |
| 26 | aria-label="View seats" |
| 27 | > |
| 28 | <Armchair className="h-4 w-4" aria-hidden /> |
| 29 | </DialogTrigger> |
| 30 | </TooltipTrigger> |
| 31 | <TooltipContent>View seats</TooltipContent> |
| 32 | </Tooltip> |
| 33 | |
| 34 | <DialogContent title="Seats"> |
| 35 | <div className="space-y-3 p-4"> |
| 36 | <p className="text-sm font-medium text-[var(--color-fg-primary)]">{event.title}</p> |
| 37 | {event.venue_name ? ( |
| 38 | <p className="-mt-2 text-xs text-[var(--color-fg-tertiary)]"> |
| 39 | {[event.venue_name, event.city].filter(Boolean).join(" · ")} |
| 40 | </p> |
| 41 | ) : null} |
| 42 | |
| 43 | {event.seatmap_url ? ( |
| 44 | <div className="relative overflow-hidden rounded-[var(--radius)] border border-[var(--color-border-subtle)] bg-[var(--color-bg-inset)]"> |
| 45 | <Image |
| 46 | src={event.seatmap_url} |
| 47 | alt={`Seat map for ${event.title}`} |
| 48 | width={520} |
| 49 | height={360} |
| 50 | unoptimized |
| 51 | className="h-auto w-full object-contain" |
| 52 | /> |
| 53 | </div> |
| 54 | ) : ( |
| 55 | <div className="flex flex-col items-center gap-2 rounded-[var(--radius)] border border-dashed border-[var(--color-border-subtle)] py-8 text-center"> |
| 56 | <ImageOff className="h-5 w-5 text-[var(--color-fg-tertiary)]" aria-hidden /> |
| 57 | <p className="text-xs text-[var(--color-fg-tertiary)]"> |
| 58 | No seat map from the source for this event. |
| 59 | </p> |
| 60 | </div> |
| 61 | )} |
| 62 | |
| 63 | <div className="flex gap-2"> |
| 64 | <a |
| 65 | href={viewFromSeatUrl} |
| 66 | target="_blank" |
| 67 | rel="noopener noreferrer" |
| 68 | className="inline-flex h-9 flex-1 items-center justify-center gap-1.5 rounded-[var(--radius)] border border-[var(--color-border-default)] text-xs font-medium text-[var(--color-fg-secondary)] transition-colors hover:border-[var(--color-accent-teal)] hover:text-[var(--color-accent-teal)]" |
| 69 | > |
| 70 | View from seat <ExternalLink className="h-3.5 w-3.5" aria-hidden /> |
| 71 | </a> |
| 72 | <a |
| 73 | href={`${event.buy_url}${event.buy_url.includes("?") ? "&" : "?"}drophawk=1`} |
| 74 | target="_blank" |
| 75 | rel="noopener noreferrer" |
| 76 | className="inline-flex h-9 flex-1 items-center justify-center gap-1.5 rounded-[var(--radius)] bg-[var(--color-accent-teal)] text-xs font-semibold text-[var(--color-bg-inset)] transition-colors hover:bg-[var(--color-accent-teal-hover)]" |
| 77 | > |
| 78 | Pick seats <ExternalLink className="h-3.5 w-3.5" aria-hidden /> |
| 79 | </a> |
| 80 | </div> |
| 81 | </div> |
| 82 | </DialogContent> |
| 83 | </Dialog> |
| 84 | ); |
| 85 | } |