-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathemail.js
More file actions
64 lines (61 loc) · 1.81 KB
/
email.js
File metadata and controls
64 lines (61 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { buildErrorList } from '~/src/common/helpers/build-error-details.js'
import { formOverviewBackLink } from '~/src/models/links.js'
/**
* @param {FormMetadata} metadata
* @param {ValidationFailure<FormMetadataContactEmail>} [validation]
*/
export function emailViewModel(metadata, validation) {
const pageTitle = 'Email address for support'
const { formValues, formErrors } = validation ?? {}
return {
form: metadata,
backLink: formOverviewBackLink(metadata.slug),
pageTitle,
pageHeading: {
text: pageTitle,
caption: metadata.title,
size: 'large'
},
errorList: buildErrorList(formErrors),
formErrors: validation?.formErrors,
formValues: validation?.formValues,
fields: [
{
id: 'address',
name: 'address',
label: {
text: 'Email address',
isPageHeading: false
},
hint: {
text: 'Enter a dedicated support team email address. Do not enter a named individual. For example, ‘support@defra.gov.uk’'
},
type: 'email',
value: formValues?.address ?? metadata.contact?.email?.address,
autocomplete: 'email',
spellcheck: false
},
{
id: 'responseTime',
name: 'responseTime',
label: {
text: 'Response time',
isPageHeading: false
},
hint: {
text: 'Enter how long it takes to receive a response, for example, ‘We aim to respond within 2 working days’'
},
value: formValues?.responseTime ?? metadata.contact?.email?.responseTime
}
],
buttons: [
{
text: 'Save and continue'
}
]
}
}
/**
* @import { FormMetadata, FormMetadataContactEmail } from '@defra/forms-model'
* @import { ValidationFailure } from '~/src/common/helpers/types.js'
*/