@moneylion/react-native-offer-carousel 1.4.0 → 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 (160) 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/BaseOfferCard/index.js +17 -6
  4. package/lib/commonjs/components/Common/BaseOfferCard/index.js.map +1 -1
  5. package/lib/commonjs/components/Common/DynamicOfferCard/SeeMore.js +6 -3
  6. package/lib/commonjs/components/Common/DynamicOfferCard/SeeMore.js.map +1 -1
  7. package/lib/commonjs/components/Common/DynamicOfferCard/index.js +2 -1
  8. package/lib/commonjs/components/Common/DynamicOfferCard/index.js.map +1 -1
  9. package/lib/commonjs/components/Divider/index.js +0 -2
  10. package/lib/commonjs/components/Divider/index.js.map +1 -1
  11. package/lib/commonjs/components/DynamicOffers/DynamicOffers.js +0 -2
  12. package/lib/commonjs/components/DynamicOffers/DynamicOffers.js.map +1 -1
  13. package/lib/commonjs/components/DynamicOffers/DynamicOffersContainer.js +3 -22
  14. package/lib/commonjs/components/DynamicOffers/DynamicOffersContainer.js.map +1 -1
  15. package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js +6 -15
  16. package/lib/commonjs/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
  17. package/lib/commonjs/components/DynamicOffers/SeeAllButton.js +2 -1
  18. package/lib/commonjs/components/DynamicOffers/SeeAllButton.js.map +1 -1
  19. package/lib/commonjs/components/Layouts/DefaultOfferCard/index.js +2 -1
  20. package/lib/commonjs/components/Layouts/DefaultOfferCard/index.js.map +1 -1
  21. package/lib/commonjs/components/Modal/AllOffersModal.js +7 -4
  22. package/lib/commonjs/components/Modal/AllOffersModal.js.map +1 -1
  23. package/lib/commonjs/components/Modal/DescriptionPoints.js +2 -1
  24. package/lib/commonjs/components/Modal/DescriptionPoints.js.map +1 -1
  25. package/lib/commonjs/components/Modal/Disclaimer.js +2 -1
  26. package/lib/commonjs/components/Modal/Disclaimer.js.map +1 -1
  27. package/lib/commonjs/components/Modal/OfferDetailsModal.js +13 -8
  28. package/lib/commonjs/components/Modal/OfferDetailsModal.js.map +1 -1
  29. package/lib/commonjs/components/MoneyLionOfferCarousel.js +2 -8
  30. package/lib/commonjs/components/MoneyLionOfferCarousel.js.map +1 -1
  31. package/lib/commonjs/components/Text/index.js +3 -1
  32. package/lib/commonjs/components/Text/index.js.map +1 -1
  33. package/lib/commonjs/components/Touchable/TouchableOpacity.js +12 -0
  34. package/lib/commonjs/components/Touchable/TouchableOpacity.js.map +1 -0
  35. package/lib/commonjs/components/Touchable/index.js +29 -0
  36. package/lib/commonjs/components/Touchable/index.js.map +1 -0
  37. package/lib/commonjs/components/utils/withTestID.js +55 -0
  38. package/lib/commonjs/components/utils/withTestID.js.map +1 -0
  39. package/lib/commonjs/pageData.js +1 -5
  40. package/lib/commonjs/pageData.js.map +1 -1
  41. package/lib/commonjs/services/getDynamicOffers.js +1 -3
  42. package/lib/commonjs/services/getDynamicOffers.js.map +1 -1
  43. package/lib/commonjs/utils/index.js +0 -11
  44. package/lib/commonjs/utils/index.js.map +1 -1
  45. package/lib/module/components/Button/index.js +2 -1
  46. package/lib/module/components/Button/index.js.map +1 -1
  47. package/lib/module/components/Common/BaseOfferCard/index.js +17 -6
  48. package/lib/module/components/Common/BaseOfferCard/index.js.map +1 -1
  49. package/lib/module/components/Common/DynamicOfferCard/SeeMore.js +6 -3
  50. package/lib/module/components/Common/DynamicOfferCard/SeeMore.js.map +1 -1
  51. package/lib/module/components/Common/DynamicOfferCard/index.js +2 -1
  52. package/lib/module/components/Common/DynamicOfferCard/index.js.map +1 -1
  53. package/lib/module/components/Divider/index.js +0 -2
  54. package/lib/module/components/Divider/index.js.map +1 -1
  55. package/lib/module/components/DynamicOffers/DynamicOffers.js +0 -2
  56. package/lib/module/components/DynamicOffers/DynamicOffers.js.map +1 -1
  57. package/lib/module/components/DynamicOffers/DynamicOffersContainer.js +3 -22
  58. package/lib/module/components/DynamicOffers/DynamicOffersContainer.js.map +1 -1
  59. package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js +6 -15
  60. package/lib/module/components/DynamicOffers/Render/DynamicOffersRender.js.map +1 -1
  61. package/lib/module/components/DynamicOffers/SeeAllButton.js +2 -1
  62. package/lib/module/components/DynamicOffers/SeeAllButton.js.map +1 -1
  63. package/lib/module/components/Layouts/DefaultOfferCard/index.js +2 -1
  64. package/lib/module/components/Layouts/DefaultOfferCard/index.js.map +1 -1
  65. package/lib/module/components/Modal/AllOffersModal.js +6 -3
  66. package/lib/module/components/Modal/AllOffersModal.js.map +1 -1
  67. package/lib/module/components/Modal/DescriptionPoints.js +2 -1
  68. package/lib/module/components/Modal/DescriptionPoints.js.map +1 -1
  69. package/lib/module/components/Modal/Disclaimer.js +2 -1
  70. package/lib/module/components/Modal/Disclaimer.js.map +1 -1
  71. package/lib/module/components/Modal/OfferDetailsModal.js +13 -8
  72. package/lib/module/components/Modal/OfferDetailsModal.js.map +1 -1
  73. package/lib/module/components/MoneyLionOfferCarousel.js +2 -8
  74. package/lib/module/components/MoneyLionOfferCarousel.js.map +1 -1
  75. package/lib/module/components/Text/index.js +3 -1
  76. package/lib/module/components/Text/index.js.map +1 -1
  77. package/lib/module/components/Touchable/TouchableOpacity.js +5 -0
  78. package/lib/module/components/Touchable/TouchableOpacity.js.map +1 -0
  79. package/lib/module/components/Touchable/index.js +3 -0
  80. package/lib/module/components/Touchable/index.js.map +1 -0
  81. package/lib/module/components/utils/withTestID.js +50 -0
  82. package/lib/module/components/utils/withTestID.js.map +1 -0
  83. package/lib/module/pageData.js +2 -6
  84. package/lib/module/pageData.js.map +1 -1
  85. package/lib/module/services/getDynamicOffers.js +1 -3
  86. package/lib/module/services/getDynamicOffers.js.map +1 -1
  87. package/lib/module/utils/index.js +0 -1
  88. package/lib/module/utils/index.js.map +1 -1
  89. package/lib/typescript/src/components/Button/index.d.ts +3 -2
  90. package/lib/typescript/src/components/Button/index.d.ts.map +1 -1
  91. package/lib/typescript/src/components/Common/BaseOfferCard/index.d.ts.map +1 -1
  92. package/lib/typescript/src/components/Common/DynamicOfferCard/SeeMore.d.ts +2 -1
  93. package/lib/typescript/src/components/Common/DynamicOfferCard/SeeMore.d.ts.map +1 -1
  94. package/lib/typescript/src/components/Common/DynamicOfferCard/index.d.ts.map +1 -1
  95. package/lib/typescript/src/components/Divider/index.d.ts.map +1 -1
  96. package/lib/typescript/src/components/DynamicOffers/DynamicOffers.d.ts +1 -3
  97. package/lib/typescript/src/components/DynamicOffers/DynamicOffers.d.ts.map +1 -1
  98. package/lib/typescript/src/components/DynamicOffers/DynamicOffersContainer.d.ts +1 -4
  99. package/lib/typescript/src/components/DynamicOffers/DynamicOffersContainer.d.ts.map +1 -1
  100. package/lib/typescript/src/components/DynamicOffers/Render/DynamicOffersRender.d.ts +1 -3
  101. package/lib/typescript/src/components/DynamicOffers/Render/DynamicOffersRender.d.ts.map +1 -1
  102. package/lib/typescript/src/components/DynamicOffers/SeeAllButton.d.ts.map +1 -1
  103. package/lib/typescript/src/components/Layouts/DefaultOfferCard/index.d.ts.map +1 -1
  104. package/lib/typescript/src/components/Modal/AllOffersModal.d.ts.map +1 -1
  105. package/lib/typescript/src/components/Modal/DescriptionPoints.d.ts.map +1 -1
  106. package/lib/typescript/src/components/Modal/Disclaimer.d.ts.map +1 -1
  107. package/lib/typescript/src/components/Modal/OfferDetailsModal.d.ts.map +1 -1
  108. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts +0 -2
  109. package/lib/typescript/src/components/MoneyLionOfferCarousel.d.ts.map +1 -1
  110. package/lib/typescript/src/components/Text/index.d.ts +2 -1
  111. package/lib/typescript/src/components/Text/index.d.ts.map +1 -1
  112. package/lib/typescript/src/components/Touchable/TouchableOpacity.d.ts +7 -0
  113. package/lib/typescript/src/components/Touchable/TouchableOpacity.d.ts.map +1 -0
  114. package/lib/typescript/src/components/Touchable/index.d.ts +3 -0
  115. package/lib/typescript/src/components/Touchable/index.d.ts.map +1 -0
  116. package/lib/typescript/src/components/utils/withTestID.d.ts +4 -0
  117. package/lib/typescript/src/components/utils/withTestID.d.ts.map +1 -0
  118. package/lib/typescript/src/pageData.d.ts +0 -1
  119. package/lib/typescript/src/pageData.d.ts.map +1 -1
  120. package/lib/typescript/src/services/getDynamicOffers.d.ts +1 -3
  121. package/lib/typescript/src/services/getDynamicOffers.d.ts.map +1 -1
  122. package/lib/typescript/src/utils/index.d.ts +0 -1
  123. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  124. package/package.json +1 -1
  125. package/src/components/Button/index.tsx +6 -3
  126. package/src/components/Common/BaseOfferCard/index.tsx +17 -8
  127. package/src/components/Common/DynamicOfferCard/SeeMore.tsx +9 -2
  128. package/src/components/Common/DynamicOfferCard/index.tsx +1 -0
  129. package/src/components/Divider/index.tsx +0 -1
  130. package/src/components/DynamicOffers/DynamicOffers.tsx +0 -4
  131. package/src/components/DynamicOffers/DynamicOffersContainer.tsx +2 -21
  132. package/src/components/DynamicOffers/Render/DynamicOffersRender.tsx +16 -28
  133. package/src/components/DynamicOffers/SeeAllButton.tsx +1 -0
  134. package/src/components/Layouts/DefaultOfferCard/index.tsx +1 -0
  135. package/src/components/Modal/AllOffersModal.tsx +3 -1
  136. package/src/components/Modal/DescriptionPoints.tsx +6 -1
  137. package/src/components/Modal/Disclaimer.tsx +6 -1
  138. package/src/components/Modal/OfferDetailsModal.tsx +12 -6
  139. package/src/components/MoneyLionOfferCarousel.tsx +2 -6
  140. package/src/components/Text/index.tsx +7 -2
  141. package/src/components/Touchable/TouchableOpacity.tsx +15 -0
  142. package/src/components/Touchable/index.ts +2 -0
  143. package/src/components/utils/withTestID.tsx +56 -0
  144. package/src/pageData.ts +0 -6
  145. package/src/services/getDynamicOffers.ts +1 -5
  146. package/src/utils/index.ts +0 -1
  147. package/lib/commonjs/utils/getOffersBasedOnLayout.js +0 -48
  148. package/lib/commonjs/utils/getOffersBasedOnLayout.js.map +0 -1
  149. package/lib/commonjs/utils/layouts.js +0 -27
  150. package/lib/commonjs/utils/layouts.js.map +0 -1
  151. package/lib/module/utils/getOffersBasedOnLayout.js +0 -39
  152. package/lib/module/utils/getOffersBasedOnLayout.js.map +0 -1
  153. package/lib/module/utils/layouts.js +0 -20
  154. package/lib/module/utils/layouts.js.map +0 -1
  155. package/lib/typescript/src/utils/getOffersBasedOnLayout.d.ts +0 -26
  156. package/lib/typescript/src/utils/getOffersBasedOnLayout.d.ts.map +0 -1
  157. package/lib/typescript/src/utils/layouts.d.ts +0 -19
  158. package/lib/typescript/src/utils/layouts.d.ts.map +0 -1
  159. package/src/utils/getOffersBasedOnLayout.ts +0 -51
  160. package/src/utils/layouts.ts +0 -22
@@ -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
- };