import { groupItineraryByDay } from "@/lib/itinerary"; interface ItineraryItem { day: number; startTime: string; endTime: string | null; activity: string; order: number; } interface TripProgramBlockProps { meetingPoint: string | null; itinerary: string | null; itineraryItems: ItineraryItem[]; whatsIncluded: string | null; whatsExcluded: string | null; } export function TripProgramBlock({ meetingPoint, itinerary, itineraryItems, whatsIncluded, whatsExcluded, }: TripProgramBlockProps) { const hasStructuredItinerary = itineraryItems.length > 0; const hasLegacyItinerary = !hasStructuredItinerary && !!itinerary; const hasAny = meetingPoint || hasStructuredItinerary || hasLegacyItinerary || whatsIncluded || whatsExcluded; if (!hasAny) return null; const grouped = hasStructuredItinerary ? groupItineraryByDay(itineraryItems) : null; return (

Detail perjalanan

{meetingPoint && (

Meeting point

{meetingPoint}

)} {grouped && (

Itinerary

{[...grouped.entries()].map(([day, items]) => (

Hari {day}

    {items.map((item) => (
  1. {item.startTime} {item.endTime ? `–${item.endTime}` : ""} {item.activity}
  2. ))}
))}
)} {hasLegacyItinerary && (

Itinerary

{itinerary}

)} {(whatsIncluded || whatsExcluded) && (
{whatsIncluded && (

Termasuk

{whatsIncluded}

)} {whatsExcluded && (

Tidak termasuk

{whatsExcluded}

)}
)}
); }