/** * ItineraryCard Component * * Displays a beautiful, structured travel itinerary with day-by-day breakdown. * Shows activities for morning, afternoon, evening, and meal recommendations. */ import React from "react"; // Type definitions matching the backend structure interface TimeSlot { activities: string[]; location: string; } interface Meals { breakfast: string; lunch: string; dinner: string; } interface DayItinerary { day: number; title: string; morning: TimeSlot; afternoon: TimeSlot; evening: TimeSlot; meals: Meals; } export interface ItineraryData { destination: string; days: number; itinerary: DayItinerary[]; } // Restaurant data structure for day-by-day meals export interface RestaurantData { destination: string; days: number; meals: Array<{ day: number; breakfast: string; lunch: string; dinner: string; }>; } interface ItineraryCardProps { data: ItineraryData; restaurantData?: RestaurantData | null; // Optional restaurant data to populate meals } export const ItineraryCard: React.FC = ({ data, restaurantData, }) => { // Get meals for a specific day from restaurant data const getMealsForDay = (dayNumber: number): Meals | null => { if (!restaurantData) return null; const dayMeals = restaurantData.meals.find((m) => m.day === dayNumber); if (!dayMeals) return null; return { breakfast: dayMeals.breakfast, lunch: dayMeals.lunch, dinner: dayMeals.dinner, }; }; return (
{/* Header */}
πŸ—ΊοΈ

{data.destination} Itinerary

{data.days} day{data.days > 1 ? "s" : ""} of adventure

{/* Days - Scrollable */}
{data.itinerary.map((day, index) => { // Try to get restaurant meals for this day const restaurantMeals = getMealsForDay(day.day); // Use restaurant meals if available, otherwise use original itinerary meals const mealsToDisplay = restaurantMeals || day.meals; return (
{/* Day Header */}
{day.day}

{day.title}

{/* Time Slots and Meals Side-by-Side */}
{/* Time Slots - Takes 1 column */}
πŸ“…

Day Itinerary

{/* Morning */} {/* Afternoon */} {/* Evening */}
{/* Meals - Takes 2 columns */}
🍽️

Meals

{!restaurantMeals && ( Loading... )}
{restaurantMeals ? ( <> ) : ( // Show placeholder while waiting for restaurant data <>
Awaiting recommendations...
Awaiting recommendations...
Awaiting recommendations...
)}
); })}
); }; // Helper component for time slots interface TimeSlotSectionProps { icon: string; title: string; location: string; activities: string[]; color: "orange" | "yellow" | "blue"; } const TimeSlotSection: React.FC = ({ icon, title, location, activities, color, }) => { const colorClasses = { orange: "bg-orange-50 border-orange-200", yellow: "bg-amber-50 border-amber-200", blue: "bg-blue-50 border-blue-200", }; return (
{icon}

{title}

β€’ {location}
    {activities.map((activity, idx) => (
  • β€’ {activity}
  • ))}
); }; // Helper component for meals interface MealItemProps { icon: string; label: string; meal: string; } const MealItem: React.FC = ({ icon, label, meal }) => { return (
{icon}
{label}
{meal}
); };