@microsoft/omnichannel-chat-widget 0.1.0-main.bcfe8a3 → 0.1.0-main.ceb1702
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/components/livechatwidget/common/startChat.js +30 -22
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +10 -14
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +27 -21
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +11 -15
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareStartChat = exports.initStartChat = void 0;
|
|
6
|
+
exports.setupChatState = exports.prepareStartChat = exports.initStartChat = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("../../../common/Constants");
|
|
9
9
|
|
|
@@ -53,11 +53,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
53
53
|
|
|
54
54
|
await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
55
55
|
} else {
|
|
56
|
-
// Getting
|
|
57
|
-
const parseToJson = false;
|
|
58
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
59
|
-
const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
60
|
-
|
|
56
|
+
// Getting reconnectId for authenticated chat
|
|
61
57
|
const reconnectId = await (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK);
|
|
62
58
|
|
|
63
59
|
if (reconnectId) {
|
|
@@ -69,29 +65,41 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
69
65
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
70
66
|
payload: _ConversationState.ConversationState.ReconnectChat
|
|
71
67
|
});
|
|
72
|
-
} else if (showPrechat) {
|
|
73
|
-
dispatch({
|
|
74
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
75
|
-
payload: preChatSurveyResponse
|
|
76
|
-
});
|
|
77
|
-
dispatch({
|
|
78
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
79
|
-
payload: _ConversationState.ConversationState.Prechat
|
|
80
|
-
});
|
|
81
|
-
setCustomContextParams(props, state);
|
|
82
68
|
} else {
|
|
83
|
-
dispatch({
|
|
84
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
85
|
-
payload: _ConversationState.ConversationState.Loading
|
|
86
|
-
});
|
|
87
69
|
setCustomContextParams(props, state);
|
|
88
|
-
|
|
70
|
+
setupChatState(chatSDK, dispatch, setAdapter, state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat, state.appStates.proactiveChatStates.proactiveChatEnablePrechat);
|
|
89
71
|
}
|
|
90
72
|
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.prepareStartChat = prepareStartChat;
|
|
76
|
+
|
|
77
|
+
const setupChatState = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
78
|
+
// Getting PreChat Survey Context
|
|
79
|
+
const parseToJson = false;
|
|
80
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
81
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
82
|
+
|
|
83
|
+
if (showPrechat) {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
86
|
+
payload: preChatSurveyResponse
|
|
87
|
+
});
|
|
88
|
+
dispatch({
|
|
89
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
90
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
95
|
+
payload: _ConversationState.ConversationState.Loading
|
|
96
|
+
});
|
|
97
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
98
|
+
}
|
|
91
99
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
100
|
|
|
93
101
|
|
|
94
|
-
exports.
|
|
102
|
+
exports.setupChatState = setupChatState;
|
|
95
103
|
|
|
96
104
|
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
97
105
|
try {
|
|
@@ -98,7 +98,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
98
98
|
function _extends() { _extends = Object.assign || 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); }
|
|
99
99
|
|
|
100
100
|
const LiveChatWidgetStateful = props => {
|
|
101
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$
|
|
101
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$controlProps6, _props$componentOverr, _props$controlProps7, _props$componentOverr2, _props$controlProps8, _props$componentOverr3, _props$controlProps9, _props$componentOverr4, _props$controlProps10, _props$componentOverr5, _props$controlProps11, _props$componentOverr6, _props$controlProps12, _props$componentOverr7, _props$controlProps13, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$controlProps16, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
102
102
|
|
|
103
103
|
const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
104
|
|
|
@@ -227,11 +227,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
227
227
|
|
|
228
228
|
_omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
229
229
|
|
|
230
|
-
dispatch
|
|
231
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
232
|
-
payload: _ConversationState.ConversationState.Loading
|
|
233
|
-
});
|
|
234
|
-
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter);
|
|
230
|
+
(0, _startChat.setupChatState)(chatSDK, dispatch, setAdapter);
|
|
235
231
|
}
|
|
236
232
|
});
|
|
237
233
|
}
|
|
@@ -469,29 +465,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
469
465
|
id: widgetElementId,
|
|
470
466
|
styles: generalStyles,
|
|
471
467
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
472
|
-
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
468
|
+
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.skipChatButtonRendering) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
473
469
|
buttonProps: props.chatButtonProps,
|
|
474
470
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
475
471
|
startChat: prepareStartChatRelay
|
|
476
|
-
})), !((_props$
|
|
472
|
+
})), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
|
|
477
473
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
478
474
|
startChat: prepareStartChatRelay
|
|
479
|
-
})), !((_props$
|
|
475
|
+
})), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
|
|
480
476
|
headerProps: props.headerProps,
|
|
481
477
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
482
478
|
endChat: endChatRelay
|
|
483
|
-
})), !((_props$
|
|
479
|
+
})), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
484
480
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
485
481
|
initStartChat: initStartChatRelay
|
|
486
|
-
})), !((_props$
|
|
482
|
+
})), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
487
483
|
surveyProps: props.preChatSurveyPaneProps,
|
|
488
484
|
initStartChat: initStartChatRelay
|
|
489
|
-
})), !((_props$
|
|
485
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
490
486
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
491
|
-
}, props.callingContainerProps)), !((_props$
|
|
487
|
+
}, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
492
488
|
setPostChatContext: setPostChatContextRelay,
|
|
493
489
|
prepareEndChat: prepareEndChatRelay
|
|
494
|
-
}))), !((_props$
|
|
490
|
+
}))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane))));
|
|
495
491
|
};
|
|
496
492
|
|
|
497
493
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
@@ -100,7 +100,7 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
100
100
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
101
101
|
let optionalParams = {};
|
|
102
102
|
|
|
103
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
|
|
103
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext && !state.appStates.skipChatButtonRendering) {
|
|
104
104
|
var _persistedState$domai2;
|
|
105
105
|
|
|
106
106
|
optionalParams = {
|
|
@@ -30,11 +30,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
30
30
|
|
|
31
31
|
await handleRedirectUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
32
32
|
} else {
|
|
33
|
-
// Getting
|
|
34
|
-
const parseToJson = false;
|
|
35
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
36
|
-
const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
37
|
-
|
|
33
|
+
// Getting reconnectId for authenticated chat
|
|
38
34
|
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
39
35
|
|
|
40
36
|
if (reconnectId) {
|
|
@@ -46,25 +42,35 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
46
42
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
47
43
|
payload: ConversationState.ReconnectChat
|
|
48
44
|
});
|
|
49
|
-
} else if (showPrechat) {
|
|
50
|
-
dispatch({
|
|
51
|
-
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
52
|
-
payload: preChatSurveyResponse
|
|
53
|
-
});
|
|
54
|
-
dispatch({
|
|
55
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
56
|
-
payload: ConversationState.Prechat
|
|
57
|
-
});
|
|
58
|
-
setCustomContextParams(props, state);
|
|
59
45
|
} else {
|
|
60
|
-
dispatch({
|
|
61
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
62
|
-
payload: ConversationState.Loading
|
|
63
|
-
});
|
|
64
46
|
setCustomContextParams(props, state);
|
|
65
|
-
|
|
47
|
+
setupChatState(chatSDK, dispatch, setAdapter, state.appStates.conversationState === ConversationState.ProactiveChat, state.appStates.proactiveChatStates.proactiveChatEnablePrechat);
|
|
66
48
|
}
|
|
67
49
|
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const setupChatState = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
53
|
+
// Getting PreChat Survey Context
|
|
54
|
+
const parseToJson = false;
|
|
55
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
56
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
57
|
+
|
|
58
|
+
if (showPrechat) {
|
|
59
|
+
dispatch({
|
|
60
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
61
|
+
payload: preChatSurveyResponse
|
|
62
|
+
});
|
|
63
|
+
dispatch({
|
|
64
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
65
|
+
payload: ConversationState.Prechat
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
dispatch({
|
|
69
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
70
|
+
payload: ConversationState.Loading
|
|
71
|
+
});
|
|
72
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
73
|
+
}
|
|
68
74
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
75
|
|
|
70
76
|
|
|
@@ -207,4 +213,4 @@ const setCustomContextParams = (props, state) => {
|
|
|
207
213
|
}
|
|
208
214
|
};
|
|
209
215
|
|
|
210
|
-
export { prepareStartChat, initStartChat };
|
|
216
|
+
export { prepareStartChat, initStartChat, setupChatState };
|
|
@@ -6,7 +6,7 @@ import { Stack } from "@fluentui/react";
|
|
|
6
6
|
import React, { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { createTimer, getLocaleDirection, getWidgetCacheId, getWidgetEndChatEventName } from "../../../common/utils";
|
|
8
8
|
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
9
|
-
import { initStartChat, prepareStartChat } from "../common/startChat";
|
|
9
|
+
import { initStartChat, prepareStartChat, setupChatState } from "../common/startChat";
|
|
10
10
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
11
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
12
12
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
@@ -44,7 +44,7 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
|
44
44
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
45
45
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
46
46
|
export const LiveChatWidgetStateful = props => {
|
|
47
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$
|
|
47
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$controlProps6, _props$componentOverr, _props$controlProps7, _props$componentOverr2, _props$controlProps8, _props$componentOverr3, _props$controlProps9, _props$componentOverr4, _props$controlProps10, _props$componentOverr5, _props$controlProps11, _props$componentOverr6, _props$controlProps12, _props$componentOverr7, _props$controlProps13, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$controlProps16, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
48
48
|
|
|
49
49
|
const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
50
|
|
|
@@ -171,11 +171,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
171
171
|
eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
172
172
|
};
|
|
173
173
|
BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
174
|
-
dispatch
|
|
175
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
176
|
-
payload: ConversationState.Loading
|
|
177
|
-
});
|
|
178
|
-
initStartChat(chatSDK, dispatch, setAdapter);
|
|
174
|
+
setupChatState(chatSDK, dispatch, setAdapter);
|
|
179
175
|
}
|
|
180
176
|
});
|
|
181
177
|
}
|
|
@@ -396,28 +392,28 @@ export const LiveChatWidgetStateful = props => {
|
|
|
396
392
|
id: widgetElementId,
|
|
397
393
|
styles: generalStyles,
|
|
398
394
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
399
|
-
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
395
|
+
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.skipChatButtonRendering) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
400
396
|
buttonProps: props.chatButtonProps,
|
|
401
397
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
402
398
|
startChat: prepareStartChatRelay
|
|
403
|
-
})), !((_props$
|
|
399
|
+
})), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
404
400
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
405
401
|
startChat: prepareStartChatRelay
|
|
406
|
-
})), !((_props$
|
|
402
|
+
})), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
407
403
|
headerProps: props.headerProps,
|
|
408
404
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
409
405
|
endChat: endChatRelay
|
|
410
|
-
})), !((_props$
|
|
406
|
+
})), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.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$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
411
407
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
412
408
|
initStartChat: initStartChatRelay
|
|
413
|
-
})), !((_props$
|
|
409
|
+
})), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
414
410
|
surveyProps: props.preChatSurveyPaneProps,
|
|
415
411
|
initStartChat: initStartChatRelay
|
|
416
|
-
})), !((_props$
|
|
412
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
417
413
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
418
|
-
}, props.callingContainerProps)), !((_props$
|
|
414
|
+
}, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.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$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
419
415
|
setPostChatContext: setPostChatContextRelay,
|
|
420
416
|
prepareEndChat: prepareEndChatRelay
|
|
421
|
-
}))), !((_props$
|
|
417
|
+
}))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.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))));
|
|
422
418
|
};
|
|
423
419
|
export default LiveChatWidgetStateful;
|
|
@@ -74,7 +74,7 @@ export const PreChatSurveyPaneStateful = props => {
|
|
|
74
74
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
75
75
|
let optionalParams = {};
|
|
76
76
|
|
|
77
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
|
|
77
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext && !state.appStates.skipChatButtonRendering) {
|
|
78
78
|
var _persistedState$domai2;
|
|
79
79
|
|
|
80
80
|
optionalParams = {
|
|
@@ -3,5 +3,6 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
|
|
|
3
3
|
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
5
|
declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
|
|
6
|
+
declare const setupChatState: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | undefined, proactiveChatEnablePrechatState?: boolean | undefined) => Promise<void>;
|
|
6
7
|
declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
|
|
7
|
-
export { prepareStartChat, initStartChat };
|
|
8
|
+
export { prepareStartChat, initStartChat, setupChatState };
|