Skip to content

Commit

Permalink
CRS-2191-error-message-amendments (#856)
Browse files Browse the repository at this point in the history
Use createSupportLink function to correctly wrap error messages with supporting text.
  • Loading branch information
mg-moj authored Dec 11, 2024
1 parent 70bd7d5 commit 5b4069d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/services/manualEntryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ManualEntrySelectedDate,
SubmittedDate,
} from '../@types/calculateReleaseDates/calculateReleaseDatesClientTypes'
import { createSupportLink } from '../utils/utils'

const order = {
SED: 1,
Expand Down Expand Up @@ -82,7 +83,18 @@ export default class ManualEntryService {
)

if (validationMessages.messages.length > 0) {
const dateErrors = `<div class="govuk-error-message"><ul>${validationMessages.messages.map(e => `<li>${e.text}</li>`).join('\n')}</ul></div>`
const errorStart = 'There is a problem'
const errorEnd = createSupportLink({
prefixText: 'You must reselect the dates, or if you need help, ',
linkText: 'contact the Specialist support team',
suffixText: ' for support.',
emailSubjectText: 'Calculate release dates - Manual Entry - Incompatible Dates',
})

const dateErrors = `<div class="govuk-error-message">${errorStart}<ul>
<div class="govuk-error-message"><ul>
${validationMessages.messages.map(e => `<li>${e.text}</li>`).join('\n')}</ul></div>
</ul>${errorEnd}</div>`
const validationError = { errorMessage: { html: dateErrors } }
const mergedConfig = { ...config, ...validationError }
// eslint-disable-next-line no-restricted-syntax
Expand Down

0 comments on commit 5b4069d

Please sign in to comment.