Examples
Flight route picker
Built with the mantine-combobox skill
Build the route part of a flight search: where the trip starts and where it goes.
Data:
- about 40 hard-coded airports (IATA code, airport name, city, country) including cities with several airports: London (LHR, LGW, STN, LTN, LCY), New York (JFK, LGA, EWR), Paris (CDG, ORY), Tokyo (HND, NRT), Milan (MXP, LIN, BGY) and São Paulo (GRU, CGH)
- a short list of popular destinations
Fields:
- "From" and "To", side by side, with a swap button between them; swap is disabled when both are empty
- search matches the IATA code, city, airport name and country, ignoring case and accents ("sao" finds São Paulo); an exact code match comes first
- a city with several airports appears as a city option ("London, United Kingdom · All airports") followed by its airports; picking the city selects all of its airports
- the selected value shows the code and the name ("LHR · London Heathrow", "London · All airports")
- focusing an empty field shows the recent picks (last 5, from both fields) and the popular destinations
- after picking "From", focus moves to "To"
Rules:
- the same place cannot be on both sides: an airport or city selected on the other side is shown disabled with the reason ("Selected as departure"), and so are a city and its airports
- swapping keeps both values
- "Search flights" requires both fields; on submit show a short notification with the route and display the search as JSON (from and to as arrays of codes) under the fields
Write tests for the component.