Seat Booking Grid

MediumStateComponentsReact30 mins

by Pratik Rai

Read the full write-up

Build the seat picker from a cinema booking page.

Seats are laid out in rows at different prices. Some are already sold. A customer picks up to four and sees a running total.

Requirements

  1. Render the rows from ROWS. An x in the layout is a sold seat and cannot be picked.

  2. Clicking an available seat selects it; clicking it again deselects it.

  3. At most MAX_SEATS can be selected. Attempting more shows a message and changes nothing.

  4. Deselecting always works, even when at the limit.

  5. Show which seats are picked and the total price, using the price of each seat’s row.

  6. Seats carry aria-pressed and a label that includes the seat, its price and whether it is sold.

Notes

  • Prices differ per row, so the total is not just a count times one number.

  • List the picked seats in seat order rather than the order they were clicked.

Hints

Loading editor…