npm i
npm start - The application will be available at http://localhost:3000
npm run build - The built version of the app will be located in the ./build directory.
This React application is designed to display an airplane seat map using the JetsSeatMap library. It receives data via
messages from an external source (e.g., a parent window), dynamically updates the application's state, and handles data
validation errors.
-
App.js
Contains the core application logic and integration with theJetsSeatMapcomponent. -
src/common/message-service.js
Implements theMessageServiceclass for handling incoming messages and updating data. -
src/common/constants.js
Contains constants for message types used in the application (not shown in the example but assumed to be present). -
./example-of-parent-website
Provides a static example page demonstrating how to use this application within an iframe.
-
State
data(object): Stores processed data from incoming messages.isError(boolean): Indicates whether an error occurred during data processing.
-
Methods
onDataUpdated(newData, errorStatus): Updates the state with new data and the error status provided by theMessageService.
-
Effects
- Initializes an instance of
MessageServiceto listen for incoming messages. - Cleans up message listeners when the component is unmounted.
- Initializes an instance of
-
Rendering Logic
- Displays an error message if
isErroristrue.
- Displays an error message if
The MessageService class is responsible for managing the flow of data from incoming messages to the React application.
-
cleanAndParse(value)- Cleans and converts raw data into a JSON object.
- Fixes invalid or non-standard formatting.
- Returns
nullif the processing fails.
-
processIncomingMessage(event)- Processes only messages with the type
MESSAGE_TYPES.SEAT_MAP. - Iterates over each data field, cleans, and parses them.
- Passes the updated data to the application via
onDataUpdated.
- Processes only messages with the type
-
startListening()- Adds a
messageevent listener to thewindowobject.
- Adds a
-
stopListening()- Removes the
messageevent listener.
- Removes the
The data is stored in the data state, which contains an object with all the parsed information. An example structure:
{
flight: {
id: '111',
airlineCode: 'EK',
flightNo: '50',
// ...
},
availability: [],
passengers: [],
config: {
width: 400,
lang: 'EN',
// ...
}
}npm run build
docker build -t jets-seatmap-react-proxy-app:20250703 --no-cache .
docker tag jets-seatmap-react-proxy-app:20250703 docker-registry.kwiket.com/jets-seatmap-react-proxy-app:20250703
docker tag jets-seatmap-react-proxy-app:20250703 docker-registry.kwiket.com/jets-seatmap-react-proxy-app:latest
docker push docker-registry.kwiket.com/jets-seatmap-react-proxy-app:20250703
docker push docker-registry.kwiket.com/jets-seatmap-react-proxy-app:latest
curl -X POST https://cluster.kwiket.com/api/webhooks/fe936ec0-aa6a-4da1-8f6c-2766f20cbdc0