@go-mmt/ancillaries
v0.1.20
Published
Seats, Meals and Baggage widget
Downloads
7
Readme
ancillaries
A ReactJS package for flights ancillaries(seats, meals and baggages).
Quick Start
Installation:
npm i ancillaries
Usage
import Ancillaries from 'ancillaries';
import React from "react";
const [ancillaryUserSelectedData, setAncillaryUserSelectedData] = useState({});
<Ancillaries
paxCount={3}
currency="INR"
seatBgColor="#7950f2"
ancillaryBgColor="#4dabf7"
headerBgColor="#a9e34b"
widgetWidth="800px"
selectionCallBackFunction={setAncillaryUserSelectedData}
preSelectedAddons={preSelectedAddons}
headerFontColor="#7950f2"
headerSelectorColor="#7950f2"
buttonFontColor="#7950f2"
headers={h}
hostUrl={hostUrl}
ref={ancillaryRef}
/>
Options
| Option | Description | | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | paxCount | Number of passengers. (default = 1) | | currency | Addon Price in ₹ (default = "INR") | | widgetWidth | Width of the widget, Should be in between 700px to 900px( default = '880px') | | ancillaryBgColor | Widget Background color. (default = "#f4f4f4") | | seatBgColor | Seat section background color (default = "#add6ef") | | headerBgColor | Header background color (default = "#fff") | | headerFontColor | Font color in header (default = "#000000") | | headerSelectorColor | selector color in header (default = "#0091FF") | | buttonFontColor | Font color of counter button in meals and baggage section (default = "#0091FF") | | Headers | Headers to be passed to the Server(from affiliates side) for getting the ancillary data | | hostUrl | Server URL(from affiliates side). Package will make a fetch call to this server. Affiliates server has to fetch ancillary data from flights backend and return it to package. | | selectionCallBackFunction | When user selects(add/remove) any addon, this callback function will be executed with the selected addon details. | | ref | Ancillary ref. | | preSelectedAddons | To preselect Addons to user. When user selects Addons and proceed to next page and when he comes back to current page, to retain previously selected addons, this object needs to be passed. |
Functions exposed from ref
- goToNextTab
// How to use goToNextTab
ancillaryRef = useRef(null);
<Ancillaries
paxCount={3}
currency="INR"
seatBgColor="#7950f2"
ancillaryBgColor="#4dabf7"
headerBgColor="#a9e34b"
widgetWidth="800px"
selectionCallBackFunction={setAncillaryUserSelectedData}
preSelectedAddons={preSelectedAddons}
headerFontColor="#7950f2"
headerSelectorColor="#7950f2"
buttonFontColor="#7950f2"
headers={h}
hostUrl={hostUrl}
ref={ancillaryRef}
/>
ancillaryRef.current.goToNextTab((isLastTab) => {
alert('go to payment')
})
selectionCallBackFunction
When user selects(add/remove) any addon, selectionCallBackFunction will be invoked with userSelectedData.
Sample of userSelectedData
// SEAT_ITEM_1, MEAL_ITEM_1, BAGGAGE_ITEM_1 are objects and their format is defined below
{
"SEATS": [ SEAT_ITEM_1, SEAT_ITEM_2, ...],
"MEALS": [ MEAL_ITEM_1, MEAL_ITEM_2, ...],
"BAGGAGE": [BAGGAGE_ITEM_1, BAGGAGE_ITEM_2, ...]
}
Sample of SEAT_ITEM:-
{
"value": "1D", // Selected Seat code
"sellPrice": 1500, // Price of the selected seat
"flightLookupId": "DEL$HYD$2023-03-03 01:55$6E-2461" // flightLookup key for the journey
}
Sample of MEAL_ITEM:-
{
"ssrcode": "CCWT", // Unique code of selected meal
"ssrType": "VEG", // Type of meal.(veg or non veg)
"sellPrice": 200, // Price of the selected Meal
"preSelectedCount": 1,
"flightLookupId": "HYD$BLR$2023-03-03 06:50$6E-413" // flightLookup key for the journey
}
Sample of BAGGAGE_ITEM:-
{
"value": 5, // value of selected Baggage weight
"unit": "KG", // unit of selected Baggage weight
"sellPrice": 2250, // Price of the selected Baggage
"ssrcode": "XBPA", // Unique code of selected baggage
"preSelectedCount": 1, // count of selected baggage
"flightLookupId": "HYD$BLR$2023-03-03 06:50$6E-413" // flightLookup key for the journey
}
preSelectedAddons
It's value should be same as userSelectedData.
// SEAT_ITEM_1, MEAL_ITEM_1, BAGGAGE_ITEM_1 are objects and their format is defined above.
{
"SEATS": [ SEAT_ITEM_1, SEAT_ITEM_2, ...],
"MEALS": [ MEAL_ITEM_1, MEAL_ITEM_2, ...],
"BAGGAGE": [BAGGAGE_ITEM_1, BAGGAGE_ITEM_2, ...]
}
Examples
FAQs
1. How to get addons data on every user action(addition or removal of addons)?
selectionCallBackFunction
callback(prop to be passed to ancillaires component) will be called from ancillaries, on every user action with the updated addons data(in the format of userSelectedData).
2. How to retain previously selected addons, when user navigates to next page(like payment page) and coming back to addons page?
Ancillaries component will not maintain any user selected addons states when user navigates to different page. So, client has to pass previously selected addons data(which will be passed to clients in selectionCallBackFunction
callback on every user action) in preSelectedAddons
prop(in the format of userSelectedData) to ancillaries component, based on which previously selected addons will be rendered.
3. How to set the maximum number of addons, users can select for a particular journey?
paxCount
prop has to be passed with a number based on which the maximum number of addons, users can select for a particular journey will be configured at ancillaries side.
4. How to change the width of ancillaries component?
widgetWidth
prop has to be passed with the valid width values(in pixels). Max width is set as 900px and Min width is set as 700 px. So, widths given below 700px and greater than 900px will not have any effect in the component.
5. How to set the background color of ancillaries component?
ancillaryBgColor
prop has to be passed with valid background color.
6. How to set the background color of ancillaries component header?
headerBgColor
prop has to be passed with valid background color.
7. How to set the background color of seats section?
seatBgColor
prop has to passed with valid background color.