@defra/flood-webchat 0.0.1-beta.21 → 0.0.1-beta.22
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 +285 -16
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
- package/src/client/components/availability/availability.jsx +3 -3
- package/src/client/components/chat/chat.jsx +0 -1
- package/src/client/components/panel/panel-header.jsx +4 -2
- package/src/client/components/panel/panel.jsx +15 -1
- package/src/client/components/screens/end-chat.jsx +22 -2
- package/src/client/components/screens/end-feedback.jsx +18 -0
- package/src/client/components/screens/feedback.jsx +154 -0
- package/src/client/components/screens/request-chat.jsx +1 -0
- package/src/client/store/AppProvider.jsx +1 -0
|
@@ -7,10 +7,12 @@ import { Chat } from '../chat/chat.jsx'
|
|
|
7
7
|
import { Unavailable } from '../screens/unavailable.jsx'
|
|
8
8
|
import { EndChat } from '../screens/end-chat.jsx'
|
|
9
9
|
import { Settings } from '../screens/settings.jsx'
|
|
10
|
+
import { Feedback } from '../screens/feedback.jsx'
|
|
10
11
|
|
|
11
12
|
import { useApp } from '../../store/useApp.js'
|
|
12
13
|
import { useChatSdk } from '../../store/useChatSdk.js'
|
|
13
14
|
import { useFocusedElements } from '../../hooks/useFocusedElements.js'
|
|
15
|
+
import { EndFeedback } from '../screens/end-feedback.jsx'
|
|
14
16
|
|
|
15
17
|
export function Panel () {
|
|
16
18
|
const { sdk, availability, thread, threadId, setThread, setThreadId, setChatVisibility, setMessages, setUnseenCount } = useApp()
|
|
@@ -64,6 +66,10 @@ export function Panel () {
|
|
|
64
66
|
|
|
65
67
|
const onEscapeKey = useCallback(e => {
|
|
66
68
|
if (e.key === 'Escape' || e.key === 'Esc') {
|
|
69
|
+
if (thread) {
|
|
70
|
+
thread.lastMessageSeen()
|
|
71
|
+
setUnseenCount(0)
|
|
72
|
+
}
|
|
67
73
|
setChatVisibility(false)
|
|
68
74
|
}
|
|
69
75
|
}, [])
|
|
@@ -77,7 +83,9 @@ export function Panel () {
|
|
|
77
83
|
const goToRequestChatScreen = handleScreenChange(1)
|
|
78
84
|
const goToChatScreen = handleScreenChange(2)
|
|
79
85
|
const goToEndChatScreen = handleScreenChange(3)
|
|
86
|
+
const goToFeedbackScreen = handleScreenChange(4)
|
|
80
87
|
const goToSettingsScreen = handleScreenChange(5)
|
|
88
|
+
const goToEndFeedbackScreen = handleScreenChange(6)
|
|
81
89
|
|
|
82
90
|
let ScreenComponent
|
|
83
91
|
|
|
@@ -92,11 +100,17 @@ export function Panel () {
|
|
|
92
100
|
ScreenComponent = <Chat onSettingsScreen={goToSettingsScreen} onEndChatScreen={goToEndChatScreen} />
|
|
93
101
|
break
|
|
94
102
|
case 3:
|
|
95
|
-
ScreenComponent = <EndChat onChatScreen={goToChatScreen} />
|
|
103
|
+
ScreenComponent = <EndChat onChatScreen={goToChatScreen} onEndChatConfirm={goToFeedbackScreen} />
|
|
104
|
+
break
|
|
105
|
+
case 4:
|
|
106
|
+
ScreenComponent = <Feedback onCancel={() => setChatVisibility(false)} onConfirmSubmit={goToEndFeedbackScreen} />
|
|
96
107
|
break
|
|
97
108
|
case 5:
|
|
98
109
|
ScreenComponent = <Settings onCancel={goToChatScreen} />
|
|
99
110
|
break
|
|
111
|
+
case 6:
|
|
112
|
+
ScreenComponent = <EndFeedback onClose={() => setChatVisibility(false)} />
|
|
113
|
+
break
|
|
100
114
|
default:
|
|
101
115
|
ScreenComponent = <PreChat onContinue={goToRequestChatScreen} />
|
|
102
116
|
}
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
|
+
import { useApp } from '../../store/useApp.js'
|
|
4
|
+
|
|
5
|
+
export function EndChat ({ onChatScreen, onEndChatConfirm }) {
|
|
6
|
+
const { setCustomerId, setThreadId, setMessages, agentStatus, thread, setUnseenCount } = useApp()
|
|
7
|
+
|
|
8
|
+
const confirmEndChat = async e => {
|
|
9
|
+
e.preventDefault()
|
|
10
|
+
|
|
11
|
+
setThreadId()
|
|
12
|
+
setMessages([])
|
|
13
|
+
setCustomerId()
|
|
14
|
+
thread.lastMessageSeen()
|
|
15
|
+
setUnseenCount(0)
|
|
16
|
+
|
|
17
|
+
// End chat if still open
|
|
18
|
+
if (agentStatus !== 'closed') {
|
|
19
|
+
thread.endChat()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
onEndChatConfirm(e)
|
|
23
|
+
}
|
|
3
24
|
|
|
4
|
-
export function EndChat ({ onChatScreen }) {
|
|
5
25
|
return (
|
|
6
26
|
<>
|
|
7
27
|
<PanelHeader />
|
|
8
28
|
<div className='wc-body'>
|
|
9
29
|
<h3 className='govuk-heading-s' aria-live='polite'>Are you sure you want to end the chat?</h3>
|
|
10
30
|
<div className='govuk-button-group'>
|
|
11
|
-
<a href='#' className='govuk-button govuk-!-font-size-16' data-module='govuk-button'>Yes, end chat</a>
|
|
31
|
+
<a href='#' className='govuk-button govuk-!-font-size-16' data-module='govuk-button' id='confirmEndChat' onClick={confirmEndChat}>Yes, end chat</a>
|
|
12
32
|
<a href='#' className='govuk-link govuk-!-font-size-16' onClick={onChatScreen}>No, resume chat</a>
|
|
13
33
|
</div>
|
|
14
34
|
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
|
+
|
|
4
|
+
export function Feedback ({ onCancel, onConfirmSubmit }) {
|
|
5
|
+
const feedbackSubmit = async e => {
|
|
6
|
+
e.preventDefault()
|
|
7
|
+
|
|
8
|
+
onConfirmSubmit(e)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const onCancelFeedback = (e) => {
|
|
12
|
+
e.preventDefault()
|
|
13
|
+
|
|
14
|
+
onCancel()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<PanelHeader />
|
|
20
|
+
|
|
21
|
+
<div className='wc-body'>
|
|
22
|
+
<h3 id='wc-subtitle' className='govuk-heading-s'>Give Feedback on Floodline webchat</h3>
|
|
23
|
+
<p>Please note we’re unable to respond to feedback.</p>
|
|
24
|
+
<div className='govuk-form-group'>
|
|
25
|
+
<fieldset className='govuk-fieldset govuk-!-margin-bottom-4'>
|
|
26
|
+
<legend className='govuk-fieldset-heading govuk-fieldset__legend'>
|
|
27
|
+
Overall, how did you feel about webchat?
|
|
28
|
+
</legend>
|
|
29
|
+
<div className='govuk-radios govuk-radios--small' data-module='govuk-radios'>
|
|
30
|
+
<div className='govuk-radios__item'>
|
|
31
|
+
<input
|
|
32
|
+
id='very-satisfied'
|
|
33
|
+
name='satisfaction'
|
|
34
|
+
type='radio'
|
|
35
|
+
className='govuk-radios__input'
|
|
36
|
+
value='Very satisfied'
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
<label className='govuk-label govuk-radios__label' for='very-satisfied'>Very satisfied</label>
|
|
40
|
+
</div>
|
|
41
|
+
<div className='govuk-radios__item'>
|
|
42
|
+
<input
|
|
43
|
+
id='satisfied'
|
|
44
|
+
name='satisfaction'
|
|
45
|
+
type='radio'
|
|
46
|
+
className='govuk-radios__input'
|
|
47
|
+
value='Satisfied'
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
<label className='govuk-label govuk-radios__label' for='satisfied'>Satisfied</label>
|
|
51
|
+
</div>
|
|
52
|
+
<div className='govuk-radios__item'>
|
|
53
|
+
<input
|
|
54
|
+
id='no-opinion'
|
|
55
|
+
name='satisfaction'
|
|
56
|
+
type='radio'
|
|
57
|
+
className='govuk-radios__input'
|
|
58
|
+
value='No opinion'
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
<label className='govuk-label govuk-radios__label' for='no-opinion'>No Opinion</label>
|
|
62
|
+
</div>
|
|
63
|
+
<div className='govuk-radios__item'>
|
|
64
|
+
<input
|
|
65
|
+
id='dissatisfied'
|
|
66
|
+
name='satisfaction'
|
|
67
|
+
type='radio'
|
|
68
|
+
className='govuk-radios__input'
|
|
69
|
+
value='Dissatisfied'
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
<label className='govuk-label govuk-radios__label' for='dissatisfied'>Dissatisfied</label>
|
|
73
|
+
</div>
|
|
74
|
+
<div className='govuk-radios__item'>
|
|
75
|
+
<input
|
|
76
|
+
id='very-dissatisfied'
|
|
77
|
+
name='satisfaction'
|
|
78
|
+
type='radio'
|
|
79
|
+
className='govuk-radios__input'
|
|
80
|
+
value='Very dissatisfied'
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<label className='govuk-label govuk-radios__label' for='very-dissatisfied'>Very dissatisfied</label>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</fieldset>
|
|
87
|
+
|
|
88
|
+
<fieldset className='govuk-fieldset govuk-!-margin-bottom-4'>
|
|
89
|
+
<legend className='govuk-fieldset__legend'>
|
|
90
|
+
Did the adviser answer your question?
|
|
91
|
+
</legend>
|
|
92
|
+
<div className='govuk-radios govuk-radios--small' data-module='govuk-radios'>
|
|
93
|
+
<div className='govuk-radios__item'>
|
|
94
|
+
<input
|
|
95
|
+
id='answer-yes'
|
|
96
|
+
name='answer'
|
|
97
|
+
type='radio'
|
|
98
|
+
className='govuk-radios__input'
|
|
99
|
+
value='Yes'
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<label className='govuk-label govuk-radios__label' for='answer-yes'>Yes</label>
|
|
103
|
+
</div>
|
|
104
|
+
<div className='govuk-radios__item'>
|
|
105
|
+
<input
|
|
106
|
+
id='answer-no'
|
|
107
|
+
name='answer'
|
|
108
|
+
type='radio'
|
|
109
|
+
className='govuk-radios__input'
|
|
110
|
+
value='No'
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
<label className='govuk-label govuk-radios__label' for='answer-no'>No</label>
|
|
114
|
+
</div>
|
|
115
|
+
<div className='govuk-radios__item'>
|
|
116
|
+
<input
|
|
117
|
+
id='answer-partly'
|
|
118
|
+
name='answer'
|
|
119
|
+
type='radio'
|
|
120
|
+
className='govuk-radios__input'
|
|
121
|
+
value='Partly'
|
|
122
|
+
/>
|
|
123
|
+
|
|
124
|
+
<label className='govuk-label govuk-radios__label' for='answer-partly'>Partly</label>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</fieldset>
|
|
128
|
+
|
|
129
|
+
</div>
|
|
130
|
+
<div className='govuk-form-group'>
|
|
131
|
+
<label className='govuk-label' for='improvements'>
|
|
132
|
+
How can we improve webchat? (optional)
|
|
133
|
+
</label>
|
|
134
|
+
<textarea className='govuk-textarea govuk-!-margin-bottom-4' id='improvements' name='improvements' rows='5' />
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div className='govuk-form-group'>
|
|
138
|
+
<label className='wc-fieldset-heading govuk-label' for='research'>
|
|
139
|
+
Tell us your email address if you want to take part in user research (optional)
|
|
140
|
+
</label>
|
|
141
|
+
<div id='research-hint' class='wc-hint govuk-hint'>
|
|
142
|
+
We will not share your email address or use it for anything else. We’ll delete it after 2 years.
|
|
143
|
+
</div>
|
|
144
|
+
<input className='govuk-input govuk-!-margin-bottom-4' id='research' name='research' aria-describedby='research-hint' type='text' />
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<div className='govuk-button-group'>
|
|
148
|
+
<a id='feedback-save' href='#' className='govuk-button govuk-!-font-size-16' data-module='govuk-button' onClick={feedbackSubmit}>Submit</a>
|
|
149
|
+
<a id='feedback-cancel' href='#' className='govuk-link govuk-!-font-size-16' data-module='govuk-button' onClick={onCancelFeedback}>Cancel</a>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
@@ -52,6 +52,7 @@ export const AppProvider = ({ sdk, availability, options, children }) => {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
55
|
+
sdk.onChatEvent('SetConsumerContactCustomFields', () => { console.log('Custom field set') })
|
|
55
56
|
sdk.onChatEvent(ChatEvent.LIVECHAT_RECOVERED, onLiveChatRecovered)
|
|
56
57
|
sdk.onChatEvent(ChatEvent.MESSAGE_CREATED, onMessageCreated)
|
|
57
58
|
sdk.onChatEvent(ChatEvent.AGENT_TYPING_STARTED, onAgentTypingStarted)
|