@defra/flood-webchat 0.0.1-beta.17 → 0.0.1-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +270 -96
- package/dist/client.js.map +1 -1
- package/package.json +1 -2
- package/src/client/components/chat/chat.jsx +7 -6
- package/src/client/components/panel/panel-header.jsx +1 -0
- package/src/client/components/panel/panel.jsx +15 -15
- package/src/client/components/screens/end-chat.jsx +3 -3
- package/src/client/components/screens/pre-chat.jsx +16 -6
- package/src/client/components/screens/request-chat.jsx +2 -2
- package/src/client/components/screens/settings.jsx +67 -0
- package/src/client/index.jsx +3 -3
- package/src/client/lib/message-notification.js +36 -0
- package/src/client/lib/transform-messages.js +1 -2
- package/src/client/store/AppProvider.jsx +19 -2
- package/src/client/store/actions-map.js +15 -1
- package/src/client/store/constants.js +3 -0
- package/src/client/store/reducer.js +2 -4
package/dist/client.js
CHANGED
|
@@ -114,15 +114,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
114
114
|
/* harmony export */ });
|
|
115
115
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
116
116
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
117
|
-
/* harmony import */ var
|
|
118
|
-
/* harmony import */ var
|
|
119
|
-
/* harmony import */ var
|
|
120
|
-
/* harmony import */ var
|
|
121
|
-
/* harmony import */ var
|
|
122
|
-
/* harmony import */ var
|
|
123
|
-
/* harmony import */ var _hooks_useTextareaAutosize_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../hooks/useTextareaAutosize.js */ "./src/client/hooks/useTextareaAutosize.js");
|
|
124
|
-
/* harmony import */ var _lib_transform_messages_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../lib/transform-messages.js */ "./src/client/lib/transform-messages.js");
|
|
125
|
-
|
|
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");
|
|
126
123
|
|
|
127
124
|
|
|
128
125
|
|
|
@@ -131,7 +128,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
131
128
|
|
|
132
129
|
|
|
133
130
|
function Chat({
|
|
134
|
-
|
|
131
|
+
onEndChatScreen,
|
|
132
|
+
onSettingsScreen
|
|
135
133
|
}) {
|
|
136
134
|
const {
|
|
137
135
|
availability,
|
|
@@ -139,13 +137,14 @@ function Chat({
|
|
|
139
137
|
messages,
|
|
140
138
|
agent,
|
|
141
139
|
agentStatus,
|
|
142
|
-
isAgentTyping
|
|
143
|
-
|
|
140
|
+
isAgentTyping,
|
|
141
|
+
settings
|
|
142
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
144
143
|
const [userMessage, setUserMessage] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('');
|
|
145
144
|
const messageRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
146
|
-
(0,
|
|
145
|
+
(0,_hooks_useTextareaAutosize_js__WEBPACK_IMPORTED_MODULE_5__.useTextareaAutosize)(messageRef.current, userMessage);
|
|
147
146
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
148
|
-
if (messages.length !== 0) {
|
|
147
|
+
if (settings.scroll && messages.length !== 0) {
|
|
149
148
|
const chatBody = document.querySelector('.wc-body');
|
|
150
149
|
chatBody.scrollTop = chatBody.scrollHeight;
|
|
151
150
|
}
|
|
@@ -181,19 +180,19 @@ function Chat({
|
|
|
181
180
|
return;
|
|
182
181
|
}
|
|
183
182
|
try {
|
|
184
|
-
thread.sendTextMessage(
|
|
183
|
+
thread.sendTextMessage(messageRef.current.value.trim());
|
|
185
184
|
} catch (err) {
|
|
186
185
|
console.log('[Chat Error] sendMessage', err);
|
|
187
186
|
}
|
|
188
187
|
setUserMessage('');
|
|
189
188
|
};
|
|
190
189
|
const saveChat = () => {
|
|
191
|
-
const transcript = (0,
|
|
190
|
+
const transcript = (0,_lib_transform_messages_js__WEBPACK_IMPORTED_MODULE_6__.formatTranscript)(messages);
|
|
192
191
|
const saveChatLink = document.querySelector('#transcript-download');
|
|
193
192
|
saveChatLink.setAttribute('href', `data:text/plain;charset=utf-8,${transcript}`);
|
|
194
193
|
saveChatLink.click();
|
|
195
194
|
};
|
|
196
|
-
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(
|
|
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", {
|
|
197
196
|
className: "wc-status"
|
|
198
197
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
199
198
|
className: "wc-status__availability govuk-body-s"
|
|
@@ -201,14 +200,14 @@ function Chat({
|
|
|
201
200
|
className: "wc-status__link govuk-!-font-size-16",
|
|
202
201
|
href: "#",
|
|
203
202
|
"data-module": "govuk-button",
|
|
204
|
-
onClick:
|
|
203
|
+
onClick: onEndChatScreen
|
|
205
204
|
}, "End chat")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
206
205
|
className: "wc-body"
|
|
207
206
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
208
207
|
className: "wc-chat__body"
|
|
209
208
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
|
|
210
209
|
className: "wc-chat__messages"
|
|
211
|
-
}, messages.length ? messages.map((msg, index) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(
|
|
210
|
+
}, messages.length ? messages.map((msg, index) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_message_message_jsx__WEBPACK_IMPORTED_MODULE_3__.Message, {
|
|
212
211
|
key: msg.id,
|
|
213
212
|
message: msg,
|
|
214
213
|
previousMessage: messages[index - 1]
|
|
@@ -242,7 +241,7 @@ function Chat({
|
|
|
242
241
|
cy: "8",
|
|
243
242
|
r: "3",
|
|
244
243
|
fill: "currentColor"
|
|
245
|
-
})))) : null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(
|
|
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", {
|
|
246
245
|
className: "wc-footer__input"
|
|
247
246
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("form", {
|
|
248
247
|
className: "wc-form",
|
|
@@ -271,8 +270,10 @@ function Chat({
|
|
|
271
270
|
className: "wc-footer__settings"
|
|
272
271
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
273
272
|
href: "#",
|
|
273
|
+
id: "wc-settings",
|
|
274
274
|
className: "wc-footer__settings-link",
|
|
275
|
-
"data-module": "govuk-button"
|
|
275
|
+
"data-module": "govuk-button",
|
|
276
|
+
onClick: onSettingsScreen
|
|
276
277
|
}, "Settings"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
277
278
|
href: "#",
|
|
278
279
|
id: "transcript-download",
|
|
@@ -415,6 +416,7 @@ function PanelHeader() {
|
|
|
415
416
|
const onClose = e => {
|
|
416
417
|
e.preventDefault();
|
|
417
418
|
setChatVisibility(false);
|
|
419
|
+
thread.lastMessageSeen();
|
|
418
420
|
setUnseenCount(0);
|
|
419
421
|
};
|
|
420
422
|
let ButtonComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
|
|
@@ -476,9 +478,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
476
478
|
/* harmony import */ var _chat_chat_jsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../chat/chat.jsx */ "./src/client/components/chat/chat.jsx");
|
|
477
479
|
/* harmony import */ var _screens_unavailable_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../screens/unavailable.jsx */ "./src/client/components/screens/unavailable.jsx");
|
|
478
480
|
/* harmony import */ var _screens_end_chat_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../screens/end-chat.jsx */ "./src/client/components/screens/end-chat.jsx");
|
|
479
|
-
/* harmony import */ var
|
|
480
|
-
/* harmony import */ var
|
|
481
|
-
/* harmony import */ var
|
|
481
|
+
/* harmony import */ var _screens_settings_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../screens/settings.jsx */ "./src/client/components/screens/settings.jsx");
|
|
482
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
483
|
+
/* harmony import */ var _store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../store/useChatSdk.js */ "./src/client/store/useChatSdk.js");
|
|
484
|
+
/* harmony import */ var _hooks_useFocusedElements_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../hooks/useFocusedElements.js */ "./src/client/hooks/useFocusedElements.js");
|
|
485
|
+
|
|
482
486
|
|
|
483
487
|
|
|
484
488
|
|
|
@@ -500,13 +504,13 @@ function Panel() {
|
|
|
500
504
|
setChatVisibility,
|
|
501
505
|
setMessages,
|
|
502
506
|
setUnseenCount
|
|
503
|
-
} = (0,
|
|
507
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_8__.useApp)();
|
|
504
508
|
const {
|
|
505
509
|
fetchThread,
|
|
506
510
|
fetchMessages
|
|
507
|
-
} = (0,
|
|
511
|
+
} = (0,_store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_9__.useChatSdk)(sdk);
|
|
508
512
|
const [screen, setScreen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(threadId ? 2 : 0);
|
|
509
|
-
(0,
|
|
513
|
+
(0,_hooks_useFocusedElements_js__WEBPACK_IMPORTED_MODULE_10__.useFocusedElements)(screen);
|
|
510
514
|
|
|
511
515
|
/**
|
|
512
516
|
* Initializes the eventListener for pressing the escape key
|
|
@@ -554,41 +558,42 @@ function Panel() {
|
|
|
554
558
|
e.preventDefault();
|
|
555
559
|
setScreen(newScreen);
|
|
556
560
|
};
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
const
|
|
562
|
-
e.preventDefault();
|
|
563
|
-
console.log('confirmed end chat');
|
|
564
|
-
};
|
|
561
|
+
const goToPreChatScreen = handleScreenChange(0);
|
|
562
|
+
const goToRequestChatScreen = handleScreenChange(1);
|
|
563
|
+
const goToChatScreen = handleScreenChange(2);
|
|
564
|
+
const goToEndChatScreen = handleScreenChange(3);
|
|
565
|
+
const goToSettingsScreen = handleScreenChange(5);
|
|
565
566
|
let ScreenComponent;
|
|
566
567
|
switch (screen) {
|
|
567
568
|
case 0:
|
|
568
569
|
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_pre_chat_jsx__WEBPACK_IMPORTED_MODULE_2__.PreChat, {
|
|
569
|
-
|
|
570
|
+
onContinue: goToRequestChatScreen
|
|
570
571
|
});
|
|
571
572
|
break;
|
|
572
573
|
case 1:
|
|
573
574
|
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_request_chat_jsx__WEBPACK_IMPORTED_MODULE_3__.RequestChat, {
|
|
574
|
-
|
|
575
|
+
onPreChatScreen: goToPreChatScreen
|
|
575
576
|
});
|
|
576
577
|
break;
|
|
577
578
|
case 2:
|
|
578
579
|
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_chat_chat_jsx__WEBPACK_IMPORTED_MODULE_4__.Chat, {
|
|
579
|
-
|
|
580
|
-
|
|
580
|
+
onSettingsScreen: goToSettingsScreen,
|
|
581
|
+
onEndChatScreen: goToEndChatScreen
|
|
581
582
|
});
|
|
582
583
|
break;
|
|
583
584
|
case 3:
|
|
584
585
|
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_end_chat_jsx__WEBPACK_IMPORTED_MODULE_6__.EndChat, {
|
|
585
|
-
|
|
586
|
-
|
|
586
|
+
onChatScreen: goToChatScreen
|
|
587
|
+
});
|
|
588
|
+
break;
|
|
589
|
+
case 5:
|
|
590
|
+
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_settings_jsx__WEBPACK_IMPORTED_MODULE_7__.Settings, {
|
|
591
|
+
onCancel: goToChatScreen
|
|
587
592
|
});
|
|
588
593
|
break;
|
|
589
594
|
default:
|
|
590
595
|
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_pre_chat_jsx__WEBPACK_IMPORTED_MODULE_2__.PreChat, {
|
|
591
|
-
|
|
596
|
+
onContinue: goToRequestChatScreen
|
|
592
597
|
});
|
|
593
598
|
}
|
|
594
599
|
if (availability === 'UNAVAILABLE') {
|
|
@@ -596,8 +601,8 @@ function Panel() {
|
|
|
596
601
|
}
|
|
597
602
|
const Component = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
598
603
|
id: "wc-panel",
|
|
599
|
-
className: "wc-panel",
|
|
600
604
|
role: "dialog",
|
|
605
|
+
className: "wc-panel",
|
|
601
606
|
tabIndex: "-1",
|
|
602
607
|
"aria-modal": "true",
|
|
603
608
|
"aria-labelledby": "wc-header-title"
|
|
@@ -623,8 +628,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
623
628
|
|
|
624
629
|
|
|
625
630
|
function EndChat({
|
|
626
|
-
|
|
627
|
-
onEndChatConfirm
|
|
631
|
+
onChatScreen
|
|
628
632
|
}) {
|
|
629
633
|
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", {
|
|
630
634
|
className: "wc-body"
|
|
@@ -636,12 +640,11 @@ function EndChat({
|
|
|
636
640
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
637
641
|
href: "#",
|
|
638
642
|
className: "govuk-button govuk-!-font-size-16",
|
|
639
|
-
"data-module": "govuk-button"
|
|
640
|
-
onClick: onEndChatConfirm
|
|
643
|
+
"data-module": "govuk-button"
|
|
641
644
|
}, "Yes, end chat"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
642
645
|
href: "#",
|
|
643
646
|
className: "govuk-link govuk-!-font-size-16",
|
|
644
|
-
onClick:
|
|
647
|
+
onClick: onChatScreen
|
|
645
648
|
}, "No, resume chat"))));
|
|
646
649
|
}
|
|
647
650
|
|
|
@@ -663,7 +666,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
663
666
|
|
|
664
667
|
|
|
665
668
|
function PreChat({
|
|
666
|
-
|
|
669
|
+
onContinue
|
|
667
670
|
}) {
|
|
668
671
|
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", {
|
|
669
672
|
className: "wc-body"
|
|
@@ -680,19 +683,25 @@ function PreChat({
|
|
|
680
683
|
className: "govuk-body-s"
|
|
681
684
|
}, 'There are other ways to ', /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
682
685
|
className: "govuk-link",
|
|
683
|
-
href: "https://www.gov.uk/sign-up-for-flood-warnings"
|
|
686
|
+
href: "https://www.gov.uk/sign-up-for-flood-warnings",
|
|
687
|
+
target: "_blank",
|
|
688
|
+
rel: "noreferrer"
|
|
684
689
|
}, "sign up for flood warnings"), ' and ', /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
685
690
|
className: "govuk-link",
|
|
686
|
-
href: "https://www.fws.environment-agency.gov.uk/app/olr/login"
|
|
691
|
+
href: "https://www.fws.environment-agency.gov.uk/app/olr/login",
|
|
692
|
+
target: "_blank",
|
|
693
|
+
rel: "noreferrer"
|
|
687
694
|
}, "manage your flood warnings account"), "."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
688
695
|
className: "govuk-body-s"
|
|
689
|
-
},
|
|
696
|
+
}, 'Do not use webchat to ', /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
690
697
|
className: "govuk-link",
|
|
691
|
-
href: "https://www.gov.uk/report-flood-cause"
|
|
698
|
+
href: "https://www.gov.uk/report-flood-cause",
|
|
699
|
+
target: "_blank",
|
|
700
|
+
rel: "noreferrer"
|
|
692
701
|
}, "report a flood"), "."), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
|
|
693
702
|
className: "govuk-button govuk-!-font-size-16",
|
|
694
703
|
"data-module": "govuk-button",
|
|
695
|
-
onClick:
|
|
704
|
+
onClick: onContinue
|
|
696
705
|
}, "Continue"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
697
706
|
className: "govuk-heading-s"
|
|
698
707
|
}, "Other flood information"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
@@ -701,7 +710,9 @@ function PreChat({
|
|
|
701
710
|
className: "govuk-body-s"
|
|
702
711
|
}, /*#__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", {
|
|
703
712
|
className: "govuk-link",
|
|
704
|
-
href: "https://gov.uk/call-charges"
|
|
713
|
+
href: "https://gov.uk/call-charges",
|
|
714
|
+
target: "_blank",
|
|
715
|
+
rel: "noreferrer"
|
|
705
716
|
}, "Find out more about call charges"))));
|
|
706
717
|
}
|
|
707
718
|
|
|
@@ -735,7 +746,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
735
746
|
|
|
736
747
|
const QUESTION_MAX_LENGTH = 500;
|
|
737
748
|
function RequestChat({
|
|
738
|
-
|
|
749
|
+
onPreChatScreen
|
|
739
750
|
}) {
|
|
740
751
|
const {
|
|
741
752
|
sdk,
|
|
@@ -799,7 +810,7 @@ function RequestChat({
|
|
|
799
810
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
800
811
|
href: "#",
|
|
801
812
|
className: "wc-back-link govuk-back-link",
|
|
802
|
-
onClick:
|
|
813
|
+
onClick: onPreChatScreen
|
|
803
814
|
}, "What you can use webchat for"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_errorSummary_error_summary_jsx__WEBPACK_IMPORTED_MODULE_6__.ErrorSummary, {
|
|
804
815
|
errors: errors
|
|
805
816
|
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
@@ -862,6 +873,97 @@ function RequestChat({
|
|
|
862
873
|
|
|
863
874
|
/***/ }),
|
|
864
875
|
|
|
876
|
+
/***/ "./src/client/components/screens/settings.jsx":
|
|
877
|
+
/*!****************************************************!*\
|
|
878
|
+
!*** ./src/client/components/screens/settings.jsx ***!
|
|
879
|
+
\****************************************************/
|
|
880
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
881
|
+
|
|
882
|
+
__webpack_require__.r(__webpack_exports__);
|
|
883
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
884
|
+
/* harmony export */ Settings: () => (/* binding */ Settings)
|
|
885
|
+
/* harmony export */ });
|
|
886
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
887
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
888
|
+
/* harmony import */ var _panel_panel_header_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../panel/panel-header.jsx */ "./src/client/components/panel/panel-header.jsx");
|
|
889
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
function Settings({
|
|
894
|
+
onCancel
|
|
895
|
+
}) {
|
|
896
|
+
const {
|
|
897
|
+
settings,
|
|
898
|
+
setSettings
|
|
899
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_2__.useApp)();
|
|
900
|
+
const [optionAudio, setOptionAudio] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(settings.audio);
|
|
901
|
+
const [optionScroll, setOptionScroll] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(settings.scroll);
|
|
902
|
+
const onSave = e => {
|
|
903
|
+
e.preventDefault();
|
|
904
|
+
setSettings({
|
|
905
|
+
audio: optionAudio,
|
|
906
|
+
scroll: optionScroll
|
|
907
|
+
});
|
|
908
|
+
onCancel(e);
|
|
909
|
+
};
|
|
910
|
+
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", {
|
|
911
|
+
className: "wc-body"
|
|
912
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("fieldset", {
|
|
913
|
+
className: "govuk-fieldset govuk-!-margin-bottom-4"
|
|
914
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("legend", {
|
|
915
|
+
className: "govuk-fieldset__legend govuk-fieldset__legend"
|
|
916
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("h3", {
|
|
917
|
+
id: "wc-subtitle",
|
|
918
|
+
className: "govuk-heading-s"
|
|
919
|
+
}, "Change settings")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
920
|
+
className: "govuk-checkboxes govuk-checkboxes--small",
|
|
921
|
+
"data-module": "govuk-checkboxes"
|
|
922
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
923
|
+
className: "govuk-checkboxes__item"
|
|
924
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
925
|
+
id: "audio",
|
|
926
|
+
name: "audio",
|
|
927
|
+
type: "checkbox",
|
|
928
|
+
value: "audio",
|
|
929
|
+
className: "govuk-checkboxes__input",
|
|
930
|
+
defaultChecked: optionAudio,
|
|
931
|
+
onChange: () => setOptionAudio(!optionAudio)
|
|
932
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
933
|
+
className: "govuk-label govuk-checkboxes__label govuk-!-font-size-16",
|
|
934
|
+
htmlFor: "audio"
|
|
935
|
+
}, "Play a sound when receiving a new message")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
936
|
+
className: "govuk-checkboxes__item"
|
|
937
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
|
|
938
|
+
id: "scroll",
|
|
939
|
+
name: "scroll",
|
|
940
|
+
type: "checkbox",
|
|
941
|
+
value: "scroll",
|
|
942
|
+
className: "govuk-checkboxes__input",
|
|
943
|
+
defaultChecked: optionScroll,
|
|
944
|
+
onChange: () => setOptionScroll(!optionScroll)
|
|
945
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
|
|
946
|
+
className: "govuk-label govuk-checkboxes__label govuk-!-font-size-16",
|
|
947
|
+
htmlFor: "scroll"
|
|
948
|
+
}, "Scroll automatically to a new message")))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
949
|
+
className: "govuk-button-group"
|
|
950
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
951
|
+
id: "settings-save",
|
|
952
|
+
href: "#",
|
|
953
|
+
className: "govuk-button govuk-!-font-size-16",
|
|
954
|
+
"data-module": "govuk-button",
|
|
955
|
+
onClick: onSave
|
|
956
|
+
}, "Save"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
957
|
+
id: "settings-cancel",
|
|
958
|
+
href: "#",
|
|
959
|
+
className: "govuk-link govuk-!-font-size-16",
|
|
960
|
+
"data-module": "govuk-button",
|
|
961
|
+
onClick: onCancel
|
|
962
|
+
}, "Cancel"))));
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/***/ }),
|
|
966
|
+
|
|
865
967
|
/***/ "./src/client/components/screens/unavailable.jsx":
|
|
866
968
|
/*!*******************************************************!*\
|
|
867
969
|
!*** ./src/client/components/screens/unavailable.jsx ***!
|
|
@@ -1023,6 +1125,44 @@ const classnames = (...classes) => classes.filter(classname => classname && type
|
|
|
1023
1125
|
|
|
1024
1126
|
/***/ }),
|
|
1025
1127
|
|
|
1128
|
+
/***/ "./src/client/lib/message-notification.js":
|
|
1129
|
+
/*!************************************************!*\
|
|
1130
|
+
!*** ./src/client/lib/message-notification.js ***!
|
|
1131
|
+
\************************************************/
|
|
1132
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1133
|
+
|
|
1134
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1135
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1136
|
+
/* harmony export */ messageNotification: () => (/* binding */ messageNotification)
|
|
1137
|
+
/* harmony export */ });
|
|
1138
|
+
const messageNotification = audioUrl => {
|
|
1139
|
+
let buffer;
|
|
1140
|
+
const context = new (window.AudioContext || window.webkitAudioContext)();
|
|
1141
|
+
if (context.state === 'suspended') {
|
|
1142
|
+
const events = ['touchstart', 'touchend', 'mousedown', 'wheel', 'keydown', 'click'];
|
|
1143
|
+
const unlock = _e => {
|
|
1144
|
+
events.forEach(event => {
|
|
1145
|
+
document.body.removeEventListener(event, unlock);
|
|
1146
|
+
});
|
|
1147
|
+
context.resume();
|
|
1148
|
+
};
|
|
1149
|
+
events.forEach(event => {
|
|
1150
|
+
document.body.addEventListener(event, unlock, false);
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
fetch(audioUrl).then(response => response.arrayBuffer()).then(data => context.decodeAudioData(data)).then(decodedData => {
|
|
1154
|
+
buffer = decodedData;
|
|
1155
|
+
}).catch(console.error);
|
|
1156
|
+
return () => {
|
|
1157
|
+
const source = context.createBufferSource();
|
|
1158
|
+
source.buffer = buffer;
|
|
1159
|
+
source.connect(context.destination);
|
|
1160
|
+
source.start();
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
/***/ }),
|
|
1165
|
+
|
|
1026
1166
|
/***/ "./src/client/lib/transform-messages.js":
|
|
1027
1167
|
/*!**********************************************!*\
|
|
1028
1168
|
!*** ./src/client/lib/transform-messages.js ***!
|
|
@@ -1037,17 +1177,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1037
1177
|
/* harmony export */ });
|
|
1038
1178
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uuid */ "uuid");
|
|
1039
1179
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_0__);
|
|
1040
|
-
/* harmony import */ var
|
|
1041
|
-
/* harmony import */ var
|
|
1042
|
-
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! luxon */ "luxon");
|
|
1043
|
-
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(luxon__WEBPACK_IMPORTED_MODULE_2__);
|
|
1044
|
-
|
|
1180
|
+
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! luxon */ "luxon");
|
|
1181
|
+
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(luxon__WEBPACK_IMPORTED_MODULE_1__);
|
|
1045
1182
|
|
|
1046
1183
|
|
|
1047
1184
|
const transformMessage = message => {
|
|
1048
1185
|
return {
|
|
1049
1186
|
id: message.id,
|
|
1050
|
-
text:
|
|
1187
|
+
text: message.messageContent?.text,
|
|
1051
1188
|
createdAt: new Date(message.createdAt),
|
|
1052
1189
|
user: message.authorEndUserIdentity?.fullName?.trim() || null,
|
|
1053
1190
|
assignee: message.authorUser?.firstName || null,
|
|
@@ -1056,7 +1193,7 @@ const transformMessage = message => {
|
|
|
1056
1193
|
};
|
|
1057
1194
|
const transformMessages = messages => messages.map(message => transformMessage(message));
|
|
1058
1195
|
const formatTranscript = messages => {
|
|
1059
|
-
const now =
|
|
1196
|
+
const now = luxon__WEBPACK_IMPORTED_MODULE_1__.DateTime.local();
|
|
1060
1197
|
now.setZone('Europe/London');
|
|
1061
1198
|
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`;
|
|
1062
1199
|
for (const message of messages) {
|
|
@@ -1068,7 +1205,7 @@ const formatTranscript = messages => {
|
|
|
1068
1205
|
createdAt
|
|
1069
1206
|
} = message;
|
|
1070
1207
|
const author = direction === 'inbound' ? user : `${assignee} (Floodline adviser)`;
|
|
1071
|
-
const date =
|
|
1208
|
+
const date = luxon__WEBPACK_IMPORTED_MODULE_1__.DateTime.fromJSDate(new Date(createdAt)).setZone('Europe/London').toFormat('HH:mm:ss a, dd LLLL yyyy');
|
|
1072
1209
|
string += `[${date}] ${author}: \n${text}\n\n`;
|
|
1073
1210
|
}
|
|
1074
1211
|
string = string.replace(/<a\b[^>]*>/i, '').replace(/<\/a>/i, '');
|
|
@@ -1092,17 +1229,23 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1092
1229
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1093
1230
|
/* 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");
|
|
1094
1231
|
/* 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__);
|
|
1095
|
-
/* harmony import */ var
|
|
1232
|
+
/* harmony import */ var _lib_message_notification_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/message-notification.js */ "./src/client/lib/message-notification.js");
|
|
1233
|
+
/* harmony import */ var _reducer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./reducer.js */ "./src/client/store/reducer.js");
|
|
1234
|
+
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants.js */ "./src/client/store/constants.js");
|
|
1235
|
+
|
|
1236
|
+
|
|
1096
1237
|
|
|
1097
1238
|
|
|
1098
1239
|
|
|
1099
|
-
const AppContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(
|
|
1240
|
+
const AppContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(_reducer_js__WEBPACK_IMPORTED_MODULE_3__.initialState);
|
|
1100
1241
|
const AppProvider = ({
|
|
1101
1242
|
sdk,
|
|
1102
1243
|
availability,
|
|
1244
|
+
options,
|
|
1103
1245
|
children
|
|
1104
1246
|
}) => {
|
|
1105
|
-
const [state, dispatch] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(
|
|
1247
|
+
const [state, dispatch] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(_reducer_js__WEBPACK_IMPORTED_MODULE_3__.reducer, _reducer_js__WEBPACK_IMPORTED_MODULE_3__.initialState);
|
|
1248
|
+
const playSound = (0,_lib_message_notification_js__WEBPACK_IMPORTED_MODULE_2__.messageNotification)(options.audioUrl);
|
|
1106
1249
|
|
|
1107
1250
|
/**
|
|
1108
1251
|
* SDK event handlers
|
|
@@ -1156,6 +1299,10 @@ const AppProvider = ({
|
|
|
1156
1299
|
type: 'SET_UNSEEN_COUNT',
|
|
1157
1300
|
payload: e.detail.data.case.customerStatistics.unseenMessagesCount
|
|
1158
1301
|
});
|
|
1302
|
+
const isAudioOn = JSON.parse(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.SETTINGS_STORAGE_KEY)).audio;
|
|
1303
|
+
if (isAudioOn && e.detail.data.message.direction === 'outbound') {
|
|
1304
|
+
playSound();
|
|
1305
|
+
}
|
|
1159
1306
|
};
|
|
1160
1307
|
const onContactStatusChanged = e => {
|
|
1161
1308
|
dispatch({
|
|
@@ -1180,8 +1327,9 @@ const AppProvider = ({
|
|
|
1180
1327
|
type: 'SET_AVAILABILITY',
|
|
1181
1328
|
payload: availability
|
|
1182
1329
|
});
|
|
1183
|
-
setCustomerId(window.localStorage.getItem(
|
|
1184
|
-
setThreadId(window.localStorage.getItem(
|
|
1330
|
+
setCustomerId(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.CUSTOMER_ID_STORAGE_KEY));
|
|
1331
|
+
setThreadId(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.THREAD_ID_STORAGE_KEY));
|
|
1332
|
+
setSettings(JSON.parse(window.localStorage.getItem(_constants_js__WEBPACK_IMPORTED_MODULE_4__.SETTINGS_STORAGE_KEY)) || state.settings);
|
|
1185
1333
|
if (window.location.hash === '#webchat') {
|
|
1186
1334
|
setChatVisibility(true);
|
|
1187
1335
|
}
|
|
@@ -1223,6 +1371,12 @@ const AppProvider = ({
|
|
|
1223
1371
|
payload: messages
|
|
1224
1372
|
});
|
|
1225
1373
|
};
|
|
1374
|
+
const setSettings = data => {
|
|
1375
|
+
dispatch({
|
|
1376
|
+
type: 'SET_SETTINGS',
|
|
1377
|
+
payload: data
|
|
1378
|
+
});
|
|
1379
|
+
};
|
|
1226
1380
|
const setUnseenCount = unseenCount => {
|
|
1227
1381
|
dispatch({
|
|
1228
1382
|
type: 'SET_UNSEEN_COUNT',
|
|
@@ -1236,6 +1390,7 @@ const AppProvider = ({
|
|
|
1236
1390
|
const store = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({
|
|
1237
1391
|
...state,
|
|
1238
1392
|
sdk,
|
|
1393
|
+
setSettings,
|
|
1239
1394
|
setCustomerId,
|
|
1240
1395
|
setThreadId,
|
|
1241
1396
|
setThread,
|
|
@@ -1267,14 +1422,25 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1267
1422
|
/* harmony export */ actionsMap: () => (/* binding */ actionsMap)
|
|
1268
1423
|
/* harmony export */ });
|
|
1269
1424
|
/* harmony import */ var _lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/transform-messages */ "./src/client/lib/transform-messages.js");
|
|
1270
|
-
/* harmony import */ var
|
|
1425
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/client/store/constants.js");
|
|
1271
1426
|
|
|
1272
1427
|
|
|
1428
|
+
const setSettings = (state, payload) => {
|
|
1429
|
+
if (payload) {
|
|
1430
|
+
window.localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_1__.SETTINGS_STORAGE_KEY, JSON.stringify(payload));
|
|
1431
|
+
} else {
|
|
1432
|
+
window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_1__.SETTINGS_STORAGE_KEY);
|
|
1433
|
+
}
|
|
1434
|
+
return {
|
|
1435
|
+
...state,
|
|
1436
|
+
settings: payload
|
|
1437
|
+
};
|
|
1438
|
+
};
|
|
1273
1439
|
const setCustomerId = (state, payload) => {
|
|
1274
1440
|
if (payload) {
|
|
1275
|
-
window.localStorage.setItem(
|
|
1441
|
+
window.localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_1__.CUSTOMER_ID_STORAGE_KEY, payload);
|
|
1276
1442
|
} else {
|
|
1277
|
-
window.localStorage.removeItem(
|
|
1443
|
+
window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_1__.CUSTOMER_ID_STORAGE_KEY);
|
|
1278
1444
|
}
|
|
1279
1445
|
return {
|
|
1280
1446
|
...state,
|
|
@@ -1283,9 +1449,9 @@ const setCustomerId = (state, payload) => {
|
|
|
1283
1449
|
};
|
|
1284
1450
|
const setThreadId = (state, payload) => {
|
|
1285
1451
|
if (payload) {
|
|
1286
|
-
window.localStorage.setItem(
|
|
1452
|
+
window.localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_1__.THREAD_ID_STORAGE_KEY, payload);
|
|
1287
1453
|
} else {
|
|
1288
|
-
window.localStorage.removeItem(
|
|
1454
|
+
window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_1__.THREAD_ID_STORAGE_KEY);
|
|
1289
1455
|
}
|
|
1290
1456
|
return {
|
|
1291
1457
|
...state,
|
|
@@ -1349,6 +1515,7 @@ const setUnseenCount = (state, payload) => {
|
|
|
1349
1515
|
const actionsMap = {
|
|
1350
1516
|
SET_CHAT_VISIBILITY: setChatVisibility,
|
|
1351
1517
|
SET_AVAILABILITY: setAvailability,
|
|
1518
|
+
SET_SETTINGS: setSettings,
|
|
1352
1519
|
SET_CUSTOMER_ID: setCustomerId,
|
|
1353
1520
|
SET_THREAD_ID: setThreadId,
|
|
1354
1521
|
SET_THREAD: setThread,
|
|
@@ -1362,6 +1529,24 @@ const actionsMap = {
|
|
|
1362
1529
|
|
|
1363
1530
|
/***/ }),
|
|
1364
1531
|
|
|
1532
|
+
/***/ "./src/client/store/constants.js":
|
|
1533
|
+
/*!***************************************!*\
|
|
1534
|
+
!*** ./src/client/store/constants.js ***!
|
|
1535
|
+
\***************************************/
|
|
1536
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1537
|
+
|
|
1538
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1539
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1540
|
+
/* harmony export */ CUSTOMER_ID_STORAGE_KEY: () => (/* binding */ CUSTOMER_ID_STORAGE_KEY),
|
|
1541
|
+
/* harmony export */ SETTINGS_STORAGE_KEY: () => (/* binding */ SETTINGS_STORAGE_KEY),
|
|
1542
|
+
/* harmony export */ THREAD_ID_STORAGE_KEY: () => (/* binding */ THREAD_ID_STORAGE_KEY)
|
|
1543
|
+
/* harmony export */ });
|
|
1544
|
+
const SETTINGS_STORAGE_KEY = 'webchat_settings';
|
|
1545
|
+
const CUSTOMER_ID_STORAGE_KEY = 'webchat_customer_id';
|
|
1546
|
+
const THREAD_ID_STORAGE_KEY = 'webchat_thread_id';
|
|
1547
|
+
|
|
1548
|
+
/***/ }),
|
|
1549
|
+
|
|
1365
1550
|
/***/ "./src/client/store/reducer.js":
|
|
1366
1551
|
/*!*************************************!*\
|
|
1367
1552
|
!*** ./src/client/store/reducer.js ***!
|
|
@@ -1370,15 +1555,11 @@ const actionsMap = {
|
|
|
1370
1555
|
|
|
1371
1556
|
__webpack_require__.r(__webpack_exports__);
|
|
1372
1557
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1373
|
-
/* harmony export */ CUSTOMER_ID_STORAGE_KEY: () => (/* binding */ CUSTOMER_ID_STORAGE_KEY),
|
|
1374
|
-
/* harmony export */ THREAD_ID_STORAGE_KEY: () => (/* binding */ THREAD_ID_STORAGE_KEY),
|
|
1375
1558
|
/* harmony export */ initialState: () => (/* binding */ initialState),
|
|
1376
1559
|
/* harmony export */ reducer: () => (/* binding */ reducer)
|
|
1377
1560
|
/* harmony export */ });
|
|
1378
1561
|
/* harmony import */ var _actions_map__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./actions-map */ "./src/client/store/actions-map.js");
|
|
1379
1562
|
|
|
1380
|
-
const CUSTOMER_ID_STORAGE_KEY = 'webchat_customer_id';
|
|
1381
|
-
const THREAD_ID_STORAGE_KEY = 'webchat_thread_id';
|
|
1382
1563
|
const initialState = {
|
|
1383
1564
|
availability: null,
|
|
1384
1565
|
customerId: null,
|
|
@@ -1389,7 +1570,11 @@ const initialState = {
|
|
|
1389
1570
|
agent: null,
|
|
1390
1571
|
agentStatus: null,
|
|
1391
1572
|
isAgentTyping: false,
|
|
1392
|
-
isChatOpen: false
|
|
1573
|
+
isChatOpen: false,
|
|
1574
|
+
settings: {
|
|
1575
|
+
audio: true,
|
|
1576
|
+
scroll: true
|
|
1577
|
+
}
|
|
1393
1578
|
};
|
|
1394
1579
|
const reducer = (state, action) => {
|
|
1395
1580
|
const {
|
|
@@ -1521,16 +1706,6 @@ module.exports = require("react-dom/client");
|
|
|
1521
1706
|
|
|
1522
1707
|
/***/ }),
|
|
1523
1708
|
|
|
1524
|
-
/***/ "sanitize-html":
|
|
1525
|
-
/*!********************************!*\
|
|
1526
|
-
!*** external "sanitize-html" ***!
|
|
1527
|
-
\********************************/
|
|
1528
|
-
/***/ ((module) => {
|
|
1529
|
-
|
|
1530
|
-
module.exports = require("sanitize-html");
|
|
1531
|
-
|
|
1532
|
-
/***/ }),
|
|
1533
|
-
|
|
1534
1709
|
/***/ "uuid":
|
|
1535
1710
|
/*!***********************!*\
|
|
1536
1711
|
!*** external "uuid" ***!
|
|
@@ -1628,7 +1803,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1628
1803
|
/* harmony import */ var _components_availability_availability_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/availability/availability.jsx */ "./src/client/components/availability/availability.jsx");
|
|
1629
1804
|
/* harmony import */ var _lib_check_availability__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/check-availability */ "./src/client/lib/check-availability.js");
|
|
1630
1805
|
/* harmony import */ var _store_AppProvider_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./store/AppProvider.jsx */ "./src/client/store/AppProvider.jsx");
|
|
1631
|
-
/* harmony import */ var
|
|
1806
|
+
/* harmony import */ var _store_constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./store/constants.js */ "./src/client/store/constants.js");
|
|
1632
1807
|
|
|
1633
1808
|
|
|
1634
1809
|
|
|
@@ -1640,7 +1815,7 @@ async function init(container, options) {
|
|
|
1640
1815
|
const sdk = new _nice_devone_nice_cxone_chat_web_sdk__WEBPACK_IMPORTED_MODULE_2__.ChatSdk({
|
|
1641
1816
|
brandId: options.brandId,
|
|
1642
1817
|
channelId: options.channelId,
|
|
1643
|
-
customerId: window.localStorage.getItem(
|
|
1818
|
+
customerId: window.localStorage.getItem(_store_constants_js__WEBPACK_IMPORTED_MODULE_6__.CUSTOMER_ID_STORAGE_KEY) || '',
|
|
1644
1819
|
environment: options.environment
|
|
1645
1820
|
});
|
|
1646
1821
|
const root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_1__.createRoot)(container);
|
|
@@ -1653,10 +1828,9 @@ async function init(container, options) {
|
|
|
1653
1828
|
}
|
|
1654
1829
|
root.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_store_AppProvider_jsx__WEBPACK_IMPORTED_MODULE_5__.AppProvider, {
|
|
1655
1830
|
sdk: sdk,
|
|
1656
|
-
availability: availability
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
})));
|
|
1831
|
+
availability: availability,
|
|
1832
|
+
options: options
|
|
1833
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_availability_availability_jsx__WEBPACK_IMPORTED_MODULE_3__.Availability, null)));
|
|
1660
1834
|
}
|
|
1661
1835
|
})();
|
|
1662
1836
|
|