feat(mail-ingest): admin card, review mark, inbox events and links, translations

- Admin settings (desktop and phone, self-hosted only): the instance switch,
  how mail arrives (IMAP or a signed webhook) with its fields, the address
  template, the AI allowance per person and day, a connection test and the
  status in counts. Changed fields only are saved; secrets stay masked.
- The review mark of an imported booking takes its mark off: the pill in the
  desktop dialog and a row in the phone's transport sheet ('Looks right'),
  through the ordinary booking update. Its hint no longer speaks of airports.
- The inbox follows mailInbox:changed and mailInbox:settings, and
  ?inbox=mail (the 'bookings waiting' notification) opens it.
- mailIngestRepo: the online-only path the views take, answers parsed
  against the shared contracts.
- Dropped 'read with AI' and the unused mail-review contract: the server
  reads a passing AI failure again on its own.
- mailInbox, mailAdmin and the new reservation, settings and notification
  strings in all 28 locales; the pending notice is a plural group.
- The live flight line on the booking cards is one of the card's fields,
  full width on the phone; the phone's live card keeps its map to the middle.
- Admin flight and mail cards sit in the left column.
This commit is contained in:
Maurice
2026-11-13 18:31:07 +01:00
parent bd11cd347d
commit a7adef5353
209 changed files with 5915 additions and 343 deletions
@@ -110,6 +110,15 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {
if (await copyText(r.confirmation_number || '')) toast.success(t('common.copied'))
else toast.error(t('reservations.copyFailed'))
}
// "Looks right": the person checked what an import could not read for sure.
const confirmReview = async () => {
try {
await updateReservation(p.tripId, r.id, { needs_review: 0 })
toast.success(t('reservations.reviewConfirmed'))
} catch {
toast.error(t('reservations.toast.updateError'))
}
}
const rename = async () => {
const title = name.trim()
setRenaming(false)
@@ -143,7 +152,7 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {
{facts.day.date && !facts.isHotel && <span className="font-medium text-content-muted">{facts.day.date}</span>}
</span>
)}
{!!r.needs_review && <ReviewPill pill />}
{!!r.needs_review && <ReviewPill pill onConfirm={p.canEdit ? () => void confirmReview() : undefined} />}
<AirTrailPill r={r} pill />
<MailPill r={r} pill />
{r.confirmation_number && (
@@ -1,11 +1,11 @@
// FE-PLANNER-BKPARTS-001 to FE-PLANNER-BKPARTS-004
// FE-PLANNER-BKPARTS-001 to FE-PLANNER-BKPARTS-005
import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { buildTripFile } from '../../../../tests/helpers/factories';
import { downloadFile, openFile } from '../../../utils/fileDownload';
import type { BookingFacts } from './bookingFacts';
import { FileRows, WhenFields } from './bookingParts';
import { FileRows, ReviewPill, WhenFields } from './bookingParts';
vi.mock('../../../utils/fileDownload', () => ({
openFile: vi.fn(() => Promise.resolve()),
@@ -88,4 +88,13 @@ describe('FileRows', () => {
const { container } = render(<FileRows files={[]} />);
expect(container).toBeEmptyDOMElement();
});
it('FE-PLANNER-BKPARTS-005: the review pill takes its mark off only for someone who may edit', () => {
const onConfirm = vi.fn();
const { rerender } = render(<ReviewPill pill />);
expect(screen.queryByRole('button')).not.toBeInTheDocument();
rerender(<ReviewPill pill onConfirm={onConfirm} />);
fireEvent.click(screen.getByRole('button'));
expect(onConfirm).toHaveBeenCalledOnce();
});
});
@@ -167,15 +167,33 @@ export function TypeTile({ type, size = 32, raised = false }: { type: string; si
)
}
/** The warning icon beside a booking's name on a card or row, or with `pill` a header pill in the detail dialog. */
export function ReviewPill({ pill = false }: { pill?: boolean }) {
/**
* The warning icon beside a booking's name on a card or row, or with `pill` a
* header pill in the detail dialog. With `onConfirm` (the right to edit) the
* pill is the "looks right" switch that takes the mark off.
*/
export function ReviewPill({ pill = false, onConfirm }: { pill?: boolean; onConfirm?: () => void }) {
const { t } = useTranslation()
const content = (
<>
<AlertCircle size={13} strokeWidth={2.2} className="text-warning" />
{t('reservations.needsReview')}
</>
)
if (pill && onConfirm) {
return (
<Tooltip label={`${t('reservations.needsReviewHint')} ${t('reservations.reviewConfirmHint')}`}>
<button type="button" onClick={onConfirm} aria-label={t('reservations.reviewConfirm')} className={`${PILL} hover:opacity-80`} style={fs(12, 'body')}>
{content}
</button>
</Tooltip>
)
}
return (
<Tooltip label={t('reservations.needsReviewHint')}>
{pill ? (
<span className={PILL} style={fs(12, 'body')}>
<AlertCircle size={13} strokeWidth={2.2} className="text-warning" />
{t('reservations.needsReview')}
{content}
</span>
) : (
<span role="img" aria-label={t('reservations.needsReview')} className="grid flex-none place-items-center text-warning">
@@ -1,5 +1,7 @@
import { useTranslation } from '../../../i18n';
import type { Reservation } from '../../../types';
import type { DelayTone } from '../../../utils/flightLiveModel';
import { BOX, Eyebrow } from '../bookings/bookingParts';
import { useCurrentFlightLegIndex, useFlightLiveCard } from './useFlightLiveCard';
const DELAY_TEXT: Record<DelayTone, string> = { ok: 'text-success', minor: 'text-warning', major: 'text-danger' };
@@ -13,8 +15,9 @@ interface FlightLiveStripProps {
}
/**
* A flight's live state on the booking cards: what is happening in one line
* with the delay, and a thin bar across the card while it flies. The full
* A flight's live state on the booking cards, as one of the card's fields:
* what is happening in one line with the delay, and a thin bar along the
* field's foot while it flies. The full
* picture is one click away in the booking dialog. Nothing far ahead of the
* flight (the card shows its date already), nothing once it is long over.
*/
@@ -30,30 +33,30 @@ function Strip({
legIndex,
className,
}: Omit<FlightLiveStripProps, 'type'> & { legIndex: number }) {
const { t } = useTranslation();
const card = useFlightLiveCard(tripId, reservationId, legIndex);
if (!card || card.view.stage === 'upcoming') return null;
const { view } = card;
// The card's own field: the eyebrow over a framed value, like the booking code and the route under it.
return (
<div className={`flex min-w-0 flex-col gap-1.5 rounded-lg bg-surface-tertiary px-2.5 py-[7px] ${className}`}>
<div className="flex min-w-0 items-center gap-2">
<span className="min-w-0 flex-1 truncate text-caption font-semibold text-content">{card.line}</span>
{card.delay && card.delay.tone !== 'ok' && (
<span className={`flex-none text-caption font-semibold tabular-nums ${DELAY_TEXT[card.delay.tone]}`}>
{card.delay.text}
<div className={`min-w-0 ${className}`}>
<Eyebrow className="mb-[3px]">{t('reservations.status')}</Eyebrow>
<div className={`${BOX} relative overflow-hidden px-[10px] py-[7px]`}>
<div className="flex min-w-0 items-center justify-center gap-2 text-body font-semibold text-content">
<span className="min-w-0 truncate">{card.line}</span>
{card.delay && card.delay.tone !== 'ok' && (
<span className={`flex-none tabular-nums ${DELAY_TEXT[card.delay.tone]}`}>{card.delay.text}</span>
)}
</div>
{view.stage === 'airborne' && (
<span className="absolute inset-x-0 bottom-0 block h-[3px] bg-surface-tertiary" aria-hidden="true">
<span
className="block h-full bg-info transition-[width] duration-700 motion-reduce:transition-none"
style={{ width: `${Math.round(view.progress * 100)}%` }}
/>
</span>
)}
</div>
{view.stage === 'airborne' && (
<span
className="block h-1 w-full overflow-hidden rounded-full bg-[color:var(--border-primary)]"
aria-hidden="true"
>
<span
className="block h-full rounded-full bg-accent transition-[width] duration-700 motion-reduce:transition-none"
style={{ width: `${Math.round(view.progress * 100)}%` }}
/>
</span>
)}
</div>
);
}
@@ -90,3 +90,14 @@
.flight-mini-map .leaflet-tooltip.flight-mini-code::before {
display: none;
}
/* A map kept to the middle of its pass (the phone): the edges still run out,
but the route fills most of it instead of a third. */
.flight-mini-map.flight-mini-map--narrow {
-webkit-mask-image:
linear-gradient(to right, transparent, #000 16%, #000 84%, transparent),
linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
mask-image:
linear-gradient(to right, transparent, #000 16%, #000 84%, transparent),
linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
}