@envive-ai/react-hooks 0.3.1 → 0.3.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 (259) hide show
  1. package/dist/application/commerce-api.cjs +4 -4
  2. package/dist/application/commerce-api.js +4 -4
  3. package/dist/application/models/api/response.d.cts +1 -1
  4. package/dist/application/models/api/response.d.ts +1 -1
  5. package/dist/application/models/frontendConfig.d.cts +1 -1
  6. package/dist/application/models/frontendConfig.d.ts +1 -1
  7. package/dist/application/models/guards/api/isApiFormResponse.cjs +1 -1
  8. package/dist/application/models/guards/api/isApiFormResponse.js +1 -1
  9. package/dist/application/models/guards/api/isApiFormSubmittedResponseAttributes.cjs +1 -1
  10. package/dist/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +1 -1
  11. package/dist/application/models/guards/api/isApiOrderResponseAttributes.cjs +2 -2
  12. package/dist/application/models/guards/api/isApiOrderResponseAttributes.js +2 -2
  13. package/dist/application/models/guards/api/isApiProductResponseAttributes.cjs +1 -1
  14. package/dist/application/models/guards/api/isApiProductResponseAttributes.js +1 -1
  15. package/dist/application/models/guards/api/isApiResponse.cjs +1 -1
  16. package/dist/application/models/guards/api/isApiResponse.js +1 -1
  17. package/dist/application/models/guards/api/isApiSearchEventAttributes.cjs +2 -2
  18. package/dist/application/models/guards/api/isApiSearchEventAttributes.js +2 -2
  19. package/dist/application/models/message.cjs +1 -1
  20. package/dist/application/models/message.d.cts +1 -1
  21. package/dist/application/models/message.d.ts +1 -1
  22. package/dist/application/models/message.js +1 -1
  23. package/dist/application/models/validators/validateGraphQLColorsConfig.cjs +2 -1
  24. package/dist/application/models/validators/validateGraphQLColorsConfig.js +2 -1
  25. package/dist/application/models/validators/validateGraphQLFrontendConfig.cjs +1 -1
  26. package/dist/application/models/validators/validateGraphQLFrontendConfig.d.cts +1 -1
  27. package/dist/application/models/validators/validateGraphQLFrontendConfig.d.ts +1 -1
  28. package/dist/application/models/validators/validateGraphQLFrontendConfig.js +1 -1
  29. package/dist/application/utils/analyticsUtils.cjs +2 -2
  30. package/dist/application/utils/analyticsUtils.js +2 -2
  31. package/dist/application/utils/domObserver.cjs +1 -1
  32. package/dist/application/utils/domObserver.js +1 -1
  33. package/dist/application/utils/elementObserver.cjs +1 -1
  34. package/dist/application/utils/elementObserver.js +1 -1
  35. package/dist/application/utils/mutationHelper.cjs +2 -2
  36. package/dist/application/utils/mutationHelper.js +2 -2
  37. package/dist/application/utils/nodeSelector.cjs +5 -2
  38. package/dist/application/utils/nodeSelector.js +5 -2
  39. package/dist/application/utils/stringUtils.cjs +1 -1
  40. package/dist/application/utils/stringUtils.js +1 -1
  41. package/dist/atoms/app/index.cjs +1 -1
  42. package/dist/atoms/app/index.d.cts +1 -1
  43. package/dist/atoms/app/index.d.ts +1 -1
  44. package/dist/atoms/app/index.js +1 -1
  45. package/dist/atoms/app/variant.cjs +1 -1
  46. package/dist/atoms/app/variant.d.cts +3 -3
  47. package/dist/atoms/app/variant.d.ts +3 -3
  48. package/dist/atoms/app/variant.js +1 -1
  49. package/dist/atoms/chat/chatState.d.cts +15 -15
  50. package/dist/atoms/chat/chatState.d.ts +15 -15
  51. package/dist/atoms/chat/form.d.cts +2 -2
  52. package/dist/atoms/chat/form.d.ts +2 -2
  53. package/dist/atoms/chat/index.cjs +1 -1
  54. package/dist/atoms/chat/index.d.ts +3 -3
  55. package/dist/atoms/chat/index.js +1 -1
  56. package/dist/atoms/chat/lastMessage.d.cts +2 -2
  57. package/dist/atoms/chat/lastMessage.d.ts +2 -2
  58. package/dist/atoms/chat/messageQueue.cjs +1 -1
  59. package/dist/atoms/chat/messageQueue.js +1 -1
  60. package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
  61. package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
  62. package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
  63. package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
  64. package/dist/atoms/chat/replies.cjs +2 -2
  65. package/dist/atoms/chat/replies.d.cts +2 -2
  66. package/dist/atoms/chat/replies.d.ts +2 -2
  67. package/dist/atoms/chat/replies.js +2 -2
  68. package/dist/atoms/chat/suggestions.d.cts +2 -2
  69. package/dist/atoms/chat/suggestions.d.ts +2 -2
  70. package/dist/atoms/globalSearch/globalSearch.cjs +3 -1
  71. package/dist/atoms/globalSearch/globalSearch.d.cts +10 -7
  72. package/dist/atoms/globalSearch/globalSearch.d.ts +10 -7
  73. package/dist/atoms/globalSearch/globalSearch.js +3 -2
  74. package/dist/atoms/globalSearch/index.cjs +1 -0
  75. package/dist/atoms/globalSearch/index.d.cts +2 -2
  76. package/dist/atoms/globalSearch/index.d.ts +2 -2
  77. package/dist/atoms/globalSearch/index.js +2 -2
  78. package/dist/atoms/org/customerService.d.cts +7 -7
  79. package/dist/atoms/org/customerService.d.ts +6 -6
  80. package/dist/atoms/org/graphqlConfig.cjs +1 -1
  81. package/dist/atoms/org/graphqlConfig.d.cts +5 -5
  82. package/dist/atoms/org/graphqlConfig.d.ts +5 -5
  83. package/dist/atoms/org/graphqlConfig.js +1 -1
  84. package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
  85. package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
  86. package/dist/atoms/org/orgAnalyticsConfig.cjs +1 -1
  87. package/dist/atoms/org/orgAnalyticsConfig.d.cts +6 -6
  88. package/dist/atoms/org/orgAnalyticsConfig.d.ts +6 -6
  89. package/dist/atoms/org/orgAnalyticsConfig.js +1 -1
  90. package/dist/atoms/search/chatSearch.d.cts +17 -17
  91. package/dist/atoms/search/chatSearch.d.ts +17 -17
  92. package/dist/atoms/search/searchAPI.cjs +1 -1
  93. package/dist/atoms/search/searchAPI.d.cts +14 -14
  94. package/dist/atoms/search/searchAPI.d.ts +14 -14
  95. package/dist/atoms/search/searchAPI.js +1 -1
  96. package/dist/atoms/search/searchServiceAdapter.cjs +1 -1
  97. package/dist/atoms/search/searchServiceAdapter.js +1 -1
  98. package/dist/atoms/search/types.d.cts +1 -1
  99. package/dist/atoms/search/types.d.ts +1 -1
  100. package/dist/atoms/search/utils.d.cts +1 -1
  101. package/dist/atoms/search/utils.d.ts +1 -1
  102. package/dist/contexts/amplitudeContext/amplitudeContext.cjs +6 -6
  103. package/dist/contexts/amplitudeContext/amplitudeContext.js +6 -6
  104. package/dist/contexts/cdnContext/cdnContext.cjs +1 -1
  105. package/dist/contexts/cdnContext/cdnContext.js +1 -1
  106. package/dist/contexts/chatContext/chatContext.cjs +4 -4
  107. package/dist/contexts/chatContext/chatContext.js +4 -4
  108. package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +2 -3
  109. package/dist/contexts/enviveConfigContext/enviveConfigContext.js +2 -3
  110. package/dist/contexts/enviveContext/enviveContext.cjs +52 -0
  111. package/dist/contexts/enviveContext/enviveContext.d.cts +31 -0
  112. package/dist/contexts/enviveContext/enviveContext.d.ts +31 -0
  113. package/dist/contexts/enviveContext/enviveContext.js +51 -0
  114. package/dist/contexts/enviveContext/index.cjs +5 -0
  115. package/dist/contexts/enviveContext/index.d.cts +3 -0
  116. package/dist/contexts/enviveContext/index.d.ts +3 -0
  117. package/dist/contexts/enviveContext/index.js +4 -0
  118. package/dist/contexts/enviveContext/types.cjs +11 -0
  119. package/dist/contexts/enviveContext/types.d.cts +8 -0
  120. package/dist/contexts/enviveContext/types.d.ts +8 -0
  121. package/dist/contexts/enviveContext/types.js +10 -0
  122. package/dist/contexts/featureFlagContext/featureFlagContext.cjs +2 -2
  123. package/dist/contexts/featureFlagContext/featureFlagContext.js +2 -2
  124. package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.cjs +2 -2
  125. package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.js +2 -2
  126. package/dist/contexts/graphqlContext/graphqlContext.cjs +3 -3
  127. package/dist/contexts/graphqlContext/graphqlContext.js +3 -3
  128. package/dist/contexts/localStorageContext/localStorageContext.cjs +1 -1
  129. package/dist/contexts/localStorageContext/localStorageContext.js +1 -1
  130. package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +1 -1
  131. package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +1 -1
  132. package/dist/contexts/searchContext/searchContext.cjs +1 -1
  133. package/dist/contexts/searchContext/searchContext.js +1 -1
  134. package/dist/contexts/sessionStorageContext/sessionStorageContext.cjs +1 -1
  135. package/dist/contexts/sessionStorageContext/sessionStorageContext.js +1 -1
  136. package/dist/contexts/types.cjs +1 -1
  137. package/dist/contexts/types.d.cts +1 -1
  138. package/dist/contexts/types.d.ts +1 -1
  139. package/dist/contexts/types.js +1 -1
  140. package/dist/contexts/userIdentityContext/userIdentityContext.cjs +1 -1
  141. package/dist/contexts/userIdentityContext/userIdentityContext.js +1 -1
  142. package/dist/events/index.cjs +2 -4
  143. package/dist/events/index.js +2 -4
  144. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.cjs +1 -1
  145. package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.js +1 -1
  146. package/dist/hooks/Debounce/useDebounce.cjs +1 -1
  147. package/dist/hooks/Debounce/useDebounce.js +1 -1
  148. package/dist/hooks/ElementObserver/useElementObserver.cjs +2 -2
  149. package/dist/hooks/ElementObserver/useElementObserver.js +2 -2
  150. package/dist/hooks/IdentifyUser/useIdentifyUser.cjs +1 -1
  151. package/dist/hooks/IdentifyUser/useIdentifyUser.js +1 -1
  152. package/dist/hooks/ImageResolver/useImageResolver.cjs +2 -2
  153. package/dist/hooks/ImageResolver/useImageResolver.js +2 -2
  154. package/dist/hooks/IsSmallScreen/useIsSmallScreen.cjs +1 -1
  155. package/dist/hooks/IsSmallScreen/useIsSmallScreen.js +1 -1
  156. package/dist/hooks/LocalStorageOperations/useLocalStorageOperations.cjs +11 -3
  157. package/dist/hooks/LocalStorageOperations/useLocalStorageOperations.js +11 -3
  158. package/dist/hooks/Search/useRecommendedProducts.cjs +1 -1
  159. package/dist/hooks/Search/useRecommendedProducts.js +1 -1
  160. package/dist/hooks/Search/useSearch.cjs +6 -3
  161. package/dist/hooks/Search/useSearch.d.cts +3 -1
  162. package/dist/hooks/Search/useSearch.d.ts +3 -1
  163. package/dist/hooks/Search/useSearch.js +7 -4
  164. package/dist/hooks/Search/useSearchInput.cjs +1 -1
  165. package/dist/hooks/Search/useSearchInput.js +1 -1
  166. package/dist/hooks/SearchOperations/useSearchOperations.cjs +1 -1
  167. package/dist/hooks/SearchOperations/useSearchOperations.d.cts +1 -1
  168. package/dist/hooks/SearchOperations/useSearchOperations.d.ts +1 -1
  169. package/dist/hooks/SearchOperations/useSearchOperations.js +1 -1
  170. package/dist/hooks/SessionStorageOperations/useSessionStorageOperations.cjs +1 -1
  171. package/dist/hooks/SessionStorageOperations/useSessionStorageOperations.js +1 -1
  172. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.cjs +1 -1
  173. package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +1 -1
  174. package/dist/hooks/utils.cjs +3 -3
  175. package/dist/hooks/utils.d.ts +1 -1
  176. package/dist/hooks/utils.js +3 -3
  177. package/package.json +25 -6
  178. package/src/application/commerce-api.ts +12 -10
  179. package/src/application/models/api/nextMessageRequest.ts +2 -0
  180. package/src/application/models/api/response.ts +4 -4
  181. package/src/application/models/api/search.ts +1 -2
  182. package/src/application/models/api/userEvent.ts +1 -2
  183. package/src/application/models/frontendConfig.ts +2 -2
  184. package/src/application/models/guards/api/isApiOrderResponseAttributes.ts +8 -4
  185. package/src/application/models/guards/api/isApiSearchEventAttributes.ts +1 -1
  186. package/src/application/models/index.ts +1 -0
  187. package/src/application/models/message.ts +5 -5
  188. package/src/application/models/utilityTypes/delimiterCase.ts +1 -0
  189. package/src/application/models/validators/validateGraphQLColorsConfig.ts +2 -1
  190. package/src/application/models/validators/validateGraphQLFrontendConfig.ts +1 -1
  191. package/src/application/models/variantInfo/variantInfo.ts +3 -0
  192. package/src/application/utils/analyticsUtils.ts +3 -3
  193. package/src/application/utils/domObserver.ts +1 -0
  194. package/src/application/utils/elementObserver.ts +1 -0
  195. package/src/application/utils/mutationHelper.ts +3 -1
  196. package/src/application/utils/nodeSelector.ts +7 -1
  197. package/src/application/utils/stringUtils.ts +1 -0
  198. package/src/atoms/app/index.ts +17 -6
  199. package/src/atoms/app/variant.ts +11 -13
  200. package/src/atoms/chat/__tests__/messageQueue.test.spec.ts +61 -0
  201. package/src/atoms/chat/index.ts +8 -8
  202. package/src/atoms/chat/messageQueue.ts +2 -48
  203. package/src/atoms/chat/replies.ts +3 -3
  204. package/src/atoms/org/graphqlConfig.ts +0 -1
  205. package/src/atoms/org/orgAnalyticsConfig.ts +1 -1
  206. package/src/atoms/search/searchAPI.ts +1 -1
  207. package/src/atoms/search/searchServiceAdapter.ts +1 -1
  208. package/src/contexts/amplitudeContext/__tests__/amplitudeContext.test.tsx +4 -3
  209. package/src/contexts/amplitudeContext/amplitudeContext.tsx +5 -5
  210. package/src/contexts/cdnContext/cdnContext.tsx +1 -1
  211. package/src/contexts/enviveConfigContext/__tests__/enviveConfigContext.test.tsx +2 -3
  212. package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +3 -3
  213. package/src/contexts/enviveContext/enviveContext.tsx +89 -0
  214. package/src/contexts/enviveContext/index.ts +2 -0
  215. package/src/contexts/enviveContext/types.ts +4 -0
  216. package/src/contexts/featureFlagContext/featureFlagContext.tsx +1 -1
  217. package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +1 -1
  218. package/src/contexts/graphqlContext/__tests__/graphqlContext.test.tsx +7 -5
  219. package/src/contexts/graphqlContext/graphqlContext.tsx +1 -5
  220. package/src/contexts/hardcopyContext/hardcopyContext.tsx +70 -0
  221. package/src/contexts/hardcopyContext/index.ts +1 -0
  222. package/src/contexts/localStorageContext/__tests__/localStorageContext.test.tsx +9 -3
  223. package/src/contexts/localStorageContext/localStorageContext.tsx +1 -1
  224. package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +2 -3
  225. package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +1 -1
  226. package/src/contexts/pageContext/__tests__/pageContext.test.tsx +666 -0
  227. package/src/contexts/pageContext/index.ts +2 -0
  228. package/src/contexts/pageContext/mapping.ts +38 -0
  229. package/src/contexts/pageContext/pageContext.tsx +78 -0
  230. package/src/contexts/pageContext/types.ts +27 -0
  231. package/src/contexts/salesAgentContext/chatAPI.ts +75 -0
  232. package/src/contexts/salesAgentContext/index.ts +3 -0
  233. package/src/contexts/salesAgentContext/salesAgentContext.tsx +128 -0
  234. package/src/contexts/salesAgentContext/salesAgentService.ts +197 -0
  235. package/src/contexts/searchContext/__tests__/searchContext.test.tsx +14 -15
  236. package/src/contexts/searchContext/searchContext.tsx +1 -1
  237. package/src/contexts/sessionStorageContext/sessionStorageContext.tsx +1 -1
  238. package/src/contexts/systemSettingsContext/__tests__/systemSettingsContext.test.tsx +7 -6
  239. package/src/contexts/types.ts +20 -22
  240. package/src/contexts/userIdentityContext/__tests__/userIdentityContext.test.tsx +3 -8
  241. package/src/contexts/userIdentityContext/userIdentityContext.tsx +1 -1
  242. package/src/events/index.ts +5 -7
  243. package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +1 -1
  244. package/src/hooks/Debounce/useDebounce.ts +1 -1
  245. package/src/hooks/ElementObserver/useElementObserver.ts +2 -1
  246. package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +4 -2
  247. package/src/hooks/IdentifyUser/useIdentifyUser.ts +1 -1
  248. package/src/hooks/ImageResolver/useImageResolver.ts +2 -0
  249. package/src/hooks/IsSmallScreen/useIsSmallScreen.ts +1 -1
  250. package/src/hooks/LocalStorageOperations/useLocalStorageOperations.ts +20 -4
  251. package/src/hooks/Search/__tests__/useSearch.test.tsx +15 -10
  252. package/src/hooks/Search/useRecommendedProducts.ts +2 -2
  253. package/src/hooks/Search/useSearchInput.ts +1 -1
  254. package/src/hooks/SearchOperations/useSearchOperations.ts +2 -2
  255. package/src/hooks/SessionStorageOperations/useSessionStorageOperations.ts +1 -1
  256. package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +2 -2
  257. package/src/hooks/utils.ts +3 -2
  258. package/src/contexts/chatContext/chatContext.tsx +0 -463
  259. package/src/contexts/chatContext/index.ts +0 -1
