fix(planner): let the day list see which stop a booking wrote

The row shapers name every column they pass on, and accommodation_id was in
none of them. So the field the day list hides on never reached the client, and
the booked night was listed as an ordinary place next to the overnight block
that already named it. The stop was correct in the table the whole time; the
three read paths just dropped it on the way out.

The stamp on the freshly written stop had the same hole from the other side: the
INSERT went in without the booking id and an UPDATE added it afterwards, so the
row handed back in the answer, the one the client that booked the night puts
straight into its store, carried none. It goes in with the INSERT now.

The shared link gains the same filter. It has no road trip view to need the stop
and already shows the booking as its own chip on the day, so the row was only
ever the same hotel twice.
This commit is contained in:
Maurice
2026-09-13 12:59:19 +02:00
parent e3471e2dc8
commit d0d3f455a8
9 changed files with 72 additions and 9 deletions
+33
View File
@@ -1353,6 +1353,39 @@ describe('SharedTripPage', () => {
});
});
describe('FE-PAGE-SHARED-037b: a booked night is not listed twice on a shared day', () => {
// Booking a night puts its hotel on the check-in day as a stop, because road trip
// mode drives to it. A shared link has no road trip view and already shows the
// booking as its own chip on the day, so that stop would be the same hotel again.
const days = [{ id: 41, trip_id: 1, day_number: 1, date: '2026-07-01', title: 'Day One' }];
// The address is the tell: the list row prints it, the map marker's tooltip does not,
// so it says whether the row rendered rather than whether the place exists at all.
const place = (id: number, name: string, address: string) => ({
id, name, description: null, address, lat: 48.86, lng: 2.34, category_id: null,
price: null, place_time: null, end_time: null, duration_minutes: null, notes: null,
website: null, phone: null, image_url: null, transport_mode: null, category: null, tags: [],
});
it('leaves out the stop the booking wrote and keeps the one the traveller placed', async () => {
await open('stay-token', payload({
days,
assignments: {
41: [
{ id: 401, day_id: 41, order_index: 0, notes: null, accommodation_id: null, place: place(601, 'Musee Rodin', '77 Rue de Varenne') },
{ id: 402, day_id: 41, order_index: 1, notes: null, accommodation_id: 7, place: place(602, 'Hotel Adlon', 'Unter den Linden 77') },
],
},
accommodations: [{ id: 7, place_id: 602, start_day_id: 41, end_day_id: 41, place_name: 'Hotel Adlon' }],
}));
fireEvent.click(screen.getByText('Day One'));
// The stop the traveller placed is listed, address and all.
await waitFor(() => expect(screen.getByText('77 Rue de Varenne')).toBeInTheDocument());
// The booked night is not: it is already on the day as its own chip.
expect(screen.queryByText('Unter den Linden 77')).toBeNull();
});
});
// ── #2320: the richer read-only detail ─────────────────────────────────
describe('FE-PAGE-SHARED-038: a stop shows its address, description, both notes, duration and contact (#2320)', () => {
+5 -1
View File
@@ -465,7 +465,11 @@ export default function SharedTripPage() {
{/* Day Plan */}
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{sortedDays.map((day: any, di: number) => {
const da = assignments[String(day.id)] || [];
// Without the booked nights: the day already shows each of them as its
// own chip, and the stop a booking writes for the drive would be that
// same hotel a second time. There is no road trip view on a shared link,
// so the stop has nothing else to do here.
const da = (assignments[String(day.id)] || []).filter((a: any) => a.accommodation_id == null);
// A share can still carry an assignment for a deleted place. The timeline
// skips those rows, so the header must not count them either.
const dayPlaceCount = da.filter((a: any) => a.place).length;