@duffel/components 2.7.19 → 3.0.0-canary

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/.circleci/config.yml +67 -0
  2. package/.eslintrc.js +34 -0
  3. package/.github/renovate.json +16 -0
  4. package/.github/workflows/autoapprove.yml +18 -0
  5. package/.github/workflows/release.yml +86 -0
  6. package/.husky/post-commit +4 -0
  7. package/.husky/pre-commit +4 -0
  8. package/.nvmrc +1 -0
  9. package/.prettierignore +2 -0
  10. package/.storybook/Storyshots.test.js +3 -0
  11. package/.storybook/__snapshots__/Storyshots.test.js.snap +48133 -0
  12. package/.storybook/main.ts +33 -0
  13. package/.storybook/preview.tsx +28 -0
  14. package/.tool-versions +1 -0
  15. package/README.md +129 -16
  16. package/__mocks__/styleMock.js +6 -0
  17. package/babel.config.js +20 -0
  18. package/commitlint.config.js +4 -0
  19. package/config/esbuild.base.config.js +14 -0
  20. package/config/esbuild.cdn.config.js +50 -0
  21. package/config/esbuild.dev.config.js +45 -0
  22. package/config/esbuild.react.config.js +42 -0
  23. package/jest.config.ts +14 -0
  24. package/package.json +123 -192
  25. package/react-dist/components/AnimatedLoaderEllipsis.d.ts +2 -0
  26. package/react-dist/components/Button.d.ts +23 -0
  27. package/react-dist/components/Card.d.ts +14 -0
  28. package/react-dist/components/Counter.d.ts +10 -0
  29. package/react-dist/components/DuffelAncillaries.d.ts +3 -0
  30. package/react-dist/components/DuffelAncillariesCustomElement.d.ts +13 -0
  31. package/react-dist/components/ErrorBoundary.d.ts +13 -0
  32. package/react-dist/components/FetchOfferErrorState.d.ts +5 -0
  33. package/react-dist/components/Icon.d.ts +44 -0
  34. package/react-dist/components/IconButton.d.ts +16 -0
  35. package/react-dist/components/Modal.d.ts +11 -0
  36. package/react-dist/components/NonIdealState.d.ts +4 -0
  37. package/react-dist/components/Stamp.d.ts +7 -0
  38. package/react-dist/components/Tabs.d.ts +16 -0
  39. package/react-dist/components/bags/BaggageSelectionCard.d.ts +11 -0
  40. package/react-dist/components/bags/BaggageSelectionController.d.ts +13 -0
  41. package/react-dist/components/bags/BaggageSelectionModal.d.ts +11 -0
  42. package/react-dist/components/bags/BaggageSelectionModalBody.d.ts +11 -0
  43. package/react-dist/components/bags/BaggageSelectionModalBodyPassenger.d.ts +13 -0
  44. package/react-dist/components/bags/BaggageSelectionModalFooter.d.ts +14 -0
  45. package/react-dist/components/bags/BaggageSelectionModalHeader.d.ts +9 -0
  46. package/react-dist/components/bags/IncludedBaggageBanner.d.ts +7 -0
  47. package/react-dist/components/cancel_for_any_reason/CfarSelectionCard.d.ts +10 -0
  48. package/react-dist/components/cancel_for_any_reason/CfarSelectionModal.d.ts +11 -0
  49. package/react-dist/components/cancel_for_any_reason/CfarSelectionModalBody.d.ts +7 -0
  50. package/react-dist/components/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +4 -0
  51. package/react-dist/components/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +11 -0
  52. package/react-dist/components/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +2 -0
  53. package/react-dist/components/seats/Amenity.d.ts +6 -0
  54. package/react-dist/components/seats/DeckSelect.d.ts +15 -0
  55. package/react-dist/components/seats/Element.d.ts +15 -0
  56. package/react-dist/components/seats/EmptyElement.d.ts +2 -0
  57. package/react-dist/components/seats/ExitElement.d.ts +6 -0
  58. package/react-dist/components/seats/Legend.d.ts +12 -0
  59. package/react-dist/components/seats/Row.d.ts +13 -0
  60. package/react-dist/components/seats/RowSection.d.ts +17 -0
  61. package/react-dist/components/seats/SeatElement.d.ts +13 -0
  62. package/react-dist/components/seats/SeatInfo.d.ts +7 -0
  63. package/react-dist/components/seats/SeatMap.d.ts +12 -0
  64. package/react-dist/components/seats/SeatMapUnavailable.d.ts +2 -0
  65. package/react-dist/components/seats/SeatSelectionCard.d.ts +13 -0
  66. package/react-dist/components/seats/SeatSelectionModal.d.ts +13 -0
  67. package/react-dist/components/seats/SeatSelectionModalBody.d.ts +4 -0
  68. package/react-dist/components/seats/SeatSelectionModalFooter.d.ts +16 -0
  69. package/react-dist/components/seats/SeatSelectionModalHeader.d.ts +10 -0
  70. package/react-dist/components/seats/SeatUnavailable.d.ts +5 -0
  71. package/react-dist/index.d.ts +8 -0
  72. package/react-dist/index.js +36 -0
  73. package/react-dist/index.js.map +7 -0
  74. package/react-dist/lib/captureErrorInSentry.d.ts +1 -0
  75. package/react-dist/lib/compileCreateOrderPayload.d.ts +14 -0
  76. package/react-dist/lib/createPriceFormatters.d.ts +12 -0
  77. package/react-dist/lib/fetchFromDuffelAPI.d.ts +1 -0
  78. package/react-dist/lib/fetchFromFixtures.d.ts +4 -0
  79. package/react-dist/lib/formatAvailableServices.d.ts +12 -0
  80. package/react-dist/lib/formatDate.d.ts +2 -0
  81. package/react-dist/lib/formatSeatMaps.d.ts +4 -0
  82. package/react-dist/lib/getBaggageServiceDescription.d.ts +2 -0
  83. package/react-dist/lib/getCabinsForSegmentAndDeck.d.ts +2 -0
  84. package/react-dist/lib/getCurrencyForSeatMaps.d.ts +10 -0
  85. package/react-dist/lib/getCurrencyForServices.d.ts +11 -0
  86. package/react-dist/lib/getFirstSeatElementMatchingCriteria.d.ts +3 -0
  87. package/react-dist/lib/getPassengerBySegmentList.d.ts +6 -0
  88. package/react-dist/lib/getPassengerInitials.d.ts +1 -0
  89. package/react-dist/lib/getPassengerMapById.d.ts +3 -0
  90. package/react-dist/lib/getPassengerName.d.ts +3 -0
  91. package/react-dist/lib/getRowNumber.d.ts +2 -0
  92. package/react-dist/lib/getSegmentList.d.ts +2 -0
  93. package/react-dist/lib/getServicePriceMapById.d.ts +3 -0
  94. package/react-dist/lib/getSymbols.d.ts +2 -0
  95. package/react-dist/lib/getTotalAmountForServices.d.ts +6 -0
  96. package/react-dist/lib/getTotalQuantity.d.ts +2 -0
  97. package/react-dist/lib/hasService.d.ts +2 -0
  98. package/react-dist/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +3 -0
  99. package/react-dist/lib/hasWings.d.ts +2 -0
  100. package/react-dist/lib/isBaggageService.d.ts +2 -0
  101. package/react-dist/lib/isCancelForAnyReasonService.d.ts +2 -0
  102. package/react-dist/lib/isFixtureOfferId.d.ts +2 -0
  103. package/react-dist/lib/isPayloadComplete.d.ts +2 -0
  104. package/react-dist/lib/isSeatElement.d.ts +2 -0
  105. package/react-dist/lib/logging.d.ts +53 -0
  106. package/react-dist/lib/moneyStringFormatter.d.ts +8 -0
  107. package/react-dist/lib/offerIsExpired.d.ts +2 -0
  108. package/react-dist/lib/retrieveOffer.d.ts +2 -0
  109. package/react-dist/lib/retrieveOfferFromDuffelAPI.d.ts +1 -0
  110. package/react-dist/lib/retrieveSeatMaps.d.ts +2 -0
  111. package/react-dist/lib/retrieveSeatMapsFromDuffelAPI.d.ts +1 -0
  112. package/react-dist/lib/setBodyScrollability.d.ts +1 -0
  113. package/react-dist/lib/validateProps.d.ts +7 -0
  114. package/react-dist/lib/withPlural.d.ts +1 -0
  115. package/react-dist/types/Aircraft.d.ts +14 -0
  116. package/react-dist/types/Airline.d.ts +14 -0
  117. package/react-dist/types/Airport.d.ts +44 -0
  118. package/react-dist/types/City.d.ts +18 -0
  119. package/react-dist/types/CreateOrderPayload.d.ts +72 -0
  120. package/react-dist/types/CurrencyConversion.d.ts +10 -0
  121. package/react-dist/types/DuffelAncillariesProps.d.ts +70 -0
  122. package/react-dist/types/Offer.d.ts +711 -0
  123. package/react-dist/types/Order.d.ts +8 -0
  124. package/react-dist/types/Place.d.ts +8 -0
  125. package/react-dist/types/SeatMap.d.ts +190 -0
  126. package/react-dist/types/index.d.ts +11 -0
  127. package/scripts/generate-fixture.ts +195 -0
  128. package/scripts/upload-to-cdn.sh +39 -0
  129. package/scripts.tsconfig.json +11 -0
  130. package/src/components/AnimatedLoaderEllipsis.tsx +5 -0
  131. package/src/components/Button.tsx +62 -0
  132. package/src/components/Card.tsx +126 -0
  133. package/src/components/Counter.tsx +40 -0
  134. package/src/components/DuffelAncillaries.tsx +346 -0
  135. package/src/components/DuffelAncillariesCustomElement.tsx +124 -0
  136. package/src/components/ErrorBoundary.tsx +54 -0
  137. package/src/components/FetchOfferErrorState.tsx +35 -0
  138. package/src/components/Icon.tsx +151 -0
  139. package/src/components/IconButton.tsx +42 -0
  140. package/src/components/Modal.tsx +36 -0
  141. package/src/components/NonIdealState.tsx +28 -0
  142. package/src/components/Stamp.tsx +29 -0
  143. package/src/components/Tabs.tsx +36 -0
  144. package/src/components/bags/BaggageSelectionCard.tsx +96 -0
  145. package/src/components/bags/BaggageSelectionController.tsx +88 -0
  146. package/src/components/bags/BaggageSelectionModal.tsx +81 -0
  147. package/src/components/bags/BaggageSelectionModalBody.tsx +60 -0
  148. package/src/components/bags/BaggageSelectionModalBodyPassenger.tsx +122 -0
  149. package/src/components/bags/BaggageSelectionModalFooter.tsx +81 -0
  150. package/src/components/bags/BaggageSelectionModalHeader.tsx +76 -0
  151. package/src/components/bags/IncludedBaggageBanner.tsx +51 -0
  152. package/src/components/cancel_for_any_reason/CfarSelectionCard.tsx +90 -0
  153. package/src/components/cancel_for_any_reason/CfarSelectionModal.tsx +63 -0
  154. package/src/components/cancel_for_any_reason/CfarSelectionModalBody.tsx +56 -0
  155. package/src/components/cancel_for_any_reason/CfarSelectionModalBodyListItem.tsx +11 -0
  156. package/src/components/cancel_for_any_reason/CfarSelectionModalFooter.tsx +74 -0
  157. package/src/components/cancel_for_any_reason/CfarSelectionModalHeader.tsx +9 -0
  158. package/src/components/seats/Amenity.tsx +21 -0
  159. package/src/components/seats/DeckSelect.tsx +27 -0
  160. package/src/components/seats/Element.tsx +52 -0
  161. package/src/components/seats/EmptyElement.tsx +5 -0
  162. package/src/components/seats/ExitElement.tsx +17 -0
  163. package/src/components/seats/Legend.tsx +60 -0
  164. package/src/components/seats/Row.tsx +47 -0
  165. package/src/components/seats/RowSection.tsx +75 -0
  166. package/src/components/seats/SeatElement.tsx +120 -0
  167. package/src/components/seats/SeatInfo.tsx +32 -0
  168. package/src/components/seats/SeatMap.tsx +81 -0
  169. package/src/components/seats/SeatMapUnavailable.tsx +21 -0
  170. package/src/components/seats/SeatSelectionCard.tsx +103 -0
  171. package/src/components/seats/SeatSelectionModal.tsx +142 -0
  172. package/src/components/seats/SeatSelectionModalBody.tsx +13 -0
  173. package/src/components/seats/SeatSelectionModalFooter.tsx +82 -0
  174. package/src/components/seats/SeatSelectionModalHeader.tsx +87 -0
  175. package/src/components/seats/SeatUnavailable.tsx +14 -0
  176. package/src/examples/client-side/index.html +57 -0
  177. package/src/examples/full-stack/index.html +48 -0
  178. package/src/examples/full-stack/server.mjs +157 -0
  179. package/src/examples/just-typescript/README.md +37 -0
  180. package/src/examples/just-typescript/package.json +16 -0
  181. package/src/examples/just-typescript/src/index.html +23 -0
  182. package/src/examples/just-typescript/src/index.ts +35 -0
  183. package/src/examples/just-typescript/yarn.lock +154 -0
  184. package/src/examples/react-app/README.md +37 -0
  185. package/src/examples/react-app/package.json +20 -0
  186. package/src/examples/react-app/src/index.html +19 -0
  187. package/src/examples/react-app/src/index.tsx +43 -0
  188. package/src/examples/react-app/yarn.lock +219 -0
  189. package/src/fixtures/offers/off_0000AUde3KwTztSRK1cznH.json +497 -0
  190. package/src/fixtures/offers/off_0000AVx4lUFFKW8PsPeQeQ.json +307 -0
  191. package/src/fixtures/offers/off_1.json +497 -0
  192. package/src/fixtures/passengers/mock_passengers.ts +26 -0
  193. package/src/fixtures/seat-maps/off_0000AUde3KwTztSRK1cznH.json +6852 -0
  194. package/src/fixtures/seat-maps/off_0000AVx4lUFFKW8PsPeQeQ.json +1 -0
  195. package/src/fixtures/seat-maps/off_1.json +6852 -0
  196. package/src/index.ts +8 -0
  197. package/src/lib/captureErrorInSentry.ts +60 -0
  198. package/src/lib/compileCreateOrderPayload.ts +63 -0
  199. package/src/lib/createPriceFormatters.ts +73 -0
  200. package/src/lib/fetchFromDuffelAPI.ts +24 -0
  201. package/src/lib/fetchFromFixtures.ts +18 -0
  202. package/src/lib/formatAvailableServices.ts +91 -0
  203. package/src/lib/formatDate.ts +21 -0
  204. package/src/lib/formatSeatMaps.ts +81 -0
  205. package/src/lib/getBaggageServiceDescription.ts +44 -0
  206. package/src/lib/getCabinsForSegmentAndDeck.ts +4 -0
  207. package/src/lib/getCurrencyForSeatMaps.ts +22 -0
  208. package/src/lib/getCurrencyForServices.ts +24 -0
  209. package/src/lib/getFirstSeatElementMatchingCriteria.ts +22 -0
  210. package/src/lib/getPassengerBySegmentList.ts +10 -0
  211. package/src/lib/getPassengerInitials.ts +6 -0
  212. package/src/lib/getPassengerMapById.ts +17 -0
  213. package/src/lib/getPassengerName.ts +37 -0
  214. package/src/lib/getRowNumber.ts +16 -0
  215. package/src/lib/getSegmentList.ts +7 -0
  216. package/src/lib/getServicePriceMapById.ts +20 -0
  217. package/src/lib/getSymbols.ts +22 -0
  218. package/src/lib/getTotalAmountForServices.ts +72 -0
  219. package/src/lib/getTotalQuantity.ts +5 -0
  220. package/src/lib/hasService.ts +24 -0
  221. package/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.ts +35 -0
  222. package/src/lib/hasWings.ts +8 -0
  223. package/src/lib/isBaggageService.ts +8 -0
  224. package/src/lib/isCancelForAnyReasonService.ts +9 -0
  225. package/src/lib/isFixtureOfferId.ts +4 -0
  226. package/src/lib/isPayloadComplete.ts +11 -0
  227. package/src/lib/isSeatElement.ts +10 -0
  228. package/src/lib/logging.ts +100 -0
  229. package/src/lib/moneyStringFormatter.ts +34 -0
  230. package/src/lib/offerIsExpired.ts +5 -0
  231. package/src/lib/retrieveOffer.ts +49 -0
  232. package/src/lib/retrieveOfferFromDuffelAPI.ts +13 -0
  233. package/src/lib/retrieveSeatMaps.ts +50 -0
  234. package/src/lib/retrieveSeatMapsFromDuffelAPI.ts +13 -0
  235. package/src/lib/setBodyScrollability.ts +7 -0
  236. package/src/lib/validateProps.ts +37 -0
  237. package/src/lib/withPlural.ts +8 -0
  238. package/src/stories/BaggageSelectionModalHeader.stories.tsx +21 -0
  239. package/src/stories/Button.stories.tsx +60 -0
  240. package/src/stories/DuffelAncillaries.stories.tsx +126 -0
  241. package/src/stories/Icon.stories.tsx +34 -0
  242. package/src/stories/IconButton.stories.tsx +25 -0
  243. package/src/styles/colors.css +22 -0
  244. package/src/styles/components/Amenity.css +23 -0
  245. package/src/styles/components/BaggageDisplay.css +25 -0
  246. package/src/styles/components/Button.css +161 -0
  247. package/src/styles/components/Card.css +52 -0
  248. package/src/styles/components/CfarSelectionModal.css +34 -0
  249. package/src/styles/components/Counter.css +18 -0
  250. package/src/styles/components/IconButton.css +63 -0
  251. package/src/styles/components/Legend.css +58 -0
  252. package/src/styles/components/Loader.css +37 -0
  253. package/src/styles/components/LoadingState.css +81 -0
  254. package/src/styles/components/Modal.css +83 -0
  255. package/src/styles/components/PassengerSelect.css +93 -0
  256. package/src/styles/components/PassengersLayout.css +90 -0
  257. package/src/styles/components/Row.css +70 -0
  258. package/src/styles/components/Seat.css +57 -0
  259. package/src/styles/components/SeatInfo.css +61 -0
  260. package/src/styles/components/SeatMap.css +24 -0
  261. package/src/styles/components/SeatSelect.css +92 -0
  262. package/src/styles/components/Segment.css +17 -0
  263. package/src/styles/components/SelectionSegment.css +10 -0
  264. package/src/styles/components/Summary.css +70 -0
  265. package/src/styles/components/Tabs.css +49 -0
  266. package/src/styles/flex.css +5 -0
  267. package/src/styles/font-families.css +47 -0
  268. package/src/styles/global.css +50 -0
  269. package/src/styles/margin.css +3 -0
  270. package/src/styles/spacing.css +18 -0
  271. package/src/styles/transitions.css +3 -0
  272. package/src/styles/typography.css +13 -0
  273. package/src/tests/components/DuffelAncillaries.test.tsx +342 -0
  274. package/src/tests/lib/createPriceFormatters.test.tsx +152 -0
  275. package/src/tests/lib/formatAvailableServices.test.tsx +79 -0
  276. package/src/tests/lib/formatSeatMaps.test.tsx +49 -0
  277. package/src/tests/lib/getCurrencyForServices.test.tsx +44 -0
  278. package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +86 -0
  279. package/src/tests/lib/logging.test.tsx +32 -0
  280. package/src/tests/lib/moneyStringFormatter.test.tsx +12 -0
  281. package/src/tests/lib/validateProps.test.tsx +57 -0
  282. package/src/types/Aircraft.ts +16 -0
  283. package/src/types/Airline.ts +16 -0
  284. package/src/types/Airport.ts +54 -0
  285. package/src/types/City.ts +21 -0
  286. package/src/types/CreateOrderPayload.ts +99 -0
  287. package/src/types/CurrencyConversion.ts +10 -0
  288. package/src/types/DuffelAncillariesProps.ts +108 -0
  289. package/src/types/Offer.ts +851 -0
  290. package/src/types/Order.ts +6 -0
  291. package/src/types/Place.ts +6 -0
  292. package/src/types/SeatMap.ts +231 -0
  293. package/src/types/index.ts +11 -0
  294. package/tsconfig.json +52 -0
  295. package/LICENSE +0 -21
  296. package/dist/AdditionalBaggage.esm.js +0 -1
  297. package/dist/AdditionalBaggage.js +0 -1
  298. package/dist/AdditionalBaggage.min.css +0 -408
  299. package/dist/AdditionalBaggage.umd.min.js +0 -2
  300. package/dist/AdditionalBaggage.umd.min.js.LICENSE.txt +0 -60
  301. package/dist/AdditionalBaggageSelection.esm.js +0 -1
  302. package/dist/AdditionalBaggageSelection.js +0 -1
  303. package/dist/AdditionalBaggageSelection.min.css +0 -744
  304. package/dist/AdditionalBaggageSelection.umd.min.js +0 -2
  305. package/dist/AdditionalBaggageSelection.umd.min.js.LICENSE.txt +0 -93
  306. package/dist/CardPayment.esm.js +0 -2
  307. package/dist/CardPayment.esm.js.LICENSE.txt +0 -6
  308. package/dist/CardPayment.js +0 -2
  309. package/dist/CardPayment.js.LICENSE.txt +0 -6
  310. package/dist/CardPayment.min.css +0 -233
  311. package/dist/CardPayment.umd.min.js +0 -2
  312. package/dist/CardPayment.umd.min.js.LICENSE.txt +0 -61
  313. package/dist/SeatSelection.esm.js +0 -1
  314. package/dist/SeatSelection.js +0 -1
  315. package/dist/SeatSelection.min.css +0 -1127
  316. package/dist/SeatSelection.umd.min.js +0 -2
  317. package/dist/SeatSelection.umd.min.js.LICENSE.txt +0 -60
  318. package/dist/duffel-components.d.ts +0 -1614
  319. package/dist/duffel-components.esm.js +0 -2
  320. package/dist/duffel-components.esm.js.LICENSE.txt +0 -6
  321. package/dist/duffel-components.js +0 -2
  322. package/dist/duffel-components.js.LICENSE.txt +0 -6
  323. package/dist/duffel-components.min.css +0 -1280
  324. package/dist/duffel-components.umd.min.js +0 -2
  325. package/dist/duffel-components.umd.min.js.LICENSE.txt +0 -102
