@moneylion/react-native-offer-carousel 1.4.1 → 1.5.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 (148) hide show
  1. package/lib/commonjs/components/Button/index.js +2 -1
  2. package/lib/commonjs/components/Button/index.js.map +1 -1
  3. package/lib/commonjs/components/Common/DynamicOfferCard/SeeMore.js +6 -3
  4. package/lib/commonjs/components/Common/DynamicOfferCard/SeeMore.js.map +1 -1
  5. package/lib/commonjs/components/Common/DynamicOfferCard/index.js +2 -1
  6. package/lib/commonjs/components/Common/DynamicOfferCard/index.js.map +1 -1
  7. package/lib/commonjs/components/DynamicOffers/DynamicOffers.js +0 -2
  8. package/lib/commonjs/components/DynamicOffers/DynamicOffers.js.map +1 -1
  9. package/lib/commonjs/components/DynamicOffers/DynamicOffersContainer.js +3 -22
  10. package/lib/commonjs/components/DynamicOffers/DynamicOffersContainer.js.map +1 -1
  11. package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js +5 -15
  12. package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
  13. package/lib/commonjs/components/DynamicOffers/SeeAllButton.js +2 -1
  14. package/lib/commonjs/components/DynamicOffers/SeeAllButton.js.map +1 -1
  15. package/lib/commonjs/components/Layouts/DefaultOfferCard/index.js +2 -1
  16. package/lib/commonjs/components/Layouts/DefaultOfferCard/index.js.map +1 -1
  17. package/lib/commonjs/components/Modal/AllOffersModal.js +7 -4
  18. package/lib/commonjs/components/Modal/AllOffersModal.js.map +1 -1
  19. package/lib/commonjs/components/Modal/DescriptionPoints.js +2 -1
  20. package/lib/commonjs/components/Modal/DescriptionPoints.js.map +1 -1
  21. package/lib/commonjs/components/Modal/Disclaimer.js +2 -1
  22. package/lib/commonjs/components/Modal/Disclaimer.js.map +1 -1
  23. package/lib/commonjs/components/Modal/OfferDetailsModal.js +6 -3
  24. package/lib/commonjs/components/Modal/OfferDetailsModal.js.map +1 -1
  25. package/lib/commonjs/components/MoneyLionOfferCarousel.js +2 -8
  26. package/lib/commonjs/components/MoneyLionOfferCarousel.js.map +1 -1
  27. package/lib/commonjs/components/Text/index.js +3 -1
  28. package/lib/commonjs/components/Text/index.js.map +1 -1
  29. package/lib/commonjs/components/Touchable/TouchableOpacity.js +12 -0
  30. package/lib/commonjs/components/Touchable/TouchableOpacity.js.map +1 -0
  31. package/lib/commonjs/components/Touchable/index.js +29 -0
  32. package/lib/commonjs/components/Touchable/index.js.map +1 -0
  33. package/lib/commonjs/components/utils/withTestID.js +55 -0
  34. package/lib/commonjs/components/utils/withTestID.js.map +1 -0
  35. package/lib/commonjs/pageData.js +1 -5
  36. package/lib/commonjs/pageData.js.map +1 -1
  37. package/lib/commonjs/services/getDynamicOffers.js +1 -3
  38. package/lib/commonjs/services/getDynamicOffers.js.map +1 -1
  39. package/lib/commonjs/utils/index.js +0 -11
  40. package/lib/commonjs/utils/index.js.map +1 -1
  41. package/lib/module/components/Button/index.js +2 -1
  42. package/lib/module/components/Button/index.js.map +1 -1
  43. package/lib/module/components/Common/DynamicOfferCard/SeeMore.js +6 -3
  44. package/lib/module/components/Common/DynamicOfferCard/SeeMore.js.map +1 -1
  45. package/lib/module/components/Common/DynamicOfferCard/index.js +2 -1
  46. package/lib/module/components/Common/DynamicOfferCard/index.js.map +1 -1
  47. package/lib/module/components/DynamicOffers/DynamicOffers.js +0 -2
  48. package/lib/module/components/DynamicOffers/DynamicOffers.js.map +1 -1
  49. package/lib/module/components/DynamicOffers/DynamicOffersContainer.js +3 -22
  50. package/lib/module/components/DynamicOffers/DynamicOffersContainer.js.map +1 -1
  51. package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js +5 -15
  52. package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
  53. package/lib/module/components/DynamicOffers/SeeAllButton.js +2 -1
  54. package/lib/module/components/DynamicOffers/SeeAllButton.js.map +1 -1
  55. package/lib/module/components/Layouts/DefaultOfferCard/index.js +2 -1
  56. package/lib/module/components/Layouts/DefaultOfferCard/index.js.map +1 -1
  57. package/lib/module/components/Modal/AllOffersModal.js +6 -3
  58. package/lib/module/components/Modal/AllOffersModal.js.map +1 -1
  59. package/lib/module/components/Modal/DescriptionPoints.js +2 -1
  60. package/lib/module/components/Modal/DescriptionPoints.js.map +1 -1
  61. package/lib/module/components/Modal/Disclaimer.js +2 -1
  62. package/lib/module/components/Modal/Disclaimer.js.map +1 -1
  63. package/lib/module/components/Modal/OfferDetailsModal.js +6 -3
  64. package/lib/module/components/Modal/OfferDetailsModal.js.map +1 -1
  65. package/lib/module/components/MoneyLionOfferCarousel.js +2 -8
  66. package/lib/module/components/MoneyLionOfferCarousel.js.map +1 -1
  67. package/lib/module/components/Text/index.js +3 -1
  68. package/lib/module/components/Text/index.js.map +1 -1
  69. package/lib/module/components/Touchable/TouchableOpacity.js +5 -0
  70. package/lib/module/components/Touchable/TouchableOpacity.js.map +1 -0
  71. package/lib/module/components/Touchable/index.js +3 -0
  72. package/lib/module/components/Touchable/index.js.map +1 -0
  73. package/lib/module/components/utils/withTestID.js +50 -0
  74. package/lib/module/components/utils/withTestID.js.map +1 -0
  75. package/lib/module/pageData.js +2 -6
  76. package/lib/module/pageData.js.map +1 -1
  77. package/lib/module/services/getDynamicOffers.js +1 -3
  78. package/lib/module/services/getDynamicOffers.js.map +1 -1
  79. package/lib/module/utils/index.js +0 -1
  80. package/lib/module/utils/index.js.map +1 -1
  81. package/lib/typescript/src/components/Button/index.d.ts +3 -2
  82. package/lib/typescript/src/components/Button/index.d.ts.map +1 -1
  83. package/lib/typescript/src/components/Common/DynamicOfferCard/SeeMore.d.ts +2 -1
  84. package/lib/typescript/src/components/Common/DynamicOfferCard/SeeMore.d.ts.map +1 -1
  85. package/lib/typescript/src/components/Common/DynamicOfferCard/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/DynamicOffers/DynamicOffers.d.ts +1 -3
  87. package/lib/typescript/src/components/DynamicOffers/DynamicOffers.d.ts.map +1 -1
  88. package/lib/typescript/src/components/DynamicOffers/DynamicOffersContainer.d.ts +1 -4
  89. package/lib/typescript/src/components/DynamicOffers/DynamicOffersContainer.d.ts.map +1 -1
  90. package/lib/typescript/src/components/DynamicOffers/Render/DynamicOffersRender.d.ts +1 -3
  91. package/lib/typescript/src/components/DynamicOffers/Render/DynamicOffersRender.d.ts.map +1 -1
  92. package/lib/typescript/src/components/DynamicOffers/SeeAllButton.d.ts.map +1 -1
  93. package/lib/typescript/src/components/Layouts/DefaultOfferCard/index.d.ts.map +1 -1
  94. package/lib/typescript/src/components/Modal/AllOffersModal.d.ts.map +1 -1
  95. package/lib/typescript/src/components/Modal/DescriptionPoints.d.ts.map +1 -1
  96. package/lib/typescript/src/components/Modal/Disclaimer.d.ts.map +1 -1
  97. package/lib/typescript/src/components/Modal/OfferDetailsModal.d.ts.map +1 -1
  98. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts +0 -2
  99. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts.map +1 -1
  100. package/lib/typescript/src/components/Text/index.d.ts +2 -1
  101. package/lib/typescript/src/components/Text/index.d.ts.map +1 -1
  102. package/lib/typescript/src/components/Touchable/TouchableOpacity.d.ts +7 -0
  103. package/lib/typescript/src/components/Touchable/TouchableOpacity.d.ts.map +1 -0
  104. package/lib/typescript/src/components/Touchable/index.d.ts +3 -0
  105. package/lib/typescript/src/components/Touchable/index.d.ts.map +1 -0
  106. package/lib/typescript/src/components/utils/withTestID.d.ts +4 -0
  107. package/lib/typescript/src/components/utils/withTestID.d.ts.map +1 -0
  108. package/lib/typescript/src/pageData.d.ts +0 -1
  109. package/lib/typescript/src/pageData.d.ts.map +1 -1
  110. package/lib/typescript/src/services/getDynamicOffers.d.ts +1 -3
  111. package/lib/typescript/src/services/getDynamicOffers.d.ts.map +1 -1
  112. package/lib/typescript/src/utils/index.d.ts +0 -1
  113. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  114. package/package.json +1 -1
  115. package/src/components/Button/index.tsx +6 -3
  116. package/src/components/Common/DynamicOfferCard/SeeMore.tsx +9 -2
  117. package/src/components/Common/DynamicOfferCard/index.tsx +1 -0
  118. package/src/components/DynamicOffers/DynamicOffers.tsx +0 -4
  119. package/src/components/DynamicOffers/DynamicOffersContainer.tsx +2 -21
  120. package/src/components/DynamicOffers/Render/DynamicOffersRender.tsx +11 -27
  121. package/src/components/DynamicOffers/SeeAllButton.tsx +1 -0
  122. package/src/components/Layouts/DefaultOfferCard/index.tsx +1 -0
  123. package/src/components/Modal/AllOffersModal.tsx +3 -1
  124. package/src/components/Modal/DescriptionPoints.tsx +6 -1
  125. package/src/components/Modal/Disclaimer.tsx +6 -1
  126. package/src/components/Modal/OfferDetailsModal.tsx +3 -1
  127. package/src/components/MoneyLionOfferCarousel.tsx +2 -6
  128. package/src/components/Text/index.tsx +7 -2
  129. package/src/components/Touchable/TouchableOpacity.tsx +15 -0
  130. package/src/components/Touchable/index.ts +2 -0
  131. package/src/components/utils/withTestID.tsx +56 -0
  132. package/src/pageData.ts +0 -6
  133. package/src/services/getDynamicOffers.ts +1 -5
  134. package/src/utils/index.ts +0 -1
  135. package/lib/commonjs/utils/getOffersBasedOnLayout.js +0 -48
  136. package/lib/commonjs/utils/getOffersBasedOnLayout.js.map +0 -1
  137. package/lib/commonjs/utils/layouts.js +0 -27
  138. package/lib/commonjs/utils/layouts.js.map +0 -1
  139. package/lib/module/utils/getOffersBasedOnLayout.js +0 -39
  140. package/lib/module/utils/getOffersBasedOnLayout.js.map +0 -1
  141. package/lib/module/utils/layouts.js +0 -20
  142. package/lib/module/utils/layouts.js.map +0 -1
  143. package/lib/typescript/src/utils/getOffersBasedOnLayout.d.ts +0 -26
  144. package/lib/typescript/src/utils/getOffersBasedOnLayout.d.ts.map +0 -1
  145. package/lib/typescript/src/utils/layouts.d.ts +0 -19
  146. package/lib/typescript/src/utils/layouts.d.ts.map +0 -1
  147. package/src/utils/getOffersBasedOnLayout.ts +0 -51
  148. package/src/utils/layouts.ts +0 -22
