Skip to content

Commit

Permalink
PP-13313 Show card for completed tasks when credentials are set
Browse files Browse the repository at this point in the history
  • Loading branch information
DomBelcher committed Dec 19, 2024
1 parent 416c4cb commit d840c17
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ const worldpayDetailsService = require('@services/worldpay-details.service')
const WorldpayCredential = require('@models/gateway-account-credential/WorldpayCredential.class')

function get (req, res) {
const existingCredentials = req.account.getCurrentCredential().credentials?.oneOffCustomerInitiated || {}

return response(req, res, 'simplified-account/settings/worldpay-details/credentials', {
backLink: formatSimplifiedAccountPathsFor(paths.simplifiedAccount.settings.worldpayDetails.index,
req.service.externalId, req.account.type)
req.service.externalId, req.account.type),
credentials: existingCredentials
})
}

Expand Down
15 changes: 14 additions & 1 deletion app/models/WorldpayTasks.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ class WorldpayTasks {
service.externalId, gatewayAccount.type),
id: 'worldpay-credentials',
linkText: 'Link your Worldpay account with GOV.UK Pay',
complete: true
complete: true,
completedCard: {
title: 'Account credentials',
rows: [{
keyText: 'Merchant Code',
valueText: credential.credentials?.oneOffCustomerInitiated?.merchantCode
}, {
keyText: 'Username',
valueText: credential.credentials?.oneOffCustomerInitiated?.username
}, {
keyText: 'Password',
valueText: '●●●●●●●●'
}]
}
}
if (!credential || !credential.credentials.oneOffCustomerInitiated) {
worldpayCredentials.complete = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
name: 'merchantCode',
classes: 'govuk-input--width-20',
type: 'text',
value: merchantCode,
value: credentials.merchantCode,
errorMessage: errors.formErrors.merchantCode and {
text: errors.formErrors.merchantCode
}
Expand All @@ -39,7 +39,7 @@
name: 'username',
classes: 'govuk-input--width-20',
type: 'text',
value: username,
value: credentials.username,
errorMessage: errors.formErrors.username and {
text: errors.formErrors.username
},
Expand All @@ -55,7 +55,6 @@
name: 'password',
classes: "govuk-input--width-20",
type: 'password',
value: password,
errorMessage: errors.formErrors.password and {
text: errors.formErrors.password
},
Expand Down
29 changes: 29 additions & 0 deletions app/views/simplified-account/settings/worldpay-details/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@
classes: "task-list"
}) }}

{% else %}

{% set taskList = [] %}
{% for task in tasks %}
{% set taskCardRows = [] %}
{% for row in task.completedCard.rows %}
{% set taskCardRows = (taskCardRows.push({
key: { text: row.keyText },
value: { text: row.valueText }
}), taskCardRows) %}
{% endfor %}

{{ govukSummaryList({
card: {
title: {
text: task.completedCard.title
},
actions: {
items: [{
href: task.href,
text: 'Change'
}]
}
},
rows: taskCardRows
}) }}

{% endfor %}

{% endif %}

{% endblock %}

0 comments on commit d840c17

Please sign in to comment.