@moneylion/react-native-offer-carousel 1.10.1 → 1.10.2

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 (67) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/commonjs/capabilities/configuration/src/brands/checkVisualEligibility.js +13 -11
  3. package/lib/commonjs/capabilities/configuration/src/brands/checkVisualEligibility.js.map +1 -1
  4. package/lib/commonjs/capabilities/configuration/src/brands/createDerivedBrands.js +8 -19
  5. package/lib/commonjs/capabilities/configuration/src/brands/createDerivedBrands.js.map +1 -1
  6. package/lib/commonjs/capabilities/offer-catalog/src/utils/formatUtils.js +36 -21
  7. package/lib/commonjs/capabilities/offer-catalog/src/utils/formatUtils.js.map +1 -1
  8. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/formatters/annualFee.js +7 -30
  9. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/formatters/annualFee.js.map +1 -1
  10. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/formatters/purchaseApr.js +15 -17
  11. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/formatters/purchaseApr.js.map +1 -1
  12. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/formatters/recommendedCredit.js +8 -2
  13. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/formatters/recommendedCredit.js.map +1 -1
  14. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/index.js +40 -38
  15. package/lib/commonjs/capabilities/offer-catalog/src/utils/stats/index.js.map +1 -1
  16. package/lib/commonjs/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.js +22 -12
  17. package/lib/commonjs/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.js.map +1 -1
  18. package/lib/commonjs/capabilities/ui/elements/src/components/MarkdownText/components.js +22 -10
  19. package/lib/commonjs/capabilities/ui/elements/src/components/MarkdownText/components.js.map +1 -1
  20. package/lib/commonjs/components/DynamicOffers/Render/Offer.js +51 -49
  21. package/lib/commonjs/components/DynamicOffers/Render/Offer.js.map +1 -1
  22. package/lib/commonjs/version.js +1 -1
  23. package/lib/module/capabilities/configuration/src/brands/checkVisualEligibility.js +13 -11
  24. package/lib/module/capabilities/configuration/src/brands/checkVisualEligibility.js.map +1 -1
  25. package/lib/module/capabilities/configuration/src/brands/createDerivedBrands.js +7 -19
  26. package/lib/module/capabilities/configuration/src/brands/createDerivedBrands.js.map +1 -1
  27. package/lib/module/capabilities/offer-catalog/src/utils/formatUtils.js +35 -20
  28. package/lib/module/capabilities/offer-catalog/src/utils/formatUtils.js.map +1 -1
  29. package/lib/module/capabilities/offer-catalog/src/utils/stats/formatters/annualFee.js +7 -30
  30. package/lib/module/capabilities/offer-catalog/src/utils/stats/formatters/annualFee.js.map +1 -1
  31. package/lib/module/capabilities/offer-catalog/src/utils/stats/formatters/purchaseApr.js +15 -17
  32. package/lib/module/capabilities/offer-catalog/src/utils/stats/formatters/purchaseApr.js.map +1 -1
  33. package/lib/module/capabilities/offer-catalog/src/utils/stats/formatters/recommendedCredit.js +8 -2
  34. package/lib/module/capabilities/offer-catalog/src/utils/stats/formatters/recommendedCredit.js.map +1 -1
  35. package/lib/module/capabilities/offer-catalog/src/utils/stats/index.js +40 -38
  36. package/lib/module/capabilities/offer-catalog/src/utils/stats/index.js.map +1 -1
  37. package/lib/module/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.js +22 -11
  38. package/lib/module/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.js.map +1 -1
  39. package/lib/module/capabilities/ui/elements/src/components/MarkdownText/components.js +22 -10
  40. package/lib/module/capabilities/ui/elements/src/components/MarkdownText/components.js.map +1 -1
  41. package/lib/module/components/DynamicOffers/Render/Offer.js +51 -49
  42. package/lib/module/components/DynamicOffers/Render/Offer.js.map +1 -1
  43. package/lib/module/version.js +1 -1
  44. package/lib/typescript/capabilities/configuration/src/brands/checkVisualEligibility.d.ts.map +1 -1
  45. package/lib/typescript/capabilities/configuration/src/brands/createDerivedBrands.d.ts.map +1 -1
  46. package/lib/typescript/capabilities/offer-catalog/src/utils/formatUtils.d.ts.map +1 -1
  47. package/lib/typescript/capabilities/offer-catalog/src/utils/stats/formatters/annualFee.d.ts.map +1 -1
  48. package/lib/typescript/capabilities/offer-catalog/src/utils/stats/formatters/purchaseApr.d.ts.map +1 -1
  49. package/lib/typescript/capabilities/offer-catalog/src/utils/stats/formatters/recommendedCredit.d.ts.map +1 -1
  50. package/lib/typescript/capabilities/offer-catalog/src/utils/stats/index.d.ts.map +1 -1
  51. package/lib/typescript/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.d.ts +4 -192
  52. package/lib/typescript/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.d.ts.map +1 -1
  53. package/lib/typescript/capabilities/ui/elements/src/components/MarkdownText/components.d.ts.map +1 -1
  54. package/lib/typescript/components/DynamicOffers/Render/Offer.d.ts.map +1 -1
  55. package/lib/typescript/version.d.ts +1 -1
  56. package/package.json +2 -7
  57. package/src/capabilities/configuration/src/brands/checkVisualEligibility.ts +22 -16
  58. package/src/capabilities/configuration/src/brands/createDerivedBrands.ts +10 -23
  59. package/src/capabilities/offer-catalog/src/utils/formatUtils.ts +38 -19
  60. package/src/capabilities/offer-catalog/src/utils/stats/formatters/annualFee.ts +19 -46
  61. package/src/capabilities/offer-catalog/src/utils/stats/formatters/purchaseApr.ts +17 -21
  62. package/src/capabilities/offer-catalog/src/utils/stats/formatters/recommendedCredit.ts +11 -8
  63. package/src/capabilities/offer-catalog/src/utils/stats/index.ts +40 -109
  64. package/src/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.ts +26 -17
  65. package/src/capabilities/ui/elements/src/components/MarkdownText/components.tsx +27 -6
  66. package/src/components/DynamicOffers/Render/Offer.tsx +34 -33
  67. package/src/version.ts +1 -1
@@ -8,201 +8,13 @@ import type { LeadRequestOfferCatalog } from "./offer-catalog/types";
8
8
  * @returns true iff x is a string that matches the UUIDv4 format
