From 73a7c4843b0cc2f198336ab56e2eb0dcdc76d6e1 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 19 Nov 2026 21:31:46 +0100 Subject: [PATCH] fix(mobile): a stay can be added to a trip that has no place yet A stay belongs to one of the trip's places, so on a new trip the accommodation sheet only said "Add places to your trip first", and the booking could not be saved without leaving the sheet (TestFlight feedback, 5.1.3). The hint now carries the "Add place/activity" button for anyone allowed to add places: the place form opens over the sheet, and the place is listed to pick once it is saved. --- .../trip/sheets/MAccommodationSheet.tsx | 29 ++++++++++++++++--- .../mobile/trip/MAccommodationSheet.test.tsx | 18 +++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/client/src/mobile/screens/trip/sheets/MAccommodationSheet.tsx b/client/src/mobile/screens/trip/sheets/MAccommodationSheet.tsx index 0a7d84308..1f46d1748 100644 --- a/client/src/mobile/screens/trip/sheets/MAccommodationSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MAccommodationSheet.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { ArrowRight, Check, Hotel, MapPin, X } from 'lucide-react' +import { ArrowRight, Check, Hotel, MapPin, Plus, X } from 'lucide-react' import MSheet from '../../../components/MSheet' import MIconBtn from '../../../components/MIconBtn' import CustomSelect from '../../../../components/shared/CustomSelect' @@ -88,6 +88,15 @@ export default function MAccommodationSheet({ planner, shell }: MTripSheetsProps const filteredPlaces = stayPlaceChoices(places, form.place_id, categoryFilter) + // Same opener as the places tab's add button: a blank form, no prefilled position. + const canAddPlace = planner.can('place_edit', planner.trip) + const openAddPlace = () => { + planner.setEditingPlace(null) + planner.setEditingAssignmentId(null) + planner.setPrefillCoords(null) + planner.setShowPlaceForm(true) + } + const save = async () => { setSaving(true) const body = stayRequestBody(form, range) @@ -204,9 +213,21 @@ export default function MAccommodationSheet({ planner, shell }: MTripSheetsProps {/* Place picker */} {t('reservations.meta.pickHotel')} {filteredPlaces.length === 0 ? ( -

- {t('day.noPlacesForHotel')} -

+
+

{t('day.noPlacesForHotel')}

+ {/* A new trip has no place yet, and the stay needs one: the place form + opens over this sheet and its place is listed here once saved. */} + {canAddPlace && ( + + )} +
) : (
{filteredPlaces.map(p => { diff --git a/client/tests/unit/mobile/trip/MAccommodationSheet.test.tsx b/client/tests/unit/mobile/trip/MAccommodationSheet.test.tsx index 331209e0f..295840fb1 100644 --- a/client/tests/unit/mobile/trip/MAccommodationSheet.test.tsx +++ b/client/tests/unit/mobile/trip/MAccommodationSheet.test.tsx @@ -8,7 +8,7 @@ import { useSettingsStore } from '../../../../src/store/settingsStore' import { isBlurred } from '../../../helpers/bookingCodeBlur' import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render' -// FE-MOB-ACCSH-001 to FE-MOB-ACCSH-031 +// FE-MOB-ACCSH-001 to FE-MOB-ACCSH-033 // The pickers have their own suites; here they only need to be addressable, so // they render as plain controls. data-value keeps the requested value readable @@ -256,6 +256,22 @@ describe('MAccommodationSheet', () => { expect(screen.getByText('Add places to your trip first')).toBeInTheDocument() }) + it('FE-MOB-ACCSH-032: a trip without places offers to add one instead of a dead end', () => { + const { planner } = setup(makePlanner({ places: [] })) + expect(screen.getByText('Add places to your trip first')).toBeInTheDocument() + + fireEvent.click(screen.getByRole('button', { name: 'Add place/activity' })) + + expect(planner.setEditingPlace).toHaveBeenCalledWith(null) + expect(planner.setShowPlaceForm).toHaveBeenCalledWith(true) + }) + + it('FE-MOB-ACCSH-033: without the right to add places the hint stays a hint', () => { + setup(makePlanner({ places: [], can: vi.fn(() => false) })) + expect(screen.getByText('Add places to your trip first')).toBeInTheDocument() + expect(screen.queryByRole('button', { name: 'Add place/activity' })).toBeNull() + }) + it('FE-MOB-ACCSH-018: without categories there are no filter chips', () => { setup(makePlanner({ categories: [] })) expect(screen.queryByRole('button', { name: 'Hotels' })).not.toBeInTheDocument()