@envive-ai/react-widgets-v3 0.3.8 → 0.3.10
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/CXIntegration/hooks/useUnifiedCXButton.cjs +3 -2
- package/dist/CXIntegration/hooks/useUnifiedCXButton.js +4 -3
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +9 -16
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +9 -16
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +10 -16
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +10 -16
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +1 -1
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +1 -1
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +13 -1
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +14 -2
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +15 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +16 -4
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +4 -4
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +4 -4
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +4 -4
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +4 -4
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +1 -1
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +1 -1
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +1 -1
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets/utils/functions.cjs +1 -1
- package/dist/widgets/utils/functions.js +1 -1
- package/package.json +1 -1
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +4 -3
- package/src/stories/SalesAgentTest/SalesAgentTest.tsx +16 -7
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +10 -11
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +11 -12
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +2 -3
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +18 -1
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +32 -4
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +1 -1
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useSalesAgent,
|
|
6
6
|
} from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
7
7
|
import { useState } from 'react';
|
|
8
|
+
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
8
9
|
|
|
9
10
|
export const SalesAgentTest = () => {
|
|
10
11
|
const {
|
|
@@ -39,12 +40,15 @@ export const SalesAgentTest = () => {
|
|
|
39
40
|
<button
|
|
40
41
|
type="button"
|
|
41
42
|
onClick={() =>
|
|
42
|
-
onSuggestionClicked(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
onSuggestionClicked(
|
|
44
|
+
{
|
|
45
|
+
id: '1',
|
|
46
|
+
category: SuggestionCategory.ProductBased,
|
|
47
|
+
content: 'test',
|
|
48
|
+
createdAt: new Date().toISOString(),
|
|
49
|
+
},
|
|
50
|
+
ChatElementDisplayLocationV3.FLOATING_CHAT_PROMPT_BUTTON,
|
|
51
|
+
)
|
|
48
52
|
}
|
|
49
53
|
>
|
|
50
54
|
On Suggestion Clicked
|
|
@@ -107,7 +111,12 @@ export const SalesAgentTest = () => {
|
|
|
107
111
|
}}
|
|
108
112
|
type="button"
|
|
109
113
|
key={suggestion.id}
|
|
110
|
-
onClick={() =>
|
|
114
|
+
onClick={() =>
|
|
115
|
+
onSuggestionClicked(
|
|
116
|
+
suggestion,
|
|
117
|
+
ChatElementDisplayLocationV3.FLOATING_CHAT_PROMPT_BUTTON,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
111
120
|
>
|
|
112
121
|
{suggestion.content}
|
|
113
122
|
</button>
|
|
@@ -11,6 +11,7 @@ import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
|
11
11
|
import { useCallback, useMemo } from 'react';
|
|
12
12
|
import {
|
|
13
13
|
ChatElementDisplayLocationV3,
|
|
14
|
+
Suggestion,
|
|
14
15
|
VariantTypeEnum,
|
|
15
16
|
} from '@envive-ai/react-hooks/application/models';
|
|
16
17
|
import { ChatPreviewComparison } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison';
|
|
@@ -22,7 +23,7 @@ import { getMessageText, getRecentProductImageUrls } from '../utils/functions';
|
|
|
22
23
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
23
24
|
|
|
24
25
|
const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
25
|
-
const {
|
|
26
|
+
const { onSuggestionClicked } = useSalesAgent();
|
|
26
27
|
const { openChat } = useChatToggle();
|
|
27
28
|
|
|
28
29
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
@@ -32,10 +33,6 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
32
33
|
|
|
33
34
|
const { suggestions } = useAtomValue(chatAtom);
|
|
34
35
|
|
|
35
|
-
const promptButtonTexts = useMemo(() => {
|
|
36
|
-
return suggestions.map(suggestion => suggestion.content);
|
|
37
|
-
}, [suggestions]);
|
|
38
|
-
|
|
39
36
|
const messageText = useMemo(() => getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
40
37
|
|
|
41
38
|
const productImageUrls = useMemo(
|
|
@@ -62,10 +59,9 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
62
59
|
headlineText: hardcopyContent?.values?.headlineText,
|
|
63
60
|
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
64
61
|
messageText,
|
|
65
|
-
promptButtonTexts,
|
|
66
62
|
} as Pick<
|
|
67
63
|
ChatPreviewComparisonProps['widgetContentProps'],
|
|
68
|
-
'headlineText' | 'messageText' | '
|
|
64
|
+
'headlineText' | 'messageText' | 'textFieldPlaceholderText' | 'titleLabel'
|
|
69
65
|
>;
|
|
70
66
|
|
|
71
67
|
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
@@ -73,11 +69,14 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
73
69
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
74
70
|
|
|
75
71
|
const handlePromptButtonClick = useCallback(
|
|
76
|
-
(
|
|
77
|
-
|
|
72
|
+
(suggestion: Suggestion) => {
|
|
73
|
+
onSuggestionClicked(
|
|
74
|
+
suggestion,
|
|
75
|
+
ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON,
|
|
76
|
+
);
|
|
78
77
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
79
78
|
},
|
|
80
|
-
[
|
|
79
|
+
[onSuggestionClicked, openChat],
|
|
81
80
|
);
|
|
82
81
|
|
|
83
82
|
const handleTextFieldClick = useCallback(() => {
|
|
@@ -109,7 +108,7 @@ const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
109
108
|
titleLabel: hardCopyContent?.titleLabel,
|
|
110
109
|
headlineText: hardCopyContent?.headlineText,
|
|
111
110
|
messageText: hardCopyContent?.messageText,
|
|
112
|
-
|
|
111
|
+
promptButtons: suggestions,
|
|
113
112
|
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
114
113
|
images: images ?? [],
|
|
115
114
|
logoSrc: logoSrc ?? undefined,
|
|
@@ -6,7 +6,10 @@ import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms
|
|
|
6
6
|
|
|
7
7
|
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ChatElementDisplayLocationV3,
|
|
11
|
+
Suggestion,
|
|
12
|
+
} from '@envive-ai/react-hooks/application/models';
|
|
10
13
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
11
14
|
import {
|
|
12
15
|
SpiffyMetricsEventName,
|
|
@@ -20,17 +23,13 @@ import { getMessageText } from '../utils/functions';
|
|
|
20
23
|
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
21
24
|
|
|
22
25
|
const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
23
|
-
const {
|
|
26
|
+
const { onSuggestionClicked } = useSalesAgent();
|
|
24
27
|
const { openChat } = useChatToggle();
|
|
25
28
|
|
|
26
29
|
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
27
30
|
|
|
28
31
|
const { suggestions } = useAtomValue(chatAtom);
|
|
29
32
|
|
|
30
|
-
const promptButtonTexts = useMemo(() => {
|
|
31
|
-
return suggestions.map(suggestion => suggestion.content);
|
|
32
|
-
}, [suggestions]);
|
|
33
|
-
|
|
34
33
|
const messageText = useMemo(() => getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
35
34
|
|
|
36
35
|
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
@@ -42,11 +41,11 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
42
41
|
const hardCopyContent = {
|
|
43
42
|
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
44
43
|
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
44
|
+
promptButtons: suggestions,
|
|
45
45
|
messageText,
|
|
46
|
-
promptButtonTexts,
|
|
47
46
|
} as Pick<
|
|
48
47
|
ChatPreviewProps['widgetContentProps'],
|
|
49
|
-
'messageText' | '
|
|
48
|
+
'messageText' | 'promptButtons' | 'textFieldPlaceholderText' | 'titleLabel'
|
|
50
49
|
>;
|
|
51
50
|
|
|
52
51
|
const { trackEvent } = useAmplitude();
|
|
@@ -66,11 +65,11 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
66
65
|
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
67
66
|
|
|
68
67
|
const handlePromptButtonClick = useCallback(
|
|
69
|
-
(
|
|
70
|
-
|
|
68
|
+
(suggestion: Suggestion) => {
|
|
69
|
+
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
71
70
|
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
72
71
|
},
|
|
73
|
-
[
|
|
72
|
+
[onSuggestionClicked, openChat],
|
|
74
73
|
);
|
|
75
74
|
|
|
76
75
|
const handleTextFieldClick = useCallback(() => {
|
|
@@ -97,7 +96,7 @@ const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
97
96
|
const widgetContentProps: ChatPreviewProps['widgetContentProps'] = {
|
|
98
97
|
titleLabel: hardCopyContent?.titleLabel,
|
|
99
98
|
messageText: hardCopyContent?.messageText,
|
|
100
|
-
|
|
99
|
+
promptButtons: hardCopyContent?.promptButtons,
|
|
101
100
|
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
102
101
|
logoSrc: logoSrc ?? undefined,
|
|
103
102
|
};
|
|
@@ -21,7 +21,6 @@ export const FloatingChatOverlay = ({
|
|
|
21
21
|
previewMode = false,
|
|
22
22
|
}: FloatingChatOverlayProps) => {
|
|
23
23
|
const overlayClasses = classNames(
|
|
24
|
-
'envive-floating-chat-overlay',
|
|
25
24
|
previewMode ? 'envive-tw-absolute' : 'envive-tw-fixed',
|
|
26
25
|
'envive-tw-top-0',
|
|
27
26
|
'envive-tw-left-0',
|
|
@@ -32,7 +31,6 @@ export const FloatingChatOverlay = ({
|
|
|
32
31
|
);
|
|
33
32
|
|
|
34
33
|
const backdropClasses = classNames(
|
|
35
|
-
'envive-floating-chat-backdrop',
|
|
36
34
|
'envive-tw-absolute',
|
|
37
35
|
'envive-tw-top-0',
|
|
38
36
|
'envive-tw-left-0',
|
|
@@ -45,7 +43,6 @@ export const FloatingChatOverlay = ({
|
|
|
45
43
|
);
|
|
46
44
|
|
|
47
45
|
const overlayContentClasses = classNames(
|
|
48
|
-
'envive-floating-chat-overlay-content',
|
|
49
46
|
'envive-tw-relative',
|
|
50
47
|
'envive-tw-flex',
|
|
51
48
|
'envive-tw-justify-end',
|
|
@@ -63,6 +60,7 @@ export const FloatingChatOverlay = ({
|
|
|
63
60
|
<motion.div
|
|
64
61
|
key="floating-chat-overlay"
|
|
65
62
|
className={overlayClasses}
|
|
63
|
+
style={{ top: '0px' }}
|
|
66
64
|
initial={{ opacity: 0 }}
|
|
67
65
|
animate={{ opacity: 1 }}
|
|
68
66
|
exit={{ opacity: 0 }}
|
|
@@ -81,6 +79,7 @@ export const FloatingChatOverlay = ({
|
|
|
81
79
|
)}
|
|
82
80
|
<div
|
|
83
81
|
className={overlayContentClasses}
|
|
82
|
+
style={{ top: '0px' }}
|
|
84
83
|
onClick={onClose}
|
|
85
84
|
onKeyDown={e => {
|
|
86
85
|
if (e.key === 'Escape') {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ProductCardWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
2
2
|
import { PromptButtonVariant } from '@envive-ai/react-toolkit-v3/PromptButton/types';
|
|
3
|
-
import { useCallback } from 'react';
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
SpiffyMetricsEventName,
|
|
6
|
+
useAmplitude,
|
|
7
|
+
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
4
8
|
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
5
9
|
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
6
10
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
@@ -45,6 +49,19 @@ const ProductCardWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
45
49
|
const fallbackColor = productCardWidgetConfig?.fallbackColor;
|
|
46
50
|
const imageSrc = productCardWidgetConfig?.imageSrc || '';
|
|
47
51
|
|
|
52
|
+
const { trackEvent } = useAmplitude();
|
|
53
|
+
|
|
54
|
+
const { widgetConfigId } = props;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
trackEvent({
|
|
57
|
+
eventName: SpiffyMetricsEventName.ChatComponentVisible,
|
|
58
|
+
eventProps: {
|
|
59
|
+
widget_config_id: widgetConfigId,
|
|
60
|
+
widget_type: WidgetTypeV3.ProductCardV3,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}, [trackEvent, widgetConfigId]);
|
|
64
|
+
|
|
48
65
|
const handleSelect = useCallback(
|
|
49
66
|
(prompt: string) => {
|
|
50
67
|
onTypedMessageSubmitted({ query: prompt, userTyped: false });
|
package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx
CHANGED
|
@@ -6,18 +6,25 @@ import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext
|
|
|
6
6
|
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
7
7
|
|
|
8
8
|
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
9
|
-
import { useCallback, useEffect } from 'react';
|
|
9
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
10
10
|
import {
|
|
11
11
|
SpiffyMetricsEventName,
|
|
12
12
|
useAmplitude,
|
|
13
13
|
} from '@envive-ai/react-hooks/contexts/amplitudeContext';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ChatElementDisplayLocationV3,
|
|
16
|
+
VariantTypeEnum,
|
|
17
|
+
} from '@envive-ai/react-hooks/application/models';
|
|
15
18
|
import {
|
|
16
19
|
PromptButtonCarouselWithImage,
|
|
17
20
|
PromptButtonCarouselWithImageProps,
|
|
18
21
|
} from '@envive-ai/react-toolkit-v3/PromptButtonCarouselWithImage';
|
|
22
|
+
import { lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
23
|
+
import { useAtomValue } from 'jotai';
|
|
24
|
+
import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
19
25
|
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
20
26
|
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
27
|
+
import { getRecentProductImageUrls } from '../utils/functions';
|
|
21
28
|
|
|
22
29
|
const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
23
30
|
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
@@ -63,6 +70,27 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
63
70
|
openChat(ChatElementDisplayLocationV3.PROMPT_BUTTON_CAROUSEL_WITH_IMAGE_TEXT_FIELD);
|
|
64
71
|
}, [openChat]);
|
|
65
72
|
|
|
73
|
+
const variantInfo = useAtomValue(variantInfoAtom);
|
|
74
|
+
const productId = variantInfo.variant === VariantTypeEnum.Pdp ? variantInfo.productId : undefined;
|
|
75
|
+
|
|
76
|
+
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
77
|
+
|
|
78
|
+
const productImageUrls = useMemo(
|
|
79
|
+
() => (lastAssistantMessage ? getRecentProductImageUrls(lastAssistantMessage, productId) : []),
|
|
80
|
+
[lastAssistantMessage, productId],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const productImageUrl = productImageUrls[1] ?? productImageUrls[0] ?? '';
|
|
84
|
+
|
|
85
|
+
const isDynamic = promptButtonCarouselWithImageWidgetConfig?.isDynamic ?? false;
|
|
86
|
+
|
|
87
|
+
const finalImageSrc = isDynamic
|
|
88
|
+
? productImageUrl
|
|
89
|
+
: promptButtonCarouselWithImageWidgetConfig?.image?.src;
|
|
90
|
+
const finalImageAlt = isDynamic
|
|
91
|
+
? 'Product Image From Page'
|
|
92
|
+
: promptButtonCarouselWithImageWidgetConfig?.image?.alt;
|
|
93
|
+
|
|
66
94
|
return (
|
|
67
95
|
<PromptButtonCarouselWithImage
|
|
68
96
|
id={id}
|
|
@@ -71,8 +99,8 @@ const PromptButtonCarouselWithImageWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
71
99
|
title={hardCopyContent?.title}
|
|
72
100
|
promptButtonsTexts={hardCopyContent?.promptButtonsTexts}
|
|
73
101
|
promptButtonType={promptButtonCarouselWithImageWidgetConfig?.promptButtonType}
|
|
74
|
-
imageSrc={
|
|
75
|
-
alt={
|
|
102
|
+
imageSrc={finalImageSrc}
|
|
103
|
+
alt={finalImageAlt}
|
|
76
104
|
textFieldPlaceholder={hardCopyContent?.textFieldPlaceholder}
|
|
77
105
|
hideTextField={promptButtonCarouselWithImageWidgetConfig?.hideTextField}
|
|
78
106
|
handlePromptButtonClick={handlePromptButtonClick}
|
|
@@ -66,6 +66,7 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<PromptCarousel
|
|
69
|
+
{...props}
|
|
69
70
|
id={id}
|
|
70
71
|
theme={Theme.GLOBAL_CUSTOM}
|
|
71
72
|
isLoading={isLoading}
|
|
@@ -75,7 +76,6 @@ const PromptCarouselWidgetHandler = (props: BaseWidgetProps) => {
|
|
|
75
76
|
animationSpeed={animationSpeed}
|
|
76
77
|
handleButtonClick={handleButtonClick}
|
|
77
78
|
promptButtonTexts={buttonTexts}
|
|
78
|
-
{...props}
|
|
79
79
|
/>
|
|
80
80
|
);
|
|
81
81
|
};
|