@duffel/components 3.0.0-canary → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.eslintrc.js +14 -1
  2. package/.github/workflows/release.yml +4 -1
  3. package/.storybook/__snapshots__/Storyshots.test.js.snap +185 -0
  4. package/CONTRIBUTING.md +83 -0
  5. package/README.md +34 -109
  6. package/config/esbuild.base.config.js +7 -3
  7. package/config/esbuild.cdn.config.js +4 -3
  8. package/config/esbuild.dev.config.js +4 -3
  9. package/config/esbuild.react.config.js +3 -3
  10. package/package.json +16 -5
  11. package/react-dist/components/{Card.d.ts → DuffelAncillaries/Card.d.ts} +1 -1
  12. package/react-dist/components/{DuffelAncillaries.d.ts → DuffelAncillaries/DuffelAncillaries.d.ts} +1 -1
  13. package/react-dist/components/{DuffelAncillariesCustomElement.d.ts → DuffelAncillaries/DuffelAncillariesCustomElement.d.ts} +1 -1
  14. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionCard.d.ts +2 -2
  15. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionController.d.ts +2 -2
  16. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModal.d.ts +2 -2
  17. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalBody.d.ts +2 -2
  18. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalBodyPassenger.d.ts +2 -2
  19. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalFooter.d.ts +1 -1
  20. package/react-dist/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalHeader.d.ts +1 -1
  21. package/react-dist/components/{bags → DuffelAncillaries/bags}/IncludedBaggageBanner.d.ts +1 -1
  22. package/react-dist/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionCard.d.ts +2 -2
  23. package/react-dist/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModal.d.ts +2 -2
  24. package/react-dist/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalBody.d.ts +1 -1
  25. package/react-dist/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalFooter.d.ts +2 -2
  26. package/react-dist/components/{seats → DuffelAncillaries/seats}/Amenity.d.ts +1 -1
  27. package/react-dist/components/{seats → DuffelAncillaries/seats}/Element.d.ts +2 -2
  28. package/react-dist/components/{seats → DuffelAncillaries/seats}/Legend.d.ts +1 -1
  29. package/react-dist/components/{seats → DuffelAncillaries/seats}/Row.d.ts +2 -2
  30. package/react-dist/components/{seats → DuffelAncillaries/seats}/RowSection.d.ts +2 -2
  31. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatElement.d.ts +2 -2
  32. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatInfo.d.ts +1 -1
  33. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatMap.d.ts +2 -2
  34. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatSelectionCard.d.ts +3 -3
  35. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatSelectionModal.d.ts +3 -3
  36. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalFooter.d.ts +2 -2
  37. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalHeader.d.ts +1 -1
  38. package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatUnavailable.d.ts +1 -1
  39. package/react-dist/components/DuffelPayments/DuffelPayments.d.ts +11 -0
  40. package/react-dist/components/DuffelPayments/DuffelPaymentsCustomElement.d.ts +14 -0
  41. package/react-dist/components/{Button.d.ts → shared/Button.d.ts} +2 -2
  42. package/react-dist/components/{ErrorBoundary.d.ts → shared/ErrorBoundary.d.ts} +1 -1
  43. package/react-dist/components/{IconButton.d.ts → shared/IconButton.d.ts} +1 -1
  44. package/react-dist/components/{NonIdealState.d.ts → shared/NonIdealState.d.ts} +1 -1
  45. package/react-dist/custom-elements.d.ts +6 -0
  46. package/react-dist/custom-elements.js +37 -0
  47. package/react-dist/custom-elements.js.map +7 -0
  48. package/react-dist/index.d.ts +4 -5
  49. package/react-dist/index.js +21 -20
  50. package/react-dist/index.js.map +4 -4
  51. package/react-dist/lib/captureErrorInSentry.d.ts +1 -1
  52. package/react-dist/lib/fetchFromDuffelAPI.d.ts +7 -0
  53. package/react-dist/lib/logging.d.ts +7 -14
  54. package/react-dist/lib/retrieveSeatMaps.d.ts +1 -1
  55. package/react-dist/types/DuffelAncillariesProps.d.ts +1 -1
  56. package/scripts/generate-fixture.ts +13 -8
  57. package/scripts/upload-to-cdn.sh +4 -9
  58. package/src/components/{Card.tsx → DuffelAncillaries/Card.tsx} +1 -1
  59. package/src/components/{Counter.tsx → DuffelAncillaries/Counter.tsx} +1 -1
  60. package/src/components/{DuffelAncillaries.tsx → DuffelAncillaries/DuffelAncillaries.tsx} +61 -63
  61. package/src/components/{DuffelAncillariesCustomElement.tsx → DuffelAncillaries/DuffelAncillariesCustomElement.tsx} +2 -2
  62. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionCard.tsx +4 -4
  63. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionController.tsx +2 -2
  64. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModal.tsx +3 -3
  65. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalBody.tsx +3 -3
  66. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalBodyPassenger.tsx +2 -2
  67. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalFooter.tsx +2 -2
  68. package/src/components/{bags → DuffelAncillaries/bags}/BaggageSelectionModalHeader.tsx +1 -1
  69. package/src/components/{bags → DuffelAncillaries/bags}/IncludedBaggageBanner.tsx +1 -1
  70. package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionCard.tsx +4 -4
  71. package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModal.tsx +3 -3
  72. package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalBody.tsx +3 -3
  73. package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalBodyListItem.tsx +1 -1
  74. package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalFooter.tsx +4 -4
  75. package/src/components/{seats → DuffelAncillaries/seats}/Amenity.tsx +2 -2
  76. package/src/components/{seats → DuffelAncillaries/seats}/DeckSelect.tsx +1 -1
  77. package/src/components/{seats → DuffelAncillaries/seats}/Element.tsx +2 -2
  78. package/src/components/{seats → DuffelAncillaries/seats}/ExitElement.tsx +1 -1
  79. package/src/components/{seats → DuffelAncillaries/seats}/Legend.tsx +2 -2
  80. package/src/components/{seats → DuffelAncillaries/seats}/Row.tsx +2 -2
  81. package/src/components/{seats → DuffelAncillaries/seats}/RowSection.tsx +5 -2
  82. package/src/components/{seats → DuffelAncillaries/seats}/SeatElement.tsx +3 -3
  83. package/src/components/{seats → DuffelAncillaries/seats}/SeatInfo.tsx +1 -1
  84. package/src/components/{seats → DuffelAncillaries/seats}/SeatMap.tsx +2 -2
  85. package/src/components/{seats → DuffelAncillaries/seats}/SeatMapUnavailable.tsx +1 -1
  86. package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionCard.tsx +5 -5
  87. package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModal.tsx +4 -4
  88. package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalBody.tsx +1 -1
  89. package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalFooter.tsx +3 -3
  90. package/src/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalHeader.tsx +1 -1
  91. package/src/components/{seats → DuffelAncillaries/seats}/SeatUnavailable.tsx +2 -2
  92. package/src/components/DuffelPayments/DuffelPayments.tsx +218 -0
  93. package/src/components/DuffelPayments/DuffelPaymentsCustomElement.tsx +130 -0
  94. package/src/components/{Button.tsx → shared/Button.tsx} +4 -3
  95. package/src/components/{ErrorBoundary.tsx → shared/ErrorBoundary.tsx} +2 -2
  96. package/src/components/{Icon.tsx → shared/Icon.tsx} +2 -1
  97. package/src/components/{IconButton.tsx → shared/IconButton.tsx} +1 -1
  98. package/src/components/{Modal.tsx → shared/Modal.tsx} +5 -1
  99. package/src/components/{NonIdealState.tsx → shared/NonIdealState.tsx} +1 -1
  100. package/src/custom-elements.ts +13 -0
  101. package/src/examples/client-side/README.md +30 -0
  102. package/src/examples/client-side/index.html +1 -1
  103. package/src/examples/full-stack/README.md +34 -0
  104. package/src/examples/full-stack/index.html +1 -1
  105. package/src/examples/full-stack/server.mjs +1 -0
  106. package/src/examples/just-typescript/src/index.html +2 -2
  107. package/src/examples/just-typescript/src/index.ts +2 -1
  108. package/src/examples/payments-custom-element/README.md +17 -0
  109. package/src/examples/payments-custom-element/index.html +43 -0
  110. package/src/examples/payments-just-typescript/README.md +37 -0
  111. package/src/examples/payments-just-typescript/package.json +16 -0
  112. package/src/examples/payments-just-typescript/src/index.html +23 -0
  113. package/src/examples/payments-just-typescript/src/index.ts +18 -0
  114. package/src/examples/payments-just-typescript/yarn.lock +154 -0
  115. package/src/examples/react-app/src/index.tsx +11 -6
  116. package/src/index.ts +4 -5
  117. package/src/lib/captureErrorInSentry.ts +2 -20
  118. package/src/lib/fetchFromDuffelAPI.ts +36 -6
  119. package/src/lib/formatDate.ts +3 -4
  120. package/src/lib/getBaggageServiceDescription.ts +2 -4
  121. package/src/lib/getTotalAmountForServices.ts +1 -1
  122. package/src/lib/logging.ts +52 -32
  123. package/src/lib/retrieveOffer.ts +11 -6
  124. package/src/lib/retrieveSeatMaps.ts +13 -8
  125. package/src/stories/BaggageSelectionModalHeader.stories.tsx +1 -1
  126. package/src/stories/Button.stories.tsx +12 -3
  127. package/src/stories/DuffelAncillaries.stories.tsx +1 -1
  128. package/src/stories/DuffelPayments.stories.tsx +34 -0
  129. package/src/stories/Icon.stories.tsx +3 -2
  130. package/src/stories/IconButton.stories.tsx +1 -1
  131. package/src/styles/components/DuffelPayments.css +42 -0
  132. package/src/styles/components/Modal.css +2 -1
  133. package/src/styles/global.css +1 -0
  134. package/src/tests/components/DuffelAncillaries.test.tsx +1 -1
  135. package/src/tests/lib/createPriceFormatters.test.tsx +1 -1
  136. package/src/tests/lib/formatAvailableServices.test.tsx +1 -1
  137. package/src/tests/lib/formatSeatMaps.test.tsx +2 -2
  138. package/src/tests/lib/getCurrencyForServices.test.tsx +1 -1
  139. package/src/tests/lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected.test.ts +1 -1
  140. package/src/tests/lib/logging.test.tsx +14 -14
  141. package/src/tests/lib/moneyStringFormatter.test.tsx +1 -1
  142. package/src/tests/lib/validateProps.test.tsx +1 -1
  143. package/src/types/DuffelAncillariesProps.ts +1 -1
  144. package/tsconfig.json +1 -1
  145. /package/react-dist/components/{Counter.d.ts → DuffelAncillaries/Counter.d.ts} +0 -0
  146. /package/react-dist/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalBodyListItem.d.ts +0 -0
  147. /package/react-dist/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalHeader.d.ts +0 -0
  148. /package/react-dist/components/{seats → DuffelAncillaries/seats}/DeckSelect.d.ts +0 -0
  149. /package/react-dist/components/{seats → DuffelAncillaries/seats}/EmptyElement.d.ts +0 -0
  150. /package/react-dist/components/{seats → DuffelAncillaries/seats}/ExitElement.d.ts +0 -0
  151. /package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatMapUnavailable.d.ts +0 -0
  152. /package/react-dist/components/{seats → DuffelAncillaries/seats}/SeatSelectionModalBody.d.ts +0 -0
  153. /package/react-dist/components/{AnimatedLoaderEllipsis.d.ts → shared/AnimatedLoaderEllipsis.d.ts} +0 -0
  154. /package/react-dist/components/{FetchOfferErrorState.d.ts → shared/FetchOfferErrorState.d.ts} +0 -0
  155. /package/react-dist/components/{Icon.d.ts → shared/Icon.d.ts} +0 -0
  156. /package/react-dist/components/{Modal.d.ts → shared/Modal.d.ts} +0 -0
  157. /package/react-dist/components/{Stamp.d.ts → shared/Stamp.d.ts} +0 -0
  158. /package/react-dist/components/{Tabs.d.ts → shared/Tabs.d.ts} +0 -0
  159. /package/src/components/{cancel_for_any_reason → DuffelAncillaries/cancel_for_any_reason}/CfarSelectionModalHeader.tsx +0 -0
  160. /package/src/components/{seats → DuffelAncillaries/seats}/EmptyElement.tsx +0 -0
  161. /package/src/components/{AnimatedLoaderEllipsis.tsx → shared/AnimatedLoaderEllipsis.tsx} +0 -0
  162. /package/src/components/{FetchOfferErrorState.tsx → shared/FetchOfferErrorState.tsx} +0 -0
  163. /package/src/components/{Stamp.tsx → shared/Stamp.tsx} +0 -0
  164. /package/src/components/{Tabs.tsx → shared/Tabs.tsx} +0 -0
