fix(bookings): keep the review's map status within the complexity and strict-null budgets

The status hides itself for a stay linked to a trip place instead of each form
branching around it, and a lookup takes a missing name.
This commit is contained in:
Maurice
2026-10-25 18:30:27 +01:00
parent b80fdf27f2
commit 44509723fd
5 changed files with 30 additions and 13 deletions
@@ -368,12 +368,14 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
</div>
<EditorField label={t('reservations.locationAddress')}>
<AddressInput value={form.hotel_address} onChange={v => set('hotel_address', v)}
onPick={!form.hotel_place_id ? stayPin.pick : undefined}
onPick={stayPin.pick}
placeholder={t('reservations.locationPlaceholder')} className={INPUT} />
</EditorField>
{!form.hotel_place_id && (
<StayPinStatus pin={stayPin.pin} onRetry={() => stayPin.lookUp(form.title, form.hotel_address)} />
)}
<StayPinStatus
pin={stayPin.pin}
hidden={!!form.hotel_place_id}
onRetry={() => stayPin.lookUp(form.title, form.hotel_address)}
/>
</>
)}
@@ -23,6 +23,17 @@ describe('StayPinStatus', () => {
expect(container.textContent).toBe('');
});
it('FE-STAY-PIN-STATUS-001b: a stay already linked to a place of the trip shows nothing', () => {
const { container } = render(
createElement(
TranslationProvider,
null,
createElement(StayPinStatus, { pin: { status: 'missing' }, hidden: true, onRetry: vi.fn() })
)
);
expect(container.textContent).toBe('');
});
it('FE-STAY-PIN-STATUS-002: says it is looking, then where it found the stay', () => {
show({ status: 'searching' });
expect(screen.getByRole('status')).toHaveTextContent('Looking for it on the map');
@@ -5,6 +5,8 @@ import type { StayPin } from './useStayPin';
interface StayPinStatusProps {
pin: StayPin;
/** A stay already linked to a place of the trip shows on the map through that place. */
hidden?: boolean;
/** Asks the map again with what the form now holds. */
onRetry: () => void;
}
@@ -15,9 +17,9 @@ interface StayPinStatusProps {
* found, with a way to search again before it is saved without a pin. Shared by
* the desktop booking dialog and the phone's booking sheet.
*/
export default function StayPinStatus({ pin, onRetry }: StayPinStatusProps) {
export default function StayPinStatus({ pin, hidden = false, onRetry }: StayPinStatusProps) {
const { t } = useTranslation();
if (pin.status === 'idle') return null;
if (hidden || pin.status === 'idle') return null;
if (pin.status === 'searching') {
return (
+2 -2
View File
@@ -29,9 +29,9 @@ export function useStayPin() {
[]
);
const lookUp = (name: string, address: string | null | undefined) => {
const lookUp = (name: string | null | undefined, address: string | null | undefined) => {
const mine = ++ticket.current;
const queries = stayQueries(name, address);
const queries = stayQueries(name ?? '', address);
if (isEffectivelyOffline()) {
setPin({ status: 'idle' });
return;