@defra/flood-webchat 0.0.1-beta.4 → 0.0.1-beta.40
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 +1939 -416
- package/dist/client.js.map +1 -1
- package/dist/server.js +181 -241
- package/dist/server.js.map +1 -1
- package/main.scss +10 -6
- package/package.json +5 -2
- package/src/client/components/availability/availability.jsx +64 -55
- package/src/client/components/availability/availability.scss +15 -33
- package/src/client/components/chat/chat.jsx +199 -0
- package/src/client/components/chat/chat.scss +233 -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 +54 -14
- package/src/client/components/panel/panel.jsx +113 -72
- package/src/client/components/panel/panel.scss +63 -22
- package/src/client/components/screens/end-chat.jsx +77 -0
- package/src/client/components/screens/feedback.jsx +65 -0
- package/src/client/components/screens/pre-chat.jsx +50 -30
- package/src/client/components/screens/request-chat.jsx +171 -4
- package/src/client/components/screens/settings.jsx +97 -0
- package/src/client/components/screens/unavailable.jsx +23 -0
- package/src/client/components/skip-link.jsx +42 -0
- package/src/client/hooks/useFocusedElements.js +80 -0
- package/src/client/hooks/useTextareaAutosize.js +13 -0
- package/src/client/index.jsx +15 -1
- package/src/client/lib/agent-status-headline.js +17 -0
- package/src/client/lib/check-availability.js +1 -0
- package/src/client/lib/history.js +13 -0
- package/src/client/lib/message-notification.js +36 -0
- package/src/client/lib/transform-messages.js +34 -0
- package/src/client/scss/_objects.scss +33 -0
- package/src/client/scss/_settings.scss +80 -0
- package/src/client/scss/_tools.scss +33 -0
- package/src/client/scss/_utilities.scss +25 -0
- package/src/client/store/AppProvider.jsx +179 -0
- package/src/client/store/actions-map.js +143 -0
- package/src/client/store/constants.js +3 -0
- package/src/client/store/reducer.js +31 -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 +16 -8
- package/src/client/lib/external-stores.js +0 -4
- package/src/client/lib/external-sync-store.js +0 -42
|
@@ -1,26 +1,51 @@
|
|
|
1
1
|
.wc-panel {
|
|
2
2
|
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
3
|
position: fixed;
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
flex-wrap: nowrap;
|
|
5
|
+
z-index: 999;
|
|
7
6
|
top: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
bottom: 0;
|
|
8
9
|
left: 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@include mq ($from: 'tablet') {
|
|
16
|
-
bottom: 0;
|
|
17
|
-
right: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
-webkit-overflow-scrolling: touch;
|
|
13
|
+
touch-action: pan-x pan-y;
|
|
14
|
+
background-color: #ffffff;
|
|
15
|
+
@include mq ($from: tablet) {
|
|
18
16
|
top: auto;
|
|
19
17
|
left: auto;
|
|
20
18
|
width: 400px;
|
|
21
19
|
height: 540px;
|
|
22
|
-
margin-bottom: 10px;
|
|
23
20
|
margin-right: 10px;
|
|
21
|
+
margin-bottom: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:focus {
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:focus.wc-focus-visible::after {
|
|
29
|
+
@include focus($glow: 5px, $strong: 2px, $background: 0, $inset: 0);
|
|
30
|
+
left: 4px;
|
|
31
|
+
right: 4px;
|
|
32
|
+
top: 4px;
|
|
33
|
+
bottom: 4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__inner {
|
|
37
|
+
position: relative;
|
|
38
|
+
flex: 0 0 100%;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-wrap: nowrap;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
background-color: transparent;
|
|
43
|
+
border: 0;
|
|
44
|
+
outline: 0;
|
|
45
|
+
@include mq ($from: tablet) {
|
|
46
|
+
border: 1px solid govuk-colour('black');
|
|
47
|
+
}
|
|
48
|
+
box-sizing: border-box;
|
|
24
49
|
}
|
|
25
50
|
}
|
|
26
51
|
|
|
@@ -29,43 +54,59 @@
|
|
|
29
54
|
flex-direction: row;
|
|
30
55
|
align-items: center;
|
|
31
56
|
background-color: govuk-colour('black');
|
|
57
|
+
border-bottom: 1px solid govuk-colour('black');
|
|
58
|
+
padding: 3px;
|
|
32
59
|
|
|
33
60
|
&__link {
|
|
34
61
|
margin: 0 govuk-spacing(2);
|
|
35
62
|
}
|
|
36
63
|
|
|
37
64
|
&__title {
|
|
38
|
-
|
|
65
|
+
@extend %govuk-heading-s;
|
|
66
|
+
font-size: 19px;
|
|
67
|
+
padding: 0 0 0 10px;
|
|
68
|
+
@include mq ($from: tablet) {
|
|
69
|
+
padding-left: 7px;
|
|
70
|
+
}
|
|
39
71
|
color: govuk-colour('white');
|
|
40
72
|
margin-bottom: 0;
|
|
41
73
|
}
|
|
42
74
|
|
|
43
|
-
&__close
|
|
75
|
+
&__close,
|
|
76
|
+
&__hide,
|
|
77
|
+
&__back {
|
|
44
78
|
display: flex;
|
|
45
79
|
justify-content: center;
|
|
46
80
|
color: govuk-colour('white');
|
|
47
81
|
background: none;
|
|
48
82
|
border: 0;
|
|
49
|
-
padding:
|
|
83
|
+
padding: 7px;
|
|
50
84
|
margin: 0 0 0 auto;
|
|
51
85
|
cursor: pointer;
|
|
52
86
|
|
|
53
87
|
&:focus {
|
|
54
|
-
|
|
88
|
+
outline: 3px solid $govuk-focus-colour;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&__back {
|
|
93
|
+
margin: 0;
|
|
94
|
+
display: flex;
|
|
95
|
+
|
|
96
|
+
@include mq ($from: 'tablet') {
|
|
97
|
+
display: none
|
|
55
98
|
}
|
|
56
99
|
}
|
|
57
100
|
}
|
|
58
101
|
|
|
59
102
|
.wc-body {
|
|
60
|
-
|
|
61
|
-
|
|
103
|
+
font-size: 16px;
|
|
62
104
|
flex: 1;
|
|
63
105
|
position: relative;
|
|
64
106
|
overflow-y: auto;
|
|
65
107
|
overscroll-behavior: contain;
|
|
66
|
-
border: 1px solid govuk-colour('black');
|
|
67
108
|
}
|
|
68
109
|
|
|
69
|
-
.wc-
|
|
70
|
-
|
|
110
|
+
.wc-content {
|
|
111
|
+
padding: 20px 15px;
|
|
71
112
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
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, threadId, setUnseenCount, isKeyboard } = useApp()
|
|
7
|
+
|
|
8
|
+
const confirmEndChat = async e => {
|
|
9
|
+
e.preventDefault()
|
|
10
|
+
|
|
11
|
+
window.localStorage.setItem('tmpThreadId', threadId)
|
|
12
|
+
setThreadId()
|
|
13
|
+
setMessages([])
|
|
14
|
+
setCustomerId()
|
|
15
|
+
thread.lastMessageSeen()
|
|
16
|
+
setUnseenCount(0)
|
|
17
|
+
|
|
18
|
+
// End chat if still open
|
|
19
|
+
if (agentStatus !== 'closed') {
|
|
20
|
+
thread.endChat()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
onEndChatConfirm(e)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (isKeyboard) {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
document.querySelector('#confirm-endchat').focus()
|
|
30
|
+
}, 10)
|
|
31
|
+
}
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
const handleKeyPress = e => {
|
|
35
|
+
if ((e.key === 'Enter' || e.key === ' ') && e.target.id === 'confirm-endchat') {
|
|
36
|
+
confirmEndChat(e)
|
|
37
|
+
}
|
|
38
|
+
if ((e.key === 'Enter' || e.key === ' ') && e.target.id === 'resume-chat') {
|
|
39
|
+
onChatScreen(e)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<PanelHeader />
|
|
46
|
+
<div className='wc-body'>
|
|
47
|
+
<div className='wc-content'>
|
|
48
|
+
<h3 className='wc-heading' aria-live='polite'>Are you sure you want to end the chat?</h3>
|
|
49
|
+
<div className='govuk-button-group'>
|
|
50
|
+
<a
|
|
51
|
+
id='confirm-endchat'
|
|
52
|
+
href='#endChat'
|
|
53
|
+
role='button'
|
|
54
|
+
className='wc-button govuk-button'
|
|
55
|
+
data-module='govuk-button'
|
|
56
|
+
onClick={confirmEndChat}
|
|
57
|
+
onKeyDown={handleKeyPress}
|
|
58
|
+
>
|
|
59
|
+
Yes, end chat
|
|
60
|
+
</a>
|
|
61
|
+
<a
|
|
62
|
+
id='resume-chat'
|
|
63
|
+
href='#resumeChat'
|
|
64
|
+
role='button'
|
|
65
|
+
className='wc-link govuk-link'
|
|
66
|
+
data-module='govuk-button'
|
|
67
|
+
onClick={onChatScreen}
|
|
68
|
+
onKeyDown={handleKeyPress}
|
|
69
|
+
>
|
|
70
|
+
No, resume chat
|
|
71
|
+
</a>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
|
+
export function Feedback ({ onCancel }) {
|
|
4
|
+
const feedbackSend = e => {
|
|
5
|
+
const tmpThreadId = window.localStorage.getItem('tmpThreadId')
|
|
6
|
+
window.location.href = `https://defragroup.eu.qualtrics.com/jfe/form/SV_8dgFSJcxxIfqx5Y?Id=${tmpThreadId}&Source=${window.location.href}`
|
|
7
|
+
window.localStorage.removeItem('tmpThreadId')
|
|
8
|
+
onCancel(e)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const feedbackClose = async e => {
|
|
12
|
+
window.localStorage.removeItem('tmpThreadId')
|
|
13
|
+
onCancel(e)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const handleKeyPress = e => {
|
|
17
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
18
|
+
if (e.target.id === 'feedback-close') {
|
|
19
|
+
feedbackClose(e)
|
|
20
|
+
}
|
|
21
|
+
if (e.target.id === 'feedback-send') {
|
|
22
|
+
feedbackSend(e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<PanelHeader />
|
|
30
|
+
|
|
31
|
+
<div className='wc-body'>
|
|
32
|
+
<div className='wc-content'>
|
|
33
|
+
<h3 id='wc-subtitle' className='wc-heading'>Give Feedback on Floodline webchat</h3>
|
|
34
|
+
<p>Please note we’re unable to respond to feedback.</p>
|
|
35
|
+
<p>
|
|
36
|
+
<a
|
|
37
|
+
id='feedback-send'
|
|
38
|
+
className='govuk-link'
|
|
39
|
+
href='#'
|
|
40
|
+
target='_blank'
|
|
41
|
+
rel='noreferrer'
|
|
42
|
+
onKeyDown={handleKeyPress}
|
|
43
|
+
onClick={feedbackSend}
|
|
44
|
+
>
|
|
45
|
+
Leave Feedback
|
|
46
|
+
</a>
|
|
47
|
+
</p>
|
|
48
|
+
<p>
|
|
49
|
+
<a
|
|
50
|
+
id='feedback-close'
|
|
51
|
+
className='wc-link govuk-link'
|
|
52
|
+
href='#'
|
|
53
|
+
data-module='govuk-button'
|
|
54
|
+
role='button'
|
|
55
|
+
onKeyDown={handleKeyPress}
|
|
56
|
+
onClick={feedbackClose}
|
|
57
|
+
>
|
|
58
|
+
Close
|
|
59
|
+
</a>
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
@@ -1,42 +1,62 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
2
3
|
|
|
3
|
-
export function PreChat ({
|
|
4
|
-
const onContinue = (e) => {
|
|
5
|
-
e.preventDefault()
|
|
6
|
-
setScreen(screen + 1)
|
|
7
|
-
}
|
|
8
|
-
|
|
4
|
+
export function PreChat ({ onContinue }) {
|
|
9
5
|
return (
|
|
10
6
|
<>
|
|
11
|
-
<
|
|
12
|
-
<p className='govuk-body-s'>Webchat lets you talk directly to a Floodline adviser.</p>
|
|
7
|
+
<PanelHeader />
|
|
13
8
|
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<li>advice on what to do before, during and after a flood</li>
|
|
19
|
-
</ul>
|
|
9
|
+
<div className='wc-body'>
|
|
10
|
+
<div className='wc-content'>
|
|
11
|
+
<h3 className='wc-heading' aria-live='polite'>What you can use webchat for</h3>
|
|
12
|
+
<p>Webchat lets you talk directly to a Floodline adviser.</p>
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
<p>You can use webchat to get:</p>
|
|
15
|
+
<ul className='wc-list'>
|
|
16
|
+
<li>current flood warnings and alerts in your area</li>
|
|
17
|
+
<li>information on the flood warning service</li>
|
|
18
|
+
<li>advice on what to do before, during and after a flood</li>
|
|
19
|
+
</ul>
|
|
20
|
+
<p>
|
|
21
|
+
There are other ways to
|
|
22
|
+
<a className='govuk-link' href='https://www.gov.uk/sign-up-for-flood-warnings' target='_blank' rel='noreferrer'>
|
|
23
|
+
sign up for flood warnings
|
|
24
|
+
</a>
|
|
25
|
+
and
|
|
26
|
+
<a className='govuk-link' href='https://www.fws.environment-agency.gov.uk/app/olr/login' target='_blank' rel='noreferrer'>
|
|
27
|
+
manage your flood warnings account
|
|
28
|
+
</a>.
|
|
29
|
+
</p>
|
|
30
|
+
<p>
|
|
31
|
+
Do not use webchat to
|
|
32
|
+
<a
|
|
33
|
+
className='govuk-link'
|
|
34
|
+
href='https://www.gov.uk/report-flood-cause'
|
|
35
|
+
target='_blank'
|
|
36
|
+
rel='noreferrer'
|
|
37
|
+
>
|
|
38
|
+
report a flood
|
|
39
|
+
</a>.
|
|
40
|
+
</p>
|
|
23
41
|
|
|
24
|
-
|
|
42
|
+
<button className='govuk-button wc-button govuk-!-margin-top-1' data-module='govuk-button' onClick={onContinue}>Continue</button>
|
|
25
43
|
|
|
26
|
-
|
|
44
|
+
<h3 className='wc-heading'>Other flood information</h3>
|
|
27
45
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
<p>Call Floodline for all other flood and flood warning information.</p>
|
|
47
|
+
<p>
|
|
48
|
+
<strong>Floodline helpline</strong>
|
|
49
|
+
<br />
|
|
50
|
+
Telephone: 0345 988 1188
|
|
51
|
+
<br />
|
|
52
|
+
Textphone: 0345 602 6340
|
|
53
|
+
<br />
|
|
54
|
+
Open 24 hours a day, 7 days a week
|
|
55
|
+
<br />
|
|
56
|
+
<a className='govuk-link' href='https://gov.uk/call-charges' target='_blank' rel='noreferrer'>Find out more about call charges</a>
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
40
60
|
</>
|
|
41
61
|
)
|
|
42
62
|
}
|
|
@@ -1,10 +1,177 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useRef, useState, useEffect } from 'react'
|
|
2
|
+
import * as uuid from 'uuid'
|
|
3
|
+
|
|
4
|
+
import { classnames } from '../../lib/classnames.js'
|
|
5
|
+
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
6
|
+
import { useApp } from '../../store/useApp.js'
|
|
7
|
+
import { useChatSdk } from '../../store/useChatSdk.js'
|
|
8
|
+
import { ErrorSummary } from '../errorSummary/error-summary.jsx'
|
|
9
|
+
|
|
10
|
+
const QUESTION_MAX_LENGTH = 500
|
|
11
|
+
|
|
12
|
+
export function RequestChat ({ onPreChatScreen }) {
|
|
13
|
+
const { sdk, setCustomerId, setThreadId, setThread } = useApp()
|
|
14
|
+
const { fetchCustomerId, fetchThread } = useChatSdk(sdk)
|
|
15
|
+
const [errors, setErrors] = useState({})
|
|
16
|
+
const [questionLength, setQuestionLength] = useState(0)
|
|
17
|
+
const [isButtonDisabled, setButtonDisabled] = useState(false)
|
|
18
|
+
|
|
19
|
+
const nameRef = useRef()
|
|
20
|
+
const questionRef = useRef()
|
|
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
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (Object.keys(errors).length) {
|
|
34
|
+
document.querySelector('.govuk-error-summary')?.focus()
|
|
35
|
+
}
|
|
36
|
+
}, [errors])
|
|
37
|
+
|
|
38
|
+
const onQuestionChange = e => {
|
|
39
|
+
setQuestionLength(e.target.value.length)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const buttonLabel = isButtonDisabled ? 'Requesting...' : 'Request Chat'
|
|
43
|
+
|
|
44
|
+
const onRequestChat = async e => {
|
|
45
|
+
e.preventDefault()
|
|
46
|
+
|
|
47
|
+
if (isButtonDisabled) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const errs = {}
|
|
52
|
+
|
|
53
|
+
if (nameRef.current.value.length === 0) {
|
|
54
|
+
errs.name = 'Enter your name'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (questionRef.current.value.length === 0) {
|
|
58
|
+
errs.question = 'Enter your question'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (questionRef.current.value.length > QUESTION_MAX_LENGTH) {
|
|
62
|
+
errs.question = 'Your question must be 500 characters or less'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (Object.keys(errs).length === 0) {
|
|
66
|
+
try {
|
|
67
|
+
setButtonDisabled(true)
|
|
68
|
+
const threadId = uuid.v4()
|
|
69
|
+
const customerId = await fetchCustomerId()
|
|
70
|
+
const thread = await fetchThread(threadId)
|
|
71
|
+
|
|
72
|
+
sdk.getCustomer().setName(nameRef.current.value)
|
|
73
|
+
|
|
74
|
+
await thread.startChat(questionRef.current.value || 'Begin conversation')
|
|
75
|
+
|
|
76
|
+
setCustomerId(customerId)
|
|
77
|
+
setThreadId(threadId)
|
|
78
|
+
setThread(thread)
|
|
79
|
+
thread.setCustomField('threadid', threadId)
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.log('[Request Chat Error]', err)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setErrors(errs)
|
|
86
|
+
}
|
|
2
87
|
|
|
3
|
-
export function RequestChat ({ onBack }) {
|
|
4
88
|
return (
|
|
5
89
|
<>
|
|
6
|
-
<
|
|
7
|
-
|
|
90
|
+
<PanelHeader />
|
|
91
|
+
|
|
92
|
+
<div className='wc-body'>
|
|
93
|
+
<div className='wc-content'>
|
|
94
|
+
<a href='#' className='wc-back-link govuk-back-link' onClick={onPreChatScreen}>
|
|
95
|
+
What you can use webchat for
|
|
96
|
+
</a>
|
|
97
|
+
|
|
98
|
+
<ErrorSummary errors={errors} />
|
|
99
|
+
|
|
100
|
+
<h3 className='wc-heading' aria-live='polite'>
|
|
101
|
+
Your name and question
|
|
102
|
+
</h3>
|
|
103
|
+
|
|
104
|
+
<form>
|
|
105
|
+
<div className={classnames('wc-form-group', 'govuk-form-group', errors.name && 'govuk-form-group--error')}>
|
|
106
|
+
<label className='wc-label govuk-label' htmlFor='wc-name'>
|
|
107
|
+
Your name
|
|
108
|
+
</label>
|
|
109
|
+
{errors.name && (
|
|
110
|
+
<p className='govuk-error-message'>
|
|
111
|
+
<span className='govuk-visually-hidden'>Error:</span> {errors.name}
|
|
112
|
+
</p>
|
|
113
|
+
)}
|
|
114
|
+
<input
|
|
115
|
+
ref={nameRef}
|
|
116
|
+
className={classnames('wc-input', 'govuk-input', errors.name && 'govuk-input--error')}
|
|
117
|
+
id='wc-name'
|
|
118
|
+
name='name'
|
|
119
|
+
type='text'
|
|
120
|
+
data-testid='request-chat-user-name'
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<div className='wc-form-group govuk-character-count' data-module='govuk-character-count' data-maxlength='500'>
|
|
125
|
+
<div className={classnames('govuk-form-group', errors.question && 'govuk-form-group--error')}>
|
|
126
|
+
<label className='wc-label govuk-label' htmlFor='wc-question'>
|
|
127
|
+
Your question
|
|
128
|
+
</label>
|
|
129
|
+
{errors.question && (
|
|
130
|
+
<p className='govuk-error-message'>
|
|
131
|
+
<span className='govuk-visually-hidden'>Error:</span>
|
|
132
|
+
{errors.question}
|
|
133
|
+
</p>
|
|
134
|
+
)}
|
|
135
|
+
<textarea
|
|
136
|
+
ref={questionRef}
|
|
137
|
+
id='wc-question'
|
|
138
|
+
name='question'
|
|
139
|
+
rows='5'
|
|
140
|
+
aria-describedby='wc-question-info'
|
|
141
|
+
onChange={onQuestionChange}
|
|
142
|
+
className={classnames('wc-textarea', 'govuk-textarea', 'govuk-js-character-count', !isQuestionLengthValid || errors.question ? 'govuk-textarea--error' : '')}
|
|
143
|
+
data-testid='request-chat-user-question'
|
|
144
|
+
/>
|
|
145
|
+
<div
|
|
146
|
+
id='wc-question-info'
|
|
147
|
+
className='wc-hint govuk-hint govuk-char-count__msg'
|
|
148
|
+
style={{ color: `${!isQuestionLengthValid ? '#d4351c' : ''}` }}
|
|
149
|
+
aria-hidden='true'
|
|
150
|
+
>
|
|
151
|
+
{questionHint}
|
|
152
|
+
</div>
|
|
153
|
+
<div className='govuk-character-count__sr-status govuk-visually-hidden' aria-live='polite'>
|
|
154
|
+
{questionHint}
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div className='wc-inset-text govuk-inset-text'>
|
|
160
|
+
By selecting 'Request chat' you agree to the terms of our
|
|
161
|
+
<a href='https://check-for-flooding.service.gov.uk/privacy-notice' target='_blank' rel='noreferrer' className='govuk-link'>privacy notice</a>.
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<button
|
|
165
|
+
className='wc-button govuk-button govuk-!-margin-top-1'
|
|
166
|
+
data-module='govuk-button'
|
|
167
|
+
onClick={onRequestChat}
|
|
168
|
+
aria-disabled={isButtonDisabled}
|
|
169
|
+
>
|
|
170
|
+
{buttonLabel}
|
|
171
|
+
</button>
|
|
172
|
+
</form>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
8
175
|
</>
|
|
9
176
|
)
|
|
10
177
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
|
+
|
|
4
|
+
import { useApp } from '../../store/useApp.js'
|
|
5
|
+
|
|
6
|
+
export function Settings ({ onCancel }) {
|
|
7
|
+
const { settings, setSettings } = useApp()
|
|
8
|
+
|
|
9
|
+
const [optionAudio, setOptionAudio] = useState(settings.audio)
|
|
10
|
+
const [optionScroll, setOptionScroll] = useState(settings.scroll)
|
|
11
|
+
|
|
12
|
+
const onSave = e => {
|
|
13
|
+
e.preventDefault()
|
|
14
|
+
|
|
15
|
+
setSettings({ audio: optionAudio, scroll: optionScroll })
|
|
16
|
+
onCancel(e)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const handleKeyPress = e => {
|
|
20
|
+
if ((e.key === 'Enter' || e.key === ' ') && e.target.id === 'settings-save') {
|
|
21
|
+
onSave(e)
|
|
22
|
+
} else if ((e.key === 'Enter' || e.key === ' ') && e.target.id === 'settings-cancel') {
|
|
23
|
+
onCancel(e)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<PanelHeader />
|
|
30
|
+
|
|
31
|
+
<div className='wc-body'>
|
|
32
|
+
<div className='wc-content'>
|
|
33
|
+
<fieldset className='govuk-fieldset govuk-!-margin-bottom-4'>
|
|
34
|
+
<legend className='govuk-fieldset__legend govuk-fieldset__legend'>
|
|
35
|
+
<h3 id='wc-subtitle' className='wc-heading'>Change settings</h3>
|
|
36
|
+
</legend>
|
|
37
|
+
<div className='govuk-checkboxes govuk-checkboxes--small' data-module='govuk-checkboxes'>
|
|
38
|
+
<div className='govuk-checkboxes__item'>
|
|
39
|
+
<input
|
|
40
|
+
id='audio'
|
|
41
|
+
name='audio'
|
|
42
|
+
type='checkbox'
|
|
43
|
+
value='audio'
|
|
44
|
+
className='govuk-checkboxes__input'
|
|
45
|
+
defaultChecked={optionAudio}
|
|
46
|
+
onChange={() => setOptionAudio(!optionAudio)}
|
|
47
|
+
/>
|
|
48
|
+
<label className='wc-label govuk-label govuk-checkboxes__label' htmlFor='audio'>
|
|
49
|
+
Play a sound when receiving a new message
|
|
50
|
+
</label>
|
|
51
|
+
</div>
|
|
52
|
+
<div className='govuk-checkboxes__item'>
|
|
53
|
+
<input
|
|
54
|
+
id='scroll'
|
|
55
|
+
name='scroll'
|
|
56
|
+
type='checkbox'
|
|
57
|
+
value='scroll'
|
|
58
|
+
className='govuk-checkboxes__input'
|
|
59
|
+
defaultChecked={optionScroll}
|
|
60
|
+
onChange={() => setOptionScroll(!optionScroll)}
|
|
61
|
+
/>
|
|
62
|
+
<label className='wc-label govuk-label govuk-checkboxes__label' htmlFor='scroll'>
|
|
63
|
+
Scroll automatically to a new message
|
|
64
|
+
</label>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</fieldset>
|
|
68
|
+
|
|
69
|
+
<div className='govuk-button-group'>
|
|
70
|
+
<a
|
|
71
|
+
id='settings-save'
|
|
72
|
+
href='#'
|
|
73
|
+
className='wc-button govuk-button'
|
|
74
|
+
data-module='govuk-button'
|
|
75
|
+
role='button'
|
|
76
|
+
onClick={onSave}
|
|
77
|
+
onKeyDown={handleKeyPress}
|
|
78
|
+
>
|
|
79
|
+
Save
|
|
80
|
+
</a>
|
|
81
|
+
<a
|
|
82
|
+
id='settings-cancel'
|
|
83
|
+
href='#'
|
|
84
|
+
className='wc-link govuk-link'
|
|
85
|
+
data-module='govuk-button'
|
|
86
|
+
role='button'
|
|
87
|
+
onClick={onCancel}
|
|
88
|
+
onKeyDown={handleKeyPress}
|
|
89
|
+
>
|
|
90
|
+
Cancel
|
|
91
|
+
</a>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { PanelHeader } from '../panel/panel-header.jsx'
|
|
3
|
+
|
|
4
|
+
export function Unavailable () {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<PanelHeader />
|
|
8
|
+
|
|
9
|
+
<div className='wc-body'>
|
|
10
|
+
<h3 id='wc-subtitle' className='govuk-heading-m'>Webchat is currently not available</h3>
|
|
11
|
+
<p className='govuk-body-s'>Try again later, or call Floodline:</p>
|
|
12
|
+
<p className='govuk-body-s'>
|
|
13
|
+
<strong>Floodline helpline</strong>
|
|
14
|
+
<br />Telephone: 0345 988 1188
|
|
15
|
+
<br />Textphone: 0345 602 6340
|
|
16
|
+
<br />Open 24 hours a day, 7 days a week
|
|
17
|
+
<br /><a className='govuk-link' href='https://gov.uk/call-charges'>Find out more about call charges</a>
|
|
18
|
+
</p>
|
|
19
|
+
<p className='govuk-body-s'>We're running webchat as a trial, it will not always be available.</p>
|
|
20
|
+
</div>
|
|
21
|
+
</>
|
|
22
|
+
)
|
|
23
|
+
}
|