@microsoft/omnichannel-chat-widget 1.0.2 → 1.0.3-main.1acfc60
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/lib/cjs/common/Constants.js +54 -1
- package/lib/cjs/common/storage/default/defaultCacheManager.js +7 -6
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/cjs/common/telemetry/TelemetryConstants.js +7 -1
- package/lib/cjs/common/utils.js +27 -5
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -10
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -3
- package/lib/cjs/components/livechatwidget/common/endChat.js +197 -99
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +41 -21
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +139 -0
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -255
- package/lib/cjs/components/livechatwidget/common/startChat.js +85 -69
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +162 -100
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +18 -8
- package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +62 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +25 -12
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +16 -13
- package/lib/cjs/contexts/createReducer.js +13 -23
- package/lib/cjs/controller/componentController.js +2 -1
- package/lib/cjs/index.js +20 -0
- package/lib/esm/common/Constants.js +49 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +5 -4
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/esm/common/telemetry/TelemetryConstants.js +7 -1
- package/lib/esm/common/utils.js +25 -4
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -13
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -3
- package/lib/esm/components/livechatwidget/common/endChat.js +196 -99
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +41 -21
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +130 -0
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -255
- package/lib/esm/components/livechatwidget/common/startChat.js +86 -70
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +164 -102
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +18 -8
- package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -2
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +54 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +25 -12
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -15
- package/lib/esm/contexts/createReducer.js +13 -23
- package/lib/esm/controller/componentController.js +2 -1
- package/lib/esm/index.js +4 -1
- package/lib/types/common/Constants.d.ts +21 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +3 -3
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +2 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +7 -1
- package/lib/types/common/utils.d.ts +3 -2
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +6 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -6
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.d.ts +9 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +8 -7
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +2 -1
- package/lib/types/index.d.ts +3 -0
- package/package.json +2 -1
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +0 -36
- package/lib/cjs/contexts/common/ConversationEndEntity.js +0 -12
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +0 -30
- package/lib/esm/contexts/common/ConversationEndEntity.js +0 -5
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +0 -6
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +0 -4
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
|
-
import { Constants, E2VVOptions, LiveWorkItemState } from "../../../common/Constants";
|
|
5
4
|
import { Stack } from "@fluentui/react";
|
|
6
5
|
import React, { useEffect, useRef, useState } from "react";
|
|
7
6
|
import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
8
|
-
import { createTimer, getBroadcastChannelName,
|
|
7
|
+
import { createTimer, getBroadcastChannelName, getLocaleDirection, getStateFromCache, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty, getWidgetCacheIdfromProps, getConversationDetailsCall, newGuid } from "../../../common/utils";
|
|
9
8
|
import { endChat, prepareEndChat } from "../common/endChat";
|
|
10
|
-
import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
11
9
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
12
10
|
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
13
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
14
12
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
15
13
|
import { Components } from "botframework-webchat";
|
|
16
14
|
import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
|
|
17
|
-
import { ConversationEndEntity } from "../../../contexts/common/ConversationEndEntity";
|
|
18
15
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
19
16
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
17
|
+
import { Constants, E2VVOptions, StorageType, LiveWorkItemState, ConversationEndEntity, ConfirmationState } from "../../../common/Constants";
|
|
20
18
|
import { ElementType } from "@microsoft/omnichannel-chat-components";
|
|
21
19
|
import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
|
|
22
20
|
import HeaderStateful from "../../headerstateful/HeaderStateful";
|
|
@@ -38,20 +36,20 @@ import { defaultScrollBarProps } from "../common/defaultProps/defaultScrollBarPr
|
|
|
38
36
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
39
37
|
import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
|
|
40
38
|
import { getGeneralStylesForButton } from "../common/getGeneralStylesForButton";
|
|
41
|
-
import { handleAgentEndConversation } from "../common/agentEndConversationHelper";
|
|
42
39
|
import { handleChatDisconnect } from "../common/chatDisconnectHelper";
|
|
43
40
|
import { initCallingSdk } from "../common/initCallingSdk";
|
|
44
41
|
import { initConfirmationPropsComposer } from "../common/initConfirmationPropsComposer";
|
|
45
42
|
import { initWebChatComposer } from "../common/initWebChatComposer";
|
|
46
|
-
import {
|
|
43
|
+
import { registerBroadcastServiceForStorage } from "../../../common/storage/default/defaultCacheManager";
|
|
47
44
|
import { registerTelemetryLoggers } from "../common/registerTelemetryLoggers";
|
|
48
45
|
import { setPostChatContextAndLoadSurvey } from "../common/setPostChatContextAndLoadSurvey";
|
|
49
46
|
import { startProactiveChat } from "../common/startProactiveChat";
|
|
50
47
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
51
48
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
52
49
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
50
|
+
import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
53
51
|
export const LiveChatWidgetStateful = props => {
|
|
54
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$
|
|
52
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates10, _state$appStates15, _props$webChatContain6, _props$styleProps2, _props$controlProps11, _props$controlProps12, _props$componentOverr, _props$controlProps13, _props$componentOverr2, _props$controlProps14, _props$componentOverr3, _props$controlProps15, _props$componentOverr4, _props$controlProps16, _props$componentOverr5, _props$controlProps17, _props$componentOverr6, _props$controlProps18, _props$componentOverr7, _props$controlProps19, _props$controlProps20, _props$componentOverr8, _props$controlProps21, _props$componentOverr9, _props$controlProps22, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
55
53
|
const [state, dispatch] = useChatContextStore();
|
|
56
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
55
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -80,23 +78,25 @@ export const LiveChatWidgetStateful = props => {
|
|
|
80
78
|
TelemetryTimers.LcwLoadToChatButtonTimer = createTimer();
|
|
81
79
|
const widgetElementId = ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.id) || "oc-lcw";
|
|
82
80
|
const currentMessageCountRef = useRef(0);
|
|
81
|
+
let widgetStateEventId = "";
|
|
83
82
|
const lastLWICheckTimeRef = useRef(0);
|
|
84
|
-
let widgetStateEventName = "";
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
83
|
let optionalParams;
|
|
87
84
|
let activeCachedChatExist = false;
|
|
85
|
+
const uwid = useRef(""); // its an uniqueid per chatr instance
|
|
86
|
+
|
|
88
87
|
const setOptionalParams = () => {
|
|
89
|
-
var _state$appStates, _state$domainStates;
|
|
88
|
+
var _state$appStates, _state$domainStates, _state$appStates3;
|
|
90
89
|
if (!isUndefinedOrEmpty((_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.reconnectId)) {
|
|
90
|
+
var _state$appStates2;
|
|
91
91
|
activeCachedChatExist = true;
|
|
92
92
|
optionalParams = {
|
|
93
|
-
reconnectId: state.appStates.reconnectId
|
|
93
|
+
reconnectId: state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.reconnectId
|
|
94
94
|
};
|
|
95
|
-
} else if (!isUndefinedOrEmpty((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext)) {
|
|
95
|
+
} else if (!isUndefinedOrEmpty(state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationState) === ConversationState.Active) {
|
|
96
96
|
var _state$domainStates2;
|
|
97
97
|
activeCachedChatExist = true;
|
|
98
98
|
optionalParams = {
|
|
99
|
-
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
99
|
+
liveChatContext: state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
100
100
|
};
|
|
101
101
|
} else {
|
|
102
102
|
activeCachedChatExist = false;
|
|
@@ -107,7 +107,6 @@ export const LiveChatWidgetStateful = props => {
|
|
|
107
107
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
108
|
const startChat = async (props, localState) => {
|
|
109
109
|
let isChatValid = false;
|
|
110
|
-
|
|
111
110
|
//Start a chat from cache/reconnectid
|
|
112
111
|
if (activeCachedChatExist === true) {
|
|
113
112
|
dispatch({
|
|
@@ -138,9 +137,18 @@ export const LiveChatWidgetStateful = props => {
|
|
|
138
137
|
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, undefined, undefined, localState, props);
|
|
139
138
|
return;
|
|
140
139
|
} else {
|
|
140
|
+
var _state$appStates4;
|
|
141
|
+
// To avoid showing blank screen in popout
|
|
142
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.hideStartChatButton) === false) {
|
|
143
|
+
dispatch({
|
|
144
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
145
|
+
payload: ConversationState.Closed
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
141
149
|
dispatch({
|
|
142
150
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
143
|
-
payload: ConversationState.
|
|
151
|
+
payload: ConversationState.Loading
|
|
144
152
|
});
|
|
145
153
|
}
|
|
146
154
|
}
|
|
@@ -149,37 +157,42 @@ export const LiveChatWidgetStateful = props => {
|
|
|
149
157
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
158
|
const setupClientDataStore = () => {
|
|
151
159
|
// Add default localStorage support for widget
|
|
160
|
+
const widgetCacheId = getWidgetCacheIdfromProps(props);
|
|
152
161
|
if (props.contextDataStore === undefined) {
|
|
153
|
-
var _props$controlProps3
|
|
162
|
+
var _props$controlProps3;
|
|
154
163
|
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.cacheTtlInMins) ?? Constants.CacheTtlInMinutes;
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? StorageType.sessionStorage : StorageType.localStorage;
|
|
165
|
+
DataStoreManager.clientDataStore = defaultClientDataStoreProvider(cacheTtlInMins, storageType);
|
|
166
|
+
registerBroadcastServiceForStorage(widgetCacheId, cacheTtlInMins, storageType);
|
|
157
167
|
} else {
|
|
158
168
|
DataStoreManager.clientDataStore = props.contextDataStore;
|
|
159
169
|
}
|
|
160
170
|
};
|
|
161
171
|
useEffect(() => {
|
|
162
|
-
var _props$
|
|
172
|
+
var _props$controlProps4, _props$controlProps5, _props$controlProps6, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps8, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
173
|
+
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
174
|
+
state.domainStates.confirmationState = ConfirmationState.NotSet;
|
|
163
175
|
setupClientDataStore();
|
|
164
176
|
registerTelemetryLoggers(props, dispatch);
|
|
165
177
|
createInternetConnectionChangeHandler();
|
|
178
|
+
uwid.current = newGuid();
|
|
166
179
|
dispatch({
|
|
167
180
|
type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
168
181
|
payload: widgetElementId
|
|
169
182
|
});
|
|
170
183
|
dispatch({
|
|
171
184
|
type: LiveChatWidgetActionType.SET_START_CHAT_BUTTON_DISPLAY,
|
|
172
|
-
payload: ((_props$
|
|
185
|
+
payload: ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.hideStartChatButton) || false
|
|
173
186
|
});
|
|
174
187
|
dispatch({
|
|
175
188
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
176
189
|
payload: false
|
|
177
190
|
});
|
|
178
|
-
if ((_props$
|
|
179
|
-
var _props$
|
|
191
|
+
if ((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.widgetInstanceId && !isNullOrEmptyString((_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.widgetInstanceId)) {
|
|
192
|
+
var _props$controlProps7;
|
|
180
193
|
dispatch({
|
|
181
194
|
type: LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
182
|
-
payload: (_props$
|
|
195
|
+
payload: (_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId
|
|
183
196
|
});
|
|
184
197
|
}
|
|
185
198
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== E2VVOptions.NoCalling) {
|
|
@@ -198,7 +211,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
198
211
|
}
|
|
199
212
|
|
|
200
213
|
// Initialize global dir
|
|
201
|
-
const globalDir = ((_props$
|
|
214
|
+
const globalDir = ((_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.dir) ?? getLocaleDirection((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
202
215
|
dispatch({
|
|
203
216
|
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
204
217
|
payload: globalDir
|
|
@@ -206,25 +219,35 @@ export const LiveChatWidgetStateful = props => {
|
|
|
206
219
|
setOptionalParams();
|
|
207
220
|
|
|
208
221
|
// Unauth chat
|
|
209
|
-
if (state.appStates.hideStartChatButton === false) {
|
|
222
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates5 = state.appStates) === null || _state$appStates5 === void 0 ? void 0 : _state$appStates5.hideStartChatButton) === false) {
|
|
210
223
|
startChat(props);
|
|
211
224
|
}
|
|
212
225
|
}, []);
|
|
213
226
|
|
|
214
227
|
// useEffect for when skip chat button rendering
|
|
215
228
|
useEffect(() => {
|
|
216
|
-
|
|
229
|
+
var _state$appStates6;
|
|
230
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
|
|
231
|
+
var _props$chatConfig3, _props$chatConfig3$Li;
|
|
232
|
+
//handle OOH pane
|
|
233
|
+
if ((props === null || props === void 0 ? void 0 : (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
234
|
+
dispatch({
|
|
235
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
236
|
+
payload: ConversationState.OutOfOffice
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
217
240
|
BroadcastService.postMessage({
|
|
218
241
|
eventName: BroadcastEvent.ChatInitiated
|
|
219
242
|
});
|
|
220
243
|
//Pass the state to avoid getting stale state
|
|
221
244
|
startChat(props, state);
|
|
222
245
|
}
|
|
223
|
-
}, [state.appStates.hideStartChatButton]);
|
|
246
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates7 = state.appStates) === null || _state$appStates7 === void 0 ? void 0 : _state$appStates7.hideStartChatButton]);
|
|
224
247
|
|
|
225
248
|
// useEffect for custom context
|
|
226
249
|
useEffect(() => {
|
|
227
|
-
var _chatSDK$
|
|
250
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps10;
|
|
228
251
|
// Add the custom context on receiving the SetCustomContext event
|
|
229
252
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
230
253
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -253,11 +276,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
253
276
|
});
|
|
254
277
|
|
|
255
278
|
// Toggle chat visibility
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
256
280
|
BroadcastService.getMessageByEventName(BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(async event => {
|
|
257
281
|
var _event$payload;
|
|
258
282
|
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
259
|
-
var _props$
|
|
260
|
-
if ((_props$
|
|
283
|
+
var _props$controlProps9;
|
|
284
|
+
if ((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideStartChatButton) {
|
|
261
285
|
var _event$payload2;
|
|
262
286
|
dispatch({
|
|
263
287
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -284,14 +308,15 @@ export const LiveChatWidgetStateful = props => {
|
|
|
284
308
|
|
|
285
309
|
// Start chat from SDK Event
|
|
286
310
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
287
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
|
|
288
311
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
289
312
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
290
313
|
Description: "Start chat event received."
|
|
291
314
|
});
|
|
292
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
293
315
|
|
|
294
|
-
//
|
|
316
|
+
// DataStoreManager.clientDataStore?.swtichToSessionStorage(true);
|
|
317
|
+
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
318
|
+
|
|
319
|
+
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
295
320
|
if (persistedState === undefined) {
|
|
296
321
|
BroadcastService.postMessage({
|
|
297
322
|
eventName: BroadcastEvent.ChatInitiated
|
|
@@ -302,9 +327,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
302
327
|
|
|
303
328
|
// Chat exist in cache
|
|
304
329
|
if (persistedState) {
|
|
305
|
-
var _persistedState$
|
|
330
|
+
var _persistedState$appSt, _persistedState$appSt2, _persistedState$appSt3, _persistedState$appSt4;
|
|
306
331
|
// Only initiate new chat if widget state in cache in one of the followings
|
|
307
|
-
if (persistedState.appStates.conversationState === ConversationState.Closed || persistedState.appStates.conversationState === ConversationState.InActive || persistedState.appStates.conversationState === ConversationState.Postchat) {
|
|
332
|
+
if (((_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Closed || ((_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === ConversationState.InActive || ((_persistedState$appSt3 = persistedState.appStates) === null || _persistedState$appSt3 === void 0 ? void 0 : _persistedState$appSt3.conversationState) === ConversationState.Postchat) {
|
|
308
333
|
BroadcastService.postMessage({
|
|
309
334
|
eventName: BroadcastEvent.ChatInitiated
|
|
310
335
|
});
|
|
@@ -313,33 +338,33 @@ export const LiveChatWidgetStateful = props => {
|
|
|
313
338
|
}
|
|
314
339
|
|
|
315
340
|
// If minimized, maximize the chat
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
341
|
+
if ((persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt4 = persistedState.appStates) === null || _persistedState$appSt4 === void 0 ? void 0 : _persistedState$appSt4.isMinimized) === true) {
|
|
342
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
343
|
+
dispatch({
|
|
344
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
345
|
+
payload: false
|
|
346
|
+
});
|
|
347
|
+
BroadcastService.postMessage({
|
|
348
|
+
eventName: BroadcastEvent.MaximizeChat,
|
|
349
|
+
payload: {
|
|
350
|
+
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
351
|
+
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
327
355
|
}
|
|
328
356
|
});
|
|
329
357
|
|
|
330
358
|
// End chat
|
|
331
359
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const skipCloseChat = false;
|
|
341
|
-
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
342
|
-
}
|
|
360
|
+
// This is to ensure to get latest state from cache in multitab
|
|
361
|
+
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
362
|
+
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
363
|
+
prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
364
|
+
} else {
|
|
365
|
+
const skipEndChatSDK = true;
|
|
366
|
+
const skipCloseChat = false;
|
|
367
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
343
368
|
}
|
|
344
369
|
BroadcastService.postMessage({
|
|
345
370
|
eventName: BroadcastEvent.CloseChat
|
|
@@ -352,17 +377,15 @@ export const LiveChatWidgetStateful = props => {
|
|
|
352
377
|
});
|
|
353
378
|
|
|
354
379
|
// Listen to end chat event from other tabs
|
|
355
|
-
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
356
|
-
BroadcastService.getMessageByEventName(endChatEventName).subscribe(
|
|
357
|
-
|
|
358
|
-
|
|
380
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
|
|
381
|
+
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
382
|
+
console.log("Receiving end chat event", JSON.stringify(msg.payload));
|
|
383
|
+
if (msg.payload !== uwid.current) {
|
|
384
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
359
387
|
});
|
|
360
388
|
|
|
361
|
-
// When conversation ended by agent
|
|
362
|
-
if (state.appStates.conversationEndedBy === ConversationEndEntity.Agent) {
|
|
363
|
-
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
389
|
//Listen to WidgetSize, used for minimize to maximize
|
|
367
390
|
BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
368
391
|
dispatch({
|
|
@@ -411,6 +434,17 @@ export const LiveChatWidgetStateful = props => {
|
|
|
411
434
|
});
|
|
412
435
|
});
|
|
413
436
|
}
|
|
437
|
+
if (state.appStates.conversationState === ConversationState.InActive) {
|
|
438
|
+
var _props$webChatContain2, _props$webChatContain3;
|
|
439
|
+
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.renderingMiddlewareProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.hideSendboxOnConversationEnd) !== false) {
|
|
440
|
+
setWebChatStyles(styles => {
|
|
441
|
+
return {
|
|
442
|
+
...styles,
|
|
443
|
+
hideSendBox: true
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
414
448
|
}, [state.appStates.conversationState]);
|
|
415
449
|
useEffect(() => {
|
|
416
450
|
canStartProactiveChat.current = state.appStates.conversationState === ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
@@ -448,16 +482,55 @@ export const LiveChatWidgetStateful = props => {
|
|
|
448
482
|
}
|
|
449
483
|
}, [state.appStates.unreadMessageCount]);
|
|
450
484
|
useEffect(() => {
|
|
451
|
-
var _props$
|
|
485
|
+
var _props$webChatContain4;
|
|
452
486
|
setWebChatStyles({
|
|
453
487
|
...webChatStyles,
|
|
454
|
-
...((_props$
|
|
488
|
+
...((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.webChatStyles)
|
|
455
489
|
});
|
|
456
|
-
}, [(_props$
|
|
490
|
+
}, [(_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.webChatStyles]);
|
|
491
|
+
useEffect(() => {
|
|
492
|
+
//Confirmation pane dismissing through OK option, so proceed with end chat
|
|
493
|
+
if (state.domainStates.confirmationState === ConfirmationState.Ok) {
|
|
494
|
+
dispatch({
|
|
495
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
496
|
+
payload: ConversationEndEntity.Customer
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}, [state.domainStates.confirmationState]);
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
var _state$appStates8, _state$appStates9;
|
|
502
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates9 = state.appStates) === null || _state$appStates9 === void 0 ? void 0 : _state$appStates9.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
503
|
+
dispatch({
|
|
504
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
505
|
+
payload: ConversationState.InActive
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationEndedBy]);
|
|
509
|
+
useEffect(() => {
|
|
510
|
+
var _state$appStates11, _state$appStates12, _state$appStates13, _state$appStates14;
|
|
511
|
+
// Do not process anything during initialization
|
|
512
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationEndedBy) === ConversationEndEntity.NotSet) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// If start chat failed, and C2 is trying to close chat widget
|
|
517
|
+
if (state !== null && state !== void 0 && (_state$appStates12 = state.appStates) !== null && _state$appStates12 !== void 0 && _state$appStates12.startChatFailed) {
|
|
518
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
523
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationState) === ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationState) === ConversationState.InActive) {
|
|
524
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
//All other cases
|
|
529
|
+
prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
530
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates15 = state.appStates) === null || _state$appStates15 === void 0 ? void 0 : _state$appStates15.conversationEndedBy]);
|
|
457
531
|
|
|
458
532
|
// Publish chat widget state
|
|
459
533
|
useEffect(() => {
|
|
460
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
|
|
461
534
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
462
535
|
// Ghost chat scenarios
|
|
463
536
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -469,15 +542,15 @@ export const LiveChatWidgetStateful = props => {
|
|
|
469
542
|
const prompt = Constants.BrowserUnloadConfirmationMessage;
|
|
470
543
|
return prompt;
|
|
471
544
|
};
|
|
472
|
-
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
473
546
|
window.onunload = function () {
|
|
474
547
|
initiateEndChatOnBrowserUnload();
|
|
475
548
|
};
|
|
476
549
|
}*/
|
|
477
550
|
|
|
478
|
-
|
|
551
|
+
widgetStateEventId = getWidgetCacheIdfromProps(props);
|
|
479
552
|
const chatWidgetStateChangeEvent = {
|
|
480
|
-
eventName:
|
|
553
|
+
eventName: widgetStateEventId,
|
|
481
554
|
payload: {
|
|
482
555
|
...state
|
|
483
556
|
}
|
|
@@ -485,20 +558,6 @@ export const LiveChatWidgetStateful = props => {
|
|
|
485
558
|
BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
486
559
|
}, [state]);
|
|
487
560
|
|
|
488
|
-
// Initiate End chat from a single point
|
|
489
|
-
useEffect(() => {
|
|
490
|
-
if (state.appStates.conversationEndedBy !== undefined) {
|
|
491
|
-
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
492
|
-
}
|
|
493
|
-
}, [state.appStates.conversationEndedBy]);
|
|
494
|
-
|
|
495
|
-
// Handle Agent end conversation cases
|
|
496
|
-
useEffect(() => {
|
|
497
|
-
if (state.appStates.conversationEndedByAgentEventReceived) {
|
|
498
|
-
handleAgentEndConversation(props, state, dispatch);
|
|
499
|
-
}
|
|
500
|
-
}, [state.appStates.conversationEndedByAgentEventReceived]);
|
|
501
|
-
|
|
502
561
|
// Handle Chat disconnect cases
|
|
503
562
|
useEffect(() => {
|
|
504
563
|
if (state.appStates.chatDisconnectEventReceived) {
|
|
@@ -511,9 +570,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
511
570
|
Event: TelemetryEvent.BrowserUnloadEventStarted,
|
|
512
571
|
Description: "Browser unload event received."
|
|
513
572
|
});
|
|
514
|
-
endChat(props, chatSDK, setAdapter, setWebChatStyles,
|
|
573
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
|
|
515
574
|
// Clean local storage
|
|
516
|
-
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(
|
|
575
|
+
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventId);
|
|
517
576
|
|
|
518
577
|
//Dispose calling instance
|
|
519
578
|
if (voiceVideoCallingSDK) {
|
|
@@ -524,14 +583,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
524
583
|
eventName: BroadcastEvent.ClosePopoutWindow
|
|
525
584
|
});
|
|
526
585
|
};
|
|
527
|
-
const webChatProps = initWebChatComposer(props,
|
|
586
|
+
const webChatProps = initWebChatComposer(props, state, dispatch, chatSDK);
|
|
528
587
|
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
529
588
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
530
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, setAdapter, setWebChatStyles,
|
|
589
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab, uwid.current);
|
|
531
590
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
532
591
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
533
592
|
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
534
593
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
594
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
595
|
+
const prepareEndChatRelay = () => prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
535
596
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
536
597
|
::-webkit-scrollbar {
|
|
537
598
|
width: ${scrollbarProps.width};
|
|
@@ -551,35 +612,36 @@ export const LiveChatWidgetStateful = props => {
|
|
|
551
612
|
}
|
|
552
613
|
`), /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
553
614
|
styleOptions: webChatStyles,
|
|
554
|
-
directLine: ((_props$
|
|
615
|
+
directLine: ((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine
|
|
555
616
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
556
617
|
id: widgetElementId,
|
|
557
618
|
styles: generalStyles,
|
|
558
619
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
559
|
-
}, !((_props$
|
|
620
|
+
}, !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideChatButton) && !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideStartChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
560
621
|
buttonProps: props.chatButtonProps,
|
|
561
622
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
562
623
|
startChat: prepareStartChatRelay
|
|
563
|
-
})), !((_props$
|
|
624
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
564
625
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
565
626
|
startChat: prepareStartChatRelay
|
|
566
|
-
})), !((_props$
|
|
627
|
+
})), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
567
628
|
headerProps: props.headerProps,
|
|
568
629
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
569
630
|
endChat: endChatRelay
|
|
570
|
-
})), !((_props$
|
|
631
|
+
})), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, {
|
|
571
632
|
loadingPaneProps: props.loadingPaneProps,
|
|
572
633
|
startChatErrorPaneProps: props.startChatErrorPaneProps
|
|
573
|
-
})), !((_props$
|
|
634
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
574
635
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
575
636
|
initStartChat: initStartChatRelay
|
|
576
|
-
})), !((_props$
|
|
637
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
577
638
|
surveyProps: props.preChatSurveyPaneProps,
|
|
578
639
|
initStartChat: initStartChatRelay
|
|
579
|
-
})), !((_props$
|
|
640
|
+
})), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
580
641
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
581
|
-
}, props.callingContainerProps)), !((_props$
|
|
582
|
-
setPostChatContext: setPostChatContextRelay
|
|
583
|
-
|
|
642
|
+
}, props.callingContainerProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
643
|
+
setPostChatContext: setPostChatContextRelay,
|
|
644
|
+
prepareEndChat: prepareEndChatRelay
|
|
645
|
+
}))), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane)))));
|
|
584
646
|
};
|
|
585
647
|
export default LiveChatWidgetStateful;
|
|
@@ -56,8 +56,8 @@ export const LoadingPaneStateful = props => {
|
|
|
56
56
|
}, []);
|
|
57
57
|
return /*#__PURE__*/React.createElement(LoadingPane, {
|
|
58
58
|
componentOverrides: loadingPaneProps === null || loadingPaneProps === void 0 ? void 0 : loadingPaneProps.componentOverrides,
|
|
59
|
-
controlProps: state.appStates.
|
|
60
|
-
styleProps: state.appStates.
|
|
59
|
+
controlProps: state.appStates.startChatFailed ? errorUIControlProps : loadingPaneControlProps,
|
|
60
|
+
styleProps: state.appStates.startChatFailed ? errorUIStyleProps : loadingPaneStyleProps,
|
|
61
61
|
windowWidth: width,
|
|
62
62
|
windowHeight: height
|
|
63
63
|
});
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
|
+
import { ConversationEndEntity } from "../../common/Constants";
|
|
4
|
+
import { CustomerVoiceEvents } from "./enums/CustomerVoiceEvents";
|
|
5
|
+
import { PostChatSurveyMode } from "./enums/PostChatSurveyMode";
|
|
3
6
|
import { PostChatSurveyPane } from "@microsoft/omnichannel-chat-components";
|
|
4
7
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
5
8
|
import { defaultGeneralPostChatSurveyPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps";
|
|
6
9
|
import { findAllFocusableElement } from "../../common/utils";
|
|
7
10
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
|
|
12
|
+
let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
13
|
+
const surveyLink = `${surveyInviteLink}
|
|
14
|
+
&embed=${isEmbed.toString()}
|
|
15
|
+
&compact=${compact.toString() ?? "true"}
|
|
16
|
+
&lang=${locale ?? "en-us"}
|
|
17
|
+
&showmultilingual=${showMultiLingual.toString() ?? "false"}`;
|
|
18
|
+
return surveyLink;
|
|
19
|
+
};
|
|
10
20
|
export const PostChatSurveyPaneStateful = props => {
|
|
11
|
-
var
|
|
21
|
+
var _props$styleProps, _state$appStates, _state$appStates2, _props$controlProps;
|
|
12
22
|
const [state] = useChatContextStore();
|
|
13
|
-
const postChatSurveyMode = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveymode;
|
|
14
23
|
const generalStyleProps = Object.assign({}, defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
|
|
15
|
-
display: state.appStates.isMinimized ? "none" : ""
|
|
24
|
+
display: state.appStates.isMinimized ? "none" : "contents"
|
|
16
25
|
});
|
|
17
26
|
let surveyInviteLink = "";
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
const surveyMode = (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.selectedSurveyMode) === PostChatSurveyMode.Embed;
|
|
28
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Bot && state.domainStates.postChatContext.botSurveyInviteLink) {
|
|
29
|
+
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
20
30
|
} else {
|
|
21
|
-
surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink
|
|
31
|
+
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
22
32
|
}
|
|
23
33
|
const styleProps = {
|
|
24
34
|
...props.styleProps,
|