BookingLookup
The form that opens an existing booking: a record locator and a surname, both required, both sent in a request body. It renders no receipt — on a match it hands the reservation to your page, which routes to the confirmation with the reference alone.
A booking made through this demo app answers here. Stage 4 — the confirmation — is where a matched booking lands, and it is also the page that explains what a receipt may and may not do.
Implementation guide
Five decisions for the lookup: why the surname is not optional, why a wrong name is a different answer from an unknown reference, what may not be persisted, and how to keep your own markup.
Mount it, and route on the match
The component owns the form, the validation and the wording of all three answers. Your page owns one thing: where a traveller goes once their booking is in hand. That is the whole of the integration — there is no store to wire and no state to keep.
app/find-booking/page.tsx 'use client';import { useRouter } from 'next/navigation';import { bookingConfirmationHref } from '@sheriph/fk-ui/confirmation';import { BookingLookup } from '@sheriph/fk-ui/retrieval';/*** /find-booking — the page your "manage my booking" link points at.** The component owns the form and the three answers. This page owns the one thing* the component deliberately does not: where a traveller goes once their booking* is in hand.*/export default function FindBookingPage() {const router = useRouter();return (<main className="mx-auto max-w-xl px-4 py-12"><BookingLookuponFound={(booking) => {// Only the reference travels. It is the confirmation's whole contract,// and it is the only one of the two things the traveller typed that a// URL is allowed to carry.router.push(bookingConfirmationHref(booking.booking.bookingReference));}}/></main>);}The reference is not a credential, and the surname is
Travelport needs only the record locator, so an endpoint that asked for one and stopped there would be enough to find a booking. It would not be enough to hand it over: a locator is six characters, it is printed on a boarding pass, it gets read out over the phone, and it is often the only thing written on the printout a stranger can pick up.
The surname is the second thing the caller has to know, and unlike the locator it is not on anything a stranger is likely to be holding. That is why it is a required field and not an optional one — a second factor a caller can skip by leaving the box empty is not a second factor. Matching is deliberately forgiving about how a name was typed (case, spaces, punctuation and accents are ignored) and exact about what it says:
O'Brien,OBRIENando brienare one surname;SMITHandSMYTHare two, and a prefix is not a match. Failing a traveller on their own booking is the expensive mistake; the locator still has to be right.Three answers, and they are different on purpose
A wrong surname is a successful lookup with a negative answer, and the component treats it that way: the field turns red and says the reference is valid and the name is not. Collapsing it into “no booking found” is the tidier security posture and the worse product — it sends someone who typed their own name slightly wrong off to hunt for a reference that was always correct.
A locator nobody holds is the case that is collapsed, deliberately: it answers
404with the same body as a locator belonging to another agency, because a lookup that could tell those apart would be a way of asking which locators are real. That check runs before the surname is ever read.the three answers POST /api/bookings/lookup{ "pnr": "ZXG25P", "surname": "OBrien", "agencyId": "Z26VDX" }/* 1 — the reference was found, and the surname is on it.The reservation, exactly as /bookings/retrieve returns it. */{ "data": { "status": "found","booking": { "booking": { "bookingReference": "ZXG25P", ... },"legs": [ ... ],"passengers": [ { "type": "adult","given": "JOHN","surname": "OBRIEN" } ],"agency": { "name": "Acme Travel", ... } } } }/* 2 — the reference was found, and the surname is not on it.Nothing else comes back: no names, no dates, no price. */{ "data": { "status": "surname-mismatch" } }/* 3 — no such booking in this agency's ledger. Written the same way whether thelocator is unknown or belongs to another agency's site, so the endpointcannot be used to ask which locators are real. */HTTP 404{ "error": "Booking not found" }Nothing is persisted, and the surname least of all
Both values live in component state and travel in a
POSTbody. Neither reaches the URL, the fk-ui store,localStorageorsessionStorage. On a match the reference alone goes into the redirect — that is the confirmation's contract, and a surname is personal data that has no business in a URL somebody can bookmark, share or find in a log.The consequence for your own page is the one to watch: do not add a
?surname=parameter to make a form state survive a refresh, and do not stash the pair in a store to save the second request.It is a form, not a stage — and you can keep your own markup
It does not render the booking. The receipt is
BookingConfirmation's job, and it stays that way: two components that both render a booking is two ways to describe one booking. If you would rather keep your own inputs, the snippet below is the same lookup without the component — the client method and the three answers are the parts that must not drift.Two forms on one page is safe: every input's
idis generated, so the second form's label cannot end up pointing at the first form's field.your own form, against the same endpoint 'use client';import { useRouter } from 'next/navigation';import { bookingConfirmationHref } from '@sheriph/fk-ui/confirmation';import { useFlightKit } from '@sheriph/fk-ui/core';/*** Your own form, against the same endpoint.** Worth reading even if you use the component, because it is the whole of what* the component does — and it is the honest answer to "can I keep my own markup?"* You can. The client method, the normalisation and the three answers are the* parts that must not drift; the two inputs around them are yours.*/export function useLookup() {const client = useFlightKit();const router = useRouter();return async function lookup(reference: string, surname: string) {const result = await client.lookupBooking({// A locator is upper-case in the GDS; a traveller types it however they like.pnr: reference.trim().toUpperCase(),surname,agencyId: client.agencyId,});if (result.status === 'surname-mismatch') {// The reference is valid. Say so, and ask about the spelling — do not send// this traveller off to hunt for a different reference.return { field: 'surname' as const };}router.push(bookingConfirmationHref(result.booking.booking.bookingReference));return { field: null };};}
BookingLookup — props
- onFound
- (booking: RetrievedBooking) => void
Called with the reservation when the reference and the surname agree. Route from here — bookingConfirmationHref(booking.booking.bookingReference) is the whole of the usual case. The component does not navigate on your behalf, so it works under your URLs and inside a modal.
- title
- string=
'Find your booking'The visible heading, and the name the form is announced by. Pass an empty string for a bare form to drop inside your own card.
- description
- string=
'Enter your booking reference and the surname of any traveller on it.'One line under the heading. Worth keeping: it tells the traveller whose surname to type, which is the one thing about a booking they can get wrong without noticing.
- className
- string
Merged onto the form — the element that sits in your layout.
Code samples
The page whole, the endpoint's three answers, and the same lookup without the component.
'use client';import { useRouter } from 'next/navigation';import { bookingConfirmationHref } from '@sheriph/fk-ui/confirmation';import { BookingLookup } from '@sheriph/fk-ui/retrieval';/*** /find-booking — the page your "manage my booking" link points at.** The component owns the form and the three answers. This page owns the one thing* the component deliberately does not: where a traveller goes once their booking* is in hand.*/export default function FindBookingPage() {const router = useRouter();return (<main className="mx-auto max-w-xl px-4 py-12"><BookingLookuponFound={(booking) => {// Only the reference travels. It is the confirmation's whole contract,// and it is the only one of the two things the traveller typed that a// URL is allowed to carry.router.push(bookingConfirmationHref(booking.booking.bookingReference));}}/></main>);}
POST /api/bookings/lookup{ "pnr": "ZXG25P", "surname": "OBrien", "agencyId": "Z26VDX" }/* 1 — the reference was found, and the surname is on it.The reservation, exactly as /bookings/retrieve returns it. */{ "data": { "status": "found","booking": { "booking": { "bookingReference": "ZXG25P", ... },"legs": [ ... ],"passengers": [ { "type": "adult","given": "JOHN","surname": "OBRIEN" } ],"agency": { "name": "Acme Travel", ... } } } }/* 2 — the reference was found, and the surname is not on it.Nothing else comes back: no names, no dates, no price. */{ "data": { "status": "surname-mismatch" } }/* 3 — no such booking in this agency's ledger. Written the same way whether thelocator is unknown or belongs to another agency's site, so the endpointcannot be used to ask which locators are real. */HTTP 404{ "error": "Booking not found" }
'use client';import { useRouter } from 'next/navigation';import { bookingConfirmationHref } from '@sheriph/fk-ui/confirmation';import { useFlightKit } from '@sheriph/fk-ui/core';/*** Your own form, against the same endpoint.** Worth reading even if you use the component, because it is the whole of what* the component does — and it is the honest answer to "can I keep my own markup?"* You can. The client method, the normalisation and the three answers are the* parts that must not drift; the two inputs around them are yours.*/export function useLookup() {const client = useFlightKit();const router = useRouter();return async function lookup(reference: string, surname: string) {const result = await client.lookupBooking({// A locator is upper-case in the GDS; a traveller types it however they like.pnr: reference.trim().toUpperCase(),surname,agencyId: client.agencyId,});if (result.status === 'surname-mismatch') {// The reference is valid. Say so, and ask about the spelling — do not send// this traveller off to hunt for a different reference.return { field: 'surname' as const };}router.push(bookingConfirmationHref(result.booking.booking.bookingReference));return { field: null };};}