@duffel/components 3.1.3--prototype.3 → 3.1.3--prototype.6
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/{react-dist/custom-elements.js → custom-elements.js} +2 -2
- package/{react-dist/custom-elements.js.map → custom-elements.js.map} +1 -1
- package/{react-dist/index.js → index.js} +2 -2
- package/{react-dist/index.js.map → index.js.map} +1 -1
- package/package.json +3 -7
- package/scripts/generate-fixture.d.ts +3 -0
- package/scripts/setup-suggestion-data.d.ts +28 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/.circleci/config.yml +0 -67
- package/.eslintrc.js +0 -47
- package/.github/CODEOWNERS +0 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
- package/.github/renovate.json +0 -12
- package/.nvmrc +0 -1
- package/.prettierignore +0 -6
- package/.storybook/main.ts +0 -33
- package/.storybook/preview.tsx +0 -28
- package/.tool-versions +0 -1
- package/.vscode/extensions.json +0 -7
- package/.vscode/settings.json +0 -10
- package/.yarn/releases/yarn-4.0.1.cjs +0 -893
- package/.yarn/sdks/eslint/bin/eslint.js +0 -20
- package/.yarn/sdks/eslint/lib/api.js +0 -20
- package/.yarn/sdks/eslint/lib/unsupported-api.js +0 -20
- package/.yarn/sdks/eslint/package.json +0 -14
- package/.yarn/sdks/integrations.yml +0 -5
- package/.yarn/sdks/prettier/bin-prettier.js +0 -20
- package/.yarn/sdks/prettier/index.js +0 -20
- package/.yarn/sdks/prettier/package.json +0 -7
- package/.yarn/sdks/typescript/bin/tsc +0 -20
- package/.yarn/sdks/typescript/bin/tsserver +0 -20
- package/.yarn/sdks/typescript/lib/tsc.js +0 -20
- package/.yarn/sdks/typescript/lib/tsserver.js +0 -225
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -225
- package/.yarn/sdks/typescript/lib/typescript.js +0 -20
- package/.yarn/sdks/typescript/package.json +0 -10
- package/.yarnrc.yml +0 -3
- package/CONTRIBUTING.md +0 -83
- package/README.md +0 -68
- package/__mocks__/styleMock.js +0 -6
- package/babel.config.js +0 -20
- package/commitlint.config.js +0 -4
- package/config/esbuild.base.config.js +0 -18
- package/config/esbuild.cdn.config.js +0 -51
- package/config/esbuild.dev.config.js +0 -46
- package/config/esbuild.react.config.js +0 -42
- package/data/airports.csv +0 -9084
- package/data/cities.csv +0 -256
- package/jest.config.ts +0 -14
- package/scripts/build-and-publish.sh +0 -42
- package/scripts/generate-fixture.ts +0 -200
- package/scripts/setup-suggestion-data.ts +0 -100
- package/scripts/upload-to-cdn.sh +0 -34
- package/scripts.tsconfig.json +0 -11
- package/src/components/DuffelAncillaries/Card.tsx +0 -126
- package/src/components/DuffelAncillaries/Counter.tsx +0 -40
- package/src/components/DuffelAncillaries/DuffelAncillaries.tsx +0 -350
- package/src/components/DuffelAncillaries/DuffelAncillariesCustomElement.tsx +0 -124
- package/src/components/DuffelAncillaries/bags/BaggageSelectionCard.tsx +0 -101
- package/src/components/DuffelAncillaries/bags/BaggageSelectionController.tsx +0 -88
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModal.tsx +0 -81
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalBody.tsx +0 -60
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.tsx +0 -122
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalFooter.tsx +0 -88
- package/src/components/DuffelAncillaries/bags/BaggageSelectionModalHeader.tsx +0 -82
- package/src/components/DuffelAncillaries/bags/IncludedBaggageBanner.tsx +0 -51
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.tsx +0 -90
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.tsx +0 -63
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.tsx +0 -56
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.tsx +0 -11
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.tsx +0 -74
- package/src/components/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.tsx +0 -9
- package/src/components/DuffelAncillaries/seats/Amenity.tsx +0 -21
- package/src/components/DuffelAncillaries/seats/DeckSelect.tsx +0 -27
- package/src/components/DuffelAncillaries/seats/Element.tsx +0 -52
- package/src/components/DuffelAncillaries/seats/EmptyElement.tsx +0 -5
- package/src/components/DuffelAncillaries/seats/ExitElement.tsx +0 -17
- package/src/components/DuffelAncillaries/seats/Legend.tsx +0 -60
- package/src/components/DuffelAncillaries/seats/Row.tsx +0 -47
- package/src/components/DuffelAncillaries/seats/RowSection.tsx +0 -78
- package/src/components/DuffelAncillaries/seats/SeatElement.tsx +0 -120
- package/src/components/DuffelAncillaries/seats/SeatInfo.tsx +0 -32
- package/src/components/DuffelAncillaries/seats/SeatMap.tsx +0 -85
- package/src/components/DuffelAncillaries/seats/SeatMapUnavailable.tsx +0 -21
- package/src/components/DuffelAncillaries/seats/SeatSelectionCard.tsx +0 -103
- package/src/components/DuffelAncillaries/seats/SeatSelectionModal.tsx +0 -142
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalBody.tsx +0 -13
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalFooter.tsx +0 -89
- package/src/components/DuffelAncillaries/seats/SeatSelectionModalHeader.tsx +0 -97
- package/src/components/DuffelAncillaries/seats/SeatUnavailable.tsx +0 -14
- package/src/components/DuffelPayments/DuffelPayments.tsx +0 -224
- package/src/components/DuffelPayments/DuffelPaymentsCustomElement.tsx +0 -130
- package/src/components/PlacesLookup/PlacesLookup.tsx +0 -122
- package/src/components/shared/AnimatedLoaderEllipsis.tsx +0 -5
- package/src/components/shared/Button.tsx +0 -63
- package/src/components/shared/ErrorBoundary.tsx +0 -54
- package/src/components/shared/FetchOfferErrorState.tsx +0 -35
- package/src/components/shared/Icon.tsx +0 -151
- package/src/components/shared/IconButton.tsx +0 -42
- package/src/components/shared/Modal.tsx +0 -40
- package/src/components/shared/NonIdealState.tsx +0 -28
- package/src/components/shared/Stamp.tsx +0 -29
- package/src/components/shared/Tabs.tsx +0 -36
- package/src/custom-elements.ts +0 -13
- package/src/examples/client-side/README.md +0 -30
- package/src/examples/client-side/index.html +0 -57
- package/src/examples/full-stack/README.md +0 -34
- package/src/examples/full-stack/index.html +0 -48
- package/src/examples/full-stack/server.mjs +0 -158
- package/src/examples/just-typescript/.yarn/install-state.gz +0 -0
- package/src/examples/just-typescript/README.md +0 -37
- package/src/examples/just-typescript/package.json +0 -16
- package/src/examples/just-typescript/src/index.html +0 -23
- package/src/examples/just-typescript/src/index.ts +0 -36
- package/src/examples/just-typescript/yarn.lock +0 -467
- package/src/examples/next/README.md +0 -28
- package/src/examples/next/next-env.d.ts +0 -5
- package/src/examples/next/next.config.js +0 -4
- package/src/examples/next/package.json +0 -24
- package/src/examples/next/src/app/DuffelComponents.tsx +0 -40
- package/src/examples/next/src/app/layout.tsx +0 -18
- package/src/examples/next/src/app/page.tsx +0 -9
- package/src/examples/next/tsconfig.json +0 -27
- package/src/examples/next/yarn.lock +0 -257
- package/src/examples/payments-custom-element/README.md +0 -17
- package/src/examples/payments-custom-element/index.html +0 -43
- package/src/examples/payments-just-typescript/README.md +0 -37
- package/src/examples/payments-just-typescript/package.json +0 -16
- package/src/examples/payments-just-typescript/src/index.html +0 -23
- package/src/examples/payments-just-typescript/src/index.ts +0 -18
- package/src/examples/payments-just-typescript/yarn.lock +0 -154
- package/src/examples/react-app/README.md +0 -37
- package/src/examples/react-app/package.json +0 -20
- package/src/examples/react-app/src/index.html +0 -19
- package/src/examples/react-app/src/index.tsx +0 -48
- package/src/examples/react-app/yarn.lock +0 -219
- package/src/fixtures/offers/off_0000AUde3KwTztSRK1cznH.json +0 -497
- package/src/fixtures/offers/off_0000AVx4lUFFKW8PsPeQeQ.json +0 -307
- package/src/fixtures/offers/off_1.json +0 -488
- package/src/fixtures/passengers/mock_passengers.ts +0 -26
- package/src/fixtures/seat-maps/off_0000AUde3KwTztSRK1cznH.json +0 -6852
- package/src/fixtures/seat-maps/off_0000AVx4lUFFKW8PsPeQeQ.json +0 -1
- package/src/fixtures/seat-maps/off_1.json +0 -6852
- package/src/index.ts +0 -7
- package/src/lib/captureErrorInSentry.ts +0 -42
- package/src/lib/compileCreateOrderPayload.ts +0 -63
- package/src/lib/createPriceFormatters.ts +0 -73
- package/src/lib/fetchFromDuffelAPI.ts +0 -54
- package/src/lib/fetchFromFixtures.ts +0 -18
- package/src/lib/formatAvailableServices.ts +0 -91
- package/src/lib/formatDate.ts +0 -20
- package/src/lib/formatSeatMaps.ts +0 -81
- package/src/lib/getBaggageServiceDescription.ts +0 -39
- package/src/lib/getCabinsForSegmentAndDeck.ts +0 -4
- package/src/lib/getCurrencyForSeatMaps.ts +0 -22
- package/src/lib/getCurrencyForServices.ts +0 -24
- package/src/lib/getFirstSeatElementMatchingCriteria.ts +0 -22
- package/src/lib/getPassengerBySegmentList.ts +0 -10
- package/src/lib/getPassengerInitials.ts +0 -6
- package/src/lib/getPassengerMapById.ts +0 -17
- package/src/lib/getPassengerName.ts +0 -41
- package/src/lib/getRowNumber.ts +0 -16
- package/src/lib/getSegmentList.ts +0 -7
- package/src/lib/getServicePriceMapById.ts +0 -20
- package/src/lib/getSymbols.ts +0 -22
- package/src/lib/getTotalAmountForServices.ts +0 -72
- package/src/lib/getTotalQuantity.ts +0 -5
- package/src/lib/hasHighLuminance.ts +0 -9
- package/src/lib/hasService.ts +0 -24
- package/src/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.ts +0 -35
- package/src/lib/hasWings.ts +0 -8
- package/src/lib/isBaggageService.ts +0 -8
- package/src/lib/isCancelForAnyReasonService.ts +0 -9
- package/src/lib/isFixtureOfferId.ts +0 -4
- package/src/lib/isPayloadComplete.ts +0 -11
- package/src/lib/isSeatElement.ts +0 -10
- package/src/lib/logging.ts +0 -120
- package/src/lib/moneyStringFormatter.ts +0 -34
- package/src/lib/offerIsExpired.ts +0 -5
- package/src/lib/retrieveOffer.ts +0 -56
- package/src/lib/retrieveOfferFromDuffelAPI.ts +0 -13
- package/src/lib/retrieveSeatMaps.ts +0 -55
- package/src/lib/retrieveSeatMapsFromDuffelAPI.ts +0 -13
- package/src/lib/setBodyScrollability.ts +0 -7
- package/src/lib/validateProps.ts +0 -37
- package/src/lib/withPlural.ts +0 -8
- package/src/stories/BaggageSelectionModalHeader.stories.tsx +0 -21
- package/src/stories/Button.stories.tsx +0 -91
- package/src/stories/DuffelAncillaries.stories.tsx +0 -166
- package/src/stories/DuffelPayments.stories.tsx +0 -34
- package/src/stories/Icon.stories.tsx +0 -35
- package/src/stories/IconButton.stories.tsx +0 -25
- package/src/stories/PlacesLookup.stories.tsx +0 -22
- package/src/styles/colors.css +0 -22
- package/src/styles/components/Amenity.css +0 -23
- package/src/styles/components/BaggageDisplay.css +0 -25
- package/src/styles/components/Button.css +0 -169
- package/src/styles/components/Card.css +0 -52
- package/src/styles/components/CfarSelectionModal.css +0 -34
- package/src/styles/components/Counter.css +0 -18
- package/src/styles/components/DuffelPayments.css +0 -42
- package/src/styles/components/IconButton.css +0 -63
- package/src/styles/components/Legend.css +0 -62
- package/src/styles/components/Loader.css +0 -37
- package/src/styles/components/LoadingState.css +0 -87
- package/src/styles/components/Modal.css +0 -84
- package/src/styles/components/PassengerSelect.css +0 -99
- package/src/styles/components/PassengersLayout.css +0 -90
- package/src/styles/components/PlacesLookup.css +0 -36
- package/src/styles/components/Row.css +0 -70
- package/src/styles/components/Seat.css +0 -59
- package/src/styles/components/SeatInfo.css +0 -61
- package/src/styles/components/SeatMap.css +0 -24
- package/src/styles/components/SeatSelect.css +0 -92
- package/src/styles/components/Segment.css +0 -17
- package/src/styles/components/SelectionSegment.css +0 -10
- package/src/styles/components/Summary.css +0 -70
- package/src/styles/components/Tabs.css +0 -52
- package/src/styles/flex.css +0 -5
- package/src/styles/font-families.css +0 -47
- package/src/styles/global.css +0 -52
- package/src/styles/margin.css +0 -3
- package/src/styles/spacing.css +0 -18
- package/src/styles/transitions.css +0 -3
- package/src/styles/typography.css +0 -13
- package/src/tests/components/DuffelAncillaries.test.tsx +0 -342
- package/src/tests/lib/createPriceFormatters.test.tsx +0 -152
- package/src/tests/lib/formatAvailableServices.test.tsx +0 -79
- package/src/tests/lib/formatSeatMaps.test.tsx +0 -49
- package/src/tests/lib/getCurrencyForServices.test.tsx +0 -44
- package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +0 -86
- package/src/tests/lib/logging.test.tsx +0 -32
- package/src/tests/lib/moneyStringFormatter.test.tsx +0 -12
- package/src/tests/lib/validateProps.test.tsx +0 -57
- package/src/types/Aircraft.ts +0 -16
- package/src/types/Airline.ts +0 -16
- package/src/types/Airport.ts +0 -54
- package/src/types/City.ts +0 -21
- package/src/types/CreateOrderPayload.ts +0 -99
- package/src/types/CurrencyConversion.ts +0 -10
- package/src/types/DuffelAncillariesProps.ts +0 -108
- package/src/types/Offer.ts +0 -851
- package/src/types/Order.ts +0 -6
- package/src/types/Place.ts +0 -6
- package/src/types/SeatMap.ts +0 -231
- package/src/types/index.ts +0 -11
- package/tsconfig.json +0 -58
- /package/{react-dist/components → components}/DuffelAncillaries/Card.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/Counter.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/DuffelAncillaries.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/DuffelAncillariesCustomElement.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionCard.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionController.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionModal.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionModalBody.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionModalBodyPassenger.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionModalFooter.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/BaggageSelectionModalHeader.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/bags/IncludedBaggageBanner.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/cancel_for_any_reason/CfarSelectionCard.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModal.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBody.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/Amenity.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/DeckSelect.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/Element.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/EmptyElement.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/ExitElement.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/Legend.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/Row.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/RowSection.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatElement.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatInfo.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatMap.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatMapUnavailable.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatSelectionCard.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatSelectionModal.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatSelectionModalBody.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatSelectionModalFooter.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatSelectionModalHeader.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelAncillaries/seats/SeatUnavailable.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelPayments/DuffelPayments.d.ts +0 -0
- /package/{react-dist/components → components}/DuffelPayments/DuffelPaymentsCustomElement.d.ts +0 -0
- /package/{react-dist/components → components}/PlacesLookup/PlacesLookup.d.ts +0 -0
- /package/{react-dist/components → components}/shared/AnimatedLoaderEllipsis.d.ts +0 -0
- /package/{react-dist/components → components}/shared/Button.d.ts +0 -0
- /package/{react-dist/components → components}/shared/ErrorBoundary.d.ts +0 -0
- /package/{react-dist/components → components}/shared/FetchOfferErrorState.d.ts +0 -0
- /package/{react-dist/components → components}/shared/Icon.d.ts +0 -0
- /package/{react-dist/components → components}/shared/IconButton.d.ts +0 -0
- /package/{react-dist/components → components}/shared/Modal.d.ts +0 -0
- /package/{react-dist/components → components}/shared/NonIdealState.d.ts +0 -0
- /package/{react-dist/components → components}/shared/Stamp.d.ts +0 -0
- /package/{react-dist/components → components}/shared/Tabs.d.ts +0 -0
- /package/{react-dist/custom-elements.d.ts → custom-elements.d.ts} +0 -0
- /package/{react-dist/index.d.ts → index.d.ts} +0 -0
- /package/{react-dist/lib → lib}/captureErrorInSentry.d.ts +0 -0
- /package/{react-dist/lib → lib}/compileCreateOrderPayload.d.ts +0 -0
- /package/{react-dist/lib → lib}/createPriceFormatters.d.ts +0 -0
- /package/{react-dist/lib → lib}/fetchFromDuffelAPI.d.ts +0 -0
- /package/{react-dist/lib → lib}/fetchFromFixtures.d.ts +0 -0
- /package/{react-dist/lib → lib}/formatAvailableServices.d.ts +0 -0
- /package/{react-dist/lib → lib}/formatDate.d.ts +0 -0
- /package/{react-dist/lib → lib}/formatSeatMaps.d.ts +0 -0
- /package/{react-dist/lib → lib}/getBaggageServiceDescription.d.ts +0 -0
- /package/{react-dist/lib → lib}/getCabinsForSegmentAndDeck.d.ts +0 -0
- /package/{react-dist/lib → lib}/getCurrencyForSeatMaps.d.ts +0 -0
- /package/{react-dist/lib → lib}/getCurrencyForServices.d.ts +0 -0
- /package/{react-dist/lib → lib}/getFirstSeatElementMatchingCriteria.d.ts +0 -0
- /package/{react-dist/lib → lib}/getPassengerBySegmentList.d.ts +0 -0
- /package/{react-dist/lib → lib}/getPassengerInitials.d.ts +0 -0
- /package/{react-dist/lib → lib}/getPassengerMapById.d.ts +0 -0
- /package/{react-dist/lib → lib}/getPassengerName.d.ts +0 -0
- /package/{react-dist/lib → lib}/getRowNumber.d.ts +0 -0
- /package/{react-dist/lib → lib}/getSegmentList.d.ts +0 -0
- /package/{react-dist/lib → lib}/getServicePriceMapById.d.ts +0 -0
- /package/{react-dist/lib → lib}/getSymbols.d.ts +0 -0
- /package/{react-dist/lib → lib}/getTotalAmountForServices.d.ts +0 -0
- /package/{react-dist/lib → lib}/getTotalQuantity.d.ts +0 -0
- /package/{react-dist/lib → lib}/hasHighLuminance.d.ts +0 -0
- /package/{react-dist/lib → lib}/hasService.d.ts +0 -0
- /package/{react-dist/lib → lib}/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +0 -0
- /package/{react-dist/lib → lib}/hasWings.d.ts +0 -0
- /package/{react-dist/lib → lib}/isBaggageService.d.ts +0 -0
- /package/{react-dist/lib → lib}/isCancelForAnyReasonService.d.ts +0 -0
- /package/{react-dist/lib → lib}/isFixtureOfferId.d.ts +0 -0
- /package/{react-dist/lib → lib}/isPayloadComplete.d.ts +0 -0
- /package/{react-dist/lib → lib}/isSeatElement.d.ts +0 -0
- /package/{react-dist/lib → lib}/logging.d.ts +0 -0
- /package/{react-dist/lib → lib}/moneyStringFormatter.d.ts +0 -0
- /package/{react-dist/lib → lib}/offerIsExpired.d.ts +0 -0
- /package/{react-dist/lib → lib}/retrieveOffer.d.ts +0 -0
- /package/{react-dist/lib → lib}/retrieveOfferFromDuffelAPI.d.ts +0 -0
- /package/{react-dist/lib → lib}/retrieveSeatMaps.d.ts +0 -0
- /package/{react-dist/lib → lib}/retrieveSeatMapsFromDuffelAPI.d.ts +0 -0
- /package/{react-dist/lib → lib}/setBodyScrollability.d.ts +0 -0
- /package/{react-dist/lib → lib}/validateProps.d.ts +0 -0
- /package/{react-dist/lib → lib}/withPlural.d.ts +0 -0
- /package/{react-dist/types → types}/Aircraft.d.ts +0 -0
- /package/{react-dist/types → types}/Airline.d.ts +0 -0
- /package/{react-dist/types → types}/Airport.d.ts +0 -0
- /package/{react-dist/types → types}/City.d.ts +0 -0
- /package/{react-dist/types → types}/CreateOrderPayload.d.ts +0 -0
- /package/{react-dist/types → types}/CurrencyConversion.d.ts +0 -0
- /package/{react-dist/types → types}/DuffelAncillariesProps.d.ts +0 -0
- /package/{react-dist/types → types}/Offer.d.ts +0 -0
- /package/{react-dist/types → types}/Order.d.ts +0 -0
- /package/{react-dist/types → types}/Place.d.ts +0 -0
- /package/{react-dist/types → types}/SeatMap.d.ts +0 -0
- /package/{react-dist/types → types}/index.d.ts +0 -0
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Icon, IconName } from "@components/shared/Icon";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
export interface CardProps {
|
|
6
|
-
buttonTitle: string;
|
|
7
|
-
title: string;
|
|
8
|
-
icon: IconName;
|
|
9
|
-
onClick?: (() => void) | null;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
copy: string;
|
|
12
|
-
isLoading?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
isSelected?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Card: React.FC<CardProps> = ({
|
|
18
|
-
buttonTitle,
|
|
19
|
-
title,
|
|
20
|
-
icon,
|
|
21
|
-
copy,
|
|
22
|
-
onClick,
|
|
23
|
-
children,
|
|
24
|
-
isLoading,
|
|
25
|
-
disabled,
|
|
26
|
-
isSelected,
|
|
27
|
-
}) => {
|
|
28
|
-
const hasChildren = React.Children.toArray(children).length > 0;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<button
|
|
32
|
-
title={buttonTitle}
|
|
33
|
-
{...(onClick && { onClick })}
|
|
34
|
-
disabled={disabled}
|
|
35
|
-
className={classNames(
|
|
36
|
-
"ancillary-card",
|
|
37
|
-
isLoading && "ancillary-card--loading"
|
|
38
|
-
)}
|
|
39
|
-
// We are using inline styles here because
|
|
40
|
-
// we don't want the cards to appear unstyled
|
|
41
|
-
// before the CSS stylesheet loads.
|
|
42
|
-
// This is important for this component since it
|
|
43
|
-
// be on visible on the page when it loads.
|
|
44
|
-
style={{
|
|
45
|
-
cursor: "pointer",
|
|
46
|
-
background: "transparent",
|
|
47
|
-
color: "var(--GREY-900)",
|
|
48
|
-
border: "solid 1px rgba(226, 226, 232, 1)",
|
|
49
|
-
display: "flex",
|
|
50
|
-
rowGap: "4px",
|
|
51
|
-
padding: "20px",
|
|
52
|
-
borderRadius: "8px",
|
|
53
|
-
justifyContent: "space-between",
|
|
54
|
-
flexWrap: "wrap",
|
|
55
|
-
flexDirection: "column",
|
|
56
|
-
width: "100%",
|
|
57
|
-
boxSizing: "border-box",
|
|
58
|
-
fontSize: "16px",
|
|
59
|
-
fontWeight: "400",
|
|
60
|
-
lineHeight: "24px",
|
|
61
|
-
letterSpacing: "0em",
|
|
62
|
-
transition:
|
|
63
|
-
"border-color 0.3s var(--TRANSITION-CUBIC-BEZIER) background-color 0.3s var(--TRANSITION-CUBIC-BEZIER)",
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
66
|
-
<div
|
|
67
|
-
style={{
|
|
68
|
-
display: "flex",
|
|
69
|
-
alignItems: "flex-start",
|
|
70
|
-
marginBlock: "0",
|
|
71
|
-
textAlign: "start",
|
|
72
|
-
marginTop: "2px",
|
|
73
|
-
columnGap: "12px",
|
|
74
|
-
width: "100%",
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<div>
|
|
78
|
-
{isSelected ? (
|
|
79
|
-
<Icon name="check" className="ancillary-card__selected-icon" />
|
|
80
|
-
) : (
|
|
81
|
-
<Icon name={icon} />
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
<div
|
|
86
|
-
style={{
|
|
87
|
-
display: "flex",
|
|
88
|
-
justifyContent: "space-between",
|
|
89
|
-
alignItems: "start",
|
|
90
|
-
width: "100%",
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<p
|
|
94
|
-
className="p1--semibold"
|
|
95
|
-
style={{
|
|
96
|
-
marginBlock: "0",
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
{title}
|
|
100
|
-
</p>
|
|
101
|
-
<div className="ancillary-card__children">
|
|
102
|
-
{hasChildren ? (
|
|
103
|
-
children
|
|
104
|
-
) : (
|
|
105
|
-
<Icon
|
|
106
|
-
name="expand_content"
|
|
107
|
-
className="ancillary-card__expand-icon"
|
|
108
|
-
/>
|
|
109
|
-
)}
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
<p
|
|
114
|
-
className="p1--regular"
|
|
115
|
-
style={{
|
|
116
|
-
textAlign: "start",
|
|
117
|
-
color: "var(--GREY-600)",
|
|
118
|
-
marginLeft: "34px",
|
|
119
|
-
marginBlock: "0",
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
122
|
-
{copy}
|
|
123
|
-
</p>
|
|
124
|
-
</button>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IconButton } from "@components/shared/IconButton";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
interface CounterProps {
|
|
5
|
-
id: string;
|
|
6
|
-
min: number;
|
|
7
|
-
max: number;
|
|
8
|
-
value: number;
|
|
9
|
-
onChange: (value: number) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Counter: React.FC<CounterProps> = ({
|
|
13
|
-
id,
|
|
14
|
-
min,
|
|
15
|
-
max,
|
|
16
|
-
value,
|
|
17
|
-
onChange,
|
|
18
|
-
}) => (
|
|
19
|
-
<div className="counter" id={id}>
|
|
20
|
-
<IconButton
|
|
21
|
-
icon="minus"
|
|
22
|
-
title="Remove one"
|
|
23
|
-
id={`${id}-minus`}
|
|
24
|
-
data-testid={`${id}-minus`}
|
|
25
|
-
variant="outlined"
|
|
26
|
-
disabled={value <= min}
|
|
27
|
-
onClick={() => onChange(Math.max(value - 1, min))}
|
|
28
|
-
/>
|
|
29
|
-
<div className="counter__count-label">{value}</div>
|
|
30
|
-
<IconButton
|
|
31
|
-
icon="add"
|
|
32
|
-
title="Add one"
|
|
33
|
-
id={`${id}-plus`}
|
|
34
|
-
data-testid={`${id}-plus`}
|
|
35
|
-
variant="outlined"
|
|
36
|
-
disabled={value >= max}
|
|
37
|
-
onClick={() => onChange(Math.min(value + 1, max))}
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { ErrorBoundary } from "@components/shared/ErrorBoundary";
|
|
2
|
-
import { FetchOfferErrorState } from "@components/shared/FetchOfferErrorState";
|
|
3
|
-
import { compileCreateOrderPayload } from "@lib/compileCreateOrderPayload";
|
|
4
|
-
import { createPriceFormatters } from "@lib/createPriceFormatters";
|
|
5
|
-
import { formatAvailableServices } from "@lib/formatAvailableServices";
|
|
6
|
-
import { formatSeatMaps } from "@lib/formatSeatMaps";
|
|
7
|
-
import { hasHighLuminance } from "@lib/hasHighLuminance";
|
|
8
|
-
import { isPayloadComplete } from "@lib/isPayloadComplete";
|
|
9
|
-
import { initializeLogger, logGroup } from "@lib/logging";
|
|
10
|
-
import { offerIsExpired } from "@lib/offerIsExpired";
|
|
11
|
-
import { retrieveOffer } from "@lib/retrieveOffer";
|
|
12
|
-
import { retrieveSeatMaps } from "@lib/retrieveSeatMaps";
|
|
13
|
-
import {
|
|
14
|
-
areDuffelAncillariesPropsValid,
|
|
15
|
-
isDuffelAncillariesPropsWithClientKeyAndOfferId,
|
|
16
|
-
isDuffelAncillariesPropsWithOfferAndClientKey,
|
|
17
|
-
isDuffelAncillariesPropsWithOfferAndSeatMaps,
|
|
18
|
-
isDuffelAncillariesPropsWithOfferIdForFixture,
|
|
19
|
-
} from "@lib/validateProps";
|
|
20
|
-
import * as Sentry from "@sentry/browser";
|
|
21
|
-
import * as React from "react";
|
|
22
|
-
import {
|
|
23
|
-
CreateOrderPayloadPassengers,
|
|
24
|
-
CreateOrderPayloadService,
|
|
25
|
-
} from "../../types/CreateOrderPayload";
|
|
26
|
-
import { DuffelAncillariesProps } from "../../types/DuffelAncillariesProps";
|
|
27
|
-
import { Offer } from "../../types/Offer";
|
|
28
|
-
import { SeatMap } from "../../types/SeatMap";
|
|
29
|
-
import { BaggageSelectionCard } from "./bags/BaggageSelectionCard";
|
|
30
|
-
import { CfarSelectionCard } from "./cancel_for_any_reason/CfarSelectionCard";
|
|
31
|
-
import { SeatSelectionCard } from "./seats/SeatSelectionCard";
|
|
32
|
-
|
|
33
|
-
const COMPONENT_CDN = process.env.COMPONENT_CDN || "";
|
|
34
|
-
const hrefToComponentStyles = `${COMPONENT_CDN}/global.css`;
|
|
35
|
-
|
|
36
|
-
export const DuffelAncillaries: React.FC<DuffelAncillariesProps> = (props) => {
|
|
37
|
-
initializeLogger(props.debug || false);
|
|
38
|
-
|
|
39
|
-
logGroup("Properties passed into the component:", props);
|
|
40
|
-
|
|
41
|
-
if (!areDuffelAncillariesPropsValid(props)) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
`The props (${Object.keys(
|
|
44
|
-
props
|
|
45
|
-
)}) passed to DuffelAncillaries are invalid. ` +
|
|
46
|
-
"`onPayloadReady`, `passengers` and `services` are always required. " +
|
|
47
|
-
"Then, depending on your use case you may have one of the following combinations of required props: " +
|
|
48
|
-
"`offer_id` and `client_key`, `offer` and `seat_maps` or `offer` and `client_key`." +
|
|
49
|
-
"Please refer to the documentation for more information and working examples: " +
|
|
50
|
-
"https://duffel.com/docs/guides/ancillaries-component"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (props.services.length === 0) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`You must provide at least one service in the "services" prop. Valid services: ["bags", "seats", "cancel_for_any_reason"]`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const isPropsWithOfferIdForFixture =
|
|
60
|
-
isDuffelAncillariesPropsWithOfferIdForFixture(props);
|
|
61
|
-
|
|
62
|
-
const isPropsWithClientKeyAndOfferId =
|
|
63
|
-
isDuffelAncillariesPropsWithClientKeyAndOfferId(props);
|
|
64
|
-
|
|
65
|
-
const isPropsWithOfferAndSeatMaps =
|
|
66
|
-
isDuffelAncillariesPropsWithOfferAndSeatMaps(props);
|
|
67
|
-
|
|
68
|
-
const isPropsWithOfferAndClientKey =
|
|
69
|
-
isDuffelAncillariesPropsWithOfferAndClientKey(props);
|
|
70
|
-
|
|
71
|
-
const shouldRetrieveSeatMaps =
|
|
72
|
-
props.services.includes("seats") &&
|
|
73
|
-
!("seat_maps" in props) &&
|
|
74
|
-
(isPropsWithOfferIdForFixture ||
|
|
75
|
-
isPropsWithClientKeyAndOfferId ||
|
|
76
|
-
isPropsWithOfferAndClientKey);
|
|
77
|
-
|
|
78
|
-
const [passengers, setPassengers] =
|
|
79
|
-
React.useState<CreateOrderPayloadPassengers>(props.passengers);
|
|
80
|
-
|
|
81
|
-
const [offer, setOffer] = React.useState<Offer | undefined>(
|
|
82
|
-
(props as any).offer
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const [isOfferLoading, setIsOfferLoading] = React.useState(
|
|
86
|
-
isPropsWithClientKeyAndOfferId
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const [seatMaps, setSeatMaps] = React.useState<SeatMap[] | undefined>(
|
|
90
|
-
isPropsWithOfferAndSeatMaps ? props.seat_maps : undefined
|
|
91
|
-
);
|
|
92
|
-
const [isSeatMapLoading, setIsSeatMapLoading] = React.useState(
|
|
93
|
-
shouldRetrieveSeatMaps
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const [error, setError] = React.useState<null | string>(null);
|
|
97
|
-
|
|
98
|
-
const [baggageSelectedServices, setBaggageSelectedServices] = React.useState(
|
|
99
|
-
new Array<CreateOrderPayloadService>()
|
|
100
|
-
);
|
|
101
|
-
const [seatSelectedServices, setSeatSelectedServices] = React.useState(
|
|
102
|
-
new Array<CreateOrderPayloadService>()
|
|
103
|
-
);
|
|
104
|
-
const [cfarSelectedServices, setCfarSelectedServices] = React.useState(
|
|
105
|
-
new Array<CreateOrderPayloadService>()
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const priceFormatters = createPriceFormatters(
|
|
109
|
-
props.markup,
|
|
110
|
-
props.priceFormatters
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const updateOffer = (offer: Offer) => {
|
|
114
|
-
const expiryErrorMessage = "This offer has expired.";
|
|
115
|
-
if (offerIsExpired(offer)) {
|
|
116
|
-
setError(expiryErrorMessage);
|
|
117
|
-
return;
|
|
118
|
-
} else {
|
|
119
|
-
const msUntilExpiry = new Date(offer?.expires_at)?.getTime() - Date.now();
|
|
120
|
-
|
|
121
|
-
// Only show the expiry error message if the offer expires in less than a day,
|
|
122
|
-
// to prevent buffer overflows when showing offers for fixtures, which expire in
|
|
123
|
-
// years.
|
|
124
|
-
const milisecondsInOneDay = 1000 * 60 * 60 * 24;
|
|
125
|
-
if (msUntilExpiry < milisecondsInOneDay) {
|
|
126
|
-
setTimeout(() => setError(expiryErrorMessage), msUntilExpiry);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const offerWithFormattedServices = formatAvailableServices(
|
|
131
|
-
offer,
|
|
132
|
-
priceFormatters
|
|
133
|
-
);
|
|
134
|
-
setOffer(offerWithFormattedServices);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const updateSeatMaps = (seatMaps: SeatMap[]) => {
|
|
138
|
-
const formattedSeatMaps = formatSeatMaps(seatMaps, priceFormatters.seats);
|
|
139
|
-
setSeatMaps(formattedSeatMaps);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
React.useEffect(() => {
|
|
143
|
-
// whenever the props change, we'll set the sentry context to thse values
|
|
144
|
-
// so that we can see them in the sentry logs and better support the users of the component library
|
|
145
|
-
Sentry.setContext("props", {
|
|
146
|
-
"props.services": props.services,
|
|
147
|
-
"props.passengers.length": (props as any).passengers.length,
|
|
148
|
-
"props.offer_id": (props as any).offer_id,
|
|
149
|
-
"props.client_key": (props as any).client_key,
|
|
150
|
-
"props.offer?.id": (props as any).offer?.id,
|
|
151
|
-
"props.seat_maps?.[0]?.id": (props as any).seat_maps?.[0]?.id,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (isPropsWithClientKeyAndOfferId || isPropsWithOfferIdForFixture) {
|
|
155
|
-
retrieveOffer(
|
|
156
|
-
props.offer_id,
|
|
157
|
-
!isPropsWithOfferIdForFixture ? props.client_key : null,
|
|
158
|
-
setError,
|
|
159
|
-
setIsOfferLoading,
|
|
160
|
-
(offer) => {
|
|
161
|
-
updateOffer(offer);
|
|
162
|
-
|
|
163
|
-
if (offer.passengers.length !== passengers.length) {
|
|
164
|
-
throw new Error(
|
|
165
|
-
`The number of passengers given to \`duffel-ancillaries\` (${props.passengers.length}) doesn't match ` +
|
|
166
|
-
`the number of passengers on the given offer (${offer.passengers.length}).`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (isPropsWithOfferIdForFixture) {
|
|
171
|
-
// There's no way the component users will know the passenger IDs for the fixture offer
|
|
172
|
-
// so we'll need to add them here
|
|
173
|
-
setPassengers(
|
|
174
|
-
props.passengers.map((passenger, index) => ({
|
|
175
|
-
...passenger,
|
|
176
|
-
id: offer.passengers[index].id,
|
|
177
|
-
}))
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (shouldRetrieveSeatMaps) {
|
|
185
|
-
retrieveSeatMaps(
|
|
186
|
-
isPropsWithClientKeyAndOfferId || isPropsWithOfferIdForFixture
|
|
187
|
-
? props.offer_id
|
|
188
|
-
: props.offer.id,
|
|
189
|
-
!isPropsWithOfferIdForFixture ? props.client_key : null,
|
|
190
|
-
() => updateSeatMaps([]),
|
|
191
|
-
setIsSeatMapLoading,
|
|
192
|
-
updateSeatMaps
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (isPropsWithOfferAndClientKey) {
|
|
197
|
-
updateOffer(props.offer);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (isPropsWithOfferAndSeatMaps) {
|
|
201
|
-
updateOffer(props.offer);
|
|
202
|
-
updateSeatMaps(props.seat_maps);
|
|
203
|
-
}
|
|
204
|
-
}, [
|
|
205
|
-
// `as any` is needed here because the list
|
|
206
|
-
// of dependencies is different for each combination of props.
|
|
207
|
-
// To satisfy typescript, we'd need to conditionally assign
|
|
208
|
-
// the dependencies to the hook after checking its type,
|
|
209
|
-
// however that is not possible in a react hook.
|
|
210
|
-
(props as any).offer_id,
|
|
211
|
-
(props as any).client_key,
|
|
212
|
-
(props as any).offer?.id,
|
|
213
|
-
(props as any).seat_maps?.[0]?.id,
|
|
214
|
-
]);
|
|
215
|
-
|
|
216
|
-
React.useEffect(() => {
|
|
217
|
-
if (!offer) return;
|
|
218
|
-
|
|
219
|
-
const createOrderPayload = compileCreateOrderPayload({
|
|
220
|
-
baggageSelectedServices,
|
|
221
|
-
seatSelectedServices,
|
|
222
|
-
cfarSelectedServices,
|
|
223
|
-
offer,
|
|
224
|
-
passengers,
|
|
225
|
-
seatMaps,
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
if (isPayloadComplete(createOrderPayload)) {
|
|
229
|
-
const metadata = {
|
|
230
|
-
offer_total_amount: offer.total_amount,
|
|
231
|
-
offer_total_currency: offer.total_currency,
|
|
232
|
-
offer_tax_amount: offer.tax_amount,
|
|
233
|
-
offer_tax_currency: offer.tax_currency,
|
|
234
|
-
baggage_services: baggageSelectedServices,
|
|
235
|
-
seat_services: seatSelectedServices,
|
|
236
|
-
cancel_for_any_reason_services: cfarSelectedServices,
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
logGroup("Payload ready", {
|
|
240
|
-
"Order creation payload": createOrderPayload,
|
|
241
|
-
"Services metadata": metadata,
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
props.onPayloadReady(createOrderPayload, metadata);
|
|
245
|
-
}
|
|
246
|
-
}, [baggageSelectedServices, seatSelectedServices, cfarSelectedServices]);
|
|
247
|
-
|
|
248
|
-
if (!areDuffelAncillariesPropsValid(props)) {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const nonIdealStateHeight = `${
|
|
253
|
-
// 72 (card height) + 32 gap between cards
|
|
254
|
-
72 * props.services.length + 32 * (props.services.length - 1)
|
|
255
|
-
}px`;
|
|
256
|
-
|
|
257
|
-
const duffelComponentsStyle = {
|
|
258
|
-
// Adding inline styles here to avoid the cards jumping down
|
|
259
|
-
// before the css is loaded duet to the missing "row gap".
|
|
260
|
-
display: "flex",
|
|
261
|
-
width: "100%",
|
|
262
|
-
flexDirection: "column",
|
|
263
|
-
rowGap: "12px",
|
|
264
|
-
...(props.styles?.accentColor && {
|
|
265
|
-
"--ACCENT": props.styles.accentColor,
|
|
266
|
-
}),
|
|
267
|
-
...(props.styles?.accentColor &&
|
|
268
|
-
hasHighLuminance(props.styles.accentColor) && {
|
|
269
|
-
"--SECONDARY": "var(--GREY-900)",
|
|
270
|
-
"--TERTIARY": "var(--GREY-400)",
|
|
271
|
-
}),
|
|
272
|
-
...(props.styles?.fontFamily && {
|
|
273
|
-
"--FONT-FAMILY": props.styles.fontFamily,
|
|
274
|
-
}),
|
|
275
|
-
...(props.styles?.buttonCornerRadius && {
|
|
276
|
-
"--BUTTON-RADIUS": props.styles.buttonCornerRadius,
|
|
277
|
-
}),
|
|
278
|
-
// `as any` is needed here is needed because we want to set css variables
|
|
279
|
-
// that are not part of the css properties type
|
|
280
|
-
} as any;
|
|
281
|
-
|
|
282
|
-
const state = {
|
|
283
|
-
isOfferLoading,
|
|
284
|
-
isSeatMapLoading,
|
|
285
|
-
baggageSelectedServices,
|
|
286
|
-
seatSelectedServices,
|
|
287
|
-
cfarSelectedServices,
|
|
288
|
-
offer,
|
|
289
|
-
seatMaps,
|
|
290
|
-
error,
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
logGroup("Component's internal state:", state);
|
|
294
|
-
|
|
295
|
-
return (
|
|
296
|
-
<>
|
|
297
|
-
<link rel="stylesheet" href={hrefToComponentStyles}></link>
|
|
298
|
-
|
|
299
|
-
<div className="duffel-components" style={duffelComponentsStyle}>
|
|
300
|
-
<ErrorBoundary>
|
|
301
|
-
{error && (
|
|
302
|
-
<FetchOfferErrorState
|
|
303
|
-
height={nonIdealStateHeight}
|
|
304
|
-
message={error}
|
|
305
|
-
/>
|
|
306
|
-
)}
|
|
307
|
-
|
|
308
|
-
{!error &&
|
|
309
|
-
props.services.map((ancillaryName) => {
|
|
310
|
-
if (ancillaryName === "bags")
|
|
311
|
-
return (
|
|
312
|
-
<BaggageSelectionCard
|
|
313
|
-
key="bags"
|
|
314
|
-
isLoading={isOfferLoading}
|
|
315
|
-
offer={offer}
|
|
316
|
-
passengers={passengers}
|
|
317
|
-
selectedServices={baggageSelectedServices}
|
|
318
|
-
setSelectedServices={setBaggageSelectedServices}
|
|
319
|
-
/>
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
if (ancillaryName === "seats")
|
|
323
|
-
return (
|
|
324
|
-
<SeatSelectionCard
|
|
325
|
-
key="seats"
|
|
326
|
-
isLoading={isOfferLoading || isSeatMapLoading}
|
|
327
|
-
seatMaps={seatMaps}
|
|
328
|
-
offer={offer}
|
|
329
|
-
passengers={passengers}
|
|
330
|
-
selectedServices={seatSelectedServices}
|
|
331
|
-
setSelectedServices={setSeatSelectedServices}
|
|
332
|
-
/>
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
if (ancillaryName === "cancel_for_any_reason")
|
|
336
|
-
return (
|
|
337
|
-
<CfarSelectionCard
|
|
338
|
-
key="cancel_for_any_reason"
|
|
339
|
-
isLoading={isOfferLoading}
|
|
340
|
-
offer={offer}
|
|
341
|
-
selectedServices={cfarSelectedServices}
|
|
342
|
-
setSelectedServices={setCfarSelectedServices}
|
|
343
|
-
/>
|
|
344
|
-
);
|
|
345
|
-
})}
|
|
346
|
-
</ErrorBoundary>
|
|
347
|
-
</div>
|
|
348
|
-
</>
|
|
349
|
-
);
|
|
350
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { createRoot, Root } from "react-dom/client";
|
|
2
|
-
import { CreateOrderPayload } from "../../types/CreateOrderPayload";
|
|
3
|
-
import {
|
|
4
|
-
DuffelAncillariesPropsWithClientKeyAndOfferId,
|
|
5
|
-
DuffelAncillariesPropsWithOfferIdForFixture,
|
|
6
|
-
DuffelAncillariesPropsWithOffersAndSeatMaps,
|
|
7
|
-
DuffelAncillariesPropWithOfferAndClientKey,
|
|
8
|
-
OnPayloadReady,
|
|
9
|
-
OnPayloadReadyMetadata,
|
|
10
|
-
} from "../../types/DuffelAncillariesProps";
|
|
11
|
-
import { DuffelAncillaries } from "./DuffelAncillaries";
|
|
12
|
-
|
|
13
|
-
declare global {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
15
|
-
namespace JSX {
|
|
16
|
-
interface IntrinsicElements {
|
|
17
|
-
"duffel-ancillaries": React.DetailedHTMLProps<
|
|
18
|
-
React.HTMLAttributes<HTMLElement>,
|
|
19
|
-
HTMLElement
|
|
20
|
-
>;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const CUSTOM_ELEMENT_TAG = "duffel-ancillaries";
|
|
26
|
-
|
|
27
|
-
// A bit reptitive but typescript is not clever enough
|
|
28
|
-
// to infer the correct type if we just use
|
|
29
|
-
// `Omit<DuffelAncillariesProps, 'onPayloadReady'>`
|
|
30
|
-
type DuffelAncillariesCustomElementRenderArguments =
|
|
31
|
-
| Omit<DuffelAncillariesPropsWithOfferIdForFixture, "onPayloadReady">
|
|
32
|
-
| Omit<DuffelAncillariesPropsWithClientKeyAndOfferId, "onPayloadReady">
|
|
33
|
-
| Omit<DuffelAncillariesPropWithOfferAndClientKey, "onPayloadReady">
|
|
34
|
-
| Omit<DuffelAncillariesPropsWithOffersAndSeatMaps, "onPayloadReady">;
|
|
35
|
-
|
|
36
|
-
class DuffelAncillariesCustomElement extends HTMLElement {
|
|
37
|
-
/**
|
|
38
|
-
* The React root for displaying content inside a browser DOM element.
|
|
39
|
-
*/
|
|
40
|
-
private root!: Root;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* `connectedCallback` is called to initialise the custom element
|
|
44
|
-
*/
|
|
45
|
-
connectedCallback() {
|
|
46
|
-
const container = document.createElement("div");
|
|
47
|
-
this.attachShadow({ mode: "open" }).appendChild(container);
|
|
48
|
-
|
|
49
|
-
this.root = createRoot(container);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* When this function is called, it will render/re-render
|
|
54
|
-
* the `DuffelAncillaries` component with the given props.
|
|
55
|
-
*/
|
|
56
|
-
public render(withProps: DuffelAncillariesCustomElementRenderArguments) {
|
|
57
|
-
if (!this.root) {
|
|
58
|
-
throw "It was not possible to render `duffel-ancillaries` because `this.root` is missing.";
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
this.root.render(
|
|
62
|
-
<DuffelAncillaries
|
|
63
|
-
{...withProps}
|
|
64
|
-
onPayloadReady={(data, metadata) => {
|
|
65
|
-
this.dispatchEvent(
|
|
66
|
-
new CustomEvent("onPayloadReady", {
|
|
67
|
-
detail: { data, metadata },
|
|
68
|
-
composed: true,
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
}}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
window.customElements.get(CUSTOM_ELEMENT_TAG) ||
|
|
78
|
-
window.customElements.define(
|
|
79
|
-
CUSTOM_ELEMENT_TAG,
|
|
80
|
-
DuffelAncillariesCustomElement
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
function tryToGetDuffelAncillariesCustomElement(
|
|
84
|
-
caller: string
|
|
85
|
-
): DuffelAncillariesCustomElement {
|
|
86
|
-
const element =
|
|
87
|
-
document.querySelector<DuffelAncillariesCustomElement>(CUSTOM_ELEMENT_TAG);
|
|
88
|
-
if (!element) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`Could not find duffel-ancillaries element in the DOM. Maybe you need to call ${caller} after 'window.onload'?`
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
return element;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function renderDuffelAncillariesCustomElement(
|
|
97
|
-
props: DuffelAncillariesCustomElementRenderArguments
|
|
98
|
-
) {
|
|
99
|
-
const element = tryToGetDuffelAncillariesCustomElement(
|
|
100
|
-
"renderDuffelAncillariesCustomElement"
|
|
101
|
-
);
|
|
102
|
-
element.render(props);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
type OnPayloadReadyCustomEvent = CustomEvent<{
|
|
106
|
-
data: CreateOrderPayload;
|
|
107
|
-
metadata: OnPayloadReadyMetadata;
|
|
108
|
-
}>;
|
|
109
|
-
|
|
110
|
-
export function onDuffelAncillariesPayloadReady(
|
|
111
|
-
onPayloadReady: OnPayloadReady
|
|
112
|
-
) {
|
|
113
|
-
const element = tryToGetDuffelAncillariesCustomElement(
|
|
114
|
-
"onDuffelAncillariesPayloadReady"
|
|
115
|
-
);
|
|
116
|
-
const eventListener = (event: OnPayloadReadyCustomEvent) => {
|
|
117
|
-
onPayloadReady(event.detail.data, event.detail.metadata);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// using `as EventListener` here because typescript doesn't know the event type for `onPayloadReady`
|
|
121
|
-
// There's a few different suggestions to resolve this seemed good enough
|
|
122
|
-
// You can learn more here: https://github.com/microsoft/TypeScript/issues/28357
|
|
123
|
-
element.addEventListener("onPayloadReady", eventListener as EventListener);
|
|
124
|
-
}
|