9
9
  */
10
10
  export declare const isUUIDv4: (x: unknown) => boolean;
11
- export declare function withDeviceSignals<TData extends LeadCreateData | LeadRequestOfferCatalog>(context: CnfContext, payload: TData): TData extends {
12
- /**
13
- * The leads API required device ID's be in the UUID format. If the string
14
- * we receive here is not in the expected format, we will create an error
15
- * passing it to the API.
16
- */
11
+ export declare function withDeviceSignals<TData extends LeadCreateData | LeadRequestOfferCatalog>(context: CnfContext, payload: TData): {
17
12
  deviceId: undefined;
18
13
  sessionInformation: {
19
14
  ipAddress: undefined;
20
15
  userAgent: undefined;
21
16
  };
22
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
23
- } ? TData : Omit<TData, keyof TData & ("deviceId" | "sessionInformation" | "clientTags")> & Omit<{
24
- /**
25
- * The leads API required device ID's be in the UUID format. If the string
26
- * we receive here is not in the expected format, we will create an error
27
- * passing it to the API.
28
- */
29
- deviceId: undefined;
30
- sessionInformation: {
31
- ipAddress: undefined;
32
- userAgent: undefined;
33
- };
34
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
35
- }, keyof TData & ("deviceId" | "sessionInformation" | "clientTags")> & { -readonly [Key in keyof TData & ("deviceId" | "sessionInformation" | "clientTags")]: TData[Key] extends void | null | undefined ? {
36
- /**
37
- * The leads API required device ID's be in the UUID format. If the string
38
- * we receive here is not in the expected format, we will create an error
39
- * passing it to the API.
40
- */
41
- deviceId: undefined;
42
- sessionInformation: {
43
- ipAddress: undefined;
44
- userAgent: undefined;
45
- };
46
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
47
- }[Key] extends void | null | undefined ? void | null | undefined : {
48
- /**
49
- * The leads API required device ID's be in the UUID format. If the string
50
- * we receive here is not in the expected format, we will create an error
51
- * passing it to the API.
52
- */
53
- deviceId: undefined;
54
- sessionInformation: {
55
- ipAddress: undefined;
56
- userAgent: undefined;
57
- };
58
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
59
- }[Key] : {
60
- /**
61
- * The leads API required device ID's be in the UUID format. If the string
62
- * we receive here is not in the expected format, we will create an error
63
- * passing it to the API.
64
- */
65
- deviceId: undefined;
66
- sessionInformation: {
67
- ipAddress: undefined;
68
- userAgent: undefined;
69
- };
70
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
71
- }[Key] extends void | null | undefined ? TData[Key] : TData[Key] extends infer T ? T extends TData[Key] ? T extends void | null | undefined ? {
72
- /**
73
- * The leads API required device ID's be in the UUID format. If the string
74
- * we receive here is not in the expected format, we will create an error
75
- * passing it to the API.
76
- */
77
- deviceId: undefined;
78
- sessionInformation: {
79
- ipAddress: undefined;
80
- userAgent: undefined;
81
- };
82
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
83
- }[Key] extends infer T_1 ? T_1 extends {
84
- /**
85
- * The leads API required device ID's be in the UUID format. If the string
86
- * we receive here is not in the expected format, we will create an error
87
- * passing it to the API.
88
- */
89
- deviceId: undefined;
90
- sessionInformation: {
91
- ipAddress: undefined;
92
- userAgent: undefined;
93
- };
94
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
95
- }[Key] ? T_1 extends void | null | undefined ? void | null | undefined : T_1 : never : never : {
96
- /**
97
- * The leads API required device ID's be in the UUID format. If the string
98
- * we receive here is not in the expected format, we will create an error
99
- * passing it to the API.
100
- */
101
- deviceId: undefined;
102
- sessionInformation: {
103
- ipAddress: undefined;
104
- userAgent: undefined;
105
- };
106
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
107
- }[Key] extends infer T_2 ? T_2 extends {
108
- /**
109
- * The leads API required device ID's be in the UUID format. If the string
110
- * we receive here is not in the expected format, we will create an error
111
- * passing it to the API.
112
- */
113
- deviceId: undefined;
114
- sessionInformation: {
115
- ipAddress: undefined;
116
- userAgent: undefined;
117
- };
118
- clientTags: Record<"system" | "app" | "os" | "isMobile" | "evReferrer" | "consumerBrand" | "cnfEnvironment", string[]>;
119
- }[Key] ? T_2 extends void | null | undefined ? T : T extends any[] ? T_2 extends any[] ? T extends infer T_3 ? T_3 extends T ? T_3 extends (infer DestinationType)[] ? T_2 extends infer T_4 ? T_4 extends T_2 ? T_4 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_4 : never : never : T_2 | T_3 : never : never : T_2 | T : T extends Function ? T_2 | T : T extends RegExp ? T_2 | T : T extends Promise<any> ? T_2 | T : T_2 extends Function ? T | T_2 : T_2 extends RegExp ? T | T_2 : T_2 extends Promise<any> ? T | T_2 : T extends {
120
- [x: string]: any;
121
- [x: number]: any;
122
- [x: symbol]: any;
123
- } ? T_2 extends {
124
- [x: string]: any;
125
- [x: number]: any;
126
- [x: symbol]: any;
127
- } ? T extends infer T_5 ? T_5 extends T ? T_5 extends T_2 ? T_5 : Omit<T_5, keyof T_5 & keyof T_2> & Omit<T_2, keyof T_5 & keyof T_2> & { -readonly [Key_2 in keyof T_5 & keyof T_2]: T_5[Key_2] extends void | null | undefined ? T_2[Key_2] extends void | null | undefined ? void | null | undefined : T_2[Key_2] : T_2[Key_2] extends void | null | undefined ? T_5[Key_2] : T_5[Key_2] extends infer T_6 ? T_6 extends T_5[Key_2] ? T_6 extends void | null | undefined ? T_2[Key_2] extends infer T_7 ? T_7 extends T_2[Key_2] ? T_7 extends void | null | undefined ? void | null | undefined : T_7 : never : never : T_2[Key_2] extends infer T_8 ? T_8 extends T_2[Key_2] ? T_8 extends void | null | undefined ? T_6 : T_6 extends any[] ? T_8 extends any[] ? T_6 extends infer T_9 ? T_9 extends T_6 ? T_9 extends (infer DestinationType)[] ? T_8 extends infer T_10 ? T_10 extends T_8 ? T_10 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_10 : never : never : T_8 | T_9 : never : never : T_8 | T_6 : T_6 extends Function ? T_8 | T_6 : T_6 extends RegExp ? T_8 | T_6 : T_6 extends Promise<any> ? T_8 | T_6 : T_8 extends Function ? T_6 | T_8 : T_8 extends RegExp ? T_6 | T_8 : T_8 extends Promise<any> ? T_6 | T_8 : T_6 extends {
128
- [x: string]: any;
129
- [x: number]: any;
130
- [x: symbol]: any;
131
- } ? T_8 extends {
132
- [x: string]: any;
133
- [x: number]: any;
134
- [x: symbol]: any;
135
- } ? T_6 extends infer T_11 ? T_11 extends T_6 ? T_11 extends T_8 ? T_11 : Omit<T_11, keyof T_11 & keyof T_8> & Omit<T_8, keyof T_11 & keyof T_8> & { -readonly [Key_3 in keyof T_11 & keyof T_8]: T_11[Key_3] extends void | null | undefined ? T_8[Key_3] extends void | null | undefined ? void | null | undefined : T_8[Key_3] : T_8[Key_3] extends void | null | undefined ? T_11[Key_3] : T_11[Key_3] extends infer T_12 ? T_12 extends T_11[Key_3] ? T_12 extends void | null | undefined ? T_8[Key_3] extends infer T_13 ? T_13 extends T_8[Key_3] ? T_13 extends void | null | undefined ? void | null | undefined : T_13 : never : never : T_8[Key_3] extends infer T_14 ? T_14 extends T_8[Key_3] ? T_14 extends void | null | undefined ? T_12 : T_12 extends any[] ? T_14 extends any[] ? T_12 extends infer T_15 ? T_15 extends T_12 ? T_15 extends (infer DestinationType)[] ? T_14 extends infer T_16 ? T_16 extends T_14 ? T_16 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_16 : never : never : T_14 | T_15 : never : never : T_14 | T_12 : T_12 extends Function ? T_14 | T_12 : T_12 extends RegExp ? T_14 | T_12 : T_12 extends Promise<any> ? T_14 | T_12 : T_14 extends Function ? T_12 | T_14 : T_14 extends RegExp ? T_12 | T_14 : T_14 extends Promise<any> ? T_12 | T_14 : T_12 extends {
136
- [x: string]: any;
137
- [x: number]: any;
138
- [x: symbol]: any;
139
- } ? T_14 extends {
140
- [x: string]: any;
141
- [x: number]: any;
142
- [x: symbol]: any;
143
- } ? T_12 extends infer T_17 ? T_17 extends T_12 ? T_17 extends T_14 ? T_17 : Omit<T_17, keyof T_17 & keyof T_14> & Omit<T_14, keyof T_17 & keyof T_14> & { -readonly [Key_4 in keyof T_17 & keyof T_14]: T_17[Key_4] extends void | null | undefined ? T_14[Key_4] extends void | null | undefined ? void | null | undefined : T_14[Key_4] : T_14[Key_4] extends void | null | undefined ? T_17[Key_4] : T_17[Key_4] extends infer T_18 ? T_18 extends T_17[Key_4] ? T_18 extends void | null | undefined ? T_14[Key_4] extends infer T_19 ? T_19 extends T_14[Key_4] ? T_19 extends void | null | undefined ? void | null | undefined : T_19 : never : never : T_14[Key_4] extends infer T_20 ? T_20 extends T_14[Key_4] ? T_20 extends void | null | undefined ? T_18 : T_18 extends any[] ? T_20 extends any[] ? T_18 extends infer T_21 ? T_21 extends T_18 ? T_21 extends (infer DestinationType)[] ? T_20 extends infer T_22 ? T_22 extends T_20 ? T_22 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_22 : never : never : T_20 | T_21 : never : never : T_20 | T_18 : T_18 extends Function ? T_20 | T_18 : T_18 extends RegExp ? T_20 | T_18 : T_18 extends Promise<any> ? T_20 | T_18 : T_20 extends Function ? T_18 | T_20 : T_20 extends RegExp ? T_18 | T_20 : T_20 extends Promise<any> ? T_18 | T_20 : T_18 extends {
144
- [x: string]: any;
145
- [x: number]: any;
146
- [x: symbol]: any;
147
- } ? T_20 extends {
148
- [x: string]: any;
149
- [x: number]: any;
150
- [x: symbol]: any;
151
- } ? T_18 extends infer T_23 ? T_23 extends T_18 ? T_23 extends T_20 ? T_23 : Omit<T_23, keyof T_23 & keyof T_20> & Omit<T_20, keyof T_23 & keyof T_20> & { -readonly [Key_5 in keyof T_23 & keyof T_20]: T_23[Key_5] extends void | null | undefined ? T_20[Key_5] extends void | null | undefined ? void | null | undefined : T_20[Key_5] : T_20[Key_5] extends void | null | undefined ? T_23[Key_5] : T_23[Key_5] extends infer T_24 ? T_24 extends T_23[Key_5] ? T_24 extends void | null | undefined ? T_20[Key_5] extends infer T_25 ? T_25 extends T_20[Key_5] ? T_25 extends void | null | undefined ? void | null | undefined : T_25 : never : never : T_20[Key_5] extends infer T_26 ? T_26 extends T_20[Key_5] ? T_26 extends void | null | undefined ? T_24 : T_24 extends any[] ? T_26 extends any[] ? T_24 extends infer T_27 ? T_27 extends T_24 ? T_27 extends (infer DestinationType)[] ? T_26 extends infer T_28 ? T_28 extends T_26 ? T_28 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_28 : never : never : T_26 | T_27 : never : never : T_26 | T_24 : T_24 extends Function ? T_26 | T_24 : T_24 extends RegExp ? T_26 | T_24 : T_24 extends Promise<any> ? T_26 | T_24 : T_26 extends Function ? T_24 | T_26 : T_26 extends RegExp ? T_24 | T_26 : T_26 extends Promise<any> ? T_24 | T_26 : T_24 extends {
152
- [x: string]: any;
153
- [x: number]: any;
154
- [x: symbol]: any;
155
- } ? T_26 extends {
156
- [x: string]: any;
157
- [x: number]: any;
158
- [x: symbol]: any;
159
- } ? T_24 extends infer T_29 ? T_29 extends T_24 ? T_29 extends T_26 ? T_29 : Omit<T_29, keyof T_29 & keyof T_26> & Omit<T_26, keyof T_29 & keyof T_26> & { -readonly [Key_6 in keyof T_29 & keyof T_26]: T_29[Key_6] extends void | null | undefined ? T_26[Key_6] extends void | null | undefined ? void | null | undefined : T_26[Key_6] : T_26[Key_6] extends void | null | undefined ? T_29[Key_6] : T_29[Key_6] extends infer T_30 ? T_30 extends T_29[Key_6] ? T_30 extends void | null | undefined ? T_26[Key_6] extends infer T_31 ? T_31 extends T_26[Key_6] ? T_31 extends void | null | undefined ? void | null | undefined : T_31 : never : never : T_26[Key_6] extends infer T_32 ? T_32 extends T_26[Key_6] ? T_32 extends void | null | undefined ? T_30 : T_30 extends any[] ? T_32 extends any[] ? T_30 extends infer T_33 ? T_33 extends T_30 ? T_33 extends (infer DestinationType)[] ? T_32 extends infer T_34 ? T_34 extends T_32 ? T_34 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_34 : never : never : T_32 | T_33 : never : never : T_32 | T_30 : T_30 extends Function ? T_32 | T_30 : T_30 extends RegExp ? T_32 | T_30 : T_30 extends Promise<any> ? T_32 | T_30 : T_32 extends Function ? T_30 | T_32 : T_32 extends RegExp ? T_30 | T_32 : T_32 extends Promise<any> ? T_30 | T_32 : T_30 extends {
160
- [x: string]: any;
161
- [x: number]: any;
162
- [x: symbol]: any;
163
- } ? T_32 extends {
164
- [x: string]: any;
165
- [x: number]: any;
166
- [x: symbol]: any;
167
- } ? T_30 extends infer T_35 ? T_35 extends T_30 ? T_35 extends T_32 ? T_35 : Omit<T_35, keyof T_35 & keyof T_32> & Omit<T_32, keyof T_35 & keyof T_32> & { -readonly [Key_7 in keyof T_35 & keyof T_32]: T_35[Key_7] extends void | null | undefined ? T_32[Key_7] extends void | null | undefined ? void | null | undefined : T_32[Key_7] : T_32[Key_7] extends void | null | undefined ? T_35[Key_7] : T_35[Key_7] extends infer T_36 ? T_36 extends T_35[Key_7] ? T_36 extends void | null | undefined ? T_32[Key_7] extends infer T_37 ? T_37 extends T_32[Key_7] ? T_37 extends void | null | undefined ? void | null | undefined : T_37 : never : never : T_32[Key_7] extends infer T_38 ? T_38 extends T_32[Key_7] ? T_38 extends void | null | undefined ? T_36 : T_36 extends any[] ? T_38 extends any[] ? T_36 extends infer T_39 ? T_39 extends T_36 ? T_39 extends (infer DestinationType)[] ? T_38 extends infer T_40 ? T_40 extends T_38 ? T_40 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_40 : never : never : T_38 | T_39 : never : never : T_38 | T_36 : T_36 extends Function ? T_38 | T_36 : T_36 extends RegExp ? T_38 | T_36 : T_36 extends Promise<any> ? T_38 | T_36 : T_38 extends Function ? T_36 | T_38 : T_38 extends RegExp ? T_36 | T_38 : T_38 extends Promise<any> ? T_36 | T_38 : T_36 extends {
168
- [x: string]: any;
169
- [x: number]: any;
170
- [x: symbol]: any;
171
- } ? T_38 extends {
172
- [x: string]: any;
173
- [x: number]: any;
174
- [x: symbol]: any;
175
- } ? T_36 extends infer T_41 ? T_41 extends T_36 ? T_41 extends T_38 ? T_41 : Omit<T_41, keyof T_41 & keyof T_38> & Omit<T_38, keyof T_41 & keyof T_38> & { -readonly [Key_8 in keyof T_41 & keyof T_38]: T_41[Key_8] extends void | null | undefined ? T_38[Key_8] extends void | null | undefined ? void | null | undefined : T_38[Key_8] : T_38[Key_8] extends void | null | undefined ? T_41[Key_8] : T_41[Key_8] extends infer T_42 ? T_42 extends T_41[Key_8] ? T_42 extends void | null | undefined ? T_38[Key_8] extends infer T_43 ? T_43 extends T_38[Key_8] ? T_43 extends void | null | undefined ? void | null | undefined : T_43 : never : never : T_38[Key_8] extends infer T_44 ? T_44 extends T_38[Key_8] ? T_44 extends void | null | undefined ? T_42 : T_42 extends any[] ? T_44 extends any[] ? T_42 extends infer T_45 ? T_45 extends T_42 ? T_45 extends (infer DestinationType)[] ? T_44 extends infer T_46 ? T_46 extends T_44 ? T_46 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_46 : never : never : T_44 | T_45 : never : never : T_44 | T_42 : T_42 extends Function ? T_44 | T_42 : T_42 extends RegExp ? T_44 | T_42 : T_42 extends Promise<any> ? T_44 | T_42 : T_44 extends Function ? T_42 | T_44 : T_44 extends RegExp ? T_42 | T_44 : T_44 extends Promise<any> ? T_42 | T_44 : T_42 extends {
176
- [x: string]: any;
177
- [x: number]: any;
178
- [x: symbol]: any;
179
- } ? T_44 extends {
180
- [x: string]: any;
181
- [x: number]: any;
182
- [x: symbol]: any;
183
- } ? T_42 extends infer T_47 ? T_47 extends T_42 ? T_47 extends T_44 ? T_47 : Omit<T_47, keyof T_47 & keyof T_44> & Omit<T_44, keyof T_47 & keyof T_44> & { -readonly [Key_9 in keyof T_47 & keyof T_44]: T_47[Key_9] extends void | null | undefined ? T_44[Key_9] extends void | null | undefined ? void | null | undefined : T_44[Key_9] : T_44[Key_9] extends void | null | undefined ? T_47[Key_9] : T_47[Key_9] extends infer T_48 ? T_48 extends T_47[Key_9] ? T_48 extends void | null | undefined ? T_44[Key_9] extends infer T_49 ? T_49 extends T_44[Key_9] ? T_49 extends void | null | undefined ? void | null | undefined : T_49 : never : never : T_44[Key_9] extends infer T_50 ? T_50 extends T_44[Key_9] ? T_50 extends void | null | undefined ? T_48 : T_48 extends any[] ? T_50 extends any[] ? T_48 extends infer T_51 ? T_51 extends T_48 ? T_51 extends (infer DestinationType)[] ? T_50 extends infer T_52 ? T_52 extends T_50 ? T_52 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_52 : never : never : T_50 | T_51 : never : never : T_50 | T_48 : T_48 extends Function ? T_50 | T_48 : T_48 extends RegExp ? T_50 | T_48 : T_48 extends Promise<any> ? T_50 | T_48 : T_50 extends Function ? T_48 | T_50 : T_50 extends RegExp ? T_48 | T_50 : T_50 extends Promise<any> ? T_48 | T_50 : T_48 extends {
184
- [x: string]: any;
185
- [x: number]: any;
186
- [x: symbol]: any;
187
- } ? T_50 extends {
188
- [x: string]: any;
189
- [x: number]: any;
190
- [x: symbol]: any;
191
- } ? T_48 extends infer T_53 ? T_53 extends T_48 ? T_53 extends T_50 ? T_53 : Omit<T_53, keyof T_53 & keyof T_50> & Omit<T_50, keyof T_53 & keyof T_50> & { -readonly [Key_10 in keyof T_53 & keyof T_50]: T_53[Key_10] extends void | null | undefined ? T_50[Key_10] extends void | null | undefined ? void | null | undefined : T_50[Key_10] : T_50[Key_10] extends void | null | undefined ? T_53[Key_10] : T_53[Key_10] extends infer T_54 ? T_54 extends T_53[Key_10] ? T_54 extends void | null | undefined ? T_50[Key_10] extends infer T_55 ? T_55 extends T_50[Key_10] ? T_55 extends void | null | undefined ? void | null | undefined : T_55 : never : never : T_50[Key_10] extends infer T_56 ? T_56 extends T_50[Key_10] ? T_56 extends void | null | undefined ? T_54 : T_54 extends any[] ? T_56 extends any[] ? T_54 extends infer T_57 ? T_57 extends T_54 ? T_57 extends (infer DestinationType)[] ? T_56 extends infer T_58 ? T_58 extends T_56 ? T_58 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_58 : never : never : T_56 | T_57 : never : never : T_56 | T_54 : T_54 extends Function ? T_56 | T_54 : T_54 extends RegExp ? T_56 | T_54 : T_54 extends Promise<any> ? T_56 | T_54 : T_56 extends Function ? T_54 | T_56 : T_56 extends RegExp ? T_54 | T_56 : T_56 extends Promise<any> ? T_54 | T_56 : T_54 extends {
192
- [x: string]: any;
193
- [x: number]: any;
194
- [x: symbol]: any;
195
- } ? T_56 extends {
196
- [x: string]: any;
197
- [x: number]: any;
198
- [x: symbol]: any;
199
- } ? T_54 extends infer T_59 ? T_59 extends T_54 ? T_59 extends T_56 ? T_59 : Omit<T_59, keyof T_59 & keyof T_56> & Omit<T_56, keyof T_59 & keyof T_56> & { -readonly [Key_11 in keyof T_59 & keyof T_56]: T_59[Key_11] extends void | null | undefined ? T_56[Key_11] extends void | null | undefined ? void | null | undefined : T_56[Key_11] : T_56[Key_11] extends void | null | undefined ? T_59[Key_11] : T_59[Key_11] extends infer T_60 ? T_60 extends T_59[Key_11] ? T_60 extends void | null | undefined ? T_56[Key_11] extends infer T_61 ? T_61 extends T_56[Key_11] ? T_61 extends void | null | undefined ? void | null | undefined : T_61 : never : never : T_56[Key_11] extends infer T_62 ? T_62 extends T_56[Key_11] ? T_62 extends void | null | undefined ? T_60 : T_60 extends any[] ? T_62 extends any[] ? T_60 extends infer T_63 ? T_63 extends T_60 ? T_63 extends (infer DestinationType)[] ? T_62 extends infer T_64 ? T_64 extends T_62 ? T_64 extends (infer SourceType)[] ? (DestinationType | SourceType)[] : DestinationType[] | T_64 : never : never : T_62 | T_63 : never : never : T_62 | T_60 : T_60 extends Function ? T_62 | T_60 : T_60 extends RegExp ? T_62 | T_60 : T_60 extends Promise<any> ? T_62 | T_60 : T_62 extends Function ? T_60 | T_62 : T_62 extends RegExp ? T_60 | T_62 : T_62 extends Promise<any> ? T_60 | T_62 : T_60 extends {
200
- [x: string]: any;
201
- [x: number]: any;
202
- [x: symbol]: any;
203
- } ? T_62 extends {
204
- [x: string]: any;
205
- [x: number]: any;
206
- [x: symbol]: any;
207
- } ? /*elided*/ any : T_62 | T_60 : T_60 | T_62 : never : never : never : never; } : never : never : T_56 | T_54 : T_54 | T_56 : never : never : never : never; } : never : never : T_50 | T_48 : T_48 | T_50 : never : never : never : never; } : never : never : T_44 | T_42 : T_42 | T_44 : never : never : never : never; } : never : never : T_38 | T_36 : T_36 | T_38 : never : never : never : never; } : never : never : T_32 | T_30 : T_30 | T_32 : never : never : never : never; } : never : never : T_26 | T_24 : T_24 | T_26 : never : never : never : never; } : never : never : T_20 | T_18 : T_18 | T_20 : never : never : never : never; } : never : never : T_14 | T_12 : T_12 | T_14 : never : never : never : never; } : never : never : T_8 | T_6 : T_6 | T_8 : never : never : never : never; } : never : never : T_2 | T : T | T_2 : never : never : never : never; };
17
+ } & TData & {
18
+ clientTags: Record<string, string[]>;
19
+ };
208
20
  //# sourceMappingURL=withDeviceSignals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withDeviceSignals.d.ts","sourceRoot":"","sources":["../../../../../../../../src/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAC;AAEvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMrE;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,YACY,CAAC;AAkBhD,wBAAgB,iBAAiB,CAChC,KAAK,SAAS,cAAc,GAAG,uBAAuB,EACrD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK;IA2BnC;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;IAJH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;41BAYJ"}
