@envive-ai/react-hooks 0.3.2 → 0.3.4
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/_virtual/rolldown_runtime.cjs +2 -0
- package/dist/_virtual/rolldown_runtime.js +29 -0
- package/dist/application/commerce-api.cjs +15 -5
- package/dist/application/commerce-api.js +14 -4
- package/dist/application/models/api/nextMessageRequest.d.cts +3 -1
- package/dist/application/models/api/nextMessageRequest.d.ts +3 -1
- package/dist/application/models/api/userEvent.d.cts +4 -2
- package/dist/application/models/api/userEvent.d.ts +4 -2
- package/dist/application/models/chatElementDisplayLocationV3.cjs +18 -0
- package/dist/application/models/chatElementDisplayLocationV3.d.cts +15 -0
- package/dist/application/models/chatElementDisplayLocationV3.d.ts +15 -0
- package/dist/application/models/chatElementDisplayLocationV3.js +17 -0
- package/dist/application/models/colorsConfigV3.cjs +26 -0
- package/dist/application/models/colorsConfigV3.d.cts +22 -0
- package/dist/application/models/colorsConfigV3.d.ts +22 -0
- package/dist/application/models/colorsConfigV3.js +24 -0
- package/dist/application/models/featureGates.cjs +2 -1
- package/dist/application/models/featureGates.d.cts +2 -1
- package/dist/application/models/featureGates.d.ts +2 -1
- package/dist/application/models/featureGates.js +2 -1
- package/dist/application/models/frontendConfig.d.cts +4 -2
- package/dist/application/models/frontendConfig.d.ts +4 -2
- package/dist/application/models/frontendConfigV3.d.cts +14 -0
- package/dist/application/models/frontendConfigV3.d.ts +14 -0
- package/dist/application/models/index.cjs +3 -0
- package/dist/application/models/index.d.cts +4 -3
- package/dist/application/models/index.d.ts +4 -3
- package/dist/application/models/index.js +3 -2
- package/dist/application/models/utils/snakeToCamelTransformer.cjs +2 -1
- package/dist/application/models/utils/snakeToCamelTransformer.d.cts +7 -2
- package/dist/application/models/utils/snakeToCamelTransformer.d.ts +7 -2
- package/dist/application/models/utils/snakeToCamelTransformer.js +2 -2
- package/dist/application/models/variantInfo/variantInfo.cjs +4 -1
- package/dist/application/models/variantInfo/variantInfo.d.cts +4 -1
- package/dist/application/models/variantInfo/variantInfo.d.ts +4 -1
- package/dist/application/models/variantInfo/variantInfo.js +4 -1
- package/dist/application/utils/analyticsUtils.cjs +5 -4
- package/dist/application/utils/analyticsUtils.d.cts +1 -1
- package/dist/application/utils/analyticsUtils.d.ts +1 -1
- package/dist/application/utils/analyticsUtils.js +3 -2
- package/dist/application/utils/elementObserver.cjs +1 -1
- package/dist/application/utils/elementObserver.d.cts +2 -2
- package/dist/application/utils/elementObserver.d.ts +2 -2
- package/dist/application/utils/elementObserver.js +1 -1
- package/dist/application/utils/index.d.cts +1 -1
- package/dist/application/utils/index.d.ts +1 -1
- package/dist/application/utils/widgetTextFromApiWidgetTextResponse.cjs +14 -0
- package/dist/application/utils/widgetTextFromApiWidgetTextResponse.js +13 -0
- package/dist/application/utils/widgetTextRequestToApiRequest.cjs +30 -0
- package/dist/application/utils/widgetTextRequestToApiRequest.js +29 -0
- package/dist/atoms/amplitude/amplitudeTrackEventAtom.cjs +1 -1
- package/dist/atoms/amplitude/amplitudeTrackEventAtom.js +1 -1
- package/dist/atoms/app/index.cjs +13 -1
- package/dist/atoms/app/index.d.cts +4 -3
- package/dist/atoms/app/index.d.ts +9 -8
- package/dist/atoms/app/index.js +13 -4
- package/dist/atoms/app/variant.cjs +6 -2
- package/dist/atoms/app/variant.d.cts +76 -5
- package/dist/atoms/app/variant.d.ts +76 -5
- package/dist/atoms/app/variant.js +4 -2
- package/dist/atoms/chat/chatState.cjs +9 -4
- package/dist/atoms/chat/chatState.d.cts +25 -18
- package/dist/atoms/chat/chatState.d.ts +25 -18
- package/dist/atoms/chat/chatState.js +6 -3
- package/dist/atoms/chat/form.cjs +4 -4
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.cjs +32 -30
- package/dist/atoms/chat/index.d.cts +4 -4
- package/dist/atoms/chat/index.d.ts +3 -3
- package/dist/atoms/chat/index.js +2 -2
- package/dist/atoms/chat/lastMessage.cjs +4 -4
- package/dist/atoms/chat/lastMessage.d.cts +2 -2
- package/dist/atoms/chat/lastMessage.d.ts +2 -2
- package/dist/atoms/chat/messageQueue.cjs +1 -35
- package/dist/atoms/chat/messageQueue.js +2 -34
- package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
- package/dist/atoms/chat/renderedWidgetRefs.d.ts +2 -2
- package/dist/atoms/chat/replies.cjs +9 -8
- package/dist/atoms/chat/replies.d.cts +3 -3
- package/dist/atoms/chat/replies.d.ts +3 -3
- package/dist/atoms/chat/replies.js +3 -2
- package/dist/atoms/chat/suggestions.cjs +6 -6
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/envive/enviveConfig.cjs +5 -2
- package/dist/atoms/envive/enviveConfig.js +5 -2
- package/dist/atoms/globalSearch/globalSearch.cjs +1 -3
- package/dist/atoms/globalSearch/globalSearch.d.cts +7 -10
- package/dist/atoms/globalSearch/globalSearch.d.ts +7 -10
- package/dist/atoms/globalSearch/globalSearch.js +2 -3
- package/dist/atoms/globalSearch/index.cjs +0 -1
- package/dist/atoms/globalSearch/index.d.cts +2 -2
- package/dist/atoms/globalSearch/index.d.ts +2 -2
- package/dist/atoms/globalSearch/index.js +2 -2
- package/dist/atoms/org/customerService.d.cts +6 -6
- package/dist/atoms/org/customerService.d.ts +6 -6
- package/dist/atoms/org/graphqlConfig.cjs +1 -3
- package/dist/atoms/org/graphqlConfig.d.cts +6 -9
- package/dist/atoms/org/graphqlConfig.d.ts +6 -9
- package/dist/atoms/org/graphqlConfig.js +2 -3
- package/dist/atoms/org/index.cjs +2 -3
- package/dist/atoms/org/index.d.cts +2 -2
- package/dist/atoms/org/index.d.ts +2 -2
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +5 -5
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +5 -5
- package/dist/atoms/search/chatSearch.cjs +7 -7
- package/dist/atoms/search/chatSearch.d.cts +20 -18
- package/dist/atoms/search/chatSearch.d.ts +20 -18
- package/dist/atoms/search/searchAPI.d.cts +15 -14
- package/dist/atoms/search/searchAPI.d.ts +15 -14
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/widget/chatPreviewLoading.cjs +23 -0
- package/dist/atoms/widget/chatPreviewLoading.d.cts +26 -0
- package/dist/atoms/widget/chatPreviewLoading.d.ts +26 -0
- package/dist/atoms/widget/chatPreviewLoading.js +22 -0
- package/dist/atoms/widget/index.cjs +3 -0
- package/dist/atoms/widget/index.d.cts +2 -0
- package/dist/atoms/widget/index.d.ts +2 -0
- package/dist/atoms/widget/index.js +3 -0
- package/dist/contexts/amplitudeContext/amplitudeContext.cjs +41 -228
- package/dist/contexts/amplitudeContext/amplitudeContext.d.cts +4 -39
- package/dist/contexts/amplitudeContext/amplitudeContext.d.ts +4 -39
- package/dist/contexts/amplitudeContext/amplitudeContext.js +45 -231
- package/dist/contexts/amplitudeContext/index.cjs +2 -1
- package/dist/contexts/amplitudeContext/index.d.cts +2 -1
- package/dist/contexts/amplitudeContext/index.d.ts +2 -1
- package/dist/contexts/amplitudeContext/index.js +2 -1
- package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +3 -2
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.cts +2 -1
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.ts +2 -1
- package/dist/contexts/enviveConfigContext/enviveConfigContext.js +3 -2
- package/dist/contexts/enviveContext/enviveContext.cjs +73 -18
- package/dist/contexts/enviveContext/enviveContext.d.cts +9 -1
- package/dist/contexts/enviveContext/enviveContext.d.ts +9 -1
- package/dist/contexts/enviveContext/enviveContext.js +75 -20
- package/dist/contexts/enviveCssContext/enviveCssContext.cjs +96 -24
- package/dist/contexts/enviveCssContext/enviveCssContext.js +96 -24
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.cjs +5 -7
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.cts +2 -2
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +2 -2
- package/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.js +5 -7
- package/dist/contexts/graphqlContext/graphqlContext.cjs +70 -8
- package/dist/contexts/graphqlContext/graphqlContext.d.cts +17 -5
- package/dist/contexts/graphqlContext/graphqlContext.d.ts +17 -5
- package/dist/contexts/graphqlContext/graphqlContext.js +70 -8
- package/dist/contexts/graphqlContext/index.d.cts +2 -2
- package/dist/contexts/graphqlContext/index.d.ts +2 -2
- package/dist/contexts/graphqlContext/mockV3Config.cjs +208 -0
- package/dist/contexts/graphqlContext/mockV3Config.js +207 -0
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +169 -0
- package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +24 -0
- package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +24 -0
- package/dist/contexts/hardcopyContext/hardcopyContext.js +167 -0
- package/dist/contexts/hardcopyContext/index.cjs +4 -0
- package/dist/contexts/hardcopyContext/index.d.cts +2 -0
- package/dist/contexts/hardcopyContext/index.d.ts +2 -0
- package/dist/contexts/hardcopyContext/index.js +3 -0
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +7 -8
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +8 -9
- package/dist/contexts/pageContext/index.cjs +6 -0
- package/dist/contexts/pageContext/index.d.cts +3 -0
- package/dist/contexts/pageContext/index.d.ts +3 -0
- package/dist/contexts/pageContext/index.js +4 -0
- package/dist/contexts/pageContext/mapping.cjs +29 -0
- package/dist/contexts/pageContext/mapping.d.cts +8 -0
- package/dist/contexts/pageContext/mapping.d.ts +8 -0
- package/dist/contexts/pageContext/mapping.js +29 -0
- package/dist/contexts/pageContext/pageContext.cjs +86 -0
- package/dist/contexts/pageContext/pageContext.d.cts +14 -0
- package/dist/contexts/pageContext/pageContext.d.ts +14 -0
- package/dist/contexts/pageContext/pageContext.js +84 -0
- package/dist/contexts/pageContext/types.cjs +0 -0
- package/dist/contexts/pageContext/types.d.cts +31 -0
- package/dist/contexts/pageContext/types.d.ts +31 -0
- package/dist/contexts/pageContext/types.js +1 -0
- package/dist/contexts/salesAgentContext/chatAPI.cjs +48 -0
- package/dist/contexts/salesAgentContext/chatAPI.d.cts +35 -0
- package/dist/contexts/salesAgentContext/chatAPI.d.ts +35 -0
- package/dist/contexts/salesAgentContext/chatAPI.js +47 -0
- package/dist/contexts/salesAgentContext/index.cjs +20 -0
- package/dist/contexts/salesAgentContext/index.d.cts +4 -0
- package/dist/contexts/salesAgentContext/index.d.ts +4 -0
- package/dist/contexts/salesAgentContext/index.js +5 -0
- package/dist/contexts/salesAgentContext/salesAgentContext.cjs +130 -0
- package/dist/contexts/salesAgentContext/salesAgentContext.d.cts +22 -0
- package/dist/contexts/salesAgentContext/salesAgentContext.d.ts +22 -0
- package/dist/contexts/salesAgentContext/salesAgentContext.js +128 -0
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +135 -0
- package/dist/contexts/salesAgentContext/salesAgentService.js +134 -0
- package/dist/contexts/salesAgentContext/statusCodeError.cjs +14 -0
- package/dist/contexts/salesAgentContext/statusCodeError.js +13 -0
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/types.cjs +2 -3
- package/dist/contexts/types.d.cts +12 -8
- package/dist/contexts/types.d.ts +12 -8
- package/dist/contexts/types.js +2 -3
- package/dist/contexts/typesV3.cjs +125 -0
- package/dist/contexts/typesV3.d.cts +246 -0
- package/dist/contexts/typesV3.d.ts +246 -0
- package/dist/contexts/typesV3.js +113 -0
- package/dist/contexts/uiConfigContext/index.cjs +4 -0
- package/dist/contexts/uiConfigContext/index.d.cts +2 -0
- package/dist/contexts/uiConfigContext/index.d.ts +2 -0
- package/dist/contexts/uiConfigContext/index.js +3 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.cjs +44 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.d.cts +15 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.d.ts +15 -0
- package/dist/contexts/uiConfigContext/uiConfigContext.js +42 -0
- package/dist/contexts/widgetConfigContext/index.cjs +4 -0
- package/dist/contexts/widgetConfigContext/index.d.cts +2 -0
- package/dist/contexts/widgetConfigContext/index.d.ts +2 -0
- package/dist/contexts/widgetConfigContext/index.js +3 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.cjs +67 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.d.cts +19 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.d.ts +19 -0
- package/dist/contexts/widgetConfigContext/widgetConfigContext.js +65 -0
- package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/useAmplitudeOperations.d.ts +1 -1
- package/dist/hooks/AppDetails/useAppDetails.cjs +2 -4
- package/dist/hooks/AppDetails/useAppDetails.js +3 -5
- package/dist/hooks/ChatToggle/useChatToggle.cjs +6 -5
- package/dist/hooks/ChatToggle/useChatToggle.js +3 -2
- package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.cjs +3 -3
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +3 -3
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +1 -1
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.js +2 -2
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.cjs +30 -21
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.cts +5 -4
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.ts +5 -4
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.js +30 -21
- package/dist/hooks/ImageResolver/useImageResolver.cjs +1 -1
- package/dist/hooks/ImageResolver/useImageResolver.js +1 -1
- package/dist/hooks/Search/useSearch.cjs +10 -12
- package/dist/hooks/Search/useSearch.d.cts +1 -3
- package/dist/hooks/Search/useSearch.d.ts +1 -3
- package/dist/hooks/Search/useSearch.js +7 -9
- package/dist/hooks/Search/useSearchInput.cjs +4 -4
- package/dist/hooks/Search/useSearchInput.js +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.cjs +5 -4
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.cts +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.d.ts +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +3 -2
- package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.cjs +3 -2
- package/dist/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +3 -2
- package/dist/hooks/utils.d.ts +1 -1
- package/dist/node_modules/classnames/index.cjs +52 -0
- package/dist/node_modules/classnames/index.js +49 -0
- package/dist/packages/components-v3/dist/Container/Container.cjs +11 -0
- package/dist/packages/components-v3/dist/Container/Container.js +12 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetCenterContentProperties.js +3 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Container/hooks/useGetFluidProperties.js +3 -0
- package/dist/packages/components-v3/dist/Container/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Container/index.js +3 -0
- package/dist/packages/components-v3/dist/Image/Image.cjs +16 -0
- package/dist/packages/components-v3/dist/Image/Image.js +17 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAccessibilityProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAccessibilityProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAspectRatioProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetAspectRatioProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetObjectFitProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetObjectFitProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetRoundedProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetRoundedProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetSkeletonProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetSkeletonProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetWidthProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useGetWidthProperties.js +3 -0
- package/dist/packages/components-v3/dist/Image/hooks/useHandleImageLoading.cjs +1 -0
- package/dist/packages/components-v3/dist/Image/hooks/useHandleImageLoading.js +3 -0
- package/dist/packages/components-v3/dist/ImageGallery/ImageGallery.cjs +2 -0
- package/dist/packages/components-v3/dist/ImageGallery/ImageGallery.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/ImageItem.cjs +2 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/ImageItem.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.cjs +15 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.js +16 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/NormalLayout.cjs +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/NormalLayout.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/OverlappedLayout.cjs +1 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/OverlappedLayout.js +3 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/index.js +6 -0
- package/dist/packages/components-v3/dist/ImageGallery/hooks/useGetContainerProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/ImageGallery/hooks/useGetContainerProperties.js +3 -0
- package/dist/packages/components-v3/dist/ImageGallery/index.cjs +2 -0
- package/dist/packages/components-v3/dist/ImageGallery/index.js +4 -0
- package/dist/packages/components-v3/dist/ImageGallery/types/types.cjs +13 -0
- package/dist/packages/components-v3/dist/ImageGallery/types/types.js +12 -0
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.js +13 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Icon.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Icon.js +3 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Label.cjs +3 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Label.js +5 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.js +13 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Loading.cjs +9 -0
- package/dist/packages/components-v3/dist/PromptButton/components/Loading.js +10 -0
- package/dist/packages/components-v3/dist/PromptButton/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/PromptButton/components/index.js +6 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetBoldTextProperties.js +3 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.cjs +8 -0
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.js +9 -0
- package/dist/packages/components-v3/dist/PromptButton/index.cjs +2 -0
- package/dist/packages/components-v3/dist/PromptButton/index.js +4 -0
- package/dist/packages/components-v3/dist/PromptButton/types/index.cjs +13 -0
- package/dist/packages/components-v3/dist/PromptButton/types/index.js +12 -0
- package/dist/packages/components-v3/dist/PromptCarousel/PromptCarousel.cjs +12 -0
- package/dist/packages/components-v3/dist/PromptCarousel/PromptCarousel.js +14 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/BlockScrollContainer.cjs +9 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/BlockScrollContainer.js +10 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/ButtonContainerRow.cjs +11 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/ButtonContainerRow.js +12 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithBlockScroll.cjs +4 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithBlockScroll.js +6 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithRowScroll.cjs +4 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/CarouselContentWithRowScroll.js +6 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/index.cjs +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/components/index.js +5 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/index.cjs +5 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/index.js +7 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useButtonScrollPosition.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useButtonScrollPosition.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselAnimation.cjs +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselAnimation.js +5 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselButtons.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselButtons.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useCarouselRefs.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.cjs +1 -0
- package/dist/packages/components-v3/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.js +3 -0
- package/dist/packages/components-v3/dist/PromptCarousel/index.cjs +2 -0
- package/dist/packages/components-v3/dist/PromptCarousel/index.js +4 -0
- package/dist/packages/components-v3/dist/PromptCarousel/types/types.cjs +19 -0
- package/dist/packages/components-v3/dist/PromptCarousel/types/types.js +17 -0
- package/dist/packages/components-v3/dist/Stack/Stack.cjs +36 -0
- package/dist/packages/components-v3/dist/Stack/Stack.js +36 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useFormatStackChildren.cjs +27 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useFormatStackChildren.js +26 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetAlignProperties.cjs +20 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetAlignProperties.js +19 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetDirectionProperties.cjs +19 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetDirectionProperties.js +18 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetGapProperties.cjs +16 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetGapProperties.js +15 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetJustifyProperties.cjs +21 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetJustifyProperties.js +20 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetStyleProperties.cjs +38 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetStyleProperties.js +38 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetWrapProperties.cjs +13 -0
- package/dist/packages/components-v3/dist/Stack/hooks/useGetWrapProperties.js +12 -0
- package/dist/packages/components-v3/dist/Stack/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Stack/index.js +3 -0
- package/dist/packages/components-v3/dist/Stack/utils/constants.cjs +42 -0
- package/dist/packages/components-v3/dist/Stack/utils/constants.js +41 -0
- package/dist/packages/components-v3/dist/Typography/Typography.cjs +15 -0
- package/dist/packages/components-v3/dist/Typography/Typography.js +16 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAccessibilityAttributes.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetAlignProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetColorProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNoWrapProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetNumberOfLinesProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/hooks/useGetVariantProperties.js +3 -0
- package/dist/packages/components-v3/dist/Typography/index.cjs +1 -0
- package/dist/packages/components-v3/dist/Typography/index.js +3 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/WidgetWrapper.cjs +12 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/WidgetWrapper.js +13 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/hooks/useGetWrapperProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/hooks/useGetWrapperProperties.js +3 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/index.cjs +2 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/index.js +4 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/types/types.cjs +13 -0
- package/dist/packages/components-v3/dist/WidgetWrapper/types/types.js +12 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.cjs +25 -0
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.js +23 -0
- package/dist/packages/components-v3/dist/utils/useCheckIsMobile.cjs +1 -0
- package/dist/packages/components-v3/dist/utils/useCheckIsMobile.js +3 -0
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.cjs +57 -0
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.js +56 -0
- package/dist/packages/icons/dist/FourPointStar.cjs +8 -0
- package/dist/packages/icons/dist/FourPointStar.js +9 -0
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +28 -0
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +26 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +697 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +697 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +44 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +44 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +1529 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +1529 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +330 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +330 -0
- package/dist/packages/icons/dist/node_modules/react/index.cjs +14 -0
- package/dist/packages/icons/dist/node_modules/react/index.js +14 -0
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +14 -0
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +14 -0
- package/dist/services/amplitudeService/amplitudeService.cjs +204 -0
- package/dist/services/amplitudeService/amplitudeService.d.cts +75 -0
- package/dist/services/amplitudeService/amplitudeService.d.ts +75 -0
- package/dist/services/amplitudeService/amplitudeService.js +202 -0
- package/dist/services/amplitudeService/index.cjs +4 -0
- package/dist/services/amplitudeService/index.d.cts +2 -0
- package/dist/services/amplitudeService/index.d.ts +2 -0
- package/dist/services/amplitudeService/index.js +3 -0
- package/dist/services/enviveConfigService/enviveConfigService.cjs +36 -0
- package/dist/services/enviveConfigService/enviveConfigService.d.cts +43 -0
- package/dist/services/enviveConfigService/enviveConfigService.d.ts +43 -0
- package/dist/services/enviveConfigService/enviveConfigService.js +36 -0
- package/dist/services/enviveConfigService/index.cjs +3 -0
- package/dist/services/enviveConfigService/index.d.cts +2 -0
- package/dist/services/enviveConfigService/index.d.ts +2 -0
- package/dist/services/enviveConfigService/index.js +3 -0
- package/dist/types/enviveConfig.d.cts +29 -0
- package/dist/types/enviveConfig.d.ts +29 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +40 -4
- package/src/application/commerce-api.ts +14 -1
- package/src/application/models/api/userEvent.ts +3 -1
- package/src/application/models/api/widgetText.ts +9 -0
- package/src/application/models/api/widgetTextRequest.ts +10 -0
- package/src/application/models/chatElementDisplayLocationV3.ts +12 -0
- package/src/application/models/colorsConfigV3.ts +26 -0
- package/src/application/models/featureGates.ts +1 -0
- package/src/application/models/frontendConfig.ts +5 -0
- package/src/application/models/frontendConfigV3.ts +10 -0
- package/src/application/models/index.ts +1 -0
- package/src/application/models/utils/snakeToCamelTransformer.ts +1 -1
- package/src/application/utils/elementObserver.ts +2 -2
- package/src/application/utils/widgetTextFromApiWidgetTextResponse.ts +30 -0
- package/src/application/utils/widgetTextRequestToApiRequest.ts +45 -0
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -8
- package/src/atoms/app/index.ts +3 -3
- package/src/atoms/app/variant.ts +5 -0
- package/src/atoms/chat/chatState.ts +10 -2
- package/src/atoms/envive/enviveConfig.ts +5 -0
- package/src/atoms/org/graphqlConfig.ts +0 -1
- package/src/atoms/widget/chatPreviewLoading.ts +36 -0
- package/src/atoms/widget/index.ts +1 -0
- package/src/contexts/amplitudeContext/__tests__/amplitudeContext.test.tsx +197 -187
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +56 -334
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +3 -0
- package/src/contexts/enviveContext/enviveContext.tsx +101 -27
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +121 -22
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +12 -11
- package/src/contexts/graphqlContext/graphqlContext.tsx +131 -13
- package/src/contexts/graphqlContext/mockV3Config.ts +209 -0
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +136 -14
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +6 -6
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +5 -13
- package/src/contexts/pageContext/__tests__/pageContext.test.tsx +24 -8
- package/src/contexts/pageContext/mapping.ts +4 -0
- package/src/contexts/pageContext/pageContext.tsx +41 -12
- package/src/contexts/pageContext/types.ts +4 -0
- package/src/contexts/salesAgentContext/chatAPI.ts +1 -0
- package/src/contexts/salesAgentContext/salesAgentContext.tsx +94 -42
- package/src/contexts/salesAgentContext/salesAgentService.ts +78 -3
- package/src/contexts/salesAgentContext/statusCodeError.ts +10 -0
- package/src/contexts/searchContext/__tests__/searchContext.test.tsx +8 -2
- package/src/contexts/types.ts +15 -19
- package/src/contexts/typesV3.ts +316 -0
- package/src/contexts/uiConfigContext/__tests__/uiConfigContext.test.tsx +321 -0
- package/src/contexts/uiConfigContext/index.ts +1 -0
- package/src/contexts/uiConfigContext/uiConfigContext.tsx +44 -0
- package/src/contexts/widgetConfigContext/__tests__/widgetConfigContext.test.tsx +512 -0
- package/src/contexts/widgetConfigContext/index.ts +1 -0
- package/src/contexts/widgetConfigContext/widgetConfigContext.tsx +84 -0
- package/src/hooks/AppDetails/useAppDetails.ts +2 -2
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +22 -21
- package/src/hooks/Search/__tests__/useSearch.test.tsx +15 -6
- package/src/hooks/Search/useSearch.tsx +6 -5
- package/src/services/amplitudeService/__tests__/amplitudeService.test.ts +558 -0
- package/src/services/amplitudeService/amplitudeService.ts +324 -0
- package/src/services/amplitudeService/index.ts +1 -0
- package/src/services/enviveConfigService/enviveConfigService.ts +72 -0
- package/src/services/enviveConfigService/index.ts +1 -0
- package/src/types/enviveConfig.ts +27 -0
- package/src/types/index.ts +1 -0
- package/dist/contexts/chatContext/chatContext.cjs +0 -306
- package/dist/contexts/chatContext/chatContext.d.cts +0 -15
- package/dist/contexts/chatContext/chatContext.d.ts +0 -15
- package/dist/contexts/chatContext/chatContext.js +0 -304
- package/dist/contexts/chatContext/index.cjs +0 -4
- package/dist/contexts/chatContext/index.d.cts +0 -2
- package/dist/contexts/chatContext/index.d.ts +0 -2
- package/dist/contexts/chatContext/index.js +0 -3
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import Logger from 'src/application/logging/logger';
|
|
4
|
+
import { useNewOrgConfig } from 'src/hooks/NewOrgConfig';
|
|
5
|
+
import { WidgetConfigProvider, useWidgetConfig } from '../widgetConfigContext';
|
|
6
|
+
import { WidgetConfigV3, WidgetTypeV3 } from '../../typesV3';
|
|
7
|
+
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton';
|
|
8
|
+
|
|
9
|
+
// Mock the Logger to avoid console output in tests
|
|
10
|
+
vi.spyOn(Logger, 'logInfo').mockImplementation(() => {});
|
|
11
|
+
vi.spyOn(Logger, 'logWarn').mockImplementation(() => {});
|
|
12
|
+
vi.spyOn(Logger, 'logError').mockImplementation(() => {});
|
|
13
|
+
|
|
14
|
+
// Mock the useNewOrgConfig hook
|
|
15
|
+
vi.mock('src/hooks/NewOrgConfig', () => ({
|
|
16
|
+
useNewOrgConfig: vi.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
// Component that uses the useWidgetConfig hook
|
|
20
|
+
const MockWidgetConfigComponent: React.FC = () => {
|
|
21
|
+
const { getWidgetConfig, isLoading } = useWidgetConfig();
|
|
22
|
+
const [widgetConfig, setWidgetConfig] = React.useState<WidgetConfigV3 | null>(null);
|
|
23
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
24
|
+
const [isLoadingState, setIsLoadingState] = React.useState(false);
|
|
25
|
+
|
|
26
|
+
const handleGetConfig = async () => {
|
|
27
|
+
setIsLoadingState(true);
|
|
28
|
+
try {
|
|
29
|
+
const config = await getWidgetConfig({
|
|
30
|
+
widgetType: WidgetTypeV3.PromptCarouselV3,
|
|
31
|
+
widgetConfigId: 'test-config-id',
|
|
32
|
+
});
|
|
33
|
+
setWidgetConfig(config);
|
|
34
|
+
setError(null);
|
|
35
|
+
} catch (err: unknown) {
|
|
36
|
+
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
37
|
+
setWidgetConfig(null);
|
|
38
|
+
} finally {
|
|
39
|
+
setIsLoadingState(false);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div data-testid="widget-config-component">
|
|
45
|
+
<div data-testid="is-loading">{isLoading.toString()}</div>
|
|
46
|
+
<div data-testid="is-loading-state">{isLoadingState.toString()}</div>
|
|
47
|
+
<div data-testid="has-widget-config">{widgetConfig ? 'true' : 'false'}</div>
|
|
48
|
+
<div data-testid="widget-config-id">{widgetConfig?.widgetConfigId || 'not-set'}</div>
|
|
49
|
+
<div data-testid="widget-config-type">{widgetConfig?.type || 'not-set'}</div>
|
|
50
|
+
{error && <div data-testid="error-message">{error}</div>}
|
|
51
|
+
<button
|
|
52
|
+
data-testid="get-config-btn"
|
|
53
|
+
type="button"
|
|
54
|
+
onClick={handleGetConfig}
|
|
55
|
+
>
|
|
56
|
+
Get Config
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Wrapper component for testing
|
|
63
|
+
const TestWrapper: React.FC<{
|
|
64
|
+
children: React.ReactNode;
|
|
65
|
+
mockNewOrgConfig?: {
|
|
66
|
+
frontendConfig?: {
|
|
67
|
+
widgetConfigs?: Record<string, WidgetConfigV3>;
|
|
68
|
+
} | null;
|
|
69
|
+
loading?: boolean;
|
|
70
|
+
};
|
|
71
|
+
}> = ({ children, mockNewOrgConfig = {} }) => {
|
|
72
|
+
const mockUseNewOrgConfig = useNewOrgConfig as ReturnType<typeof vi.fn>;
|
|
73
|
+
mockUseNewOrgConfig.mockReturnValue({
|
|
74
|
+
frontendConfig: mockNewOrgConfig.frontendConfig ?? null,
|
|
75
|
+
loading: mockNewOrgConfig.loading ?? false,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return <WidgetConfigProvider>{children}</WidgetConfigProvider>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
describe('WidgetConfigProvider', () => {
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
vi.clearAllMocks();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('useWidgetConfig Hook Integration', () => {
|
|
87
|
+
it('should provide context through useWidgetConfig hook', async () => {
|
|
88
|
+
const mockWidgetConfig: WidgetConfigV3 = {
|
|
89
|
+
widgetConfigId: 'test-config-id',
|
|
90
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
91
|
+
contentId: 'test-content-id',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
render(
|
|
95
|
+
<TestWrapper
|
|
96
|
+
mockNewOrgConfig={{
|
|
97
|
+
frontendConfig: {
|
|
98
|
+
widgetConfigs: {
|
|
99
|
+
'test-config-id': mockWidgetConfig,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
loading: false,
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
<MockWidgetConfigComponent />
|
|
106
|
+
</TestWrapper>,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
await waitFor(() => {
|
|
110
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(screen.getByTestId('is-loading')).toHaveTextContent('false');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should throw error when used outside of WidgetConfigProvider', () => {
|
|
117
|
+
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
118
|
+
|
|
119
|
+
const TestComponent: React.FC = () => {
|
|
120
|
+
try {
|
|
121
|
+
useWidgetConfig();
|
|
122
|
+
return <div data-testid="no-error">No Error</div>;
|
|
123
|
+
} catch (error: unknown) {
|
|
124
|
+
return (
|
|
125
|
+
<div data-testid="error">
|
|
126
|
+
{error instanceof Error ? error.message : 'Unknown error'}
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
render(<TestComponent />);
|
|
133
|
+
|
|
134
|
+
expect(screen.getByTestId('error')).toHaveTextContent(
|
|
135
|
+
'useWidgetConfig must be used within a WidgetConfigProvider',
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
consoleSpy.mockRestore();
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('getWidgetConfig', () => {
|
|
143
|
+
it('should successfully retrieve widget config when config exists', async () => {
|
|
144
|
+
const mockWidgetConfig: WidgetConfigV3 = {
|
|
145
|
+
widgetConfigId: 'test-config-id',
|
|
146
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
147
|
+
contentId: 'test-content-id',
|
|
148
|
+
promptButtonType: PromptButtonVariant.LIGHT,
|
|
149
|
+
boldFirstButton: true,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
render(
|
|
153
|
+
<TestWrapper
|
|
154
|
+
mockNewOrgConfig={{
|
|
155
|
+
frontendConfig: {
|
|
156
|
+
widgetConfigs: {
|
|
157
|
+
'test-config-id': mockWidgetConfig,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
loading: false,
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<MockWidgetConfigComponent />
|
|
164
|
+
</TestWrapper>,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
await waitFor(() => {
|
|
168
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
172
|
+
await act(async () => {
|
|
173
|
+
getConfigButton.click();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
await waitFor(() => {
|
|
177
|
+
expect(screen.getByTestId('has-widget-config')).toHaveTextContent('true');
|
|
178
|
+
expect(screen.getByTestId('widget-config-id')).toHaveTextContent('test-config-id');
|
|
179
|
+
expect(screen.getByTestId('widget-config-type')).toHaveTextContent(
|
|
180
|
+
WidgetTypeV3.PromptCarouselV3,
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
expect(screen.queryByTestId('error-message')).not.toBeInTheDocument();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should throw error when frontend config is loading', async () => {
|
|
188
|
+
render(
|
|
189
|
+
<TestWrapper
|
|
190
|
+
mockNewOrgConfig={{
|
|
191
|
+
frontendConfig: {
|
|
192
|
+
widgetConfigs: {
|
|
193
|
+
'test-config-id': {
|
|
194
|
+
widgetConfigId: 'test-config-id',
|
|
195
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
loading: true,
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<MockWidgetConfigComponent />
|
|
203
|
+
</TestWrapper>,
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
await waitFor(() => {
|
|
207
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
211
|
+
await act(async () => {
|
|
212
|
+
getConfigButton.click();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
await waitFor(() => {
|
|
216
|
+
expect(screen.getByTestId('error-message')).toHaveTextContent('Frontend config is loading');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should throw error when widget config is not found', async () => {
|
|
221
|
+
render(
|
|
222
|
+
<TestWrapper
|
|
223
|
+
mockNewOrgConfig={{
|
|
224
|
+
frontendConfig: {
|
|
225
|
+
widgetConfigs: {},
|
|
226
|
+
},
|
|
227
|
+
loading: false,
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
<MockWidgetConfigComponent />
|
|
231
|
+
</TestWrapper>,
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
await waitFor(() => {
|
|
235
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
239
|
+
await act(async () => {
|
|
240
|
+
getConfigButton.click();
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
await waitFor(() => {
|
|
244
|
+
expect(screen.getByTestId('error-message')).toHaveTextContent(
|
|
245
|
+
'Widget type: PromptCarouselV3 does not match widget config type: undefined',
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should throw error when widget type does not match config type', async () => {
|
|
251
|
+
// Create a mock config with wrong type for testing error handling
|
|
252
|
+
const mockWidgetConfig = {
|
|
253
|
+
widgetConfigId: 'test-config-id',
|
|
254
|
+
type: WidgetTypeV3.ChatPreviewV3, // Different type - using type assertion for test
|
|
255
|
+
} as unknown as WidgetConfigV3;
|
|
256
|
+
|
|
257
|
+
render(
|
|
258
|
+
<TestWrapper
|
|
259
|
+
mockNewOrgConfig={{
|
|
260
|
+
frontendConfig: {
|
|
261
|
+
widgetConfigs: {
|
|
262
|
+
'test-config-id': mockWidgetConfig,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
loading: false,
|
|
266
|
+
}}
|
|
267
|
+
>
|
|
268
|
+
<MockWidgetConfigComponent />
|
|
269
|
+
</TestWrapper>,
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
await waitFor(() => {
|
|
273
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
277
|
+
await act(async () => {
|
|
278
|
+
getConfigButton.click();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
await waitFor(() => {
|
|
282
|
+
expect(screen.getByTestId('error-message')).toHaveTextContent(
|
|
283
|
+
'Widget type: PromptCarouselV3 does not match widget config type: ChatPreviewV3',
|
|
284
|
+
);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('should throw error when frontendConfig is null', async () => {
|
|
289
|
+
render(
|
|
290
|
+
<TestWrapper
|
|
291
|
+
mockNewOrgConfig={{
|
|
292
|
+
frontendConfig: null,
|
|
293
|
+
loading: false,
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
<MockWidgetConfigComponent />
|
|
297
|
+
</TestWrapper>,
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
await waitFor(() => {
|
|
301
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
305
|
+
await act(async () => {
|
|
306
|
+
getConfigButton.click();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
await waitFor(() => {
|
|
310
|
+
expect(screen.getByTestId('error-message')).toHaveTextContent(
|
|
311
|
+
'Widget type: PromptCarouselV3 does not match widget config type: undefined',
|
|
312
|
+
);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
describe('isLoading State', () => {
|
|
318
|
+
it('should be true when frontend config is loading', async () => {
|
|
319
|
+
render(
|
|
320
|
+
<TestWrapper
|
|
321
|
+
mockNewOrgConfig={{
|
|
322
|
+
frontendConfig: {
|
|
323
|
+
widgetConfigs: {},
|
|
324
|
+
},
|
|
325
|
+
loading: true,
|
|
326
|
+
}}
|
|
327
|
+
>
|
|
328
|
+
<MockWidgetConfigComponent />
|
|
329
|
+
</TestWrapper>,
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
await waitFor(() => {
|
|
333
|
+
expect(screen.getByTestId('is-loading')).toHaveTextContent('true');
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('should be true when widget config is being retrieved', async () => {
|
|
338
|
+
const mockWidgetConfig: WidgetConfigV3 = {
|
|
339
|
+
widgetConfigId: 'test-config-id',
|
|
340
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
render(
|
|
344
|
+
<TestWrapper
|
|
345
|
+
mockNewOrgConfig={{
|
|
346
|
+
frontendConfig: {
|
|
347
|
+
widgetConfigs: {
|
|
348
|
+
'test-config-id': mockWidgetConfig,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
loading: false,
|
|
352
|
+
}}
|
|
353
|
+
>
|
|
354
|
+
<MockWidgetConfigComponent />
|
|
355
|
+
</TestWrapper>,
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
await waitFor(() => {
|
|
359
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
363
|
+
|
|
364
|
+
// Click button and check loading state
|
|
365
|
+
await act(async () => {
|
|
366
|
+
getConfigButton.click();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// isLoadingState should be true during the async operation
|
|
370
|
+
await waitFor(() => {
|
|
371
|
+
expect(screen.getByTestId('is-loading-state')).toHaveTextContent('false');
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('should be false when both frontend config and widget config are not loading', async () => {
|
|
376
|
+
render(
|
|
377
|
+
<TestWrapper
|
|
378
|
+
mockNewOrgConfig={{
|
|
379
|
+
frontendConfig: {
|
|
380
|
+
widgetConfigs: {},
|
|
381
|
+
},
|
|
382
|
+
loading: false,
|
|
383
|
+
}}
|
|
384
|
+
>
|
|
385
|
+
<MockWidgetConfigComponent />
|
|
386
|
+
</TestWrapper>,
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
await waitFor(() => {
|
|
390
|
+
expect(screen.getByTestId('is-loading')).toHaveTextContent('false');
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
describe('Logger Integration', () => {
|
|
396
|
+
it('should log info when retrieving widget config', async () => {
|
|
397
|
+
const logInfoSpy = vi.spyOn(Logger, 'logInfo');
|
|
398
|
+
const mockWidgetConfig: WidgetConfigV3 = {
|
|
399
|
+
widgetConfigId: 'test-config-id',
|
|
400
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
render(
|
|
404
|
+
<TestWrapper
|
|
405
|
+
mockNewOrgConfig={{
|
|
406
|
+
frontendConfig: {
|
|
407
|
+
widgetConfigs: {
|
|
408
|
+
'test-config-id': mockWidgetConfig,
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
loading: false,
|
|
412
|
+
}}
|
|
413
|
+
>
|
|
414
|
+
<MockWidgetConfigComponent />
|
|
415
|
+
</TestWrapper>,
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
await waitFor(() => {
|
|
419
|
+
expect(screen.getByTestId('widget-config-component')).toBeInTheDocument();
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
const getConfigButton = screen.getByTestId('get-config-btn');
|
|
423
|
+
await act(async () => {
|
|
424
|
+
getConfigButton.click();
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
await waitFor(() => {
|
|
428
|
+
expect(logInfoSpy).toHaveBeenCalledWith('widgetConfigContext | retrieving widget config', {
|
|
429
|
+
widgetConfigId: 'test-config-id',
|
|
430
|
+
widgetType: WidgetTypeV3.PromptCarouselV3,
|
|
431
|
+
});
|
|
432
|
+
expect(logInfoSpy).toHaveBeenCalledWith(
|
|
433
|
+
'widgetConfigContext | returning widget config response',
|
|
434
|
+
mockWidgetConfig,
|
|
435
|
+
);
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
describe('Multiple Widget Config Retrievals', () => {
|
|
441
|
+
it('should handle multiple sequential widget config retrievals', async () => {
|
|
442
|
+
const mockWidgetConfig1: WidgetConfigV3 = {
|
|
443
|
+
widgetConfigId: 'config-1',
|
|
444
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
445
|
+
};
|
|
446
|
+
const mockWidgetConfig2: WidgetConfigV3 = {
|
|
447
|
+
widgetConfigId: 'config-2',
|
|
448
|
+
type: WidgetTypeV3.PromptCarouselV3,
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const TestComponent: React.FC = () => {
|
|
452
|
+
const { getWidgetConfig } = useWidgetConfig();
|
|
453
|
+
const [config1, setConfig1] = React.useState<WidgetConfigV3 | null>(null);
|
|
454
|
+
const [config2, setConfig2] = React.useState<WidgetConfigV3 | null>(null);
|
|
455
|
+
|
|
456
|
+
const handleGetConfigs = async () => {
|
|
457
|
+
const c1 = await getWidgetConfig({
|
|
458
|
+
widgetType: WidgetTypeV3.PromptCarouselV3,
|
|
459
|
+
widgetConfigId: 'config-1',
|
|
460
|
+
});
|
|
461
|
+
setConfig1(c1);
|
|
462
|
+
|
|
463
|
+
const c2 = await getWidgetConfig({
|
|
464
|
+
widgetType: WidgetTypeV3.PromptCarouselV3,
|
|
465
|
+
widgetConfigId: 'config-2',
|
|
466
|
+
});
|
|
467
|
+
setConfig2(c2);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
return (
|
|
471
|
+
<div>
|
|
472
|
+
<div data-testid="config-1-id">{config1?.widgetConfigId || 'not-set'}</div>
|
|
473
|
+
<div data-testid="config-2-id">{config2?.widgetConfigId || 'not-set'}</div>
|
|
474
|
+
<button
|
|
475
|
+
data-testid="get-configs-btn"
|
|
476
|
+
type="button"
|
|
477
|
+
onClick={handleGetConfigs}
|
|
478
|
+
>
|
|
479
|
+
Get Configs
|
|
480
|
+
</button>
|
|
481
|
+
</div>
|
|
482
|
+
);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
render(
|
|
486
|
+
<TestWrapper
|
|
487
|
+
mockNewOrgConfig={{
|
|
488
|
+
frontendConfig: {
|
|
489
|
+
widgetConfigs: {
|
|
490
|
+
'config-1': mockWidgetConfig1,
|
|
491
|
+
'config-2': mockWidgetConfig2,
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
loading: false,
|
|
495
|
+
}}
|
|
496
|
+
>
|
|
497
|
+
<TestComponent />
|
|
498
|
+
</TestWrapper>,
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
const getConfigsButton = screen.getByTestId('get-configs-btn');
|
|
502
|
+
await act(async () => {
|
|
503
|
+
getConfigsButton.click();
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
await waitFor(() => {
|
|
507
|
+
expect(screen.getByTestId('config-1-id')).toHaveTextContent('config-1');
|
|
508
|
+
expect(screen.getByTestId('config-2-id')).toHaveTextContent('config-2');
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './widgetConfigContext';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ReactNode, createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
2
|
+
import Logger from 'src/application/logging/logger';
|
|
3
|
+
import { useNewOrgConfig } from 'src/hooks/NewOrgConfig';
|
|
4
|
+
import { WidgetConfigV3, WidgetTypeV3 } from '../typesV3';
|
|
5
|
+
|
|
6
|
+
interface WidgetConfigRequest {
|
|
7
|
+
widgetType: WidgetTypeV3;
|
|
8
|
+
widgetConfigId: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface WidgetConfigContextType {
|
|
12
|
+
getWidgetConfig: (request: WidgetConfigRequest) => Promise<WidgetConfigV3>;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const WidgetConfigContext = createContext<WidgetConfigContextType | undefined>(undefined);
|
|
17
|
+
|
|
18
|
+
export const WidgetConfigProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
|
|
19
|
+
const { frontendConfig, loading: isFrontendConfigLoading } = useNewOrgConfig();
|
|
20
|
+
const [isLoadingWidgetConfig, setIsLoadingWidgetConfig] = useState(false);
|
|
21
|
+
|
|
22
|
+
const getWidgetConfig = useCallback(
|
|
23
|
+
async (request: WidgetConfigRequest): Promise<WidgetConfigV3> => {
|
|
24
|
+
setIsLoadingWidgetConfig(true);
|
|
25
|
+
Logger.logInfo('widgetConfigContext | retrieving widget config', {
|
|
26
|
+
widgetConfigId: request.widgetConfigId,
|
|
27
|
+
widgetType: request.widgetType,
|
|
28
|
+
});
|
|
29
|
+
if (isFrontendConfigLoading) {
|
|
30
|
+
setIsLoadingWidgetConfig(false);
|
|
31
|
+
throw new Error('Frontend config is loading');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { widgetConfigId, widgetType } = request;
|
|
35
|
+
const response = frontendConfig?.widgetConfigs?.[widgetConfigId];
|
|
36
|
+
Logger.logInfo('widgetConfigContext | returning widget config response', response);
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
[
|
|
40
|
+
WidgetTypeV3.SocialProofV3,
|
|
41
|
+
WidgetTypeV3.ChatPreviewV3,
|
|
42
|
+
WidgetTypeV3.ChatPreviewComparisonV3,
|
|
43
|
+
WidgetTypeV3.ChatPreviewLoadingV3,
|
|
44
|
+
].includes(widgetType)
|
|
45
|
+
) {
|
|
46
|
+
if (response?.type !== WidgetTypeV3.SocialProofV3) {
|
|
47
|
+
setIsLoadingWidgetConfig(false);
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Widget type: ${widgetType} does not match widget config type: ${response?.type}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
} else if (response?.type !== widgetType) {
|
|
53
|
+
setIsLoadingWidgetConfig(false);
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Widget type: ${widgetType} does not match widget config type: ${response?.type}`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!response) {
|
|
60
|
+
setIsLoadingWidgetConfig(false);
|
|
61
|
+
throw new Error(
|
|
62
|
+
`No widget config response found for widget type: ${request.widgetType} and widget config id: ${request.widgetConfigId}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
setIsLoadingWidgetConfig(false);
|
|
66
|
+
return response;
|
|
67
|
+
},
|
|
68
|
+
[frontendConfig, isFrontendConfigLoading],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const isLoading = isFrontendConfigLoading || isLoadingWidgetConfig;
|
|
72
|
+
|
|
73
|
+
const value = useMemo(() => ({ getWidgetConfig, isLoading }), [getWidgetConfig, isLoading]);
|
|
74
|
+
|
|
75
|
+
return <WidgetConfigContext.Provider value={value}>{children}</WidgetConfigContext.Provider>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const useWidgetConfig = () => {
|
|
79
|
+
const context = useContext(WidgetConfigContext);
|
|
80
|
+
if (!context) {
|
|
81
|
+
throw new Error('useWidgetConfig must be used within a WidgetConfigProvider');
|
|
82
|
+
}
|
|
83
|
+
return context;
|
|
84
|
+
};
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
contextSourceAtom,
|
|
7
7
|
envAtom as enviveEnvAtom,
|
|
8
8
|
orgShortNameAtom as enviveOrgShortNameAtom,
|
|
9
|
+
orgIdAtom,
|
|
9
10
|
} from 'src/atoms/envive/enviveConfig';
|
|
10
11
|
import { chatIdAtom, userIdAtom } from 'src/atoms/app/index';
|
|
11
|
-
import { useOrgId } from 'src/hooks/GraphQLConfig/useGraphQLConfig';
|
|
12
12
|
|
|
13
13
|
export interface AppDetails {
|
|
14
14
|
orgId: string;
|
|
@@ -21,7 +21,7 @@ export interface AppDetails {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const useAppDetails = (): AppDetails => {
|
|
24
|
-
const
|
|
24
|
+
const fetchedOrgId = useAtomValue(orgIdAtom);
|
|
25
25
|
const orgId = fetchedOrgId ?? ''; // Provide a default empty string if undefined
|
|
26
26
|
|
|
27
27
|
const orgShortName = useAtomValue(enviveOrgShortNameAtom) ?? 'spiffy-ai';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { useAtom } from 'jotai';
|
|
2
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { orgIdAtom } from 'src/atoms/org/graphqlConfig';
|
|
4
2
|
import { GraphQlConfigValues, useGraphQLClient } from 'src/contexts/graphqlContext/graphqlContext';
|
|
5
3
|
|
|
6
4
|
export const useColorsAndFrontendConfig = () => {
|
|
@@ -32,31 +30,34 @@ export const useColorsAndFrontendConfig = () => {
|
|
|
32
30
|
return { data, loading, error, refetch: fetchConfig };
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
export const
|
|
36
|
-
const {
|
|
37
|
-
const [
|
|
33
|
+
export const useUIConfig = () => {
|
|
34
|
+
const { getConfig, isReady } = useGraphQLClient();
|
|
35
|
+
const [data, setData] = useState<GraphQlConfigValues>({});
|
|
38
36
|
const [loading, setLoading] = useState(false);
|
|
39
37
|
const [error, setError] = useState<Error | null>(null);
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
const fetchConfig = useCallback(async () => {
|
|
42
40
|
if (!isReady) return;
|
|
41
|
+
if (loading) return;
|
|
42
|
+
if (Object.keys(data).length > 0) return;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
setError(null);
|
|
44
|
+
setLoading(true);
|
|
45
|
+
setError(null);
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
try {
|
|
48
|
+
const result = await getConfig();
|
|
49
|
+
setData(result);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
52
|
+
} finally {
|
|
53
|
+
setLoading(false);
|
|
54
|
+
}
|
|
55
|
+
}, [data, getConfig, isReady, loading]);
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
console.log('====== useUIConfig hook ======', isReady, loading, data, error);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
fetchConfig();
|
|
60
|
+
}, [fetchConfig]);
|
|
60
61
|
|
|
61
|
-
return {
|
|
62
|
+
return { data, loading, error, refetch: fetchConfig };
|
|
62
63
|
};
|