@@ -462,8 +462,7 @@ interface VisitCategoryMap extends BaseCategoryExtractor<CategoryExtractorType.V
462
462
  }
463
463
 
464
464
  // This will return a hard-coded default PageVisitCategory. It is intended to be used by fallback page types
465
- interface VisitCategoryDefault
466
- extends BaseCategoryExtractor<CategoryExtractorType.VisitCategoryDefault> {
465
+ interface VisitCategoryDefault extends BaseCategoryExtractor<CategoryExtractorType.VisitCategoryDefault> {
467
466
  value: PageVisitCategory;
468
467
  }
469
468
 
@@ -549,16 +548,13 @@ interface QueryParamTest extends BasePageVariantTest<PageVariantTestType.QueryPa
549
548
  queryParam: string;
550
549
  }
551
550
 
552
- interface UserHasInteractedTest
553
- extends BasePageVariantTest<PageVariantTestType.UserHasInteracted> {}
551
+ interface UserHasInteractedTest extends BasePageVariantTest<PageVariantTestType.UserHasInteracted> {}
554
552
 
555
- interface UserHasNotInteractedTest
556
- extends BasePageVariantTest<PageVariantTestType.UserHasNotInteracted> {}
553
+ interface UserHasNotInteractedTest extends BasePageVariantTest<PageVariantTestType.UserHasNotInteracted> {}
557
554
 