1
+ {"version":3,"file":"withDeviceSignals.d.ts","sourceRoot":"","sources":["../../../../../../../../src/capabilities/offers/pipeline/src/sources/ratetables/withDeviceSignals.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAC;AAEvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMrE;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,YACY,CAAC;AAkBhD,wBAAgB,iBAAiB,CAChC,KAAK,SAAS,cAAc,GAAG,uBAAuB,EACrD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK;;;;;;;;EAqDpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../../../../../src/capabilities/ui/elements/src/components/MarkdownText/components.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAa,EACZ,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AA6B3E,eAAO,MAAM,wBAAwB,GAAI,4CAKtC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,WAAW,CAAC;CAC1B,KAAG,WAkHH,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../../../../../src/capabilities/ui/elements/src/components/MarkdownText/components.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAa,EAEZ,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AA0C3E,eAAO,MAAM,wBAAwB,GAAI,4CAKtC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,WAAW,CAAC;CAC1B,KAAG,WAyHH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Offer.d.ts","sourceRoot":"","sources":["../../../../../src/components/DynamicOffers/Render/Offer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAM3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,KAAK,oBAAoB,GAAG;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,EACnB,KAAK,EACL,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,kBAAkB,GAClB,EAAE;QACF,KAAK,EAAE,SAAS,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC7B,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yJAAyJ;IACzJ,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAE7B,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,4HAQnB,oBAAoB,wBAyEpB,CAAC"}
1
+ {"version":3,"file":"Offer.d.ts","sourceRoot":"","sources":["../../../../../src/components/DynamicOffers/Render/Offer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAM3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,KAAK,oBAAoB,GAAG;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,CAAC,EACnB,KAAK,EACL,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,kBAAkB,GAClB,EAAE;QACF,KAAK,EAAE,SAAS,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC7B,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yJAAyJ;IACzJ,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAE7B,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,4HAQnB,oBAAoB,wBA4EpB,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.10.1";
1
+ export declare const VERSION = "1.10.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneylion/react-native-offer-carousel",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "React Native components for the Engine by MoneyLion Mobile SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -30,14 +30,12 @@
30
30
  "scripts": {
31
31
  "test": "jest --silent",
32
32
  "typecheck": "tsc --noEmit",
33
- "clean": "del-cli lib",
34
33
  "sync-version": "node scripts/sync-version.js",
35
34
  "prepare": "yarn sync-version && bob build"
36
35
  },
37
36
  "author": "",
38
37
  "license": "ISC",
39
38
  "devDependencies": {
40
- "del-cli": "^5.1.0",
41
39
  "react-native-builder-bob": "^0.20.0",
42
40
  "type-fest": "4.26.1"
43
41
  },
@@ -61,10 +59,7 @@
61
59
  ]
62
60
  },
63
61
  "dependencies": {
64
- "defu": "6.1.5",
65
- "numbro": "^2.5.0",
66
62
  "radash": "11.0.0",
67
- "react-native-markdown-display": "^7.0.2",
68
- "ts-pattern": "5.1.1"
63
+ "react-native-markdown-display": "^7.0.2"
69
64
  }
70
65
  }
@@ -1,6 +1,5 @@
1
1
  import { get } from "radash";
2
2
  import { enhanceType, type Brand } from "./types";
3
- import { match, P } from "ts-pattern";
4
3
 
5
4
  /**
6
5
  * A UI centric concept that prioritizes brands for visual use, both by the data available and the preferences of the brand.
@@ -12,18 +11,25 @@ export type VisualBrandKind = "primary" | "secondary" | "none";
12
11
  * Used to rank a primary eligible brand highest if no brand prefers primary, such as a licensed brand
13
12
  * @param brand
14
13
  */
15
- export const checkVisualBrandEligibility = (brand: Brand) =>
16
- match([enhanceType(brand), get(brand, "allowedMarks"), brand?.isLicensed])
17
- .returnType<VisualBrandKind>()
18
- .with(
19
- [P._, P._, true],
20
- ["business", { logo: true, name: true }, P.any],
21
- ["product", { logo: true, name: true }, P.any],
22
- () => "primary"
23
- )
24
- .with(
25
- ["individual", P._, P.any],
26
- ["business", { name: true, logo: false }, P.any],
27
- () => "secondary"
28
- )
29
- .otherwise(() => "none");
14
+ export const checkVisualBrandEligibility = (brand: Brand): VisualBrandKind => {
15
+ const type = enhanceType(brand);
16
+ const allowedMarks = get<{ logo?: boolean; name?: boolean } | undefined>(
17
+ brand,
18
+ "allowedMarks"
19
+ );
20
+
21
+ const hasFullMarks =
22
+ allowedMarks?.logo === true && allowedMarks?.name === true;
23
+ const hasNameOnlyMarks =
24
+ allowedMarks?.logo === false && allowedMarks?.name === true;
25
+
26
+ if (brand?.isLicensed === true) return "primary";
27
+ if ((type === "business" || type === "product") && hasFullMarks) {
28
+ return "primary";
29
+ }
30
+
31
+ if (type === "individual") return "secondary";
32
+ if (type === "business" && hasNameOnlyMarks) return "secondary";
33
+
34
+ return "none";
35
+ };
@@ -1,9 +1,17 @@
1
1
  import { isObject, sift } from "radash";
2
2
  import type { Brand } from "../../../../builder";
3
- import { P, match } from "ts-pattern";
4
3
  import { enhanceType } from "./types";
5
4
  import { checkVisualBrandEligibility } from "./checkVisualEligibility";
6
5
 
6
+ const resolveLicensedBrand = (brand: Brand): Brand => {
7
+ if (enhanceType(brand) === "licensed") return brand;
8
+
9
+ const candidate = brand?.isLicensed || brand?.licensedBrand;
10
+ if (isObject(candidate)) return candidate as Brand;
11
+
12
+ throw new Error("Missing Licensed Brand");
13
+ };
14
+
7
15
  /**
8
16
  * Extracts and normalizes a brand into -
9
17
  * LicensedBrand - The brand to be used for terms, legal and other compliance needs
@@ -11,29 +19,8 @@ import { checkVisualBrandEligibility } from "./checkVisualEligibility";
11
19
  * @param brand
12
20
  */
13
21
  export const createDerivedBrands = (brand: Brand) => {
14
- // Determine the licensed brand for this brand, keeping in mind that this brand may be the licensed brand
15
- const licensedBrand = match([
16
- enhanceType(brand),
17
- brand?.isLicensed || brand?.licensedBrand,
18
- ])
19
- // Ensure we get back a brand at the end
20
- .returnType<Brand>()
21
- // If the type is licensed, return this brand
22
- .with(["licensed", P._], () => brand)
23
- // If the type is not licensed, but there is a cobrand setup, use that to get the licensed brand
24
- .with(
25
- [P.not("licensed"), P.select("licensedBrandObj")],
26
- ({ licensedBrandObj }) => {
27
- if (isObject(licensedBrandObj)) return licensedBrandObj;
28
- // Throw if no licensed brand is able to be found
29
- throw new Error("Missing Licensed Brand");
30
- }
31
- )
32
- .otherwise(() => {
33
- throw new Error("Missing Licensed Brand");
34
- });
22
+ const licensedBrand = resolveLicensedBrand(brand);
35
23
 
36
- // Determine the set of visual brands which should be displayed on the page
37
24
  const brandCanBeShown = checkVisualBrandEligibility(brand) !== "none";
38
25
  return Array.from(new Set(sift([licensedBrand, brandCanBeShown && brand])));
39
26
  };
@@ -1,4 +1,30 @@
1
- import numbro from "numbro";
1
+ const formatNumberWithMantissa = (
2
+ value: number,
3
+ mantissa: number,
4
+ trimMantissa: boolean,
5
+ thousandSeparated: boolean
6
+ ): string => {
7
+ let str = value.toFixed(mantissa);
8
+
9
+ if (trimMantissa && str.includes(".")) {
10
+ str = str.replace(/0+$/, "").replace(/\.$/, "");
11
+ }
12
+
13
+ if (thousandSeparated) {
14
+ const [intPart, decPart] = str.split(".");
15
+ const withCommas = (intPart ?? "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
16
+ str = decPart !== undefined ? `${withCommas}.${decPart}` : withCommas;
17
+ }
18
+
19
+ return str;
20
+ };
21
+
22
+ const COMPACT_UNITS = [
23
+ { threshold: 1e12, suffix: "T" },
24
+ { threshold: 1e9, suffix: "B" },
25
+ { threshold: 1e6, suffix: "M" },
26
+ { threshold: 1e3, suffix: "K" },
27
+ ] as const;
2
28
 
3
29
  /**
4
30
  * Format the amount
@@ -25,15 +51,14 @@ export const formatAmount = (amount?: number, raw?: boolean): string => {
25
51
  ? (Math.ceil(amount / 1000000) * 1000000) / 100 // Round to nearest million if large
26
52
  : amount / 100;
27
53
 
28
- // Format the amount in dollars
29
- const formattedAmount = numbro(amountInDollars).formatCurrency({
30
- average: amountInDollars >= 1000,
31
- mantissa: amountInDollars < 1000 ? 2 : 1,
32
- trimMantissa: !(amount < 100 && amount !== 0),
33
- spaceSeparated: false,
34
- });
54
+ const mantissa = amountInDollars < 1000 ? 2 : 1;
55
+ const trimMantissa = !(amount < 100 && amount !== 0);
35
56
 
36
- return formattedAmount.toUpperCase();
57
+ const unit = COMPACT_UNITS.find((u) => amountInDollars >= u.threshold);
58
+ const scaled = unit ? amountInDollars / unit.threshold : amountInDollars;
59
+ const suffix = unit?.suffix ?? "";
60
+
61
+ return `$${formatNumberWithMantissa(scaled, mantissa, trimMantissa, false)}${suffix}`.toUpperCase();
37
62
  };
38
63
 
39
64
  /**
@@ -51,10 +76,7 @@ export const formatAmount = (amount?: number, raw?: boolean): string => {
51
76
  export const formatPercentage = (percentage?: number): string => {
52
77
  if (percentage === undefined || percentage === null) return "N/A";
53
78
 
54
- return `${numbro(percentage / 100).format({
55
- mantissa: 2,
56
- trimMantissa: true,
57
- })}%`;
79
+ return `${formatNumberWithMantissa(percentage / 100, 2, true, false)}%`;
58
80
  };
59
81
 
60
82
  /**
@@ -103,13 +125,10 @@ const formatAmountUnabbreviated = (amount?: number, raw?: boolean): string => {
103
125
  const amountInDollars = isLargeAmount
104
126
  ? (Math.ceil(amount / 1000000) * 1000000) / 100 // Round to nearest million if large
105
127
  : amount / 100;
128
+ const mantissa = amountInDollars < 1000 ? 2 : 1;
129
+ const trimMantissa = !(amount < 100 && amount !== 0);
106
130
  // Format the amount in dollars
107
- const formattedAmount = numbro(amountInDollars).formatCurrency({
108
- mantissa: amountInDollars < 1000 ? 2 : 1,
109
- trimMantissa: !(amount < 100 && amount !== 0),
110
- spaceSeparated: false,
111
- thousandSeparated: true,
112
- });
131
+ const formattedAmount = `$${formatNumberWithMantissa(amountInDollars, mantissa, trimMantissa, true)}`;
113
132
 
114
133
  return formattedAmount.toUpperCase();
115
134
  };
@@ -1,5 +1,4 @@
1
1
  import { get } from "radash";
2
- import { P, match } from "ts-pattern";
3
2
  import type { StatElementProps } from "../types";
4
3
  import { formatAmount, formatRange } from "../../formatUtils";
5
4
  import type { BaseOffer } from "../../../types/offerCatalogSchema";
@@ -21,56 +20,30 @@ const determineContent = ({
21
20
  annualIntroFeeTermValue,
22
21
  raw,
23
22
  }: {
24
- annualFeeValue?: string;
25
23
  minAnnualFeeValue?: number;
26
24
  maxAnnualFeeValue?: number;
27
25
  annualIntroFeeValue?: number;
28
26
  annualIntroFeeTermValue?: number;
29
27
  raw: boolean;
30
- }) => {
31
- return match({
32
- minAnnualFeeValue,
33
- maxAnnualFeeValue,
34
- annualIntroFeeValue,
35
- annualIntroFeeTermValue,
36
- })
37
- .with(
38
- { annualIntroFeeValue: P.not(undefined) },
39
- ({
40
- annualIntroFeeValue,
41
- annualIntroFeeTermValue,
42
- minAnnualFeeValue,
43
- maxAnnualFeeValue,
44
- }) => {
45
- const postIntroFee = formatRange(
46
- minAnnualFeeValue,
47
- maxAnnualFeeValue,
48
- "amount"
49
- );
50
- return `${formatAmount(
51
- annualIntroFeeValue
52
- )} for ${annualIntroFeeTermValue} years, then ${postIntroFee}`;
53
- }
54
- )
55
- .with(
56
- {
57
- minAnnualFeeValue: P.not(undefined),
58
- maxAnnualFeeValue: P.not(undefined),
59
- },
60
- ({ minAnnualFeeValue, maxAnnualFeeValue }) => {
61
- if (minAnnualFeeValue === maxAnnualFeeValue) {
62
- return formatAmount(minAnnualFeeValue, raw);
63
- }
64
- return formatRange(minAnnualFeeValue, maxAnnualFeeValue, "amount");
65
- }
66
- )
67
- .with({ minAnnualFeeValue: P.not(undefined) }, ({ minAnnualFeeValue }) =>
68
- formatAmount(minAnnualFeeValue)
69
- )
70
- .with({ maxAnnualFeeValue: P.not(undefined) }, ({ maxAnnualFeeValue }) =>
71
- formatAmount(maxAnnualFeeValue)
72
- )
73
- .otherwise(() => "See Terms");
28
+ }): string => {
29
+ if (annualIntroFeeValue !== undefined) {
30
+ const postIntroFee = formatRange(
31
+ minAnnualFeeValue,
32
+ maxAnnualFeeValue,
33
+ "amount"
34
+ );
35
+ return `${formatAmount(annualIntroFeeValue)} for ${annualIntroFeeTermValue} years, then ${postIntroFee}`;
36
+ }
37
+ if (minAnnualFeeValue !== undefined && maxAnnualFeeValue !== undefined) {
38
+ if (minAnnualFeeValue === maxAnnualFeeValue) {
39
+ return formatAmount(minAnnualFeeValue, raw);
40
+ }
41
+ return formatRange(minAnnualFeeValue, maxAnnualFeeValue, "amount");
42
+ }
43
+
44
+ const fee = minAnnualFeeValue ?? maxAnnualFeeValue;
45
+ if (fee !== undefined) return formatAmount(fee);
46
+ return "See Terms";
74
47
  };
75
48
 
76
49
  export const annualFee =
@@ -1,5 +1,4 @@
1
1
  import { get } from "radash";
2
- import { P, match } from "ts-pattern";
3
2
  import type { StatElementProps } from "../types";
4
3
  import { formatRange } from "../../formatUtils";
5
4
  import type { BaseOffer } from "../../../types/offerCatalogSchema";
@@ -33,21 +32,14 @@ const determineContent = ({
33
32
  purchaseAprValue?: string;
34
33
  minPurchaseAprValue?: number;
35
34
  maxPurchaseAprValue?: number;
36
- }) => {
37
- return match({ purchaseAprValue, minPurchaseAprValue, maxPurchaseAprValue })
38
- .with(
39
- { purchaseAprValue: P.not(undefined) },
40
- ({ purchaseAprValue }) => purchaseAprValue
41
- )
42
- .with(
43
- {
44
- minPurchaseAprValue: P.not(undefined),
45
- maxPurchaseAprValue: P.not(undefined),
46
- },
47
- ({ minPurchaseAprValue, maxPurchaseAprValue }) =>
48
- formatRange(minPurchaseAprValue, maxPurchaseAprValue, "percentage")
49
- )
50
- .otherwise(() => "See Terms");
35
+ }): string => {
36
+ if (purchaseAprValue !== undefined) {
37
+ return purchaseAprValue;
38
+ }
39
+ if (minPurchaseAprValue !== undefined && maxPurchaseAprValue !== undefined) {
40
+ return formatRange(minPurchaseAprValue, maxPurchaseAprValue, "percentage");
41
+ }
42
+ return "See Terms";
51
43
  };
52
44
 
53
45
  /**
@@ -56,11 +48,15 @@ const determineContent = ({
56
48
  * @param label {string}
57
49
  * @returns {string}
58
50
  */
59
- const determineLabel = (aprType: string, label: string) => {
60
- return match(aprType)
61
- .with("variable", () => "Variable APR:")
62
- .with("fixed", () => "Fixed APR:")
63
- .otherwise(() => label);
51
+ const determineLabel = (aprType: string, label: string): string => {
52
+ switch (aprType) {
53
+ case "variable":
54
+ return "Variable APR:";
55
+ case "fixed":
56
+ return "Fixed APR:";
57
+ default:
58
+ return label;
59
+ }
64
60
  };
65
61
 
66
62
  export const purchaseApr =
@@ -1,5 +1,4 @@
1
1
  import { get } from "radash";
2
- import { P, match } from "ts-pattern";
3
2
  import type { StatElementProps } from "../types";
4
3
  import { formatStringListWithAnd } from "../../formatUtils";
5
4
  import type { BaseOffer } from "../../../types/offerCatalogSchema";
@@ -28,13 +27,17 @@ export const recommendedCredit =
28
27
  ({ label, fieldName }: RecommendedCreditStat): StatElementProps => {
29
28
  const recommendedCreditValue = get<string[]>(offer, fieldName);
30
29
 
31
- const content = match(recommendedCreditValue)
32
- .with(P.array(), (value) =>
33
- hasAllRecommendedRatings(value)
34
- ? "Any"
35
- : formatStringListWithAnd(orderRecommendedRatings(value))
36
- )
37
- .otherwise(() => "See Terms");
30
+ let content = "See Terms";
31
+
32
+ if (Array.isArray(recommendedCreditValue)) {
33
+ if (hasAllRecommendedRatings(recommendedCreditValue)) {
34
+ content = "Any";
35
+ } else {
36
+ content = formatStringListWithAnd(
37
+ orderRecommendedRatings(recommendedCreditValue)
38
+ );
39
+ }
40
+ }
38
41
 
39
42
  return {
40
43
  label,