@envive-ai/react-widgets-v3 0.3.10 → 0.3.11
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/debug/GenericSelect.cjs +167 -0
- package/dist/debug/GenericSelect.js +165 -0
- package/dist/debug/MessageContent.cjs +151 -0
- package/dist/debug/MessageContent.js +149 -0
- package/dist/debug/chatEmbed.cjs +95 -0
- package/dist/debug/chatEmbed.js +92 -0
- package/dist/debug/debugBar.cjs +18 -0
- package/dist/debug/debugBar.js +17 -0
- package/dist/debug/reportIssue.cjs +528 -0
- package/dist/debug/reportIssue.js +524 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/apis/CustomerServiceApi.cjs +265 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/apis/DefaultApi.cjs +591 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/apis/InferenceApi.cjs +265 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/apis/ProductsApi.cjs +105 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/apis/SearchApi.cjs +229 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/apis/index.cjs +43 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/index.cjs +39 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AddNoteToLatestConversationRequest.cjs +68 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AddNoteToLatestConversationResponse.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AddToCartAttributes.cjs +53 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AnalyticsIdentifyRequest.cjs +86 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AnalyticsTrackEventRequest.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AttachmentRequest.cjs +63 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/AutoForm.cjs +55 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/Context.cjs +89 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ConversationStatus.cjs +63 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CreateConversationRequest.cjs +68 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CreateConversationResponse.cjs +64 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CustServiceAttachment.cjs +68 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CustServiceConversation.cjs +69 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CustServiceConversationMessages.cjs +67 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CustServiceCustomer.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CustServiceMessage.cjs +85 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/CustomerServiceProvider.cjs +63 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/FormResponseAttributes.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/FormResponseAttributesFormCategory.cjs +55 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/FormSubmittedAttributes.cjs +65 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/FormType.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/FulfillmentDisplayStatus.cjs +84 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/GenerationParams.cjs +74 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/GetConversationMessagesRequest.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/IsBusinessHoursRequest.cjs +54 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/IsBusinessHoursResponse.cjs +59 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/LabelValue.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ManualForm.cjs +55 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRule.cjs +70 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRuleAction.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRuleActionAttribute.cjs +58 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRuleActionType.cjs +64 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRuleCondition.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRuleOp.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/MerchRuleStatus.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/NextMessageRequest.cjs +78 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/OrderItemInfo.cjs +78 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/OrderResponseAttributes.cjs +71 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/Organization.cjs +83 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/OrganizationConfig.cjs +82 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/OrganizationConfigResults.cjs +70 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/OrganizationSettings.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PDPAttributes.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PLPAttributeCategory.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PLPAttributes.cjs +64 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PLPAttributesAttributes.cjs +55 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PLPIdAttributes.cjs +53 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PLPUrlAttributes.cjs +53 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PageVisitAttributes.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/PageVisitCategory.cjs +65 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductRetrievalRequest.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductRetrievalResponse.cjs +55 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductSearchFilterResponseAttributes.cjs +53 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductSearchRequest.cjs +71 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductSearchResponse.cjs +64 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductSearchResponseAttributes.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ProductSearchResponseV2.cjs +64 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/QueryTypedAttributes.cjs +53 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ReportContent.cjs +59 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ReportSessionRequest.cjs +99 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/Response.cjs +68 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ResponseCategory.cjs +69 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/ResponseProductAttributes.cjs +91 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SearchAttributes.cjs +65 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SearchResponseProduct.cjs +93 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SearchSuggestionsResponse.cjs +58 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SendMessageRequest.cjs +71 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SendMessageResponse.cjs +55 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/StatsigExperiment.cjs +64 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/StatsigFeatureGate.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/Suggestion.cjs +70 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SuggestionCategory.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SuggestionClickedAttributes.cjs +53 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SupportedEventProductCategory.cjs +62 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SupportedEventRequest.cjs +67 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/SupportedEventResponse.cjs +78 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/TurnInfo.cjs +70 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/TurnInfoPrevUserEvent.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingGenericConfig.cjs +52 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingPDPConfig.cjs +65 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingPLPConfig.cjs +61 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingRequest.cjs +65 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingResponse.cjs +73 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingResponseSpecificDetails.cjs +59 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UrlResolvingType.cjs +67 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UserEvent.cjs +69 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UserEventAttributes.cjs +75 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/UserEventCategory.cjs +70 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/V1GetSessionMessages200Response.cjs +67 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/V1SearchExplainGet200Response.cjs +63 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetString.cjs +60 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetTextRequest.cjs +73 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetTextResponse.cjs +66 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetType.cjs +69 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/index.cjs +221 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/runtime.cjs +324 -0
- package/dist/node_modules/react-icons/fa/index.cjs +65 -0
- package/dist/node_modules/react-icons/fa/index.js +61 -0
- package/dist/node_modules/react-icons/lib/iconBase.cjs +121 -0
- package/dist/node_modules/react-icons/lib/iconBase.js +119 -0
- package/dist/node_modules/react-icons/lib/iconContext.cjs +17 -0
- package/dist/node_modules/react-icons/lib/iconContext.js +14 -0
- package/dist/packages/icons/dist/IconCloseVariant.cjs +22 -0
- package/dist/packages/icons/dist/IconCloseVariant.js +22 -0
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +27 -0
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +25 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +696 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +696 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +43 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +43 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +1528 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +1528 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +329 -0
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +329 -0
- package/dist/packages/icons/dist/node_modules/react/index.cjs +13 -0
- package/dist/packages/icons/dist/node_modules/react/index.js +13 -0
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +13 -0
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +13 -0
- package/dist/{widgets → packages/widgets}/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/{widgets → packages/widgets}/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/{widgets → packages/widgets}/dist/SuggestionBar/SuggestionBar.d.ts +2 -2
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +3 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +2 -2
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +1 -1
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +3 -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 +3 -1
- package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.cjs +4 -1
- package/dist/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.js +5 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.cjs +31 -0
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +15 -0
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +15 -0
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.js +30 -0
- package/dist/widgets/FullPageSalesAgentWidget/index.cjs +3 -0
- package/dist/widgets/FullPageSalesAgentWidget/index.d.cts +2 -0
- package/dist/widgets/FullPageSalesAgentWidget/index.d.ts +2 -0
- package/dist/widgets/FullPageSalesAgentWidget/index.js +3 -0
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +3 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +3 -2
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +4 -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 +4 -3
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +28 -4
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +29 -5
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +8 -6
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +8 -6
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +3 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +3 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +3 -2
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +3 -2
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +2 -2
- package/dist/widgets/utils/functions.cjs +1 -1
- package/dist/widgets/utils/functions.js +1 -1
- package/dist/widgets-v2/SearchResults/index.d.ts +3 -3
- package/dist/widgets-v2/SearchZeroState/index.d.ts +4 -4
- package/dist/widgets-v2/SuggestionBar/index.d.ts +3 -3
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +2 -2
- package/package.json +5 -1
- package/src/debug/GenericSelect.tsx +236 -0
- package/src/debug/MessageContent.tsx +248 -0
- package/src/debug/chatEmbed.tsx +119 -0
- package/src/debug/debugBar.tsx +13 -0
- package/src/debug/reportIssue.tsx +649 -0
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +6 -0
- package/src/stories/FullPageSalesAgentWidget.stories.tsx +68 -0
- package/src/stories/SalesAgentTest/SalesAgentTest.tsx +10 -2
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +2 -0
- package/src/widgets/FloatingChatWidget/hooks/useFloatingButtonVisibility.ts +11 -5
- package/src/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.tsx +46 -0
- package/src/widgets/FullPageSalesAgentWidget/index.ts +1 -0
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +5 -1
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +6 -1
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +31 -2
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +10 -2
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +5 -1
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +5 -1
- /package/dist/{widgets → packages/widgets}/dist/SearchResults/SearchResults.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SearchResults/index.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SearchResults/types.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SearchZeroState/SearchZeroState.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SearchZeroState/index.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SearchZeroState/types.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SuggestionBar/index.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SuggestionBar/types.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SuggestionButtonContainer/SuggestionButtonContainer.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/SuggestionButtonContainer/types.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/config/BaseWidgetConfig.d.ts +0 -0
- /package/dist/{widgets → packages/widgets}/dist/config/WidgetType.d.ts +0 -0
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReportSessionRequest,
|
|
3
|
+
ReportSessionRequestReportPriorityEnum,
|
|
4
|
+
ReportSessionRequestReportTypeEnum,
|
|
5
|
+
Suggestion,
|
|
6
|
+
TurnInfo,
|
|
7
|
+
} from '@spiffy-ai/commerce-api-client';
|
|
8
|
+
import { ChangeEvent, useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import { useAtomValue } from 'jotai';
|
|
10
|
+
|
|
11
|
+
import { Message, MessageType } from '@envive-ai/react-hooks/application/models';
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import IconCloseVariant from '@envive-ai/react-icons/IconCloseVariant';
|
|
14
|
+
import CommerceApiClient from '@envive-ai/react-hooks/application/commerce-api';
|
|
15
|
+
import { userIdAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
16
|
+
import { orgShortNameAtom } from '@envive-ai/react-hooks/atoms/envive/enviveConfig';
|
|
17
|
+
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
18
|
+
import { StringUtils, validateEmail } from '@envive-ai/react-hooks/application/utils';
|
|
19
|
+
import { GenericSelect } from './GenericSelect';
|
|
20
|
+
import ChatEmbed from './chatEmbed';
|
|
21
|
+
|
|
22
|
+
const messageContent = (m: Message) => {
|
|
23
|
+
if (m.type === MessageType.Text) {
|
|
24
|
+
return m.metadata.content;
|
|
25
|
+
}
|
|
26
|
+
if (m.type === MessageType.Product) {
|
|
27
|
+
return `PRODUCT ID: ${m.metadata?.id}`;
|
|
28
|
+
}
|
|
29
|
+
if (m.type === MessageType.Review) {
|
|
30
|
+
return `REVIEW: by ${m.metadata?.reviewer}`;
|
|
31
|
+
}
|
|
32
|
+
if (m.type === MessageType.Page) {
|
|
33
|
+
return `PAGE: ${m.metadata?.url}`;
|
|
34
|
+
}
|
|
35
|
+
if (m.type === MessageType.Separator) {
|
|
36
|
+
return `SEPARATOR`;
|
|
37
|
+
}
|
|
38
|
+
if (m.type === MessageType.QueryTyped) {
|
|
39
|
+
return `QUERY TYPED: ${m.metadata?.content}`;
|
|
40
|
+
}
|
|
41
|
+
if (m.type === MessageType.SuggestionClicked) {
|
|
42
|
+
return `SUGGESTION CLICKED`;
|
|
43
|
+
}
|
|
44
|
+
if (m.type === MessageType.Search) {
|
|
45
|
+
return `SEARCH: ${m.metadata?.searchTerm}`;
|
|
46
|
+
}
|
|
47
|
+
if (m.type === MessageType.ProductSearch) {
|
|
48
|
+
return `PRODUCT SEARCH: ${m.metadata?.generatedQuery} (${m.metadata?.productCount} products)`;
|
|
49
|
+
}
|
|
50
|
+
if (m.type === MessageType.ProductSearchFilter) {
|
|
51
|
+
return `PRODUCT SEARCH FILTER: ${m.metadata?.filterName}`;
|
|
52
|
+
}
|
|
53
|
+
if (m.type === MessageType.Form) {
|
|
54
|
+
return `FORM: ${m.metadata?.formType}`;
|
|
55
|
+
}
|
|
56
|
+
if (m.type === MessageType.Order) {
|
|
57
|
+
return `ORDER: ${m.metadata?.orderId}`;
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`Unsupported message type: ${m.type}`);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const ReportHeader = ({ onClose }: { onClose: () => void }) => {
|
|
63
|
+
const userId = useAtomValue(userIdAtom);
|
|
64
|
+
const handleCopyClick = useCallback(async () => {
|
|
65
|
+
try {
|
|
66
|
+
await navigator.clipboard.writeText(userId);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error('Failed to copy to clipboard:', err);
|
|
69
|
+
}
|
|
70
|
+
}, [userId]);
|
|
71
|
+
|
|
72
|
+
const headerTitleClassnames = classNames({
|
|
73
|
+
'envive-tw-text-[24px]': true,
|
|
74
|
+
'md:envive-tw-text-[30px]': true,
|
|
75
|
+
'envive-tw-mb-[12px]': true,
|
|
76
|
+
'envive-tw-color-[#161844]': true,
|
|
77
|
+
'envive-tw-leading-[1.33]': true,
|
|
78
|
+
'md:envive-tw-leading-[1.2]': true,
|
|
79
|
+
'envive-tw-font-bold': true,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const headerLinkClassnames = classNames({
|
|
83
|
+
'envive-tw-underline': true,
|
|
84
|
+
'envive-tw-text-[#3C57AA]': true,
|
|
85
|
+
'hover:envive-tw-text-[#3C57AA]': true,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const headerDescriptionClassnames = classNames({
|
|
89
|
+
'envive-tw-text-[16px]': true,
|
|
90
|
+
'envive-tw-text-normal': true,
|
|
91
|
+
'envive-tw-font-medium': true,
|
|
92
|
+
'envive-tw-max-w-[70ch]': true,
|
|
93
|
+
'envive-tw-text-[#161844]': true,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const userIdClassnames = classNames({
|
|
97
|
+
'envive-tw-text-xs': true,
|
|
98
|
+
'envive-tw-text-gray-500': true,
|
|
99
|
+
'envive-tw-font-semibold': true,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div className="envive-tw-pb-0 envive-tw-mb-[24px] envive-tw-flex envive-tw-w-full envive-tw-flex-row envive-tw-items-start envive-tw-justify-between envive-tw-gap-3 envive-tw-px-[24px] envive-tw-pt-[24px]">
|
|
104
|
+
<div className="envive-tw-flex envive-tw-w-full envive-tw-flex-col envive-tw-items-stretch envive-tw-gap-3">
|
|
105
|
+
<div className="envive-tw-flex envive-tw-flex-row envive-tw-items-start envive-tw-justify-between envive-tw-gap-3">
|
|
106
|
+
<div className="envive-tw-max-w-[100%]">
|
|
107
|
+
<h2 className={headerTitleClassnames}>Give us feedback on this message</h2>
|
|
108
|
+
<p className={headerDescriptionClassnames}>
|
|
109
|
+
For UI bugs and Feature Ideas, please use{' '}
|
|
110
|
+
<a
|
|
111
|
+
href="https://spiffy-ai.notion.site/19fe47c0828780b1a6cfd0ac4373cebe"
|
|
112
|
+
target="_blank"
|
|
113
|
+
rel="noopener noreferrer"
|
|
114
|
+
className={headerLinkClassnames}
|
|
115
|
+
>
|
|
116
|
+
this form
|
|
117
|
+
</a>
|
|
118
|
+
.
|
|
119
|
+
</p>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-items-end envive-tw-gap-3">
|
|
123
|
+
<div className="envive-tw-flex envive-tw-flex-row envive-tw-items-center envive-tw-gap-2">
|
|
124
|
+
<p className={userIdClassnames}>User Id: {userId.slice(0, 4)}...</p>
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
onClick={handleCopyClick}
|
|
128
|
+
aria-label="Copy chat ID"
|
|
129
|
+
className="envive-tw-rounded-base envive-tw-border envive-tw-border-gray-300 envive-tw-px-2 envive-tw-py-0.5 envive-tw-text-xs envive-tw-font-bold hover:envive-tw-bg-gray-50"
|
|
130
|
+
>
|
|
131
|
+
Copy
|
|
132
|
+
</button>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
className="envive-tw-p-0 envive-tw-h-[16px] envive-tw-w-[16px]"
|
|
140
|
+
onClick={onClose}
|
|
141
|
+
>
|
|
142
|
+
<IconCloseVariant />
|
|
143
|
+
</button>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const ReportFormFields = ({
|
|
149
|
+
priority,
|
|
150
|
+
setPriority,
|
|
151
|
+
reportedBy,
|
|
152
|
+
onReportedByChanging,
|
|
153
|
+
reason,
|
|
154
|
+
onDescriptionChanging,
|
|
155
|
+
turnInfo,
|
|
156
|
+
setTurnInfo,
|
|
157
|
+
lastMessagesText,
|
|
158
|
+
lastSuggestionsText,
|
|
159
|
+
}: {
|
|
160
|
+
priority: ReportSessionRequestReportPriorityEnum;
|
|
161
|
+
setPriority: (key: string) => void;
|
|
162
|
+
reportedBy: string;
|
|
163
|
+
onReportedByChanging: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
164
|
+
reason: string;
|
|
165
|
+
onDescriptionChanging: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
166
|
+
turnInfo: TurnInfo;
|
|
167
|
+
setTurnInfo: (
|
|
168
|
+
e: ChangeEvent<HTMLTextAreaElement>,
|
|
169
|
+
field: 'message_correction' | 'suggestions_correction',
|
|
170
|
+
) => void;
|
|
171
|
+
lastMessagesText: string;
|
|
172
|
+
lastSuggestionsText: string;
|
|
173
|
+
}) => {
|
|
174
|
+
const requiredFieldClassnames = classNames({
|
|
175
|
+
'envive-tw-text-[#008000]': true,
|
|
176
|
+
'envive-tw-text-xs': true,
|
|
177
|
+
'envive-tw-font-normal': true,
|
|
178
|
+
'envive-tw-italic': true,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<form
|
|
183
|
+
onSubmit={e => {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
}}
|
|
186
|
+
className="envive-tw-pt-0 envive-tw-flex envive-tw-flex-col envive-tw-gap-[24px] envive-tw-px-[24px] envive-tw-pb-[8px]"
|
|
187
|
+
>
|
|
188
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-gap-2">
|
|
189
|
+
<div className="envive-tw-flex envive-tw-flex-row envive-tw-items-center envive-tw-gap-3">
|
|
190
|
+
<span
|
|
191
|
+
id="priority-label"
|
|
192
|
+
className="envive-tw-mb-0 envive-tw-flex envive-tw-shrink-0 envive-tw-items-center envive-tw-gap-2 envive-tw-text-[12px] envive-tw-font-bold envive-tw-text-[#161844]"
|
|
193
|
+
>
|
|
194
|
+
Priority
|
|
195
|
+
</span>
|
|
196
|
+
<GenericSelect
|
|
197
|
+
type="priority"
|
|
198
|
+
selectedKey={priority}
|
|
199
|
+
onSelect={key => {
|
|
200
|
+
setPriority(key as ReportSessionRequestReportPriorityEnum);
|
|
201
|
+
}}
|
|
202
|
+
aria-labelledby="priority-label"
|
|
203
|
+
/>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-gap-2">
|
|
208
|
+
<span
|
|
209
|
+
id="email-label"
|
|
210
|
+
className="envive-tw-flex envive-tw-items-center envive-tw-gap-2 envive-tw-text-[12px] envive-tw-font-bold envive-tw-text-[#161844]"
|
|
211
|
+
>
|
|
212
|
+
Your Email
|
|
213
|
+
<p className={requiredFieldClassnames}>* Required so we can follow up with you</p>
|
|
214
|
+
</span>
|
|
215
|
+
<input
|
|
216
|
+
className="envive-tw-rounded-md envive-tw-w-full envive-tw-border envive-tw-border-gray-300 envive-tw-px-3 envive-tw-py-2 envive-tw-text-sm"
|
|
217
|
+
placeholder="Email address"
|
|
218
|
+
value={reportedBy}
|
|
219
|
+
type="email"
|
|
220
|
+
onChange={onReportedByChanging}
|
|
221
|
+
aria-labelledby="email-label"
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-gap-[0]">
|
|
226
|
+
<span
|
|
227
|
+
id="chat-history-label"
|
|
228
|
+
className="envive-tw-flex envive-tw-items-center envive-tw-gap-2 envive-tw-text-[12px] envive-tw-font-bold envive-tw-text-[#161844]"
|
|
229
|
+
>
|
|
230
|
+
Chat History
|
|
231
|
+
</span>
|
|
232
|
+
<div
|
|
233
|
+
className="envive-tw-rounded-md envive-tw-h-[250px] envive-tw-w-full envive-tw-overflow-auto envive-tw-border envive-tw-border-[#D9D9D9] envive-tw-p-2"
|
|
234
|
+
aria-labelledby="chat-history-label"
|
|
235
|
+
>
|
|
236
|
+
<ChatEmbed />
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-gap-2">
|
|
241
|
+
<span
|
|
242
|
+
id="description-label"
|
|
243
|
+
className="envive-tw-flex envive-tw-items-center envive-tw-gap-2 envive-tw-text-[12px] envive-tw-font-bold envive-tw-text-[#161844]"
|
|
244
|
+
>
|
|
245
|
+
What is the problem with this message?
|
|
246
|
+
<p className={requiredFieldClassnames}>
|
|
247
|
+
* Required to train the model and generate the correct message
|
|
248
|
+
</p>
|
|
249
|
+
</span>
|
|
250
|
+
<textarea
|
|
251
|
+
className="envive-tw-rounded-md envive-tw-w-full envive-tw-border envive-tw-border-gray-300 envive-tw-px-3 envive-tw-py-2 envive-tw-text-sm"
|
|
252
|
+
placeholder="Please describe the issue"
|
|
253
|
+
value={reason}
|
|
254
|
+
onChange={onDescriptionChanging}
|
|
255
|
+
aria-labelledby="description-label"
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-gap-2">
|
|
260
|
+
<span
|
|
261
|
+
id="message-correction-label"
|
|
262
|
+
className="envive-tw-flex envive-tw-items-center envive-tw-gap-2 envive-tw-text-[12px] envive-tw-font-bold envive-tw-text-[#161844]"
|
|
263
|
+
>
|
|
264
|
+
What should the message have said?
|
|
265
|
+
<p className="envive-tw-text-xs envive-tw-font-normal envive-tw-italic envive-tw-text-gray-500">
|
|
266
|
+
Creating an alternative message will ensure the AI sounds the way you want.
|
|
267
|
+
</p>
|
|
268
|
+
</span>
|
|
269
|
+
<textarea
|
|
270
|
+
className="envive-tw-rounded-md envive-tw-w-full envive-tw-border envive-tw-border-gray-300 envive-tw-px-3 envive-tw-py-2 envive-tw-text-sm"
|
|
271
|
+
placeholder="Alternative phrasing of the message"
|
|
272
|
+
value={turnInfo.message_correction ?? lastMessagesText}
|
|
273
|
+
onChange={e => setTurnInfo(e, 'message_correction')}
|
|
274
|
+
rows={10}
|
|
275
|
+
aria-labelledby="message-correction-label"
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
<div className="envive-tw-flex envive-tw-flex-col envive-tw-gap-2">
|
|
280
|
+
<span
|
|
281
|
+
id="suggested-responses-label"
|
|
282
|
+
className="envive-tw-flex envive-tw-items-center envive-tw-gap-2 envive-tw-text-[12px] envive-tw-font-bold envive-tw-text-[#161844]"
|
|
283
|
+
>
|
|
284
|
+
What should the suggested responses for the user be?
|
|
285
|
+
</span>
|
|
286
|
+
<textarea
|
|
287
|
+
className="envive-tw-rounded-md envive-tw-w-full envive-tw-border envive-tw-border-gray-300 envive-tw-px-3 envive-tw-py-2 envive-tw-text-sm"
|
|
288
|
+
placeholder="Alternative suggested responses"
|
|
289
|
+
value={turnInfo.suggestions_correction ?? lastSuggestionsText}
|
|
290
|
+
onChange={e => setTurnInfo(e, 'suggestions_correction')}
|
|
291
|
+
rows={6}
|
|
292
|
+
aria-labelledby="suggested-responses-label"
|
|
293
|
+
/>
|
|
294
|
+
</div>
|
|
295
|
+
</form>
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const ReportFooter = ({
|
|
300
|
+
isReporting,
|
|
301
|
+
errorMessage,
|
|
302
|
+
reportedByIsInvalid,
|
|
303
|
+
isReasonInvalid,
|
|
304
|
+
onReportSession,
|
|
305
|
+
onClose,
|
|
306
|
+
}: {
|
|
307
|
+
isReporting: boolean;
|
|
308
|
+
errorMessage: string;
|
|
309
|
+
reportedByIsInvalid: boolean;
|
|
310
|
+
isReasonInvalid: boolean;
|
|
311
|
+
onReportSession: () => void;
|
|
312
|
+
onClose: () => void;
|
|
313
|
+
}) => {
|
|
314
|
+
const sendFeedbackButtonClassnames = classNames({
|
|
315
|
+
'envive-tw-flex': true,
|
|
316
|
+
'envive-tw-w-full': true,
|
|
317
|
+
'sm:envive-tw-w-[180px]': true,
|
|
318
|
+
'envive-tw-h-10': true,
|
|
319
|
+
'envive-tw-py-2.5': true,
|
|
320
|
+
'envive-tw-px-6': true,
|
|
321
|
+
'envive-tw-justify-center': true,
|
|
322
|
+
'envive-tw-items-center': true,
|
|
323
|
+
'envive-tw-gap-2': true,
|
|
324
|
+
'envive-tw-rounded-full': true,
|
|
325
|
+
'envive-tw-border': true,
|
|
326
|
+
'envive-tw-border-[#3C57AA]': true,
|
|
327
|
+
'envive-tw-bg-[#3C57AA]': true,
|
|
328
|
+
'envive-tw-text-white': true,
|
|
329
|
+
'hover:envive-tw-bg-[#2B4A8A]': true,
|
|
330
|
+
'disabled:envive-tw-opacity-50': true,
|
|
331
|
+
'disabled:envive-tw-cursor-not-allowed': true,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
const cancelButtonClassnames = classNames({
|
|
335
|
+
'envive-tw-flex': true,
|
|
336
|
+
'envive-tw-w-full': true,
|
|
337
|
+
'sm:envive-tw-w-[171px]': true,
|
|
338
|
+
'envive-tw-h-10': true,
|
|
339
|
+
'envive-tw-py-2.5': true,
|
|
340
|
+
'envive-tw-px-6': true,
|
|
341
|
+
'envive-tw-justify-center': true,
|
|
342
|
+
'envive-tw-items-center': true,
|
|
343
|
+
'envive-tw-gap-2': true,
|
|
344
|
+
'envive-tw-rounded-full': true,
|
|
345
|
+
'envive-tw-border': true,
|
|
346
|
+
'envive-tw-border-[#3C57AA]': true,
|
|
347
|
+
'envive-tw-text-[#3C57AA]': true,
|
|
348
|
+
'envive-tw-text-center': true,
|
|
349
|
+
'envive-tw-text-base': true,
|
|
350
|
+
'envive-tw-font-medium': true,
|
|
351
|
+
'envive-tw-bg-[#EDF2F7]': true,
|
|
352
|
+
'hover:envive-tw-bg-[#F5F5F5]': true,
|
|
353
|
+
'disabled:envive-tw-opacity-50': true,
|
|
354
|
+
'disabled:envive-tw-cursor-not-allowed': true,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const buttonFooterClassnames = classNames({
|
|
358
|
+
'envive-tw-flex': true,
|
|
359
|
+
'envive-tw-items-start': true,
|
|
360
|
+
'envive-tw-gap-6': true,
|
|
361
|
+
'envive-tw-justify-start': true,
|
|
362
|
+
'envive-tw-p-0': true,
|
|
363
|
+
'envive-tw-shadow-none': true,
|
|
364
|
+
'envive-tw-flex-0': true,
|
|
365
|
+
'envive-tw-flex-auto': true,
|
|
366
|
+
'envive-tw-flex-col': true,
|
|
367
|
+
'sm:envive-tw-flex-row': true,
|
|
368
|
+
'envive-tw-w-full': true,
|
|
369
|
+
'envive-tw-bottom-0': true,
|
|
370
|
+
'envive-tw-z-[1]': true,
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const footerClassnames = classNames({
|
|
374
|
+
'envive-tw-bg-[#FFFFFF70]': true,
|
|
375
|
+
'envive-tw-py-[24px]': true,
|
|
376
|
+
'envive-tw-sticky': true,
|
|
377
|
+
'envive-tw-bottom-0': true,
|
|
378
|
+
'envive-tw-w-full': true,
|
|
379
|
+
'envive-tw-px-[24px]': true,
|
|
380
|
+
'envive-tw-border-t': true,
|
|
381
|
+
'envive-tw-border-[#EBEBEB]': true,
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
return (
|
|
385
|
+
<div className={footerClassnames}>
|
|
386
|
+
<div className={buttonFooterClassnames}>
|
|
387
|
+
<button
|
|
388
|
+
type="button"
|
|
389
|
+
disabled={isReporting || reportedByIsInvalid || isReasonInvalid}
|
|
390
|
+
onClick={onReportSession}
|
|
391
|
+
className={sendFeedbackButtonClassnames}
|
|
392
|
+
>
|
|
393
|
+
{isReporting ? 'Sending...' : 'Send Feedback'}
|
|
394
|
+
</button>
|
|
395
|
+
<button
|
|
396
|
+
type="button"
|
|
397
|
+
disabled={isReporting}
|
|
398
|
+
onClick={onClose}
|
|
399
|
+
className={cancelButtonClassnames}
|
|
400
|
+
>
|
|
401
|
+
Cancel
|
|
402
|
+
</button>
|
|
403
|
+
{errorMessage && (
|
|
404
|
+
<div className="envive-tw-text-xs envive-tw-font-normal envive-tw-italic envive-tw-text-red-500">
|
|
405
|
+
{errorMessage}
|
|
406
|
+
</div>
|
|
407
|
+
)}
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
);
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
interface DrawerProps {
|
|
414
|
+
isOpen: boolean;
|
|
415
|
+
onClose: () => void;
|
|
416
|
+
children: React.ReactNode;
|
|
417
|
+
width?: string;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const Drawer = ({
|
|
421
|
+
isOpen,
|
|
422
|
+
onClose,
|
|
423
|
+
children,
|
|
424
|
+
width = 'md:envive-tw-w-[80%] lg:envive-tw-w-[67%]',
|
|
425
|
+
}: DrawerProps) => {
|
|
426
|
+
if (!isOpen) return null;
|
|
427
|
+
|
|
428
|
+
return (
|
|
429
|
+
<div className="envive-tw-fixed envive-tw-right-[0] envive-tw-top-[0] envive-tw-z-[9999] envive-tw-flex envive-tw-w-full envive-tw-flex-row envive-tw-justify-end">
|
|
430
|
+
<div
|
|
431
|
+
className="envive-tw-bg envive-tw-flex-grow envive-tw-bg-black/40"
|
|
432
|
+
onClick={onClose}
|
|
433
|
+
/>
|
|
434
|
+
<div className={`envive-tw-w-full ${width} envive-tw-h-screen`}>
|
|
435
|
+
<div className="envive-tw-min-h-0 envive-tw-px-0 envive-tw-relative envive-tw-flex envive-tw-h-screen envive-tw-w-full envive-tw-flex-col envive-tw-border envive-tw-border-solid envive-tw-border-[#0000ff] envive-tw-bg-white">
|
|
436
|
+
{children}
|
|
437
|
+
</div>
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
export const ReportIssue = () => {
|
|
444
|
+
const { messages, suggestions, userEvents } = useAtomValue(chatAtom);
|
|
445
|
+
const lastMessages = useAtomValue(lastAssistantMessageAtom);
|
|
446
|
+
const [lastMessagesText, setLastMessagesText] = useState<string>('');
|
|
447
|
+
const [lastSuggestionsText, setLastSuggestionsText] = useState<string>('');
|
|
448
|
+
const [lastSuggestions, setLastSuggestions] = useState<Suggestion[]>([]);
|
|
449
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
450
|
+
const [turnInfo, setTurnInfo] = useState<TurnInfo>({});
|
|
451
|
+
const reportType = ReportSessionRequestReportTypeEnum.Turn;
|
|
452
|
+
const [isReasonInvalid, setIsReasonInvalid] = useState(true);
|
|
453
|
+
const [reason, setReason] = useState('');
|
|
454
|
+
const [reportedBy, setReportedBy] = useState('');
|
|
455
|
+
const [reportedByIsInvalid, setReportedByIsInvalid] = useState(true);
|
|
456
|
+
const [isReporting, setIsReporting] = useState(false);
|
|
457
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
458
|
+
const [priority, setPriority] = useState<ReportSessionRequestReportPriorityEnum>(
|
|
459
|
+
ReportSessionRequestReportPriorityEnum.NoPriority,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
const userId = useAtomValue(userIdAtom);
|
|
463
|
+
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
464
|
+
const lastUserEvent =
|
|
465
|
+
userEvents && userEvents.length > 0 ? userEvents[userEvents.length - 1] : undefined;
|
|
466
|
+
|
|
467
|
+
const onOpen = useCallback(() => setIsOpen(true), []);
|
|
468
|
+
const onClose = useCallback(() => setIsOpen(false), []);
|
|
469
|
+
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
if (messages) {
|
|
472
|
+
const currentMessages = messages.length > 0 ? messages[messages.length - 1] : [];
|
|
473
|
+
if (currentMessages.length > 0 && lastUserEvent) {
|
|
474
|
+
setTurnInfo(prev => ({
|
|
475
|
+
...prev,
|
|
476
|
+
turn_idx: currentMessages.length - 1,
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}, [messages]);
|
|
481
|
+
|
|
482
|
+
useEffect(() => {
|
|
483
|
+
if (suggestions) {
|
|
484
|
+
setLastSuggestions(suggestions as unknown as Suggestion[]);
|
|
485
|
+
} else {
|
|
486
|
+
setLastSuggestions([]);
|
|
487
|
+
}
|
|
488
|
+
}, [suggestions]);
|
|
489
|
+
|
|
490
|
+
useEffect(() => {
|
|
491
|
+
if (lastUserEvent) {
|
|
492
|
+
setTurnInfo(prev => ({
|
|
493
|
+
...prev,
|
|
494
|
+
prev_user_event: {
|
|
495
|
+
id: lastUserEvent.eventId,
|
|
496
|
+
category: lastUserEvent.category,
|
|
497
|
+
},
|
|
498
|
+
}));
|
|
499
|
+
} else {
|
|
500
|
+
setTurnInfo(prev => ({ ...prev, prev_user_event: undefined }));
|
|
501
|
+
}
|
|
502
|
+
}, [lastUserEvent]);
|
|
503
|
+
|
|
504
|
+
useEffect(() => {
|
|
505
|
+
if (lastMessages) {
|
|
506
|
+
setLastMessagesText(
|
|
507
|
+
lastMessages
|
|
508
|
+
.filter(m => m.type !== MessageType.Separator)
|
|
509
|
+
.map(m => messageContent(m))
|
|
510
|
+
.join('\n\n'),
|
|
511
|
+
);
|
|
512
|
+
setTurnInfo(prev => ({
|
|
513
|
+
...prev,
|
|
514
|
+
messages: lastMessages.map(m => ({
|
|
515
|
+
id: m.id,
|
|
516
|
+
content: messageContent(m),
|
|
517
|
+
})),
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
}, [lastMessages]);
|
|
521
|
+
|
|
522
|
+
useEffect(() => {
|
|
523
|
+
if (lastSuggestions) {
|
|
524
|
+
const sortedSuggestions = [
|
|
525
|
+
...lastSuggestions.filter(s => s.is_answer),
|
|
526
|
+
...lastSuggestions.filter(s => !s.is_answer),
|
|
527
|
+
];
|
|
528
|
+
setLastSuggestionsText(`- ${sortedSuggestions.map(s => s.content).join('\n- ')}`);
|
|
529
|
+
setTurnInfo(prev => ({
|
|
530
|
+
...prev,
|
|
531
|
+
suggestions: sortedSuggestions.map(s => ({
|
|
532
|
+
id: s.id,
|
|
533
|
+
content: s.content,
|
|
534
|
+
})),
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
}, [lastSuggestions]);
|
|
538
|
+
|
|
539
|
+
const reportSession = useCallback(async () => {
|
|
540
|
+
try {
|
|
541
|
+
setIsReporting(true);
|
|
542
|
+
setErrorMessage('');
|
|
543
|
+
const request: ReportSessionRequest = {
|
|
544
|
+
user_id: userId,
|
|
545
|
+
reported_by: reportedBy,
|
|
546
|
+
org_short_name: orgShortName,
|
|
547
|
+
report_priority: priority,
|
|
548
|
+
reason,
|
|
549
|
+
turn_info: turnInfo,
|
|
550
|
+
report_type: reportType,
|
|
551
|
+
};
|
|
552
|
+
console.info('Submitting report', request);
|
|
553
|
+
await CommerceApiClient.reportSession(request);
|
|
554
|
+
onClose();
|
|
555
|
+
} catch (error) {
|
|
556
|
+
console.error('Error sending report', error);
|
|
557
|
+
setErrorMessage(
|
|
558
|
+
'There was an error sending the report. Please try again or contact Envive Support.',
|
|
559
|
+
);
|
|
560
|
+
} finally {
|
|
561
|
+
setIsReporting(false);
|
|
562
|
+
}
|
|
563
|
+
}, [userId, reportedBy, orgShortName, priority, reason, turnInfo, reportType, onClose]);
|
|
564
|
+
|
|
565
|
+
const onReportedByChanging = useCallback((e: ChangeEvent<HTMLInputElement>) => {
|
|
566
|
+
const reportedByValue = e.target.value;
|
|
567
|
+
const isEmail = validateEmail(reportedByValue);
|
|
568
|
+
setReportedByIsInvalid(!reportedByValue || !isEmail);
|
|
569
|
+
setReportedBy(reportedByValue);
|
|
570
|
+
}, []);
|
|
571
|
+
|
|
572
|
+
const onDescriptionChanging = useCallback((e: ChangeEvent<HTMLTextAreaElement>) => {
|
|
573
|
+
const descriptionValue = e.target.value;
|
|
574
|
+
setIsReasonInvalid(StringUtils.isNullOrEmpty(descriptionValue));
|
|
575
|
+
setReason(descriptionValue);
|
|
576
|
+
}, []);
|
|
577
|
+
|
|
578
|
+
const handlePriorityChange = useCallback((key: string) => {
|
|
579
|
+
setPriority(key as ReportSessionRequestReportPriorityEnum);
|
|
580
|
+
}, []);
|
|
581
|
+
|
|
582
|
+
const handleTurnInfoChange = useCallback(
|
|
583
|
+
(
|
|
584
|
+
e: ChangeEvent<HTMLTextAreaElement>,
|
|
585
|
+
field: 'message_correction' | 'suggestions_correction',
|
|
586
|
+
) => {
|
|
587
|
+
setTurnInfo(prev => ({ ...prev, [field]: e.target.value }));
|
|
588
|
+
},
|
|
589
|
+
[],
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
const buttonClassnames = classNames({
|
|
593
|
+
'envive-tw-underline': true,
|
|
594
|
+
'envive-tw-text-inherit': true,
|
|
595
|
+
'envive-tw-text-[12px]': true,
|
|
596
|
+
'envive-tw-cursor-pointer': true,
|
|
597
|
+
'envive-tw-bg-transparent': true,
|
|
598
|
+
'envive-tw-border-none': true,
|
|
599
|
+
'envive-tw-p-0': true,
|
|
600
|
+
'envive-tw-m-0': true,
|
|
601
|
+
'envive-tw-inline': true,
|
|
602
|
+
'envive-tw-z-[9999]': true,
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
return (
|
|
606
|
+
<div className="envive-tw-mx-[16px] envive-tw-block envive-tw-h-[24px] envive-tw-w-full">
|
|
607
|
+
<button
|
|
608
|
+
type="button"
|
|
609
|
+
onClick={e => {
|
|
610
|
+
e.preventDefault();
|
|
611
|
+
onOpen();
|
|
612
|
+
}}
|
|
613
|
+
className={buttonClassnames}
|
|
614
|
+
>
|
|
615
|
+
Give us feedback
|
|
616
|
+
</button>
|
|
617
|
+
<Drawer
|
|
618
|
+
isOpen={isOpen}
|
|
619
|
+
onClose={onClose}
|
|
620
|
+
>
|
|
621
|
+
<ReportHeader onClose={onClose} />
|
|
622
|
+
<div className="envive-tw-min-h-0 envive-tw-p-0 envive-tw-flex envive-tw-flex-[1_1_auto] envive-tw-flex-col envive-tw-overflow-y-auto">
|
|
623
|
+
{lastMessages && lastSuggestions && lastMessages.length > 0 && (
|
|
624
|
+
<ReportFormFields
|
|
625
|
+
priority={priority}
|
|
626
|
+
setPriority={handlePriorityChange}
|
|
627
|
+
reportedBy={reportedBy}
|
|
628
|
+
onReportedByChanging={onReportedByChanging}
|
|
629
|
+
reason={reason}
|
|
630
|
+
onDescriptionChanging={onDescriptionChanging}
|
|
631
|
+
turnInfo={turnInfo}
|
|
632
|
+
setTurnInfo={handleTurnInfoChange}
|
|
633
|
+
lastMessagesText={lastMessagesText}
|
|
634
|
+
lastSuggestionsText={lastSuggestionsText}
|
|
635
|
+
/>
|
|
636
|
+
)}
|
|
637
|
+
</div>
|
|
638
|
+
<ReportFooter
|
|
639
|
+
isReporting={isReporting}
|
|
640
|
+
errorMessage={errorMessage}
|
|
641
|
+
reportedByIsInvalid={reportedByIsInvalid}
|
|
642
|
+
isReasonInvalid={isReasonInvalid}
|
|
643
|
+
onReportSession={reportSession}
|
|
644
|
+
onClose={onClose}
|
|
645
|
+
/>
|
|
646
|
+
</Drawer>
|
|
647
|
+
</div>
|
|
648
|
+
);
|
|
649
|
+
};
|
|
@@ -362,6 +362,7 @@ describe('withBaseWidget', () => {
|
|
|
362
362
|
describe('Hardcopy content fetching', () => {
|
|
363
363
|
it('should fetch hardcopy content when widget mounts', async () => {
|
|
364
364
|
const mockHardcopy: HardcopyResponse = {
|
|
365
|
+
responseId: 'mock-response-id',
|
|
365
366
|
language: 'en',
|
|
366
367
|
values: {
|
|
367
368
|
suggestionBarButtons: ['Button 1', 'Button 2'],
|
|
@@ -393,6 +394,7 @@ describe('withBaseWidget', () => {
|
|
|
393
394
|
|
|
394
395
|
it('should pass hardcopy content to widget', async () => {
|
|
395
396
|
const mockHardcopy: HardcopyResponse = {
|
|
397
|
+
responseId: 'mock-response-id',
|
|
396
398
|
language: 'en',
|
|
397
399
|
values: {
|
|
398
400
|
chatPreviewTitle: 'Chat Preview Title',
|
|
@@ -498,6 +500,7 @@ describe('withBaseWidget', () => {
|
|
|
498
500
|
|
|
499
501
|
it('should render widget with hardcopy content when available', async () => {
|
|
500
502
|
const mockHardcopy: HardcopyResponse = {
|
|
503
|
+
responseId: 'mock-response-id',
|
|
501
504
|
language: 'en',
|
|
502
505
|
values: {
|
|
503
506
|
imagePromptTitle: 'Image Prompt Title',
|
|
@@ -528,6 +531,7 @@ describe('withBaseWidget', () => {
|
|
|
528
531
|
describe('Integration tests', () => {
|
|
529
532
|
it('should handle full flow: visibility tracking + hardcopy rendering', async () => {
|
|
530
533
|
const mockHardcopy: HardcopyResponse = {
|
|
534
|
+
responseId: 'mock-response-id',
|
|
531
535
|
language: 'en',
|
|
532
536
|
values: {
|
|
533
537
|
suggestionBarButtons: ['Button 1', 'Button 2', 'Button 3'],
|
|
@@ -580,10 +584,12 @@ describe('withBaseWidget', () => {
|
|
|
580
584
|
|
|
581
585
|
it('should handle multiple widget instances independently', async () => {
|
|
582
586
|
const mockHardcopy1: HardcopyResponse = {
|
|
587
|
+
responseId: 'mock-response-id',
|
|
583
588
|
language: 'en',
|
|
584
589
|
values: { buttons: ['Button 1'] },
|
|
585
590
|
};
|
|
586
591
|
const mockHardcopy2: HardcopyResponse = {
|
|
592
|
+
responseId: 'mock-response-id',
|
|
587
593
|
language: 'en',
|
|
588
594
|
values: { buttons: ['Button 2'] },
|
|
589
595
|
};
|