558
555
  interface IsLoadingTest extends BasePageVariantTest<PageVariantTestType.isLoading> {}
559
556
 
560
- interface IsProductComparison
561
- extends BasePageVariantTest<PageVariantTestType.isProductComparison> {}
557
+ interface IsProductComparison extends BasePageVariantTest<PageVariantTestType.isProductComparison> {}
562
558
 
563
559
  interface PageFallbackTest extends BasePageVariantTest<PageVariantTestType.Fallback> {}
564
560
 
@@ -664,6 +660,15 @@ enum WidgetType {
664
660
  NoOp = 'NoOp',
665
661
  }
666
662
 
663
+ export enum WidgetTypeV3 {
664
+ SuggestionBarV3 = 'SuggestionBarV3',
665
+ ChatPreviewV3 = 'ChatPreviewV3',
666
+ SocialProofV3 = 'SocialProofV3',
667
+ ImagePromptCardV3 = 'ImagePromptCardV3',
668
+ ImageBannerV3 = 'ImageBannerV3',
669
+ SingleImagePromptV3 = 'SingleImagePromptV3',
670
+ }
671
+
667
672
  type WidgetConfig =
668
673
  | ChatPreviewWidgetConfig
669
674
  | SocialProofV2WidgetConfig
@@ -751,31 +756,26 @@ interface BaseChatPreviewConfig {
751
756
 
752
757
  // Specific chat preview widget configurations
753
758
  interface ChatPreviewPostInteractionWidgetConfig
754
- extends BaseWidgetConfig<WidgetType.ChatPreviewPostInteraction>,
755
- BaseChatPreviewConfig {
759
+ extends BaseWidgetConfig<WidgetType.ChatPreviewPostInteraction>, BaseChatPreviewConfig {
756
760
  chatPreviewVariant: ChatPreviewVariant;
757
761
  addSeparators?: boolean;
758
762
  }
759
763
 
760
764
  interface ChatPreviewIsLoadingWidgetConfig
761
- extends BaseWidgetConfig<WidgetType.ChatPreviewIsLoading>,
762
- BaseChatPreviewConfig {}
765
+ extends BaseWidgetConfig<WidgetType.ChatPreviewIsLoading>, BaseChatPreviewConfig {}
763
766
 
764
767
  interface ChatPreviewProductComparisonWidgetConfig
765
- extends BaseWidgetConfig<WidgetType.ChatPreviewProductComparison>,
766
- BaseChatPreviewConfig {
768
+ extends BaseWidgetConfig<WidgetType.ChatPreviewProductComparison>, BaseChatPreviewConfig {
767
769
  useLargeProductComparison?: boolean;
768
770
  }
769
771
 
770
772
  interface ChatPreviewV2WidgetConfig
771
- extends BaseWidgetConfig<WidgetType.ChatPreviewV2>,
772
- BaseChatPreviewConfig {
773
+ extends BaseWidgetConfig<WidgetType.ChatPreviewV2>, BaseChatPreviewConfig {
773
774
  animatedTextConfig: ChatPreviewAnimatedTextConfig;
774
775
  }
775
776
 
776
777
  interface SocialProofV2WidgetConfig
777
- extends BaseWidgetConfig<WidgetType.SocialProofV2>,
778
- BaseChatPreviewConfig {
778
+ extends BaseWidgetConfig<WidgetType.SocialProofV2>, BaseChatPreviewConfig {
779
779
  customerQuery?: string; // Default: 'asked which products are the best'
780
780
  imageConfig: SocialProofImageConfig;
781
781
  }
@@ -811,8 +811,7 @@ interface SingleImagePromptWidgetConfig extends BaseWidgetConfig<WidgetType.Sing
811
811
  userQueryButtonConfig: UserQueryButtonConfig;
812
812
  }
813
813
 
814
- interface SearchEntryPointWidgetConfig
815
- extends BaseWidgetConfig<WidgetType.SearchZeroStateEntryPoint> {
814
+ interface SearchEntryPointWidgetConfig extends BaseWidgetConfig<WidgetType.SearchZeroStateEntryPoint> {
816
815
  searchZeroStateVariant: SearchZeroStateVariant;
817
816
  searchInputVariant: SearchInputVariant;
818
817
  searchIconVariant?: SearchIconVariant;
@@ -830,8 +829,7 @@ interface SearchEntryPointWidgetConfig
830
829
  interface NoOpWidgetConfig extends BaseWidgetConfig<WidgetType.NoOp> {}
831
830
  interface SearchOverlayHostWidgetConfig extends BaseWidgetConfig<WidgetType.SearchOverlayHost> {}
832
831
 
833
- interface SearchResultsEntryPointWidgetConfig
834
- extends BaseWidgetConfig<WidgetType.SearchResultsEntryPoint> {
832
+ interface SearchResultsEntryPointWidgetConfig extends BaseWidgetConfig<WidgetType.SearchResultsEntryPoint> {
835
833
  searchInputVariant: SearchInputVariant;
836
834
  searchFilterSidebarVariant: SearchFilterSidebarVariant;
837
835
  productGridVariant: ProductGridVariant;
@@ -1,17 +1,11 @@
1
1
  import React from 'react';
2
- import { render, screen, waitFor, act } from '@testing-library/react';
2
+ import { act, render, screen, waitFor } from '@testing-library/react';
3
3
  import { Provider, useStore } from 'jotai';
4
- import { useAtomValue } from 'jotai';
5
- import {
6
- UserIdentityProvider,
7
- useUserIdentity,
8
- UserIdentityContextType,
9
- } from '../userIdentityContext';
10
4
  import { userIdAtom } from 'src/atoms/app';
11
5
  import { LocalStorageProvider } from 'src/contexts/localStorageContext';
12
6
  import Logger from 'src/application/logging/logger';
13
7
  import CommerceApiClient from 'src/application/commerce-api';
14
- import { v4 as uuid } from 'uuid';
8
+ import { UserIdentityProvider, useUserIdentity } from '../userIdentityContext';
15
9
 
16
10
  // Mock the Logger to avoid console output in tests
17
11
  vi.spyOn(Logger, 'logInfo').mockImplementation(() => {});
@@ -104,6 +98,7 @@ const IdentifyUserComponent: React.FC = () => {
104
98
  return (
105
99
  <div>
106
100
  <button
101
+ type="button"
107
102
  data-testid="identify-button"
108
103
  onClick={handleIdentify}
109
104
  >
@@ -1,4 +1,4 @@
1
- import React, { createContext, useCallback, useContext, useMemo, useState, useEffect } from 'react';
1
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
2
2
  import UAParser from 'ua-parser-js';
3
3
  import Logger from 'src/application/logging/logger';
4
4
  import CommerceApiClient from 'src/application/commerce-api';
@@ -29,13 +29,11 @@ export class EventsDispatcher {
29
29
  * @param includeDefault - optional parameter to exclude the default event
30
30
  * data
31
31
  */
32
- static dispatch(eventName: string, detail?: Record<string, any>, includeDefault?: boolean) {
33
- if (detail === undefined) {
34
- detail = {};
35
- }
36
- if (includeDefault === undefined) {
37
- includeDefault = true;
38
- }
32
+ static dispatch(
33
+ eventName: string,
34
+ detail: Record<string, any> = {},
35
+ includeDefault: boolean = true,
36
+ ) {
39
37
  const eventData = includeDefault ? { ...this.eventData, ...detail } : detail;
40
38
  const event = new CustomEvent(eventName, {
41
39
  detail: eventData,
@@ -1,4 +1,4 @@
1
- import { useState, useCallback } from 'react';
1
+ import { useCallback, useState } from 'react';
2
2
  import {
3
3
  SpiffyMetricsEventName,
4
4
  useAmplitude,
@@ -1,4 +1,4 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
 
3
3
  export function useDebounce<T>(value: T, delay: number): T {
4
4
  const [debouncedValue, setDebouncedValue] = useState<T>(value);
@@ -151,6 +151,7 @@ export const useElementObserver = (selector: NodeSelector): ElementObserverUtili
151
151
  if (!renderBlocked) {
152
152
  return eoRef.current.render(fn);
153
153
  }
154
+ return undefined;
154
155
  };
155
156
 
156
157
  /**
@@ -211,7 +212,7 @@ export const useElementObserver = (selector: NodeSelector): ElementObserverUtili
211
212
  */
212
213
  const applyStyle = (styles: React.CSSProperties) => {
213
214
  const node = eoRef?.current?.getNode();
214
- node && Object.assign(node.style, styles);
215
+ return node && Object.assign(node.style, styles);
215
216
  };
216
217
 
217
218
  useEffect(() => {
@@ -1,4 +1,6 @@
1
+ import { useAtom } from 'jotai';
1
2
  import { useCallback, useEffect, useState } from 'react';
3
+ import { orgIdAtom } from 'src/atoms/org/graphqlConfig';
2
4
  import { GraphQlConfigValues, useGraphQLClient } from 'src/contexts/graphqlContext/graphqlContext';
3
5
 
4
6
  export const useColorsAndFrontendConfig = () => {
@@ -32,7 +34,7 @@ export const useColorsAndFrontendConfig = () => {
32
34
 
33
35
  export const useOrgId = () => {
34
36
  const { getOrgId, isReady } = useGraphQLClient();
35
- const [orgId, setOrgId] = useState<string | undefined>();
37
+ const [orgId, setOrgId] = useAtom(orgIdAtom);
36
38
  const [loading, setLoading] = useState(false);
37
39
  const [error, setError] = useState<Error | null>(null);
38
40
 
@@ -54,7 +56,7 @@ export const useOrgId = () => {
54
56
  };
55
57
 
56
58
  fetchOrgId();
57
- }, [getOrgId, isReady]);
59
+ }, [getOrgId, isReady, setOrgId]);
58
60
 
59
61
  return { orgId, loading, error };
60
62
  };
@@ -1,4 +1,4 @@
1
- import { useState, useCallback } from 'react';
1
+ import { useCallback, useState } from 'react';
2
2
  import { useUserIdentity } from 'src/contexts/userIdentityContext/userIdentityContext';
3
3
 
4
4
  export const useIdentifyUser = () => {
@@ -1,6 +1,8 @@
1
+ /* eslint-disable @typescript-eslint/no-use-before-define */
1
2
  import { useAtomValue } from 'jotai';
2
3
  import { OrgShortName } from 'src/application/models';
3
4
  import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
5
+
4
6
  abstract class ImageResolver {
5
7
  abstract resolve(url: string, size: number): string;
6
8
  }
@@ -1,4 +1,4 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
 
3
3
  export const useIsSmallScreen = () => {
4
4
  const [isSmall, setIsSmall] = useState(false);
@@ -1,6 +1,6 @@
1
- import { useState, useEffect, useCallback } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { LocalStorageEventListener } from 'src/application/models/localStorageEventListener';
3
- import { useLocalStorage, LocalStorageKeys } from 'src/contexts/localStorageContext';
3
+ import { LocalStorageKeys, useLocalStorage } from 'src/contexts/localStorageContext';
4
4
 
5
5
  // Reactive localStorage value hook
6
6
  export const useLocalStorageValue = (key: string) => {
@@ -43,7 +43,15 @@ export const useSpiffyFeatureFlag = () => {
43
43
  );
44
44
 
45
45
  return {
46
- value: value === 'true' ? true : value === 'false' ? false : null,
46
+ value: (() => {
47
+ if (value === 'true') {
48
+ return true;
49
+ }
50
+ if (value === 'false') {
51
+ return false;
52
+ }
53
+ return null;
54
+ })(),
47
55
  setFlag,
48
56
  };
49
57
  };
@@ -65,7 +73,15 @@ export const useEnviveFeatureFlag = () => {
65
73
  );
66
74
 
67
75
  return {
68
- value: value === 'true' ? true : value === 'false' ? false : null,
76
+ value: (() => {
77
+ if (value === 'true') {
78
+ return true;
79
+ }
80
+ if (value === 'false') {
81
+ return false;
82
+ }
83
+ return null;
84
+ })(),
69
85
  setFlag,
70
86
  };
71
87
  };
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
- import { render, screen, waitFor, act } from '@testing-library/react';
2
+ import { act, render, screen, waitFor } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
- import { Provider, useAtomValue, useSetAtom } from 'jotai';
5
- import { useSearch } from '../useSearch';
4
+ import { Provider, useSetAtom } from 'jotai';
6
5
  import { AmplitudeProvider } from 'src/contexts/amplitudeContext/amplitudeContext';
7
6
  import { EnviveConfigProvider } from 'src/contexts/enviveConfigContext/enviveConfigContext';
8
7
  import { LocalStorageProvider } from 'src/contexts/localStorageContext/localStorageContext';
@@ -12,19 +11,18 @@ import { FeatureFlagServiceProvider } from 'src/contexts/featureFlagServiceConte
12
11
  import { NewOrgConfigProvider } from 'src/contexts/newOrgConfigContext/newOrgConfigContext';
13
12
  import { SearchProvider } from 'src/contexts/searchContext/searchContext';
14
13
  import {
14
+ createFilterOption,
15
15
  searchAtom,
16
16
  searchParamsAtom,
17
- searchSelectedFiltersAtom,
18
17
  searchProductSortingAtom,
19
- searchFiltersAtom,
18
+ searchSelectedFiltersAtom,
20
19
  } from 'src/atoms/search';
21
20
  import { isFilterOpenAtom } from 'src/atoms/globalSearch/globalSearch';
22
21
  import { ProductSorting } from 'src/atoms/search/types';
23
22
  import { SearchResult } from 'src/application/models/api/search';
24
23
  import { SearchResultsState } from 'src/hooks/utils';
25
- import { createFilterOption } from 'src/atoms/search';
26
- import { SearchFilterDatum } from 'src/types/search-filter-types';
27
24
  import { SearchResponseProduct } from '@spiffy-ai/commerce-api-client';
25
+ import { useSearch } from '../useSearch';
28
26
 
29
27
  // Mock dependencies
30
28
  vi.mock('src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent', () => ({
@@ -231,6 +229,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
231
229
  />
232
230
 
233
231
  <button
232
+ type="button"
234
233
  data-testid="submit-search"
235
234
  onClick={searchHook.onSubmitSearch}
236
235
  >
@@ -238,6 +237,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
238
237
  </button>
239
238
 
240
239
  <button
240
+ type="button"
241
241
  data-testid="toggle-filter"
242
242
  onClick={() => searchHook.setIsFilterOpen(!searchHook.isFilterOpen)}
243
243
  >
@@ -245,6 +245,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
245
245
  </button>
246
246
 
247
247
  <button
248
+ type="button"
248
249
  data-testid="clear-all-filters"
249
250
  onClick={searchHook.onClearAllFilters}
250
251
  >
@@ -252,6 +253,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
252
253
  </button>
253
254
 
254
255
  <button
256
+ type="button"
255
257
  data-testid="reset-search"
256
258
  onClick={searchHook.resetSearch}
257
259
  >
@@ -260,6 +262,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
260
262
 
261
263
  {searchHook.availableDynamicFilters.length > 0 && (
262
264
  <button
265
+ type="button"
263
266
  data-testid="toggle-dynamic-filter"
264
267
  onClick={() =>
265
268
  searchHook.onToggleDynamicFilter({
@@ -274,6 +277,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
274
277
 
275
278
  {searchHook.searchFilters.length > 0 && (
276
279
  <button
280
+ type="button"
277
281
  data-testid="select-filter-item"
278
282
  onClick={() =>
279
283
  searchHook.onSelectFilterItem({
@@ -290,6 +294,7 @@ const TestComponent: React.FC<{ allowRedirect?: boolean }> = ({ allowRedirect =
290
294
 
291
295
  {searchHook.selectedFilterOptions.length > 0 && (
292
296
  <button
297
+ type="button"
293
298
  data-testid="remove-filter"
294
299
  onClick={() => searchHook.onRemoveFilter(searchHook.selectedFilterOptions[0])}
295
300
  >
@@ -619,7 +624,7 @@ describe('useSearch', () => {
619
624
  it('should show loading state', async () => {
620
625
  render(
621
626
  <TestWrapper
622
- loading={true}
627
+ loading
623
628
  query="test"
624
629
  >
625
630
  <TestComponent />
@@ -803,8 +808,8 @@ describe('useSearch', () => {
803
808
  describe('Allow Redirect Option', () => {
804
809
  it('should pass allowRedirect option to performSearch', async () => {
805
810
  render(
806
- <TestWrapper allowRedirect={true}>
807
- <TestComponent allowRedirect={true} />
811
+ <TestWrapper allowRedirect>
812
+ <TestComponent allowRedirect />
808
813
  </TestWrapper>,
809
814
  );
810
815
 
@@ -2,13 +2,13 @@ import { useAtomValue, useSetAtom } from 'jotai';
2
2
  import { useEffect } from 'react';
3
3
  import { useFeatureFlagService } from 'src/contexts/featureFlagServiceContext/featureFlagServiceContext';
4
4
  import {
5
- retrievedProductsAtom,
6
5
  performProductRetrievalAtom,
7
6
  productRetrievalAtom,
7
+ retrievedProductsAtom,
8
8
  } from 'src/atoms/search/productRetrievalAPI';
9
- import { useNewOrgConfig } from '../NewOrgConfig';
10
9
  import { SearchResponseProductAttributes } from 'src/application/models/api/response';
11
10
  import { FeatureGates } from 'src/application/models';
11
+ import { useNewOrgConfig } from '../NewOrgConfig';
12
12
 
13
13
  /**
14
14
  * A hook to get recommended products.
@@ -1,4 +1,4 @@
1
- import { useState, useCallback, useRef, useMemo } from 'react';
1
+ import { useCallback, useMemo, useRef, useState } from 'react';
2
2
  import { useAtomValue } from 'jotai';
3
3
  import Fuse from 'fuse.js';
4
4
 
@@ -1,6 +1,6 @@
1
- import { useState, useCallback, useEffect } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { useSearchService } from 'src/contexts/searchContext';
3
- import { SearchResult, SearchParams } from 'src/application/models/api/search';
3
+ import { SearchParams, SearchResult } from 'src/application/models/api/search';
4
4
 
5
5
  export const useProductSearch = () => {
6
6
  const { searchProducts, isReady } = useSearchService();
@@ -1,4 +1,4 @@
1
- import { useState, useEffect, useCallback } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { useSessionStorage } from 'src/contexts/sessionStorageContext';
3
3
 
4
4
  export const useSessionStorageValue = (key: string) => {
@@ -39,7 +39,7 @@ export const useTrackComponentVisibleEvent = (
39
39
  }
40
40
  // Default case for other event types
41
41
  return {
42
- component: component,
42
+ component,
43
43
  ...eventProps,
44
44
  };
45
45
  })();
@@ -47,7 +47,7 @@ export const useTrackComponentVisibleEvent = (
47
47
  useEffect(() => {
48
48
  if (isVisible && !hasTrackedEvent.current) {
49
49
  trackEvent({
50
- eventName: eventName,
50
+ eventName,
51
51
  eventProps: componentProps,
52
52
  });
53
53
  hasTrackedEvent.current = true;
@@ -80,11 +80,11 @@ const parseTime = (time: string, timeZone: string) => {
80
80
  // Adjust hours for AM/PM
81
81
  let adjustedHours = 0;
82
82
  if (period.toUpperCase() === 'PM' && hours !== '12') {
83
- adjustedHours = parseInt(hours) + 12;
83
+ adjustedHours = parseInt(hours, 10) + 12;
84
84
  }
85
85
 
86
86
  if (period.toUpperCase() === 'AM' && hours !== '12') {
87
- adjustedHours = parseInt(hours);
87
+ adjustedHours = parseInt(hours, 10);
88
88
  }
89
89
 
90
90
  // Create the date string with time zone
@@ -94,6 +94,7 @@ const parseTime = (time: string, timeZone: string) => {
94
94
  )}:${minutes}:00`;
95
95
  return new Date(`${formattedDate}${timeZone}`);
96
96
  }
97
+ return undefined;
97
98
  };
98
99
 
99
100
  export const isWithinBusinessHours = (startTime: string, endTime: string, timeZone: string) => {