@@ -1 +1 @@
1
- export declare const captureErrorInSentry: (error: Error, context?: Record<string, any>) => string;
1
+ export declare const captureErrorInSentry: (error: Error) => string;
@@ -1 +1,8 @@
1
+ export interface ErrorResponse extends Response {
2
+ data: {
3
+ meta: any;
4
+ errors: any[];
5
+ };
6
+ }
7
+ export declare const isErrorResponse: (response: any) => response is ErrorResponse;
1
8
  export declare function fetchFromDuffelAPI(withClientKey: string, path: string, method?: string, body?: string): Promise<any>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * The functions in this file are used to enable logging.
4
3
  *
@@ -24,10 +23,12 @@
24
23
  * log('This is a log message')
25
24
  * logGroup('These messages will be grouped together', ['This is a log message', 'This is another log message'])
26
25
  */
27
- declare const initializeLogger: (debugMode: boolean) => {
28
- log: (message: any) => void;
29
- logGroup: typeof logGroup;
30
- };
26
+ declare const initializeLogger: (debugMode: boolean) => void;
27
+ /**
28
+ * Log a message to the console. Messages will be prefixed with "[Duffel Ancillaries]".
29
+ * @param message The message to print to the console.
30
+ */
31
+ declare const log: (message: any) => void;
31
32
  /**
32
33
  * Log a series of messages to the console inside a collapsible group.
33
34
  * @param groupName The name of the group of messages. This will be prefixed with "[Duffel Ancillaries]".
@@ -42,12 +43,4 @@ declare function logGroup(groupName: string, messages: any[]): void;
42
43
  declare function logGroup(groupName: string, object: {
43
44
  [key: string]: any;
44
45
  }): void;
45
- declare const LogContext: import("react").Context<{
46
- log: (message: any) => void;
47
- logGroup: typeof logGroup;
48
- }>;
49
- declare const useLog: () => {
50
- log: (message: any) => void;
51
- logGroup: typeof logGroup;
52
- };
53
- export { LogContext, initializeLogger, useLog };
46
+ export { initializeLogger, logGroup, log };
@@ -1,2 +1,2 @@
1
1
  import { SeatMap } from "../types/SeatMap";
2
- export declare function retrieveSeatMaps(offer_id: string, client_key: string | null, onError: (error: string) => void, setIsLoading: (isLoading: boolean) => void, onSeatMapReady: (seatMaps: SeatMap[]) => void): Promise<void>;
2
+ export declare function retrieveSeatMaps(offer_id: string, client_key: string | null, onError: () => void, setIsLoading: (isLoading: boolean) => void, onSeatMapReady: (seatMaps: SeatMap[]) => void): Promise<void>;
@@ -45,7 +45,7 @@ export type DuffelAncillariesPriceFormatterForSeats = (amount: number, currency:
45
45
  };
46
46
  export type DuffelAncillariesPriceFormatterForCancelForAnyReason = (amount: number, currency: string, service: OfferAvailableServiceCancelForAnyReason) => {
47
47
  amount: number;
48
- currency: string;
48
+ currency?: string;
49
49
  };
50
50
  export interface DuffelAncillariesPriceFormatters {
51
51
  bags?: DuffelAncillariesPriceFormatterForBags;
@@ -10,6 +10,9 @@ const DUFFEL_API_TOKEN = process.env.DUFFEL_API_TOKEN || "";
10
10
  const DUFFEL_API_URL = process.env.DUFFEL_API_URL || "";
11
11
  const VERBOSE = process.env.VERBOSE === "true";
12
12
 
13
+ // eslint-disable-next-line
14
+ const log = console.log;
15
+
13
16
  if (DUFFEL_API_URL.includes("localhost"))
14
17
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
15
18
 
@@ -89,7 +92,8 @@ const main = async () => {
89
92
  const sliceInput = new Array<[string, string]>(sliceCount);
90
93
  for (let i = 0; i < sliceCount; i++) {
91
94
  let origin = sliceInput[i - 1]?.[0];
92
- console.log(`\nSlice #${i + 1}`);
95
+
96
+ log(`\nSlice #${i + 1}`);
93
97
  const { value } = await prompts({
94
98
  type: "text",
95
99
  name: "value",
@@ -108,7 +112,7 @@ const main = async () => {
108
112
  }
109
113
 
110
114
  // ask how many adults
111
- console.log(`\n`);
115
+ log(`\n`);
112
116
  const { adultCount } = await prompts({
113
117
  type: "number",
114
118
  name: "adultCount",
@@ -117,7 +121,7 @@ const main = async () => {
117
121
  });
118
122
 
119
123
  // ask for requested sources
120
- console.log(`\n`);
124
+ log(`\n`);
121
125
  const { requestedSources } = await prompts({
122
126
  type: "text",
123
127
  name: "requestedSources",
@@ -135,7 +139,7 @@ const main = async () => {
135
139
  const airlines = new Set(
136
140
  offerRequest.offers.map((offer) => offer.owner.iata_code)
137
141
  );
138
- console.log(
142
+ log(
139
143
  `Received ${withPlural(
140
144
  offerRequest.offers.length,
141
145
  "offer",
@@ -147,7 +151,7 @@ const main = async () => {
147
151
  "airlines"
148
152
  )}(${Array.from(airlines.values()).join(",")})`
149
153
  );
150
- console.log(
154
+ log(
151
155
  `Search completed, offer request ID: ${offerRequest.id}.\nUsing first offer to get services: ${offerRequest.offers[0].id}\n`
152
156
  );
153
157
  }
@@ -183,10 +187,11 @@ const main = async () => {
183
187
  JSON.stringify(seatMaps, null, 2)
184
188
  );
185
189
 
186
- console.log(`\n🐄 Fixtures saved for ${firstOffer.id}`);
187
- console.log(` ↳ /src/fixtures/offer/${firstOffer.id}.json`);
188
- console.log(` ↳ /src/fixtures/seat-maps/${firstOffer.id}.json\n`);
190
+ log(`\n🐄 Fixtures saved for ${firstOffer.id}`);
191
+ log(` ↳ /src/fixtures/offer/${firstOffer.id}.json`);
192
+ log(` ↳ /src/fixtures/seat-maps/${firstOffer.id}.json\n`);
189
193
  } catch (err) {
194
+ // eslint-disable-next-line
190
195
  console.error(err);
191
196
  process.exit(1);
192
197
  }
@@ -4,7 +4,7 @@
4
4
  set -e
5
5
 
6
6
  # Define where to upload files too
7
- GCP_PREFIX=gs://duffel-assets/components/ancillaries
7
+ GCP_PREFIX=gs://duffel-assets/components
8
8
 
9
9
  # Gets current version from package.json
10
10
  VERSION=$(jq '.version' package.json -r)
@@ -16,7 +16,7 @@ if [ -z "$VERSION" ]; then
16
16
  fi
17
17
 
18
18
  # Check if folder exists
19
- if gsutil -q stat "$GCP_PREFIX/$VERSION/index.js"; then
19
+ if gsutil -q stat "$GCP_PREFIX/$VERSION/duffel-ancillaries.js"; then
20
20
  # Confirm with user before overriding
21
21
  read -p "Version \`$VERSION\` already exists. Do you want to override it? (\`Y\` to continue) " -n 1 -r
22
22
  echo
@@ -30,10 +30,5 @@ if gsutil -q stat "$GCP_PREFIX/$VERSION/index.js"; then
30
30
  fi
31
31
 
32
32
  # Uploads fixtures
33
- gcloud storage cp -r dist/ancillaries "$GCP_PREFIX/$VERSION"
34
-
35
- # Check if --latest argument is provided
36
- if [ "$1" == "--latest" ]; then
37
- # Copies the current version into the latest folder
38
- gcloud storage cp -r "$GCP_PREFIX/$VERSION" "$GCP_PREFIX/latest"
39
- fi
33
+ gcloud storage cp -r cdn-dist "$GCP_PREFIX/$VERSION"
34
+
@@ -1,6 +1,6 @@
1
+ import { Icon, IconName } from "@components/shared/Icon";
1
2
  import classNames from "classnames";
2
3
  import * as React from "react";
3
- import { Icon, IconName } from "./Icon";
4
4
 
5
5
  export interface CardProps {
6
6
  buttonTitle: string;
@@ -1,5 +1,5 @@
1
+ import { IconButton } from "@components/shared/IconButton";
1
2
  import * as React from "react";
2
- import { IconButton } from "./IconButton";
3
3
 
4
4
  interface CounterProps {
5
5
  id: string;
@@ -1,9 +1,11 @@
1
+ import { ErrorBoundary } from "@components/shared/ErrorBoundary";
2
+ import { FetchOfferErrorState } from "@components/shared/FetchOfferErrorState";
1
3
  import { compileCreateOrderPayload } from "@lib/compileCreateOrderPayload";
2
4
  import { createPriceFormatters } from "@lib/createPriceFormatters";
3
5
  import { formatAvailableServices } from "@lib/formatAvailableServices";
4
6
  import { formatSeatMaps } from "@lib/formatSeatMaps";
5
7
  import { isPayloadComplete } from "@lib/isPayloadComplete";
6
- import { LogContext, initializeLogger } from "@lib/logging";
8
+ import { initializeLogger, logGroup } from "@lib/logging";
7
9
  import { offerIsExpired } from "@lib/offerIsExpired";
8
10
  import { retrieveOffer } from "@lib/retrieveOffer";
9
11
  import { retrieveSeatMaps } from "@lib/retrieveSeatMaps";
@@ -19,12 +21,10 @@ import * as React from "react";
19
21
  import {
20
22
  CreateOrderPayloadPassengers,
21
23
  CreateOrderPayloadService,
22
- } from "../types/CreateOrderPayload";
23
- import { DuffelAncillariesProps } from "../types/DuffelAncillariesProps";
24
- import { Offer } from "../types/Offer";
25
- import { SeatMap } from "../types/SeatMap";
26
- import { ErrorBoundary } from "./ErrorBoundary";
27
- import { FetchOfferErrorState } from "./FetchOfferErrorState";
24
+ } from "../../types/CreateOrderPayload";
25
+ import { DuffelAncillariesProps } from "../../types/DuffelAncillariesProps";
26
+ import { Offer } from "../../types/Offer";
27
+ import { SeatMap } from "../../types/SeatMap";
28
28
  import { BaggageSelectionCard } from "./bags/BaggageSelectionCard";
29
29
  import { CfarSelectionCard } from "./cancel_for_any_reason/CfarSelectionCard";
30
30
  import { SeatSelectionCard } from "./seats/SeatSelectionCard";
@@ -33,9 +33,9 @@ const COMPONENT_CDN = process.env.COMPONENT_CDN || "";
33
33
  const hrefToComponentStyles = `${COMPONENT_CDN}/global.css`;
34
34
 
35
35
  export const DuffelAncillaries: React.FC<DuffelAncillariesProps> = (props) => {
36
- const logger = initializeLogger(props.debug || false);
36
+ initializeLogger(props.debug || false);
37
37
 
38
- logger.logGroup("Properties passed into the component:", props);
38
+ logGroup("Properties passed into the component:", props);
39
39
 
40
40
  if (!areDuffelAncillariesPropsValid(props)) {
41
41
  throw new Error(
@@ -186,7 +186,7 @@ export const DuffelAncillaries: React.FC<DuffelAncillariesProps> = (props) => {
186
186
  ? props.offer_id
187
187
  : props.offer.id,
188
188
  !isPropsWithOfferIdForFixture ? props.client_key : null,
189
- setError,
189
+ () => updateSeatMaps([]),
190
190
  setIsSeatMapLoading,
191
191
  updateSeatMaps
192
192
  );
@@ -235,7 +235,7 @@ export const DuffelAncillaries: React.FC<DuffelAncillariesProps> = (props) => {
235
235
  cancel_for_any_reason_services: cfarSelectedServices,
236
236
  };
237
237
 
238
- logger.logGroup("Payload ready", {
238
+ logGroup("Payload ready", {
239
239
  "Order creation payload": createOrderPayload,
240
240
  "Services metadata": metadata,
241
241
  });
@@ -284,63 +284,61 @@ export const DuffelAncillaries: React.FC<DuffelAncillariesProps> = (props) => {
284
284
  error,
285
285
  };
286
286
 
287
- logger.logGroup("Component's internal state:", state);
287
+ logGroup("Component's internal state:", state);
288
288
 
289
289
  return (
290
290
  <>
291
291
  <link rel="stylesheet" href={hrefToComponentStyles}></link>
292
292
 
293
- <LogContext.Provider value={logger}>
294
- <div className="duffel-components" style={duffelComponentsStyle}>
295
- <ErrorBoundary>
296
- {error && (
297
- <FetchOfferErrorState
298
- height={nonIdealStateHeight}
299
- message={error}
300
- />
301
- )}
302
-
303
- {!error &&
304
- props.services.map((ancillaryName) => {
305
- if (ancillaryName === "bags")
306
- return (
307
- <BaggageSelectionCard
308
- key="bags"
309
- isLoading={isOfferLoading}
310
- offer={offer}
311
- passengers={passengers}
312
- selectedServices={baggageSelectedServices}
313
- setSelectedServices={setBaggageSelectedServices}
314
- />
315
- );
316
-
317
- if (ancillaryName === "seats")
318
- return (
319
- <SeatSelectionCard
320
- key="seats"
321
- isLoading={isOfferLoading || isSeatMapLoading}
322
- seatMaps={seatMaps}
323
- offer={offer}
324
- passengers={passengers}
325
- selectedServices={seatSelectedServices}
326
- setSelectedServices={setSeatSelectedServices}
327
- />
328
- );
329
-
330
- if (ancillaryName === "cancel_for_any_reason")
331
- return (
332
- <CfarSelectionCard
333
- key="cancel_for_any_reason"
334
- isLoading={isOfferLoading}
335
- offer={offer}
336
- selectedServices={cfarSelectedServices}
337
- setSelectedServices={setCfarSelectedServices}
338
- />
339
- );
340
- })}
341
- </ErrorBoundary>
342
- </div>
343
- </LogContext.Provider>
293
+ <div className="duffel-components" style={duffelComponentsStyle}>
294
+ <ErrorBoundary>
295
+ {error && (
296
+ <FetchOfferErrorState
297
+ height={nonIdealStateHeight}
298
+ message={error}
299
+ />
300
+ )}
301
+
302
+ {!error &&
303
+ props.services.map((ancillaryName) => {
304
+ if (ancillaryName === "bags")
305
+ return (
306
+ <BaggageSelectionCard
307
+ key="bags"
308
+ isLoading={isOfferLoading}
309
+ offer={offer}
310
+ passengers={passengers}
311
+ selectedServices={baggageSelectedServices}
312
+ setSelectedServices={setBaggageSelectedServices}
313
+ />
314
+ );
315
+
316
+ if (ancillaryName === "seats")
317
+ return (
318
+ <SeatSelectionCard
319
+ key="seats"
320
+ isLoading={isOfferLoading || isSeatMapLoading}
321
+ seatMaps={seatMaps}
322
+ offer={offer}
323
+ passengers={passengers}
324
+ selectedServices={seatSelectedServices}
325
+ setSelectedServices={setSeatSelectedServices}
326
+ />
327
+ );
328
+
329
+ if (ancillaryName === "cancel_for_any_reason")
330
+ return (
331
+ <CfarSelectionCard
332
+ key="cancel_for_any_reason"
333
+ isLoading={isOfferLoading}
334
+ offer={offer}
335
+ selectedServices={cfarSelectedServices}
336
+ setSelectedServices={setCfarSelectedServices}
337
+ />
338
+ );
339
+ })}
340
+ </ErrorBoundary>
341
+ </div>
344
342
  </>
345
343
  );
346
344
  };
@@ -1,5 +1,5 @@
1
1
  import { createRoot, Root } from "react-dom/client";
2
- import { CreateOrderPayload } from "../types/CreateOrderPayload";
2
+ import { CreateOrderPayload } from "../../types/CreateOrderPayload";
3
3
  import {
4
4
  DuffelAncillariesPropsWithClientKeyAndOfferId,
5
5
  DuffelAncillariesPropsWithOfferIdForFixture,
@@ -7,7 +7,7 @@ import {
7
7
  DuffelAncillariesPropWithOfferAndClientKey,
8
8
  OnPayloadReady,
9
9
  OnPayloadReadyMetadata,
10
- } from "../types/DuffelAncillariesProps";
10
+ } from "../../types/DuffelAncillariesProps";
11
11
  import { DuffelAncillaries } from "./DuffelAncillaries";
12
12
 
13
13
  declare global {
@@ -1,3 +1,5 @@
1
+ import { AnimatedLoaderEllipsis } from "@components/shared/AnimatedLoaderEllipsis";
2
+ import { Stamp } from "@components/shared/Stamp";
1
3
  import { getCurrencyForServices } from "@lib/getCurrencyForServices";
2
4
  import { getTotalAmountForServices } from "@lib/getTotalAmountForServices";
3
5
  import { getTotalQuantity } from "@lib/getTotalQuantity";
@@ -8,11 +10,9 @@ import React from "react";
8
10
  import {
9
11
  CreateOrderPayload,
10
12
  CreateOrderPayloadServices,
11
- } from "../../types/CreateOrderPayload";
12
- import { Offer } from "../../types/Offer";
13
- import { AnimatedLoaderEllipsis } from "../AnimatedLoaderEllipsis";
13
+ } from "../../../types/CreateOrderPayload";
14
+ import { Offer } from "../../../types/Offer";
14
15
  import { Card } from "../Card";
15
- import { Stamp } from "../Stamp";
16
16
  import { BaggageSelectionModal } from "./BaggageSelectionModal";
17
17
 
18
18
  export interface BaggageSelectionCardProps {
@@ -2,8 +2,8 @@ import { getBaggageServiceDescription } from "@lib/getBaggageServiceDescription"
2
2
  import { hasServiceOfSameMetadataTypeAlreadyBeenSelected } from "@lib/hasServiceOfSameMetadataTypeAlreadyBeenSelected";
3
3
  import { moneyStringFormatter } from "@lib/moneyStringFormatter";
4
4
  import React from "react";
5
- import { CreateOrderPayloadServices } from "../../types/CreateOrderPayload";
6
- import { OfferAvailableServiceBaggage } from "../../types/Offer";
5
+ import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
6
+ import { OfferAvailableServiceBaggage } from "../../../types/Offer";
7
7
  import { Counter } from "../Counter";
8
8
 
9
9
  interface BaggageSelectionControllerProps {
@@ -1,3 +1,4 @@
1
+ import { Modal } from "@components/shared/Modal";
1
2
  import { getCurrencyForServices } from "@lib/getCurrencyForServices";
2
3
  import { getPassengerMapById } from "@lib/getPassengerMapById";
3
4
  import { getSegmentList } from "@lib/getSegmentList";
@@ -7,9 +8,8 @@ import React, { useState } from "react";
7
8
  import {
8
9
  CreateOrderPayload,
9
10
  CreateOrderPayloadServices,
10
- } from "../../types/CreateOrderPayload";
11
- import { Offer } from "../../types/Offer";
12
- import { Modal } from "../Modal";
11
+ } from "../../../types/CreateOrderPayload";
12
+ import { Offer } from "../../../types/Offer";
13
13
  import { BaggageSelectionModalBody } from "./BaggageSelectionModalBody";
14
14
  import { BaggageSelectionModalFooter } from "./BaggageSelectionModalFooter";
15
15
  import { BaggageSelectionModalHeader } from "./BaggageSelectionModalHeader";
@@ -1,15 +1,15 @@
1
- import { ModalBody } from "@components/Modal";
1
+ import { ModalBody } from "@components/shared/Modal";
2
2
  import { getPassengerName } from "@lib/getPassengerName";
3
3
  import React from "react";
4
4
  import {
5
5
  CreateOrderPayloadPassenger,
6
6
  CreateOrderPayloadServices,
7
- } from "../../types/CreateOrderPayload";
7
+ } from "../../../types/CreateOrderPayload";
8
8
  import {
9
9
  Offer,
10
10
  OfferAvailableServiceBaggage,
11
11
  OfferSliceSegment,
12
- } from "../../types/Offer";
12
+ } from "../../../types/Offer";
13
13
  import { BaggageSelectionModalBodyPassenger } from "./BaggageSelectionModalBodyPassenger";
14
14
 
15
15
  export interface BaggageSelectionModalBodyProps {
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import { CreateOrderPayloadServices } from "../../types/CreateOrderPayload";
2
+ import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
3
3
  import {
4
4
  OfferAvailableServiceBaggage,
5
5
  OfferSliceSegmentPassengerBaggage,
6
- } from "../../types/Offer";
6
+ } from "../../../types/Offer";
7
7
  import { BaggageSelectionController } from "./BaggageSelectionController";
8
8
  import { IncludedBaggageBanner } from "./IncludedBaggageBanner";
9
9
 
@@ -1,11 +1,11 @@
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 "../../types/CreateOrderPayload";
8
- import { Button } from "../Button";
8
+ import { CreateOrderPayloadServices } from "../../../types/CreateOrderPayload";
9
9
 
10
10
  export interface BaggageSelectionModalFooterProps {
11
11
  currency: string;
@@ -1,6 +1,6 @@
1
1
  import { formatDateString } from "@lib/formatDate";
2
2
  import React from "react";
3
- import { OfferSliceSegment } from "../../types/Offer";
3
+ import { OfferSliceSegment } from "../../../types/Offer";
4
4
 
5
5
  export interface BaggageSelectionModalHeaderProps {
6
6
  segmentCount: number;
@@ -1,6 +1,6 @@
1
1
  import { withPlural } from "@lib/withPlural";
2
2
  import React from "react";
3
- import { OfferSliceSegmentPassengerBaggage } from "../../types/Offer";
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 "../../types/CreateOrderPayload";
11
- import { Offer } from "../../types/Offer";
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 "../../types/CreateOrderPayload";
6
+ } from "../../../types/CreateOrderPayload";
6
7
  import {
7
8
  Offer,
8
9
  OfferAvailableServiceCancelForAnyReason,
9
- } from "../../types/Offer";
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 "../../types/Offer";
8
+ } from "../../../types/Offer";
9
9
  import { CfarSelectionModalBodyListItem } from "./CfarSelectionModalBodyListItem";
10
10
 
11
11
  export interface CfarSelectionModalBodyProps {
@@ -1,4 +1,4 @@
1
- import { Icon } from "@components/Icon";
1
+ import { Icon } from "@components/shared/Icon";
2
2
  import React, { ReactNode } from "react";
3
3
 
4
4
  export const CfarSelectionModalBodyListItem: React.FC<{
@@ -1,9 +1,9 @@
1
- import { Icon } from "@components/Icon";
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 "../../types/CreateOrderPayload";
5
- import { OfferAvailableServiceCancelForAnyReason } from "../../types/Offer";
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;
@@ -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 "../../types/SeatMap";
4
- import { Icon, IconName } from "../Icon";
4
+ import { SeatMapCabinRowSectionElementAmenity } from "../../../types/SeatMap";
5
5
 
6
6
  const amenitiesWithoutWrapper = ["bassinet", "exit_row"];
7
7
 
@@ -1,4 +1,4 @@
1
- import { Tabs } from "@components/Tabs";
1
+ import { Tabs } from "@components/shared/Tabs";
2
2
  import * as React from "react";
3
3
 
4
4
  export interface DeckSelectProps {
@@ -1,7 +1,7 @@
1
1
  import { isSeatElement } from "@lib/isSeatElement";
2
2
  import * as React from "react";
3
- import { CreateOrderPayloadSeatService } from "../../types/CreateOrderPayload";
4
- import { SeatMapCabinRowSectionElement } from "../../types/SeatMap";
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 } from "@components/shared/Icon";
1
2
  import classNames from "classnames";
2
3
  import * as React from "react";
3
- import { Icon } from "../Icon";
4
4
 
5
5
  interface ExitElementProps {
6
6
  isRight: boolean;
@@ -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 "../../types/SeatMap";
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 "../../types/CreateOrderPayload";
4
- import { SeatMapCabinRow } from "../../types/SeatMap";
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 {