@envive-ai/react-hooks 0.2.5 → 0.2.6-alpha-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.
- package/dist/AmplitudeOperations-C3i2q2Bn.js +34 -0
- package/dist/AmplitudeOperations-DcuLn1Zk.cjs +41 -0
- package/dist/{NewOrgConfig-B98Y9tMb.js → NewOrgConfig-BtvujFC8.js} +2 -2
- package/dist/{NewOrgConfig-ZbBKiByQ.cjs → NewOrgConfig-CHt7Xg4t.cjs} +2 -2
- package/dist/TrackComponentVisibleEvent-Be7wfXXY.js +53 -0
- package/dist/TrackComponentVisibleEvent-KUihr_y4.cjs +60 -0
- package/dist/amplitudeContext-CRFxGj_x.d.ts +52 -0
- package/dist/amplitudeContext-ZkerrMUa.d.cts +52 -0
- package/dist/api-D4HaU2Gf.js +166 -0
- package/dist/api-D4Xoibs9.cjs +239 -0
- package/dist/application/models/graphql/index.cjs +3 -3
- package/dist/application/models/graphql/index.d.cts +2 -2
- package/dist/application/models/graphql/index.d.ts +2 -2
- package/dist/application/models/graphql/index.js +2 -3
- package/dist/application/models/guards/api/index.cjs +3 -3
- package/dist/application/models/guards/api/index.d.cts +2 -2
- package/dist/application/models/guards/api/index.d.ts +2 -2
- package/dist/application/models/guards/api/index.js +3 -3
- package/dist/application/models/guards/utils.cjs +1 -1
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/guards/utils.js +1 -1
- package/dist/application/models/index.cjs +7 -23
- package/dist/application/models/index.d.cts +167 -11
- package/dist/application/models/index.d.ts +168 -12
- package/dist/application/models/index.js +7 -11
- package/dist/application/utils/index.cjs +19 -19
- package/dist/application/utils/index.d.cts +14 -63
- package/dist/application/utils/index.d.ts +14 -63
- package/dist/application/utils/index.js +19 -19
- package/dist/{atomStore-DXTVqiKc.js → atomStore-BuopbV9k.js} +1 -1
- package/dist/{atomStore-DNji91Im.cjs → atomStore-CZKe3itM.cjs} +1 -1
- package/dist/atoms/app/index.cjs +19 -19
- package/dist/atoms/app/index.d.cts +9 -20
- package/dist/atoms/app/index.d.ts +2 -13
- package/dist/atoms/app/index.js +19 -19
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +21 -21
- package/dist/atoms/chat/index.d.cts +37 -45
- package/dist/atoms/chat/index.d.ts +35 -43
- package/dist/atoms/chat/index.js +21 -21
- package/dist/atoms/globalSearch/index.cjs +1 -1
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +1 -1
- package/dist/atoms/org/index.cjs +10 -11
- package/dist/atoms/org/index.d.cts +19 -31
- package/dist/atoms/org/index.d.ts +19 -31
- package/dist/atoms/org/index.js +2 -3
- package/dist/atoms/search/index.cjs +7 -47
- package/dist/atoms/search/index.d.cts +76 -14
- package/dist/atoms/search/index.d.ts +76 -14
- package/dist/atoms/search/index.js +7 -29
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/cdnContext-B2-NiEiW.js +38 -0
- package/dist/cdnContext-CdhppNeT.cjs +53 -0
- package/dist/chat-C9KdnT5V.js +230 -0
- package/dist/chat-bImNRcnQ.cjs +330 -0
- package/dist/chatState-DqWSgmjC.cjs +120 -0
- package/dist/chatState-DxG0t4fK.js +34 -0
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/locators/components/chat/index.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.cts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.ts +1 -1
- package/dist/config/locators/components/common/index.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +1 -1
- package/dist/config/locators/components/index.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/components/search/index.d.cts +1 -1
- package/dist/config/locators/components/search/index.d.ts +1 -1
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +19 -19
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.d.ts +1 -1
- package/dist/contexts/amplitudeContext/index.js +19 -19
- package/dist/contexts/cdnContext/index.cjs +4 -4
- package/dist/contexts/cdnContext/index.d.cts +2 -6
- package/dist/contexts/cdnContext/index.d.ts +2 -6
- package/dist/contexts/cdnContext/index.js +4 -4
- package/dist/contexts/enviveConfigContext/index.cjs +4 -4
- package/dist/contexts/enviveConfigContext/index.d.cts +3 -24
- package/dist/contexts/enviveConfigContext/index.d.ts +3 -24
- package/dist/contexts/enviveConfigContext/index.js +4 -4
- package/dist/contexts/enviveCssContext/index.cjs +15 -19
- package/dist/contexts/enviveCssContext/index.d.cts +3 -5
- package/dist/contexts/enviveCssContext/index.d.ts +3 -5
- package/dist/contexts/enviveCssContext/index.js +15 -19
- package/dist/contexts/featureFlagContext/index.cjs +9 -10
- package/dist/contexts/featureFlagContext/index.d.cts +3 -11
- package/dist/contexts/featureFlagContext/index.d.ts +3 -11
- package/dist/contexts/featureFlagContext/index.js +6 -7
- package/dist/contexts/featureFlagServiceContext/index.cjs +4 -3
- package/dist/contexts/featureFlagServiceContext/index.d.cts +1 -4
- package/dist/contexts/featureFlagServiceContext/index.d.ts +1 -4
- package/dist/contexts/featureFlagServiceContext/index.js +4 -3
- package/dist/contexts/graphqlContext/index.cjs +8 -13
- package/dist/contexts/graphqlContext/index.d.cts +11 -14
- package/dist/contexts/graphqlContext/index.d.ts +11 -14
- package/dist/contexts/graphqlContext/index.js +8 -13
- package/dist/contexts/localStorageContext/index.cjs +3 -3
- package/dist/contexts/localStorageContext/index.d.cts +3 -22
- package/dist/contexts/localStorageContext/index.d.ts +3 -22
- package/dist/contexts/localStorageContext/index.js +4 -3
- package/dist/contexts/newOrgConfigContext/index.cjs +13 -17
- package/dist/contexts/newOrgConfigContext/index.d.cts +12 -15
- package/dist/contexts/newOrgConfigContext/index.d.ts +12 -15
- package/dist/contexts/newOrgConfigContext/index.js +13 -17
- package/dist/contexts/searchContext/index.cjs +24 -24
- package/dist/contexts/searchContext/index.d.cts +2 -7
- package/dist/contexts/searchContext/index.d.ts +2 -7
- package/dist/contexts/searchContext/index.js +24 -24
- package/dist/contexts/sessionStorageContext/index.cjs +2 -2
- package/dist/contexts/sessionStorageContext/index.d.cts +2 -6
- package/dist/contexts/sessionStorageContext/index.d.ts +2 -6
- package/dist/contexts/sessionStorageContext/index.js +2 -2
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +2 -11
- package/dist/contexts/shopifyUrlContext/index.d.ts +2 -11
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +4 -4
- package/dist/contexts/systemSettingsContext/index.d.cts +6 -16
- package/dist/contexts/systemSettingsContext/index.d.ts +4 -14
- package/dist/contexts/systemSettingsContext/index.js +4 -4
- package/dist/contexts/userIdentityContext/index.cjs +19 -19
- package/dist/contexts/userIdentityContext/index.d.cts +11 -2
- package/dist/contexts/userIdentityContext/index.d.ts +11 -2
- package/dist/contexts/userIdentityContext/index.js +19 -19
- package/dist/dist-B7BErEyV.cjs +6019 -0
- package/dist/dist-CtkINi1R.js +5923 -0
- package/dist/domObserver-B19-69gW.js +285 -0
- package/dist/{domObserver-v9ODTyfT.js → domObserver-CwieVNgj.cjs} +23 -4
- package/dist/enviveConfig-Be2kZE7j.js +62 -0
- package/dist/enviveConfig-u50Rpz-G.cjs +130 -0
- package/dist/enviveConfigContext-1oiQuocd.js +45 -0
- package/dist/enviveConfigContext-kQfHEGdJ.cjs +60 -0
- package/dist/events/index.cjs +2 -3
- package/dist/events/index.d.cts +2 -15
- package/dist/events/index.d.ts +2 -15
- package/dist/events/index.js +2 -2
- package/dist/events-CgFGtanE.cjs +69 -0
- package/dist/events-WOOrnUAx.js +63 -0
- package/dist/exceptions/index.cjs +4 -0
- package/dist/exceptions/index.d.cts +12 -0
- package/dist/exceptions/index.d.ts +12 -0
- package/dist/exceptions/index.js +3 -0
- package/dist/exceptions-BjDgLzGi.cjs +32 -0
- package/dist/exceptions-CUGY31Ua.js +20 -0
- package/dist/featureFlagServiceContext-B7je7VZV.d.cts +24 -0
- package/dist/featureFlagServiceContext-CPsygiHO.js +46 -0
- package/dist/featureFlagServiceContext-ahy3jou0.d.ts +24 -0
- package/dist/featureFlagServiceContext-pPneufeB.cjs +66 -0
- package/dist/{globalSearch-Ccxq8hNF.js → globalSearch-B_v9qfCT.js} +1 -1
- package/dist/{globalSearch-FBk2epe8.cjs → globalSearch-OiF96VLG.cjs} +1 -1
- package/dist/graphql-CvAHWmel.js +46 -0
- package/dist/graphql-JaGqsToc.cjs +70 -0
- package/dist/graphqlContext-BuXJ5DiW.js +96 -0
- package/dist/graphqlContext-CU7NIJo7.cjs +111 -0
- package/dist/hooks/AmplitudeOperations/index.cjs +21 -22
- package/dist/hooks/AmplitudeOperations/index.d.cts +2 -2
- package/dist/hooks/AmplitudeOperations/index.d.ts +2 -2
- package/dist/hooks/AmplitudeOperations/index.js +20 -21
- package/dist/hooks/AppDetails/index.cjs +22 -22
- package/dist/hooks/AppDetails/index.d.cts +3 -23
- package/dist/hooks/AppDetails/index.d.ts +3 -23
- package/dist/hooks/AppDetails/index.js +22 -22
- package/dist/hooks/CdnOperations/index.cjs +4 -4
- package/dist/hooks/CdnOperations/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.js +4 -4
- package/dist/hooks/ChatToggle/index.cjs +24 -24
- package/dist/hooks/ChatToggle/index.d.cts +2 -2
- package/dist/hooks/ChatToggle/index.d.ts +2 -2
- package/dist/hooks/ChatToggle/index.js +22 -22
- package/dist/hooks/ChatToggleAnalytics/index.cjs +23 -24
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.js +22 -23
- package/dist/hooks/CustomerSupportHandoff/index.cjs +2 -2
- package/dist/hooks/CustomerSupportHandoff/index.js +2 -2
- package/dist/hooks/Debounce/index.cjs +20 -2
- package/dist/hooks/Debounce/index.js +18 -2
- package/dist/hooks/ElementObserver/index.cjs +4 -6
- package/dist/hooks/ElementObserver/index.d.cts +4 -25
- package/dist/hooks/ElementObserver/index.d.ts +4 -25
- package/dist/hooks/ElementObserver/index.js +4 -6
- package/dist/hooks/GrabAndScroll/index.cjs +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.js +1 -1
- package/dist/hooks/GraphQLConfig/index.cjs +9 -14
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -13
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -13
- package/dist/hooks/GraphQLConfig/index.js +9 -14
- package/dist/hooks/IdentifyUser/index.cjs +19 -19
- package/dist/hooks/IdentifyUser/index.js +19 -19
- package/dist/hooks/ImageResolver/index.cjs +20 -29
- package/dist/hooks/ImageResolver/index.js +20 -29
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/LocalStorageOperations/index.cjs +8 -7
- package/dist/hooks/LocalStorageOperations/index.js +4 -3
- package/dist/hooks/MessageFilter/index.cjs +3 -12
- package/dist/hooks/MessageFilter/index.d.cts +2 -17
- package/dist/hooks/MessageFilter/index.d.ts +2 -17
- package/dist/hooks/MessageFilter/index.js +2 -11
- package/dist/hooks/NewOrgConfig/index.cjs +14 -18
- package/dist/hooks/NewOrgConfig/index.d.cts +3 -16
- package/dist/hooks/NewOrgConfig/index.d.ts +3 -16
- package/dist/hooks/NewOrgConfig/index.js +14 -18
- package/dist/hooks/Search/index.cjs +332 -167
- package/dist/hooks/Search/index.d.cts +3 -57
- package/dist/hooks/Search/index.d.ts +3 -57
- package/dist/hooks/Search/index.js +320 -156
- package/dist/hooks/SearchOperations/index.cjs +25 -25
- package/dist/hooks/SearchOperations/index.d.cts +2 -3
- package/dist/hooks/SearchOperations/index.d.ts +2 -3
- package/dist/hooks/SearchOperations/index.js +25 -25
- package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
- package/dist/hooks/SessionStorageOperations/index.js +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.cjs +3 -3
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -4
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -4
- package/dist/hooks/ShopifyUrlOperations/index.js +3 -3
- package/dist/hooks/SnapCalculator/index.cjs +1 -1
- package/dist/hooks/SnapCalculator/index.d.cts +4 -3
- package/dist/hooks/SnapCalculator/index.d.ts +4 -3
- package/dist/hooks/SnapCalculator/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +17 -6
- package/dist/hooks/SystemSettingsContext/index.d.cts +5 -15
- package/dist/hooks/SystemSettingsContext/index.d.ts +5 -15
- package/dist/hooks/SystemSettingsContext/index.js +15 -6
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +21 -21
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +2 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +2 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.js +21 -21
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +21 -21
- package/dist/hooks/UpdateAnalyticsProps/index.js +20 -20
- package/dist/hooks/utils.d.cts +20 -13
- package/dist/hooks/utils.d.ts +20 -13
- package/dist/{index-LTdMHOxj.d.ts → index-B4cSHxVN.d.ts} +1 -1
- package/dist/{index-DzbkQtaK.d.cts → index-BQpWG3Jm.d.cts} +1 -1
- package/dist/index-BVZbvpx_.d.cts +11 -0
- package/dist/index-CEmUfoZa.d.ts +42 -0
- package/dist/index-CMZcE7pk.d.cts +224 -0
- package/dist/{index-DBqgBV9N.d.ts → index-CYGpI6hE.d.ts} +1 -1
- package/dist/{index-9NE86em3.d.cts → index-ClVBVK15.d.cts} +1 -1
- package/dist/{index-nDWHlouq.d.ts → index-Clf4wYaJ.d.ts} +1 -1
- package/dist/index-DeQte6mb.d.ts +11 -0
- package/dist/index-Dzv6WwSZ.d.ts +224 -0
- package/dist/{index-FQjyuD3D.d.cts → index-ca7Qn8o0.d.cts} +1 -1
- package/dist/{index-DHgVW8ey.d.ts → index-dngXrfnT.d.ts} +1 -1
- package/dist/index-qOBU4GEh.d.cts +42 -0
- package/dist/{index-Da1s8h5C.d.cts → index-w64il54a.d.cts} +1 -1
- package/dist/interceptors/index.cjs +28 -3
- package/dist/interceptors/index.d.cts +4 -15
- package/dist/interceptors/index.d.ts +4 -15
- package/dist/interceptors/index.js +25 -3
- package/dist/localStorageContext-Bb2b_3ue.cjs +104 -0
- package/dist/localStorageContext-D2uXKahw.js +90 -0
- package/dist/{logger-W3lqg-4b.js → logger-BMVdhQOV.js} +1 -1
- package/dist/{logger-TBIl4uIH.cjs → logger-BqHq67zN.cjs} +1 -1
- package/dist/models-DmsMlaHT.js +1118 -0
- package/dist/models-wh2gh_Qz.cjs +1305 -0
- package/dist/newOrgConfigAtom-Dsk0fJNR.js +8 -0
- package/dist/{newOrgConfigAtom-A4BEeHMf.cjs → newOrgConfigAtom-hs5A1pbZ.cjs} +1 -1
- package/dist/newOrgConfigContext-DPUxIF2G.js +53 -0
- package/dist/newOrgConfigContext-lw85mMS-.cjs +68 -0
- package/dist/nodeSelector-CbWcUbuc.d.ts +28 -0
- package/dist/nodeSelector-Cj-Xl1LP.d.cts +28 -0
- package/dist/org-C2kLSSe9.cjs +111 -0
- package/dist/org-CIczyLRP.js +32 -0
- package/dist/search-BzXoTgRx.js +233 -0
- package/dist/search-D1cU29CV.cjs +312 -0
- package/dist/searchContext-C8DpjnqD.js +129 -0
- package/dist/searchContext-R_XuFzYe.cjs +145 -0
- package/dist/searchServiceAdapter-CKc7UXKi.js +16 -0
- package/dist/searchServiceAdapter-pROGm3Rf.cjs +34 -0
- package/dist/sessionStorageContext-ByaTsDUC.cjs +66 -0
- package/dist/sessionStorageContext-DKE97oMv.js +52 -0
- package/dist/shopifyUrlContext-G9eqIcsL.cjs +75 -0
- package/dist/shopifyUrlContext-WAm0pnPh.js +61 -0
- package/dist/systemSettingsContext-B-FZ8UAg.js +39 -0
- package/dist/systemSettingsContext-J1sny8W8.cjs +60 -0
- package/dist/types/index.cjs +3 -33
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.js +2 -30
- package/dist/types-1iJ_FnQQ.cjs +39 -0
- package/dist/types-D5du68Vp.js +27 -0
- package/dist/urlsParser-C-Vzs--G.cjs +78 -0
- package/dist/urlsParser-G7Ocwg0M.js +42 -0
- package/dist/useAppDetails-BtK9ZZJs.js +30 -0
- package/dist/useAppDetails-Bw2jJ39H.cjs +38 -0
- package/dist/useGraphQLConfig-Dc8h2yyN.cjs +76 -0
- package/dist/useGraphQLConfig-DuLB3tdv.js +63 -0
- package/dist/{useIntersection-BJRFGG0f.js → useIntersection-BWiHkpKL.js} +1 -1
- package/dist/{useIntersection-CYRvxtRN.cjs → useIntersection-DZHz44BY.cjs} +1 -1
- package/dist/{utils-DIvMgPe8.js → utils-B1LVzQYK.js} +1 -1
- package/dist/{utils-Buo4KU5l.cjs → utils-BivlGkeU.cjs} +1 -1
- package/dist/{utils-BRNaQkCK.js → utils-CExht7Uj.js} +1 -1
- package/dist/{utils-CDw74BCO.cjs → utils-CiJLDPjY.cjs} +1 -1
- package/dist/utils-D_kATUj6.js +1 -1
- package/dist/utils-DqNhRm2b.cjs +1546 -0
- package/dist/utils-IogJwDB9.js +1364 -0
- package/dist/utils-hYTjy7hJ.cjs +1 -1
- package/dist/{utils-DyTiotQz.d.ts → utils-wWki3L1d.d.ts} +1 -1
- package/package.json +7 -25
- package/src/application/commerce-api.ts +38 -37
- package/src/application/models/graphql/index.ts +1 -0
- package/src/application/models/graphql/queries/getMerchantColorsQuery.ts +1 -23
- package/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.ts +1 -89
- package/src/application/models/guards/api/isApiFormResponse.ts +4 -4
- package/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.ts +2 -2
- package/src/application/models/guards/api/isApiOrderResponseAttributes.ts +2 -20
- package/src/application/models/guards/api/isApiOrgConfigResults.ts +3 -9
- package/src/application/models/guards/api/isApiOrganizationConfig.ts +8 -32
- package/src/application/models/guards/api/isApiPDPEventAttributes.ts +8 -5
- package/src/application/models/guards/api/isApiPLPEventAttributes.ts +14 -10
- package/src/application/models/guards/api/isApiPageResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiProductResponseAttributes.ts +2 -4
- package/src/application/models/guards/api/isApiProductSearchAttributes.ts +9 -6
- package/src/application/models/guards/api/isApiProductSearchFilterAttributes.ts +7 -4
- package/src/application/models/guards/api/isApiQueryTypedEventAttributes.ts +8 -3
- package/src/application/models/guards/api/isApiResponse.ts +22 -15
- package/src/application/models/guards/api/isApiReviewResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiReviewRichInformation.ts +1 -1
- package/src/application/models/guards/api/isApiTextResponseAttributes.ts +1 -1
- package/src/application/models/guards/graphQL/isGraphQLColorsConfig.ts +1 -1
- package/src/application/models/guards/isBaseEcommerceEvent.ts +1 -2
- package/src/application/models/guards/isGA4EcommerceEvent.ts +1 -1
- package/src/application/models/guards/isLegacyUAEcommerceEvent.ts +1 -1
- package/src/application/models/guards/isMobilePLPChatPlacementParameter.ts +1 -3
- package/src/application/models/guards/isSpanxTakeAQuizCtaParameter.ts +5 -3
- package/src/application/models/guards/isVariantInfo.ts +6 -1
- package/src/application/models/index.ts +30 -95
- package/src/application/models/utils/snakeToCamelTransformer.ts +8 -8
- package/src/application/models/validators/validateGraphQLColorsConfig.ts +6 -2
- package/src/application/models/validators/validateGraphQLFrontendConfig.ts +6 -6
- package/src/application/models/validators/validateMobilePLPChatPlacementParameter.ts +5 -3
- package/src/application/models/validators/validateOrgConfigResults.ts +6 -5
- package/src/application/models/validators/validateOrganizationConfig.ts +11 -8
- package/src/application/models/validators/validateResponse.ts +66 -44
- package/src/application/models/validators/validateSuggestion.ts +1 -1
- package/src/application/models/validators/validateUserEvent.ts +23 -12
- package/src/application/utils/analyticsUtils.ts +16 -38
- package/src/application/utils/coreContextToApiContext.ts +3 -1
- package/src/application/utils/coreUserEventToApiUserEvent.ts +2 -2
- package/src/application/utils/elementObserver.ts +1 -1
- package/src/application/utils/imageFilter.ts +5 -2
- package/src/application/utils/index.ts +20 -21
- package/src/application/utils/messageFromFormSubmittedEvent.ts +1 -1
- package/src/application/utils/messageFromQueryEvent.ts +1 -1
- package/src/application/utils/messageFromResponse.ts +14 -10
- package/src/application/utils/messageFromSuggestionEvent.ts +6 -4
- package/src/application/utils/mouseEventTypes.ts +1 -1
- package/src/application/utils/nextMessageRequestToApiRequest.ts +1 -1
- package/src/application/utils/overrides.ts +1 -49
- package/src/application/utils/supportedEventRequestToApiRequest.ts +3 -1
- package/src/application/utils/urlsParser.ts +1 -7
- package/src/atoms/app/index.ts +15 -25
- package/src/atoms/app/variant.ts +1 -1
- package/src/atoms/chat/chatState.ts +9 -14
- package/src/atoms/chat/form.ts +1 -1
- package/src/atoms/chat/messageQueue.ts +25 -50
- package/src/atoms/chat/replies.ts +40 -43
- package/src/atoms/chat/suggestions.ts +34 -29
- package/src/atoms/envive/enviveConfig.ts +14 -20
- package/src/atoms/org/customerService.ts +4 -8
- package/src/atoms/org/graphqlConfig.ts +7 -15
- package/src/atoms/org/index.ts +4 -6
- package/src/atoms/org/newOrgConfigAtom.ts +2 -2
- package/src/atoms/org/orgAnalyticsConfig.ts +1 -1
- package/src/atoms/search/index.ts +0 -1
- package/src/atoms/search/productFilters.ts +72 -52
- package/src/atoms/search/productRetrievalAPI.ts +72 -0
- package/src/atoms/search/productRetrievalAdapter.ts +28 -0
- package/src/atoms/search/productSorter.ts +2 -2
- package/src/atoms/search/searchAPI.ts +42 -60
- package/src/atoms/search/searchServiceAdapter.ts +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +104 -143
- package/src/contexts/cdnContext/cdnContext.tsx +9 -16
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +6 -27
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +5 -12
- package/src/contexts/featureFlagContext/featureFlagContext.tsx +27 -48
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +11 -3
- package/src/contexts/graphqlContext/graphqlContext.tsx +40 -95
- package/src/contexts/localStorageContext/localStorageContext.tsx +26 -60
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +10 -22
- package/src/contexts/searchContext/searchContext.tsx +29 -49
- package/src/contexts/sessionStorageContext/sessionStorageContext.tsx +12 -33
- package/src/contexts/shopifyUrlContext/shopifyUrlContext.tsx +20 -37
- package/src/contexts/systemSettingsContext/systemSettingsContext.tsx +8 -21
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +33 -77
- package/src/events/index.ts +8 -5
- package/src/events/registerAnalyticsListeners.ts +10 -13
- package/src/exceptions/index.ts +2 -0
- package/src/{types/exceptions → exceptions}/unsupportedProductExceptions.ts +2 -2
- package/src/global.d.ts +8 -0
- package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +6 -11
- package/src/hooks/AppDetails/useAppDetails.ts +10 -24
- package/src/hooks/ChatToggle/useChatToggle.ts +7 -19
- package/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.ts +4 -4
- package/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.ts +1 -1
- package/src/hooks/ElementObserver/useElementObserver.ts +14 -32
- package/src/hooks/GrabAndScroll/useGrabAndScroll.ts +125 -124
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +5 -7
- package/src/hooks/ImageResolver/useImageResolver.ts +24 -31
- package/src/hooks/LocalStorageOperations/useLocalStorageOperations.ts +12 -19
- package/src/hooks/MessageFilter/useMessageFilter.ts +1 -7
- package/src/hooks/Search/useRecommendedProducts.ts +50 -0
- package/src/hooks/Search/useSearch.tsx +80 -210
- package/src/hooks/Search/useSearchInput.ts +227 -0
- package/src/hooks/SearchOperations/useSearchOperations.ts +8 -12
- package/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.ts +8 -14
- package/src/hooks/SnapCalculator/useSnapCalculator.ts +1 -2
- package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +8 -11
- package/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.ts +11 -25
- package/src/hooks/utils.ts +19 -29
- package/src/interceptors/index.ts +1 -2
- package/src/interceptors/useMessageInterceptor.ts +10 -6
- package/src/{application/models/api/response.ts → types/ApiResponse.ts} +35 -29
- package/src/types/FilterAttribute.ts +35 -0
- package/src/{application/models/message.ts → types/Message.ts} +38 -34
- package/src/types/Suggestion.ts +6 -0
- package/src/types/index.ts +4 -4
- package/src/util/colorVar.ts +4 -0
- package/src/util/configVersion.ts +4 -0
- package/src/util/domInsertion.ts +17 -0
- package/dist/SystemSettingsContext-CO5c1L62.cjs +0 -20
- package/dist/SystemSettingsContext-CXmUlH8i.js +0 -13
- package/dist/TrackComponentVisibleEvent-B0WO3ArV.js +0 -52
- package/dist/TrackComponentVisibleEvent-LRE9MYzL.cjs +0 -59
- package/dist/amplitudeContext-B73xamNe.d.cts +0 -52
- package/dist/amplitudeContext-DXnJi0V1.d.ts +0 -52
- package/dist/api-BWSsazAG.js +0 -166
- package/dist/api-DeW6rHj3.cjs +0 -239
- package/dist/application/models/utilityTypes/index.cjs +0 -1
- package/dist/application/models/utilityTypes/index.d.cts +0 -2
- package/dist/application/models/utilityTypes/index.d.ts +0 -2
- package/dist/application/models/utilityTypes/index.js +0 -3
- package/dist/application/models/variantInfo/index.cjs +0 -3
- package/dist/application/models/variantInfo/index.d.cts +0 -2
- package/dist/application/models/variantInfo/index.d.ts +0 -2
- package/dist/application/models/variantInfo/index.js +0 -3
- package/dist/atoms/search/types.cjs +0 -5
- package/dist/atoms/search/types.d.cts +0 -2
- package/dist/atoms/search/types.d.ts +0 -2
- package/dist/atoms/search/types.js +0 -3
- package/dist/cdnContext-CH_-ssYa.js +0 -38
- package/dist/cdnContext-D7kHxOzE.cjs +0 -53
- package/dist/chat-CqPuT9_V.cjs +0 -393
- package/dist/chat-DH70QqJp.js +0 -257
- package/dist/chatElementDisplayLocation-BoE6DEdv.d.ts +0 -25
- package/dist/chatElementDisplayLocation-DWmfNX_u.d.cts +0 -25
- package/dist/chatSearch-BQCZI8MJ.cjs +0 -418
- package/dist/chatSearch-D8xCWU8m.js +0 -295
- package/dist/chatState-CcFtSqJT.cjs +0 -120
- package/dist/chatState-DKnNHmwe.js +0 -34
- package/dist/contexts/chatContext/index.cjs +0 -326
- package/dist/contexts/chatContext/index.d.cts +0 -15
- package/dist/contexts/chatContext/index.d.ts +0 -15
- package/dist/contexts/chatContext/index.js +0 -319
- package/dist/contexts/types.cjs +0 -7
- package/dist/contexts/types.d.cts +0 -4
- package/dist/contexts/types.d.ts +0 -4
- package/dist/contexts/types.js +0 -3
- package/dist/domObserver-Bqf3ooj8.cjs +0 -304
- package/dist/enviveConfig-DZBohDpc.js +0 -62
- package/dist/enviveConfig-Dv9-esGV.cjs +0 -130
- package/dist/enviveConfigContext-D2OELZDR.cjs +0 -60
- package/dist/enviveConfigContext-DrDjCems.js +0 -45
- package/dist/events-DYY4l817.cjs +0 -90
- package/dist/events-DyUix-Bn.js +0 -78
- package/dist/featureFlagServiceContext-CJyYItqu.cjs +0 -62
- package/dist/featureFlagServiceContext-C_2m4wPL.d.ts +0 -23
- package/dist/featureFlagServiceContext-CiKWV306.d.cts +0 -23
- package/dist/featureFlagServiceContext-FBM6DdMJ.js +0 -42
- package/dist/featureGates-KEwAL8p_.js +0 -26
- package/dist/featureGates-qU_ulhpC.cjs +0 -32
- package/dist/frontendConfig-CymUbclV.d.ts +0 -856
- package/dist/frontendConfig-tVg0hsWZ.d.cts +0 -856
- package/dist/graphql-3PxNRFOc.js +0 -36
- package/dist/graphql-DGYfelZp.cjs +0 -53
- package/dist/graphqlConfig-GHZ1UgCw.cjs +0 -73
- package/dist/graphqlConfig-mDg6J44N.js +0 -24
- package/dist/graphqlContext-BZPEAFSR.cjs +0 -111
- package/dist/graphqlContext-Bf3E-V2T.d.cts +0 -28
- package/dist/graphqlContext-CQikpV_I.d.ts +0 -28
- package/dist/graphqlContext-eaZPxgRE.js +0 -96
- package/dist/index-BVf069X-.d.ts +0 -184
- package/dist/index-B_KJB5L_.d.cts +0 -186
- package/dist/index-BkLv_fCu.d.ts +0 -186
- package/dist/index-Bmub8e38.d.cts +0 -98
- package/dist/index-C0eAp5f5.d.ts +0 -98
- package/dist/index-CESxqFso.d.cts +0 -228
- package/dist/index-CG3P8xE1.d.cts +0 -676
- package/dist/index-CJc7_j_v.d.ts +0 -44
- package/dist/index-CiWEYzXl.d.cts +0 -184
- package/dist/index-Cyq5HiC0.d.cts +0 -44
- package/dist/index-DL2ODEnw.d.ts +0 -1
- package/dist/index-DgjDuQl4.d.ts +0 -676
- package/dist/index-RcVcRKH7.d.cts +0 -1
- package/dist/index-vP8BKdxl.d.ts +0 -228
- package/dist/interceptors/types.cjs +0 -1
- package/dist/interceptors/types.d.cts +0 -13
- package/dist/interceptors/types.d.ts +0 -13
- package/dist/interceptors/types.js +0 -3
- package/dist/localStorageContext-BPZ82q-G.js +0 -95
- package/dist/localStorageContext-NRP-CdmF.cjs +0 -115
- package/dist/models-D-4db7XW.cjs +0 -1537
- package/dist/models-c86hYW-F.js +0 -1296
- package/dist/newOrgConfigAtom-OzAyrPS8.js +0 -8
- package/dist/newOrgConfigContext-DOdUxlOE.d.cts +0 -16
- package/dist/newOrgConfigContext-DX9iqIIK.cjs +0 -68
- package/dist/newOrgConfigContext-aqN8Tu79.js +0 -53
- package/dist/newOrgConfigContext-jphS5d4K.d.ts +0 -16
- package/dist/nodeSelector-B3bPtEjX.d.cts +0 -31
- package/dist/nodeSelector-Dcn3_NrZ.d.ts +0 -31
- package/dist/org-Bq2KsJSp.cjs +0 -43
- package/dist/org-gtWmGw4K.js +0 -12
- package/dist/search-BQPMtze5.cjs +0 -205
- package/dist/search-CIrqYYMI.d.ts +0 -20
- package/dist/search-PXzaYtZj.js +0 -126
- package/dist/search-filter-types-BhK20ts3.d.ts +0 -102
- package/dist/search-filter-types-BxaNSLs_.d.cts +0 -102
- package/dist/search-y-ioX5Mz.d.cts +0 -20
- package/dist/searchContext-CmsLR6Ka.cjs +0 -145
- package/dist/searchContext-NPfqMf6b.js +0 -129
- package/dist/searchServiceAdapter-BczodJGV.cjs +0 -34
- package/dist/searchServiceAdapter-BuEHFG5t.js +0 -16
- package/dist/sessionStorageContext-C1u04nAK.js +0 -52
- package/dist/sessionStorageContext-Cy8xc9-3.cjs +0 -66
- package/dist/shopifyUrlContext-CUyq3f27.cjs +0 -75
- package/dist/shopifyUrlContext-DTLlqlMj.js +0 -61
- package/dist/spiffyWidgets-BnkP5kXf.d.ts +0 -20
- package/dist/spiffyWidgets-BuS00VaQ.d.cts +0 -20
- package/dist/systemSettingsContext-Ba-wi2NZ.cjs +0 -60
- package/dist/systemSettingsContext-DumUaV0m.js +0 -39
- package/dist/test-types-DbrKQIqB.d.ts +0 -40
- package/dist/test-types-ThQiO_cc.d.cts +0 -40
- package/dist/types-BWzwd0Qc.js +0 -30
- package/dist/types-CEx2uKKS.d.ts +0 -51
- package/dist/types-CKMMb_gX.d.cts +0 -51
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CtUb63bt.js +0 -76
- package/dist/types-Cz8CaPUQ.cjs +0 -48
- package/dist/types-Dc6hx6ei.js +0 -1
- package/dist/types-Mwm0bS2l.d.ts +0 -10
- package/dist/types-UUvB6h05.cjs +0 -106
- package/dist/types-zQGBI-Yo.d.cts +0 -10
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +0 -15
- package/dist/types.d.ts +0 -15
- package/dist/types.js +0 -1
- package/dist/urlsParser-COzMdJaX.cjs +0 -78
- package/dist/urlsParser-DxjoLj98.js +0 -42
- package/dist/useAmplitudeOperations-Cv0fi3uj.cjs +0 -41
- package/dist/useAmplitudeOperations-Ti6phPPq.js +0 -34
- package/dist/useAppDetails-BgqbPlfR.cjs +0 -38
- package/dist/useAppDetails-DnKGYtCd.js +0 -30
- package/dist/useDebounce-BV7B-Jz3.js +0 -19
- package/dist/useDebounce-vU5iW5sa.cjs +0 -26
- package/dist/useGraphQLConfig-BizpCw23.cjs +0 -76
- package/dist/useGraphQLConfig-DFWl9Z89.js +0 -63
- package/dist/useMessageInterceptor-BjGP_uXm.js +0 -25
- package/dist/useMessageInterceptor-arAqUq1Q.cjs +0 -33
- package/dist/userIdentityContext-BvsEnQVX.d.ts +0 -20
- package/dist/userIdentityContext-D2oFVFzo.d.cts +0 -20
- package/dist/utilityTypes-B2KuRn37.js +0 -1
- package/dist/utilityTypes-BGbL2WTP.cjs +0 -0
- package/dist/utils-B7PAzB_M.d.cts +0 -22
- package/dist/utils-CLGXsOwE.cjs +0 -1591
- package/dist/utils-CrQ0h9tc.d.ts +0 -22
- package/dist/utils-jYtD3hmA.js +0 -1385
- package/dist/variantInfo-BfKlkaWU.js +0 -11
- package/dist/variantInfo-DpLn4nHz.cjs +0 -17
- package/src/application/models/api/context.ts +0 -4
- package/src/application/models/api/generationParams.ts +0 -4
- package/src/application/models/api/nextMessageRequest.ts +0 -11
- package/src/application/models/api/orgAnalyticsConfig.ts +0 -19
- package/src/application/models/api/orgConfigResults.ts +0 -44
- package/src/application/models/api/organizationConfig.ts +0 -12
- package/src/application/models/api/responseGenerics.ts +0 -67
- package/src/application/models/api/search.ts +0 -26
- package/src/application/models/api/suggestion.ts +0 -4
- package/src/application/models/api/supportedEventRequest.ts +0 -8
- package/src/application/models/api/userEvent.ts +0 -101
- package/src/application/models/cachedValue.ts +0 -8
- package/src/application/models/chatElementDisplayLocation.ts +0 -22
- package/src/application/models/clientDetails.ts +0 -18
- package/src/application/models/colorsConfig.ts +0 -28
- package/src/application/models/conversationalSearchIds.ts +0 -5
- package/src/application/models/dataLayer.ts +0 -45
- package/src/application/models/events.ts +0 -5
- package/src/application/models/featureGates.ts +0 -21
- package/src/application/models/frontendConfig.ts +0 -14
- package/src/application/models/googleAnalyticsEvents.ts +0 -8
- package/src/application/models/localStorageEventListener.ts +0 -4
- package/src/application/models/mobilePLPChatPlacementParameter.ts +0 -3
- package/src/application/models/orgsEnum.ts +0 -36
- package/src/application/models/productExperiment.ts +0 -5
- package/src/application/models/spanxTakeAQuizCtaParameter.ts +0 -4
- package/src/application/models/spiffyWidgets.ts +0 -16
- package/src/application/models/utilityTypes/camelCase.ts +0 -87
- package/src/application/models/utilityTypes/camelCasedPropertiesDeep.ts +0 -80
- package/src/application/models/utilityTypes/delimiterCase.ts +0 -121
- package/src/application/models/utilityTypes/delimiterCasedPropertiesDeep.ts +0 -98
- package/src/application/models/utilityTypes/index.ts +0 -1
- package/src/application/models/utilityTypes/internal.ts +0 -93
- package/src/application/models/utilityTypes/primitive.ts +0 -8
- package/src/application/models/utilityTypes/snakeCasedPropertiesDeep.ts +0 -49
- package/src/application/models/utilityTypes/splitWords.ts +0 -76
- package/src/application/models/utilityTypes/trim.ts +0 -28
- package/src/application/models/utilityTypes/unknownArray.ts +0 -25
- package/src/application/models/variantInfo/index.ts +0 -1
- package/src/application/models/variantInfo/pageVisitInfo.ts +0 -6
- package/src/application/models/variantInfo/plpInfo.ts +0 -3
- package/src/application/models/variantInfo/productInfo.ts +0 -5
- package/src/application/models/variantInfo/variantInfo.ts +0 -29
- package/src/application/utils/__tests__/divideArrays.test.ts +0 -14
- package/src/application/utils/cdnUtils.ts +0 -11
- package/src/atoms/search/chatSearch.ts +0 -317
- package/src/atoms/search/types.ts +0 -55
- package/src/config/divIds.ts +0 -27
- package/src/config/socialProofClasses.ts +0 -17
- package/src/contexts/chatContext/chatContext.tsx +0 -509
- package/src/contexts/chatContext/index.ts +0 -1
- package/src/contexts/types.ts +0 -1066
- package/src/events/event-types.ts +0 -11
- package/src/interceptors/types.ts +0 -6
- package/src/merchants/domInsertion.ts +0 -30
- package/src/merchants/gridInsertion.ts +0 -19
- package/src/types/config-versions.ts +0 -6
- package/src/types/customerService.ts +0 -31
- package/src/types/custservice-types.ts +0 -28
- package/src/types/search-filter-types.ts +0 -111
- package/src/types/suggestionBarV2-types.ts +0 -4
- package/src/types/test-types.ts +0 -3
- package/src/types.ts +0 -11
- /package/dist/{AmplitudeOperations-CWI4yjZ4.js → featureFlagServiceContext-CbUOAw5l.js} +0 -0
- /package/dist/{AmplitudeOperations-BEGeYKG5.cjs → featureFlagServiceContext-DSo2brno.cjs} +0 -0
- /package/src/{types/exceptions → exceptions}/sessionExceptions.ts +0 -0
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import { OrgShortName } from
|
|
3
|
-
import {
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { OrgShortName } from '@envive-ai/types';
|
|
3
|
+
import { useAtomValue } from 'jotai';
|
|
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
|
}
|
|
7
9
|
|
|
8
|
-
class MerchantImageResolver {
|
|
9
|
-
private static imageResolverMap = new Map<string, ImageResolver>();
|
|
10
|
-
|
|
11
|
-
private static loadMapping() {
|
|
12
|
-
if (this.imageResolverMap.size === 0) {
|
|
13
|
-
this.imageResolverMap.set(OrgShortName.Spanx, new ShopifyImageResolver());
|
|
14
|
-
this.imageResolverMap.set(
|
|
15
|
-
OrgShortName.SpanxStaging,
|
|
16
|
-
new ShopifyImageResolver()
|
|
17
|
-
);
|
|
18
|
-
this.imageResolverMap.set(
|
|
19
|
-
OrgShortName.UniqueVintage,
|
|
20
|
-
new ShopifyImageResolver()
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return this.imageResolverMap;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static get(name: string) {
|
|
27
|
-
return this.loadMapping().get(name);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
10
|
class ShopifyImageResolver extends ImageResolver {
|
|
32
11
|
resolve(url: string, size: number): string {
|
|
33
12
|
const pattern = /_\d+x\.jpg/;
|
|
@@ -36,7 +15,7 @@ class ShopifyImageResolver extends ImageResolver {
|
|
|
36
15
|
if (urlHasPrefix) {
|
|
37
16
|
return url.replace(pattern, newSizePrefix);
|
|
38
17
|
}
|
|
39
|
-
return url.replace(
|
|
18
|
+
return url.replace('.jpg', newSizePrefix);
|
|
40
19
|
}
|
|
41
20
|
}
|
|
42
21
|
|
|
@@ -44,10 +23,7 @@ export const useImageResolver = () => {
|
|
|
44
23
|
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
45
24
|
const resolve = (image?: string, size?: number) => {
|
|
46
25
|
if (image && size && orgShortName) {
|
|
47
|
-
const newImagePath = MerchantImageResolver.get(orgShortName)?.resolve(
|
|
48
|
-
image,
|
|
49
|
-
size
|
|
50
|
-
);
|
|
26
|
+
const newImagePath = MerchantImageResolver.get(orgShortName)?.resolve(image, size);
|
|
51
27
|
return newImagePath || image;
|
|
52
28
|
}
|
|
53
29
|
return image;
|
|
@@ -57,3 +33,20 @@ export const useImageResolver = () => {
|
|
|
57
33
|
resolve,
|
|
58
34
|
};
|
|
59
35
|
};
|
|
36
|
+
|
|
37
|
+
class MerchantImageResolver {
|
|
38
|
+
private static imageResolverMap = new Map<string, ImageResolver>();
|
|
39
|
+
|
|
40
|
+
private static loadMapping() {
|
|
41
|
+
if (this.imageResolverMap.size === 0) {
|
|
42
|
+
this.imageResolverMap.set(OrgShortName.Spanx, new ShopifyImageResolver());
|
|
43
|
+
this.imageResolverMap.set(OrgShortName.SpanxStaging, new ShopifyImageResolver());
|
|
44
|
+
this.imageResolverMap.set(OrgShortName.UniqueVintage, new ShopifyImageResolver());
|
|
45
|
+
}
|
|
46
|
+
return this.imageResolverMap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get(name: string) {
|
|
50
|
+
return this.loadMapping().get(name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
useLocalStorage,
|
|
5
|
-
LocalStorageKeys,
|
|
6
|
-
} from "src/contexts/localStorageContext";
|
|
1
|
+
import { LocalStorageEventListener, LocalStorageKeys } from '@envive-ai/types';
|
|
2
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import { useLocalStorage } from 'src/contexts/localStorageContext';
|
|
7
4
|
|
|
8
5
|
// Reactive localStorage value hook
|
|
9
6
|
export const useLocalStorageValue = (key: string) => {
|
|
10
|
-
const { getItem, setItem, attachListener, detachListener } =
|
|
11
|
-
useLocalStorage();
|
|
7
|
+
const { getItem, setItem, attachListener, detachListener } = useLocalStorage();
|
|
12
8
|
const [value, setValue] = useState<string | null>(() => getItem(key));
|
|
13
9
|
|
|
14
10
|
useEffect(() => {
|
|
@@ -28,7 +24,7 @@ export const useLocalStorageValue = (key: string) => {
|
|
|
28
24
|
setItem(key, newValue);
|
|
29
25
|
setValue(newValue);
|
|
30
26
|
},
|
|
31
|
-
[key, setItem]
|
|
27
|
+
[key, setItem],
|
|
32
28
|
);
|
|
33
29
|
|
|
34
30
|
return { value, setValue: updateValue };
|
|
@@ -43,11 +39,11 @@ export const useSpiffyFeatureFlag = () => {
|
|
|
43
39
|
(flag: boolean | null) => {
|
|
44
40
|
setSpiffyOnFeatureFlag(flag);
|
|
45
41
|
},
|
|
46
|
-
[setSpiffyOnFeatureFlag]
|
|
42
|
+
[setSpiffyOnFeatureFlag],
|
|
47
43
|
);
|
|
48
44
|
|
|
49
45
|
return {
|
|
50
|
-
value: value ===
|
|
46
|
+
value: value === 'true' ? true : value === 'false' ? false : null,
|
|
51
47
|
setFlag,
|
|
52
48
|
};
|
|
53
49
|
};
|
|
@@ -60,25 +56,22 @@ export const useEnviveFeatureFlag = () => {
|
|
|
60
56
|
const setFlag = useCallback(
|
|
61
57
|
(flag: boolean | null) => {
|
|
62
58
|
if (flag === true) {
|
|
63
|
-
setItem(LocalStorageKeys.EnviveOnOverride,
|
|
59
|
+
setItem(LocalStorageKeys.EnviveOnOverride, 'true');
|
|
64
60
|
} else if (flag === false) {
|
|
65
|
-
setItem(LocalStorageKeys.EnviveOnOverride,
|
|
61
|
+
setItem(LocalStorageKeys.EnviveOnOverride, 'false');
|
|
66
62
|
}
|
|
67
63
|
},
|
|
68
|
-
[setItem]
|
|
64
|
+
[setItem],
|
|
69
65
|
);
|
|
70
66
|
|
|
71
67
|
return {
|
|
72
|
-
value: value ===
|
|
68
|
+
value: value === 'true' ? true : value === 'false' ? false : null,
|
|
73
69
|
setFlag,
|
|
74
70
|
};
|
|
75
71
|
};
|
|
76
72
|
|
|
77
73
|
// Storage listener hook
|
|
78
|
-
export const useLocalStorageListener = (
|
|
79
|
-
key: string,
|
|
80
|
-
callback: (event: StorageEvent) => void
|
|
81
|
-
) => {
|
|
74
|
+
export const useLocalStorageListener = (key: string, callback: (event: StorageEvent) => void) => {
|
|
82
75
|
const { attachListener, detachListener } = useLocalStorage();
|
|
83
76
|
|
|
84
77
|
useEffect(() => {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type MessageFinder = {
|
|
4
|
-
msgs: Message[][];
|
|
5
|
-
type?: MessageType;
|
|
6
|
-
role?: MessageRole;
|
|
7
|
-
};
|
|
1
|
+
import { MessageFinder, Message, MessageType } from '@envive-ai/types';
|
|
8
2
|
|
|
9
3
|
export const useMessageFilter = () => {
|
|
10
4
|
const findMessageIndex = ({ msgs, type, role }: MessageFinder) => {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SearchResponseProductAttributes,
|
|
3
|
+
FeatureGates,
|
|
4
|
+
} from "@envive-ai/types";
|
|
5
|
+
import { useAtomValue, useSetAtom } from "jotai";
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
import { useFeatureFlagService } from "src/contexts/featureFlagServiceContext/featureFlagServiceContext";
|
|
8
|
+
import {
|
|
9
|
+
retrievedProductsAtom,
|
|
10
|
+
performProductRetrievalAtom,
|
|
11
|
+
productRetrievalAtom,
|
|
12
|
+
} from "src/atoms/search/productRetrievalAPI";
|
|
13
|
+
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A hook to get recommended products.
|
|
17
|
+
* It checks the `IsRecommendedProductsEnabled` feature gate and triggers fetching if needed.
|
|
18
|
+
* If the gate is enabled, it returns the list of recommended products.
|
|
19
|
+
* If the gate is disabled, it returns an empty array.
|
|
20
|
+
*
|
|
21
|
+
* @returns The list of recommended products or an empty array.
|
|
22
|
+
*/
|
|
23
|
+
export const useRecommendedProducts =
|
|
24
|
+
(): SearchResponseProductAttributes["attributes"][] => {
|
|
25
|
+
const featureFlagService = useFeatureFlagService();
|
|
26
|
+
const isEnabled = featureFlagService.isFeatureGateEnabled(
|
|
27
|
+
FeatureGates.IsRecommendedProductsEnabled
|
|
28
|
+
);
|
|
29
|
+
const recommendedProducts = useAtomValue(retrievedProductsAtom);
|
|
30
|
+
const performProductRetrieval = useSetAtom(performProductRetrievalAtom);
|
|
31
|
+
const { lastProductIds } = useAtomValue(productRetrievalAtom);
|
|
32
|
+
const orgUIConfig = useNewOrgConfig();
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const recommendedProductIds = orgUIConfig.searchConfig
|
|
36
|
+
? orgUIConfig.searchConfig.recommendedProducts
|
|
37
|
+
: [];
|
|
38
|
+
// Fetch only if the feature is enabled, there are IDs to fetch, and we haven't already fetched them.
|
|
39
|
+
if (
|
|
40
|
+
isEnabled &&
|
|
41
|
+
recommendedProductIds &&
|
|
42
|
+
recommendedProductIds.length > 0 &&
|
|
43
|
+
!lastProductIds
|
|
44
|
+
) {
|
|
45
|
+
performProductRetrieval({ productIds: recommendedProductIds });
|
|
46
|
+
}
|
|
47
|
+
}, [isEnabled, performProductRetrieval, lastProductIds, orgUIConfig]);
|
|
48
|
+
|
|
49
|
+
return isEnabled ? recommendedProducts : [];
|
|
50
|
+
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
SearchResultsHocProps,
|
|
5
|
+
ProductSorting,
|
|
6
|
+
SearchFilterDatum,
|
|
7
|
+
SpiffyMetricsEventName,
|
|
8
|
+
SelectedFilterOption,
|
|
9
|
+
SelectFilterItem,
|
|
10
|
+
SpiffyWidgets,
|
|
11
|
+
} from "@envive-ai/types";
|
|
4
12
|
import {
|
|
5
13
|
addSearchFilterAtom,
|
|
6
14
|
clearSearchFiltersAtom,
|
|
@@ -13,90 +21,26 @@ import {
|
|
|
13
21
|
searchParamsAtom,
|
|
14
22
|
searchProductSortingAtom,
|
|
15
23
|
searchSelectedFiltersAtom,
|
|
16
|
-
|
|
17
|
-
} from "
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from "src/atoms/globalSearch/globalSearch";
|
|
22
|
-
import { formatFilterDisplayName } from "src/atoms/search/utils";
|
|
23
|
-
import { ProductSorting } from "src/atoms/search/types";
|
|
24
|
-
import {
|
|
25
|
-
SpiffyMetricsEventName,
|
|
26
|
-
useAmplitude,
|
|
27
|
-
} from "src/contexts/amplitudeContext/amplitudeContext";
|
|
28
|
-
import { SpiffyWidgets } from "src/application/models/spiffyWidgets";
|
|
29
|
-
import { ProductCardConfig } from "src/contexts/types";
|
|
30
|
-
import Logger from "src/application/logging/logger";
|
|
31
|
-
import { SearchResult } from "src/application/models/api/search";
|
|
32
|
-
import { SearchResponseProduct } from "@spiffy-ai/commerce-api-client";
|
|
33
|
-
import {
|
|
34
|
-
SearchFilterDatum,
|
|
35
|
-
SelectFilterItem,
|
|
36
|
-
} from "src/types/search-filter-types";
|
|
37
|
-
import { getSearchResultsState, SearchResultsState } from "../utils";
|
|
38
|
-
import { orgShortNameAtom } from "src/atoms/envive/enviveConfig";
|
|
24
|
+
} from "../../atoms/search";
|
|
25
|
+
import { isFilterOpenAtom } from "../../atoms/globalSearch/globalSearch";
|
|
26
|
+
import { formatFilterDisplayName } from "../../atoms/search/utils";
|
|
27
|
+
import { useAmplitude } from "../../contexts/amplitudeContext/amplitudeContext";
|
|
28
|
+
import { orgShortNameAtom } from "../../atoms/envive/enviveConfig";
|
|
39
29
|
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
40
30
|
import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
searchData: SearchResult | null;
|
|
45
|
-
searchResponseId: string;
|
|
46
|
-
merchantShortName: string;
|
|
47
|
-
productCardConfig: ProductCardConfig;
|
|
48
|
-
productList: SearchResponseProduct[];
|
|
49
|
-
autocompleteResults: string[];
|
|
50
|
-
searchFilters: SearchFilterDatum[];
|
|
51
|
-
availableDynamicFilters: { name: string; displayName: string }[];
|
|
52
|
-
selectedFilterOptions: SelectedFilterOption[];
|
|
53
|
-
|
|
54
|
-
// State
|
|
55
|
-
searchText: string;
|
|
56
|
-
searchResultsState: SearchResultsState;
|
|
57
|
-
isLoadingAutocomplete: boolean;
|
|
58
|
-
isLoadingSearch: boolean;
|
|
59
|
-
isFilterOpen: boolean;
|
|
60
|
-
isDirty: boolean;
|
|
61
|
-
focusedIndex: number;
|
|
62
|
-
focusedOptionId: string | undefined;
|
|
63
|
-
|
|
64
|
-
// UI
|
|
65
|
-
filterButtonText: string;
|
|
66
|
-
|
|
67
|
-
// Event Handlers
|
|
68
|
-
onSearchInputChange: (value: string) => void;
|
|
69
|
-
onSubmitSearch: () => void;
|
|
70
|
-
onAutocompleteSelect: (suggestion: string) => void;
|
|
71
|
-
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
72
|
-
onToggleDynamicFilter: ({
|
|
73
|
-
filter,
|
|
74
|
-
dynamicFilterDisplayName,
|
|
75
|
-
}: {
|
|
76
|
-
filter: string;
|
|
77
|
-
dynamicFilterDisplayName: string;
|
|
78
|
-
}) => void;
|
|
79
|
-
onSelectFilterItem: SelectFilterItem;
|
|
80
|
-
onRemoveFilter: (filter: SelectedFilterOption) => void;
|
|
81
|
-
onClearAllFilters: () => void;
|
|
82
|
-
setIsFilterOpen: (isFilterOpen: boolean) => void;
|
|
83
|
-
|
|
84
|
-
// Refs
|
|
85
|
-
searchResultsRef: React.RefObject<HTMLDivElement>;
|
|
86
|
-
}
|
|
31
|
+
import { getSearchResultsState } from "../utils";
|
|
32
|
+
import { useRecommendedProducts } from "./useRecommendedProducts";
|
|
33
|
+
import { useSearchInput } from "./useSearchInput";
|
|
87
34
|
|
|
88
35
|
export const useSearch = (): SearchResultsHocProps => {
|
|
89
36
|
// Atoms
|
|
37
|
+
const { trackEvent } = useAmplitude();
|
|
90
38
|
const config = useNewOrgConfig();
|
|
91
39
|
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
92
40
|
const { data: searchData, loading: isLoadingSearch } =
|
|
93
41
|
useAtomValue(searchAtom);
|
|
94
42
|
const productList = useAtomValue(filteredSearchProductsAtom);
|
|
95
43
|
const performSearch = useSetAtom(performSearchAtom);
|
|
96
|
-
const [
|
|
97
|
-
{ results: autocompleteResults, isLoading: isLoadingAutocomplete },
|
|
98
|
-
setAutocompleteState,
|
|
99
|
-
] = useAtom(autocompleteStateAtom);
|
|
100
44
|
const [{ query }] = useAtom(searchParamsAtom);
|
|
101
45
|
const [isFilterOpen, setIsFilterOpen] = useAtom(isFilterOpenAtom);
|
|
102
46
|
const [selectedFilterOptions] = useAtom(searchSelectedFiltersAtom);
|
|
@@ -105,25 +49,49 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
105
49
|
const [productSorting, setProductSorting] = useAtom(searchProductSortingAtom);
|
|
106
50
|
const clearFilters = useSetAtom(clearSearchFiltersAtom);
|
|
107
51
|
const searchFilters = useAtomValue(searchFiltersAtom);
|
|
108
|
-
|
|
109
|
-
// State
|
|
110
|
-
const [isDirty, setIsDirty] = useState(true);
|
|
111
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
112
|
-
const [focusedOptionId, setFocusedOptionId] = useState<string | undefined>(
|
|
113
|
-
undefined
|
|
114
|
-
);
|
|
115
|
-
const [searchText, setSearchText] = useState(query || "");
|
|
52
|
+
const recommendedProducts = useRecommendedProducts();
|
|
116
53
|
|
|
117
54
|
// Refs
|
|
118
55
|
const searchResultsRef = useRef<HTMLDivElement>(null);
|
|
119
56
|
|
|
120
|
-
//
|
|
121
|
-
const
|
|
57
|
+
// Utilities
|
|
58
|
+
const scrollToTop = useCallback(() => {
|
|
59
|
+
const container = searchResultsRef.current;
|
|
60
|
+
if (container) {
|
|
61
|
+
container.scrollTo({ top: 0, behavior: "smooth" });
|
|
62
|
+
} else {
|
|
63
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
// Search Input Hook
|
|
68
|
+
const searchInput = useSearchInput({
|
|
69
|
+
initialSearchText: query || "",
|
|
70
|
+
searchOrigin: SpiffyWidgets.SearchResults,
|
|
71
|
+
onSearchSubmit: (searchQuery) => {
|
|
72
|
+
performSearch({ query: searchQuery });
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
searchText,
|
|
78
|
+
focusedIndex,
|
|
79
|
+
focusedOptionId,
|
|
80
|
+
autocompleteResults,
|
|
81
|
+
shouldShowAutocomplete,
|
|
82
|
+
handleSearchInputChange,
|
|
83
|
+
handleSearchInputFocus,
|
|
84
|
+
handleSearchInputBlur,
|
|
85
|
+
handleKeyDown,
|
|
86
|
+
handleAutocompleteSelect,
|
|
87
|
+
handleSubmitSearch,
|
|
88
|
+
setSearchText,
|
|
89
|
+
} = searchInput;
|
|
122
90
|
const searchResultsState = getSearchResultsState(isLoadingSearch, searchData);
|
|
123
91
|
|
|
124
92
|
const dynamicFilters = searchData?.filters || [];
|
|
125
93
|
|
|
126
|
-
// Provide fallback values when
|
|
94
|
+
// Provide fallback values when config is not yet available
|
|
127
95
|
const safeProductCardConfig = config?.frontendConfig?.uiConfigs
|
|
128
96
|
?.productCardConfig || {
|
|
129
97
|
variant: "minimal",
|
|
@@ -188,8 +156,6 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
188
156
|
}, [filters]);
|
|
189
157
|
|
|
190
158
|
// Callbacks
|
|
191
|
-
const { trackEvent } = useAmplitude();
|
|
192
|
-
|
|
193
159
|
const handleToggleDynamicFilter = useCallback(
|
|
194
160
|
({
|
|
195
161
|
filter,
|
|
@@ -209,92 +175,19 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
209
175
|
addFilter(
|
|
210
176
|
createFilterOption("dynamic", filter, dynamicFilterDisplayName)
|
|
211
177
|
);
|
|
178
|
+
scrollToTop();
|
|
212
179
|
},
|
|
213
|
-
[addFilter, searchText, trackEvent]
|
|
180
|
+
[addFilter, searchText, scrollToTop, trackEvent]
|
|
214
181
|
);
|
|
215
182
|
|
|
216
183
|
const handleRemoveFilter = useCallback(
|
|
217
184
|
(filter: SelectedFilterOption) => {
|
|
218
185
|
removeFilter(filter.id);
|
|
186
|
+
scrollToTop();
|
|
219
187
|
},
|
|
220
|
-
[removeFilter]
|
|
188
|
+
[removeFilter, scrollToTop]
|
|
221
189
|
);
|
|
222
190
|
|
|
223
|
-
const handleSubmitSearch = useCallback(async () => {
|
|
224
|
-
if (searchText.trim()) {
|
|
225
|
-
trackEvent({
|
|
226
|
-
eventName: SpiffyMetricsEventName.SearchQuerySubmitted,
|
|
227
|
-
eventProps: {
|
|
228
|
-
searchOrigin: SpiffyWidgets.SearchResults,
|
|
229
|
-
queryText: searchText.trim(),
|
|
230
|
-
},
|
|
231
|
-
alsoSendToGoogleAnalytics: true,
|
|
232
|
-
});
|
|
233
|
-
const url = new URL(window.location.href);
|
|
234
|
-
url.searchParams.set("esq", searchText.trim());
|
|
235
|
-
window.history.pushState({}, "", url);
|
|
236
|
-
performSearch({ query: searchText.trim() });
|
|
237
|
-
}
|
|
238
|
-
}, [performSearch, searchText, trackEvent]);
|
|
239
|
-
|
|
240
|
-
const handleAutocompleteSelect = useCallback(
|
|
241
|
-
(suggestion: string) => {
|
|
242
|
-
setSearchText(suggestion);
|
|
243
|
-
handleSubmitSearch();
|
|
244
|
-
},
|
|
245
|
-
[handleSubmitSearch, setSearchText]
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
const handleKeyDown = useCallback(
|
|
249
|
-
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
250
|
-
if (event.key === "ArrowDown") {
|
|
251
|
-
event.preventDefault();
|
|
252
|
-
const newIndex = (focusedIndex + 1) % autocompleteResults.length;
|
|
253
|
-
setFocusedIndex(newIndex);
|
|
254
|
-
setFocusedOptionId(`option-${newIndex}`);
|
|
255
|
-
} else if (event.key === "ArrowUp") {
|
|
256
|
-
event.preventDefault();
|
|
257
|
-
const newIndex =
|
|
258
|
-
(focusedIndex - 1 + autocompleteResults.length) %
|
|
259
|
-
autocompleteResults.length;
|
|
260
|
-
setFocusedIndex(newIndex);
|
|
261
|
-
setFocusedOptionId(`option-${newIndex}`);
|
|
262
|
-
} else if (event.key === "Enter") {
|
|
263
|
-
if (focusedIndex === -1) {
|
|
264
|
-
event.preventDefault();
|
|
265
|
-
handleSubmitSearch();
|
|
266
|
-
} else {
|
|
267
|
-
event.preventDefault();
|
|
268
|
-
const suggestionText = autocompleteResults[focusedIndex];
|
|
269
|
-
handleAutocompleteSelect(suggestionText);
|
|
270
|
-
}
|
|
271
|
-
} else if (event.key === "Escape") {
|
|
272
|
-
event.preventDefault();
|
|
273
|
-
setFocusedIndex(-1);
|
|
274
|
-
setFocusedOptionId(undefined);
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
[
|
|
278
|
-
autocompleteResults,
|
|
279
|
-
focusedIndex,
|
|
280
|
-
handleAutocompleteSelect,
|
|
281
|
-
handleSubmitSearch,
|
|
282
|
-
]
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
const handleSearchInputChange = (newValue: string) => {
|
|
286
|
-
if (newValue.length === 1) {
|
|
287
|
-
trackEvent({
|
|
288
|
-
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
289
|
-
eventProps: {
|
|
290
|
-
searchOrigin: SpiffyWidgets.SearchResults,
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
setSearchText(newValue);
|
|
295
|
-
setIsDirty(true);
|
|
296
|
-
};
|
|
297
|
-
|
|
298
191
|
const handleSelectFilterItem: SelectFilterItem = useCallback(
|
|
299
192
|
({
|
|
300
193
|
filterId,
|
|
@@ -317,8 +210,10 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
317
210
|
},
|
|
318
211
|
});
|
|
319
212
|
setProductSorting(newSort);
|
|
213
|
+
scrollToTop();
|
|
320
214
|
} else if (!isSelected) {
|
|
321
215
|
removeFilter(`${filterId}:${filterItemId}`);
|
|
216
|
+
scrollToTop();
|
|
322
217
|
} else {
|
|
323
218
|
trackEvent({
|
|
324
219
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
@@ -330,15 +225,24 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
330
225
|
},
|
|
331
226
|
});
|
|
332
227
|
addFilter(createFilterOption(filterId, filterItemId, displayName));
|
|
228
|
+
scrollToTop();
|
|
333
229
|
}
|
|
334
230
|
},
|
|
335
|
-
[
|
|
231
|
+
[
|
|
232
|
+
addFilter,
|
|
233
|
+
removeFilter,
|
|
234
|
+
setProductSorting,
|
|
235
|
+
searchText,
|
|
236
|
+
scrollToTop,
|
|
237
|
+
trackEvent,
|
|
238
|
+
]
|
|
336
239
|
);
|
|
337
240
|
|
|
338
241
|
const handleClearAllFilters = useCallback(() => {
|
|
339
242
|
setProductSorting(ProductSorting.FEATURED);
|
|
340
243
|
clearFilters();
|
|
341
|
-
|
|
244
|
+
scrollToTop();
|
|
245
|
+
}, [setProductSorting, clearFilters, scrollToTop]);
|
|
342
246
|
|
|
343
247
|
// Side Effects
|
|
344
248
|
useTrackComponentVisibleEvent(
|
|
@@ -360,53 +264,15 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
360
264
|
}
|
|
361
265
|
}, [productList.length, searchText, trackEvent]);
|
|
362
266
|
|
|
267
|
+
// This is the single source of truth for the search text triggering a search
|
|
363
268
|
useEffect(() => {
|
|
364
269
|
if (query && query !== searchText) {
|
|
270
|
+
const esq = new URLSearchParams(window.location.search).get("esq");
|
|
365
271
|
setSearchText(query);
|
|
272
|
+
performSearch({ query: esq ?? query });
|
|
366
273
|
}
|
|
367
274
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
368
|
-
}, [query]);
|
|
369
|
-
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
const esq = new URLSearchParams(window.location.search).get("esq");
|
|
372
|
-
if (esq) {
|
|
373
|
-
setSearchText(esq);
|
|
374
|
-
performSearch({ query: esq });
|
|
375
|
-
}
|
|
376
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
377
|
-
}, [performSearch]);
|
|
378
|
-
|
|
379
|
-
const fetchAutocompleteSuggestions = (_query: string) => {
|
|
380
|
-
// TODO: implement autocomplete suggestions
|
|
381
|
-
return Promise.resolve([]);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
useEffect(() => {
|
|
385
|
-
if (fetchAutocompleteSuggestions === undefined) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if (!isDirty || debouncedSearchText.length <= 2) {
|
|
390
|
-
setAutocompleteState({ results: [], isLoading: false });
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
setAutocompleteState((prev) => ({ ...prev, isLoading: true }));
|
|
395
|
-
|
|
396
|
-
const fetchData = async () => {
|
|
397
|
-
try {
|
|
398
|
-
const results = await fetchAutocompleteSuggestions?.(
|
|
399
|
-
debouncedSearchText
|
|
400
|
-
);
|
|
401
|
-
setAutocompleteState({ results: results ?? [], isLoading: false });
|
|
402
|
-
} catch (error) {
|
|
403
|
-
Logger.logError("Failed to fetch autocomplete suggestions:", error);
|
|
404
|
-
setAutocompleteState({ results: [], isLoading: false });
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
fetchData();
|
|
409
|
-
}, [debouncedSearchText, isDirty, setAutocompleteState]);
|
|
275
|
+
}, [performSearch, query, setSearchText]);
|
|
410
276
|
|
|
411
277
|
return {
|
|
412
278
|
searchData,
|
|
@@ -414,16 +280,18 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
414
280
|
merchantShortName: safeMerchantShortName,
|
|
415
281
|
productCardConfig: safeProductCardConfig,
|
|
416
282
|
productList,
|
|
283
|
+
recommendedProducts,
|
|
417
284
|
autocompleteResults,
|
|
418
285
|
searchFilters: filters,
|
|
419
286
|
availableDynamicFilters,
|
|
420
287
|
selectedFilterOptions,
|
|
421
288
|
searchText,
|
|
289
|
+
query: query || "",
|
|
422
290
|
searchResultsState,
|
|
423
|
-
isLoadingAutocomplete,
|
|
424
291
|
isLoadingSearch,
|
|
292
|
+
isLoadingAutocomplete: false,
|
|
425
293
|
isFilterOpen,
|
|
426
|
-
|
|
294
|
+
shouldShowAutocomplete,
|
|
427
295
|
focusedIndex,
|
|
428
296
|
focusedOptionId,
|
|
429
297
|
filterButtonText,
|
|
@@ -431,6 +299,8 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
431
299
|
onSubmitSearch: handleSubmitSearch,
|
|
432
300
|
onAutocompleteSelect: handleAutocompleteSelect,
|
|
433
301
|
onKeyDown: handleKeyDown,
|
|
302
|
+
onSearchInputFocus: handleSearchInputFocus,
|
|
303
|
+
onSearchInputBlur: handleSearchInputBlur,
|
|
434
304
|
onToggleDynamicFilter: handleToggleDynamicFilter,
|
|
435
305
|
onSelectFilterItem: handleSelectFilterItem,
|
|
436
306
|
onRemoveFilter: handleRemoveFilter,
|