@envive-ai/react-hooks 0.3.4 → 0.3.6
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/application/models/chatElementDisplayLocationV3.cjs +7 -1
- package/dist/application/models/chatElementDisplayLocationV3.d.cts +7 -1
- package/dist/application/models/chatElementDisplayLocationV3.d.ts +7 -1
- package/dist/application/models/chatElementDisplayLocationV3.js +7 -1
- package/dist/application/models/featureGates.cjs +6 -2
- package/dist/application/models/featureGates.d.cts +6 -2
- package/dist/application/models/featureGates.d.ts +6 -2
- package/dist/application/models/featureGates.js +6 -2
- package/dist/application/models/guards/api/isApiPDPEventAttributes.cjs +2 -2
- package/dist/application/models/guards/api/isApiPDPEventAttributes.js +2 -2
- package/dist/application/utils/elementObserver.d.cts +2 -2
- package/dist/application/utils/elementObserver.d.ts +2 -2
- package/dist/atoms/app/index.cjs +3 -1
- package/dist/atoms/app/index.d.cts +3 -3
- package/dist/atoms/app/index.d.ts +9 -9
- package/dist/atoms/app/index.js +3 -3
- package/dist/atoms/app/variant.cjs +2 -1
- package/dist/atoms/app/variant.d.cts +17 -9
- package/dist/atoms/app/variant.d.ts +17 -9
- package/dist/atoms/app/variant.js +2 -2
- package/dist/atoms/chat/chatState.d.cts +18 -18
- package/dist/atoms/chat/chatState.d.ts +18 -18
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.d.cts +3 -3
- package/dist/atoms/chat/index.d.ts +1 -1
- package/dist/atoms/chat/lastMessage.d.cts +2 -2
- package/dist/atoms/chat/lastMessage.d.ts +2 -2
- 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.d.cts +3 -3
- package/dist/atoms/chat/replies.d.ts +3 -3
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/envive/enviveConfig.cjs +1 -11
- package/dist/atoms/envive/enviveConfig.js +1 -11
- package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
- package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
- package/dist/atoms/org/customerService.d.cts +6 -6
- package/dist/atoms/org/customerService.d.ts +6 -6
- package/dist/atoms/org/graphqlConfig.d.cts +4 -4
- package/dist/atoms/org/graphqlConfig.d.ts +4 -4
- 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.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/productRetrievalAPI.cjs +1 -7
- package/dist/atoms/search/productRetrievalAPI.js +1 -7
- package/dist/atoms/search/productRetrievalAdapter.cjs +4 -4
- package/dist/atoms/search/productRetrievalAdapter.js +4 -4
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/searchAPI.d.ts +13 -13
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
- package/dist/contexts/enviveContext/enviveContext.cjs +21 -15
- package/dist/contexts/enviveContext/enviveContext.d.cts +4 -1
- package/dist/contexts/enviveContext/enviveContext.d.ts +4 -1
- package/dist/contexts/enviveContext/enviveContext.js +21 -15
- package/dist/contexts/graphqlContext/graphqlContext.cjs +86 -5
- package/dist/contexts/graphqlContext/graphqlContext.js +86 -5
- package/dist/contexts/graphqlContext/mockV3Config.cjs +56 -14
- package/dist/contexts/graphqlContext/mockV3Config.js +56 -14
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +33 -20
- package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +2 -2
- package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +2 -2
- package/dist/contexts/hardcopyContext/hardcopyContext.js +33 -20
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +11 -9
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.d.cts +2 -1
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.d.ts +2 -1
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +11 -9
- package/dist/contexts/pageContext/index.cjs +1 -0
- package/dist/contexts/pageContext/index.d.cts +2 -2
- package/dist/contexts/pageContext/index.d.ts +2 -2
- package/dist/contexts/pageContext/index.js +2 -2
- package/dist/contexts/pageContext/mapping.cjs +91 -1
- package/dist/contexts/pageContext/mapping.d.cts +5 -2
- package/dist/contexts/pageContext/mapping.d.ts +5 -2
- package/dist/contexts/pageContext/mapping.js +90 -2
- package/dist/contexts/pageContext/pageContext.cjs +33 -5
- package/dist/contexts/pageContext/pageContext.d.cts +2 -1
- package/dist/contexts/pageContext/pageContext.d.ts +2 -1
- package/dist/contexts/pageContext/pageContext.js +34 -6
- package/dist/contexts/pageContext/types.d.cts +2 -2
- package/dist/contexts/pageContext/types.d.ts +2 -2
- package/dist/contexts/salesAgentContext/chatAPI.cjs +4 -1
- package/dist/contexts/salesAgentContext/chatAPI.d.cts +4 -1
- package/dist/contexts/salesAgentContext/chatAPI.d.ts +4 -1
- package/dist/contexts/salesAgentContext/chatAPI.js +4 -1
- package/dist/contexts/salesAgentContext/index.d.cts +2 -2
- package/dist/contexts/salesAgentContext/index.d.ts +2 -2
- package/dist/contexts/salesAgentContext/salesAgentContext.cjs +4 -2
- package/dist/contexts/salesAgentContext/salesAgentContext.d.cts +2 -2
- package/dist/contexts/salesAgentContext/salesAgentContext.d.ts +2 -2
- package/dist/contexts/salesAgentContext/salesAgentContext.js +4 -2
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +6 -3
- package/dist/contexts/salesAgentContext/salesAgentService.js +7 -4
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.ts +2 -2
- package/dist/contexts/types.d.cts +1 -1
- package/dist/contexts/types.d.ts +1 -1
- package/dist/contexts/typesV3.cjs +20 -17
- package/dist/contexts/typesV3.d.cts +39 -12
- package/dist/contexts/typesV3.d.ts +39 -12
- package/dist/contexts/typesV3.js +5 -2
- package/dist/hooks/ChatToggle/useChatToggle.cjs +1 -1
- package/dist/hooks/ChatToggle/useChatToggle.d.cts +5 -5
- package/dist/hooks/ChatToggle/useChatToggle.d.ts +5 -5
- package/dist/hooks/ChatToggle/useChatToggle.js +1 -1
- package/dist/hooks/ElementObserver/useElementObserver.cjs +10 -10
- package/dist/hooks/ElementObserver/useElementObserver.js +10 -10
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.ts +2 -2
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.d.ts +1 -1
- package/dist/merchants/domInsertion.cjs +1 -1
- package/dist/merchants/domInsertion.d.cts +1 -1
- package/dist/merchants/domInsertion.d.ts +1 -1
- package/dist/merchants/domInsertion.js +1 -1
- package/dist/packages/components-v3/dist/ChatHeader/ChatHeader.cjs +2 -0
- package/dist/packages/components-v3/dist/ChatHeader/ChatHeader.js +4 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/CloseButton.cjs +16 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/CloseButton.js +17 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Handle.cjs +6 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Handle.js +8 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Layout.cjs +4 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Layout.js +6 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Logo.cjs +3 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Logo.js +5 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Toggle.cjs +7 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/Toggle.js +9 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/ToggleItem.cjs +6 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/ToggleItem.js +8 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/index.cjs +6 -0
- package/dist/packages/components-v3/dist/ChatHeader/components/index.js +8 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetCloseButtonProperties.cjs +22 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetCloseButtonProperties.js +23 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetHandleProperties.cjs +58 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetHandleProperties.js +59 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetLayoutProperties.cjs +8 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetLayoutProperties.js +9 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetToggleOptionProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetToggleOptionProperties.js +3 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetToggleProperties.cjs +12 -0
- package/dist/packages/components-v3/dist/ChatHeader/hooks/useGetToggleProperties.js +13 -0
- package/dist/packages/components-v3/dist/ChatHeader/index.cjs +2 -0
- package/dist/packages/components-v3/dist/ChatHeader/index.js +4 -0
- package/dist/packages/components-v3/dist/ChatHeader/types/index.cjs +11 -0
- package/dist/packages/components-v3/dist/ChatHeader/types/index.js +10 -0
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.cjs +1 -1
- package/dist/packages/components-v3/dist/ImageGallery/components/Layout.js +1 -1
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.cjs +1 -1
- package/dist/packages/components-v3/dist/PromptButton/PromptButton.js +1 -1
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.cjs +1 -1
- package/dist/packages/components-v3/dist/PromptButton/components/Layout.js +1 -1
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.cjs +1 -1
- package/dist/packages/components-v3/dist/PromptButton/hooks/useGetLayoutBaseProperties.js +1 -1
- package/dist/packages/components-v3/dist/Tokens/index.cjs +11 -0
- package/dist/packages/components-v3/dist/Tokens/index.js +13 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/WelcomeMessage.cjs +2 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/WelcomeMessage.js +4 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Container.cjs +14 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Container.js +15 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/SparkleIcon.cjs +3 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/SparkleIcon.js +5 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Text.cjs +3 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Text.js +5 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Title.cjs +3 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/Title.js +5 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/index.cjs +4 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/components/index.js +6 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/hooks/useGetContainerProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/hooks/useGetContainerProperties.js +3 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/hooks/useGetSparkleIconProperties.cjs +1 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/hooks/useGetSparkleIconProperties.js +3 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/index.cjs +2 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/index.js +4 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/types/types.cjs +14 -0
- package/dist/packages/components-v3/dist/WelcomeMessage/types/types.js +14 -0
- package/dist/packages/components-v3/dist/src/models/colorsConfig.cjs +26 -0
- package/dist/packages/components-v3/dist/src/models/colorsConfig.js +25 -0
- package/dist/packages/components-v3/dist/tokens/aspectRatio/aspectRatio.cjs +16 -0
- package/dist/packages/components-v3/dist/tokens/aspectRatio/aspectRatio.js +17 -0
- package/dist/packages/components-v3/dist/tokens/breakpoints/breakpoints.cjs +25 -0
- package/dist/packages/components-v3/dist/tokens/breakpoints/breakpoints.js +23 -0
- package/dist/packages/components-v3/dist/tokens/colors/colors.cjs +51 -0
- package/dist/packages/components-v3/dist/tokens/colors/colors.js +51 -0
- package/dist/packages/components-v3/dist/tokens/radius/radius.cjs +64 -0
- package/dist/packages/components-v3/dist/tokens/radius/radius.js +65 -0
- package/dist/packages/components-v3/dist/tokens/theme/theme.cjs +13 -0
- package/dist/packages/components-v3/dist/tokens/theme/theme.js +12 -0
- package/dist/packages/components-v3/dist/tokens/typography/fontFamily.cjs +25 -0
- package/dist/packages/components-v3/dist/tokens/typography/fontFamily.js +25 -0
- package/dist/packages/components-v3/dist/tokens/typography/fontSize.cjs +37 -0
- package/dist/packages/components-v3/dist/tokens/typography/fontSize.js +38 -0
- package/dist/packages/components-v3/dist/tokens/typography/fontWeight.cjs +17 -0
- package/dist/packages/components-v3/dist/tokens/typography/fontWeight.js +18 -0
- package/dist/packages/components-v3/dist/tokens/typography/letterSpacing.cjs +15 -0
- package/dist/packages/components-v3/dist/tokens/typography/letterSpacing.js +16 -0
- package/dist/packages/components-v3/dist/tokens/typography/lineHeight.cjs +31 -0
- package/dist/packages/components-v3/dist/tokens/typography/lineHeight.js +32 -0
- package/dist/packages/components-v3/dist/tokens/typography/typography.cjs +5 -0
- package/dist/packages/components-v3/dist/tokens/typography/typography.js +7 -0
- package/dist/packages/components-v3/dist/tokens/utils.cjs +7 -0
- package/dist/packages/components-v3/dist/tokens/utils.js +6 -0
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.cjs +2 -2
- package/dist/packages/components-v3/dist/utils/useResponsiveValue.js +2 -2
- package/dist/packages/icons/dist/IconCloseRounded.cjs +22 -0
- package/dist/packages/icons/dist/IconCloseRounded.js +22 -0
- package/dist/packages/icons/dist/IconCloseSharp.cjs +31 -0
- package/dist/packages/icons/dist/IconCloseSharp.js +31 -0
- package/dist/packages/icons/dist/IconCloseTransparent.cjs +24 -0
- package/dist/packages/icons/dist/IconCloseTransparent.js +24 -0
- package/dist/packages/icons/dist/Sparkles.cjs +8 -0
- package/dist/packages/icons/dist/Sparkles.js +9 -0
- package/dist/types/customerService.cjs +20 -0
- package/dist/types/customerService.js +19 -0
- package/package.json +1 -5
- package/src/application/models/chatElementDisplayLocationV3.ts +6 -0
- package/src/application/models/featureGates.ts +6 -1
- package/src/application/models/guards/api/isApiPDPEventAttributes.ts +5 -1
- package/src/atoms/app/index.ts +7 -1
- package/src/atoms/app/variant.ts +3 -2
- package/src/atoms/envive/enviveConfig.ts +0 -11
- package/src/atoms/search/productRetrievalAPI.ts +0 -8
- package/src/atoms/search/productRetrievalAdapter.ts +6 -10
- package/src/contexts/amplitudeContext/__tests__/amplitudeContext.test.tsx +0 -1
- package/src/contexts/enviveContext/enviveContext.tsx +9 -5
- package/src/contexts/graphqlContext/graphqlContext.tsx +128 -9
- package/src/contexts/graphqlContext/mockV3Config.ts +53 -12
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +29 -13
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +234 -0
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +15 -8
- package/src/contexts/pageContext/__tests__/pageContext.test.tsx +119 -69
- package/src/contexts/pageContext/mapping.ts +184 -2
- package/src/contexts/pageContext/pageContext.tsx +30 -5
- package/src/contexts/pageContext/types.ts +1 -2
- package/src/contexts/salesAgentContext/chatAPI.ts +9 -0
- package/src/contexts/salesAgentContext/salesAgentContext.tsx +10 -3
- package/src/contexts/salesAgentContext/salesAgentService.ts +13 -1
- package/src/contexts/typesV3.ts +52 -20
- package/src/contexts/uiConfigContext/__tests__/uiConfigContext.test.tsx +14 -6
- package/src/contexts/widgetConfigContext/__tests__/widgetConfigContext.test.tsx +1 -1
- package/src/hooks/ChatToggle/useChatToggle.ts +4 -4
- package/src/hooks/ElementObserver/useElementObserver.ts +9 -9
- package/src/merchants/domInsertion.ts +0 -16
- package/dist/hooks/ChatToggleAnalytics/index.cjs +0 -3
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +0 -2
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +0 -2
- package/dist/hooks/ChatToggleAnalytics/index.js +0 -3
- package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.cjs +0 -19
- package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.d.cts +0 -9
- package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.d.ts +0 -9
- package/dist/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -18
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.cjs +0 -25
- package/dist/packages/components-v3/dist/packages/components-v3/tokens/breakpoints/breakpoints.js +0 -23
- package/src/application/utils/cdnUtils.ts +0 -8
- package/src/config/divIds.ts +0 -31
- package/src/config/locators/components/chat/entrypoints.ts +0 -13
- package/src/config/locators/components/chat/preview.ts +0 -12
- package/src/config/locators/components/report-issue.ts +0 -21
- package/src/config/socialProofClasses.ts +0 -12
- package/src/events/registerAnalyticsListeners.ts +0 -44
- package/src/hooks/ChatToggleAnalytics/index.ts +0 -1
- package/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.ts +0 -15
- package/src/types/FilterAttribute.ts +0 -32
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { ProductRetrievalParams, ProductRetrievalResult } from './types';
|
|
2
2
|
|
|
3
3
|
// This will be set by the ProductRetrievalProvider when it initializes
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const productRetrievalAdapter: {
|
|
5
|
+
fn: ((params: ProductRetrievalParams) => Promise<ProductRetrievalResult>) | null;
|
|
6
|
+
} = { fn: null };
|
|
7
7
|
|
|
8
8
|
export const setProductRetrievalFunction = (
|
|
9
9
|
fn: (params: ProductRetrievalParams) => Promise<ProductRetrievalResult>,
|
|
10
10
|
) => {
|
|
11
|
-
|
|
11
|
+
productRetrievalAdapter.fn = fn;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const getProductRetrievalFunction = () => {
|
|
15
|
-
if (!
|
|
15
|
+
if (!productRetrievalAdapter.fn) {
|
|
16
16
|
throw new Error(
|
|
17
17
|
'Product retrieval function not initialized. Make sure ProductRetrievalProvider is mounted.',
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const clearProductRetrievalFunction = () => {
|
|
24
|
-
productRetrievalFunction = null;
|
|
20
|
+
return productRetrievalAdapter.fn;
|
|
25
21
|
};
|
|
@@ -8,7 +8,7 @@ import { AmplitudeProvider } from '../amplitudeContext';
|
|
|
8
8
|
import { EnviveConfigProvider } from '../enviveConfigContext';
|
|
9
9
|
import { EnviveCssProvider } from '../enviveCssContext';
|
|
10
10
|
import { FeatureFlagService, FeatureFlagServiceProvider } from '../featureFlagServiceContext';
|
|
11
|
-
import { GraphQLProvider } from '../graphqlContext';
|
|
11
|
+
import { GraphQlConfigValues, GraphQLProvider } from '../graphqlContext';
|
|
12
12
|
import { LocalStorageProvider } from '../localStorageContext';
|
|
13
13
|
import { NewOrgConfigProvider } from '../newOrgConfigContext';
|
|
14
14
|
import { UserIdentityProvider } from '../userIdentityContext';
|
|
@@ -50,6 +50,8 @@ interface EnviveProviderProps extends AgentWrapperProps {
|
|
|
50
50
|
amplitudeService?: AmplitudeService;
|
|
51
51
|
mockV3ConfigToDeprecatedConfig?: boolean;
|
|
52
52
|
requestV3Config?: boolean;
|
|
53
|
+
previewMode?: boolean;
|
|
54
|
+
overrideConfig?: GraphQlConfigValues;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const SearchAgentWrapper: React.FC<AgentWrapperProps> = ({ children, enabledAgents }) => {
|
|
@@ -72,6 +74,8 @@ const SalesAgentWrapper: React.FC<AgentWrapperProps> = ({ children, enabledAgent
|
|
|
72
74
|
|
|
73
75
|
export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
74
76
|
children,
|
|
77
|
+
previewMode = false,
|
|
78
|
+
overrideConfig,
|
|
75
79
|
enabledAgents,
|
|
76
80
|
enviveConfigService: inputEnviveConfigService,
|
|
77
81
|
featureFlagService: inputFeatureFlagService,
|
|
@@ -107,8 +111,8 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
107
111
|
() => ({
|
|
108
112
|
...config,
|
|
109
113
|
featureGates: enviveServiceConfig?.gates || [],
|
|
110
|
-
orgShortName: enviveServiceConfig?.org
|
|
111
|
-
orgId: enviveServiceConfig?.org
|
|
114
|
+
orgShortName: enviveServiceConfig?.org?.org?.short_name || '',
|
|
115
|
+
orgId: enviveServiceConfig?.org?.org?.id || '',
|
|
112
116
|
}),
|
|
113
117
|
[config, enviveServiceConfig],
|
|
114
118
|
);
|
|
@@ -131,12 +135,12 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
131
135
|
mockV3ConfigToDeprecatedConfig={mockV3ConfigToDeprecatedConfig}
|
|
132
136
|
requestV3Config={requestV3Config}
|
|
133
137
|
>
|
|
134
|
-
<NewOrgConfigProvider>
|
|
138
|
+
<NewOrgConfigProvider overrideConfig={overrideConfig}>
|
|
135
139
|
<LocalStorageProvider>
|
|
136
140
|
<FeatureFlagServiceProvider featureFlagService={featureFlagService}>
|
|
137
141
|
<UserIdentityProvider>
|
|
138
142
|
<AmplitudeProvider externalAmplitudeService={inputAmplitudeService}>
|
|
139
|
-
<PageProvider>
|
|
143
|
+
<PageProvider previewMode={previewMode}>
|
|
140
144
|
<UiConfigProvider>
|
|
141
145
|
<WidgetConfigProvider>
|
|
142
146
|
<HardcopyProvider>
|
|
@@ -20,8 +20,13 @@ import {
|
|
|
20
20
|
import { FrontendConfigV3 } from 'src/application/models/frontendConfigV3';
|
|
21
21
|
import { ColorMappingV3 } from 'src/application/models/colorsConfigV3';
|
|
22
22
|
import { mockV3ColorsConfig, mockV3FrontendConfig } from './mockV3Config';
|
|
23
|
-
import { ConfigVersionEnum, WidgetConfigV3 } from '../typesV3';
|
|
24
|
-
import {
|
|
23
|
+
import { ConfigVersionEnum, Position, WidgetConfigV3 } from '../typesV3';
|
|
24
|
+
import {
|
|
25
|
+
OrgPageConfig,
|
|
26
|
+
PageVariantConfig,
|
|
27
|
+
PageVariantTestType,
|
|
28
|
+
WidgetMountingConfig,
|
|
29
|
+
} from '../types';
|
|
25
30
|
|
|
26
31
|
interface BaseMeConfigQueryResponse {
|
|
27
32
|
me: {
|
|
@@ -64,6 +69,7 @@ const colorsAndFrontendConfigQuery = () => `
|
|
|
64
69
|
getProductsConfigByVersion(version: $version) {
|
|
65
70
|
frontend { values }
|
|
66
71
|
colors { values }
|
|
72
|
+
v_three_config { values }
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -75,6 +81,114 @@ type GraphQLProviderProps = {
|
|
|
75
81
|
mockV3ConfigToDeprecatedConfig?: boolean;
|
|
76
82
|
};
|
|
77
83
|
|
|
84
|
+
const DEFAULT_PAGE_VARIANTS: PageVariantConfig[] = [
|
|
85
|
+
{
|
|
86
|
+
variantId: 'plp',
|
|
87
|
+
variantType: 'plp',
|
|
88
|
+
plpIdExtractor: 'url-resolver-plp-id',
|
|
89
|
+
widgetMounting: [],
|
|
90
|
+
variantTests: [
|
|
91
|
+
{
|
|
92
|
+
testType: PageVariantTestType.UrlResolver,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
variantId: 'pdp',
|
|
98
|
+
variantType: 'pdp',
|
|
99
|
+
productIdExtractor: 'url-resolver-product-id',
|
|
100
|
+
widgetMounting: [],
|
|
101
|
+
variantTests: [
|
|
102
|
+
{
|
|
103
|
+
testType: PageVariantTestType.UrlResolver,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
const mapPositionToCamelCase = (position: string): Position => {
|
|
110
|
+
if (position === 'bottom-left') {
|
|
111
|
+
return 'bottomLeft';
|
|
112
|
+
}
|
|
113
|
+
if (position === 'middle-left') {
|
|
114
|
+
return 'middleLeft';
|
|
115
|
+
}
|
|
116
|
+
if (position === 'middle-right') {
|
|
117
|
+
return 'middleRight';
|
|
118
|
+
}
|
|
119
|
+
if (position === 'bottom-right') {
|
|
120
|
+
return 'bottomRight';
|
|
121
|
+
}
|
|
122
|
+
throw new Error(`Invalid position: ${position}`);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* This function is used to do some additional cleanup of the v3 frontend config to ensure that the config is in the correct format.
|
|
127
|
+
*/
|
|
128
|
+
const v3FrontendConfigCleanup = (
|
|
129
|
+
v3RootConfig: FrontendConfigV3Response,
|
|
130
|
+
): FrontendConfigV3Response => {
|
|
131
|
+
const { uiConfigs } = v3RootConfig;
|
|
132
|
+
if (!uiConfigs) {
|
|
133
|
+
return v3RootConfig;
|
|
134
|
+
}
|
|
135
|
+
const { floatingButton, lookAndFeel } = uiConfigs as any;
|
|
136
|
+
if (!floatingButton || !lookAndFeel) {
|
|
137
|
+
return v3RootConfig;
|
|
138
|
+
}
|
|
139
|
+
const { fontSize, lineHeight } = lookAndFeel.typography as any;
|
|
140
|
+
return {
|
|
141
|
+
...v3RootConfig,
|
|
142
|
+
uiConfigs: {
|
|
143
|
+
...uiConfigs,
|
|
144
|
+
floatingButton: {
|
|
145
|
+
...floatingButton,
|
|
146
|
+
position: mapPositionToCamelCase(
|
|
147
|
+
v3RootConfig.uiConfigs?.floatingButton?.position as string,
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
lookAndFeel: {
|
|
151
|
+
...lookAndFeel,
|
|
152
|
+
chatHeaderLogoDarkSrc: lookAndFeel.chatHeaderLogoDarkSrc || lookAndFeel.chatHeaderLogoSrc,
|
|
153
|
+
chatHeaderLogoLightSrc: lookAndFeel.chatHeaderLogoLightSrc || lookAndFeel.chatHeaderLogoSrc,
|
|
154
|
+
typography: {
|
|
155
|
+
...lookAndFeel.typography,
|
|
156
|
+
fontSize: {
|
|
157
|
+
// The fonts sizes are defined differently in the backend config
|
|
158
|
+
// so we need to map the values to the correct camel case keys
|
|
159
|
+
b1: fontSize?.b1 || fontSize?.b_1,
|
|
160
|
+
b2: fontSize?.b2 || fontSize?.b_2,
|
|
161
|
+
b3: fontSize?.b3 || fontSize?.b_3,
|
|
162
|
+
b4: fontSize?.b4 || fontSize?.b_4,
|
|
163
|
+
b5: fontSize?.b5 || fontSize?.b_5,
|
|
164
|
+
h1: fontSize?.h1 || fontSize?.h_1,
|
|
165
|
+
h2: fontSize?.h2 || fontSize?.h_2,
|
|
166
|
+
h3: fontSize?.h3 || fontSize?.h_3,
|
|
167
|
+
l1: fontSize?.l1 || fontSize?.l_1,
|
|
168
|
+
l2: fontSize?.l2 || fontSize?.l_2,
|
|
169
|
+
t1: fontSize?.t1 || fontSize?.t_1,
|
|
170
|
+
t2: fontSize?.t2 || fontSize?.t_2,
|
|
171
|
+
t3: fontSize?.t3 || fontSize?.t_3,
|
|
172
|
+
},
|
|
173
|
+
lineHeight: {
|
|
174
|
+
...lookAndFeel.typography.lineHeight,
|
|
175
|
+
'114': lineHeight?.lh_114 || lineHeight?.[114],
|
|
176
|
+
'116': lineHeight?.lh_116 || lineHeight?.[116],
|
|
177
|
+
'118': lineHeight?.lh_118 || lineHeight?.[118],
|
|
178
|
+
'120': lineHeight?.lh_120 || lineHeight?.[120],
|
|
179
|
+
'124': lineHeight?.lh_124 || lineHeight?.[124],
|
|
180
|
+
'128': lineHeight?.lh_128 || lineHeight?.[128],
|
|
181
|
+
'130': lineHeight?.lh_130 || lineHeight?.[130],
|
|
182
|
+
'133': lineHeight?.lh_133 || lineHeight?.[133],
|
|
183
|
+
'140': lineHeight?.lh_140 || lineHeight?.[140],
|
|
184
|
+
'148': lineHeight?.lh_148 || lineHeight?.[148],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
78
192
|
export const GraphQLProvider = ({
|
|
79
193
|
children,
|
|
80
194
|
requestV3Config = false,
|
|
@@ -127,10 +241,11 @@ export const GraphQLProvider = ({
|
|
|
127
241
|
const response = await executeQuery(query);
|
|
128
242
|
|
|
129
243
|
// We may update this root config location in the future
|
|
130
|
-
const v3RootConfig =
|
|
131
|
-
response.me.getProductsConfigByVersion?.frontend?.values?.ui_configs?.v_three_config;
|
|
244
|
+
const v3RootConfig = response.me.getProductsConfigByVersion?.v_three_config?.values;
|
|
132
245
|
|
|
133
|
-
const v3FrontendConfig =
|
|
246
|
+
const v3FrontendConfig = v3FrontendConfigCleanup(
|
|
247
|
+
transformSnakeToCamel(v3RootConfig) as FrontendConfigV3Response,
|
|
248
|
+
);
|
|
134
249
|
|
|
135
250
|
const v3MountingConfigsArray = (transformSnakeToCamel(v3RootConfig?.mounting_configs) ??
|
|
136
251
|
[]) as unknown as { key: string; config: WidgetMountingConfig }[];
|
|
@@ -151,9 +266,9 @@ export const GraphQLProvider = ({
|
|
|
151
266
|
{ widgetConfigId, ...rest } as WidgetConfigV3,
|
|
152
267
|
]),
|
|
153
268
|
) as Record<string, WidgetConfigV3>;
|
|
154
|
-
const v3pageVariants = v3RootConfig?.page_variants
|
|
155
|
-
validateAndTransformPageVariants
|
|
156
|
-
|
|
269
|
+
const v3pageVariants: PageVariantConfig[] = Array.isArray(v3RootConfig?.page_variants)
|
|
270
|
+
? v3RootConfig?.page_variants.map(validateAndTransformPageVariants)
|
|
271
|
+
: DEFAULT_PAGE_VARIANTS;
|
|
157
272
|
|
|
158
273
|
const v3ColorsConfig = transformSnakeToCamel(v3RootConfig?.colors?.values);
|
|
159
274
|
|
|
@@ -172,7 +287,11 @@ export const GraphQLProvider = ({
|
|
|
172
287
|
|
|
173
288
|
return {
|
|
174
289
|
colorsConfig: v3ColorsConfig as ColorsConfigV3Response,
|
|
175
|
-
frontendConfig:
|
|
290
|
+
frontendConfig: {
|
|
291
|
+
...(v3FrontendConfig as FrontendConfigV3Response),
|
|
292
|
+
// Need to replace the automatic widget configs with the object based ones
|
|
293
|
+
widgetConfigs: v3WidgetConfigs,
|
|
294
|
+
},
|
|
176
295
|
orgPageConfig: {
|
|
177
296
|
pageVariants: v3pageVariants,
|
|
178
297
|
widgetConfigs: v3WidgetConfigs,
|
|
@@ -3,8 +3,13 @@ import { ColorMappingV3, ColorNames, colorVar } from 'src/application/models/col
|
|
|
3
3
|
import { CamelCasedPropertiesDeep } from 'src/application/models';
|
|
4
4
|
import { ImageGalleryLayout } from '@envive-ai/react-toolkit-v3/ImageGallery';
|
|
5
5
|
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton';
|
|
6
|
-
import {
|
|
6
|
+
import { AnimationSpeed, PromptCarouselRows } from '@envive-ai/react-toolkit-v3/PromptCarousel';
|
|
7
7
|
import { WidgetWrapperVariant } from '@envive-ai/react-toolkit-v3/WidgetWrapper';
|
|
8
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
9
|
+
import { ChatHeaderVariant } from '@envive-ai/react-toolkit-v3/ChatHeader';
|
|
10
|
+
import { SparkleIconColor } from '@envive-ai/react-toolkit-v3/WelcomeMessage';
|
|
11
|
+
|
|
12
|
+
import { CustomerServiceType } from 'src/types/customerService';
|
|
8
13
|
import { ConfigVersionEnum, SocialProofWidgetKind, WidgetTypeV3 } from '../typesV3';
|
|
9
14
|
|
|
10
15
|
const mockImages = [
|
|
@@ -49,13 +54,14 @@ export const mockV3FrontendConfig: FrontendConfigV3 = {
|
|
|
49
54
|
version: ConfigVersionEnum.V3,
|
|
50
55
|
shortName: 'Envive AI',
|
|
51
56
|
lookAndFeel: {
|
|
52
|
-
theme:
|
|
57
|
+
theme: Theme.STANDARD,
|
|
53
58
|
agentName: 'Envive AI',
|
|
54
|
-
|
|
59
|
+
chatHeaderLogoDarkSrc: 'https://cdn.spiffy.ai/other/assets/envive-ai/Envive_Logo_DK.svg',
|
|
60
|
+
chatHeaderLogoLightSrc: 'https://cdn.spiffy.ai/other/assets/envive-ai/Envive_Logo_Lt.svg',
|
|
55
61
|
widgetLogoSrc: 'https://cdn.spiffy.ai/other/assets/envive-ai/Envive_Logo_DK.svg',
|
|
56
62
|
hideWidgetLogo: false,
|
|
57
63
|
elementRadius: 8,
|
|
58
|
-
imageAspectRatio: '
|
|
64
|
+
imageAspectRatio: '1/1',
|
|
59
65
|
buttonColors: {
|
|
60
66
|
lightButtonBackgroundColor: colorVar(ColorNames.BackgroundSecondary),
|
|
61
67
|
lightButtonIconColor: colorVar(ColorNames.AccentPrimary),
|
|
@@ -105,22 +111,31 @@ export const mockV3FrontendConfig: FrontendConfigV3 = {
|
|
|
105
111
|
},
|
|
106
112
|
},
|
|
107
113
|
floatingButton: {
|
|
108
|
-
position: '
|
|
109
|
-
backgroundColor:
|
|
110
|
-
mode: '
|
|
114
|
+
position: 'bottomRight',
|
|
115
|
+
backgroundColor: ColorNames.BackgroundPrimary,
|
|
116
|
+
mode: 'dark',
|
|
111
117
|
showOption: 'always',
|
|
112
118
|
style: 'attached',
|
|
113
119
|
iconSVGSrc: '',
|
|
114
120
|
},
|
|
115
121
|
floatingChat: {
|
|
116
|
-
headerBackgroundColor:
|
|
117
|
-
headerMode:
|
|
118
|
-
welcomeMessageIconColor:
|
|
119
|
-
showVerifiedBuyer:
|
|
120
|
-
|
|
122
|
+
headerBackgroundColor: undefined,
|
|
123
|
+
headerMode: ChatHeaderVariant.DARK,
|
|
124
|
+
welcomeMessageIconColor: SparkleIconColor.ACCENT_PRIMARY,
|
|
125
|
+
showVerifiedBuyer: true,
|
|
126
|
+
userQueryInputEnabled: true,
|
|
121
127
|
showEnviveLogo: true,
|
|
122
128
|
ignoreFirstModelResponse: false,
|
|
123
129
|
neverShowSingleProductCards: false,
|
|
130
|
+
welcomeMessageTitle: 'Welcome to Envive AI',
|
|
131
|
+
welcomeMessageText:
|
|
132
|
+
'Your personal shopper trained on the collective knowledge of thousands of real experts!',
|
|
133
|
+
chatFooterTextFieldPlaceholderText: 'Ask me anything...',
|
|
134
|
+
},
|
|
135
|
+
customerServiceIntegration: {
|
|
136
|
+
provider: CustomerServiceType.unsupported,
|
|
137
|
+
enabled: false,
|
|
138
|
+
suppressMerchantButton: false,
|
|
124
139
|
},
|
|
125
140
|
},
|
|
126
141
|
pageVariants: [],
|
|
@@ -205,5 +220,31 @@ export const mockV3FrontendConfig: FrontendConfigV3 = {
|
|
|
205
220
|
secondaryButtonVariant: PromptButtonVariant.LIGHT,
|
|
206
221
|
images: mockImages,
|
|
207
222
|
},
|
|
223
|
+
'typing-animation-test-light-widget': {
|
|
224
|
+
widgetConfigId: 'typing-animation-test-light-widget',
|
|
225
|
+
contentId: 'typing-animation-test-light-widget',
|
|
226
|
+
type: WidgetTypeV3.TypingAnimationV3,
|
|
227
|
+
widgetVariant: WidgetWrapperVariant.CARD_WITH_BORDER,
|
|
228
|
+
promptButtonType: PromptButtonVariant.LIGHT,
|
|
229
|
+
promptCarouselRows: PromptCarouselRows.ALWAYS_ONE,
|
|
230
|
+
showTextField: true,
|
|
231
|
+
},
|
|
232
|
+
'typing-animation-test-dark-widget': {
|
|
233
|
+
widgetConfigId: 'typing-animation-test-dark-widget',
|
|
234
|
+
contentId: 'typing-animation-test-dark-widget',
|
|
235
|
+
type: WidgetTypeV3.TypingAnimationV3,
|
|
236
|
+
widgetVariant: WidgetWrapperVariant.CARD_WITH_BORDER,
|
|
237
|
+
promptButtonType: PromptButtonVariant.DARK,
|
|
238
|
+
promptCarouselRows: PromptCarouselRows.ALWAYS_ONE,
|
|
239
|
+
showTextField: true,
|
|
240
|
+
},
|
|
241
|
+
'prompt-button-carousel-with-image-test-widget': {
|
|
242
|
+
widgetConfigId: 'prompt-button-carousel-with-image-test-widget',
|
|
243
|
+
contentId: 'prompt-button-carousel-with-image-test-widget',
|
|
244
|
+
type: WidgetTypeV3.PromptButtonCarouselWithImageV3,
|
|
245
|
+
promptButtonType: PromptButtonVariant.LIGHT,
|
|
246
|
+
image: mockImages[0],
|
|
247
|
+
hideTextField: false,
|
|
248
|
+
},
|
|
208
249
|
},
|
|
209
250
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { UserEvent } from '@spiffy-ai/commerce-api-client';
|
|
2
1
|
import { ReactNode, createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
2
|
import Logger from 'src/application/logging/logger';
|
|
4
3
|
|
|
@@ -9,6 +8,7 @@ import { WidgetTextRequest } from 'src/application/models/api/widgetTextRequest'
|
|
|
9
8
|
import { useAtomValue } from 'jotai';
|
|
10
9
|
import { appDetailsAtom } from 'src/atoms/app';
|
|
11
10
|
import { toCamelCase } from 'src/application/models/utils/snakeToCamelTransformer';
|
|
11
|
+
import { UserEvent } from 'src/application/models';
|
|
12
12
|
import { WidgetTypeV3 } from '../typesV3';
|
|
13
13
|
import { useFeatureFlagService } from '../featureFlagServiceContext/featureFlagServiceContext';
|
|
14
14
|
|
|
@@ -69,18 +69,6 @@ const MOCK_HARDCOPY_RESPONSE: Partial<Record<WidgetTypeV3, HardcopyResponse>> =
|
|
|
69
69
|
],
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
|
-
[WidgetTypeV3.TypingAnimationV3]: {
|
|
73
|
-
language: 'en',
|
|
74
|
-
values: {
|
|
75
|
-
chatPreviewTitle: 'Chat Preview Title',
|
|
76
|
-
typewriterTextPrefix: 'Want to know',
|
|
77
|
-
typewriterTexts: ['more about this product?', 'what others are saying?', 'how to use it?'],
|
|
78
|
-
suggestionButtons: ['Button 1', 'Button 2', 'Button 3'],
|
|
79
|
-
footerText: 'Ask me anything...',
|
|
80
|
-
|
|
81
|
-
chatPreviewDescription: 'Chat Preview Description',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
72
|
[WidgetTypeV3.SocialProofV3]: {
|
|
85
73
|
language: 'en',
|
|
86
74
|
values: {
|
|
@@ -99,6 +87,26 @@ const MOCK_HARDCOPY_RESPONSE: Partial<Record<WidgetTypeV3, HardcopyResponse>> =
|
|
|
99
87
|
textFieldPlaceholderText: 'Ask me anything...',
|
|
100
88
|
},
|
|
101
89
|
},
|
|
90
|
+
[WidgetTypeV3.TypingAnimationV3]: {
|
|
91
|
+
language: 'en',
|
|
92
|
+
values: {
|
|
93
|
+
titleLabel: 'Shopping Assistant',
|
|
94
|
+
headlineText: 'Need help finding',
|
|
95
|
+
animatedTextSequence: [
|
|
96
|
+
'the perfect gift for your loved ones?',
|
|
97
|
+
'something special for the holidays?',
|
|
98
|
+
'the ideal present for someone special?',
|
|
99
|
+
],
|
|
100
|
+
hintText: 'Ask me anything',
|
|
101
|
+
promptButtonTexts: [
|
|
102
|
+
'What are your best sellers?',
|
|
103
|
+
'Show me summer dresses',
|
|
104
|
+
'Do you have free shipping?',
|
|
105
|
+
'What sizes are available?',
|
|
106
|
+
],
|
|
107
|
+
textFieldAriaLabel: 'Ask me anything',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
102
110
|
[WidgetTypeV3.ChatPreviewComparisonV3]: {
|
|
103
111
|
language: 'en',
|
|
104
112
|
values: {
|
|
@@ -121,6 +129,14 @@ const MOCK_HARDCOPY_RESPONSE: Partial<Record<WidgetTypeV3, HardcopyResponse>> =
|
|
|
121
129
|
textFieldPlaceholderText: 'Ask me anything...',
|
|
122
130
|
},
|
|
123
131
|
},
|
|
132
|
+
[WidgetTypeV3.PromptButtonCarouselWithImageV3]: {
|
|
133
|
+
language: 'en',
|
|
134
|
+
values: {
|
|
135
|
+
titleLabel: 'Need some help?',
|
|
136
|
+
promptButtonsTexts: ['Help me find a product', "What's on your mind?", 'Talk to a human'],
|
|
137
|
+
textFieldPlaceholderText: 'Ask me anything...',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
124
140
|
};
|
|
125
141
|
|
|
126
142
|
const HardcopyContext = createContext<HardcopyContextType | undefined>(undefined);
|
|
@@ -457,4 +457,238 @@ describe('NewOrgConfigProvider', () => {
|
|
|
457
457
|
});
|
|
458
458
|
});
|
|
459
459
|
});
|
|
460
|
+
describe('Override Config', () => {
|
|
461
|
+
it('should use overrideConfig when provided instead of fetched config', async () => {
|
|
462
|
+
const fetchedData = {
|
|
463
|
+
colorsConfig: { accentPrimary: '#FF0000' },
|
|
464
|
+
frontendConfig: { merchantOverrideCss: 'fetched-css' },
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
const overrideData = {
|
|
468
|
+
colorsConfig: { accentPrimary: '#0000FF' },
|
|
469
|
+
frontendConfig: { merchantOverrideCss: 'override-css' },
|
|
470
|
+
orgPageConfig: { pageVariants: [] },
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// Updated TestWrapper to accept overrideConfig
|
|
474
|
+
const TestWrapperWithOverride: React.FC<{
|
|
475
|
+
children: React.ReactNode;
|
|
476
|
+
orgShortName?: string;
|
|
477
|
+
mockHookData?: any;
|
|
478
|
+
overrideConfig?: any;
|
|
479
|
+
}> = ({ children, orgShortName, mockHookData = {}, overrideConfig }) => {
|
|
480
|
+
const mockUseUIConfig = useUIConfig as any;
|
|
481
|
+
mockUseUIConfig.mockReturnValue({
|
|
482
|
+
data: mockHookData.data || {},
|
|
483
|
+
loading: mockHookData.loading ?? false,
|
|
484
|
+
error: mockHookData.error || null,
|
|
485
|
+
refetch: vi.fn(),
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
return (
|
|
489
|
+
<Provider>
|
|
490
|
+
<EnviveConfigProvider
|
|
491
|
+
identifyingPrefix="test"
|
|
492
|
+
orgShortName={orgShortName}
|
|
493
|
+
baseUrl="https://test-api.example.com"
|
|
494
|
+
orgLevelApiKey="test-key"
|
|
495
|
+
>
|
|
496
|
+
<LocalStorageProvider>
|
|
497
|
+
<GraphQLProvider>
|
|
498
|
+
<NewOrgConfigProvider overrideConfig={overrideConfig}>
|
|
499
|
+
{children}
|
|
500
|
+
</NewOrgConfigProvider>
|
|
501
|
+
</GraphQLProvider>
|
|
502
|
+
</LocalStorageProvider>
|
|
503
|
+
</EnviveConfigProvider>
|
|
504
|
+
</Provider>
|
|
505
|
+
);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
const ConfigChecker: React.FC = () => {
|
|
509
|
+
const config = useNewOrgConfigContext();
|
|
510
|
+
return (
|
|
511
|
+
<div data-testid="config-checker">
|
|
512
|
+
<div data-testid="accent-color">{config.colorsConfig?.accentPrimary || 'none'}</div>
|
|
513
|
+
<div data-testid="css-value">
|
|
514
|
+
{config.frontendConfig?.merchantOverrideCss || 'none'}
|
|
515
|
+
</div>
|
|
516
|
+
</div>
|
|
517
|
+
);
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
render(
|
|
521
|
+
<TestWrapperWithOverride
|
|
522
|
+
orgShortName="test-org"
|
|
523
|
+
mockHookData={{ data: fetchedData, loading: false }}
|
|
524
|
+
overrideConfig={overrideData}
|
|
525
|
+
>
|
|
526
|
+
<ConfigChecker />
|
|
527
|
+
</TestWrapperWithOverride>,
|
|
528
|
+
);
|
|
529
|
+
|
|
530
|
+
await waitFor(() => {
|
|
531
|
+
expect(screen.getByTestId('accent-color')).toHaveTextContent('#0000FF');
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// Should use override config, not fetched config
|
|
535
|
+
expect(screen.getByTestId('css-value')).toHaveTextContent('override-css');
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
it('should fall back to fetched config when overrideConfig is not provided', async () => {
|
|
539
|
+
const fetchedData = {
|
|
540
|
+
colorsConfig: { accentPrimary: '#FF0000' },
|
|
541
|
+
frontendConfig: { merchantOverrideCss: 'fetched-css' },
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
const ConfigChecker: React.FC = () => {
|
|
545
|
+
const config = useNewOrgConfigContext();
|
|
546
|
+
return (
|
|
547
|
+
<div data-testid="config-checker">
|
|
548
|
+
<div data-testid="accent-color">{config.colorsConfig?.accentPrimary || 'none'}</div>
|
|
549
|
+
<div data-testid="css-value">
|
|
550
|
+
{config.frontendConfig?.merchantOverrideCss || 'none'}
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
);
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
render(
|
|
557
|
+
<TestWrapper
|
|
558
|
+
orgShortName="test-org"
|
|
559
|
+
mockHookData={{ data: fetchedData, loading: false }}
|
|
560
|
+
>
|
|
561
|
+
<ConfigChecker />
|
|
562
|
+
</TestWrapper>,
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
await waitFor(() => {
|
|
566
|
+
expect(screen.getByTestId('accent-color')).toHaveTextContent('#FF0000');
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
expect(screen.getByTestId('css-value')).toHaveTextContent('fetched-css');
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
it('should set newOrgConfigAtom with overrideConfig when provided', async () => {
|
|
573
|
+
const fetchedData = {
|
|
574
|
+
colorsConfig: { accentPrimary: '#FF0000' },
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const overrideData = {
|
|
578
|
+
colorsConfig: { accentPrimary: '#00FF00' },
|
|
579
|
+
frontendConfig: { merchantOverrideCss: 'override-css' },
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const TestWrapperWithOverride: React.FC<{
|
|
583
|
+
children: React.ReactNode;
|
|
584
|
+
orgShortName?: string;
|
|
585
|
+
mockHookData?: any;
|
|
586
|
+
overrideConfig?: any;
|
|
587
|
+
}> = ({ children, orgShortName, mockHookData = {}, overrideConfig }) => {
|
|
588
|
+
const mockUseUIConfig = useUIConfig as any;
|
|
589
|
+
mockUseUIConfig.mockReturnValue({
|
|
590
|
+
data: mockHookData.data || {},
|
|
591
|
+
loading: mockHookData.loading ?? false,
|
|
592
|
+
error: mockHookData.error || null,
|
|
593
|
+
refetch: vi.fn(),
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
return (
|
|
597
|
+
<Provider>
|
|
598
|
+
<EnviveConfigProvider
|
|
599
|
+
identifyingPrefix="test"
|
|
600
|
+
orgShortName={orgShortName}
|
|
601
|
+
baseUrl="https://test-api.example.com"
|
|
602
|
+
orgLevelApiKey="test-key"
|
|
603
|
+
>
|
|
604
|
+
<LocalStorageProvider>
|
|
605
|
+
<GraphQLProvider>
|
|
606
|
+
<NewOrgConfigProvider overrideConfig={overrideConfig}>
|
|
607
|
+
{children}
|
|
608
|
+
</NewOrgConfigProvider>
|
|
609
|
+
</GraphQLProvider>
|
|
610
|
+
</LocalStorageProvider>
|
|
611
|
+
</EnviveConfigProvider>
|
|
612
|
+
</Provider>
|
|
613
|
+
);
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
render(
|
|
617
|
+
<TestWrapperWithOverride
|
|
618
|
+
orgShortName="test-org"
|
|
619
|
+
mockHookData={{ data: fetchedData, loading: false }}
|
|
620
|
+
overrideConfig={overrideData}
|
|
621
|
+
>
|
|
622
|
+
<AtomReaderComponent />
|
|
623
|
+
</TestWrapperWithOverride>,
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
await waitFor(() => {
|
|
627
|
+
expect(screen.getByTestId('atom-has-config')).toHaveTextContent('has-config');
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// Atom should have the override config values
|
|
631
|
+
expect(screen.getByTestId('atom-has-colors')).toHaveTextContent('true');
|
|
632
|
+
expect(screen.getByTestId('atom-has-frontend')).toHaveTextContent('true');
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
it('should handle undefined overrideConfig gracefully', async () => {
|
|
636
|
+
const fetchedData = {
|
|
637
|
+
colorsConfig: { accentPrimary: '#FF0000' },
|
|
638
|
+
frontendConfig: { merchantOverrideCss: 'fetched-css' },
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
const TestWrapperWithOverride: React.FC<{
|
|
642
|
+
children: React.ReactNode;
|
|
643
|
+
orgShortName?: string;
|
|
644
|
+
mockHookData?: any;
|
|
645
|
+
overrideConfig?: any;
|
|
646
|
+
}> = ({ children, orgShortName, mockHookData = {}, overrideConfig }) => {
|
|
647
|
+
const mockUseUIConfig = useUIConfig as any;
|
|
648
|
+
mockUseUIConfig.mockReturnValue({
|
|
649
|
+
data: mockHookData.data || {},
|
|
650
|
+
loading: mockHookData.loading ?? false,
|
|
651
|
+
error: mockHookData.error || null,
|
|
652
|
+
refetch: vi.fn(),
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
return (
|
|
656
|
+
<Provider>
|
|
657
|
+
<EnviveConfigProvider
|
|
658
|
+
identifyingPrefix="test"
|
|
659
|
+
orgShortName={orgShortName}
|
|
660
|
+
baseUrl="https://test-api.example.com"
|
|
661
|
+
orgLevelApiKey="test-key"
|
|
662
|
+
>
|
|
663
|
+
<LocalStorageProvider>
|
|
664
|
+
<GraphQLProvider>
|
|
665
|
+
<NewOrgConfigProvider overrideConfig={overrideConfig}>
|
|
666
|
+
{children}
|
|
667
|
+
</NewOrgConfigProvider>
|
|
668
|
+
</GraphQLProvider>
|
|
669
|
+
</LocalStorageProvider>
|
|
670
|
+
</EnviveConfigProvider>
|
|
671
|
+
</Provider>
|
|
672
|
+
);
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
render(
|
|
676
|
+
<TestWrapperWithOverride
|
|
677
|
+
orgShortName="test-org"
|
|
678
|
+
mockHookData={{ data: fetchedData, loading: false }}
|
|
679
|
+
overrideConfig={undefined}
|
|
680
|
+
>
|
|
681
|
+
<MockNewOrgConfigComponent />
|
|
682
|
+
</TestWrapperWithOverride>,
|
|
683
|
+
);
|
|
684
|
+
|
|
685
|
+
await waitFor(() => {
|
|
686
|
+
expect(screen.getByTestId('loading')).toHaveTextContent('false');
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
// Should fall back to fetched data
|
|
690
|
+
expect(screen.getByTestId('has-colors-config')).toHaveTextContent('true');
|
|
691
|
+
expect(screen.getByTestId('has-frontend-config')).toHaveTextContent('true');
|
|
692
|
+
});
|
|
693
|
+
});
|
|
460
694
|
});
|