@duffel/components 3.0.7-canary → 3.1.2--prototype
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/.eslintrc.js +8 -0
- package/.github/CODEOWNERS +4 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/renovate.json +1 -5
- package/.github/workflows/release.yml +3 -0
- package/.storybook/__snapshots__/Storyshots.test.js.snap +20384 -533
- package/.tool-versions +1 -1
- package/README.md +16 -2
- package/config/esbuild.base.config.js +6 -2
- package/config/esbuild.cdn.config.js +2 -1
- package/config/esbuild.dev.config.js +2 -1
- package/config/esbuild.react.config.js +1 -1
- package/data/airports.csv +9084 -0
- package/data/cities.csv +256 -0
- package/package.json +11 -1
- package/react-dist/index.js +51 -21
- package/scripts/generate-fixture.ts +13 -8
- package/scripts/setup-suggestion-data.ts +100 -0
- package/scripts/upload-to-cdn.sh +1 -1
- package/src/components/{Card.tsx → DuffelAncillaries/Card.tsx} +1 -1
- package/src/components/{Counter.tsx → DuffelAncillaries/Counter.tsx} +1 -1
- package/src/components/{DuffelAncillaries.tsx → DuffelAncillaries/DuffelAncillaries.tsx} +68 -64
- package/src/components/{DuffelAncillariesCustomElement.tsx → DuffelAncillaries/DuffelAncillariesCustomElement.tsx} +2 -2
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionCard.tsx +10 -5
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionController.tsx +2 -2
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModal.tsx +4 -4
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalBody.tsx +3 -3
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalBodyPassenger.tsx +4 -4
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalFooter.tsx +23 -16
- package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalHeader.tsx +24 -18
- package/src/components/{bags → DuffelAncillaries/bags}/IncludedBaggageBanner.tsx +1 -1
- package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionCard.tsx +4 -4
- package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModal.tsx +3 -3
- package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalBody.tsx +3 -3
- package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalBodyListItem.tsx +1 -1
- package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalFooter.tsx +5 -5
- package/src/components/{seats → DuffelAncillaries/seats}/Amenity.tsx +2 -2
- package/src/components/{seats → DuffelAncillaries/seats}/DeckSelect.tsx +1 -1
- package/src/components/{seats → DuffelAncillaries/seats}/Element.tsx +2 -2
- package/src/components/{seats → DuffelAncillaries/seats}/ExitElement.tsx +1 -1
- package/src/components/{seats → DuffelAncillaries/seats}/Legend.tsx +2 -2
- package/src/components/{seats → DuffelAncillaries/seats}/Row.tsx +2 -2
- package/src/components/{seats → DuffelAncillaries/seats}/RowSection.tsx +5 -2
- package/src/components/{seats → DuffelAncillaries/seats}/SeatElement.tsx +3 -3
- package/src/components/{seats → DuffelAncillaries/seats}/SeatInfo.tsx +1 -1
- package/src/components/{seats → DuffelAncillaries/seats}/SeatMap.tsx +6 -2
- package/src/components/{seats → DuffelAncillaries/seats}/SeatMapUnavailable.tsx +1 -1
- package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionCard.tsx +5 -5
- package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModal.tsx +5 -5
- package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalBody.tsx +1 -1
- package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalFooter.tsx +24 -17
- package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalHeader.tsx +30 -20
- package/src/components/{seats → DuffelAncillaries/seats}/SeatUnavailable.tsx +2 -2
- package/src/components/DuffelPayments/DuffelPayments.tsx +224 -0
- package/src/components/DuffelPayments/DuffelPaymentsCustomElement.tsx +130 -0
- package/src/components/PlacesLookup/PlacesLookup.tsx +123 -0
- package/src/components/ShowData/ShowData.tsx +38 -0
- package/src/components/ShowData/ShowDataCustomElement.tsx +85 -0
- package/src/components/{Button.tsx → shared/Button.tsx} +4 -3
- package/src/components/{ErrorBoundary.tsx → shared/ErrorBoundary.tsx} +2 -2
- package/src/components/{Icon.tsx → shared/Icon.tsx} +11 -11
- package/src/components/{IconButton.tsx → shared/IconButton.tsx} +1 -1
- package/src/components/{Modal.tsx → shared/Modal.tsx} +5 -1
- package/src/components/{NonIdealState.tsx → shared/NonIdealState.tsx} +1 -1
- package/src/custom-elements.ts +6 -1
- package/src/examples/client-side/index.html +1 -1
- package/src/examples/full-stack/index.html +1 -1
- package/src/examples/full-stack/server.mjs +1 -0
- package/src/examples/just-typescript/src/index.html +2 -2
- package/src/examples/just-typescript/src/index.ts +2 -1
- package/src/examples/payments-custom-element/README.md +17 -0
- package/src/examples/payments-custom-element/index.html +43 -0
- package/src/examples/payments-just-typescript/README.md +37 -0
- package/src/examples/payments-just-typescript/package.json +16 -0
- package/src/examples/payments-just-typescript/src/index.html +23 -0
- package/src/examples/payments-just-typescript/src/index.ts +18 -0
- package/src/examples/react-app/src/index.tsx +11 -6
- package/src/fixtures/offers/off_1.json +1 -10
- package/src/index.ts +3 -1
- package/src/lib/captureErrorInSentry.ts +2 -20
- package/src/lib/fetchFromDuffelAPI.ts +36 -6
- package/src/lib/formatDate.ts +3 -4
- package/src/lib/getBaggageServiceDescription.ts +1 -6
- package/src/lib/getPassengerName.ts +4 -0
- package/src/lib/getTotalAmountForServices.ts +1 -1
- package/src/lib/hasHighLuminance.ts +9 -0
- package/src/lib/logging.ts +52 -32
- package/src/lib/retrieveOffer.ts +13 -6
- package/src/lib/retrieveSeatMaps.ts +13 -8
- package/src/stories/BaggageSelectionModalHeader.stories.tsx +1 -1
- package/src/stories/Button.stories.tsx +33 -2
- package/src/stories/DuffelAncillaries.stories.tsx +42 -2
- package/src/stories/DuffelPayments.stories.tsx +34 -0
- package/src/stories/Icon.stories.tsx +3 -2
- package/src/stories/IconButton.stories.tsx +1 -1
- package/src/stories/PlacesLookup.stories.tsx +22 -0
- package/src/stories/ShowData.stories.tsx +16 -0
- package/src/styles/components/Button.css +11 -3
- package/src/styles/components/Card.css +3 -3
- package/src/styles/components/CfarSelectionModal.css +1 -1
- package/src/styles/components/DuffelPayments.css +42 -0
- package/src/styles/components/Legend.css +10 -6
- package/src/styles/components/LoadingState.css +8 -2
- package/src/styles/components/Modal.css +2 -1
- package/src/styles/components/PassengerSelect.css +8 -2
- package/src/styles/components/PlacesLookup.css +36 -0
- package/src/styles/components/Seat.css +9 -7
- package/src/styles/components/SeatInfo.css +1 -1
- package/src/styles/components/Tabs.css +5 -2
- package/src/styles/global.css +2 -0
- package/src/tests/components/DuffelAncillaries.test.tsx +1 -1
- package/src/tests/lib/createPriceFormatters.test.tsx +1 -1
- package/src/tests/lib/formatAvailableServices.test.tsx +1 -1
- package/src/tests/lib/formatSeatMaps.test.tsx +2 -2
- package/src/tests/lib/getCurrencyForServices.test.tsx +1 -1
- package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +1 -1
- package/src/tests/lib/logging.test.tsx +14 -14
- package/src/tests/lib/moneyStringFormatter.test.tsx +1 -1
- package/src/tests/lib/validateProps.test.tsx +1 -1
- package/src/types/DuffelAncillariesProps.ts +1 -1
- package/react-dist/components/AnimatedLoaderEllipsis.d.ts +0 -2
- package/react-dist/components/Button.d.ts +0 -23
- package/react-dist/components/Card.d.ts +0 -14
- package/react-dist/components/Counter.d.ts +0 -10
- package/react-dist/components/DuffelAncillaries.d.ts +0 -3
- package/react-dist/components/DuffelAncillariesCustomElement.d.ts +0 -13
- package/react-dist/components/ErrorBoundary.d.ts +0 -13
- package/react-dist/components/FetchOfferErrorState.d.ts +0 -5
- package/react-dist/components/Icon.d.ts +0 -44
- package/react-dist/components/IconButton.d.ts +0 -16
- package/react-dist/components/Modal.d.ts +0 -11
- package/react-dist/components/NonIdealState.d.ts +0 -4
- package/react-dist/components/Stamp.d.ts +0 -7
- package/react-dist/components/Tabs.d.ts +0 -16
- package/react-dist/components/bags/BaggageSelectionCard.d.ts +0 -11
- package/react-dist/components/bags/BaggageSelectionController.d.ts +0 -13
- package/react-dist/components/bags/BaggageSelectionModal.d.ts +0 -11
- package/react-dist/components/bags/BaggageSelectionModalBody.d.ts +0 -11
- package/react-dist/components/bags/BaggageSelectionModalBodyPassenger.d.ts +0 -13
- package/react-dist/components/bags/BaggageSelectionModalFooter.d.ts +0 -14
- package/react-dist/components/bags/BaggageSelectionModalHeader.d.ts +0 -9
- package/react-dist/components/bags/IncludedBaggageBanner.d.ts +0 -7
- package/react-dist/components/cancel_for_any_reason/CfarSelectionCard.d.ts +0 -10
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModal.d.ts +0 -11
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalBody.d.ts +0 -7
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalBodyListItem.d.ts +0 -4
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalFooter.d.ts +0 -11
- package/react-dist/components/cancel_for_any_reason/CfarSelectionModalHeader.d.ts +0 -2
- package/react-dist/components/seats/Amenity.d.ts +0 -6
- package/react-dist/components/seats/DeckSelect.d.ts +0 -15
- package/react-dist/components/seats/Element.d.ts +0 -15
- package/react-dist/components/seats/EmptyElement.d.ts +0 -2
- package/react-dist/components/seats/ExitElement.d.ts +0 -6
- package/react-dist/components/seats/Legend.d.ts +0 -12
- package/react-dist/components/seats/Row.d.ts +0 -13
- package/react-dist/components/seats/RowSection.d.ts +0 -17
- package/react-dist/components/seats/SeatElement.d.ts +0 -13
- package/react-dist/components/seats/SeatInfo.d.ts +0 -7
- package/react-dist/components/seats/SeatMap.d.ts +0 -12
- package/react-dist/components/seats/SeatMapUnavailable.d.ts +0 -2
- package/react-dist/components/seats/SeatSelectionCard.d.ts +0 -13
- package/react-dist/components/seats/SeatSelectionModal.d.ts +0 -13
- package/react-dist/components/seats/SeatSelectionModalBody.d.ts +0 -4
- package/react-dist/components/seats/SeatSelectionModalFooter.d.ts +0 -16
- package/react-dist/components/seats/SeatSelectionModalHeader.d.ts +0 -10
- package/react-dist/components/seats/SeatUnavailable.d.ts +0 -5
- package/react-dist/custom-elements.d.ts +0 -5
- package/react-dist/custom-elements.js +0 -36
- package/react-dist/custom-elements.js.map +0 -7
- package/react-dist/index.d.ts +0 -6
- package/react-dist/index.js.map +0 -7
- package/react-dist/lib/captureErrorInSentry.d.ts +0 -1
- package/react-dist/lib/compileCreateOrderPayload.d.ts +0 -14
- package/react-dist/lib/createPriceFormatters.d.ts +0 -12
- package/react-dist/lib/fetchFromDuffelAPI.d.ts +0 -1
- package/react-dist/lib/fetchFromFixtures.d.ts +0 -4
- package/react-dist/lib/formatAvailableServices.d.ts +0 -12
- package/react-dist/lib/formatDate.d.ts +0 -2
- package/react-dist/lib/formatSeatMaps.d.ts +0 -4
- package/react-dist/lib/getBaggageServiceDescription.d.ts +0 -2
- package/react-dist/lib/getCabinsForSegmentAndDeck.d.ts +0 -2
- package/react-dist/lib/getCurrencyForSeatMaps.d.ts +0 -10
- package/react-dist/lib/getCurrencyForServices.d.ts +0 -11
- package/react-dist/lib/getFirstSeatElementMatchingCriteria.d.ts +0 -3
- package/react-dist/lib/getPassengerBySegmentList.d.ts +0 -6
- package/react-dist/lib/getPassengerInitials.d.ts +0 -1
- package/react-dist/lib/getPassengerMapById.d.ts +0 -3
- package/react-dist/lib/getPassengerName.d.ts +0 -3
- package/react-dist/lib/getRowNumber.d.ts +0 -2
- package/react-dist/lib/getSegmentList.d.ts +0 -2
- package/react-dist/lib/getServicePriceMapById.d.ts +0 -3
- package/react-dist/lib/getSymbols.d.ts +0 -2
- package/react-dist/lib/getTotalAmountForServices.d.ts +0 -6
- package/react-dist/lib/getTotalQuantity.d.ts +0 -2
- package/react-dist/lib/hasService.d.ts +0 -2
- package/react-dist/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.d.ts +0 -3
- package/react-dist/lib/hasWings.d.ts +0 -2
- package/react-dist/lib/isBaggageService.d.ts +0 -2
- package/react-dist/lib/isCancelForAnyReasonService.d.ts +0 -2
- package/react-dist/lib/isFixtureOfferId.d.ts +0 -2
- package/react-dist/lib/isPayloadComplete.d.ts +0 -2
- package/react-dist/lib/isSeatElement.d.ts +0 -2
- package/react-dist/lib/logging.d.ts +0 -53
- package/react-dist/lib/moneyStringFormatter.d.ts +0 -8
- package/react-dist/lib/offerIsExpired.d.ts +0 -2
- package/react-dist/lib/retrieveOffer.d.ts +0 -2
- package/react-dist/lib/retrieveOfferFromDuffelAPI.d.ts +0 -1
- package/react-dist/lib/retrieveSeatMaps.d.ts +0 -2
- package/react-dist/lib/retrieveSeatMapsFromDuffelAPI.d.ts +0 -1
- package/react-dist/lib/setBodyScrollability.d.ts +0 -1
- package/react-dist/lib/validateProps.d.ts +0 -7
- package/react-dist/lib/withPlural.d.ts +0 -1
- package/react-dist/types/Aircraft.d.ts +0 -14
- package/react-dist/types/Airline.d.ts +0 -14
- package/react-dist/types/Airport.d.ts +0 -44
- package/react-dist/types/City.d.ts +0 -18
- package/react-dist/types/CreateOrderPayload.d.ts +0 -72
- package/react-dist/types/CurrencyConversion.d.ts +0 -10
- package/react-dist/types/DuffelAncillariesProps.d.ts +0 -70
- package/react-dist/types/Offer.d.ts +0 -711
- package/react-dist/types/Order.d.ts +0 -8
- package/react-dist/types/Place.d.ts +0 -8
- package/react-dist/types/SeatMap.d.ts +0 -190
- package/react-dist/types/index.d.ts +0 -11
- package/src/examples/just-typescript/yarn.lock +0 -154
- package/src/examples/react-app/yarn.lock +0 -219
- /package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalHeader.tsx +0 -0
- /package/src/components/{seats → DuffelAncillaries/seats}/EmptyElement.tsx +0 -0
- /package/src/components/{AnimatedLoaderEllipsis.tsx → shared/AnimatedLoaderEllipsis.tsx} +0 -0
- /package/src/components/{FetchOfferErrorState.tsx → shared/FetchOfferErrorState.tsx} +0 -0
- /package/src/components/{Stamp.tsx → shared/Stamp.tsx} +0 -0
- /package/src/components/{Tabs.tsx → shared/Tabs.tsx} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { withPlural } from "@lib/withPlural";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { OfferSliceSegmentPassengerBaggage } from "
|
|
3
|
+
import { OfferSliceSegmentPassengerBaggage } from "../../../types/Offer";
|
|
4
4
|
|
|
5
5
|
interface IncludedBaggageBannerProps {
|
|
6
6
|
includedBaggage: OfferSliceSegmentPassengerBaggage[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnimatedLoaderEllipsis } from "@components/AnimatedLoaderEllipsis";
|
|
2
|
-
import { Stamp } from "@components/Stamp";
|
|
1
|
+
import { AnimatedLoaderEllipsis } from "@components/shared/AnimatedLoaderEllipsis";
|
|
2
|
+
import { Stamp } from "@components/shared/Stamp";
|
|
3
3
|
import { getCurrencyForServices } from "@lib/getCurrencyForServices";
|
|
4
4
|
import { getTotalAmountForServices } from "@lib/getTotalAmountForServices";
|
|
5
5
|
import { getTotalQuantity } from "@lib/getTotalQuantity";
|
|
@@ -7,8 +7,8 @@ import { hasService } from "@lib/hasService";
|
|
|
7
7
|
import { isCancelForAnyReasonService } from "@lib/isCancelForAnyReasonService";
|
|
8
8
|
import { moneyStringFormatter } from "@lib/moneyStringFormatter";
|
|
9
9
|
import React from "react";
|
|
10
|
-
import { CreateOrderPayloadServices } from "
|
|
11
|
-
import { Offer } from "
|
|
10
|
+
import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
|
|
11
|
+
import { Offer } from "../../../types/Offer";
|
|
12
12
|
import { Card } from "../Card";
|
|
13
13
|
import { CfarSelectionModal } from "./CfarSelectionModal";
|
|
14
14
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { Modal } from "@components/shared/Modal";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import {
|
|
3
4
|
CreateOrderPayloadServiceInformationForCancelForAnyReason,
|
|
4
5
|
CreateOrderPayloadServices,
|
|
5
|
-
} from "
|
|
6
|
+
} from "../../../types/CreateOrderPayload";
|
|
6
7
|
import {
|
|
7
8
|
Offer,
|
|
8
9
|
OfferAvailableServiceCancelForAnyReason,
|
|
9
|
-
} from "
|
|
10
|
-
import { Modal } from "../Modal";
|
|
10
|
+
} from "../../../types/Offer";
|
|
11
11
|
import { CfarSelectionModalBody } from "./CfarSelectionModalBody";
|
|
12
12
|
import { CfarSelectionModalFooter } from "./CfarSelectionModalFooter";
|
|
13
13
|
import { CfarSelectionModalHeader } from "./CfarSelectionModalHeader";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Icon } from "@components/Icon";
|
|
2
|
-
import { ModalBody } from "@components/Modal";
|
|
1
|
+
import { Icon } from "@components/shared//Icon";
|
|
2
|
+
import { ModalBody } from "@components/shared/Modal";
|
|
3
3
|
import { moneyStringFormatter } from "@lib/moneyStringFormatter";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import {
|
|
6
6
|
Offer,
|
|
7
7
|
OfferAvailableServiceCancelForAnyReason,
|
|
8
|
-
} from "
|
|
8
|
+
} from "../../../types/Offer";
|
|
9
9
|
import { CfarSelectionModalBodyListItem } from "./CfarSelectionModalBodyListItem";
|
|
10
10
|
|
|
11
11
|
export interface CfarSelectionModalBodyProps {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Button } from "@components/shared/Button";
|
|
2
|
+
import { Icon } from "@components/shared/Icon";
|
|
2
3
|
import { moneyStringFormatter } from "@lib/moneyStringFormatter";
|
|
3
4
|
import React from "react";
|
|
4
|
-
import { CreateOrderPayloadServices } from "
|
|
5
|
-
import { OfferAvailableServiceCancelForAnyReason } from "
|
|
6
|
-
import { Button } from "../Button";
|
|
5
|
+
import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
|
|
6
|
+
import { OfferAvailableServiceCancelForAnyReason } from "../../../types/Offer";
|
|
7
7
|
|
|
8
8
|
export interface CfarSelectionModalFooterProps {
|
|
9
9
|
service: OfferAvailableServiceCancelForAnyReason;
|
|
@@ -67,7 +67,7 @@ const ProtectedTripBanner: React.FC = () => (
|
|
|
67
67
|
<Icon
|
|
68
68
|
size={20}
|
|
69
69
|
name="shield_with_moon"
|
|
70
|
-
style={{ fill: "rgb(var(--ACCENT))" }}
|
|
70
|
+
style={{ fill: "var(--SECONDARY, rgb(var(--ACCENT)))" }}
|
|
71
71
|
/>
|
|
72
72
|
Your trip is protected
|
|
73
73
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Icon, IconName } from "@components/shared/Icon";
|
|
1
2
|
import classNames from "classnames";
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
import { SeatMapCabinRowSectionElementAmenity } from "
|
|
4
|
-
import { Icon, IconName } from "../Icon";
|
|
4
|
+
import { SeatMapCabinRowSectionElementAmenity } from "../../../types/SeatMap";
|
|
5
5
|
|
|
6
6
|
const amenitiesWithoutWrapper = ["bassinet", "exit_row"];
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSeatElement } from "@lib/isSeatElement";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { CreateOrderPayloadSeatService } from "
|
|
4
|
-
import { SeatMapCabinRowSectionElement } from "
|
|
3
|
+
import { CreateOrderPayloadSeatService } from "../../../types/CreateOrderPayload";
|
|
4
|
+
import { SeatMapCabinRowSectionElement } from "../../../types/SeatMap";
|
|
5
5
|
import { Amenity } from "./Amenity";
|
|
6
6
|
import { EmptyElement } from "./EmptyElement";
|
|
7
7
|
import { ExitElement } from "./ExitElement";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Icon, IconName } from "@components/Icon";
|
|
1
|
+
import { Icon, IconName } from "@components/shared/Icon";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { SeatMapCabinRowSectionElementAmenity } from "
|
|
3
|
+
import { SeatMapCabinRowSectionElementAmenity } from "../../../types/SeatMap";
|
|
4
4
|
|
|
5
5
|
export interface LegendProps {
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRowNumber } from "@lib/getRowNumber";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { CreateOrderPayloadSeatService } from "
|
|
4
|
-
import { SeatMapCabinRow } from "
|
|
3
|
+
import { CreateOrderPayloadSeatService } from "../../../types/CreateOrderPayload";
|
|
4
|
+
import { SeatMapCabinRow } from "../../../types/SeatMap";
|
|
5
5
|
import { RowSection } from "./RowSection";
|
|
6
6
|
|
|
7
7
|
export interface RowProps {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { CreateOrderPayloadSeatService } from "
|
|
4
|
-
import {
|
|
3
|
+
import { CreateOrderPayloadSeatService } from "../../../types/CreateOrderPayload";
|
|
4
|
+
import {
|
|
5
|
+
SeatMapCabinRow,
|
|
6
|
+
SeatMapCabinRowSection,
|
|
7
|
+
} from "../../../types/SeatMap";
|
|
5
8
|
import { Element } from "./Element";
|
|
6
9
|
import { EmptyElement } from "./EmptyElement";
|
|
7
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Icon } from "@components/shared/Icon";
|
|
1
2
|
import { getPassengerInitials } from "@lib/getPassengerInitials";
|
|
2
3
|
import { moneyStringFormatter } from "@lib/moneyStringFormatter";
|
|
3
4
|
import classNames from "classnames";
|
|
4
5
|
import * as React from "react";
|
|
5
|
-
import { CreateOrderPayloadSeatService } from "
|
|
6
|
-
import { SeatMapCabinRowSectionElementSeat } from "
|
|
7
|
-
import { Icon } from "../Icon";
|
|
6
|
+
import { CreateOrderPayloadSeatService } from "../../../types/CreateOrderPayload";
|
|
7
|
+
import { SeatMapCabinRowSectionElementSeat } from "../../../types/SeatMap";
|
|
8
8
|
import { SeatInfo } from "./SeatInfo";
|
|
9
9
|
import { SeatUnavailable } from "./SeatUnavailable";
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import {
|
|
4
4
|
SeatMapCabinRowSectionAvailableService,
|
|
5
5
|
SeatMapCabinRowSectionElementSeat,
|
|
6
|
-
} from "
|
|
6
|
+
} from "../../../types/SeatMap";
|
|
7
7
|
|
|
8
8
|
export interface SeatInfoProps {
|
|
9
9
|
seat: SeatMapCabinRowSectionElementSeat | null;
|
|
@@ -3,8 +3,8 @@ import { getSymbols } from "@lib/getSymbols";
|
|
|
3
3
|
import { hasWings } from "@lib/hasWings";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import { CreateOrderPayloadSeatService } from "
|
|
7
|
-
import { SeatMap as SeatMapType } from "
|
|
6
|
+
import { CreateOrderPayloadSeatService } from "../../../types/CreateOrderPayload";
|
|
7
|
+
import { SeatMap as SeatMapType } from "../../../types/SeatMap";
|
|
8
8
|
import { DeckSelect } from "./DeckSelect";
|
|
9
9
|
import { Legend } from "./Legend";
|
|
10
10
|
import { Row } from "./Row";
|
|
@@ -29,6 +29,10 @@ export const SeatMap: React.FC<SeatMapProps> = ({
|
|
|
29
29
|
}) => {
|
|
30
30
|
const [selectedDeck, setSelectedDeck] = React.useState(0);
|
|
31
31
|
|
|
32
|
+
if (!seatMap || !seatMap.cabins || !seatMap.cabins.length) {
|
|
33
|
+
return <SeatMapUnavailable />;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
const cabins = getCabinsForSegmentAndDeck(selectedDeck, seatMap);
|
|
33
37
|
const hasMultipleDecks = cabins.length !== seatMap.cabins.length;
|
|
34
38
|
const anyHasWings = seatMap.cabins.some((cabin) => cabin.wings);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AnimatedLoaderEllipsis } from "@components/shared/AnimatedLoaderEllipsis";
|
|
2
|
+
import { Stamp } from "@components/shared/Stamp";
|
|
1
3
|
import { getCurrencyForSeatMaps } from "@lib/getCurrencyForSeatMaps";
|
|
2
4
|
import { getTotalAmountForServices } from "@lib/getTotalAmountForServices";
|
|
3
5
|
import { getTotalQuantity } from "@lib/getTotalQuantity";
|
|
@@ -8,12 +10,10 @@ import {
|
|
|
8
10
|
CreateOrderPayload,
|
|
9
11
|
CreateOrderPayloadSeatService,
|
|
10
12
|
CreateOrderPayloadServices,
|
|
11
|
-
} from "
|
|
12
|
-
import { Offer } from "
|
|
13
|
-
import { SeatMap } from "
|
|
14
|
-
import { AnimatedLoaderEllipsis } from "../AnimatedLoaderEllipsis";
|
|
13
|
+
} from "../../../types/CreateOrderPayload";
|
|
14
|
+
import { Offer } from "../../../types/Offer";
|
|
15
|
+
import { SeatMap } from "../../../types/SeatMap";
|
|
15
16
|
import { Card } from "../Card";
|
|
16
|
-
import { Stamp } from "../Stamp";
|
|
17
17
|
import { SeatSelectionModal } from "./SeatSelectionModal";
|
|
18
18
|
|
|
19
19
|
export interface SeatSelectionCardProps {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Modal } from "@components/shared/Modal";
|
|
1
2
|
import { getCurrencyForSeatMaps } from "@lib/getCurrencyForSeatMaps";
|
|
2
3
|
import { getPassengerBySegmentList } from "@lib/getPassengerBySegmentList";
|
|
3
4
|
import { getPassengerMapById } from "@lib/getPassengerMapById";
|
|
@@ -8,10 +9,9 @@ import React from "react";
|
|
|
8
9
|
import {
|
|
9
10
|
CreateOrderPayload,
|
|
10
11
|
CreateOrderPayloadSeatService,
|
|
11
|
-
} from "
|
|
12
|
-
import { Offer } from "
|
|
13
|
-
import { SeatMap } from "
|
|
14
|
-
import { Modal } from "../Modal";
|
|
12
|
+
} from "../../../types/CreateOrderPayload";
|
|
13
|
+
import { Offer } from "../../../types/Offer";
|
|
14
|
+
import { SeatMap } from "../../../types/SeatMap";
|
|
15
15
|
import { SeatSelectionModalBody } from "./SeatSelectionModalBody";
|
|
16
16
|
import { SeatSelectionModalFooter } from "./SeatSelectionModalFooter";
|
|
17
17
|
import { SeatSelectionModalHeader } from "./SeatSelectionModalHeader";
|
|
@@ -100,7 +100,7 @@ export const SeatSelectionModal: React.FC<SeatSelectionModalProps> = ({
|
|
|
100
100
|
getCurrencyForSeatMaps(seatMaps) ?? offer.total_currency;
|
|
101
101
|
|
|
102
102
|
return (
|
|
103
|
-
<Modal isOpen={isOpen} onClose={() => onClose(
|
|
103
|
+
<Modal isOpen={isOpen} onClose={() => onClose(selectedServices)}>
|
|
104
104
|
<SeatSelectionModalHeader
|
|
105
105
|
segmentAndPassengerPermutationsCount={
|
|
106
106
|
segmentAndPassengerPermutations.length
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Button } from "@components/shared/Button";
|
|
1
2
|
import { ServicePriceMapById } from "@lib/getServicePriceMapById";
|
|
2
3
|
import { getTotalAmountForServicesWithPriceMap } from "@lib/getTotalAmountForServices";
|
|
3
4
|
import { getTotalQuantity } from "@lib/getTotalQuantity";
|
|
4
5
|
import { moneyStringFormatter } from "@lib/moneyStringFormatter";
|
|
5
6
|
import { withPlural } from "@lib/withPlural";
|
|
6
7
|
import React from "react";
|
|
7
|
-
import { CreateOrderPayloadServices } from "
|
|
8
|
-
import { SeatMap } from "
|
|
9
|
-
import { Button } from "../Button";
|
|
8
|
+
import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
|
|
9
|
+
import { SeatMap } from "../../../types/SeatMap";
|
|
10
10
|
|
|
11
11
|
export interface SeatSelectionModalFooterProps {
|
|
12
12
|
currency: string;
|
|
@@ -42,6 +42,7 @@ export const SeatSelectionModalFooter: React.FC<
|
|
|
42
42
|
seatMaps
|
|
43
43
|
);
|
|
44
44
|
const totalAmountLabel = moneyStringFormatter(currency)(totalAmount);
|
|
45
|
+
const isOneWay = isFirstSegment && isLastSegment;
|
|
45
46
|
|
|
46
47
|
return (
|
|
47
48
|
<div style={{ padding: "16px 24px 24px" }}>
|
|
@@ -51,21 +52,27 @@ export const SeatSelectionModalFooter: React.FC<
|
|
|
51
52
|
</div>
|
|
52
53
|
|
|
53
54
|
<div
|
|
54
|
-
style={
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
style={
|
|
56
|
+
isOneWay
|
|
57
|
+
? { marginTop: "16px", display: "grid" }
|
|
58
|
+
: {
|
|
59
|
+
marginTop: "16px",
|
|
60
|
+
display: "grid",
|
|
61
|
+
columnGap: "12px",
|
|
62
|
+
gridTemplateColumns: "repeat(2, 1fr)",
|
|
63
|
+
}
|
|
64
|
+
}
|
|
60
65
|
>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
{!isOneWay && (
|
|
67
|
+
<Button
|
|
68
|
+
size={48}
|
|
69
|
+
disabled={isFirstSegment}
|
|
70
|
+
variant="outlined"
|
|
71
|
+
onClick={() => onPreviousSegmentButtonClicked()}
|
|
72
|
+
>
|
|
73
|
+
Back
|
|
74
|
+
</Button>
|
|
75
|
+
)}
|
|
69
76
|
|
|
70
77
|
<Button
|
|
71
78
|
size={48}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatDateString } from "@lib/formatDate";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { OfferSliceSegment } from "
|
|
3
|
+
import { OfferSliceSegment } from "../../../types/Offer";
|
|
4
4
|
|
|
5
5
|
export interface SeatSelectionModalHeaderProps {
|
|
6
6
|
segmentAndPassengerPermutationsCount: number;
|
|
@@ -21,23 +21,32 @@ export const SeatSelectionModalHeader: React.FC<
|
|
|
21
21
|
setCurrentSegmentAndPassengerPermutationsIndex,
|
|
22
22
|
}) => (
|
|
23
23
|
<div style={{ padding: "24px 24px 16px" }}>
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
index
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
{segmentAndPassengerPermutationsCount > 1 && (
|
|
25
|
+
<div style={{ display: "flex", columnGap: "4px" }}>
|
|
26
|
+
{Array(segmentAndPassengerPermutationsCount)
|
|
27
|
+
.fill(0)
|
|
28
|
+
.map((_, index) =>
|
|
29
|
+
index === currentSegmentAndPassengerPermutationsIndex ? (
|
|
30
|
+
<ActiveSegment key={`segment_${index}`} />
|
|
31
|
+
) : (
|
|
32
|
+
<InactiveSegment
|
|
33
|
+
key={`segment_${index}`}
|
|
34
|
+
onClick={() =>
|
|
35
|
+
setCurrentSegmentAndPassengerPermutationsIndex(index)
|
|
36
|
+
}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
<h2
|
|
43
|
+
className="h3--semibold"
|
|
44
|
+
style={
|
|
45
|
+
segmentAndPassengerPermutationsCount > 1
|
|
46
|
+
? { marginBlock: "12px 0px" }
|
|
47
|
+
: {}
|
|
48
|
+
}
|
|
49
|
+
>
|
|
41
50
|
Flight to {currentSegment.destination.iata_code}
|
|
42
51
|
<span
|
|
43
52
|
className="p2--regular"
|
|
@@ -70,7 +79,8 @@ const InactiveSegment: React.FC<{
|
|
|
70
79
|
height: "4px",
|
|
71
80
|
padding: "0",
|
|
72
81
|
borderRadius: "4px",
|
|
73
|
-
backgroundColor:
|
|
82
|
+
backgroundColor:
|
|
83
|
+
"var(--TERTIARY, rgba(var(--ACCENT), var(--ACCENT-LIGHT-200)))",
|
|
74
84
|
transition: "background-color 0.3s var(--TRANSITION-CUBIC-BEZIER)",
|
|
75
85
|
...style,
|
|
76
86
|
}}
|
|
@@ -81,7 +91,7 @@ const ActiveSegment = () => (
|
|
|
81
91
|
<InactiveSegment
|
|
82
92
|
onClick={undefined}
|
|
83
93
|
style={{
|
|
84
|
-
backgroundColor: "rgb(var(--ACCENT))",
|
|
94
|
+
backgroundColor: "var(--SECONDARY, rgb(var(--ACCENT)))",
|
|
85
95
|
}}
|
|
86
96
|
/>
|
|
87
97
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Icon } from "@components/shared/Icon";
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
import { SeatMapCabinRowSectionElementSeat } from "
|
|
3
|
-
import { Icon } from "../Icon";
|
|
3
|
+
import { SeatMapCabinRowSectionElementSeat } from "../../../types/SeatMap";
|
|
4
4
|
|
|
5
5
|
export const SeatUnavailable: React.FC<{
|
|
6
6
|
seat: SeatMapCabinRowSectionElementSeat;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { ErrorBoundary } from "@components/shared/ErrorBoundary";
|
|
2
|
+
import { hasHighLuminance } from "@lib/hasHighLuminance";
|
|
3
|
+
import { initializeLogger } from "@lib/logging";
|
|
4
|
+
import {
|
|
5
|
+
CardElement,
|
|
6
|
+
Elements,
|
|
7
|
+
useElements,
|
|
8
|
+
useStripe,
|
|
9
|
+
} from "@stripe/react-stripe-js";
|
|
10
|
+
import { StripeCardElement, StripeError, loadStripe } from "@stripe/stripe-js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { CustomStyles } from "../../types";
|
|
13
|
+
import { Button } from "../shared/Button";
|
|
14
|
+
|
|
15
|
+
const COMPONENT_CDN = process.env.COMPONENT_CDN || "";
|
|
16
|
+
const hrefToComponentStyles = `${COMPONENT_CDN}/global.css`;
|
|
17
|
+
|
|
18
|
+
const STRIPE_CARD_ELEMENT = "card";
|
|
19
|
+
const COMPONENT_VERSION = process.env.COMPONENT_VERSION;
|
|
20
|
+
|
|
21
|
+
export interface DuffelPaymentsProps {
|
|
22
|
+
paymentIntentClientToken: string;
|
|
23
|
+
onSuccessfulPayment: () => void;
|
|
24
|
+
onFailedPayment: (error: StripeError) => void;
|
|
25
|
+
|
|
26
|
+
styles?: CustomStyles;
|
|
27
|
+
debug?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const CARD_ELEMENT_STYLE_BASE = {
|
|
31
|
+
color: "var(--GREY-900)",
|
|
32
|
+
fontFamily:
|
|
33
|
+
'"-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "sans-serif"',
|
|
34
|
+
fontSmoothing: "antialiased",
|
|
35
|
+
fontSize: "16px",
|
|
36
|
+
"::placeholder": {
|
|
37
|
+
color: "#ababb4",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const CARD_ELEMENT_STYLE_INVALID = {
|
|
42
|
+
color: "#ef4444",
|
|
43
|
+
iconColor: "#ef4444",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const CardPaymentComponent: React.FC<DuffelPaymentsProps> = ({
|
|
47
|
+
styles,
|
|
48
|
+
paymentIntentClientToken,
|
|
49
|
+
onSuccessfulPayment,
|
|
50
|
+
onFailedPayment,
|
|
51
|
+
}) => {
|
|
52
|
+
const [cardElement, setCardElement] =
|
|
53
|
+
React.useState<StripeCardElement | null>(null);
|
|
54
|
+
const [isComplete, setIsComplete] = React.useState<boolean>(false);
|
|
55
|
+
const [isInvalid, setIsInvalid] = React.useState<boolean>(false);
|
|
56
|
+
const [isProcessing, setIsProcessing] = React.useState<boolean>(false);
|
|
57
|
+
const [errorMessage, setErrorMessage] = React.useState<string>("");
|
|
58
|
+
const stripe = useStripe();
|
|
59
|
+
const elements = useElements();
|
|
60
|
+
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
if (elements && !cardElement) {
|
|
63
|
+
const maybeCard = elements?.getElement(STRIPE_CARD_ELEMENT);
|
|
64
|
+
maybeCard && setCardElement(maybeCard as StripeCardElement);
|
|
65
|
+
}
|
|
66
|
+
}, [elements, cardElement]);
|
|
67
|
+
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (cardElement) {
|
|
70
|
+
cardElement.on("change", (event) => {
|
|
71
|
+
const { error, complete } = event;
|
|
72
|
+
|
|
73
|
+
if (error) {
|
|
74
|
+
setIsInvalid(true);
|
|
75
|
+
setErrorMessage(error.message);
|
|
76
|
+
} else {
|
|
77
|
+
setIsInvalid(false);
|
|
78
|
+
}
|
|
79
|
+
complete ? setIsComplete(true) : setIsComplete(false);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, [cardElement]);
|
|
83
|
+
|
|
84
|
+
// User is responsible for handling outcome of payment.
|
|
85
|
+
const handleSubmit = async (
|
|
86
|
+
e: React.MouseEvent<HTMLFormElement, MouseEvent>
|
|
87
|
+
) => {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
if (!stripe || !elements) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (cardElement) {
|
|
94
|
+
setIsProcessing(true);
|
|
95
|
+
const decodedDuffelPaymentIntentClientToken = atob(
|
|
96
|
+
paymentIntentClientToken
|
|
97
|
+
);
|
|
98
|
+
const parsedDuffelPaymentIntentClientToken = JSON.parse(
|
|
99
|
+
decodedDuffelPaymentIntentClientToken
|
|
100
|
+
);
|
|
101
|
+
const { client_secret: clientSecret } =
|
|
102
|
+
parsedDuffelPaymentIntentClientToken;
|
|
103
|
+
|
|
104
|
+
const result = await stripe.confirmCardPayment(clientSecret, {
|
|
105
|
+
payment_method: {
|
|
106
|
+
card: cardElement,
|
|
107
|
+
metadata: {
|
|
108
|
+
duffel_components_version:
|
|
109
|
+
COMPONENT_VERSION || "failed-to-get-version",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
setIsProcessing(false);
|
|
115
|
+
if (result.error) {
|
|
116
|
+
const { error } = result;
|
|
117
|
+
onFailedPayment(error);
|
|
118
|
+
} else {
|
|
119
|
+
onSuccessfulPayment();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return paymentIntentClientToken ? (
|
|
125
|
+
<div className="card-payment__container">
|
|
126
|
+
<form onSubmit={handleSubmit}>
|
|
127
|
+
{isProcessing && (
|
|
128
|
+
<div
|
|
129
|
+
className="card-payment--in-progress"
|
|
130
|
+
aria-live="polite"
|
|
131
|
+
aria-busy="true"
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
<CardElement
|
|
135
|
+
className="card-details"
|
|
136
|
+
options={{
|
|
137
|
+
style: {
|
|
138
|
+
base: {
|
|
139
|
+
...CARD_ELEMENT_STYLE_BASE,
|
|
140
|
+
...(styles?.fontFamily && {
|
|
141
|
+
fontFamily: styles.fontFamily,
|
|
142
|
+
}),
|
|
143
|
+
},
|
|
144
|
+
invalid: { ...CARD_ELEMENT_STYLE_INVALID },
|
|
145
|
+
},
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
<div className="card-payment__container--invalid" role="alert">
|
|
149
|
+
{isInvalid && errorMessage}
|
|
150
|
+
</div>
|
|
151
|
+
<Button
|
|
152
|
+
className="card-payment__pay-button"
|
|
153
|
+
type="submit"
|
|
154
|
+
disabled={!isComplete || isProcessing}
|
|
155
|
+
aria-label="Pay"
|
|
156
|
+
>
|
|
157
|
+
{isProcessing ? "Processing..." : "Pay"}
|
|
158
|
+
</Button>
|
|
159
|
+
</form>
|
|
160
|
+
</div>
|
|
161
|
+
) : null;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const DuffelPayments: React.FC<DuffelPaymentsProps> = (props) => {
|
|
165
|
+
const [stripe, setStripe] = React.useState<Promise<any> | null>(null);
|
|
166
|
+
initializeLogger(props.debug || false);
|
|
167
|
+
|
|
168
|
+
const decodedDuffelPaymentIntentClientToken = atob(
|
|
169
|
+
props.paymentIntentClientToken
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
let parsedDuffelPaymentIntentClientToken;
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
parsedDuffelPaymentIntentClientToken = JSON.parse(
|
|
176
|
+
decodedDuffelPaymentIntentClientToken
|
|
177
|
+
);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
throw new Error("Invalid Duffel payment intent client token provided");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const { publishable_key: duffelPublishableKey } =
|
|
183
|
+
parsedDuffelPaymentIntentClientToken;
|
|
184
|
+
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
if (!stripe && duffelPublishableKey) {
|
|
187
|
+
const stripe = loadStripe(duffelPublishableKey);
|
|
188
|
+
stripe && setStripe(stripe);
|
|
189
|
+
}
|
|
190
|
+
}, [stripe, duffelPublishableKey]);
|
|
191
|
+
|
|
192
|
+
const duffelComponentsStyle: React.CSSProperties = {
|
|
193
|
+
...(props.styles?.accentColor && {
|
|
194
|
+
"--ACCENT": props.styles.accentColor,
|
|
195
|
+
}),
|
|
196
|
+
...(props.styles?.accentColor &&
|
|
197
|
+
hasHighLuminance(props.styles.accentColor) && {
|
|
198
|
+
"--SECONDARY": "black",
|
|
199
|
+
"--TERTIARY": "grey",
|
|
200
|
+
}),
|
|
201
|
+
...(props.styles?.fontFamily && {
|
|
202
|
+
"--FONT-FAMILY": props.styles.fontFamily,
|
|
203
|
+
}),
|
|
204
|
+
...(props.styles?.buttonCornerRadius && {
|
|
205
|
+
"--BUTTON-RADIUS": props.styles.buttonCornerRadius,
|
|
206
|
+
}),
|
|
207
|
+
// `as any` is needed here is needed because we want to set css variables
|
|
208
|
+
// that are not part of the css properties type
|
|
209
|
+
} as any;
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<>
|
|
213
|
+
<link rel="stylesheet" href={hrefToComponentStyles}></link>
|
|
214
|
+
|
|
215
|
+
<div className="duffel-components" style={duffelComponentsStyle}>
|
|
216
|
+
<ErrorBoundary>
|
|
217
|
+
<Elements stripe={stripe}>
|
|
218
|
+
<CardPaymentComponent {...props} />
|
|
219
|
+
</Elements>
|
|
220
|
+
</ErrorBoundary>
|
|
221
|
+
</div>
|
|
222
|
+
</>
|
|
223
|
+
);
|
|
224
|
+
};
|