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()