/** * TripItineraryCard — Sasquatch's day-by-day skate trip plan. * ───────────────────────────────────────────────────────────────────────────── * Renders a structured itinerary (not a wall of text): weather header, days * with spots/events/coaches, local crews, and honest actions — * • Save all spots to a Collection (Nostr-native, logged-in only) * • Book / message a coach (links to their profile → zap/DM there) * • Deep-link out to flights/stays (we assist, we don't book) */ import { useState } from 'react'; import { Loader2, Check, MapPin, Calendar, GraduationCap, Users, CloudRain, Bookmark, Plane } from 'lucide-react'; import type { Itinerary } from '@/lib/tripPlanner'; import { travelLinks } from '@/lib/tripPlanner'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useCreateSpotCollection } from '@/hooks/useSpotCollections'; import { useToast } from '@/hooks/useToast'; import { cn } from '@/lib/utils'; const KIND_ICON = { spot: MapPin, event: Calendar, coach: GraduationCap, } as const; export function TripItineraryCard({ itinerary }: { itinerary: Itinerary }) { const { user } = useCurrentUser(); const { createCollection, isPending } = useCreateSpotCollection(); const { toast } = useToast(); const [saved, setSaved] = useState(false); const w = itinerary.weather; const rainy = (w?.precipitation_mm ?? 0) > 0.5 || (w?.skateability_score ?? 100) < 40; const handleSave = async () => { if (!user) { toast({ title: 'Log in to save', description: 'Sign in to keep this trip as a Collection.' }); return; } try { await createCollection({ title: `${itinerary.destination} skate trip 🛹`, description: `Trip plan by The Sasquatch — ${itinerary.days.length} days in ${itinerary.destination}.`, spotRefs: itinerary.allSpotRefs, }); setSaved(true); toast({ title: 'Saved to Collections 🦧', description: `Your ${itinerary.destination} trip is bookmarked.` }); } catch (err) { toast({ title: "Couldn't save", description: err instanceof Error ? err.message : 'Try again in a sec.', variant: 'destructive', }); } }; return (