@@ -4,7 +4,6 @@ import {
4
4
  View,
5
5
  SafeAreaView,
6
6
  ScrollView,
7
- TouchableOpacity,
8
7
  StyleSheet,
9
8
  Linking,
10
9
  type LayoutChangeEvent,
@@ -15,6 +14,7 @@ import Text from "../Text";
15
14
  import { DynamicOffersContainer } from "../DynamicOffers/DynamicOffersContainer";
16
15
  import type { DynamicOfferProps } from "../DynamicOffers/DynamicOffers";
17
16
  import { useTheme } from "../../context/ThemeProvider";
17
+ import { TouchableOpacity } from "../Touchable";
18
18
 
19
19
  type AllOffersModalProps = {
20
20
  visible: boolean;
@@ -114,6 +114,7 @@ export const AllOffersModal = ({
114
114
  onPress={onClose}
115
115
  style={styles.closeXButton}
116
116
  hitSlop={{ top: 15, right: 15, bottom: 15, left: 15 }}
117
+ testID="offer_carousel.all_offers_modal.close_button"
117
118
  >
118
119
  <Text style={styles.closeXText} color={"foregroundNeutral"}>
119
120
 
@@ -124,6 +125,7 @@ export const AllOffersModal = ({
124
125
  weight="bold"
125
126
  color={"foregroundNeutral"}
126
127
  style={styles.headerTitle}
128
+ testID="offer_carousel.all_offers_modal.title"
127
129
  >
128
130
  {title}
129
131
  </Text>
@@ -11,7 +11,12 @@ export function DescriptionPoints({
11
11
  }) {
12
12
  return (
13
13
  <View gap={8}>
14
- <Text variant={"body-3"} weight={"bold"} color={"foregroundNeutral"}>
14
+ <Text
15
+ variant={"body-3"}
16
+ weight={"bold"}
17
+ color={"foregroundNeutral"}
18
+ testID="offer_carousel.offer_details_modal.offer_details_title"
19
+ >
15
20
  Offer Details
16
21
  </Text>
17
22
  <MarkdownText
@@ -6,7 +6,12 @@ import { MarkdownText } from "../../capabilities/ui/elements/src/components/Mark
6
6
  export function Disclaimer({ disclaimer }: { disclaimer: string }) {
7
7
  return (
8
8
  <View gap={16}>
9
- <Text variant={"body-3"} weight={"bold"} color={"foregroundNeutral"}>
9
+ <Text
10
+ variant={"body-3"}
11
+ weight={"bold"}
12
+ color={"foregroundNeutral"}
13
+ testID="offer_carousel.offer_details_modal.provider_disclaimer_title"
14
+ >
10
15
  Provider Disclaimer
11
16
  </Text>
12
17
  <MarkdownText
@@ -4,7 +4,6 @@ import {
4
4
  View,
5
5
  SafeAreaView,
6
6
  ScrollView,
7
- TouchableOpacity,
8
7
  StyleSheet,
9
8
  StatusBar,
10
9
  Platform,
@@ -16,6 +15,7 @@ import { CallToAction } from "../Common/DynamicOfferCard/CallToAction";
16
15
  import Divider from "../Divider";
17
16
  import type { BaseOffer } from "../../capabilities/offer-catalog/src";
18
17
  import { useTheme } from "../../context/ThemeProvider";
18
+ import { TouchableOpacity } from "../Touchable";
19
19
 
20
20
  type OfferDetailsModalProps = {
21
21
  visible: boolean;
@@ -68,6 +68,7 @@ export const OfferDetailsModal = ({
68
68
  onPress={onClose}
69
69
  style={styles.closeXButton}
70
70
  hitSlop={{ top: 15, right: 15, bottom: 15, left: 15 }}
71
+ testID="offer_carousel.offer_details_modal.close_button"
71
72
  >
72
73
  <Text
73
74
  style={[styles.closeXText, { color: theme.foregroundNeutral }]}
@@ -94,6 +95,7 @@ export const OfferDetailsModal = ({
94
95
  overrideUrl={offer.overrideUrl}
95
96
  style={styles.cta}
96
97
  context={"offer_details"}
98
+ testID="offer_carousel.offer_details_modal.cta"
97
99
  >
98
100
  {CTA_LABEL}
99
101
  </CallToAction>
@@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useState } from "react";
2
2
  import { localCnfContext } from "../config/mocks/cnfContext";
3
3
  import { Text } from "react-native";
4
4
  import { getPageData } from "../pageData";
5
- import type { Layout } from "../utils";
6
5
  import {
7
6
  DynamicOffersContainer,
8
7
  DynamicOfferSkeleton,
@@ -34,7 +33,6 @@ export type MoneyLionOfferCarouselProps = {
34
33
  productType?: string;
35
34
  query?: string;
36
35
  tags?: string;
37
- displayLayout?: Layout;
38
36
  staticProductTypes?: string;
39
37
  fontFamily?: Partial<FontFamily>;
40
38
  showProductTypeLabel?: boolean;
@@ -247,7 +245,7 @@ const InternalMoneyLionOfferCarousel = (
247
245
  );
248
246
 
249
247
  if (isLoading) {
250
- return <DynamicOfferSkeleton displayLayout={"fixed"} />;
248
+ return <DynamicOfferSkeleton />;
251
249
  }
252
250
 
253
251
  if (error) {
@@ -259,12 +257,11 @@ const InternalMoneyLionOfferCarousel = (
259
257
  }
260
258
 
261
259
  if (!pageData) {
262
- return <DynamicOfferSkeleton displayLayout={"fixed"} />;
260
+ return <DynamicOfferSkeleton />;
263
261
  }
264
262
 
265
263
  const {
266
264
  shouldHideFooter,
267
- displayLayout,
268
265
  showProductTypeLabel,
269
266
  showCardBorder,
270
267
  offers,
@@ -275,7 +272,6 @@ const InternalMoneyLionOfferCarousel = (
275
272
  const config: DynamicOfferProps = {
276
273
  offers,
277
274
  shouldHideFooter,
278
- displayLayout,
279
275
  showProductTypeLabel,
280
276
  showCardBorder,
281
277
  title,
@@ -7,6 +7,7 @@ import {
7
7
  type TextProps as RNTextProps,
8
8
  } from "react-native";
9
9
  import { useTheme, type ThemeColors } from "../../context/ThemeProvider";
10
+ import withTestID from "../utils/withTestID";
10
11
 
11
12
  // Define the variant types
12
13
  export type Variant =
@@ -41,6 +42,10 @@ export interface TextProps extends Omit<RNTextProps, "style"> {
41
42
  style?: StyleProp<TextStyle>;
42
43
  }
43
44
 
45
+ export type TextRef = React.ElementRef<typeof RNText>;
46
+
47
+ const TextWithTestID = withTestID<TextProps, TextRef>(RNText);
48
+
44
49
  const Text: React.FC<TextProps> = ({
45
50
  variant,
46
51
  weight,
@@ -85,9 +90,9 @@ const Text: React.FC<TextProps> = ({
85
90
  }
86
91
 
87
92
  return (
88
- <RNText style={styleArray} ellipsizeMode={"tail"} {...restProps}>
93
+ <TextWithTestID style={styleArray} ellipsizeMode={"tail"} {...restProps}>
89
94
  {children}
90
- </RNText>
95
+ </TextWithTestID>
91
96
  );
92
97
  };
93
98
 
@@ -0,0 +1,15 @@
1
+ import { TouchableOpacity as RNTouchableOpacity } from "react-native";
2
+
3
+ import withTestID from "../utils/withTestID";
4
+
5
+ export type TouchableOpacityProps = React.ComponentProps<
6
+ typeof RNTouchableOpacity
7
+ >;
8
+
9
+ export type TouchableOpacityRef = React.ElementRef<typeof RNTouchableOpacity>;
10
+
11
+ const TouchableOpacity = withTestID<TouchableOpacityProps, TouchableOpacityRef>(
12
+ RNTouchableOpacity
13
+ );
14
+
15
+ export default TouchableOpacity;
@@ -0,0 +1,2 @@
1
+ export { default as TouchableOpacity } from "./TouchableOpacity";
2
+ export * from "./TouchableOpacity";
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { Platform } from "react-native";
3
+
4
+ //#region generateAccessibilityLabel
5
+ /**
6
+ * TestID would work on IOS, and accessibilityLabel would work on android
7
+ * However if both are available in the component, IOS won't work
8
+ * Workaround: https://stackoverflow.com/a/54844164
9
+ * There is a related fix on React native >0.65.x version https://github.com/facebook/react-native/commit/381fb395ad9d2d48717a5d082aaedbecdd804554
10
+ * Will revisit on new react native version if issue still persist
11
+ */
12
+ const generateAccessibilityLabel = (accessibilityLabel?: string) => {
13
+ if (!accessibilityLabel) {
14
+ return;
15
+ }
16
+ return Platform.select({
17
+ ios: undefined,
18
+ android: accessibilityLabel,
19
+ });
20
+ };
21
+ //#endregion
22
+
23
+ //#region testID prop types
24
+ type AccessibilityProps = import("react-native").AccessibilityProps;
25
+ type ViewProps = import("react-native").ViewProps;
26
+ type TestIDProps = Pick<AccessibilityProps, "accessibilityLabel"> &
27
+ Pick<ViewProps, "testID">;
28
+ //#endregion
29
+
30
+ //#region withTestID wrapper
31
+ function withTestID<P extends object, R = unknown>(
32
+ Component: React.ComponentType<P & React.RefAttributes<R>>
33
+ ) {
34
+ const WrappedComponent = React.forwardRef<R, P & TestIDProps>(
35
+ (props, ref) => {
36
+ const { accessibilityLabel, testID, ...rest } = props;
37
+ // In development, use testID as accessibilityLabel if not provided
38
+ const label =
39
+ __DEV__ && !accessibilityLabel ? testID : accessibilityLabel;
40
+
41
+ return (
42
+ <Component
43
+ {...(rest as P)}
44
+ ref={ref}
45
+ testID={testID}
46
+ accessibilityLabel={generateAccessibilityLabel(label)}
47
+ />
48
+ );
49
+ }
50
+ );
51
+ WrappedComponent.displayName = `withTestID(${Component.displayName || Component.name || "Component"})`;
52
+ return WrappedComponent;
53
+ }
54
+ //#endregion
55
+
56
+ export default withTestID;
package/src/pageData.ts CHANGED
@@ -7,7 +7,6 @@ import { getDynamicOffers } from "./services/getDynamicOffers";
7
7
  // import { getDynamicOffers } from "./services/getDynamicOffers";
8
8
  import {
9
9
  getDefaultProductType,
10
- getLayout,
11
10
  getProductTypesDefinition,
12
11
  resolveProductTypes,
13
12
  } from "./utils";
@@ -28,7 +27,6 @@ export async function getPageData({
28
27
  productType,
29
28
  query,
30
29
  tags,
31
- displayLayout,
32
30
  searchAPIToken,
33
31
  showProductTypeLabel,
34
32
  showCardBorder,
@@ -53,8 +51,6 @@ export async function getPageData({
53
51
 
54
52
  const safeTags = encodeURI(resolvedTags);
55
53
 
56
- const safeDisplayLayout = getLayout(displayLayout);
57
-
58
54
  // Get product types and result type
59
55
  const { productTypes, resultType } = await resolveProductTypes({
60
56
  defaultProductType,
@@ -75,7 +71,6 @@ export async function getPageData({
75
71
  const { offers, isError, leadUuid, rateTableUuid, errorCode } =
76
72
  await getDynamicOffers({
77
73
  tags: safeTags,
78
- displayLayout: safeDisplayLayout,
79
74
  productTypes,
80
75
  resultType,
81
76
  isCachedOffersRequest,
@@ -97,6 +92,5 @@ export async function getPageData({
97
92
  showCardBorder,
98
93
  // shouldHideFooter,
99
94
  showProductTypeLabel,
100
- displayLayout: safeDisplayLayout,
101
95
  };
102
96
  }
@@ -3,7 +3,6 @@ import {
3
3
  addClientTagsToOfferLinks,
4
4
  getOffersByProductTypes,
5
5
  selectDynamicOffers,
6
- type Layout,
7
6
  } from "../utils";
8
7
  import type {
9
8
  GetProductTypesProps,
@@ -12,7 +11,6 @@ import type {
12
11
  import { sortOffersByRecommendationScore } from "../utils/sortOffersByRecommendationScore";
13
12
  import { pipe } from "effect";
14
13
  import { formatOfferUrl } from "../utils/formatOfferUrl";
15
- import { getOffersBasedOnLayout } from "../utils/getOffersBasedOnLayout";
16
14
  import type {
17
15
  PartnerOverride,
18
16
  ProductTypeDefinition,
@@ -21,7 +19,6 @@ import type { CnfContext } from "../capabilities/core/src/system/cnfContext/CnfC
21
19
 
22
20
  export type GetDynamicOffersProps = {
23
21
  tags: string;
24
- displayLayout: Layout;
25
22
  productTypes: string[];
26
23
  resultType: ProductTypesResult["resultType"];
27
24
  isCachedOffersRequest: boolean;
@@ -46,7 +43,6 @@ export type GetDynamicOffersProps = {
46
43
  */
47
44
  export const getDynamicOffers = async ({
48
45
  tags,
49
- displayLayout,
50
46
  defaultProductType,
51
47
  productTypes,
52
48
  resultType,
@@ -92,7 +88,7 @@ export const getDynamicOffers = async ({
92
88
  sortedOffers,
93
89
  formatOfferUrl(productTypesDefinition, partnersOverrideDefinition),
94
90
  addClientTagsToOfferLinks(isCachedOffersRequest, tags),
95
- getOffersBasedOnLayout(displayLayout)
91
+ sortOffersByRecommendationScore
96
92
  ),
97
93
  isError,
98
94
  errorCode,
@@ -2,7 +2,6 @@ export * from "./addClientTagsToOfferLinks";
2
2
  export * from "./getDefaultProductType";
3
3
  export * from "./getOffersByProductTypes";
4
4
  export * from "./getProductTypesDefinition";
5
- export * from "./layouts";
6
5
  export * from "./resolveProductTypes";
7
6
  export * from "./selectDynamicOffers";
8
7
  export * from "./sortOffersByRecommendationScore";
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sortFixedOffers = exports.getOffersByLayout = exports.getOffersBasedOnLayout = void 0;
7
- var _effect = require("effect");
8
- var _sortOffersByRecommendationScore = require("./sortOffersByRecommendationScore");
9
- const MAX_OFFERS_TO_DISPLAY = 3;
10
-
11
- /**
12
- * Sorts the offers based on the layout.
13
- *
14
- * @param offers - The offers to sort.
15
- * @returns The sorted offers.
16
- */
17
- const sortFixedOffers = offers => {
18
- const resultOffers = Array.from({
19
- length: offers.length >= MAX_OFFERS_TO_DISPLAY ? MAX_OFFERS_TO_DISPLAY : offers.length
20
- }, (_, index) => offers[index % offers.length]).filter(offer => offer !== undefined);
21
- return resultOffers;
22
- };
23
-
24
- /**
25
- * Gets the offers based on the layout.
26
- *
27
- * @param layout - The layout to get the offers for.
28
- * @param offers - The offers to get.
29
- * @returns The offers.
30
- */
31
- exports.sortFixedOffers = sortFixedOffers;
32
- const getOffersByLayout = layout => offers => {
33
- return layout === "carousel" ? (0, _sortOffersByRecommendationScore.sortOffersByRecommendationScore)(offers) : sortFixedOffers(offers);
34
- };
35
-
36
- /**
37
- * Gets the offers based on the layout.
38
- *
39
- * @param layout - The layout to get the offers for.
40
- * @param offers - The offers to get.
41
- * @returns The offers.
42
- */
43
- exports.getOffersByLayout = getOffersByLayout;
44
- const getOffersBasedOnLayout = layout => offers => {
45
- return (0, _effect.pipe)(offers, getOffersByLayout(layout));
46
- };
47
- exports.getOffersBasedOnLayout = getOffersBasedOnLayout;
48
- //# sourceMappingURL=getOffersBasedOnLayout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_effect","require","_sortOffersByRecommendationScore","MAX_OFFERS_TO_DISPLAY","sortFixedOffers","offers","resultOffers","Array","from","length","_","index","filter","offer","undefined","exports","getOffersByLayout","layout","sortOffersByRecommendationScore","getOffersBasedOnLayout","pipe"],"sourceRoot":"../../../src","sources":["utils/getOffersBasedOnLayout.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,gCAAA,GAAAD,OAAA;AAGA,MAAME,qBAAqB,GAAG,CAAC;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,GAAIC,MAAmB,IAAkB;EACpE,MAAMC,YAAY,GAAGC,KAAK,CAACC,IAAI,CAC9B;IACCC,MAAM,EACLJ,MAAM,CAACI,MAAM,IAAIN,qBAAqB,GACnCA,qBAAqB,GACrBE,MAAM,CAACI;EACZ,CAAC,EACD,CAACC,CAAC,EAAEC,KAAK,KAAKN,MAAM,CAACM,KAAK,GAAGN,MAAM,CAACI,MAAM,CAC3C,CAAC,CAACG,MAAM,CAAEC,KAAK,IAAyBA,KAAK,KAAKC,SAAS,CAAC;EAE5D,OAAOR,YAAY;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAS,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAOO,MAAMY,iBAAiB,GAAIC,MAAc,IAAMZ,MAAmB,IAAK;EAC7E,OAAOY,MAAM,KAAK,UAAU,GACzB,IAAAC,gEAA+B,EAACb,MAAM,CAAC,GACvCD,eAAe,CAACC,MAAM,CAAC;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAU,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAOO,MAAMG,sBAAsB,GACjCF,MAAc,IAAMZ,MAAmB,IAAK;EAC5C,OAAO,IAAAe,YAAI,EAACf,MAAM,EAAEW,iBAAiB,CAACC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAACF,OAAA,CAAAI,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.layouts = exports.getLayout = void 0;
7
- const layouts = exports.layouts = {
8
- carousel: "carousel",
9
- fixed: "fixed"
10
- };
11
- /**
12
- * Get layout based on the provided layout
13
- * @param layout {string | null} layout
14
- * @returns {Layout} layout or default layout
15
- *
16
- * @example
17
- * getLayout('fixed') // 'fixed'
18
- * getLayout('invalidLayout') // 'carousel'
19
- * getLayout(null) // 'carousel'
20
- * getLayout('') // 'carousel'
21
- * getLayout('carousel') // 'carousel'
22
- */
23
- const getLayout = layout => {
24
- return layouts[layout] ?? layouts.carousel;
25
- };
26
- exports.getLayout = getLayout;
27
- //# sourceMappingURL=layouts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["layouts","exports","carousel","fixed","getLayout","layout"],"sourceRoot":"../../../src","sources":["utils/layouts.ts"],"mappings":";;;;;;AAAO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG;EACtBE,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE;AACR,CAAU;AAIV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GAAIC,MAAe,IAAa;EACrD,OAAOL,OAAO,CAACK,MAAM,CAAW,IAAIL,OAAO,CAACE,QAAQ;AACrD,CAAC;AAACD,OAAA,CAAAG,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,39 +0,0 @@
1
- import { pipe } from "effect";
2
- import { sortOffersByRecommendationScore } from "./sortOffersByRecommendationScore";
3
- const MAX_OFFERS_TO_DISPLAY = 3;
4
-
5
- /**
6
- * Sorts the offers based on the layout.
7
- *
8
- * @param offers - The offers to sort.
9
- * @returns The sorted offers.
10
- */
11
- export const sortFixedOffers = offers => {
12
- const resultOffers = Array.from({
13
- length: offers.length >= MAX_OFFERS_TO_DISPLAY ? MAX_OFFERS_TO_DISPLAY : offers.length
14
- }, (_, index) => offers[index % offers.length]).filter(offer => offer !== undefined);
15
- return resultOffers;
16
- };
17
-
18
- /**
19
- * Gets the offers based on the layout.
20
- *
21
- * @param layout - The layout to get the offers for.
22
- * @param offers - The offers to get.
23
- * @returns The offers.
24
- */
25
- export const getOffersByLayout = layout => offers => {
26
- return layout === "carousel" ? sortOffersByRecommendationScore(offers) : sortFixedOffers(offers);
27
- };
28
-
29
- /**
30
- * Gets the offers based on the layout.
31
- *
32
- * @param layout - The layout to get the offers for.
33
- * @param offers - The offers to get.
34
- * @returns The offers.
35
- */
36
- export const getOffersBasedOnLayout = layout => offers => {
37
- return pipe(offers, getOffersByLayout(layout));
38
- };
39
- //# sourceMappingURL=getOffersBasedOnLayout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["pipe","sortOffersByRecommendationScore","MAX_OFFERS_TO_DISPLAY","sortFixedOffers","offers","resultOffers","Array","from","length","_","index","filter","offer","undefined","getOffersByLayout","layout","getOffersBasedOnLayout"],"sourceRoot":"../../../src","sources":["utils/getOffersBasedOnLayout.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,SAASC,+BAA+B,QAAQ,mCAAmC;AAGnF,MAAMC,qBAAqB,GAAG,CAAC;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAIC,MAAmB,IAAkB;EACpE,MAAMC,YAAY,GAAGC,KAAK,CAACC,IAAI,CAC9B;IACCC,MAAM,EACLJ,MAAM,CAACI,MAAM,IAAIN,qBAAqB,GACnCA,qBAAqB,GACrBE,MAAM,CAACI;EACZ,CAAC,EACD,CAACC,CAAC,EAAEC,KAAK,KAAKN,MAAM,CAACM,KAAK,GAAGN,MAAM,CAACI,MAAM,CAC3C,CAAC,CAACG,MAAM,CAAEC,KAAK,IAAyBA,KAAK,KAAKC,SAAS,CAAC;EAE5D,OAAOR,YAAY;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMS,iBAAiB,GAAIC,MAAc,IAAMX,MAAmB,IAAK;EAC7E,OAAOW,MAAM,KAAK,UAAU,GACzBd,+BAA+B,CAACG,MAAM,CAAC,GACvCD,eAAe,CAACC,MAAM,CAAC;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,sBAAsB,GACjCD,MAAc,IAAMX,MAAmB,IAAK;EAC5C,OAAOJ,IAAI,CAACI,MAAM,EAAEU,iBAAiB,CAACC,MAAM,CAAC,CAAC;AAC/C,CAAC","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- export const layouts = {
2
- carousel: "carousel",
3
- fixed: "fixed"
4
- };
5
- /**
6
- * Get layout based on the provided layout
7
- * @param layout {string | null} layout
8
- * @returns {Layout} layout or default layout
9
- *
10
- * @example
11
- * getLayout('fixed') // 'fixed'
12
- * getLayout('invalidLayout') // 'carousel'
13
- * getLayout(null) // 'carousel'
14
- * getLayout('') // 'carousel'
15
- * getLayout('carousel') // 'carousel'
16
- */
17
- export const getLayout = layout => {
18
- return layouts[layout] ?? layouts.carousel;
19
- };
20
- //# sourceMappingURL=layouts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["layouts","carousel","fixed","getLayout","layout"],"sourceRoot":"../../../src","sources":["utils/layouts.ts"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAG;EACtBC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE;AACR,CAAU;AAIV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAIC,MAAe,IAAa;EACrD,OAAOJ,OAAO,CAACI,MAAM,CAAW,IAAIJ,OAAO,CAACC,QAAQ;AACrD,CAAC","ignoreList":[]}
@@ -1,26 +0,0 @@
1
- import type { Layout } from "./layouts";
2
- import type { BaseOffer } from "../capabilities/offer-catalog/src";
3
- /**
4
- * Sorts the offers based on the layout.
5
- *
6
- * @param offers - The offers to sort.
7
- * @returns The sorted offers.
8
- */
9
- export declare const sortFixedOffers: (offers: BaseOffer[]) => BaseOffer[];
10
- /**
11
- * Gets the offers based on the layout.
12
- *
13
- * @param layout - The layout to get the offers for.
14
- * @param offers - The offers to get.
15
- * @returns The offers.
16
- */
17
- export declare const getOffersByLayout: (layout: Layout) => (offers: BaseOffer[]) => BaseOffer[];
18
- /**
19
- * Gets the offers based on the layout.
20
- *
21
- * @param layout - The layout to get the offers for.
22
- * @param offers - The offers to get.
23
- * @returns The offers.
24
- */
25
- export declare const getOffersBasedOnLayout: (layout: Layout) => (offers: BaseOffer[]) => BaseOffer[];
26
- //# sourceMappingURL=getOffersBasedOnLayout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getOffersBasedOnLayout.d.ts","sourceRoot":"","sources":["../../../../src/utils/getOffersBasedOnLayout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAInE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,WAAY,SAAS,EAAE,KAAG,SAAS,EAY9D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,WAAY,MAAM,cAAc,SAAS,EAAE,gBAIxE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,WACzB,MAAM,cAAc,SAAS,EAAE,gBAEvC,CAAC"}
@@ -1,19 +0,0 @@
1
- export declare const layouts: {
2
- readonly carousel: "carousel";
3
- readonly fixed: "fixed";
4
- };
5
- export type Layout = keyof typeof layouts;
6
- /**
7
- * Get layout based on the provided layout
8
- * @param layout {string | null} layout
9
- * @returns {Layout} layout or default layout
10
- *
11
- * @example
12
- * getLayout('fixed') // 'fixed'
13
- * getLayout('invalidLayout') // 'carousel'
14
- * getLayout(null) // 'carousel'
15
- * getLayout('') // 'carousel'
16
- * getLayout('carousel') // 'carousel'
17
- */
18
- export declare const getLayout: (layout?: string) => Layout;
19
- //# sourceMappingURL=layouts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../../src/utils/layouts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;CAGV,CAAC;AAEX,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,OAAO,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,YAAa,MAAM,KAAG,MAE3C,CAAC"}
@@ -1,51 +0,0 @@
1
- import { pipe } from "effect";
2
- import type { Layout } from "./layouts";
3
- import { sortOffersByRecommendationScore } from "./sortOffersByRecommendationScore";
4
- import type { BaseOffer } from "../capabilities/offer-catalog/src";
5
-
6
- const MAX_OFFERS_TO_DISPLAY = 3;
7
-
8
- /**
9
- * Sorts the offers based on the layout.
10
- *
11
- * @param offers - The offers to sort.
12
- * @returns The sorted offers.
13
- */
14
- export const sortFixedOffers = (offers: BaseOffer[]): BaseOffer[] => {
15
- const resultOffers = Array.from(
16
- {
17
- length:
18
- offers.length >= MAX_OFFERS_TO_DISPLAY
19
- ? MAX_OFFERS_TO_DISPLAY
20
- : offers.length,
21
- },
22
- (_, index) => offers[index % offers.length]
23
- ).filter((offer): offer is BaseOffer => offer !== undefined);
24
-
25
- return resultOffers;
26
- };
27
-
28
- /**
29
- * Gets the offers based on the layout.
30
- *
31
- * @param layout - The layout to get the offers for.
32
- * @param offers - The offers to get.
33
- * @returns The offers.
34
- */
35
- export const getOffersByLayout = (layout: Layout) => (offers: BaseOffer[]) => {
36
- return layout === "carousel"
37
- ? sortOffersByRecommendationScore(offers)
38
- : sortFixedOffers(offers);
39
- };
40
-
41
- /**
42
- * Gets the offers based on the layout.
43
- *
44
- * @param layout - The layout to get the offers for.
45
- * @param offers - The offers to get.
46
- * @returns The offers.
47
- */
48
- export const getOffersBasedOnLayout =
49
- (layout: Layout) => (offers: BaseOffer[]) => {
50
- return pipe(offers, getOffersByLayout(layout));
51
- };
@@ -1,22 +0,0 @@
1
- export const layouts = {
2
- carousel: "carousel",
3
- fixed: "fixed",
4
- } as const;
5
-
6
- export type Layout = keyof typeof layouts;
7
-
8
- /**
9
- * Get layout based on the provided layout
10
- * @param layout {string | null} layout
11
- * @returns {Layout} layout or default layout
12
- *
13
- * @example
14
- * getLayout('fixed') // 'fixed'
15
- * getLayout('invalidLayout') // 'carousel'
16
- * getLayout(null) // 'carousel'
17
- * getLayout('') // 'carousel'
18
- * getLayout('carousel') // 'carousel'
19
- */
20
- export const getLayout = (layout?: string): Layout => {
21
- return layouts[layout as Layout] ?? layouts.carousel;
22
- };