@@ -0,0 +1,122 @@
1
+ import React from "react";
2
+ import { CreateOrderPayloadServices } from "../../types/CreateOrderPayload";
3
+ import {
4
+ OfferAvailableServiceBaggage,
5
+ OfferSliceSegmentPassengerBaggage,
6
+ } from "../../types/Offer";
7
+ import { BaggageSelectionController } from "./BaggageSelectionController";
8
+ import { IncludedBaggageBanner } from "./IncludedBaggageBanner";
9
+
10
+ export interface BaggageSelectionModalBodyPassengerProps {
11
+ segmentId: string;
12
+ passengerId: string;
13
+ passengerName: string;
14
+ includedBaggage: OfferSliceSegmentPassengerBaggage[];
15
+ passengerServicesForSegment: OfferAvailableServiceBaggage[];
16
+ selectedServices: CreateOrderPayloadServices;
17
+ setSelectedServices: (selectedServices: CreateOrderPayloadServices) => void;
18
+ }
19
+
20
+ export const BaggageSelectionModalBodyPassenger: React.FC<
21
+ BaggageSelectionModalBodyPassengerProps
22
+ > = ({
23
+ segmentId,
24
+ passengerId,
25
+ passengerName,
26
+ includedBaggage,
27
+ passengerServicesForSegment,
28
+ selectedServices,
29
+ setSelectedServices,
30
+ }) => {
31
+ const hasIncludedBaggage = includedBaggage.reduce(
32
+ (sum, bag) => sum + bag.quantity,
33
+ 0
34
+ );
35
+
36
+ return (
37
+ <div style={{ marginTop: "24px" }}>
38
+ <h3 style={{ margin: 0 }} className="p1--semibold">
39
+ {passengerName}
40
+ </h3>
41
+ {hasIncludedBaggage && (
42
+ <IncludedBaggageBanner includedBaggage={includedBaggage} />
43
+ )}
44
+
45
+ <div style={{ display: "flex", rowGap: "8px", flexDirection: "column" }}>
46
+ {passengerServicesForSegment.map((availableService) => (
47
+ <BaggageSelectionController
48
+ key={availableService.id}
49
+ passengerId={passengerId}
50
+ segmentId={segmentId}
51
+ availableService={availableService}
52
+ selectedServices={selectedServices}
53
+ quantity={
54
+ selectedServices.find(({ id }) => id == availableService.id)
55
+ ?.quantity || 0
56
+ }
57
+ onQuantityChanged={(newQuantity) =>
58
+ onBaggageQuantityChanged(
59
+ newQuantity,
60
+ segmentId,
61
+ passengerId,
62
+ passengerName,
63
+ availableService,
64
+ selectedServices,
65
+ setSelectedServices
66
+ )
67
+ }
68
+ />
69
+ ))}
70
+ </div>
71
+
72
+ {passengerServicesForSegment.length === 0 && (
73
+ <p style={{ color: `var(--GREY-700)`, margin: 0 }}>
74
+ Extra baggage is not available for this passenger on this flight
75
+ </p>
76
+ )}
77
+ </div>
78
+ );
79
+ };
80
+
81
+ const onBaggageQuantityChanged = (
82
+ newQuantity: number,
83
+ segmentId: string,
84
+ passengerId: string,
85
+ passengerName: string,
86
+ availableService: OfferAvailableServiceBaggage,
87
+ selectedServices: CreateOrderPayloadServices,
88
+ setSelectedServices: (selectedServices: CreateOrderPayloadServices) => void
89
+ ) => {
90
+ // check if the service which had its quantity changed is already in the list
91
+ const changedServiceIndex = selectedServices.findIndex(
92
+ ({ id }) => availableService.id === id
93
+ );
94
+
95
+ // create a copy of the existing list of selected services
96
+ const newSelectedServices = Array.from(selectedServices);
97
+
98
+ // if the service is not in the list, add it
99
+ if (changedServiceIndex < 0) {
100
+ newSelectedServices.push({
101
+ id: availableService.id,
102
+ quantity: newQuantity,
103
+ serviceInformation: {
104
+ segmentId,
105
+ passengerId,
106
+ passengerName,
107
+ total_amount: availableService.total_amount,
108
+ total_currency: availableService.total_currency,
109
+ ...availableService.metadata,
110
+ },
111
+ });
112
+ } else {
113
+ // if the service is in the list, update its quantity
114
+ newSelectedServices[changedServiceIndex].quantity = newQuantity;
115
+ }
116
+
117
+ // remove any services with a quantity of 0
118
+ // and update the list of selected services
119
+ setSelectedServices(
120
+ newSelectedServices.filter(({ quantity }) => quantity !== 0)
121
+ );
122
+ };
@@ -0,0 +1,81 @@
1
+ import { ServicePriceMapById } from "@lib/getServicePriceMapById";
2
+ import { getTotalAmountForServicesWithPriceMap } from "@lib/getTotalAmountForServices";
3
+ import { getTotalQuantity } from "@lib/getTotalQuantity";
4
+ import { moneyStringFormatter } from "@lib/moneyStringFormatter";
5
+ import { withPlural } from "@lib/withPlural";
6
+ import React from "react";
7
+ import { CreateOrderPayloadServices } from "../../types/CreateOrderPayload";
8
+ import { Button } from "../Button";
9
+
10
+ export interface BaggageSelectionModalFooterProps {
11
+ currency: string;
12
+ selectedServices: CreateOrderPayloadServices;
13
+ servicePrices: ServicePriceMapById;
14
+
15
+ isFirstSegment: boolean;
16
+ isLastSegment: boolean;
17
+
18
+ onNextSegmentButtonClicked: () => void;
19
+ onPreviousSegmentButtonClicked: () => void;
20
+ onClose: () => void;
21
+ }
22
+
23
+ export const BaggageSelectionModalFooter: React.FC<
24
+ BaggageSelectionModalFooterProps
25
+ > = ({
26
+ selectedServices,
27
+ servicePrices,
28
+ currency,
29
+ isFirstSegment,
30
+ isLastSegment,
31
+ onNextSegmentButtonClicked,
32
+ onPreviousSegmentButtonClicked,
33
+ onClose,
34
+ }) => {
35
+ const totalQuantity = getTotalQuantity(selectedServices);
36
+ const totalAmount = getTotalAmountForServicesWithPriceMap(
37
+ servicePrices,
38
+ selectedServices
39
+ );
40
+ const totalAmountLabel = moneyStringFormatter(currency)(totalAmount);
41
+
42
+ return (
43
+ <div style={{ padding: "16px 24px 24px" }}>
44
+ <div className="flex--space-between">
45
+ <div>
46
+ Price for {withPlural(totalQuantity, "extra bag", "extra bags")}
47
+ </div>
48
+ <div className="h3--semibold" data-testid="baggage-total-amount-label">
49
+ + {totalAmountLabel}
50
+ </div>
51
+ </div>
52
+
53
+ <div
54
+ style={{
55
+ marginTop: "16px",
56
+ display: "grid",
57
+ columnGap: "12px",
58
+ gridTemplateColumns: "repeat(2, 1fr)",
59
+ }}
60
+ >
61
+ <Button
62
+ size={48}
63
+ variant="outlined"
64
+ disabled={isFirstSegment}
65
+ onClick={() => onPreviousSegmentButtonClicked()}
66
+ >
67
+ Back
68
+ </Button>
69
+ <Button
70
+ size={48}
71
+ data-testid="confirm-selection-for-baggage"
72
+ onClick={() =>
73
+ isLastSegment ? onClose() : onNextSegmentButtonClicked()
74
+ }
75
+ >
76
+ {isLastSegment ? "Confirm" : "Next"}
77
+ </Button>
78
+ </div>
79
+ </div>
80
+ );
81
+ };
@@ -0,0 +1,76 @@
1
+ import { formatDateString } from "@lib/formatDate";
2
+ import React from "react";
3
+ import { OfferSliceSegment } from "../../types/Offer";
4
+
5
+ export interface BaggageSelectionModalHeaderProps {
6
+ segmentCount: number;
7
+ currentSegmentIndex: number;
8
+ currentSegment: OfferSliceSegment;
9
+ setCurrentSegmentIndex: (index: number) => void;
10
+ }
11
+
12
+ export const BaggageSelectionModalHeader: React.FC<
13
+ BaggageSelectionModalHeaderProps
14
+ > = ({
15
+ segmentCount,
16
+ currentSegmentIndex,
17
+ currentSegment,
18
+ setCurrentSegmentIndex,
19
+ }) => (
20
+ <div style={{ padding: "24px 24px 16px" }}>
21
+ <div style={{ display: "flex", columnGap: "4px" }}>
22
+ {Array(segmentCount)
23
+ .fill(0)
24
+ .map((_, index) =>
25
+ index === currentSegmentIndex ? (
26
+ <ActiveSegment key={`segment_${index}`} />
27
+ ) : (
28
+ <InactiveSegment
29
+ key={`segment_${index}`}
30
+ onClick={() => setCurrentSegmentIndex(index)}
31
+ />
32
+ )
33
+ )}
34
+ </div>
35
+ <h2 className="h3--semibold" style={{ marginTop: "12px" }}>
36
+ Flight to {currentSegment.destination.iata_code}
37
+ <span
38
+ className="p2--regular"
39
+ style={{
40
+ color: "var(--GREY-600)",
41
+ marginLeft: "8px",
42
+ }}
43
+ >
44
+ {formatDateString(currentSegment.departing_at)}
45
+ </span>
46
+ </h2>
47
+ </div>
48
+ );
49
+
50
+ const InactiveSegment: React.FC<{
51
+ style?: React.CSSProperties;
52
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
53
+ }> = ({ onClick, style }) => (
54
+ <button
55
+ onClick={onClick}
56
+ style={{
57
+ border: "none",
58
+ width: "4px",
59
+ height: "4px",
60
+ padding: "0",
61
+ borderRadius: "4px",
62
+ backgroundColor: "rgba(var(--ACCENT), var(--ACCENT-LIGHT-200))",
63
+ transition: "background-color 0.3s var(--TRANSITION-CUBIC-BEZIER)",
64
+ ...style,
65
+ }}
66
+ />
67
+ );
68
+
69
+ const ActiveSegment = () => (
70
+ <InactiveSegment
71
+ onClick={undefined}
72
+ style={{
73
+ backgroundColor: "rgb(var(--ACCENT))",
74
+ }}
75
+ />
76
+ );
@@ -0,0 +1,51 @@
1
+ import { withPlural } from "@lib/withPlural";
2
+ import React from "react";
3
+ import { OfferSliceSegmentPassengerBaggage } from "../../types/Offer";
4
+
5
+ interface IncludedBaggageBannerProps {
6
+ includedBaggage: OfferSliceSegmentPassengerBaggage[];
7
+ }
8
+
9
+ export const IncludedBaggageBanner: React.FC<IncludedBaggageBannerProps> = ({
10
+ includedBaggage,
11
+ }) => {
12
+ const { carryOnBagsQuantity, checkedBagsQuantity } = includedBaggage.reduce(
13
+ (sum, { type, quantity }) => ({
14
+ carryOnBagsQuantity:
15
+ sum.carryOnBagsQuantity + (type === "carry_on" ? quantity : 0),
16
+ checkedBagsQuantity:
17
+ sum.checkedBagsQuantity + (type === "checked" ? quantity : 0),
18
+ }),
19
+ {
20
+ carryOnBagsQuantity: 0,
21
+ checkedBagsQuantity: 0,
22
+ }
23
+ );
24
+
25
+ const baggageLabelStringArray = new Array<string>();
26
+ if (carryOnBagsQuantity > 0) {
27
+ baggageLabelStringArray.push(
28
+ withPlural(carryOnBagsQuantity, "cabin bag", "cabin bags")
29
+ );
30
+ }
31
+ if (checkedBagsQuantity > 0) {
32
+ baggageLabelStringArray.push(
33
+ withPlural(checkedBagsQuantity, "checked bag", "checked bags")
34
+ );
35
+ }
36
+
37
+ return (
38
+ <div
39
+ style={{
40
+ marginBlock: "8px",
41
+ padding: "8px 12px",
42
+ color: ` var(--GREEN-300)`,
43
+ backgroundColor: ` var(--GREEN-100)`,
44
+ borderRadius: "6px",
45
+ }}
46
+ className="p2--regular"
47
+ >
48
+ {baggageLabelStringArray.join(" and ")} included with ticket
49
+ </div>
50
+ );
51
+ };
@@ -0,0 +1,90 @@
1
+ import { AnimatedLoaderEllipsis } from "@components/AnimatedLoaderEllipsis";
2
+ import { Stamp } from "@components/Stamp";
3
+ import { getCurrencyForServices } from "@lib/getCurrencyForServices";
4
+ import { getTotalAmountForServices } from "@lib/getTotalAmountForServices";
5
+ import { getTotalQuantity } from "@lib/getTotalQuantity";
6
+ import { hasService } from "@lib/hasService";
7
+ import { isCancelForAnyReasonService } from "@lib/isCancelForAnyReasonService";
8
+ import { moneyStringFormatter } from "@lib/moneyStringFormatter";
9
+ import React from "react";
10
+ import { CreateOrderPayloadServices } from "../../types/CreateOrderPayload";
11
+ import { Offer } from "../../types/Offer";
12
+ import { Card } from "../Card";
13
+ import { CfarSelectionModal } from "./CfarSelectionModal";
14
+
15
+ export interface CfarSelectionCardProps {
16
+ isLoading: boolean;
17
+ offer?: Offer;
18
+ selectedServices: CreateOrderPayloadServices;
19
+ setSelectedServices: (selectedServices: CreateOrderPayloadServices) => void;
20
+ }
21
+
22
+ export const CfarSelectionCard: React.FC<CfarSelectionCardProps> = ({
23
+ isLoading,
24
+ offer,
25
+ selectedServices,
26
+ setSelectedServices,
27
+ }) => {
28
+ const [isOpen, setIsOpen] = React.useState(false);
29
+
30
+ const containsCfarService = hasService(offer, "cancel_for_any_reason");
31
+ const totalQuantity = getTotalQuantity(selectedServices);
32
+ const isCfarAdded = totalQuantity > 0;
33
+
34
+ let currencyToUse = offer?.base_currency || "";
35
+ if (containsCfarService) {
36
+ currencyToUse = getCurrencyForServices(offer!, "cancel_for_any_reason");
37
+ }
38
+
39
+ const totalAmount = getTotalAmountForServices(offer!, selectedServices);
40
+ const totalAmountFormatted = offer
41
+ ? moneyStringFormatter(currencyToUse)(totalAmount)
42
+ : "0";
43
+
44
+ const cfarService = offer?.available_services.find(
45
+ isCancelForAnyReasonService
46
+ );
47
+
48
+ const copy =
49
+ containsCfarService && isCfarAdded
50
+ ? `Your trip is protected for ${totalAmountFormatted}`
51
+ : `Protect your purchase if you decide to cancel`;
52
+
53
+ return (
54
+ <>
55
+ <Card
56
+ buttonTitle="Add cancel for any reason"
57
+ title="Cancel for any reason"
58
+ copy={copy}
59
+ icon="shield_with_moon"
60
+ onClick={containsCfarService ? () => setIsOpen(true) : null}
61
+ isLoading={isLoading}
62
+ disabled={!isLoading && !containsCfarService}
63
+ isSelected={isCfarAdded}
64
+ >
65
+ {isLoading && (
66
+ <Stamp color="var(--GREY-900)" backgroundColor="var(--GREY-100)">
67
+ Loading
68
+ <AnimatedLoaderEllipsis />
69
+ </Stamp>
70
+ )}
71
+ {!isLoading && !containsCfarService && (
72
+ <Stamp color="var(--GREY-700)" backgroundColor="var(--GREY-200)">
73
+ Not available
74
+ </Stamp>
75
+ )}
76
+ </Card>
77
+
78
+ <CfarSelectionModal
79
+ isOpen={Boolean(isOpen && offer && cfarService)}
80
+ offerCurrency={offer?.base_currency}
81
+ service={cfarService}
82
+ onClose={(newSelectedServices) => {
83
+ setIsOpen(false);
84
+ setSelectedServices(newSelectedServices);
85
+ }}
86
+ selectedServices={selectedServices}
87
+ />
88
+ </>
89
+ );
90
+ };
@@ -0,0 +1,63 @@
1
+ import React from "react";
2
+ import {
3
+ CreateOrderPayloadServiceInformationForCancelForAnyReason,
4
+ CreateOrderPayloadServices,
5
+ } from "../../types/CreateOrderPayload";
6
+ import {
7
+ Offer,
8
+ OfferAvailableServiceCancelForAnyReason,
9
+ } from "../../types/Offer";
10
+ import { Modal } from "../Modal";
11
+ import { CfarSelectionModalBody } from "./CfarSelectionModalBody";
12
+ import { CfarSelectionModalFooter } from "./CfarSelectionModalFooter";
13
+ import { CfarSelectionModalHeader } from "./CfarSelectionModalHeader";
14
+
15
+ export interface CfarSelectionModalProps {
16
+ isOpen: boolean;
17
+ offerCurrency?: Offer["base_currency"];
18
+ service?: OfferAvailableServiceCancelForAnyReason;
19
+ selectedServices: CreateOrderPayloadServices;
20
+ onClose: (selectedServices: CreateOrderPayloadServices) => void;
21
+ }
22
+
23
+ export const CfarSelectionModal: React.FC<CfarSelectionModalProps> = ({
24
+ isOpen,
25
+ offerCurrency,
26
+ service,
27
+ onClose,
28
+ selectedServices,
29
+ }) => {
30
+ return (
31
+ <Modal isOpen={isOpen} onClose={() => onClose(selectedServices)}>
32
+ <CfarSelectionModalHeader />
33
+ {service && offerCurrency && (
34
+ <>
35
+ <CfarSelectionModalBody
36
+ service={service}
37
+ offerCurrency={offerCurrency}
38
+ />
39
+ <CfarSelectionModalFooter
40
+ service={service}
41
+ selectedServices={selectedServices}
42
+ onAddCfarService={() =>
43
+ onClose([
44
+ {
45
+ id: service.id,
46
+ quantity: 1,
47
+ serviceInformation: {
48
+ type: "cancel_for_any_reason",
49
+ total_amount: service.total_amount,
50
+ total_currency: service.total_currency,
51
+ ...service.metadata,
52
+ } as CreateOrderPayloadServiceInformationForCancelForAnyReason,
53
+ },
54
+ ])
55
+ }
56
+ onRemoveCfarService={() => onClose([])}
57
+ onClose={() => onClose(selectedServices)}
58
+ />
59
+ </>
60
+ )}
61
+ </Modal>
62
+ );
63
+ };
@@ -0,0 +1,56 @@
1
+ import { Icon } from "@components/Icon";
2
+ import { ModalBody } from "@components/Modal";
3
+ import { moneyStringFormatter } from "@lib/moneyStringFormatter";
4
+ import React from "react";
5
+ import {
6
+ Offer,
7
+ OfferAvailableServiceCancelForAnyReason,
8
+ } from "../../types/Offer";
9
+ import { CfarSelectionModalBodyListItem } from "./CfarSelectionModalBodyListItem";
10
+
11
+ export interface CfarSelectionModalBodyProps {
12
+ offerCurrency: Offer["base_currency"];
13
+ service: OfferAvailableServiceCancelForAnyReason;
14
+ }
15
+
16
+ export const CfarSelectionModalBody: React.FC<CfarSelectionModalBodyProps> = ({
17
+ offerCurrency,
18
+ service,
19
+ }) => (
20
+ <ModalBody>
21
+ <ul style={{ padding: 0 }}>
22
+ <CfarSelectionModalBodyListItem>
23
+ Cancel your trip for any reason
24
+ </CfarSelectionModalBodyListItem>
25
+
26
+ <CfarSelectionModalBodyListItem>
27
+ Guaranteed refund of{" "}
28
+ {moneyStringFormatter(offerCurrency)(+service.metadata.refund_amount)}
29
+ </CfarSelectionModalBodyListItem>
30
+
31
+ <CfarSelectionModalBodyListItem>
32
+ Redeemable up to 24 hours before first flight departure
33
+ </CfarSelectionModalBodyListItem>
34
+ </ul>
35
+ <a
36
+ href={service.metadata.terms_and_conditions_url}
37
+ rel="noopener noreferrer"
38
+ target="_blank"
39
+ className="p2--regular"
40
+ style={{
41
+ color: "var(--GREY-600)",
42
+ }}
43
+ >
44
+ Terms and conditions
45
+ <Icon
46
+ name="north_east"
47
+ size={16}
48
+ style={{
49
+ display: "inline",
50
+ verticalAlign: "middle",
51
+ marginLeft: "4px",
52
+ }}
53
+ />
54
+ </a>
55
+ </ModalBody>
56
+ );
@@ -0,0 +1,11 @@
1
+ import { Icon } from "@components/Icon";
2
+ import React, { ReactNode } from "react";
3
+
4
+ export const CfarSelectionModalBodyListItem: React.FC<{
5
+ children: ReactNode;
6
+ }> = ({ children }) => (
7
+ <li className="cfar-modal-list-item">
8
+ <Icon name="check" />
9
+ <p>{children}</p>
10
+ </li>
11
+ );
@@ -0,0 +1,74 @@
1
+ import { Icon } from "@components/Icon";
2
+ import { moneyStringFormatter } from "@lib/moneyStringFormatter";
3
+ import React from "react";
4
+ import { CreateOrderPayloadServices } from "../../types/CreateOrderPayload";
5
+ import { OfferAvailableServiceCancelForAnyReason } from "../../types/Offer";
6
+ import { Button } from "../Button";
7
+
8
+ export interface CfarSelectionModalFooterProps {
9
+ service: OfferAvailableServiceCancelForAnyReason;
10
+ selectedServices: CreateOrderPayloadServices;
11
+ onAddCfarService: () => void;
12
+ onRemoveCfarService: () => void;
13
+ onClose: () => void;
14
+ }
15
+
16
+ export const CfarSelectionModalFooter: React.FC<
17
+ CfarSelectionModalFooterProps
18
+ > = ({
19
+ service,
20
+ selectedServices,
21
+ onAddCfarService,
22
+ onRemoveCfarService,
23
+ onClose,
24
+ }) => {
25
+ const serviceIncluded = selectedServices.some(({ id }) => id == service.id);
26
+ const formattedPrice = moneyStringFormatter(service.total_currency)(
27
+ +service.total_amount
28
+ );
29
+
30
+ return (
31
+ <div className="cfar-modal-footer">
32
+ <Button
33
+ size={48}
34
+ variant={serviceIncluded ? "destructive" : "outlined"}
35
+ onClick={serviceIncluded ? onRemoveCfarService : onClose}
36
+ >
37
+ {serviceIncluded ? "Remove protection" : "Don’t protect trip"}
38
+ </Button>
39
+
40
+ {!serviceIncluded && (
41
+ <Button
42
+ size={48}
43
+ data-testid="confirm-selection-for-cfar"
44
+ onClick={onAddCfarService}
45
+ >
46
+ Add protection for {formattedPrice}
47
+ </Button>
48
+ )}
49
+
50
+ {serviceIncluded && <ProtectedTripBanner />}
51
+ </div>
52
+ );
53
+ };
54
+
55
+ const ProtectedTripBanner: React.FC = () => (
56
+ <div
57
+ style={{
58
+ display: "flex",
59
+ alignItems: "center",
60
+ justifyContent: "center",
61
+ columnGap: "8px",
62
+ backgroundColor: "var(--GREY-100)",
63
+ padding: "var(--space-12)",
64
+ borderRadius: "var(--BUTTON-RADIUS)",
65
+ }}
66
+ >
67
+ <Icon
68
+ size={20}
69
+ name="shield_with_moon"
70
+ style={{ fill: "rgb(var(--ACCENT))" }}
71
+ />
72
+ Your trip is protected
73
+ </div>
74
+ );
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ export const CfarSelectionModalHeader: React.FC = () => (
4
+ <div style={{ padding: "24px 24px 16px" }}>
5
+ <h2 className="h3--semibold" style={{ marginBlock: 0 }}>
6
+ Cancel for any reason
7
+ </h2>
8
+ </div>
9
+ );
@@ -0,0 +1,21 @@
1
+ import classNames from "classnames";
2
+ import * as React from "react";
3
+ import { SeatMapCabinRowSectionElementAmenity } from "../../types/SeatMap";
4
+ import { Icon, IconName } from "../Icon";
5
+
6
+ const amenitiesWithoutWrapper = ["bassinet", "exit_row"];
7
+
8
+ export interface AmenityProps {
9
+ type: SeatMapCabinRowSectionElementAmenity;
10
+ }
11
+
12
+ export const Amenity: React.FC<AmenityProps> = ({ type }) => (
13
+ <div
14
+ className={classNames("map-element map-element--amenity", {
15
+ "map-element--wrapped": !amenitiesWithoutWrapper.includes(type),
16
+ })}
17
+ aria-label={type.toString()}
18
+ >
19
+ <Icon name={type as IconName} size={16} />
20
+ </div>
21
+ );
@@ -0,0 +1,27 @@
1
+ import { Tabs } from "@components/Tabs";
2
+ import * as React from "react";
3
+
4
+ export interface DeckSelectProps {
5
+ /**
6
+ * The currently selected deck number
7
+ */
8
+ value: number;
9
+ /**
10
+ * What to do when the user selects a deck
11
+ */
12
+ setValue: (value: number) => void;
13
+ }
14
+
15
+ /**
16
+ * The deck selection component for the seat map.
17
+ */
18
+ export const DeckSelect: React.FC<DeckSelectProps> = ({ value, setValue }) => {
19
+ const options = ["Lower deck", "Upper deck"];
20
+ return (
21
+ <Tabs
22
+ options={options}
23
+ value={options[value]}
24
+ onChange={(item) => setValue(options.indexOf(item))}
25
+ />
26
+ );
27
+ };