@defra/flood-webchat 0.0.1-beta.23 → 0.0.1-beta.25
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 +49 -220
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
- package/src/client/components/chat/chat.jsx +4 -4
- package/src/client/components/panel/panel-header.jsx +3 -3
- package/src/client/components/panel/panel.jsx +12 -18
- package/src/client/components/screens/end-chat.jsx +2 -2
- package/src/client/components/screens/feedback.jsx +4 -130
- package/src/client/components/screens/pre-chat.jsx +3 -7
- package/src/client/components/screens/request-chat.jsx +18 -12
- package/src/client/store/AppProvider.jsx +0 -1
- package/src/client/components/screens/end-feedback.jsx +0 -18
|
@@ -12,7 +12,6 @@ import { Feedback } from '../screens/feedback.jsx'
|
|
|
12
12
|
import { useApp } from '../../store/useApp.js'
|
|
13
13
|
import { useChatSdk } from '../../store/useChatSdk.js'
|
|
14
14
|
import { useFocusedElements } from '../../hooks/useFocusedElements.js'
|
|
15
|
-
import { EndFeedback } from '../screens/end-feedback.jsx'
|
|
16
15
|
|
|
17
16
|
export function Panel () {
|
|
18
17
|
const { sdk, availability, thread, threadId, setThread, setThreadId, setChatVisibility, setMessages, setUnseenCount } = useApp()
|
|
@@ -22,6 +21,16 @@ export function Panel () {
|
|
|
22
21
|
|
|
23
22
|
useFocusedElements(screen)
|
|
24
23
|
|
|
24
|
+
const onEscapeKey = useCallback(e => {
|
|
25
|
+
if (e.key === 'Escape' || e.key === 'Esc') {
|
|
26
|
+
if (threadId) {
|
|
27
|
+
thread?.lastMessageSeen()
|
|
28
|
+
setUnseenCount(0)
|
|
29
|
+
}
|
|
30
|
+
setChatVisibility(false)
|
|
31
|
+
}
|
|
32
|
+
}, [thread, threadId, setUnseenCount, setChatVisibility])
|
|
33
|
+
|
|
25
34
|
/**
|
|
26
35
|
* Initializes the eventListener for pressing the escape key
|
|
27
36
|
*/
|
|
@@ -31,7 +40,7 @@ export function Panel () {
|
|
|
31
40
|
return () => {
|
|
32
41
|
document.removeEventListener('keydown', escapeKeyEvent)
|
|
33
42
|
}
|
|
34
|
-
}, [])
|
|
43
|
+
}, [onEscapeKey, setChatVisibility])
|
|
35
44
|
|
|
36
45
|
/**
|
|
37
46
|
* Recovers the thread if there is a threadId but no thread loaded in to state
|
|
@@ -64,16 +73,6 @@ export function Panel () {
|
|
|
64
73
|
}
|
|
65
74
|
}, [thread, threadId])
|
|
66
75
|
|
|
67
|
-
const onEscapeKey = useCallback(e => {
|
|
68
|
-
if (e.key === 'Escape' || e.key === 'Esc') {
|
|
69
|
-
if (thread) {
|
|
70
|
-
thread.lastMessageSeen()
|
|
71
|
-
setUnseenCount(0)
|
|
72
|
-
}
|
|
73
|
-
setChatVisibility(false)
|
|
74
|
-
}
|
|
75
|
-
}, [])
|
|
76
|
-
|
|
77
76
|
const handleScreenChange = newScreen => e => {
|
|
78
77
|
e.preventDefault()
|
|
79
78
|
setScreen(newScreen)
|
|
@@ -85,8 +84,6 @@ export function Panel () {
|
|
|
85
84
|
const goToEndChatScreen = handleScreenChange(3)
|
|
86
85
|
const goToFeedbackScreen = handleScreenChange(4)
|
|
87
86
|
const goToSettingsScreen = handleScreenChange(5)
|
|
88
|
-
const goToEndFeedbackScreen = handleScreenChange(6)
|
|
89
|
-
|
|
90
87
|
let ScreenComponent
|
|
91
88
|
|
|
92
89
|
switch (screen) {
|
|
@@ -103,14 +100,11 @@ export function Panel () {
|
|
|
103
100
|
ScreenComponent = <EndChat onChatScreen={goToChatScreen} onEndChatConfirm={goToFeedbackScreen} />
|
|
104
101
|
break
|
|
105
102
|
case 4:
|
|
106
|
-
ScreenComponent = <Feedback onCancel={() => setChatVisibility(false)}
|
|
103
|
+
ScreenComponent = <Feedback onCancel={() => setChatVisibility(false)} />
|
|
107
104
|
break
|
|
108
105
|
case 5:
|
|
109
106
|
ScreenComponent = <Settings onCancel={goToChatScreen} />
|
|
110
107
|
break
|
|
111
|
-
case 6:
|
|
112
|
-
ScreenComponent = <EndFeedback onClose={() => setChatVisibility(false)} />
|
|
113
|
-
break
|
|
114
108
|
default:
|
|
115
109
|
ScreenComponent = <PreChat onContinue={goToRequestChatScreen} />
|
|
116
110
|
}
|
|
@@ -28,8 +28,8 @@ export function EndChat ({ onChatScreen, onEndChatConfirm }) {
|
|
|
28
28
|
<div className='wc-body'>
|
|
29
29
|
<h3 className='govuk-heading-s' aria-live='polite'>Are you sure you want to end the chat?</h3>
|
|
30
30
|
<div className='govuk-button-group'>
|
|
31
|
-
<a href='#' className='govuk-button govuk-!-font-size-16' data-module='govuk-button' id='confirmEndChat' onClick={confirmEndChat}>Yes, end chat</a>
|
|
32
|
-
<a href='#' className='govuk-link govuk-!-font-size-16' onClick={onChatScreen}>No, resume chat</a>
|
|
31
|
+
<a href='#endChat' className='govuk-button govuk-!-font-size-16' data-module='govuk-button' id='confirmEndChat' onClick={confirmEndChat}>Yes, end chat</a>
|
|
32
|
+
<a href='#resumeChat' className='govuk-link govuk-!-font-size-16' onClick={onChatScreen}>No, resume chat</a>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
</>
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
3
|
|
|
4
|
-
export function Feedback ({
|
|
5
|
-
const
|
|
6
|
-
e.preventDefault()
|
|
7
|
-
|
|
8
|
-
onConfirmSubmit(e)
|
|
4
|
+
export function Feedback ({ onCancel }) {
|
|
5
|
+
const feedbackCancel = async e => {
|
|
9
6
|
onCancel(e)
|
|
10
7
|
}
|
|
11
8
|
|
|
@@ -16,132 +13,9 @@ export function Feedback ({ onConfirmSubmit, onCancel }) {
|
|
|
16
13
|
<div className='wc-body'>
|
|
17
14
|
<h3 id='wc-subtitle' className='govuk-heading-s'>Give Feedback on Floodline webchat</h3>
|
|
18
15
|
<p>Please note we’re unable to respond to feedback.</p>
|
|
19
|
-
<
|
|
20
|
-
<fieldset className='govuk-fieldset govuk-!-margin-bottom-4'>
|
|
21
|
-
<legend className='govuk-fieldset-heading govuk-fieldset__legend'>
|
|
22
|
-
Overall, how did you feel about webchat?
|
|
23
|
-
</legend>
|
|
24
|
-
<div className='govuk-radios govuk-radios--small' data-module='govuk-radios'>
|
|
25
|
-
<div className='govuk-radios__item'>
|
|
26
|
-
<input
|
|
27
|
-
id='very-satisfied'
|
|
28
|
-
name='satisfaction'
|
|
29
|
-
type='radio'
|
|
30
|
-
className='govuk-radios__input'
|
|
31
|
-
value='Very satisfied'
|
|
32
|
-
/>
|
|
33
|
-
|
|
34
|
-
<label className='govuk-label govuk-radios__label' for='very-satisfied'>Very satisfied</label>
|
|
35
|
-
</div>
|
|
36
|
-
<div className='govuk-radios__item'>
|
|
37
|
-
<input
|
|
38
|
-
id='satisfied'
|
|
39
|
-
name='satisfaction'
|
|
40
|
-
type='radio'
|
|
41
|
-
className='govuk-radios__input'
|
|
42
|
-
value='Satisfied'
|
|
43
|
-
/>
|
|
44
|
-
|
|
45
|
-
<label className='govuk-label govuk-radios__label' for='satisfied'>Satisfied</label>
|
|
46
|
-
</div>
|
|
47
|
-
<div className='govuk-radios__item'>
|
|
48
|
-
<input
|
|
49
|
-
id='no-opinion'
|
|
50
|
-
name='satisfaction'
|
|
51
|
-
type='radio'
|
|
52
|
-
className='govuk-radios__input'
|
|
53
|
-
value='No opinion'
|
|
54
|
-
/>
|
|
55
|
-
|
|
56
|
-
<label className='govuk-label govuk-radios__label' for='no-opinion'>No Opinion</label>
|
|
57
|
-
</div>
|
|
58
|
-
<div className='govuk-radios__item'>
|
|
59
|
-
<input
|
|
60
|
-
id='dissatisfied'
|
|
61
|
-
name='satisfaction'
|
|
62
|
-
type='radio'
|
|
63
|
-
className='govuk-radios__input'
|
|
64
|
-
value='Dissatisfied'
|
|
65
|
-
/>
|
|
66
|
-
|
|
67
|
-
<label className='govuk-label govuk-radios__label' for='dissatisfied'>Dissatisfied</label>
|
|
68
|
-
</div>
|
|
69
|
-
<div className='govuk-radios__item'>
|
|
70
|
-
<input
|
|
71
|
-
id='very-dissatisfied'
|
|
72
|
-
name='satisfaction'
|
|
73
|
-
type='radio'
|
|
74
|
-
className='govuk-radios__input'
|
|
75
|
-
value='Very dissatisfied'
|
|
76
|
-
/>
|
|
77
|
-
|
|
78
|
-
<label className='govuk-label govuk-radios__label' for='very-dissatisfied'>Very dissatisfied</label>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
</fieldset>
|
|
82
|
-
|
|
83
|
-
<fieldset className='govuk-fieldset govuk-!-margin-bottom-4'>
|
|
84
|
-
<legend className='govuk-fieldset__legend'>
|
|
85
|
-
Did the adviser answer your question?
|
|
86
|
-
</legend>
|
|
87
|
-
<div className='govuk-radios govuk-radios--small' data-module='govuk-radios'>
|
|
88
|
-
<div className='govuk-radios__item'>
|
|
89
|
-
<input
|
|
90
|
-
id='answer-yes'
|
|
91
|
-
name='answer'
|
|
92
|
-
type='radio'
|
|
93
|
-
className='govuk-radios__input'
|
|
94
|
-
value='Yes'
|
|
95
|
-
/>
|
|
96
|
-
|
|
97
|
-
<label className='govuk-label govuk-radios__label' for='answer-yes'>Yes</label>
|
|
98
|
-
</div>
|
|
99
|
-
<div className='govuk-radios__item'>
|
|
100
|
-
<input
|
|
101
|
-
id='answer-no'
|
|
102
|
-
name='answer'
|
|
103
|
-
type='radio'
|
|
104
|
-
className='govuk-radios__input'
|
|
105
|
-
value='No'
|
|
106
|
-
/>
|
|
107
|
-
|
|
108
|
-
<label className='govuk-label govuk-radios__label' for='answer-no'>No</label>
|
|
109
|
-
</div>
|
|
110
|
-
<div className='govuk-radios__item'>
|
|
111
|
-
<input
|
|
112
|
-
id='answer-partly'
|
|
113
|
-
name='answer'
|
|
114
|
-
type='radio'
|
|
115
|
-
className='govuk-radios__input'
|
|
116
|
-
value='Partly'
|
|
117
|
-
/>
|
|
118
|
-
|
|
119
|
-
<label className='govuk-label govuk-radios__label' for='answer-partly'>Partly</label>
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
</fieldset>
|
|
123
|
-
|
|
124
|
-
</div>
|
|
125
|
-
<div className='govuk-form-group'>
|
|
126
|
-
<label className='govuk-label' for='improvements'>
|
|
127
|
-
How can we improve webchat? (optional)
|
|
128
|
-
</label>
|
|
129
|
-
<textarea className='govuk-textarea govuk-!-margin-bottom-4' id='improvements' name='improvements' rows='5' />
|
|
130
|
-
</div>
|
|
131
|
-
|
|
132
|
-
<div className='govuk-form-group'>
|
|
133
|
-
<label className='wc-fieldset-heading govuk-label' for='research'>
|
|
134
|
-
Tell us your email address if you want to take part in user research (optional)
|
|
135
|
-
</label>
|
|
136
|
-
<div id='research-hint' class='wc-hint govuk-hint'>
|
|
137
|
-
We will not share your email address or use it for anything else. We’ll delete it after 2 years.
|
|
138
|
-
</div>
|
|
139
|
-
<input className='govuk-input govuk-!-margin-bottom-4' id='research' name='research' aria-describedby='research-hint' type='text' />
|
|
140
|
-
</div>
|
|
141
|
-
|
|
16
|
+
<a className='govuk-link' href='#' target='_blank' rel='noreferrer'>Feedback Link</a>
|
|
142
17
|
<div className='govuk-button-group'>
|
|
143
|
-
<a id='feedback-
|
|
144
|
-
<a id='feedback-cancel' href='#' className='govuk-link govuk-!-font-size-16' data-module='govuk-button' onClick={onCancel}>Cancel</a>
|
|
18
|
+
<a id='feedback-cancel' href='#' data-module='govuk-button' role='button' onClick={feedbackCancel}>Close</a>
|
|
145
19
|
</div>
|
|
146
20
|
</div>
|
|
147
21
|
</>
|
|
@@ -18,21 +18,17 @@ export function PreChat ({ onContinue }) {
|
|
|
18
18
|
</ul>
|
|
19
19
|
|
|
20
20
|
<p className='govuk-body-s'>
|
|
21
|
-
|
|
22
|
-
'There are other ways to '
|
|
23
|
-
}
|
|
21
|
+
There are other ways to
|
|
24
22
|
<a className='govuk-link' href='https://www.gov.uk/sign-up-for-flood-warnings' target='_blank' rel='noreferrer'>
|
|
25
23
|
sign up for flood warnings
|
|
26
24
|
</a>
|
|
27
|
-
|
|
28
|
-
' and '
|
|
29
|
-
}
|
|
25
|
+
and
|
|
30
26
|
<a className='govuk-link' href='https://www.fws.environment-agency.gov.uk/app/olr/login' target='_blank' rel='noreferrer'>
|
|
31
27
|
manage your flood warnings account
|
|
32
28
|
</a>.
|
|
33
29
|
</p>
|
|
34
30
|
<p className='govuk-body-s'>
|
|
35
|
-
|
|
31
|
+
Do not use webchat to
|
|
36
32
|
<a
|
|
37
33
|
className='govuk-link'
|
|
38
34
|
href='https://www.gov.uk/report-flood-cause'
|
|
@@ -12,7 +12,6 @@ const QUESTION_MAX_LENGTH = 500
|
|
|
12
12
|
export function RequestChat ({ onPreChatScreen }) {
|
|
13
13
|
const { sdk, setCustomerId, setThreadId, setThread } = useApp()
|
|
14
14
|
const { fetchCustomerId, fetchThread } = useChatSdk(sdk)
|
|
15
|
-
|
|
16
15
|
const [errors, setErrors] = useState({})
|
|
17
16
|
const [questionLength, setQuestionLength] = useState(0)
|
|
18
17
|
const [isButtonDisabled, setButtonDisabled] = useState(false)
|
|
@@ -20,6 +19,16 @@ export function RequestChat ({ onPreChatScreen }) {
|
|
|
20
19
|
const nameRef = useRef()
|
|
21
20
|
const questionRef = useRef()
|
|
22
21
|
|
|
22
|
+
const isQuestionLengthValid = QUESTION_MAX_LENGTH >= questionLength
|
|
23
|
+
const questionLengthRemaining = QUESTION_MAX_LENGTH - questionLength
|
|
24
|
+
const questionLengthExceeded = questionLength - QUESTION_MAX_LENGTH
|
|
25
|
+
|
|
26
|
+
let questionHint = `You have ${questionLengthRemaining} characters remaining`
|
|
27
|
+
|
|
28
|
+
if (!isQuestionLengthValid) {
|
|
29
|
+
questionHint = `You have ${questionLengthExceeded} characters too many`
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
useEffect(() => {
|
|
24
33
|
if (Object.keys(errors).length) {
|
|
25
34
|
document.querySelector('.govuk-error-summary')?.focus()
|
|
@@ -30,6 +39,8 @@ export function RequestChat ({ onPreChatScreen }) {
|
|
|
30
39
|
setQuestionLength(e.target.value.length)
|
|
31
40
|
}
|
|
32
41
|
|
|
42
|
+
const buttonLabel = isButtonDisabled ? 'Requesting...' : 'Request Chat'
|
|
43
|
+
|
|
33
44
|
const onRequestChat = async e => {
|
|
34
45
|
e.preventDefault()
|
|
35
46
|
|
|
@@ -70,16 +81,6 @@ export function RequestChat ({ onPreChatScreen }) {
|
|
|
70
81
|
setErrors(errs)
|
|
71
82
|
}
|
|
72
83
|
|
|
73
|
-
const isQuestionLengthValid = QUESTION_MAX_LENGTH >= questionLength
|
|
74
|
-
const questionLengthRemaining = QUESTION_MAX_LENGTH - questionLength
|
|
75
|
-
const questionLengthExceeded = questionLength - QUESTION_MAX_LENGTH
|
|
76
|
-
|
|
77
|
-
let questionHint = `You have ${questionLengthRemaining} characters remaining`
|
|
78
|
-
|
|
79
|
-
if (!isQuestionLengthValid) {
|
|
80
|
-
questionHint = `You have ${questionLengthExceeded} characters too many`
|
|
81
|
-
}
|
|
82
|
-
|
|
83
84
|
return (
|
|
84
85
|
<>
|
|
85
86
|
<PanelHeader />
|
|
@@ -145,13 +146,18 @@ export function RequestChat ({ onPreChatScreen }) {
|
|
|
145
146
|
</div>
|
|
146
147
|
</div>
|
|
147
148
|
|
|
149
|
+
<div className='govuk-inset-text govuk-!-font-size-16'>
|
|
150
|
+
By selecting 'Request chat' you agree to the terms of our
|
|
151
|
+
<a href='https://check-for-flooding.service.gov.uk/privacy-notice' target='_blank' rel='noreferrer' className='govuk-link'>privacy notice</a>.
|
|
152
|
+
</div>
|
|
153
|
+
|
|
148
154
|
<button
|
|
149
155
|
className='govuk-button govuk-!-margin-top-1 govuk-!-font-size-16'
|
|
150
156
|
data-module='govuk-button'
|
|
151
157
|
onClick={onRequestChat}
|
|
152
158
|
disabled={isButtonDisabled}
|
|
153
159
|
>
|
|
154
|
-
{
|
|
160
|
+
{buttonLabel}
|
|
155
161
|
</button>
|
|
156
162
|
</form>
|
|
157
163
|
</div>
|
|
@@ -52,7 +52,6 @@ export const AppProvider = ({ sdk, availability, options, children }) => {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
55
|
-
sdk.onChatEvent('SetConsumerContactCustomFields', () => { console.log('Custom field set') })
|
|
56
55
|
sdk.onChatEvent(ChatEvent.LIVECHAT_RECOVERED, onLiveChatRecovered)
|
|
57
56
|
sdk.onChatEvent(ChatEvent.MESSAGE_CREATED, onMessageCreated)
|
|
58
57
|
sdk.onChatEvent(ChatEvent.AGENT_TYPING_STARTED, onAgentTypingStarted)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
|
-
|
|
4
|
-
export function EndFeedback ({ onClose }) {
|
|
5
|
-
return (
|
|
6
|
-
<>
|
|
7
|
-
<PanelHeader />
|
|
8
|
-
|
|
9
|
-
<div className='wc-body'>
|
|
10
|
-
<h3 id='wc-subtitle' class='govuk-heading-m'>Thank you for your feedback</h3>
|
|
11
|
-
<div>
|
|
12
|
-
<a href='#' role='button' draggable='false' data-module='govuk-button' data-wc-focus-visible data-wc-close-btn onClick={onClose}>Close window</a>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
</>
|
|
17
|
-
)
|
|
18
|
-
}
|