@duffel/components 2.7.20 → 3.0.0
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.
- package/.circleci/config.yml +67 -0
- package/.eslintrc.js +47 -0
- package/.github/renovate.json +16 -0
- package/.github/workflows/autoapprove.yml +18 -0
- package/.github/workflows/release.yml +89 -0
- package/.husky/post-commit +4 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +2 -0
- package/.storybook/Storyshots.test.js +3 -0
- package/.storybook/__snapshots__/Storyshots.test.js.snap +48318 -0
- package/.storybook/main.ts +33 -0
- package/.storybook/preview.tsx +28 -0
- package/.tool-versions +1 -0
- package/CONTRIBUTING.md +83 -0
- package/README.md +53 -15
- package/__mocks__/styleMock.js +6 -0
- package/babel.config.js +20 -0
- package/commitlint.config.js +4 -0
- package/config/esbuild.base.config.js +18 -0
- package/config/esbuild.cdn.config.js +51 -0
- package/config/esbuild.dev.config.js +46 -0
- package/config/esbuild.react.config.js +42 -0
- package/jest.config.ts +14 -0
- package/package.json +135 -193
- package/react-dist/components/DuffelAncillaries/Card.d.ts +14 -0
- package/react-dist/components/DuffelAncillaries/Counter.d.ts +10 -0
- package/react-dist/components/DuffelAncillaries/DuffelAncillaries.d.ts +3 -0
- package/react-dist/components/DuffelAncillaries/DuffelAncillariesCustomElement.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionCard.d.ts +11 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionController.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionModal.d.ts +11 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionModalBody.d.ts +11 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.d.ts +14 -0
- package/react-dist/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.d.ts +9 -0
- package/react-dist/components/DuffelAncillaries/bags/IncludedBaggageBanner.d.ts +7 -0
- package/react-dist/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.d.ts +10 -0
- package/react-dist/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.d.ts +11 -0
- package/react-dist/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.d.ts +7 -0
- package/react-dist/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +4 -0
- package/react-dist/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +11 -0
- package/react-dist/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +2 -0
- package/react-dist/components/DuffelAncillaries/seats/Amenity.d.ts +6 -0
- package/react-dist/components/DuffelAncillaries/seats/DeckSelect.d.ts +15 -0
- package/react-dist/components/DuffelAncillaries/seats/Element.d.ts +15 -0
- package/react-dist/components/DuffelAncillaries/seats/EmptyElement.d.ts +2 -0
- package/react-dist/components/DuffelAncillaries/seats/ExitElement.d.ts +6 -0
- package/react-dist/components/DuffelAncillaries/seats/Legend.d.ts +12 -0
- package/react-dist/components/DuffelAncillaries/seats/Row.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/seats/RowSection.d.ts +17 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatElement.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatInfo.d.ts +7 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatMap.d.ts +12 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatMapUnavailable.d.ts +2 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatSelectionCard.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatSelectionModal.d.ts +13 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatSelectionModalBody.d.ts +4 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatSelectionModalFooter.d.ts +16 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatSelectionModalHeader.d.ts +10 -0
- package/react-dist/components/DuffelAncillaries/seats/SeatUnavailable.d.ts +5 -0
- package/react-dist/components/DuffelPayments/DuffelPayments.d.ts +11 -0
- package/react-dist/components/DuffelPayments/DuffelPaymentsCustomElement.d.ts +14 -0
- package/react-dist/components/shared/AnimatedLoaderEllipsis.d.ts +2 -0
- package/react-dist/components/shared/Button.d.ts +23 -0
- package/react-dist/components/shared/ErrorBoundary.d.ts +13 -0
- package/react-dist/components/shared/FetchOfferErrorState.d.ts +5 -0
- package/react-dist/components/shared/Icon.d.ts +44 -0
- package/react-dist/components/shared/IconButton.d.ts +16 -0
- package/react-dist/components/shared/Modal.d.ts +11 -0
- package/react-dist/components/shared/NonIdealState.d.ts +4 -0
- package/react-dist/components/shared/Stamp.d.ts +7 -0
- package/react-dist/components/shared/Tabs.d.ts +16 -0
- package/react-dist/custom-elements.d.ts +6 -0
- package/react-dist/custom-elements.js +37 -0
- package/react-dist/custom-elements.js.map +7 -0
- package/react-dist/index.d.ts +7 -0
- package/react-dist/index.js +37 -0
- package/react-dist/index.js.map +7 -0
- package/react-dist/lib/captureErrorInSentry.d.ts +1 -0
- package/react-dist/lib/compileCreateOrderPayload.d.ts +14 -0
- package/react-dist/lib/createPriceFormatters.d.ts +12 -0
- package/react-dist/lib/fetchFromDuffelAPI.d.ts +8 -0
- package/react-dist/lib/fetchFromFixtures.d.ts +4 -0
- package/react-dist/lib/formatAvailableServices.d.ts +12 -0
- package/react-dist/lib/formatDate.d.ts +2 -0
- package/react-dist/lib/formatSeatMaps.d.ts +4 -0
- package/react-dist/lib/getBaggageServiceDescription.d.ts +2 -0
- package/react-dist/lib/getCabinsForSegmentAndDeck.d.ts +2 -0
- package/react-dist/lib/getCurrencyForSeatMaps.d.ts +10 -0
- package/react-dist/lib/getCurrencyForServices.d.ts +11 -0
- package/react-dist/lib/getFirstSeatElementMatchingCriteria.d.ts +3 -0
- package/react-dist/lib/getPassengerBySegmentList.d.ts +6 -0
- package/react-dist/lib/getPassengerInitials.d.ts +1 -0
- package/react-dist/lib/getPassengerMapById.d.ts +3 -0
- package/react-dist/lib/getPassengerName.d.ts +3 -0
- package/react-dist/lib/getRowNumber.d.ts +2 -0
- package/react-dist/lib/getSegmentList.d.ts +2 -0
- package/react-dist/lib/getServicePriceMapById.d.ts +3 -0
- package/react-dist/lib/getSymbols.d.ts +2 -0
- package/react-dist/lib/getTotalAmountForServices.d.ts +6 -0
- package/react-dist/lib/getTotalQuantity.d.ts +2 -0
- package/react-dist/lib/hasService.d.ts +2 -0
- package/react-dist/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +3 -0
- package/react-dist/lib/hasWings.d.ts +2 -0
- package/react-dist/lib/isBaggageService.d.ts +2 -0
- package/react-dist/lib/isCancelForAnyReasonService.d.ts +2 -0
- package/react-dist/lib/isFixtureOfferId.d.ts +2 -0
- package/react-dist/lib/isPayloadComplete.d.ts +2 -0
- package/react-dist/lib/isSeatElement.d.ts +2 -0
- package/react-dist/lib/logging.d.ts +46 -0
- package/react-dist/lib/moneyStringFormatter.d.ts +8 -0
- package/react-dist/lib/offerIsExpired.d.ts +2 -0
- package/react-dist/lib/retrieveOffer.d.ts +2 -0
- package/react-dist/lib/retrieveOfferFromDuffelAPI.d.ts +1 -0
- package/react-dist/lib/retrieveSeatMaps.d.ts +2 -0
- package/react-dist/lib/retrieveSeatMapsFromDuffelAPI.d.ts +1 -0
- package/react-dist/lib/setBodyScrollability.d.ts +1 -0
- package/react-dist/lib/validateProps.d.ts +7 -0
- package/react-dist/lib/withPlural.d.ts +1 -0
- package/react-dist/types/Aircraft.d.ts +14 -0
- package/react-dist/types/Airline.d.ts +14 -0
- package/react-dist/types/Airport.d.ts +44 -0
- package/react-dist/types/City.d.ts +18 -0
- package/react-dist/types/CreateOrderPayload.d.ts +72 -0
- package/react-dist/types/CurrencyConversion.d.ts +10 -0
- package/react-dist/types/DuffelAncillariesProps.d.ts +70 -0
- package/react-dist/types/Offer.d.ts +711 -0
- package/react-dist/types/Order.d.ts +8 -0
- package/react-dist/types/Place.d.ts +8 -0
- package/react-dist/types/SeatMap.d.ts +190 -0
- package/react-dist/types/index.d.ts +11 -0
- package/scripts/generate-fixture.ts +200 -0
- package/scripts/upload-to-cdn.sh +34 -0
- package/scripts.tsconfig.json +11 -0
- package/src/components/DuffelAncillaries/Card.tsx +126 -0
- package/src/components/DuffelAncillaries/Counter.tsx +40 -0
- package/src/components/DuffelAncillaries/DuffelAncillaries.tsx +344 -0
- package/src/components/DuffelAncillaries/DuffelAncillariesCustomElement.tsx +124 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionCard.tsx +96 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionController.tsx +88 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModal.tsx +81 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalBody.tsx +60 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.tsx +122 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.tsx +81 -0
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.tsx +76 -0
- package/src/components/DuffelAncillaries/bags/IncludedBaggageBanner.tsx +51 -0
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.tsx +90 -0
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.tsx +63 -0
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.tsx +56 -0
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.tsx +11 -0
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.tsx +74 -0
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.tsx +9 -0
- package/src/components/DuffelAncillaries/seats/Amenity.tsx +21 -0
- package/src/components/DuffelAncillaries/seats/DeckSelect.tsx +27 -0
- package/src/components/DuffelAncillaries/seats/Element.tsx +52 -0
- package/src/components/DuffelAncillaries/seats/EmptyElement.tsx +5 -0
- package/src/components/DuffelAncillaries/seats/ExitElement.tsx +17 -0
- package/src/components/DuffelAncillaries/seats/Legend.tsx +60 -0
- package/src/components/DuffelAncillaries/seats/Row.tsx +47 -0
- package/src/components/DuffelAncillaries/seats/RowSection.tsx +78 -0
- package/src/components/DuffelAncillaries/seats/SeatElement.tsx +120 -0
- package/src/components/DuffelAncillaries/seats/SeatInfo.tsx +32 -0
- package/src/components/DuffelAncillaries/seats/SeatMap.tsx +81 -0
- package/src/components/DuffelAncillaries/seats/SeatMapUnavailable.tsx +21 -0
- package/src/components/DuffelAncillaries/seats/SeatSelectionCard.tsx +103 -0
- package/src/components/DuffelAncillaries/seats/SeatSelectionModal.tsx +142 -0
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalBody.tsx +13 -0
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalFooter.tsx +82 -0
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalHeader.tsx +87 -0
- package/src/components/DuffelAncillaries/seats/SeatUnavailable.tsx +14 -0
- package/src/components/DuffelPayments/DuffelPayments.tsx +218 -0
- package/src/components/DuffelPayments/DuffelPaymentsCustomElement.tsx +130 -0
- package/src/components/shared/AnimatedLoaderEllipsis.tsx +5 -0
- package/src/components/shared/Button.tsx +63 -0
- package/src/components/shared/ErrorBoundary.tsx +54 -0
- package/src/components/shared/FetchOfferErrorState.tsx +35 -0
- package/src/components/shared/Icon.tsx +152 -0
- package/src/components/shared/IconButton.tsx +42 -0
- package/src/components/shared/Modal.tsx +40 -0
- package/src/components/shared/NonIdealState.tsx +28 -0
- package/src/components/shared/Stamp.tsx +29 -0
- package/src/components/shared/Tabs.tsx +36 -0
- package/src/custom-elements.ts +13 -0
- package/src/examples/client-side/README.md +30 -0
- package/src/examples/client-side/index.html +57 -0
- package/src/examples/full-stack/README.md +34 -0
- package/src/examples/full-stack/index.html +48 -0
- package/src/examples/full-stack/server.mjs +158 -0
- package/src/examples/just-typescript/README.md +37 -0
- package/src/examples/just-typescript/package.json +16 -0
- package/src/examples/just-typescript/src/index.html +23 -0
- package/src/examples/just-typescript/src/index.ts +36 -0
- package/src/examples/just-typescript/yarn.lock +154 -0
- package/src/examples/payments-custom-element/README.md +17 -0
- package/src/examples/payments-custom-element/index.html +43 -0
- package/src/examples/payments-just-typescript/README.md +37 -0
- package/src/examples/payments-just-typescript/package.json +16 -0
- package/src/examples/payments-just-typescript/src/index.html +23 -0
- package/src/examples/payments-just-typescript/src/index.ts +18 -0
- package/src/examples/payments-just-typescript/yarn.lock +154 -0
- package/src/examples/react-app/README.md +37 -0
- package/src/examples/react-app/package.json +20 -0
- package/src/examples/react-app/src/index.html +19 -0
- package/src/examples/react-app/src/index.tsx +48 -0
- package/src/examples/react-app/yarn.lock +219 -0
- package/src/fixtures/offers/off_0000AUde3KwTztSRK1cznH.json +497 -0
- package/src/fixtures/offers/off_0000AVx4lUFFKW8PsPeQeQ.json +307 -0
- package/src/fixtures/offers/off_1.json +497 -0
- package/src/fixtures/passengers/mock_passengers.ts +26 -0
- package/src/fixtures/seat-maps/off_0000AUde3KwTztSRK1cznH.json +6852 -0
- package/src/fixtures/seat-maps/off_0000AVx4lUFFKW8PsPeQeQ.json +1 -0
- package/src/fixtures/seat-maps/off_1.json +6852 -0
- package/src/index.ts +7 -0
- package/src/lib/captureErrorInSentry.ts +42 -0
- package/src/lib/compileCreateOrderPayload.ts +63 -0
- package/src/lib/createPriceFormatters.ts +73 -0
- package/src/lib/fetchFromDuffelAPI.ts +54 -0
- package/src/lib/fetchFromFixtures.ts +18 -0
- package/src/lib/formatAvailableServices.ts +91 -0
- package/src/lib/formatDate.ts +20 -0
- package/src/lib/formatSeatMaps.ts +81 -0
- package/src/lib/getBaggageServiceDescription.ts +42 -0
- package/src/lib/getCabinsForSegmentAndDeck.ts +4 -0
- package/src/lib/getCurrencyForSeatMaps.ts +22 -0
- package/src/lib/getCurrencyForServices.ts +24 -0
- package/src/lib/getFirstSeatElementMatchingCriteria.ts +22 -0
- package/src/lib/getPassengerBySegmentList.ts +10 -0
- package/src/lib/getPassengerInitials.ts +6 -0
- package/src/lib/getPassengerMapById.ts +17 -0
- package/src/lib/getPassengerName.ts +37 -0
- package/src/lib/getRowNumber.ts +16 -0
- package/src/lib/getSegmentList.ts +7 -0
- package/src/lib/getServicePriceMapById.ts +20 -0
- package/src/lib/getSymbols.ts +22 -0
- package/src/lib/getTotalAmountForServices.ts +72 -0
- package/src/lib/getTotalQuantity.ts +5 -0
- package/src/lib/hasService.ts +24 -0
- package/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.ts +35 -0
- package/src/lib/hasWings.ts +8 -0
- package/src/lib/isBaggageService.ts +8 -0
- package/src/lib/isCancelForAnyReasonService.ts +9 -0
- package/src/lib/isFixtureOfferId.ts +4 -0
- package/src/lib/isPayloadComplete.ts +11 -0
- package/src/lib/isSeatElement.ts +10 -0
- package/src/lib/logging.ts +120 -0
- package/src/lib/moneyStringFormatter.ts +34 -0
- package/src/lib/offerIsExpired.ts +5 -0
- package/src/lib/retrieveOffer.ts +54 -0
- package/src/lib/retrieveOfferFromDuffelAPI.ts +13 -0
- package/src/lib/retrieveSeatMaps.ts +55 -0
- package/src/lib/retrieveSeatMapsFromDuffelAPI.ts +13 -0
- package/src/lib/setBodyScrollability.ts +7 -0
- package/src/lib/validateProps.ts +37 -0
- package/src/lib/withPlural.ts +8 -0
- package/src/stories/BaggageSelectionModalHeader.stories.tsx +21 -0
- package/src/stories/Button.stories.tsx +69 -0
- package/src/stories/DuffelAncillaries.stories.tsx +126 -0
- package/src/stories/DuffelPayments.stories.tsx +34 -0
- package/src/stories/Icon.stories.tsx +35 -0
- package/src/stories/IconButton.stories.tsx +25 -0
- package/src/styles/colors.css +22 -0
- package/src/styles/components/Amenity.css +23 -0
- package/src/styles/components/BaggageDisplay.css +25 -0
- package/src/styles/components/Button.css +161 -0
- package/src/styles/components/Card.css +52 -0
- package/src/styles/components/CfarSelectionModal.css +34 -0
- package/src/styles/components/Counter.css +18 -0
- package/src/styles/components/DuffelPayments.css +42 -0
- package/src/styles/components/IconButton.css +63 -0
- package/src/styles/components/Legend.css +58 -0
- package/src/styles/components/Loader.css +37 -0
- package/src/styles/components/LoadingState.css +81 -0
- package/src/styles/components/Modal.css +84 -0
- package/src/styles/components/PassengerSelect.css +93 -0
- package/src/styles/components/PassengersLayout.css +90 -0
- package/src/styles/components/Row.css +70 -0
- package/src/styles/components/Seat.css +57 -0
- package/src/styles/components/SeatInfo.css +61 -0
- package/src/styles/components/SeatMap.css +24 -0
- package/src/styles/components/SeatSelect.css +92 -0
- package/src/styles/components/Segment.css +17 -0
- package/src/styles/components/SelectionSegment.css +10 -0
- package/src/styles/components/Summary.css +70 -0
- package/src/styles/components/Tabs.css +49 -0
- package/src/styles/flex.css +5 -0
- package/src/styles/font-families.css +47 -0
- package/src/styles/global.css +51 -0
- package/src/styles/margin.css +3 -0
- package/src/styles/spacing.css +18 -0
- package/src/styles/transitions.css +3 -0
- package/src/styles/typography.css +13 -0
- package/src/tests/components/DuffelAncillaries.test.tsx +342 -0
- package/src/tests/lib/createPriceFormatters.test.tsx +152 -0
- package/src/tests/lib/formatAvailableServices.test.tsx +79 -0
- package/src/tests/lib/formatSeatMaps.test.tsx +49 -0
- package/src/tests/lib/getCurrencyForServices.test.tsx +44 -0
- package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +86 -0
- package/src/tests/lib/logging.test.tsx +32 -0
- package/src/tests/lib/moneyStringFormatter.test.tsx +12 -0
- package/src/tests/lib/validateProps.test.tsx +57 -0
- package/src/types/Aircraft.ts +16 -0
- package/src/types/Airline.ts +16 -0
- package/src/types/Airport.ts +54 -0
- package/src/types/City.ts +21 -0
- package/src/types/CreateOrderPayload.ts +99 -0
- package/src/types/CurrencyConversion.ts +10 -0
- package/src/types/DuffelAncillariesProps.ts +108 -0
- package/src/types/Offer.ts +851 -0
- package/src/types/Order.ts +6 -0
- package/src/types/Place.ts +6 -0
- package/src/types/SeatMap.ts +231 -0
- package/src/types/index.ts +11 -0
- package/tsconfig.json +52 -0
- package/LICENSE +0 -21
- package/dist/AdditionalBaggage.esm.js +0 -1
- package/dist/AdditionalBaggage.js +0 -1
- package/dist/AdditionalBaggage.min.css +0 -408
- package/dist/AdditionalBaggage.umd.min.js +0 -2
- package/dist/AdditionalBaggage.umd.min.js.LICENSE.txt +0 -60
- package/dist/AdditionalBaggageSelection.esm.js +0 -1
- package/dist/AdditionalBaggageSelection.js +0 -1
- package/dist/AdditionalBaggageSelection.min.css +0 -744
- package/dist/AdditionalBaggageSelection.umd.min.js +0 -2
- package/dist/AdditionalBaggageSelection.umd.min.js.LICENSE.txt +0 -93
- package/dist/CardPayment.esm.js +0 -2
- package/dist/CardPayment.esm.js.LICENSE.txt +0 -6
- package/dist/CardPayment.js +0 -2
- package/dist/CardPayment.js.LICENSE.txt +0 -6
- package/dist/CardPayment.min.css +0 -233
- package/dist/CardPayment.umd.min.js +0 -2
- package/dist/CardPayment.umd.min.js.LICENSE.txt +0 -61
- package/dist/SeatSelection.esm.js +0 -1
- package/dist/SeatSelection.js +0 -1
- package/dist/SeatSelection.min.css +0 -1127
- package/dist/SeatSelection.umd.min.js +0 -2
- package/dist/SeatSelection.umd.min.js.LICENSE.txt +0 -60
- package/dist/duffel-components.d.ts +0 -1614
- package/dist/duffel-components.esm.js +0 -2
- package/dist/duffel-components.esm.js.LICENSE.txt +0 -6
- package/dist/duffel-components.js +0 -2
- package/dist/duffel-components.js.LICENSE.txt +0 -6
- package/dist/duffel-components.min.css +0 -1280
- package/dist/duffel-components.umd.min.js +0 -2
- package/dist/duffel-components.umd.min.js.LICENSE.txt +0 -102
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Modal } from "@components/shared/Modal";
|
|
2
|
+
import { getCurrencyForServices } from "@lib/getCurrencyForServices";
|
|
3
|
+
import { getPassengerMapById } from "@lib/getPassengerMapById";
|
|
4
|
+
import { getSegmentList } from "@lib/getSegmentList";
|
|
5
|
+
import { getServicePriceMapById } from "@lib/getServicePriceMapById";
|
|
6
|
+
import { hasService } from "@lib/hasService";
|
|
7
|
+
import React, { useState } from "react";
|
|
8
|
+
import {
|
|
9
|
+
CreateOrderPayload,
|
|
10
|
+
CreateOrderPayloadServices,
|
|
11
|
+
} from "../../../types/CreateOrderPayload";
|
|
12
|
+
import { Offer } from "../../../types/Offer";
|
|
13
|
+
import { BaggageSelectionModalBody } from "./BaggageSelectionModalBody";
|
|
14
|
+
import { BaggageSelectionModalFooter } from "./BaggageSelectionModalFooter";
|
|
15
|
+
import { BaggageSelectionModalHeader } from "./BaggageSelectionModalHeader";
|
|
16
|
+
|
|
17
|
+
export interface BaggageSelectionModalProps {
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
offer?: Offer;
|
|
20
|
+
passengers: CreateOrderPayload["passengers"];
|
|
21
|
+
selectedServices: CreateOrderPayloadServices;
|
|
22
|
+
onClose: (selectedServices: CreateOrderPayloadServices) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const BaggageSelectionModal: React.FC<BaggageSelectionModalProps> = ({
|
|
26
|
+
isOpen,
|
|
27
|
+
offer,
|
|
28
|
+
passengers,
|
|
29
|
+
onClose,
|
|
30
|
+
selectedServices,
|
|
31
|
+
}) => {
|
|
32
|
+
const [currentSegmentIndex, setCurrentSegmentIndex] = useState(0);
|
|
33
|
+
|
|
34
|
+
const [selectedServicesState, setSelectedServicesState] =
|
|
35
|
+
React.useState(selectedServices);
|
|
36
|
+
|
|
37
|
+
if (!offer) return null;
|
|
38
|
+
|
|
39
|
+
const segments = getSegmentList(offer);
|
|
40
|
+
const currentSegment = segments[currentSegmentIndex];
|
|
41
|
+
|
|
42
|
+
const passengerMapById = getPassengerMapById(passengers);
|
|
43
|
+
const servicePricesMap = getServicePriceMapById(offer.available_services);
|
|
44
|
+
|
|
45
|
+
let currencyToUse = offer.base_currency;
|
|
46
|
+
if (hasService(offer, "baggage")) {
|
|
47
|
+
currencyToUse = getCurrencyForServices(offer, "baggage");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Modal isOpen={isOpen} onClose={() => onClose(selectedServicesState)}>
|
|
52
|
+
<BaggageSelectionModalHeader
|
|
53
|
+
segmentCount={segments.length}
|
|
54
|
+
currentSegment={currentSegment}
|
|
55
|
+
currentSegmentIndex={currentSegmentIndex}
|
|
56
|
+
setCurrentSegmentIndex={(index) => setCurrentSegmentIndex(index)}
|
|
57
|
+
/>
|
|
58
|
+
<BaggageSelectionModalBody
|
|
59
|
+
offer={offer}
|
|
60
|
+
selectedServices={selectedServicesState}
|
|
61
|
+
passengersById={passengerMapById}
|
|
62
|
+
segment={currentSegment}
|
|
63
|
+
setSelectedServices={setSelectedServicesState}
|
|
64
|
+
/>
|
|
65
|
+
<BaggageSelectionModalFooter
|
|
66
|
+
currency={currencyToUse}
|
|
67
|
+
selectedServices={selectedServicesState}
|
|
68
|
+
servicePrices={servicePricesMap}
|
|
69
|
+
isFirstSegment={currentSegmentIndex === 0}
|
|
70
|
+
isLastSegment={currentSegmentIndex + 1 === segments.length}
|
|
71
|
+
onNextSegmentButtonClicked={() =>
|
|
72
|
+
setCurrentSegmentIndex(currentSegmentIndex + 1)
|
|
73
|
+
}
|
|
74
|
+
onPreviousSegmentButtonClicked={() =>
|
|
75
|
+
setCurrentSegmentIndex(currentSegmentIndex - 1)
|
|
76
|
+
}
|
|
77
|
+
onClose={() => onClose(selectedServicesState)}
|
|
78
|
+
/>
|
|
79
|
+
</Modal>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ModalBody } from "@components/shared/Modal";
|
|
2
|
+
import { getPassengerName } from "@lib/getPassengerName";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
CreateOrderPayloadPassenger,
|
|
6
|
+
CreateOrderPayloadServices,
|
|
7
|
+
} from "../../../types/CreateOrderPayload";
|
|
8
|
+
import {
|
|
9
|
+
Offer,
|
|
10
|
+
OfferAvailableServiceBaggage,
|
|
11
|
+
OfferSliceSegment,
|
|
12
|
+
} from "../../../types/Offer";
|
|
13
|
+
import { BaggageSelectionModalBodyPassenger } from "./BaggageSelectionModalBodyPassenger";
|
|
14
|
+
|
|
15
|
+
export interface BaggageSelectionModalBodyProps {
|
|
16
|
+
offer: Offer;
|
|
17
|
+
segment: OfferSliceSegment;
|
|
18
|
+
passengersById: Record<
|
|
19
|
+
CreateOrderPayloadPassenger["id"],
|
|
20
|
+
CreateOrderPayloadPassenger
|
|
21
|
+
>;
|
|
22
|
+
selectedServices: CreateOrderPayloadServices;
|
|
23
|
+
setSelectedServices: (selectedServices: CreateOrderPayloadServices) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const BaggageSelectionModalBody: React.FC<
|
|
27
|
+
BaggageSelectionModalBodyProps
|
|
28
|
+
> = ({
|
|
29
|
+
offer,
|
|
30
|
+
segment,
|
|
31
|
+
passengersById,
|
|
32
|
+
selectedServices,
|
|
33
|
+
setSelectedServices,
|
|
34
|
+
}) => (
|
|
35
|
+
<ModalBody>
|
|
36
|
+
{segment.passengers.map(({ passenger_id, baggages }, index) => (
|
|
37
|
+
<BaggageSelectionModalBodyPassenger
|
|
38
|
+
key={passenger_id}
|
|
39
|
+
segmentId={segment.id}
|
|
40
|
+
passengerId={passenger_id}
|
|
41
|
+
passengerName={getPassengerName(
|
|
42
|
+
passengersById[passenger_id],
|
|
43
|
+
offer.passengers.find(({ id }) => id === passenger_id),
|
|
44
|
+
index + 1
|
|
45
|
+
)}
|
|
46
|
+
includedBaggage={baggages}
|
|
47
|
+
passengerServicesForSegment={
|
|
48
|
+
offer.available_services.filter(
|
|
49
|
+
({ type, passenger_ids, segment_ids }) =>
|
|
50
|
+
type === "baggage" &&
|
|
51
|
+
passenger_ids.includes(passenger_id) &&
|
|
52
|
+
segment_ids.includes(segment.id)
|
|
53
|
+
) as OfferAvailableServiceBaggage[]
|
|
54
|
+
}
|
|
55
|
+
selectedServices={selectedServices}
|
|
56
|
+
setSelectedServices={setSelectedServices}
|
|
57
|
+
/>
|
|
58
|
+
))}
|
|
59
|
+
</ModalBody>
|
|
60
|
+
);
|
|
@@ -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 { Button } from "@components/shared/Button";
|
|
2
|
+
import { ServicePriceMapById } from "@lib/getServicePriceMapById";
|
|
3
|
+
import { getTotalAmountForServicesWithPriceMap } from "@lib/getTotalAmountForServices";
|
|
4
|
+
import { getTotalQuantity } from "@lib/getTotalQuantity";
|
|
5
|
+
import { moneyStringFormatter } from "@lib/moneyStringFormatter";
|
|
6
|
+
import { withPlural } from "@lib/withPlural";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
|
|
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/shared/AnimatedLoaderEllipsis";
|
|
2
|
+
import { Stamp } from "@components/shared/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 { Modal } from "@components/shared/Modal";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {
|
|
4
|
+
CreateOrderPayloadServiceInformationForCancelForAnyReason,
|
|
5
|
+
CreateOrderPayloadServices,
|
|
6
|
+
} from "../../../types/CreateOrderPayload";
|
|
7
|
+
import {
|
|
8
|
+
Offer,
|
|
9
|
+
OfferAvailableServiceCancelForAnyReason,
|
|
10
|
+
} from "../../../types/Offer";
|
|
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/shared//Icon";
|
|
2
|
+
import { ModalBody } from "@components/shared/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
|
+
);
|
package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Icon } from "@components/shared/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
|
+
);
|