@duffel/components 3.1.3--prototype.4 → 3.1.3--prototype.7
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 -3
- 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
package/src/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is the main entry point for the library -- `@duffel/components`.
|
|
3
|
-
* If you'd like to expose other react components, please add them here.
|
|
4
|
-
*/
|
|
5
|
-
export * from "./components/DuffelAncillaries/DuffelAncillaries";
|
|
6
|
-
export * from "./components/DuffelPayments/DuffelPayments";
|
|
7
|
-
export * from "./types";
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as Sentry from "@sentry/browser";
|
|
2
|
-
|
|
3
|
-
let hasSentryInitiated = false;
|
|
4
|
-
function initiateSentry() {
|
|
5
|
-
Sentry.init({
|
|
6
|
-
dsn: "https://903950caba7d4802afe6c1e985ad5ebd@o128085.ingest.sentry.io/4504854496149504",
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The release identifier used when uploading respective source maps. Specify
|
|
10
|
-
* this value to allow Sentry to resolve the correct source maps when
|
|
11
|
-
* processing events.
|
|
12
|
-
*/
|
|
13
|
-
release: process.env.COMPONENT_VERSION,
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* List of integrations that should be installed after SDK was initialized.
|
|
17
|
-
* Accepts either a list of integrations or a function that receives
|
|
18
|
-
* default integrations and returns a new, updated list.
|
|
19
|
-
*/
|
|
20
|
-
integrations: [new Sentry.BrowserTracing()],
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Sample rate to determine trace sampling.
|
|
24
|
-
*
|
|
25
|
-
* 0.0 = 0% chance of a given trace being sent (send no traces) 1.0 = 100% chance of a given trace being sent (send
|
|
26
|
-
* all traces)
|
|
27
|
-
*
|
|
28
|
-
* Tracing is enabled if either this or `tracesSampler` is defined. If both are defined, `tracesSampleRate` is
|
|
29
|
-
* ignored.
|
|
30
|
-
*/
|
|
31
|
-
tracesSampleRate: 1,
|
|
32
|
-
});
|
|
33
|
-
hasSentryInitiated = true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const captureErrorInSentry = (error: Error) => {
|
|
37
|
-
if (!hasSentryInitiated) {
|
|
38
|
-
initiateSentry();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return Sentry.captureException(error);
|
|
42
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateOrderPayload,
|
|
3
|
-
CreateOrderPayloadService,
|
|
4
|
-
CreateOrderPayloadServices,
|
|
5
|
-
} from "../types/CreateOrderPayload";
|
|
6
|
-
import { DuffelAncillariesProps } from "../types/DuffelAncillariesProps";
|
|
7
|
-
import { Offer } from "../types/Offer";
|
|
8
|
-
import { SeatMap } from "../types/SeatMap";
|
|
9
|
-
import { getTotalAmountForServices } from "./getTotalAmountForServices";
|
|
10
|
-
|
|
11
|
-
interface CompileCreateOrderPayloadInput {
|
|
12
|
-
offer: Offer;
|
|
13
|
-
passengers: DuffelAncillariesProps["passengers"];
|
|
14
|
-
baggageSelectedServices: CreateOrderPayloadServices;
|
|
15
|
-
seatSelectedServices: CreateOrderPayloadServices;
|
|
16
|
-
cfarSelectedServices: CreateOrderPayloadServices;
|
|
17
|
-
seatMaps?: SeatMap[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const compileCreateOrderPayload = ({
|
|
21
|
-
baggageSelectedServices,
|
|
22
|
-
seatSelectedServices,
|
|
23
|
-
cfarSelectedServices,
|
|
24
|
-
offer,
|
|
25
|
-
seatMaps,
|
|
26
|
-
passengers,
|
|
27
|
-
}: CompileCreateOrderPayloadInput): Partial<CreateOrderPayload> => {
|
|
28
|
-
const selectedServicesWithInformation = [
|
|
29
|
-
...baggageSelectedServices,
|
|
30
|
-
...seatSelectedServices,
|
|
31
|
-
...cfarSelectedServices,
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const totalAmountWithServices =
|
|
35
|
-
+offer.total_amount +
|
|
36
|
-
getTotalAmountForServices(offer, selectedServicesWithInformation, seatMaps);
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
...(offer && { selected_offers: [offer.id] }),
|
|
40
|
-
passengers,
|
|
41
|
-
services: filterServicesForPayload(selectedServicesWithInformation),
|
|
42
|
-
...(offer && {
|
|
43
|
-
payments: [
|
|
44
|
-
{
|
|
45
|
-
type: "balance",
|
|
46
|
-
amount: `${totalAmountWithServices}`,
|
|
47
|
-
currency: offer.total_currency,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}),
|
|
51
|
-
type: "instant",
|
|
52
|
-
metadata: { source: `duffel-ancillaries@${process.env.COMPONENT_VERSION}` },
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const filterServicesForPayload = (
|
|
57
|
-
selectedServices: CreateOrderPayloadServices
|
|
58
|
-
): Pick<CreateOrderPayloadService, "id" | "quantity">[] => {
|
|
59
|
-
if (!Array.isArray(selectedServices)) return [];
|
|
60
|
-
return selectedServices
|
|
61
|
-
.filter(({ quantity }) => quantity > 0)
|
|
62
|
-
.map(({ id, quantity }) => ({ id, quantity }));
|
|
63
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DuffelAncillariesMarkup,
|
|
3
|
-
DuffelAncillariesMarkupDefinition,
|
|
4
|
-
DuffelAncillariesPriceFormatters,
|
|
5
|
-
} from "src/types/DuffelAncillariesProps";
|
|
6
|
-
|
|
7
|
-
const convertMarkupIntoPriceFormatter = (
|
|
8
|
-
markup: DuffelAncillariesMarkupDefinition
|
|
9
|
-
) => {
|
|
10
|
-
return (amount: number, currency: string) => {
|
|
11
|
-
const { rate, amount: markupAmount } = markup;
|
|
12
|
-
const newAmount = amount * (1 + rate) + markupAmount;
|
|
13
|
-
return { amount: newAmount, currency };
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const errorMessage =
|
|
18
|
-
"You cannot supply both markup and priceFormatters for the same service.";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates price formatters from the markup and priceFormatters passed in.
|
|
22
|
-
* Throws an error if both are supplied.
|
|
23
|
-
* If neither are supplied, the priceFormatters will be undefined.
|
|
24
|
-
*
|
|
25
|
-
* @param markup The markup to be applied to the prices of the available services of an offer.
|
|
26
|
-
* @param priceFormatters Price formatters to apply to the prices of the available services of an offer.
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
const createPriceFormatters = (
|
|
30
|
-
markup?: DuffelAncillariesMarkup,
|
|
31
|
-
priceFormatters?: DuffelAncillariesPriceFormatters
|
|
32
|
-
): DuffelAncillariesPriceFormatters => {
|
|
33
|
-
const formatters: DuffelAncillariesPriceFormatters = {};
|
|
34
|
-
|
|
35
|
-
if (priceFormatters) {
|
|
36
|
-
if (priceFormatters.bags) {
|
|
37
|
-
formatters.bags = priceFormatters.bags;
|
|
38
|
-
}
|
|
39
|
-
if (priceFormatters.seats) {
|
|
40
|
-
formatters.seats = priceFormatters.seats;
|
|
41
|
-
}
|
|
42
|
-
if (priceFormatters.cancel_for_any_reason) {
|
|
43
|
-
formatters.cancel_for_any_reason = priceFormatters.cancel_for_any_reason;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Markup takes precedence over priceFormatters.
|
|
48
|
-
if (markup) {
|
|
49
|
-
if (markup.bags) {
|
|
50
|
-
if (priceFormatters && priceFormatters.bags) {
|
|
51
|
-
throw new Error(errorMessage);
|
|
52
|
-
}
|
|
53
|
-
formatters.bags = convertMarkupIntoPriceFormatter(markup.bags);
|
|
54
|
-
}
|
|
55
|
-
if (markup.seats) {
|
|
56
|
-
if (priceFormatters && priceFormatters.seats) {
|
|
57
|
-
throw new Error(errorMessage);
|
|
58
|
-
}
|
|
59
|
-
formatters.seats = convertMarkupIntoPriceFormatter(markup.seats);
|
|
60
|
-
}
|
|
61
|
-
if (markup.cancel_for_any_reason) {
|
|
62
|
-
if (priceFormatters && priceFormatters.cancel_for_any_reason) {
|
|
63
|
-
throw new Error(errorMessage);
|
|
64
|
-
}
|
|
65
|
-
formatters.cancel_for_any_reason = convertMarkupIntoPriceFormatter(
|
|
66
|
-
markup.cancel_for_any_reason
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return formatters;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { createPriceFormatters };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { logGroup } from "./logging";
|
|
2
|
-
|
|
3
|
-
export interface ErrorResponse extends Response {
|
|
4
|
-
data: { meta: any; errors: any[] };
|
|
5
|
-
}
|
|
6
|
-
export const isErrorResponse = (response: any): response is ErrorResponse => {
|
|
7
|
-
return "data" in response && Array.isArray(response.data.errors);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const DUFFEL_API_URL = process.env.DUFFEL_API_URL;
|
|
11
|
-
const COMPONENT_VERSION = process.env.COMPONENT_VERSION;
|
|
12
|
-
|
|
13
|
-
export async function fetchFromDuffelAPI(
|
|
14
|
-
withClientKey: string,
|
|
15
|
-
path: string,
|
|
16
|
-
method = "GET",
|
|
17
|
-
body?: string
|
|
18
|
-
) {
|
|
19
|
-
logGroup("Making request to the Duffel API", { path, method });
|
|
20
|
-
const fullUrl = `${DUFFEL_API_URL}/ancillaries-component/${path}`;
|
|
21
|
-
let response: Response | null = null;
|
|
22
|
-
try {
|
|
23
|
-
response = await fetch(fullUrl, {
|
|
24
|
-
method,
|
|
25
|
-
body,
|
|
26
|
-
headers: {
|
|
27
|
-
"Duffel-Version": "v1",
|
|
28
|
-
Authorization: `Bearer ${withClientKey}`,
|
|
29
|
-
"User-Agent": `Duffel/ancillaries-component@${COMPONENT_VERSION}`,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
} catch (error) {
|
|
33
|
-
logGroup("Failed to make request to the Duffel API", { error });
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const data = await response.json();
|
|
38
|
-
if (Array.isArray(data.errors)) {
|
|
39
|
-
logGroup("Request to the Duffel API failed", {
|
|
40
|
-
operation: `${method} ${fullUrl}`,
|
|
41
|
-
method,
|
|
42
|
-
request_id: data?.meta?.request_id,
|
|
43
|
-
errors: data.errors,
|
|
44
|
-
status: response.status,
|
|
45
|
-
});
|
|
46
|
-
throw { ...response, data };
|
|
47
|
-
} else {
|
|
48
|
-
logGroup("Request to the Duffel succeeded", {
|
|
49
|
-
request_id: data?.meta?.request_id,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Offer } from "../types/Offer";
|
|
2
|
-
import { SeatMap } from "../types/SeatMap";
|
|
3
|
-
|
|
4
|
-
const COMPONENT_CDN = process.env.COMPONENT_CDN;
|
|
5
|
-
|
|
6
|
-
export const importFromOfferFixtures = async (
|
|
7
|
-
offerId: string
|
|
8
|
-
): Promise<Offer> =>
|
|
9
|
-
await (
|
|
10
|
-
await fetch(COMPONENT_CDN + `/fixtures/offers/${offerId}.json`)
|
|
11
|
-
).json();
|
|
12
|
-
|
|
13
|
-
export const importFromSeatMapsFixtures = async (
|
|
14
|
-
offerId: string
|
|
15
|
-
): Promise<SeatMap[]> =>
|
|
16
|
-
await (
|
|
17
|
-
await fetch(COMPONENT_CDN + `/fixtures/seat-maps/${offerId}.json`)
|
|
18
|
-
).json();
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { DuffelAncillariesPriceFormatters } from "../types/DuffelAncillariesProps";
|
|
2
|
-
import { Offer } from "../types/Offer";
|
|
3
|
-
import { isBaggageService } from "./isBaggageService";
|
|
4
|
-
import { isCancelForAnyReasonService } from "./isCancelForAnyReasonService";
|
|
5
|
-
|
|
6
|
-
const multipleCurrenciesErrorMessage = (
|
|
7
|
-
label: string,
|
|
8
|
-
currencies: Set<string>
|
|
9
|
-
) => {
|
|
10
|
-
return `${label} must all have the same currency, but they have ${
|
|
11
|
-
currencies.size
|
|
12
|
-
} different currencies (${[...currencies].join(
|
|
13
|
-
", "
|
|
14
|
-
)}). Check the price formatters passed into the component's render function.`;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Formats the prices of the available services of an offer according to the
|
|
19
|
-
* priceFormatters passed in.
|
|
20
|
-
*
|
|
21
|
-
* @param offer An offer from the Duffel API
|
|
22
|
-
* @param priceFormatters Optional price formatting functions. If not passed in, the offer will be returned unchanged.
|
|
23
|
-
* @returns An offer with the prices of its available services formatted according to the priceFormatters passed in.
|
|
24
|
-
*/
|
|
25
|
-
const formatAvailableServices = (
|
|
26
|
-
offer: Offer,
|
|
27
|
-
priceFormatters?: DuffelAncillariesPriceFormatters
|
|
28
|
-
): Offer => {
|
|
29
|
-
// If no custom formatters were passed in, don't do anything.
|
|
30
|
-
if (!priceFormatters) {
|
|
31
|
-
return offer;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const availableServices = offer.available_services;
|
|
35
|
-
|
|
36
|
-
const foundCurrencies = new Set<string>();
|
|
37
|
-
|
|
38
|
-
const formatters = {
|
|
39
|
-
baggage: priceFormatters?.bags,
|
|
40
|
-
cancel_for_any_reason: priceFormatters?.cancel_for_any_reason,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const servicesWithFormattedPrices = availableServices.map((service) => {
|
|
44
|
-
const serviceWithFormattedPrices = { ...service };
|
|
45
|
-
|
|
46
|
-
if (service.type in formatters && formatters[service.type]) {
|
|
47
|
-
let { total_amount, total_currency } = service;
|
|
48
|
-
|
|
49
|
-
if (isBaggageService(service)) {
|
|
50
|
-
const { amount, currency } = formatters[service.type]!(
|
|
51
|
-
+service.total_amount,
|
|
52
|
-
service.total_currency,
|
|
53
|
-
service
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
total_amount = amount.toString();
|
|
57
|
-
if (currency) {
|
|
58
|
-
total_currency = currency;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (isCancelForAnyReasonService(service)) {
|
|
63
|
-
const { amount, currency } = formatters[service.type]!(
|
|
64
|
-
+service.total_amount,
|
|
65
|
-
service.total_currency,
|
|
66
|
-
service
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
total_amount = amount.toString();
|
|
70
|
-
if (currency) {
|
|
71
|
-
total_currency = currency;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Guard against different currencies being passed in for different services.
|
|
76
|
-
foundCurrencies.add(total_currency);
|
|
77
|
-
if (foundCurrencies.size > 1) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
multipleCurrenciesErrorMessage(service.type, foundCurrencies)
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
serviceWithFormattedPrices.total_amount = total_amount;
|
|
84
|
-
serviceWithFormattedPrices.total_currency = total_currency;
|
|
85
|
-
}
|
|
86
|
-
return serviceWithFormattedPrices;
|
|
87
|
-
});
|
|
88
|
-
return { ...offer, available_services: servicesWithFormattedPrices };
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export { formatAvailableServices };
|
package/src/lib/formatDate.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { captureErrorInSentry } from "./captureErrorInSentry";
|
|
2
|
-
|
|
3
|
-
export const formatDateString = (dateString: string) => {
|
|
4
|
-
const date = new Date(dateString);
|
|
5
|
-
if (!isNaN(date.valueOf())) return formatDate(date);
|
|
6
|
-
else {
|
|
7
|
-
captureErrorInSentry(
|
|
8
|
-
new Error(
|
|
9
|
-
`formatDateString attempted to parse an invalid date string: ${dateString}`
|
|
10
|
-
)
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const formatDate = (date: Date) => {
|
|
16
|
-
const { format } = new Intl.DateTimeFormat(undefined, {
|
|
17
|
-
dateStyle: "medium",
|
|
18
|
-
});
|
|
19
|
-
return format(date);
|
|
20
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { DuffelAncillariesPriceFormatterForSeats } from "../types/DuffelAncillariesProps";
|
|
2
|
-
import { SeatMap, SeatMapCabinRowSectionElement } from "../types/SeatMap";
|
|
3
|
-
import { isSeatElement } from "./isSeatElement";
|
|
4
|
-
|
|
5
|
-
const multipleCurrenciesErrorMessage = (currencies: Set<string>) => {
|
|
6
|
-
return `Seats must all have the same currency, but they have ${
|
|
7
|
-
currencies.size
|
|
8
|
-
} different currencies (${[...currencies].join(
|
|
9
|
-
", "
|
|
10
|
-
)}). Check the price formatters passed into the component's render function.`;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const formatElement = (
|
|
14
|
-
element: SeatMapCabinRowSectionElement,
|
|
15
|
-
priceFormatter: DuffelAncillariesPriceFormatterForSeats,
|
|
16
|
-
foundCurrencies: Set<string>
|
|
17
|
-
) => {
|
|
18
|
-
const formattedElement = { ...element };
|
|
19
|
-
if (
|
|
20
|
-
isSeatElement(formattedElement) &&
|
|
21
|
-
formattedElement.available_services.length > 0
|
|
22
|
-
) {
|
|
23
|
-
const formattedServices = formattedElement.available_services.map(
|
|
24
|
-
(service) => {
|
|
25
|
-
const formattedService = { ...service };
|
|
26
|
-
const { amount, currency } = priceFormatter(
|
|
27
|
-
+service.total_amount,
|
|
28
|
-
service.total_currency,
|
|
29
|
-
service
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
formattedService.total_amount = amount.toString();
|
|
33
|
-
|
|
34
|
-
// Guard against different currencies being passed in for different seats.
|
|
35
|
-
if (currency) {
|
|
36
|
-
formattedService.total_currency = currency;
|
|
37
|
-
foundCurrencies.add(currency);
|
|
38
|
-
if (foundCurrencies.size > 1) {
|
|
39
|
-
throw new Error(multipleCurrenciesErrorMessage(foundCurrencies));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return formattedService;
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
formattedElement.available_services = formattedServices;
|
|
47
|
-
}
|
|
48
|
-
return formattedElement;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const formatSeatMaps = (
|
|
52
|
-
seatMaps: SeatMap[],
|
|
53
|
-
priceFormatter?: DuffelAncillariesPriceFormatterForSeats
|
|
54
|
-
): SeatMap[] => {
|
|
55
|
-
// If a custom formatter wasn't passed in, don't do anything.
|
|
56
|
-
if (!priceFormatter) {
|
|
57
|
-
return seatMaps;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const foundCurrencies = new Set<string>();
|
|
61
|
-
|
|
62
|
-
const formattedSeatMaps: SeatMap[] = seatMaps.map((seatMap) => {
|
|
63
|
-
const formattedCabins = seatMap.cabins.map((cabin) => {
|
|
64
|
-
const formattedRows = cabin.rows.map((row) => {
|
|
65
|
-
const formattedSections = row.sections.map((section) => {
|
|
66
|
-
const formattedElements = section.elements.map((element) => {
|
|
67
|
-
return formatElement(element, priceFormatter, foundCurrencies);
|
|
68
|
-
});
|
|
69
|
-
return { ...section, elements: formattedElements };
|
|
70
|
-
});
|
|
71
|
-
return { ...row, sections: formattedSections };
|
|
72
|
-
});
|
|
73
|
-
return { ...cabin, rows: formattedRows };
|
|
74
|
-
});
|
|
75
|
-
return { ...seatMap, cabins: formattedCabins };
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return formattedSeatMaps;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export { formatSeatMaps };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { captureErrorInSentry } from "@lib/captureErrorInSentry";
|
|
2
|
-
import { OfferAvailableServiceBaggageMetadata } from "../types/Offer";
|
|
3
|
-
|
|
4
|
-
export const getBaggageServiceDescription = (
|
|
5
|
-
metadata: OfferAvailableServiceBaggageMetadata
|
|
6
|
-
) => {
|
|
7
|
-
if (!metadata) {
|
|
8
|
-
captureErrorInSentry(
|
|
9
|
-
new Error("getBaggageServiceDescription was not given any metadata")
|
|
10
|
-
);
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
!metadata.maximum_weight_kg &&
|
|
16
|
-
!metadata.maximum_length_cm &&
|
|
17
|
-
!metadata.maximum_height_cm &&
|
|
18
|
-
!metadata.maximum_depth_cm
|
|
19
|
-
) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const hasAllDimensions =
|
|
24
|
-
metadata.maximum_length_cm &&
|
|
25
|
-
metadata.maximum_height_cm &&
|
|
26
|
-
metadata.maximum_depth_cm;
|
|
27
|
-
|
|
28
|
-
let dimensionsLabel = "";
|
|
29
|
-
if (hasAllDimensions) {
|
|
30
|
-
dimensionsLabel = ` / ${metadata.maximum_height_cm} x ${metadata.maximum_length_cm} x ${metadata.maximum_depth_cm} cm`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let weightLabel = "";
|
|
34
|
-
if (metadata.maximum_weight_kg) {
|
|
35
|
-
weightLabel = `Up to ${metadata.maximum_weight_kg}kg`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return `${weightLabel}${dimensionsLabel}`;
|
|
39
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SeatMap, SeatMapCabinRowSectionElementSeat } from "../types/SeatMap";
|
|
2
|
-
import { getFirstSeatElementMatchingCriteria } from "./getFirstSeatElementMatchingCriteria";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Returns the currency of the first service of the given seat maps.
|
|
7
|
-
*
|
|
8
|
-
* @param seatMaps[] Array of seat maps
|
|
9
|
-
* @returns A string representing the currency of the seat maps in the offer.
|
|
10
|
-
*/
|
|
11
|
-
const getCurrencyForSeatMaps = (seatMaps: SeatMap[]): string | undefined => {
|
|
12
|
-
const firstElementWithServices:
|
|
13
|
-
| SeatMapCabinRowSectionElementSeat
|
|
14
|
-
| undefined = getFirstSeatElementMatchingCriteria(
|
|
15
|
-
seatMaps,
|
|
16
|
-
(element) =>
|
|
17
|
-
element.type === "seat" && element.available_services.length > 0
|
|
18
|
-
) as SeatMapCabinRowSectionElementSeat;
|
|
19
|
-
return firstElementWithServices?.available_services[0]?.total_currency;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { getCurrencyForSeatMaps };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Offer } from "../types/Offer";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Returns the currency of the first service of the given type in the offer.
|
|
6
|
-
*
|
|
7
|
-
* @param offer An offer
|
|
8
|
-
* @returns A string representing the currency of the services in the offer.
|
|
9
|
-
* @throws If there are no services, or none of the services are of the given type.
|
|
10
|
-
*/
|
|
11
|
-
const getCurrencyForServices = (offer: Offer, serviceType: string): string => {
|
|
12
|
-
if (offer.available_services.length === 0) {
|
|
13
|
-
throw new Error("No services available");
|
|
14
|
-
}
|
|
15
|
-
const firstService = offer.available_services.find(
|
|
16
|
-
(service) => service.type === serviceType
|
|
17
|
-
);
|
|
18
|
-
if (!firstService) {
|
|
19
|
-
throw new Error(`No ${serviceType} services available`);
|
|
20
|
-
}
|
|
21
|
-
return firstService.total_currency;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { getCurrencyForServices };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SeatMap, SeatMapCabinRowSectionElement } from "../types/SeatMap";
|
|
2
|
-
|
|
3
|
-
const getFirstSeatElementMatchingCriteria = (
|
|
4
|
-
seatMaps: SeatMap[],
|
|
5
|
-
matcher: (element: SeatMapCabinRowSectionElement) => boolean
|
|
6
|
-
) => {
|
|
7
|
-
for (const seatMap of seatMaps) {
|
|
8
|
-
for (const cabin of seatMap.cabins) {
|
|
9
|
-
for (const row of cabin.rows) {
|
|
10
|
-
for (const section of row.sections) {
|
|
11
|
-
for (const element of section.elements) {
|
|
12
|
-
if (matcher(element)) {
|
|
13
|
-
return element;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { getFirstSeatElementMatchingCriteria };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { OfferSliceSegment } from "../types/Offer";
|
|
2
|
-
|
|
3
|
-
export const getPassengerBySegmentList = (segments: OfferSliceSegment[]) =>
|
|
4
|
-
segments.flatMap((segment) =>
|
|
5
|
-
segment.passengers.map((passenger, passengerIndex) => ({
|
|
6
|
-
passenger,
|
|
7
|
-
passengerIndex,
|
|
8
|
-
segment,
|
|
9
|
-
}))
|
|
10
|
-
);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateOrderPayloadPassenger,
|
|
3
|
-
CreateOrderPayloadPassengers,
|
|
4
|
-
} from "../types/CreateOrderPayload";
|
|
5
|
-
|
|
6
|
-
export type PassengerMapById = Record<
|
|
7
|
-
CreateOrderPayloadPassenger["id"],
|
|
8
|
-
CreateOrderPayloadPassenger
|
|
9
|
-
>;
|
|
10
|
-
|
|
11
|
-
export const getPassengerMapById = (
|
|
12
|
-
passengers: CreateOrderPayloadPassengers
|
|
13
|
-
): PassengerMapById =>
|
|
14
|
-
passengers.reduce(
|
|
15
|
-
(all, passenger) => ({ [passenger.id]: passenger, ...all }),
|
|
16
|
-
{} as PassengerMapById
|
|
17
|
-
);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { CreateOrderPayloadPassenger } from "../types/CreateOrderPayload";
|
|
2
|
-
import { OfferPassenger } from "../types/Offer";
|
|
3
|
-
|
|
4
|
-
export const getPassengerName = (
|
|
5
|
-
createOrderPayloadPassenger: CreateOrderPayloadPassenger,
|
|
6
|
-
offerPassenger: OfferPassenger | undefined,
|
|
7
|
-
fallbackIndex: number
|
|
8
|
-
): string => {
|
|
9
|
-
if (!createOrderPayloadPassenger) {
|
|
10
|
-
return `Passenger ${fallbackIndex}`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
createOrderPayloadPassenger.given_name &&
|
|
15
|
-
createOrderPayloadPassenger.family_name
|
|
16
|
-
) {
|
|
17
|
-
return `${createOrderPayloadPassenger.given_name} ${createOrderPayloadPassenger.family_name}`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (createOrderPayloadPassenger.given_name) {
|
|
21
|
-
return createOrderPayloadPassenger.given_name;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (createOrderPayloadPassenger.family_name) {
|
|
25
|
-
return createOrderPayloadPassenger.family_name;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (offerPassenger?.given_name && offerPassenger?.family_name) {
|
|
29
|
-
return `${offerPassenger.given_name} ${offerPassenger.family_name}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (offerPassenger?.given_name) {
|
|
33
|
-
return offerPassenger.given_name;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (offerPassenger?.family_name) {
|
|
37
|
-
return offerPassenger.family_name;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return `Passenger ${fallbackIndex}`;
|
|
41
|
-
};
|
package/src/lib/getRowNumber.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SeatMapCabinRow,
|
|
3
|
-
SeatMapCabinRowSectionElementSeat,
|
|
4
|
-
} from "../types/SeatMap";
|
|
5
|
-
|
|
6
|
-
export const getRowNumber = (row: SeatMapCabinRow): string | null => {
|
|
7
|
-
const seats = Object.values(row.sections)
|
|
8
|
-
.map((section) => section.elements)
|
|
9
|
-
.reduce((acc, val) => acc.concat(val), [])
|
|
10
|
-
.filter(
|
|
11
|
-
(element) => element.type === "seat"
|
|
12
|
-
) as SeatMapCabinRowSectionElementSeat[];
|
|
13
|
-
return seats.length > 0
|
|
14
|
-
? seats[0].designator.substring(0, seats[0].designator.length - 1)
|
|
15
|
-
: null;
|
|
16
|
-
};
|