mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
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:
@@ -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 (
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -339,11 +339,13 @@ export default function MReservationSheet({ planner, onOpenExpense }: MReservati
|
||||
placeholder={t('reservations.locationPlaceholder')}
|
||||
className={FIELD_CLS}
|
||||
/>
|
||||
{!form.hotel_place_id && (
|
||||
<div className="mt-2">
|
||||
<StayPinStatus pin={stayPin.pin} onRetry={() => stayPin.lookUp(form.title, form.hotel_address)} />
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-2 empty:hidden">
|
||||
<StayPinStatus
|
||||
pin={stayPin.pin}
|
||||
hidden={!!form.hotel_place_id}
|
||||
onRetry={() => stayPin.lookUp(form.title, form.hotel_address)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user