Seat Map Structure
TheseatMap is a two-dimensional array where each nested array represents a row in the bus, and each item within these rows represents a specific seat or space.
Each seat or space has:
- type: Defines the seat’s availability or function (
selected,available,reserved,empty,closed). - index: A unique identifier based on the seat’s row and column position in the bus.
- seatNumber: The actual seat number for the bus, where
0typically indicates a non-seating space.
Seat Types
The seat map endpoint supports several types of seats, which are detailed below:-
selected: The seat has been preselected by the system and appears in the
selectedSeatsarray. Users can see it as preselected, but they can select another seat if desired. - available: The seat is available for selection. Users can choose this seat when booking.
- reserved: The seat is temporarily reserved for another customer, awaiting confirmation. It is currently unselectable by other users until it becomes available again.
- empty: Represents a non-seating area, such as the aisle or walkway within the bus.
- closed: The seat is unavailable for selection, either due to being permanently closed or unusable for this journey.
Example Seat Map Data
- Row 1 has seats that are
closedand anemptyspace in the middle. - Row 2 follows a similar structure.
- Row 3 has a
selectedseat at index"3,5"(seat number 12), indicating a preselected seat.
Figma Prototype
View & Download Assets on figma
To export the below assets as SVG files, you can use the figma link to view and download the assets.
Example React Implementation
The
seatMap component creates a seating layout using an SVG for the seat map design and a grid of seat elements rendered based on seat type (e.g., available, selected, reserved). This interactive layout uses buttons to manage seat selection, while styling is handled using Tailwind CSS for layout, padding, and border configurations. The Wheel component is positioned at the top, adding another layer of detail to the seating design.
This Wheel component is an SVG graphic representation of a wheel symbol, complementing the layout and aesthetics of the seat map.
The SeatModel component is responsible for rendering individual seats with specific visual indicators depending on their status. This status determines how each seat appears (e.g., different colors for available, reserved, and selected seats) and provides interactive functionality.
Final Result
Visual Layout Example
Below is an example of how the bus layout might look based on the seat types:| Row | Seat 1 (closed) | Seat 2 (closed) | Space (empty) | Seat 3 (closed) | Seat 4 (closed) |
|---|---|---|---|---|---|
| 1 | Closed | Closed | Empty | Closed | Closed |
| 2 | Closed | Closed | Empty | Closed | Closed |
| 3 | Closed | Closed | Empty | Closed | Selected |
| 4 | Closed | Closed | Empty | Available | Available |