From 74971161185bccecacfd2db85ce3293cfeac74b9 Mon Sep 17 00:00:00 2001 From: "nick.leiby" Date: Sun, 1 Feb 2026 15:52:22 -0500 Subject: [PATCH] fix: render single day in ItineraryDay instead of mapping all itinerary days Co-authored-by: Cursor --- frontend/components/ItineraryDay.tsx | 208 +++++++++++++-------------- 1 file changed, 103 insertions(+), 105 deletions(-) diff --git a/frontend/components/ItineraryDay.tsx b/frontend/components/ItineraryDay.tsx index 717aeb34..897ec291 100644 --- a/frontend/components/ItineraryDay.tsx +++ b/frontend/components/ItineraryDay.tsx @@ -93,116 +93,114 @@ export default function ItineraryDay({ day, isEditing }: PropsT) { isAddingLocation || isFetchingTrip; + // Find the index of this day in the itinerary for proper day numbering + const dayIndex = trip?.itinerary?.findIndex((it) => it.id === day.id) ?? 0; + const date = trip?.startDate ? dayjs(trip.startDate).add(dayIndex, "day").format("dddd, MMMM D") : ""; + const { notes, locations } = day; + return ( - <> - {trip?.itinerary?.map(({ id: dayId, notes, locations }, i) => { - const date = dayjs(trip.startDate).add(i, "day").format("dddd, MMMM D"); - return ( -
-
-
-

Day {i + 1}

- {date} -
- setNotesMutation.mutate({ notes: value })} - className="mt-1 mb-4" - canEdit={isEditing} - /> -
- {!!locations?.length && ( -
    - {locations?.map(({ locationId, type, id }, index) => { - const location = - trip?.hotspots?.find((h) => h.id === locationId) || trip?.markers?.find((m) => m.id === locationId); +
    +
    +
    +

    Day {dayIndex + 1}

    + {date} +
    + setNotesMutation.mutate({ notes: value })} + className="mt-1 mb-4" + canEdit={isEditing} + /> +
    + {!!locations?.length && ( +
      + {locations?.map(({ locationId, type, id }, index) => { + const location = + trip?.hotspots?.find((h) => h.id === locationId) || trip?.markers?.find((m) => m.id === locationId); - return ( - - {index !== 0 && ( -
    • - -
    • + return ( + + {index !== 0 && ( +
    • + +
    • + )} +
    • + + {isEditing && ( +
      + {index !== locations.length - 1 && ( + )} -
    • + {index !== 0 && ( - {isEditing && ( -
      - {index !== locations.length - 1 && ( - - )} - {index !== 0 && ( - - )} - -
      - )} -
    • -
      - ); - })} -
    - )} - {isEditing && ( -
    - - -
    - )} -
    - ); - })} - + )} + +
+ )} + + + ); + })} + + )} + {isEditing && ( +
+ + +
+ )} + ); }