@defra/flood-webchat 0.0.1-beta.2 → 0.0.1-beta.20
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/README.md +83 -1
- package/dist/client.js +1871 -212
- package/dist/client.js.map +1 -1
- package/dist/server.js +181 -240
- package/dist/server.js.map +1 -1
- package/main.scss +4 -3
- package/package.json +6 -2
- package/src/client/components/availability/availability.jsx +44 -46
- package/src/client/components/availability/availability.scss +105 -5
- package/src/client/components/chat/chat.jsx +169 -0
- package/src/client/components/chat/chat.scss +143 -0
- package/src/client/components/errorSummary/error-summary.jsx +34 -0
- package/src/client/components/message/message.jsx +20 -0
- package/src/client/components/panel/panel-footer.jsx +9 -0
- package/src/client/components/panel/panel-header.jsx +43 -0
- package/src/client/components/panel/panel.jsx +133 -0
- package/src/client/components/panel/panel.scss +72 -0
- package/src/client/components/screens/end-chat.jsx +35 -0
- package/src/client/components/screens/end-feedback.jsx +18 -0
- package/src/client/components/screens/feedback.jsx +149 -0
- package/src/client/components/screens/pre-chat.jsx +65 -0
- package/src/client/components/screens/request-chat.jsx +157 -0
- package/src/client/components/screens/settings.jsx +67 -0
- package/src/client/components/screens/unavailable.jsx +23 -0
- package/src/client/hooks/useFocusedElements.js +71 -0
- package/src/client/hooks/useTextareaAutosize.js +13 -0
- package/src/client/index.jsx +15 -1
- package/src/client/lib/check-availability.js +1 -0
- package/src/client/lib/message-notification.js +36 -0
- package/src/client/lib/transform-messages.js +35 -0
- package/src/client/store/AppProvider.jsx +140 -0
- package/src/client/store/actions-map.js +119 -0
- package/src/client/store/constants.js +3 -0
- package/src/client/store/reducer.js +28 -0
- package/src/client/store/useApp.js +5 -0
- package/src/client/store/useChatSdk.js +37 -0
- package/src/server/index.js +15 -6
- package/src/server/lib/client.js +31 -35
- package/src/server/lib/utils.js +18 -9
- package/src/client/lib/external-stores.js +0 -4
- package/src/client/lib/external-sync-store.js +0 -42
package/dist/client.js
CHANGED
|
@@ -15,80 +15,79 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15
15
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
16
16
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
17
17
|
/* harmony import */ var _lib_classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../lib/classnames */ "./src/client/lib/classnames.js");
|
|
18
|
-
/* harmony import */ var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var onClick = function onClick() {
|
|
39
|
-
setOpen(!isOpen);
|
|
40
|
-
};
|
|
41
|
-
var onKeyDown = function onKeyDown(event) {
|
|
18
|
+
/* harmony import */ var _panel_panel_jsx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../panel/panel.jsx */ "./src/client/components/panel/panel.jsx");
|
|
19
|
+
/* harmony import */ var _store_useApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../store/useApp */ "./src/client/store/useApp.js");
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function Availability() {
|
|
25
|
+
const {
|
|
26
|
+
availability,
|
|
27
|
+
isChatOpen,
|
|
28
|
+
setChatVisibility,
|
|
29
|
+
unseenCount,
|
|
30
|
+
threadId
|
|
31
|
+
} = (0,_store_useApp__WEBPACK_IMPORTED_MODULE_3__.useApp)();
|
|
32
|
+
const [isFixed, setIsFixed] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
|
|
33
|
+
const buttonRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
34
|
+
const onClick = () => {
|
|
35
|
+
setChatVisibility(!isChatOpen);
|
|
36
|
+
};
|
|
37
|
+
const onKeyDown = event => {
|
|
42
38
|
if (event.key === ' ') {
|
|
43
39
|
event.preventDefault();
|
|
44
40
|
}
|
|
45
41
|
};
|
|
46
|
-
|
|
42
|
+
const onKeyUp = event => {
|
|
47
43
|
if (event.key === ' ') {
|
|
48
|
-
|
|
44
|
+
setChatVisibility(!isChatOpen);
|
|
49
45
|
}
|
|
50
46
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setFixed(!isOpen && isBelowFold);
|
|
47
|
+
const intersectionCallback = entries => {
|
|
48
|
+
const [entry] = entries;
|
|
49
|
+
const isBelowFold = !entry.isIntersecting && entry.boundingClientRect.top > 0;
|
|
50
|
+
setIsFixed(!isChatOpen && isBelowFold && threadId);
|
|
56
51
|
};
|
|
57
|
-
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(
|
|
58
|
-
|
|
59
|
-
var observer = new window.IntersectionObserver(intersectionCallback, {
|
|
52
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
53
|
+
const observer = new window.IntersectionObserver(intersectionCallback, {
|
|
60
54
|
rootMargin: '35px'
|
|
61
55
|
});
|
|
62
|
-
|
|
56
|
+
const parentElement = buttonRef.current?.parentElement;
|
|
63
57
|
if (parentElement) {
|
|
64
58
|
observer.observe(parentElement);
|
|
65
59
|
}
|
|
66
|
-
return
|
|
60
|
+
return () => {
|
|
67
61
|
if (parentElement) {
|
|
68
62
|
observer.unobserve(parentElement);
|
|
69
63
|
}
|
|
70
64
|
};
|
|
71
|
-
}, [buttonRef,
|
|
72
|
-
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(
|
|
65
|
+
}, [buttonRef, isChatOpen]);
|
|
66
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
73
67
|
document.documentElement.classList.toggle('wc-scroll-padding', isFixed);
|
|
74
68
|
document.body.classList.toggle('wc-scroll-padding', isFixed);
|
|
75
69
|
}, [isFixed]);
|
|
76
|
-
|
|
70
|
+
let TextComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, "Show Chat");
|
|
71
|
+
if (!threadId) {
|
|
72
|
+
TextComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, "Start Chat");
|
|
73
|
+
}
|
|
74
|
+
switch (availability) {
|
|
77
75
|
case 'AVAILABLE':
|
|
78
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
79
|
-
className: (0,_lib_classnames__WEBPACK_IMPORTED_MODULE_1__.classnames)('wc-availability', isFixed && 'wc-availability--fixed'),
|
|
76
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
77
|
+
className: (0,_lib_classnames__WEBPACK_IMPORTED_MODULE_1__.classnames)('wc-availability', isFixed && 'wc-availability--fixed', isChatOpen && 'wc-open'),
|
|
80
78
|
ref: buttonRef
|
|
81
79
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
82
80
|
className: "wc-availability__inner"
|
|
83
81
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
84
82
|
className: "wc-availability__link",
|
|
85
83
|
href: "#webchat",
|
|
86
|
-
role: "button",
|
|
87
84
|
draggable: "false",
|
|
88
85
|
onClick: onClick,
|
|
89
86
|
onKeyUp: onKeyUp,
|
|
90
87
|
onKeyDown: onKeyDown
|
|
91
|
-
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(
|
|
88
|
+
}, TextComponent, unseenCount > 0 && !isChatOpen ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
89
|
+
className: "wc-open-btn__unseen"
|
|
90
|
+
}, unseenCount) : null))), isChatOpen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_jsx__WEBPACK_IMPORTED_MODULE_2__.Panel, null));
|
|
92
91
|
case 'EXISTING':
|
|
93
92
|
case 'UNAVAILABLE':
|
|
94
93
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
@@ -100,25 +99,1259 @@ function Availability(props) {
|
|
|
100
99
|
}, "Checking availability");
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
|
|
103
|
+
/***/ }),
|
|
104
|
+
|
|
105
|
+
/***/ "./src/client/components/chat/chat.jsx":
|
|
106
|
+
/*!*********************************************!*\
|
|
107
|
+
!*** ./src/client/components/chat/chat.jsx ***!
|
|
108
|
+
\*********************************************/
|
|
109
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
110
|
+
|
|
111
|
+
__webpack_require__.r(__webpack_exports__);
|
|
112
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
113
|
+
/* harmony export */ Chat: () => (/* binding */ Chat)
|
|
114
|
+
/* harmony export */ });
|
|
115
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
116
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
117
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
118
|
+
/* harmony import */ var _panel_panel_footer_jsx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../panel/panel-footer.jsx */ "./src/client/components/panel/panel-footer.jsx");
|
|
119
|
+
/* harmony import */ var _message_message_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../message/message.jsx */ "./src/client/components/message/message.jsx");
|
|
120
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
121
|
+
/* harmony import */ var _hooks_useTextareaAutosize_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../hooks/useTextareaAutosize.js */ "./src/client/hooks/useTextareaAutosize.js");
|
|
122
|
+
/* harmony import */ var _lib_transform_messages_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../lib/transform-messages.js */ "./src/client/lib/transform-messages.js");
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
function Chat({
|
|
131
|
+
onEndChatScreen,
|
|
132
|
+
onSettingsScreen
|
|
133
|
+
}) {
|
|
134
|
+
const {
|
|
135
|
+
availability,
|
|
136
|
+
thread,
|
|
137
|
+
messages,
|
|
138
|
+
agent,
|
|
139
|
+
agentStatus,
|
|
140
|
+
isAgentTyping,
|
|
141
|
+
settings
|
|
142
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
143
|
+
const [userMessage, setUserMessage] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('');
|
|
144
|
+
const messageRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
145
|
+
(0,_hooks_useTextareaAutosize_js__WEBPACK_IMPORTED_MODULE_5__.useTextareaAutosize)(messageRef.current, userMessage);
|
|
146
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
147
|
+
if (settings.scroll && messages.length !== 0) {
|
|
148
|
+
const chatBody = document.querySelector('.wc-body');
|
|
149
|
+
chatBody.scrollTop = chatBody.scrollHeight;
|
|
150
|
+
}
|
|
151
|
+
}, [messages, isAgentTyping]);
|
|
152
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
153
|
+
const label = document.querySelector('.wc-form__label');
|
|
154
|
+
if (userMessage.length === 0) {
|
|
155
|
+
label.classList.remove('govuk-visually-hidden');
|
|
156
|
+
} else {
|
|
157
|
+
label.classList.add('govuk-visually-hidden');
|
|
158
|
+
}
|
|
159
|
+
}, [userMessage]);
|
|
160
|
+
const onChange = e => {
|
|
161
|
+
setUserMessage(e.target?.value);
|
|
162
|
+
};
|
|
163
|
+
const agentName = agent?.nickname || agent?.firstName;
|
|
164
|
+
let connectionHeadlineText = 'Connecting to Floodline';
|
|
165
|
+
if (agentStatus === 'closed') {
|
|
166
|
+
connectionHeadlineText = agentName ? `${agentName} ended the session` : 'Session ended by advisor';
|
|
167
|
+
} else if (agentStatus) {
|
|
168
|
+
if (agentName) {
|
|
169
|
+
connectionHeadlineText = `You are speaking with ${agentName}`;
|
|
170
|
+
} else {
|
|
171
|
+
connectionHeadlineText = 'No advisers currently available';
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (availability === 'UNAVAILABLE') {
|
|
175
|
+
connectionHeadlineText = 'Webchat is not currently available';
|
|
176
|
+
}
|
|
177
|
+
const sendMessage = e => {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
if (messageRef.current.value.length === 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
thread.sendTextMessage(messageRef.current.value.trim());
|
|
184
|
+
} catch (err) {
|
|
185
|
+
console.log('[Chat Error] sendMessage', err);
|
|
186
|
+
}
|
|
187
|
+
setUserMessage('');
|
|
188
|
+
};
|
|
189
|
+
const saveChat = () => {
|
|
190
|
+
const transcript = (0,_lib_transform_messages_js__WEBPACK_IMPORTED_MODULE_6__.formatTranscript)(messages);
|
|
191
|
+
const saveChatLink = document.querySelector('#transcript-download');
|
|
192
|
+
saveChatLink.setAttribute('href', `data:text/plain;charset=utf-8,${transcript}`);
|
|
193
|
+
saveChatLink.click();
|
|
194
|
+
};
|
|
195
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
196
|
+
className: "wc-status"
|
|
197
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
198
|
+
className: "wc-status__availability govuk-body-s"
|
|
199
|
+
}, connectionHeadlineText), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
200
|
+
className: "wc-status__link govuk-!-font-size-16",
|
|
201
|
+
href: "#",
|
|
202
|
+
"data-module": "govuk-button",
|
|
203
|
+
onClick: onEndChatScreen
|
|
204
|
+
}, "End chat")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
205
|
+
className: "wc-body"
|
|
206
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
207
|
+
className: "wc-chat__body"
|
|
208
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
|
|
209
|
+
className: "wc-chat__messages"
|
|
210
|
+
}, messages.length ? messages.map((msg, index) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_message_message_jsx__WEBPACK_IMPORTED_MODULE_3__.Message, {
|
|
211
|
+
key: msg.id,
|
|
212
|
+
message: msg,
|
|
213
|
+
previousMessage: messages[index - 1]
|
|
214
|
+
})) : null, isAgentTyping ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
|
|
215
|
+
className: "wc-chat__message govuk-body outbound"
|
|
216
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
217
|
+
className: "wc-chat__from govuk-!-font-size-14"
|
|
218
|
+
}, agentName, " is typing"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
219
|
+
className: "wc-chat__text outbound"
|
|
220
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", {
|
|
221
|
+
width: "28",
|
|
222
|
+
height: "16",
|
|
223
|
+
x: "0px",
|
|
224
|
+
y: "0px",
|
|
225
|
+
viewBox: "0 0 28 16"
|
|
226
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("circle", {
|
|
227
|
+
stroke: "none",
|
|
228
|
+
cx: "3",
|
|
229
|
+
cy: "8",
|
|
230
|
+
r: "3",
|
|
231
|
+
fill: "currentColor"
|
|
232
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("circle", {
|
|
233
|
+
stroke: "none",
|
|
234
|
+
cx: "14",
|
|
235
|
+
cy: "8",
|
|
236
|
+
r: "3",
|
|
237
|
+
fill: "currentColor"
|
|
238
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("circle", {
|
|
239
|
+
stroke: "none",
|
|
240
|
+
cx: "25",
|
|
241
|
+
cy: "8",
|
|
242
|
+
r: "3",
|
|
243
|
+
fill: "currentColor"
|
|
244
|
+
})))) : null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_footer_jsx__WEBPACK_IMPORTED_MODULE_2__.PanelFooter, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
245
|
+
className: "wc-footer__input"
|
|
246
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("form", {
|
|
247
|
+
className: "wc-form",
|
|
248
|
+
noValidate: true
|
|
249
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
250
|
+
className: "govuk-label wc-form__label govuk-!-font-size-16",
|
|
251
|
+
htmlFor: "wc-form-textarea"
|
|
252
|
+
}, "Your message", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
253
|
+
className: "govuk-visually-hidden"
|
|
254
|
+
}, " (enter key submits)")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("textarea", {
|
|
255
|
+
ref: messageRef,
|
|
256
|
+
rows: "1",
|
|
257
|
+
"aria-required": "true",
|
|
258
|
+
className: "wc-form__textarea govuk-textarea govuk-!-font-size-16",
|
|
259
|
+
id: "wc-form-textarea",
|
|
260
|
+
name: "message",
|
|
261
|
+
onChange: onChange,
|
|
262
|
+
value: userMessage
|
|
263
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
264
|
+
type: "submit",
|
|
265
|
+
className: "wc-form__button govuk-button govuk-!-font-size-16",
|
|
266
|
+
value: "Send",
|
|
267
|
+
"data-prevent-double-click": "true",
|
|
268
|
+
onClick: sendMessage
|
|
269
|
+
}))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
270
|
+
className: "wc-footer__settings"
|
|
271
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
272
|
+
href: "#",
|
|
273
|
+
id: "wc-settings",
|
|
274
|
+
className: "wc-footer__settings-link",
|
|
275
|
+
"data-module": "govuk-button",
|
|
276
|
+
onClick: onSettingsScreen
|
|
277
|
+
}, "Settings"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
278
|
+
href: "#",
|
|
279
|
+
id: "transcript-download",
|
|
280
|
+
className: "wc-footer__settings-link",
|
|
281
|
+
"data-module": "govuk-button",
|
|
282
|
+
download: "floodline-webchat-transcript.txt",
|
|
283
|
+
onClick: saveChat
|
|
284
|
+
}, "Save chat"))));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/***/ }),
|
|
288
|
+
|
|
289
|
+
/***/ "./src/client/components/errorSummary/error-summary.jsx":
|
|
290
|
+
/*!**************************************************************!*\
|
|
291
|
+
!*** ./src/client/components/errorSummary/error-summary.jsx ***!
|
|
292
|
+
\**************************************************************/
|
|
293
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
294
|
+
|
|
295
|
+
__webpack_require__.r(__webpack_exports__);
|
|
296
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
297
|
+
/* harmony export */ ErrorSummary: () => (/* binding */ ErrorSummary)
|
|
298
|
+
/* harmony export */ });
|
|
299
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
300
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
301
|
+
|
|
302
|
+
const ErrorSummary = ({
|
|
303
|
+
errors
|
|
304
|
+
}) => {
|
|
305
|
+
const errs = Object.keys(errors);
|
|
306
|
+
const goToInput = e => {
|
|
307
|
+
e.preventDefault();
|
|
308
|
+
const key = e.target.getAttribute('data-key');
|
|
309
|
+
document.querySelector(`#wc-${key}`).focus();
|
|
310
|
+
};
|
|
311
|
+
if (errs.length === 0) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
315
|
+
className: "govuk-error-summary govuk-!-static-margin-bottom-7",
|
|
316
|
+
"data-module": "govuk-error-summary",
|
|
317
|
+
tabIndex: "-1"
|
|
318
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
319
|
+
role: "alert"
|
|
320
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h2", {
|
|
321
|
+
id: "wc-error",
|
|
322
|
+
className: "govuk-error-summary__title"
|
|
323
|
+
}, "There is a problem"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
324
|
+
className: "govuk-error-summary__body"
|
|
325
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
|
|
326
|
+
className: "govuk-list govuk-error-summary__list"
|
|
327
|
+
}, errs.map(key => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
|
|
328
|
+
key: key
|
|
329
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
330
|
+
href: "#",
|
|
331
|
+
"data-key": key,
|
|
332
|
+
onClick: goToInput
|
|
333
|
+
}, errors[key])))))));
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/***/ }),
|
|
337
|
+
|
|
338
|
+
/***/ "./src/client/components/message/message.jsx":
|
|
339
|
+
/*!***************************************************!*\
|
|
340
|
+
!*** ./src/client/components/message/message.jsx ***!
|
|
341
|
+
\***************************************************/
|
|
342
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
343
|
+
|
|
344
|
+
__webpack_require__.r(__webpack_exports__);
|
|
345
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
346
|
+
/* harmony export */ Message: () => (/* binding */ Message)
|
|
347
|
+
/* harmony export */ });
|
|
348
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
349
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
350
|
+
/* harmony import */ var _lib_classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../lib/classnames */ "./src/client/lib/classnames.js");
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
function Message({
|
|
354
|
+
message,
|
|
355
|
+
previousMessage
|
|
356
|
+
}) {
|
|
357
|
+
const outbound = message.direction === 'outbound';
|
|
358
|
+
const messageOwnerSameAsPrevious = message?.direction === previousMessage?.direction;
|
|
359
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
|
|
360
|
+
className: (0,_lib_classnames__WEBPACK_IMPORTED_MODULE_1__.classnames)('wc-chat__message govuk-body', outbound ? 'outbound' : 'inbound')
|
|
361
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
362
|
+
className: "wc-chat__from govuk-!-font-size-14"
|
|
363
|
+
}, messageOwnerSameAsPrevious ? null : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", null, outbound ? message.assignee : 'You'), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
364
|
+
className: "govuk-visually-hidden"
|
|
365
|
+
}, ":")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
366
|
+
className: (0,_lib_classnames__WEBPACK_IMPORTED_MODULE_1__.classnames)('wc-chat__text', 'govuk-body-s', outbound ? 'outbound' : 'inbound')
|
|
367
|
+
}, message.text));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/***/ }),
|
|
371
|
+
|
|
372
|
+
/***/ "./src/client/components/panel/panel-footer.jsx":
|
|
373
|
+
/*!******************************************************!*\
|
|
374
|
+
!*** ./src/client/components/panel/panel-footer.jsx ***!
|
|
375
|
+
\******************************************************/
|
|
376
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
377
|
+
|
|
378
|
+
__webpack_require__.r(__webpack_exports__);
|
|
379
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
380
|
+
/* harmony export */ PanelFooter: () => (/* binding */ PanelFooter)
|
|
381
|
+
/* harmony export */ });
|
|
382
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
383
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
384
|
+
|
|
385
|
+
function PanelFooter({
|
|
386
|
+
children
|
|
387
|
+
}) {
|
|
388
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
389
|
+
className: "wc-footer"
|
|
390
|
+
}, children);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/***/ }),
|
|
394
|
+
|
|
395
|
+
/***/ "./src/client/components/panel/panel-header.jsx":
|
|
396
|
+
/*!******************************************************!*\
|
|
397
|
+
!*** ./src/client/components/panel/panel-header.jsx ***!
|
|
398
|
+
\******************************************************/
|
|
399
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
400
|
+
|
|
401
|
+
__webpack_require__.r(__webpack_exports__);
|
|
402
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
403
|
+
/* harmony export */ PanelHeader: () => (/* binding */ PanelHeader)
|
|
404
|
+
/* harmony export */ });
|
|
405
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
406
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
407
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
function PanelHeader() {
|
|
411
|
+
const {
|
|
412
|
+
thread,
|
|
413
|
+
setChatVisibility,
|
|
414
|
+
setUnseenCount
|
|
415
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_1__.useApp)();
|
|
416
|
+
const onClose = e => {
|
|
417
|
+
e.preventDefault();
|
|
418
|
+
setChatVisibility(false);
|
|
419
|
+
if (thread) {
|
|
420
|
+
thread.lastMessageSeen();
|
|
421
|
+
setUnseenCount(0);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
let ButtonComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
|
|
425
|
+
className: "wc-header__close",
|
|
426
|
+
"aria-label": "Close the webchat",
|
|
427
|
+
onClick: onClose
|
|
428
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", {
|
|
429
|
+
"aria-hidden": "true",
|
|
430
|
+
focusable: "false",
|
|
431
|
+
width: "20",
|
|
432
|
+
height: "20",
|
|
433
|
+
viewBox: "0 0 20 20"
|
|
434
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("path", {
|
|
435
|
+
d: "M10,8.6L15.6,3L17,4.4L11.4,10L17,15.6L15.6,17L10,11.4L4.4,17L3,15.6L8.6,10L3,4.4L4.4,3L10,8.6Z",
|
|
436
|
+
fill: "currentColor"
|
|
437
|
+
})));
|
|
438
|
+
if (thread) {
|
|
439
|
+
ButtonComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
|
|
440
|
+
className: "wc-header__hide",
|
|
441
|
+
"aria-label": "Minimise the webchat",
|
|
442
|
+
onClick: onClose
|
|
443
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", {
|
|
444
|
+
"aria-hidden": "true",
|
|
445
|
+
focusable: "false",
|
|
446
|
+
width: "20",
|
|
447
|
+
height: "20",
|
|
448
|
+
viewBox: "0 0 20 20"
|
|
449
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("path", {
|
|
450
|
+
d: "M10 14.4l-7-7L4.4 6l5.6 5.6L15.6 6 17 7.4l-7 7z",
|
|
451
|
+
fill: "currentColor"
|
|
452
|
+
})));
|
|
453
|
+
}
|
|
454
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
455
|
+
className: "wc-header"
|
|
456
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h2", {
|
|
457
|
+
id: "wc-header-title",
|
|
458
|
+
className: "wc-header__title govuk-heading-s"
|
|
459
|
+
}, "Floodline Webchat"), ButtonComponent);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/***/ }),
|
|
463
|
+
|
|
464
|
+
/***/ "./src/client/components/panel/panel.jsx":
|
|
465
|
+
/*!***********************************************!*\
|
|
466
|
+
!*** ./src/client/components/panel/panel.jsx ***!
|
|
467
|
+
\***********************************************/
|
|
468
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
469
|
+
|
|
470
|
+
__webpack_require__.r(__webpack_exports__);
|
|
471
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
472
|
+
/* harmony export */ Panel: () => (/* binding */ Panel)
|
|
473
|
+
/* harmony export */ });
|
|
474
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
475
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
476
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "react-dom");
|
|
477
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
478
|
+
/* harmony import */ var _screens_pre_chat_jsx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../screens/pre-chat.jsx */ "./src/client/components/screens/pre-chat.jsx");
|
|
479
|
+
/* harmony import */ var _screens_request_chat_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../screens/request-chat.jsx */ "./src/client/components/screens/request-chat.jsx");
|
|
480
|
+
/* harmony import */ var _chat_chat_jsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../chat/chat.jsx */ "./src/client/components/chat/chat.jsx");
|
|
481
|
+
/* harmony import */ var _screens_unavailable_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../screens/unavailable.jsx */ "./src/client/components/screens/unavailable.jsx");
|
|
482
|
+
/* harmony import */ var _screens_end_chat_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../screens/end-chat.jsx */ "./src/client/components/screens/end-chat.jsx");
|
|
483
|
+
/* harmony import */ var _screens_settings_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../screens/settings.jsx */ "./src/client/components/screens/settings.jsx");
|
|
484
|
+
/* harmony import */ var _screens_feedback_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../screens/feedback.jsx */ "./src/client/components/screens/feedback.jsx");
|
|
485
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
486
|
+
/* harmony import */ var _store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../store/useChatSdk.js */ "./src/client/store/useChatSdk.js");
|
|
487
|
+
/* harmony import */ var _hooks_useFocusedElements_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../hooks/useFocusedElements.js */ "./src/client/hooks/useFocusedElements.js");
|
|
488
|
+
/* harmony import */ var _screens_end_feedback_jsx__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../screens/end-feedback.jsx */ "./src/client/components/screens/end-feedback.jsx");
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
function Panel() {
|
|
503
|
+
const {
|
|
504
|
+
sdk,
|
|
505
|
+
availability,
|
|
506
|
+
thread,
|
|
507
|
+
threadId,
|
|
508
|
+
setThread,
|
|
509
|
+
setThreadId,
|
|
510
|
+
setChatVisibility,
|
|
511
|
+
setMessages,
|
|
512
|
+
setUnseenCount
|
|
513
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_9__.useApp)();
|
|
514
|
+
const {
|
|
515
|
+
fetchThread,
|
|
516
|
+
fetchMessages
|
|
517
|
+
} = (0,_store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_10__.useChatSdk)(sdk);
|
|
518
|
+
const [screen, setScreen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(threadId ? 2 : 0);
|
|
519
|
+
(0,_hooks_useFocusedElements_js__WEBPACK_IMPORTED_MODULE_11__.useFocusedElements)(screen);
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Initializes the eventListener for pressing the escape key
|
|
523
|
+
*/
|
|
524
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
525
|
+
const escapeKeyEvent = document.addEventListener('keydown', onEscapeKey);
|
|
526
|
+
return () => {
|
|
527
|
+
document.removeEventListener('keydown', escapeKeyEvent);
|
|
528
|
+
};
|
|
529
|
+
}, []);
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Recovers the thread if there is a threadId but no thread loaded in to state
|
|
533
|
+
*/
|
|
534
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
535
|
+
const recover = async () => {
|
|
536
|
+
try {
|
|
537
|
+
const fetchedThread = await fetchThread(threadId);
|
|
538
|
+
setThread(fetchedThread);
|
|
539
|
+
const fetchedMessages = await fetchMessages(fetchedThread, threadId);
|
|
540
|
+
setMessages(fetchedMessages);
|
|
541
|
+
} catch (err) {
|
|
542
|
+
console.log('[Chat Error] fetchThread', err);
|
|
543
|
+
setThreadId();
|
|
544
|
+
setThread();
|
|
545
|
+
setScreen(0);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
if (threadId) {
|
|
549
|
+
if (thread) {
|
|
550
|
+
thread.lastMessageSeen();
|
|
551
|
+
setUnseenCount(0);
|
|
552
|
+
setScreen(2);
|
|
553
|
+
} else {
|
|
554
|
+
recover();
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}, [thread, threadId]);
|
|
558
|
+
const onEscapeKey = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => {
|
|
559
|
+
if (e.key === 'Escape' || e.key === 'Esc') {
|
|
560
|
+
if (thread) {
|
|
561
|
+
thread.lastMessageSeen();
|
|
562
|
+
setUnseenCount(0);
|
|
563
|
+
}
|
|
564
|
+
setChatVisibility(false);
|
|
565
|
+
}
|
|
566
|
+
}, []);
|
|
567
|
+
const handleScreenChange = newScreen => e => {
|
|
568
|
+
e.preventDefault();
|
|
569
|
+
setScreen(newScreen);
|
|
570
|
+
};
|
|
571
|
+
const goToPreChatScreen = handleScreenChange(0);
|
|
572
|
+
const goToRequestChatScreen = handleScreenChange(1);
|
|
573
|
+
const goToChatScreen = handleScreenChange(2);
|
|
574
|
+
const goToEndChatScreen = handleScreenChange(3);
|
|
575
|
+
const goToFeedbackScreen = handleScreenChange(4);
|
|
576
|
+
const goToSettingsScreen = handleScreenChange(5);
|
|
577
|
+
const goToEndFeedbackScreen = handleScreenChange(6);
|
|
578
|
+
let ScreenComponent;
|
|
579
|
+
switch (screen) {
|
|
580
|
+
case 0:
|
|
581
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_pre_chat_jsx__WEBPACK_IMPORTED_MODULE_2__.PreChat, {
|
|
582
|
+
onContinue: goToRequestChatScreen
|
|
583
|
+
});
|
|
584
|
+
break;
|
|
585
|
+
case 1:
|
|
586
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_request_chat_jsx__WEBPACK_IMPORTED_MODULE_3__.RequestChat, {
|
|
587
|
+
onPreChatScreen: goToPreChatScreen
|
|
588
|
+
});
|
|
589
|
+
break;
|
|
590
|
+
case 2:
|
|
591
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_chat_chat_jsx__WEBPACK_IMPORTED_MODULE_4__.Chat, {
|
|
592
|
+
onSettingsScreen: goToSettingsScreen,
|
|
593
|
+
onEndChatScreen: goToEndChatScreen
|
|
594
|
+
});
|
|
595
|
+
break;
|
|
596
|
+
case 3:
|
|
597
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_end_chat_jsx__WEBPACK_IMPORTED_MODULE_6__.EndChat, {
|
|
598
|
+
onChatScreen: goToChatScreen,
|
|
599
|
+
onEndChatConfirm: goToFeedbackScreen
|
|
600
|
+
});
|
|
601
|
+
break;
|
|
602
|
+
case 4:
|
|
603
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_feedback_jsx__WEBPACK_IMPORTED_MODULE_8__.Feedback, {
|
|
604
|
+
onCancel: () => setChatVisibility(false),
|
|
605
|
+
onConfirmSubmit: goToEndFeedbackScreen
|
|
606
|
+
});
|
|
607
|
+
break;
|
|
608
|
+
case 5:
|
|
609
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_settings_jsx__WEBPACK_IMPORTED_MODULE_7__.Settings, {
|
|
610
|
+
onCancel: goToChatScreen
|
|
611
|
+
});
|
|
612
|
+
break;
|
|
613
|
+
case 6:
|
|
614
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_end_feedback_jsx__WEBPACK_IMPORTED_MODULE_12__.EndFeedback, {
|
|
615
|
+
onClose: () => setChatVisibility(false)
|
|
616
|
+
});
|
|
617
|
+
break;
|
|
618
|
+
default:
|
|
619
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_pre_chat_jsx__WEBPACK_IMPORTED_MODULE_2__.PreChat, {
|
|
620
|
+
onContinue: goToRequestChatScreen
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
if (availability === 'UNAVAILABLE') {
|
|
624
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_unavailable_jsx__WEBPACK_IMPORTED_MODULE_5__.Unavailable, null);
|
|
625
|
+
}
|
|
626
|
+
const Component = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
627
|
+
id: "wc-panel",
|
|
628
|
+
role: "dialog",
|
|
629
|
+
className: "wc-panel",
|
|
630
|
+
tabIndex: "-1",
|
|
631
|
+
"aria-modal": "true",
|
|
632
|
+
"aria-labelledby": "wc-header-title"
|
|
633
|
+
}, ScreenComponent);
|
|
634
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(Component, document.body));
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/***/ }),
|
|
638
|
+
|
|
639
|
+
/***/ "./src/client/components/screens/end-chat.jsx":
|
|
640
|
+
/*!****************************************************!*\
|
|
641
|
+
!*** ./src/client/components/screens/end-chat.jsx ***!
|
|
642
|
+
\****************************************************/
|
|
643
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
644
|
+
|
|
645
|
+
__webpack_require__.r(__webpack_exports__);
|
|
646
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
647
|
+
/* harmony export */ EndChat: () => (/* binding */ EndChat)
|
|
648
|
+
/* harmony export */ });
|
|
649
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
650
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
651
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
652
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
function EndChat({
|
|
657
|
+
onChatScreen,
|
|
658
|
+
onEndChatConfirm
|
|
659
|
+
}) {
|
|
660
|
+
const {
|
|
661
|
+
setCustomerId,
|
|
662
|
+
setThreadId,
|
|
663
|
+
setMessages,
|
|
664
|
+
agentStatus,
|
|
665
|
+
thread
|
|
666
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_2__.useApp)();
|
|
667
|
+
const confirmEndChat = async e => {
|
|
668
|
+
e.preventDefault();
|
|
669
|
+
setThreadId();
|
|
670
|
+
setMessages([]);
|
|
671
|
+
setCustomerId();
|
|
672
|
+
|
|
673
|
+
// End chat if still open
|
|
674
|
+
if (agentStatus !== 'closed') {
|
|
675
|
+
thread.endChat();
|
|
676
|
+
}
|
|
677
|
+
onEndChatConfirm(e);
|
|
678
|
+
};
|
|
679
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
680
|
+
className: "wc-body"
|
|
681
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
682
|
+
className: "govuk-heading-s",
|
|
683
|
+
"aria-live": "polite"
|
|
684
|
+
}, "Are you sure you want to end the chat?"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
685
|
+
className: "govuk-button-group"
|
|
686
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
687
|
+
href: "#",
|
|
688
|
+
className: "govuk-button govuk-!-font-size-16",
|
|
689
|
+
"data-module": "govuk-button",
|
|
690
|
+
id: "confirmEndChat",
|
|
691
|
+
onClick: confirmEndChat
|
|
692
|
+
}, "Yes, end chat"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
693
|
+
href: "#",
|
|
694
|
+
className: "govuk-link govuk-!-font-size-16",
|
|
695
|
+
onClick: onChatScreen
|
|
696
|
+
}, "No, resume chat"))));
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/***/ }),
|
|
700
|
+
|
|
701
|
+
/***/ "./src/client/components/screens/end-feedback.jsx":
|
|
702
|
+
/*!********************************************************!*\
|
|
703
|
+
!*** ./src/client/components/screens/end-feedback.jsx ***!
|
|
704
|
+
\********************************************************/
|
|
705
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
706
|
+
|
|
707
|
+
__webpack_require__.r(__webpack_exports__);
|
|
708
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
709
|
+
/* harmony export */ EndFeedback: () => (/* binding */ EndFeedback)
|
|
710
|
+
/* harmony export */ });
|
|
711
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
712
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
713
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
function EndFeedback({
|
|
717
|
+
onClose
|
|
718
|
+
}) {
|
|
719
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
720
|
+
className: "wc-body"
|
|
721
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
722
|
+
id: "wc-subtitle",
|
|
723
|
+
class: "govuk-heading-m"
|
|
724
|
+
}, "Thank you for your feedback"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
725
|
+
href: "#",
|
|
726
|
+
role: "button",
|
|
727
|
+
draggable: "false",
|
|
728
|
+
"data-module": "govuk-button",
|
|
729
|
+
"data-wc-focus-visible": true,
|
|
730
|
+
"data-wc-close-btn": true,
|
|
731
|
+
onClick: onClose
|
|
732
|
+
}, "Close window"))));
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/***/ }),
|
|
736
|
+
|
|
737
|
+
/***/ "./src/client/components/screens/feedback.jsx":
|
|
738
|
+
/*!****************************************************!*\
|
|
739
|
+
!*** ./src/client/components/screens/feedback.jsx ***!
|
|
740
|
+
\****************************************************/
|
|
741
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
742
|
+
|
|
743
|
+
__webpack_require__.r(__webpack_exports__);
|
|
744
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
745
|
+
/* harmony export */ Feedback: () => (/* binding */ Feedback)
|
|
746
|
+
/* harmony export */ });
|
|
747
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
748
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
749
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
function Feedback({
|
|
753
|
+
onCancel,
|
|
754
|
+
onConfirmSubmit
|
|
755
|
+
}) {
|
|
756
|
+
const feedbackSubmit = async e => {
|
|
757
|
+
e.preventDefault();
|
|
758
|
+
console.log('feedback submitted');
|
|
759
|
+
onConfirmSubmit(e);
|
|
760
|
+
};
|
|
761
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
762
|
+
className: "wc-body"
|
|
763
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
764
|
+
id: "wc-subtitle",
|
|
765
|
+
className: "govuk-heading-s"
|
|
766
|
+
}, "Give Feedback on Floodline webchat"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", null, "Please note we\u2019re unable to respond to feedback."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
767
|
+
className: "govuk-form-group"
|
|
768
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("fieldset", {
|
|
769
|
+
className: "govuk-fieldset govuk-!-margin-bottom-4"
|
|
770
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("legend", {
|
|
771
|
+
className: "govuk-fieldset-heading govuk-fieldset__legend"
|
|
772
|
+
}, "Overall, how did you feel about webchat?"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
773
|
+
className: "govuk-radios govuk-radios--small",
|
|
774
|
+
"data-module": "govuk-radios"
|
|
775
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
776
|
+
className: "govuk-radios__item"
|
|
777
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
778
|
+
id: "very-satisfied",
|
|
779
|
+
name: "satisfaction",
|
|
780
|
+
type: "radio",
|
|
781
|
+
className: "govuk-radios__input",
|
|
782
|
+
value: "Very satisfied"
|
|
783
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
784
|
+
className: "govuk-label govuk-radios__label",
|
|
785
|
+
for: "very-satisfied"
|
|
786
|
+
}, "Very satisfied")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
787
|
+
className: "govuk-radios__item"
|
|
788
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
789
|
+
id: "satisfied",
|
|
790
|
+
name: "satisfaction",
|
|
791
|
+
type: "radio",
|
|
792
|
+
className: "govuk-radios__input",
|
|
793
|
+
value: "Satisfied"
|
|
794
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
795
|
+
className: "govuk-label govuk-radios__label",
|
|
796
|
+
for: "satisfied"
|
|
797
|
+
}, "Satisfied")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
798
|
+
className: "govuk-radios__item"
|
|
799
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
800
|
+
id: "no-opinion",
|
|
801
|
+
name: "satisfaction",
|
|
802
|
+
type: "radio",
|
|
803
|
+
className: "govuk-radios__input",
|
|
804
|
+
value: "No opinion"
|
|
805
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
806
|
+
className: "govuk-label govuk-radios__label",
|
|
807
|
+
for: "no-opinion"
|
|
808
|
+
}, "No Opinion")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
809
|
+
className: "govuk-radios__item"
|
|
810
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
811
|
+
id: "dissatisfied",
|
|
812
|
+
name: "satisfaction",
|
|
813
|
+
type: "radio",
|
|
814
|
+
className: "govuk-radios__input",
|
|
815
|
+
value: "Dissatisfied"
|
|
816
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
817
|
+
className: "govuk-label govuk-radios__label",
|
|
818
|
+
for: "dissatisfied"
|
|
819
|
+
}, "Dissatisfied")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
820
|
+
className: "govuk-radios__item"
|
|
821
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
822
|
+
id: "very-dissatisfied",
|
|
823
|
+
name: "satisfaction",
|
|
824
|
+
type: "radio",
|
|
825
|
+
className: "govuk-radios__input",
|
|
826
|
+
value: "Very dissatisfied"
|
|
827
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
828
|
+
className: "govuk-label govuk-radios__label",
|
|
829
|
+
for: "very-dissatisfied"
|
|
830
|
+
}, "Very dissatisfied")))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("fieldset", {
|
|
831
|
+
className: "govuk-fieldset govuk-!-margin-bottom-4"
|
|
832
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("legend", {
|
|
833
|
+
className: "govuk-fieldset__legend"
|
|
834
|
+
}, "Did the adviser answer your question?"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
835
|
+
className: "govuk-radios govuk-radios--small",
|
|
836
|
+
"data-module": "govuk-radios"
|
|
837
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
838
|
+
className: "govuk-radios__item"
|
|
839
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
840
|
+
id: "answer-yes",
|
|
841
|
+
name: "answer",
|
|
842
|
+
type: "radio",
|
|
843
|
+
className: "govuk-radios__input",
|
|
844
|
+
value: "Yes"
|
|
845
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
846
|
+
className: "govuk-label govuk-radios__label",
|
|
847
|
+
for: "answer-yes"
|
|
848
|
+
}, "Yes")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
849
|
+
className: "govuk-radios__item"
|
|
850
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
851
|
+
id: "answer-no",
|
|
852
|
+
name: "answer",
|
|
853
|
+
type: "radio",
|
|
854
|
+
className: "govuk-radios__input",
|
|
855
|
+
value: "No"
|
|
856
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
857
|
+
className: "govuk-label govuk-radios__label",
|
|
858
|
+
for: "answer-no"
|
|
859
|
+
}, "No")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
860
|
+
className: "govuk-radios__item"
|
|
861
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
862
|
+
id: "answer-partly",
|
|
863
|
+
name: "answer",
|
|
864
|
+
type: "radio",
|
|
865
|
+
className: "govuk-radios__input",
|
|
866
|
+
value: "Partly"
|
|
867
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
868
|
+
className: "govuk-label govuk-radios__label",
|
|
869
|
+
for: "answer-partly"
|
|
870
|
+
}, "Partly"))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
871
|
+
className: "govuk-form-group"
|
|
872
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
873
|
+
className: "govuk-label",
|
|
874
|
+
for: "improvements"
|
|
875
|
+
}, "How can we improve webchat? (optional)"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("textarea", {
|
|
876
|
+
className: "govuk-textarea govuk-!-margin-bottom-4",
|
|
877
|
+
id: "improvements",
|
|
878
|
+
name: "improvements",
|
|
879
|
+
rows: "5"
|
|
880
|
+
})), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
881
|
+
className: "govuk-form-group"
|
|
882
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
883
|
+
className: "wc-fieldset-heading govuk-label",
|
|
884
|
+
for: "research"
|
|
885
|
+
}, "Tell us your email address if you want to take part in user research (optional)"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
886
|
+
id: "research-hint",
|
|
887
|
+
class: "wc-hint govuk-hint"
|
|
888
|
+
}, "We will not share your email address or use it for anything else. We\u2019ll delete it after 2 years."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
889
|
+
className: "govuk-input govuk-!-margin-bottom-4",
|
|
890
|
+
id: "research",
|
|
891
|
+
name: "research",
|
|
892
|
+
"aria-describedby": "research-hint",
|
|
893
|
+
type: "text"
|
|
894
|
+
})), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
895
|
+
className: "govuk-button-group"
|
|
896
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
897
|
+
id: "feedback-save",
|
|
898
|
+
href: "#",
|
|
899
|
+
className: "govuk-button govuk-!-font-size-16",
|
|
900
|
+
"data-module": "govuk-button",
|
|
901
|
+
onClick: feedbackSubmit
|
|
902
|
+
}, "Submit"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
903
|
+
id: "feedback-cancel",
|
|
904
|
+
href: "#",
|
|
905
|
+
className: "govuk-link govuk-!-font-size-16",
|
|
906
|
+
"data-module": "govuk-button",
|
|
907
|
+
onClick: onCancel
|
|
908
|
+
}, "Cancel"))));
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/***/ }),
|
|
912
|
+
|
|
913
|
+
/***/ "./src/client/components/screens/pre-chat.jsx":
|
|
914
|
+
/*!****************************************************!*\
|
|
915
|
+
!*** ./src/client/components/screens/pre-chat.jsx ***!
|
|
916
|
+
\****************************************************/
|
|
917
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
918
|
+
|
|
919
|
+
__webpack_require__.r(__webpack_exports__);
|
|
920
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
921
|
+
/* harmony export */ PreChat: () => (/* binding */ PreChat)
|
|
922
|
+
/* harmony export */ });
|
|
923
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
924
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
925
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
function PreChat({
|
|
929
|
+
onContinue
|
|
930
|
+
}) {
|
|
931
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
932
|
+
className: "wc-body"
|
|
933
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
934
|
+
className: "govuk-heading-s",
|
|
935
|
+
"aria-live": "polite"
|
|
936
|
+
}, "What you can use webchat for"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
937
|
+
className: "govuk-body-s"
|
|
938
|
+
}, "Webchat lets you talk directly to a Floodline adviser."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
939
|
+
className: "govuk-body-s"
|
|
940
|
+
}, "You can use webchat to get:"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
|
|
941
|
+
className: "govuk-list govuk-list--bullet govuk-body-s"
|
|
942
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", null, "current flood warnings and alerts in your area"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", null, "information on the flood warning service"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", null, "advice on what to do before, during and after a flood")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
943
|
+
className: "govuk-body-s"
|
|
944
|
+
}, 'There are other ways to ', /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
945
|
+
className: "govuk-link",
|
|
946
|
+
href: "https://www.gov.uk/sign-up-for-flood-warnings",
|
|
947
|
+
target: "_blank",
|
|
948
|
+
rel: "noreferrer"
|
|
949
|
+
}, "sign up for flood warnings"), ' and ', /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
950
|
+
className: "govuk-link",
|
|
951
|
+
href: "https://www.fws.environment-agency.gov.uk/app/olr/login",
|
|
952
|
+
target: "_blank",
|
|
953
|
+
rel: "noreferrer"
|
|
954
|
+
}, "manage your flood warnings account"), "."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
955
|
+
className: "govuk-body-s"
|
|
956
|
+
}, 'Do not use webchat to ', /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
957
|
+
className: "govuk-link",
|
|
958
|
+
href: "https://www.gov.uk/report-flood-cause",
|
|
959
|
+
target: "_blank",
|
|
960
|
+
rel: "noreferrer"
|
|
961
|
+
}, "report a flood"), "."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
|
|
962
|
+
className: "govuk-button govuk-!-font-size-16",
|
|
963
|
+
"data-module": "govuk-button",
|
|
964
|
+
onClick: onContinue
|
|
965
|
+
}, "Continue"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
966
|
+
className: "govuk-heading-s"
|
|
967
|
+
}, "Other flood information"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
968
|
+
className: "govuk-body-s"
|
|
969
|
+
}, "Call Floodline for all other flood and flood warning information."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
970
|
+
className: "govuk-body-s"
|
|
971
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("strong", null, "Floodline helpline"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), "Telephone: 0345 988 1188", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), "Textphone: 0345 602 6340", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), "Open 24 hours a day, 7 days a week", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
972
|
+
className: "govuk-link",
|
|
973
|
+
href: "https://gov.uk/call-charges",
|
|
974
|
+
target: "_blank",
|
|
975
|
+
rel: "noreferrer"
|
|
976
|
+
}, "Find out more about call charges"))));
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/***/ }),
|
|
980
|
+
|
|
981
|
+
/***/ "./src/client/components/screens/request-chat.jsx":
|
|
982
|
+
/*!********************************************************!*\
|
|
983
|
+
!*** ./src/client/components/screens/request-chat.jsx ***!
|
|
984
|
+
\********************************************************/
|
|
985
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
986
|
+
|
|
987
|
+
__webpack_require__.r(__webpack_exports__);
|
|
988
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
989
|
+
/* harmony export */ RequestChat: () => (/* binding */ RequestChat)
|
|
990
|
+
/* harmony export */ });
|
|
991
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
992
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
993
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ "uuid");
|
|
994
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_1__);
|
|
995
|
+
/* harmony import */ var _lib_classnames_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../lib/classnames.js */ "./src/client/lib/classnames.js");
|
|
996
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
997
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
998
|
+
/* harmony import */ var _store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../store/useChatSdk.js */ "./src/client/store/useChatSdk.js");
|
|
999
|
+
/* harmony import */ var _errorSummary_error_summary_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../errorSummary/error-summary.jsx */ "./src/client/components/errorSummary/error-summary.jsx");
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
const QUESTION_MAX_LENGTH = 500;
|
|
1008
|
+
function RequestChat({
|
|
1009
|
+
onPreChatScreen
|
|
1010
|
+
}) {
|
|
1011
|
+
const {
|
|
1012
|
+
sdk,
|
|
1013
|
+
setCustomerId,
|
|
1014
|
+
setThreadId,
|
|
1015
|
+
setThread
|
|
1016
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
1017
|
+
const {
|
|
1018
|
+
fetchCustomerId,
|
|
1019
|
+
fetchThread
|
|
1020
|
+
} = (0,_store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_5__.useChatSdk)(sdk);
|
|
1021
|
+
const [errors, setErrors] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({});
|
|
1022
|
+
const [questionLength, setQuestionLength] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
|
|
1023
|
+
const nameRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
1024
|
+
const questionRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
1025
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1026
|
+
if (Object.keys(errors).length) {
|
|
1027
|
+
document.querySelector('.govuk-error-summary')?.focus();
|
|
1028
|
+
}
|
|
1029
|
+
}, [errors]);
|
|
1030
|
+
const onQuestionChange = e => {
|
|
1031
|
+
setQuestionLength(e.target.value.length);
|
|
1032
|
+
};
|
|
1033
|
+
const onRequestChat = async e => {
|
|
1034
|
+
e.preventDefault();
|
|
1035
|
+
const errs = {};
|
|
1036
|
+
if (nameRef.current.value.length === 0) {
|
|
1037
|
+
errs.name = 'Enter your name';
|
|
1038
|
+
}
|
|
1039
|
+
if (questionRef.current.value.length === 0) {
|
|
1040
|
+
errs.question = 'Enter your question';
|
|
1041
|
+
}
|
|
1042
|
+
if (questionRef.current.value.length > QUESTION_MAX_LENGTH) {
|
|
1043
|
+
errs.question = 'Your question must be 500 characters or less';
|
|
1044
|
+
}
|
|
1045
|
+
if (Object.keys(errs).length === 0) {
|
|
1046
|
+
try {
|
|
1047
|
+
const threadId = uuid__WEBPACK_IMPORTED_MODULE_1__.v4();
|
|
1048
|
+
const customerId = await fetchCustomerId();
|
|
1049
|
+
const thread = await fetchThread(threadId);
|
|
1050
|
+
sdk.getCustomer().setName(nameRef.current.value);
|
|
1051
|
+
await thread.startChat(questionRef.current.value || 'Begin conversation');
|
|
1052
|
+
setCustomerId(customerId);
|
|
1053
|
+
setThreadId(threadId);
|
|
1054
|
+
setThread(thread);
|
|
1055
|
+
thread.setCustomField('threadid', threadId);
|
|
1056
|
+
} catch (err) {
|
|
1057
|
+
console.log('[Request Chat Error]', err);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
setErrors(errs);
|
|
1061
|
+
};
|
|
1062
|
+
const isQuestionLengthValid = QUESTION_MAX_LENGTH >= questionLength;
|
|
1063
|
+
const questionLengthRemaining = QUESTION_MAX_LENGTH - questionLength;
|
|
1064
|
+
const questionLengthExceeded = questionLength - QUESTION_MAX_LENGTH;
|
|
1065
|
+
let questionHint = `You have ${questionLengthRemaining} characters remaining`;
|
|
1066
|
+
if (!isQuestionLengthValid) {
|
|
1067
|
+
questionHint = `You have ${questionLengthExceeded} characters too many`;
|
|
112
1068
|
}
|
|
113
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null,
|
|
114
|
-
className: "wc-
|
|
115
|
-
},
|
|
1069
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_3__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1070
|
+
className: "wc-body"
|
|
1071
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
1072
|
+
href: "#",
|
|
1073
|
+
className: "wc-back-link govuk-back-link",
|
|
1074
|
+
onClick: onPreChatScreen
|
|
1075
|
+
}, "What you can use webchat for"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_errorSummary_error_summary_jsx__WEBPACK_IMPORTED_MODULE_6__.ErrorSummary, {
|
|
1076
|
+
errors: errors
|
|
1077
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
1078
|
+
className: "govuk-heading-s",
|
|
1079
|
+
"aria-live": "polite"
|
|
1080
|
+
}, "Your name and question"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("form", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1081
|
+
className: (0,_lib_classnames_js__WEBPACK_IMPORTED_MODULE_2__.classnames)('govuk-form-group', errors.name && 'govuk-form-group--error')
|
|
1082
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1083
|
+
className: "govuk-label",
|
|
1084
|
+
htmlFor: "wc-name"
|
|
1085
|
+
}, "Your name"), errors.name && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
1086
|
+
className: "govuk-error-message"
|
|
1087
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
116
1088
|
className: "govuk-visually-hidden"
|
|
117
|
-
}, "
|
|
1089
|
+
}, "Error:"), " ", errors.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
1090
|
+
ref: nameRef,
|
|
1091
|
+
className: (0,_lib_classnames_js__WEBPACK_IMPORTED_MODULE_2__.classnames)('govuk-input', errors.name && 'govuk-input--error'),
|
|
1092
|
+
id: "wc-name",
|
|
1093
|
+
name: "name",
|
|
1094
|
+
type: "text",
|
|
1095
|
+
"data-testid": "request-chat-user-name"
|
|
1096
|
+
})), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1097
|
+
className: "govuk-character-count",
|
|
1098
|
+
"data-module": "govuk-character-count",
|
|
1099
|
+
"data-maxlength": "500"
|
|
1100
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1101
|
+
className: (0,_lib_classnames_js__WEBPACK_IMPORTED_MODULE_2__.classnames)('govuk-form-group', errors.question && 'govuk-form-group--error')
|
|
1102
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1103
|
+
className: "govuk-label",
|
|
1104
|
+
htmlFor: "wc-question"
|
|
1105
|
+
}, "Your question"), errors.question && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
1106
|
+
className: "govuk-error-message"
|
|
1107
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
1108
|
+
className: "govuk-visually-hidden"
|
|
1109
|
+
}, "Error:"), errors.question), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("textarea", {
|
|
1110
|
+
ref: questionRef,
|
|
1111
|
+
id: "wc-question",
|
|
1112
|
+
name: "question",
|
|
1113
|
+
rows: "5",
|
|
1114
|
+
"aria-describedby": "wc-question-info",
|
|
1115
|
+
onChange: onQuestionChange,
|
|
1116
|
+
className: (0,_lib_classnames_js__WEBPACK_IMPORTED_MODULE_2__.classnames)('govuk-textarea', 'govuk-js-character-count', !isQuestionLengthValid || errors.question ? 'govuk-textarea--error' : ''),
|
|
1117
|
+
"data-testid": "request-chat-user-question"
|
|
1118
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1119
|
+
id: "wc-question-info",
|
|
1120
|
+
className: "govuk-hint govuk-character-count__message",
|
|
1121
|
+
style: {
|
|
1122
|
+
color: `${!isQuestionLengthValid ? '#d4351c' : ''}`
|
|
1123
|
+
},
|
|
1124
|
+
"aria-hidden": "true"
|
|
1125
|
+
}, questionHint), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1126
|
+
className: "govuk-character-count__sr-status govuk-visually-hidden",
|
|
1127
|
+
"aria-live": "polite"
|
|
1128
|
+
}, questionHint))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
|
|
1129
|
+
className: "govuk-button govuk-!-margin-top-1 govuk-!-font-size-16",
|
|
1130
|
+
"data-module": "govuk-button",
|
|
1131
|
+
onClick: onRequestChat
|
|
1132
|
+
}, "Request chat"))));
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/***/ }),
|
|
1136
|
+
|
|
1137
|
+
/***/ "./src/client/components/screens/settings.jsx":
|
|
1138
|
+
/*!****************************************************!*\
|
|
1139
|
+
!*** ./src/client/components/screens/settings.jsx ***!
|
|
1140
|
+
\****************************************************/
|
|
1141
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1142
|
+
|
|
1143
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1144
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1145
|
+
/* harmony export */ Settings: () => (/* binding */ Settings)
|
|
1146
|
+
/* harmony export */ });
|
|
1147
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
1148
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1149
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
1150
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
function Settings({
|
|
1155
|
+
onCancel
|
|
1156
|
+
}) {
|
|
1157
|
+
const {
|
|
1158
|
+
settings,
|
|
1159
|
+
setSettings
|
|
1160
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_2__.useApp)();
|
|
1161
|
+
const [optionAudio, setOptionAudio] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(settings.audio);
|
|
1162
|
+
const [optionScroll, setOptionScroll] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(settings.scroll);
|
|
1163
|
+
const onSave = e => {
|
|
1164
|
+
e.preventDefault();
|
|
1165
|
+
setSettings({
|
|
1166
|
+
audio: optionAudio,
|
|
1167
|
+
scroll: optionScroll
|
|
1168
|
+
});
|
|
1169
|
+
onCancel(e);
|
|
1170
|
+
};
|
|
1171
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1172
|
+
className: "wc-body"
|
|
1173
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("fieldset", {
|
|
1174
|
+
className: "govuk-fieldset govuk-!-margin-bottom-4"
|
|
1175
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("legend", {
|
|
1176
|
+
className: "govuk-fieldset__legend govuk-fieldset__legend"
|
|
1177
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
1178
|
+
id: "wc-subtitle",
|
|
1179
|
+
className: "govuk-heading-s"
|
|
1180
|
+
}, "Change settings")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1181
|
+
className: "govuk-checkboxes govuk-checkboxes--small",
|
|
1182
|
+
"data-module": "govuk-checkboxes"
|
|
1183
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1184
|
+
className: "govuk-checkboxes__item"
|
|
1185
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
1186
|
+
id: "audio",
|
|
1187
|
+
name: "audio",
|
|
1188
|
+
type: "checkbox",
|
|
1189
|
+
value: "audio",
|
|
1190
|
+
className: "govuk-checkboxes__input",
|
|
1191
|
+
defaultChecked: optionAudio,
|
|
1192
|
+
onChange: () => setOptionAudio(!optionAudio)
|
|
1193
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1194
|
+
className: "govuk-label govuk-checkboxes__label govuk-!-font-size-16",
|
|
1195
|
+
htmlFor: "audio"
|
|
1196
|
+
}, "Play a sound when receiving a new message")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1197
|
+
className: "govuk-checkboxes__item"
|
|
1198
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
1199
|
+
id: "scroll",
|
|
1200
|
+
name: "scroll",
|
|
1201
|
+
type: "checkbox",
|
|
1202
|
+
value: "scroll",
|
|
1203
|
+
className: "govuk-checkboxes__input",
|
|
1204
|
+
defaultChecked: optionScroll,
|
|
1205
|
+
onChange: () => setOptionScroll(!optionScroll)
|
|
1206
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
1207
|
+
className: "govuk-label govuk-checkboxes__label govuk-!-font-size-16",
|
|
1208
|
+
htmlFor: "scroll"
|
|
1209
|
+
}, "Scroll automatically to a new message")))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1210
|
+
className: "govuk-button-group"
|
|
1211
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
1212
|
+
id: "settings-save",
|
|
1213
|
+
href: "#",
|
|
1214
|
+
className: "govuk-button govuk-!-font-size-16",
|
|
1215
|
+
"data-module": "govuk-button",
|
|
1216
|
+
onClick: onSave
|
|
1217
|
+
}, "Save"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
1218
|
+
id: "settings-cancel",
|
|
1219
|
+
href: "#",
|
|
1220
|
+
className: "govuk-link govuk-!-font-size-16",
|
|
1221
|
+
"data-module": "govuk-button",
|
|
1222
|
+
onClick: onCancel
|
|
1223
|
+
}, "Cancel"))));
|
|
118
1224
|
}
|
|
119
1225
|
|
|
120
1226
|
/***/ }),
|
|
121
1227
|
|
|
1228
|
+
/***/ "./src/client/components/screens/unavailable.jsx":
|
|
1229
|
+
/*!*******************************************************!*\
|
|
1230
|
+
!*** ./src/client/components/screens/unavailable.jsx ***!
|
|
1231
|
+
\*******************************************************/
|
|
1232
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1233
|
+
|
|
1234
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1235
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1236
|
+
/* harmony export */ Unavailable: () => (/* binding */ Unavailable)
|
|
1237
|
+
/* harmony export */ });
|
|
1238
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
1239
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1240
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
function Unavailable() {
|
|
1244
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__.PanelHeader, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1245
|
+
className: "wc-body"
|
|
1246
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
1247
|
+
id: "wc-subtitle",
|
|
1248
|
+
className: "govuk-heading-m"
|
|
1249
|
+
}, "Webchat is currently not available"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
1250
|
+
className: "govuk-body-s"
|
|
1251
|
+
}, "Try again later, or call Floodline:"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
1252
|
+
className: "govuk-body-s"
|
|
1253
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("strong", null, "Floodline helpline"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), "Telephone: 0345 988 1188", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), "Textphone: 0345 602 6340", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), "Open 24 hours a day, 7 days a week", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("br", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
1254
|
+
className: "govuk-link",
|
|
1255
|
+
href: "https://gov.uk/call-charges"
|
|
1256
|
+
}, "Find out more about call charges")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
1257
|
+
className: "govuk-body-s"
|
|
1258
|
+
}, "We're running webchat as a trial, it will not always be available.")));
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/***/ }),
|
|
1262
|
+
|
|
1263
|
+
/***/ "./src/client/hooks/useFocusedElements.js":
|
|
1264
|
+
/*!************************************************!*\
|
|
1265
|
+
!*** ./src/client/hooks/useFocusedElements.js ***!
|
|
1266
|
+
\************************************************/
|
|
1267
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1268
|
+
|
|
1269
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1270
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1271
|
+
/* harmony export */ getFocusableElements: () => (/* binding */ getFocusableElements),
|
|
1272
|
+
/* harmony export */ useFocusedElements: () => (/* binding */ useFocusedElements)
|
|
1273
|
+
/* harmony export */ });
|
|
1274
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
1275
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1276
|
+
|
|
1277
|
+
const setAriaHidden = bool => {
|
|
1278
|
+
for (const node of document.body.children) {
|
|
1279
|
+
if (node.id !== 'wc-panel') {
|
|
1280
|
+
bool ? node.setAttribute('aria-hidden', 'true') : node.removeAttribute('aria-hidden');
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
const getFocusableElements = () => {
|
|
1285
|
+
const selectors = ['#wc-panel a:not([disabled])', '#wc-panel button:not([disabled])', '#wc-panel select:not([disabled])', '#wc-panel input:not([disabled])', '#wc-panel textarea:not([disabled])', '#wc-panel *[tabindex="0"]:not([disabled])'];
|
|
1286
|
+
const elements = document.body.querySelectorAll(selectors.join(','));
|
|
1287
|
+
return Array.from(elements).filter(e => !e.closest('[hidden]') && !e.closest('[aria-hidden="true"]'));
|
|
1288
|
+
};
|
|
1289
|
+
const useFocusedElements = screen => {
|
|
1290
|
+
const [panelElements, setPanelElements] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]);
|
|
1291
|
+
const onKeyDown = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => {
|
|
1292
|
+
const webchatPanelElement = document.querySelector('#wc-panel');
|
|
1293
|
+
if (e.key === 'Tab') {
|
|
1294
|
+
if (webchatPanelElement && !document.activeElement.closest('#wc-panel')) {
|
|
1295
|
+
webchatPanelElement.focus();
|
|
1296
|
+
}
|
|
1297
|
+
if (e.shiftKey) {
|
|
1298
|
+
if (document.activeElement === panelElements[0]) {
|
|
1299
|
+
panelElements[panelElements.length - 1].focus();
|
|
1300
|
+
e.preventDefault();
|
|
1301
|
+
} else if (document.activeElement === document.querySelector('#wc-panel')) {
|
|
1302
|
+
panelElements[panelElements.length - 1]?.focus();
|
|
1303
|
+
e.preventDefault();
|
|
1304
|
+
}
|
|
1305
|
+
} else if (document.activeElement === panelElements[panelElements.length - 1]) {
|
|
1306
|
+
panelElements[0].focus();
|
|
1307
|
+
e.preventDefault();
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}, [panelElements]);
|
|
1311
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1312
|
+
setPanelElements(getFocusableElements());
|
|
1313
|
+
}, [screen]);
|
|
1314
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1315
|
+
setAriaHidden(true);
|
|
1316
|
+
const panelElement = document.querySelector('#wc-panel');
|
|
1317
|
+
panelElement.focus();
|
|
1318
|
+
document.addEventListener('keydown', onKeyDown);
|
|
1319
|
+
return () => {
|
|
1320
|
+
setAriaHidden();
|
|
1321
|
+
document.body.querySelector('.wc-availability__link')?.focus();
|
|
1322
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
1323
|
+
};
|
|
1324
|
+
}, [panelElements]);
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
/***/ }),
|
|
1329
|
+
|
|
1330
|
+
/***/ "./src/client/hooks/useTextareaAutosize.js":
|
|
1331
|
+
/*!*************************************************!*\
|
|
1332
|
+
!*** ./src/client/hooks/useTextareaAutosize.js ***!
|
|
1333
|
+
\*************************************************/
|
|
1334
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1335
|
+
|
|
1336
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1337
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1338
|
+
/* harmony export */ useTextareaAutosize: () => (/* binding */ useTextareaAutosize)
|
|
1339
|
+
/* harmony export */ });
|
|
1340
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
1341
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1342
|
+
|
|
1343
|
+
const useTextareaAutosize = (textAreaRef, value) => {
|
|
1344
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1345
|
+
if (textAreaRef) {
|
|
1346
|
+
textAreaRef.style.height = '0px';
|
|
1347
|
+
const scrollHeight = textAreaRef.scrollHeight;
|
|
1348
|
+
textAreaRef.style.height = `${scrollHeight}px`;
|
|
1349
|
+
}
|
|
1350
|
+
}, [textAreaRef, value]);
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
/***/ }),
|
|
1354
|
+
|
|
122
1355
|
/***/ "./src/client/lib/check-availability.js":
|
|
123
1356
|
/*!**********************************************!*\
|
|
124
1357
|
!*** ./src/client/lib/check-availability.js ***!
|
|
@@ -129,37 +1362,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
129
1362
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
130
1363
|
/* harmony export */ checkAvailability: () => (/* binding */ checkAvailability)
|
|
131
1364
|
/* harmony export */ });
|
|
132
|
-
|
|
133
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return { value: void 0, done: !0 }; } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable || "" === iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } throw new TypeError(_typeof(iterable) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
function _checkAvailability() {
|
|
140
|
-
_checkAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(endpoint) {
|
|
141
|
-
var response, data;
|
|
142
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
143
|
-
while (1) switch (_context.prev = _context.next) {
|
|
144
|
-
case 0:
|
|
145
|
-
_context.next = 2;
|
|
146
|
-
return fetch(endpoint);
|
|
147
|
-
case 2:
|
|
148
|
-
response = _context.sent;
|
|
149
|
-
_context.next = 5;
|
|
150
|
-
return response.json();
|
|
151
|
-
case 5:
|
|
152
|
-
data = _context.sent;
|
|
153
|
-
return _context.abrupt("return", {
|
|
154
|
-
availability: data.availability || 'UNAVAILABLE'
|
|
155
|
-
});
|
|
156
|
-
case 7:
|
|
157
|
-
case "end":
|
|
158
|
-
return _context.stop();
|
|
159
|
-
}
|
|
160
|
-
}, _callee);
|
|
161
|
-
}));
|
|
162
|
-
return _checkAvailability.apply(this, arguments);
|
|
1365
|
+
async function checkAvailability(endpoint) {
|
|
1366
|
+
const response = await fetch(endpoint);
|
|
1367
|
+
const data = await response.json();
|
|
1368
|
+
return {
|
|
1369
|
+
availability: data.availability || 'UNAVAILABLE'
|
|
1370
|
+
};
|
|
163
1371
|
}
|
|
164
1372
|
|
|
165
1373
|
/***/ }),
|
|
@@ -174,120 +1382,561 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
174
1382
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
175
1383
|
/* harmony export */ classnames: () => (/* binding */ classnames)
|
|
176
1384
|
/* harmony export */ });
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
1385
|
+
const classnames = (...classes) => classes.filter(classname => classname && typeof classname === 'string').join(' ');
|
|
1386
|
+
|
|
1387
|
+
/***/ }),
|
|
1388
|
+
|
|
1389
|
+
/***/ "./src/client/lib/message-notification.js":
|
|
1390
|
+
/*!************************************************!*\
|
|
1391
|
+
!*** ./src/client/lib/message-notification.js ***!
|
|
1392
|
+
\************************************************/
|
|
1393
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1394
|
+
|
|
1395
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1396
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1397
|
+
/* harmony export */ messageNotification: () => (/* binding */ messageNotification)
|
|
1398
|
+
/* harmony export */ });
|
|
1399
|
+
const messageNotification = audioUrl => {
|
|
1400
|
+
let buffer;
|
|
1401
|
+
const context = new (window.AudioContext || window.webkitAudioContext)();
|
|
1402
|
+
if (context.state === 'suspended') {
|
|
1403
|
+
const events = ['touchstart', 'touchend', 'mousedown', 'wheel', 'keydown', 'click'];
|
|
1404
|
+
const unlock = _e => {
|
|
1405
|
+
events.forEach(event => {
|
|
1406
|
+
document.body.removeEventListener(event, unlock);
|
|
1407
|
+
});
|
|
1408
|
+
context.resume();
|
|
1409
|
+
};
|
|
1410
|
+
events.forEach(event => {
|
|
1411
|
+
document.body.addEventListener(event, unlock, false);
|
|
1412
|
+
});
|
|
180
1413
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}).
|
|
1414
|
+
fetch(audioUrl).then(response => response.arrayBuffer()).then(data => context.decodeAudioData(data)).then(decodedData => {
|
|
1415
|
+
buffer = decodedData;
|
|
1416
|
+
}).catch(console.error);
|
|
1417
|
+
return () => {
|
|
1418
|
+
const source = context.createBufferSource();
|
|
1419
|
+
source.buffer = buffer;
|
|
1420
|
+
source.connect(context.destination);
|
|
1421
|
+
source.start();
|
|
1422
|
+
};
|
|
184
1423
|
};
|
|
185
1424
|
|
|
186
1425
|
/***/ }),
|
|
187
1426
|
|
|
188
|
-
/***/ "./src/client/lib/
|
|
189
|
-
|
|
190
|
-
!*** ./src/client/lib/
|
|
191
|
-
|
|
1427
|
+
/***/ "./src/client/lib/transform-messages.js":
|
|
1428
|
+
/*!**********************************************!*\
|
|
1429
|
+
!*** ./src/client/lib/transform-messages.js ***!
|
|
1430
|
+
\**********************************************/
|
|
192
1431
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
193
1432
|
|
|
194
1433
|
__webpack_require__.r(__webpack_exports__);
|
|
195
1434
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
196
|
-
/* harmony export */
|
|
197
|
-
/* harmony export */
|
|
1435
|
+
/* harmony export */ formatTranscript: () => (/* binding */ formatTranscript),
|
|
1436
|
+
/* harmony export */ transformMessage: () => (/* binding */ transformMessage),
|
|
1437
|
+
/* harmony export */ transformMessages: () => (/* binding */ transformMessages)
|
|
198
1438
|
/* harmony export */ });
|
|
199
|
-
/* harmony import */ var
|
|
1439
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uuid */ "uuid");
|
|
1440
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_0__);
|
|
1441
|
+
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! luxon */ "luxon");
|
|
1442
|
+
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(luxon__WEBPACK_IMPORTED_MODULE_1__);
|
|
200
1443
|
|
|
201
|
-
|
|
202
|
-
|
|
1444
|
+
|
|
1445
|
+
const transformMessage = message => {
|
|
1446
|
+
return {
|
|
1447
|
+
id: message.id,
|
|
1448
|
+
text: message.messageContent?.text,
|
|
1449
|
+
createdAt: new Date(message.createdAt),
|
|
1450
|
+
user: message.authorEndUserIdentity?.fullName?.trim() || null,
|
|
1451
|
+
assignee: message.authorUser?.firstName || null,
|
|
1452
|
+
direction: message.direction
|
|
1453
|
+
};
|
|
1454
|
+
};
|
|
1455
|
+
const transformMessages = messages => messages.map(message => transformMessage(message));
|
|
1456
|
+
const formatTranscript = messages => {
|
|
1457
|
+
const now = luxon__WEBPACK_IMPORTED_MODULE_1__.DateTime.local();
|
|
1458
|
+
now.setZone('Europe/London');
|
|
1459
|
+
let string = `Floodline webchat transcript, ${now.toFormat('HH:mm:ss a, dd LLLL yyyy')}, (ID: ${uuid__WEBPACK_IMPORTED_MODULE_0__.v4().split('-')[0]})\n\n`;
|
|
1460
|
+
for (const message of messages) {
|
|
1461
|
+
const {
|
|
1462
|
+
text,
|
|
1463
|
+
direction,
|
|
1464
|
+
user,
|
|
1465
|
+
assignee,
|
|
1466
|
+
createdAt
|
|
1467
|
+
} = message;
|
|
1468
|
+
const author = direction === 'inbound' ? user : `${assignee} (Floodline adviser)`;
|
|
1469
|
+
const date = luxon__WEBPACK_IMPORTED_MODULE_1__.DateTime.fromJSDate(new Date(createdAt)).setZone('Europe/London').toFormat('HH:mm:ss a, dd LLLL yyyy');
|
|
1470
|
+
string += `[${date}] ${author}: \n${text}\n\n`;
|
|
1471
|
+
}
|
|
1472
|
+
string = string.replace(/<a\b[^>]*>/i, '').replace(/<\/a>/i, '');
|
|
1473
|
+
return encodeURIComponent(string);
|
|
1474
|
+
};
|
|
203
1475
|
|
|
204
1476
|
/***/ }),
|
|
205
1477
|
|
|
206
|
-
/***/ "./src/client/
|
|
207
|
-
|
|
208
|
-
!*** ./src/client/
|
|
209
|
-
|
|
1478
|
+
/***/ "./src/client/store/AppProvider.jsx":
|
|
1479
|
+
/*!******************************************!*\
|
|
1480
|
+
!*** ./src/client/store/AppProvider.jsx ***!
|
|
1481
|
+
\******************************************/
|
|
210
1482
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
211
1483
|
|
|
212
1484
|
__webpack_require__.r(__webpack_exports__);
|
|
213
1485
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
214
|
-
/* harmony export */
|
|
1486
|
+
/* harmony export */ AppContext: () => (/* binding */ AppContext),
|
|
1487
|
+
/* harmony export */ AppProvider: () => (/* binding */ AppProvider)
|
|
215
1488
|
/* harmony export */ });
|
|
216
1489
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
217
1490
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
1491
|
+
/* harmony import */ var _nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nice-devone/nice-cxone-chat-web-sdk */ "@nice-devone/nice-cxone-chat-web-sdk");
|
|
1492
|
+
/* harmony import */ var _nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__);
|
|
1493
|
+
/* harmony import */ var _lib_message_notification_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/message-notification.js */ "./src/client/lib/message-notification.js");
|
|
1494
|
+
/* harmony import */ var _reducer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./reducer.js */ "./src/client/store/reducer.js");
|
|
1495
|
+
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants.js */ "./src/client/store/constants.js");
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
const AppContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(_reducer_js__WEBPACK_IMPORTED_MODULE_3__.initialState);
|
|
1502
|
+
const AppProvider = ({
|
|
1503
|
+
sdk,
|
|
1504
|
+
availability,
|
|
1505
|
+
options,
|
|
1506
|
+
children
|
|
1507
|
+
}) => {
|
|
1508
|
+
const [state, dispatch] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(_reducer_js__WEBPACK_IMPORTED_MODULE_3__.reducer, _reducer_js__WEBPACK_IMPORTED_MODULE_3__.initialState);
|
|
1509
|
+
const playSound = (0,_lib_message_notification_js__WEBPACK_IMPORTED_MODULE_2__.messageNotification)(options.audioUrl);
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* SDK event handlers
|
|
1513
|
+
*/
|
|
1514
|
+
const onLiveChatRecovered = e => {
|
|
1515
|
+
dispatch({
|
|
1516
|
+
type: 'SET_AGENT',
|
|
1517
|
+
payload: e.detail.data.inboxAssignee
|
|
1518
|
+
});
|
|
1519
|
+
dispatch({
|
|
1520
|
+
type: 'SET_AGENT_STATUS',
|
|
1521
|
+
payload: e.detail.data.contact.status
|
|
1522
|
+
});
|
|
1523
|
+
dispatch({
|
|
1524
|
+
type: 'SET_UNSEEN_COUNT',
|
|
1525
|
+
payload: e.detail.data.contact.customerStatistics.unseenMessagesCount
|
|
1526
|
+
});
|
|
1527
|
+
};
|
|
1528
|
+
const onAssignedAgentChanged = e => {
|
|
1529
|
+
dispatch({
|
|
1530
|
+
type: 'SET_AGENT',
|
|
1531
|
+
payload: e.detail.data.inboxAssignee
|
|
1532
|
+
});
|
|
1533
|
+
dispatch({
|
|
1534
|
+
type: 'SET_AGENT_STATUS',
|
|
1535
|
+
payload: e.detail.data.case.status
|
|
1536
|
+
});
|
|
1537
|
+
};
|
|
1538
|
+
const onAgentTypingStarted = () => {
|
|
1539
|
+
dispatch({
|
|
1540
|
+
type: 'SET_AGENT_TYPING',
|
|
1541
|
+
payload: true
|
|
1542
|
+
});
|
|
1543
|
+
};
|
|
1544
|
+
const onAgentTypingEnded = () => {
|
|
1545
|
+
dispatch({
|
|
1546
|
+
type: 'SET_AGENT_TYPING',
|
|
1547
|
+
payload: false
|
|
1548
|
+
});
|
|
1549
|
+
};
|
|
1550
|
+
const onMessageCreated = e => {
|
|
1551
|
+
dispatch({
|
|
1552
|
+
type: 'SET_MESSAGE',
|
|
1553
|
+
payload: e.detail.data.message
|
|
1554
|
+
});
|
|
1555
|
+
dispatch({
|
|
1556
|
+
type: 'SET_AGENT_STATUS',
|
|
1557
|
+
payload: e.detail.data.case.status
|
|
1558
|
+
});
|
|
1559
|
+
dispatch({
|
|
1560
|
+
type: 'SET_UNSEEN_COUNT',
|
|
1561
|
+
payload: e.detail.data.case.customerStatistics.unseenMessagesCount
|
|
1562
|
+
});
|
|
1563
|
+
const isAudioOn = JSON.parse(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.SETTINGS_STORAGE_KEY)).audio;
|
|
1564
|
+
if (isAudioOn && e.detail.data.message.direction === 'outbound') {
|
|
1565
|
+
playSound();
|
|
243
1566
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
1567
|
+
};
|
|
1568
|
+
const onContactStatusChanged = e => {
|
|
1569
|
+
dispatch({
|
|
1570
|
+
type: 'SET_AGENT_STATUS',
|
|
1571
|
+
payload: e.detail.data.case.status
|
|
1572
|
+
});
|
|
1573
|
+
};
|
|
1574
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1575
|
+
sdk.onChatEvent('SetConsumerContactCustomFields', () => {
|
|
1576
|
+
console.log('Custom field set');
|
|
1577
|
+
});
|
|
1578
|
+
sdk.onChatEvent(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__.ChatEvent.LIVECHAT_RECOVERED, onLiveChatRecovered);
|
|
1579
|
+
sdk.onChatEvent(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__.ChatEvent.MESSAGE_CREATED, onMessageCreated);
|
|
1580
|
+
sdk.onChatEvent(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__.ChatEvent.AGENT_TYPING_STARTED, onAgentTypingStarted);
|
|
1581
|
+
sdk.onChatEvent(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__.ChatEvent.AGENT_TYPING_ENDED, onAgentTypingEnded);
|
|
1582
|
+
sdk.onChatEvent(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__.ChatEvent.ASSIGNED_AGENT_CHANGED, onAssignedAgentChanged);
|
|
1583
|
+
sdk.onChatEvent(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_1__.ChatEvent.CONTACT_STATUS_CHANGED, onContactStatusChanged);
|
|
1584
|
+
}, [sdk]);
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* Initialize customerId, threadId and whether the webchat should be open
|
|
1588
|
+
*/
|
|
1589
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1590
|
+
dispatch({
|
|
1591
|
+
type: 'SET_AVAILABILITY',
|
|
1592
|
+
payload: availability
|
|
1593
|
+
});
|
|
1594
|
+
setCustomerId(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.CUSTOMER_ID_STORAGE_KEY));
|
|
1595
|
+
setThreadId(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.THREAD_ID_STORAGE_KEY));
|
|
1596
|
+
setSettings(JSON.parse(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.SETTINGS_STORAGE_KEY)) || state.settings);
|
|
1597
|
+
if (window.location.hash === '#webchat') {
|
|
1598
|
+
setChatVisibility(true);
|
|
254
1599
|
}
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
1600
|
+
}, []);
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* State update functions
|
|
1604
|
+
*/
|
|
1605
|
+
const setChatVisibility = payload => {
|
|
1606
|
+
if (!payload) {
|
|
1607
|
+
window.location.hash = '';
|
|
1608
|
+
}
|
|
1609
|
+
dispatch({
|
|
1610
|
+
type: 'SET_CHAT_VISIBILITY',
|
|
1611
|
+
payload
|
|
1612
|
+
});
|
|
1613
|
+
};
|
|
1614
|
+
const setCustomerId = customerId => {
|
|
1615
|
+
dispatch({
|
|
1616
|
+
type: 'SET_CUSTOMER_ID',
|
|
1617
|
+
payload: customerId
|
|
1618
|
+
});
|
|
1619
|
+
};
|
|
1620
|
+
const setThreadId = threadId => {
|
|
1621
|
+
dispatch({
|
|
1622
|
+
type: 'SET_THREAD_ID',
|
|
1623
|
+
payload: threadId
|
|
1624
|
+
});
|
|
1625
|
+
};
|
|
1626
|
+
const setThread = thread => {
|
|
1627
|
+
dispatch({
|
|
1628
|
+
type: 'SET_THREAD',
|
|
1629
|
+
payload: thread
|
|
1630
|
+
});
|
|
1631
|
+
};
|
|
1632
|
+
const setMessages = messages => {
|
|
1633
|
+
dispatch({
|
|
1634
|
+
type: 'SET_MESSAGES',
|
|
1635
|
+
payload: messages
|
|
1636
|
+
});
|
|
1637
|
+
};
|
|
1638
|
+
const setSettings = data => {
|
|
1639
|
+
dispatch({
|
|
1640
|
+
type: 'SET_SETTINGS',
|
|
1641
|
+
payload: data
|
|
1642
|
+
});
|
|
1643
|
+
};
|
|
1644
|
+
const setUnseenCount = unseenCount => {
|
|
1645
|
+
dispatch({
|
|
1646
|
+
type: 'SET_UNSEEN_COUNT',
|
|
1647
|
+
payload: unseenCount
|
|
1648
|
+
});
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* Application-wide state and state functions
|
|
1653
|
+
*/
|
|
1654
|
+
const store = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({
|
|
1655
|
+
...state,
|
|
1656
|
+
sdk,
|
|
1657
|
+
setSettings,
|
|
1658
|
+
setCustomerId,
|
|
1659
|
+
setThreadId,
|
|
1660
|
+
setThread,
|
|
1661
|
+
setMessages,
|
|
1662
|
+
setUnseenCount,
|
|
1663
|
+
setChatVisibility,
|
|
1664
|
+
onLiveChatRecovered,
|
|
1665
|
+
onAssignedAgentChanged,
|
|
1666
|
+
onAgentTypingStarted,
|
|
1667
|
+
onAgentTypingEnded,
|
|
1668
|
+
onMessageCreated,
|
|
1669
|
+
onContactStatusChanged
|
|
1670
|
+
}));
|
|
1671
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(AppContext.Provider, {
|
|
1672
|
+
value: store
|
|
1673
|
+
}, children);
|
|
1674
|
+
};
|
|
1675
|
+
|
|
1676
|
+
/***/ }),
|
|
1677
|
+
|
|
1678
|
+
/***/ "./src/client/store/actions-map.js":
|
|
1679
|
+
/*!*****************************************!*\
|
|
1680
|
+
!*** ./src/client/store/actions-map.js ***!
|
|
1681
|
+
\*****************************************/
|
|
1682
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1683
|
+
|
|
1684
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1685
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1686
|
+
/* harmony export */ actionsMap: () => (/* binding */ actionsMap)
|
|
1687
|
+
/* harmony export */ });
|
|
1688
|
+
/* harmony import */ var _lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/transform-messages */ "./src/client/lib/transform-messages.js");
|
|
1689
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/client/store/constants.js");
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
const setSettings = (state, payload) => {
|
|
1693
|
+
if (payload) {
|
|
1694
|
+
window.localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_1__.SETTINGS_STORAGE_KEY, JSON.stringify(payload));
|
|
1695
|
+
} else {
|
|
1696
|
+
window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_1__.SETTINGS_STORAGE_KEY);
|
|
1697
|
+
}
|
|
1698
|
+
return {
|
|
1699
|
+
...state,
|
|
1700
|
+
settings: payload
|
|
1701
|
+
};
|
|
1702
|
+
};
|
|
1703
|
+
const setCustomerId = (state, payload) => {
|
|
1704
|
+
if (payload) {
|
|
1705
|
+
window.localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_1__.CUSTOMER_ID_STORAGE_KEY, payload);
|
|
1706
|
+
} else {
|
|
1707
|
+
window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_1__.CUSTOMER_ID_STORAGE_KEY);
|
|
1708
|
+
}
|
|
1709
|
+
return {
|
|
1710
|
+
...state,
|
|
1711
|
+
customerId: payload
|
|
1712
|
+
};
|
|
1713
|
+
};
|
|
1714
|
+
const setThreadId = (state, payload) => {
|
|
1715
|
+
if (payload) {
|
|
1716
|
+
window.localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_1__.THREAD_ID_STORAGE_KEY, payload);
|
|
1717
|
+
} else {
|
|
1718
|
+
window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_1__.THREAD_ID_STORAGE_KEY);
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
...state,
|
|
1722
|
+
threadId: payload
|
|
1723
|
+
};
|
|
1724
|
+
};
|
|
1725
|
+
const setChatVisibility = (state, payload) => {
|
|
1726
|
+
return {
|
|
1727
|
+
...state,
|
|
1728
|
+
isChatOpen: payload
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
const setAvailability = (state, payload) => {
|
|
1732
|
+
return {
|
|
1733
|
+
...state,
|
|
1734
|
+
availability: payload
|
|
1735
|
+
};
|
|
1736
|
+
};
|
|
1737
|
+
const setThread = (state, payload) => {
|
|
1738
|
+
return {
|
|
1739
|
+
...state,
|
|
1740
|
+
thread: payload
|
|
1741
|
+
};
|
|
1742
|
+
};
|
|
1743
|
+
const setMessage = (state, payload) => {
|
|
1744
|
+
return {
|
|
1745
|
+
...state,
|
|
1746
|
+
messages: [...state.messages, (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessage)(payload)]
|
|
1747
|
+
};
|
|
1748
|
+
};
|
|
1749
|
+
const setMessages = (state, payload) => {
|
|
1750
|
+
return {
|
|
1751
|
+
...state,
|
|
1752
|
+
messages: (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessages)(payload).reverse()
|
|
1753
|
+
};
|
|
1754
|
+
};
|
|
1755
|
+
const setAgent = (state, payload) => {
|
|
1756
|
+
return {
|
|
1757
|
+
...state,
|
|
1758
|
+
agent: payload
|
|
1759
|
+
};
|
|
1760
|
+
};
|
|
1761
|
+
const setAgentIsTyping = (state, payload) => {
|
|
1762
|
+
return {
|
|
1763
|
+
...state,
|
|
1764
|
+
isAgentTyping: payload
|
|
1765
|
+
};
|
|
1766
|
+
};
|
|
1767
|
+
const setAgentStatus = (state, payload) => {
|
|
1768
|
+
return {
|
|
1769
|
+
...state,
|
|
1770
|
+
agentStatus: payload
|
|
1771
|
+
};
|
|
1772
|
+
};
|
|
1773
|
+
const setUnseenCount = (state, payload) => {
|
|
1774
|
+
return {
|
|
1775
|
+
...state,
|
|
1776
|
+
unseenCount: payload
|
|
1777
|
+
};
|
|
1778
|
+
};
|
|
1779
|
+
const actionsMap = {
|
|
1780
|
+
SET_CHAT_VISIBILITY: setChatVisibility,
|
|
1781
|
+
SET_AVAILABILITY: setAvailability,
|
|
1782
|
+
SET_SETTINGS: setSettings,
|
|
1783
|
+
SET_CUSTOMER_ID: setCustomerId,
|
|
1784
|
+
SET_THREAD_ID: setThreadId,
|
|
1785
|
+
SET_THREAD: setThread,
|
|
1786
|
+
SET_MESSAGE: setMessage,
|
|
1787
|
+
SET_MESSAGES: setMessages,
|
|
1788
|
+
SET_AGENT: setAgent,
|
|
1789
|
+
SET_AGENT_TYPING: setAgentIsTyping,
|
|
1790
|
+
SET_AGENT_STATUS: setAgentStatus,
|
|
1791
|
+
SET_UNSEEN_COUNT: setUnseenCount
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
/***/ }),
|
|
1795
|
+
|
|
1796
|
+
/***/ "./src/client/store/constants.js":
|
|
1797
|
+
/*!***************************************!*\
|
|
1798
|
+
!*** ./src/client/store/constants.js ***!
|
|
1799
|
+
\***************************************/
|
|
1800
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1801
|
+
|
|
1802
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1803
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1804
|
+
/* harmony export */ CUSTOMER_ID_STORAGE_KEY: () => (/* binding */ CUSTOMER_ID_STORAGE_KEY),
|
|
1805
|
+
/* harmony export */ SETTINGS_STORAGE_KEY: () => (/* binding */ SETTINGS_STORAGE_KEY),
|
|
1806
|
+
/* harmony export */ THREAD_ID_STORAGE_KEY: () => (/* binding */ THREAD_ID_STORAGE_KEY)
|
|
1807
|
+
/* harmony export */ });
|
|
1808
|
+
const SETTINGS_STORAGE_KEY = 'webchat_settings';
|
|
1809
|
+
const CUSTOMER_ID_STORAGE_KEY = 'webchat_customer_id';
|
|
1810
|
+
const THREAD_ID_STORAGE_KEY = 'webchat_thread_id';
|
|
1811
|
+
|
|
1812
|
+
/***/ }),
|
|
1813
|
+
|
|
1814
|
+
/***/ "./src/client/store/reducer.js":
|
|
1815
|
+
/*!*************************************!*\
|
|
1816
|
+
!*** ./src/client/store/reducer.js ***!
|
|
1817
|
+
\*************************************/
|
|
1818
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1819
|
+
|
|
1820
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1821
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1822
|
+
/* harmony export */ initialState: () => (/* binding */ initialState),
|
|
1823
|
+
/* harmony export */ reducer: () => (/* binding */ reducer)
|
|
1824
|
+
/* harmony export */ });
|
|
1825
|
+
/* harmony import */ var _actions_map__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./actions-map */ "./src/client/store/actions-map.js");
|
|
1826
|
+
|
|
1827
|
+
const initialState = {
|
|
1828
|
+
availability: null,
|
|
1829
|
+
customerId: null,
|
|
1830
|
+
threadId: null,
|
|
1831
|
+
thread: null,
|
|
1832
|
+
messages: [],
|
|
1833
|
+
unseenCount: 0,
|
|
1834
|
+
agent: null,
|
|
1835
|
+
agentStatus: null,
|
|
1836
|
+
isAgentTyping: false,
|
|
1837
|
+
isChatOpen: false,
|
|
1838
|
+
settings: {
|
|
1839
|
+
audio: true,
|
|
1840
|
+
scroll: true
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1843
|
+
const reducer = (state, action) => {
|
|
1844
|
+
const {
|
|
1845
|
+
type,
|
|
1846
|
+
payload
|
|
1847
|
+
} = action;
|
|
1848
|
+
const fn = _actions_map__WEBPACK_IMPORTED_MODULE_0__.actionsMap[type];
|
|
1849
|
+
if (fn) {
|
|
1850
|
+
const actionFunction = fn.bind(undefined, state, payload);
|
|
1851
|
+
return actionFunction();
|
|
1852
|
+
}
|
|
1853
|
+
return state;
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
/***/ }),
|
|
1857
|
+
|
|
1858
|
+
/***/ "./src/client/store/useApp.js":
|
|
1859
|
+
/*!************************************!*\
|
|
1860
|
+
!*** ./src/client/store/useApp.js ***!
|
|
1861
|
+
\************************************/
|
|
1862
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1863
|
+
|
|
1864
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1865
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1866
|
+
/* harmony export */ useApp: () => (/* binding */ useApp)
|
|
1867
|
+
/* harmony export */ });
|
|
1868
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
1869
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1870
|
+
/* harmony import */ var _AppProvider_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AppProvider.jsx */ "./src/client/store/AppProvider.jsx");
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
const useApp = () => (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_AppProvider_jsx__WEBPACK_IMPORTED_MODULE_1__.AppContext);
|
|
1874
|
+
|
|
1875
|
+
/***/ }),
|
|
1876
|
+
|
|
1877
|
+
/***/ "./src/client/store/useChatSdk.js":
|
|
1878
|
+
/*!****************************************!*\
|
|
1879
|
+
!*** ./src/client/store/useChatSdk.js ***!
|
|
1880
|
+
\****************************************/
|
|
1881
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1882
|
+
|
|
1883
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1884
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1885
|
+
/* harmony export */ useChatSdk: () => (/* binding */ useChatSdk)
|
|
1886
|
+
/* harmony export */ });
|
|
1887
|
+
const useChatSdk = sdk => {
|
|
1888
|
+
const connect = async () => sdk.authorize();
|
|
1889
|
+
const fetchCustomerId = async () => {
|
|
1890
|
+
const response = await connect();
|
|
1891
|
+
return response?.consumerIdentity.idOnExternalPlatform;
|
|
1892
|
+
};
|
|
1893
|
+
const fetchThread = async threadId => {
|
|
1894
|
+
await connect();
|
|
1895
|
+
return sdk.getThread(threadId);
|
|
1896
|
+
};
|
|
1897
|
+
const fetchMessages = async (thread, threadId) => {
|
|
1898
|
+
await connect();
|
|
1899
|
+
const recovered = await thread.recover(threadId);
|
|
1900
|
+
const allMessages = [];
|
|
1901
|
+
let fetchedMessages = recovered.messages;
|
|
1902
|
+
while (fetchedMessages.length) {
|
|
1903
|
+
fetchedMessages.map(msg => allMessages.push(msg));
|
|
260
1904
|
try {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
listener();
|
|
264
|
-
}
|
|
1905
|
+
const response = await thread.loadMoreMessages();
|
|
1906
|
+
fetchedMessages = response.data.messages;
|
|
265
1907
|
} catch (err) {
|
|
266
|
-
|
|
267
|
-
} finally {
|
|
268
|
-
_iterator.f();
|
|
1908
|
+
fetchedMessages = [];
|
|
269
1909
|
}
|
|
270
1910
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return ExternalSyncStore;
|
|
289
|
-
}();
|
|
1911
|
+
return allMessages;
|
|
1912
|
+
};
|
|
1913
|
+
return {
|
|
1914
|
+
connect,
|
|
1915
|
+
fetchCustomerId,
|
|
1916
|
+
fetchThread,
|
|
1917
|
+
fetchMessages
|
|
1918
|
+
};
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
/***/ }),
|
|
1922
|
+
|
|
1923
|
+
/***/ "@nice-devone/nice-cxone-chat-web-sdk":
|
|
1924
|
+
/*!*******************************************************!*\
|
|
1925
|
+
!*** external "@nice-devone/nice-cxone-chat-web-sdk" ***!
|
|
1926
|
+
\*******************************************************/
|
|
1927
|
+
/***/ ((module) => {
|
|
290
1928
|
|
|
1929
|
+
module.exports = require("@nice-devone/nice-cxone-chat-web-sdk");
|
|
1930
|
+
|
|
1931
|
+
/***/ }),
|
|
1932
|
+
|
|
1933
|
+
/***/ "luxon":
|
|
1934
|
+
/*!************************!*\
|
|
1935
|
+
!*** external "luxon" ***!
|
|
1936
|
+
\************************/
|
|
1937
|
+
/***/ ((module) => {
|
|
1938
|
+
|
|
1939
|
+
module.exports = require("luxon");
|
|
291
1940
|
|
|
292
1941
|
/***/ }),
|
|
293
1942
|
|
|
@@ -301,6 +1950,16 @@ module.exports = require("react");
|
|
|
301
1950
|
|
|
302
1951
|
/***/ }),
|
|
303
1952
|
|
|
1953
|
+
/***/ "react-dom":
|
|
1954
|
+
/*!****************************!*\
|
|
1955
|
+
!*** external "react-dom" ***!
|
|
1956
|
+
\****************************/
|
|
1957
|
+
/***/ ((module) => {
|
|
1958
|
+
|
|
1959
|
+
module.exports = require("react-dom");
|
|
1960
|
+
|
|
1961
|
+
/***/ }),
|
|
1962
|
+
|
|
304
1963
|
/***/ "react-dom/client":
|
|
305
1964
|
/*!***********************************!*\
|
|
306
1965
|
!*** external "react-dom/client" ***!
|
|
@@ -309,6 +1968,16 @@ module.exports = require("react");
|
|
|
309
1968
|
|
|
310
1969
|
module.exports = require("react-dom/client");
|
|
311
1970
|
|
|
1971
|
+
/***/ }),
|
|
1972
|
+
|
|
1973
|
+
/***/ "uuid":
|
|
1974
|
+
/*!***********************!*\
|
|
1975
|
+
!*** external "uuid" ***!
|
|
1976
|
+
\***********************/
|
|
1977
|
+
/***/ ((module) => {
|
|
1978
|
+
|
|
1979
|
+
module.exports = require("uuid");
|
|
1980
|
+
|
|
312
1981
|
/***/ })
|
|
313
1982
|
|
|
314
1983
|
/******/ });
|
|
@@ -393,49 +2062,39 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
393
2062
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
394
2063
|
/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom/client */ "react-dom/client");
|
|
395
2064
|
/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom_client__WEBPACK_IMPORTED_MODULE_1__);
|
|
396
|
-
/* harmony import */ var
|
|
397
|
-
/* harmony import */ var
|
|
398
|
-
|
|
399
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return { value: void 0, done: !0 }; } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable || "" === iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } throw new TypeError(_typeof(iterable) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
400
|
-
|
|
401
|
-
|
|
2065
|
+
/* harmony import */ var _nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nice-devone/nice-cxone-chat-web-sdk */ "@nice-devone/nice-cxone-chat-web-sdk");
|
|
2066
|
+
/* harmony import */ var _nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_2__);
|
|
2067
|
+
/* harmony import */ var _components_availability_availability_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/availability/availability.jsx */ "./src/client/components/availability/availability.jsx");
|
|
2068
|
+
/* harmony import */ var _lib_check_availability__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/check-availability */ "./src/client/lib/check-availability.js");
|
|
2069
|
+
/* harmony import */ var _store_AppProvider_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./store/AppProvider.jsx */ "./src/client/store/AppProvider.jsx");
|
|
2070
|
+
/* harmony import */ var _store_constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./store/constants.js */ "./src/client/store/constants.js");
|
|
402
2071
|
|
|
403
2072
|
|
|
404
2073
|
|
|
405
2074
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
function
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
root.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_availability_availability_jsx__WEBPACK_IMPORTED_MODULE_2__.Availability, {
|
|
430
|
-
availability: availability
|
|
431
|
-
}));
|
|
432
|
-
case 12:
|
|
433
|
-
case "end":
|
|
434
|
-
return _context.stop();
|
|
435
|
-
}
|
|
436
|
-
}, _callee, null, [[1, 8]]);
|
|
437
|
-
}));
|
|
438
|
-
return _init.apply(this, arguments);
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
async function init(container, options) {
|
|
2079
|
+
const sdk = new _nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_2__.ChatSdk({
|
|
2080
|
+
brandId: options.brandId,
|
|
2081
|
+
channelId: options.channelId,
|
|
2082
|
+
customerId: window.localStorage.getItem(_store_constants_js__WEBPACK_IMPORTED_MODULE_6__.CUSTOMER_ID_STORAGE_KEY) || '',
|
|
2083
|
+
environment: options.environment
|
|
2084
|
+
});
|
|
2085
|
+
const root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_1__.createRoot)(container);
|
|
2086
|
+
let availability;
|
|
2087
|
+
try {
|
|
2088
|
+
const result = await (0,_lib_check_availability__WEBPACK_IMPORTED_MODULE_4__.checkAvailability)(options.availabilityEndpoint);
|
|
2089
|
+
availability = result.availability;
|
|
2090
|
+
} catch (e) {
|
|
2091
|
+
availability = 'UNAVAILABLE';
|
|
2092
|
+
}
|
|
2093
|
+
root.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_store_AppProvider_jsx__WEBPACK_IMPORTED_MODULE_5__.AppProvider, {
|
|
2094
|
+
sdk: sdk,
|
|
2095
|
+
availability: availability,
|
|
2096
|
+
options: options
|
|
2097
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_availability_availability_jsx__WEBPACK_IMPORTED_MODULE_3__.Availability, null)));
|
|
439
2098
|
}
|
|
440
2099
|
})();
|
|
441
2100
|
|