Skip to content

Commit

Permalink
chore: fix sonar cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangoulding committed May 21, 2024
1 parent c92d054 commit 8bc07b6
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions app/presenters/licences/licence-set-up.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function _chargeVersions (licenceSetUp) {
id: chargeInformation.id,
startDate: chargeInformation.startDate ? formatLongDate(chargeInformation.startDate) : '-',
endDate: chargeInformation.endDate ? formatLongDate(chargeInformation.endDate) : '-',
status: _chargeVersionStatus(chargeInformation.status),
status: _status(chargeInformation.status),
reason: chargeInformation.changeReason?.description,
action: [
{
Expand All @@ -43,7 +43,7 @@ function _chargeVersions (licenceSetUp) {
})
}

function _chargeVersionStatus (status) {
function _status (status) {
const statues = {
current: 'approved',
draft: 'draft',
Expand All @@ -65,7 +65,7 @@ function _workflows (workflows, auth) {
id: workflow.id,
startDate: workflow.createdAt ? formatLongDate(workflow.createdAt) : '-',
endDate: '-',
status: _chargeVersionStatus(workflow.status),
status: _status(workflow.status),
reason: workflow.data.chargeVersion.changeReason.description,
action: _workflowAction(workflow, auth)
}
Expand All @@ -74,26 +74,34 @@ function _workflows (workflows, auth) {

function _workflowAction (workflow, auth) {
if (workflow.status === 'to_setup' && auth.credentials?.scope?.includes('charge_version_workflow_editor')) {
return [
{
text: 'Set up',
link: `/licences/${workflow.licenceId}/charge-information/create?chargeVersionWorkflowId=${workflow.id}`
},
{
text: 'Remove',
link: `/charge-information-workflow/${workflow.id}/remove`
}
]
return _workflowActionEditor(workflow)
} else if (auth.credentials?.scope?.includes('charge_version_workflow_reviewer')) {
return [
{
text: 'Review',
link: `/licences/${workflow.licenceId}/charge-information/${workflow.id}/review`
}
]
return _workflowActionReviewer(workflow)
} else {
return []
}
}

return []
function _workflowActionEditor (workflow) {
return [
{
text: 'Set up',
link: `/licences/${workflow.licenceId}/charge-information/create?chargeVersionWorkflowId=${workflow.id}`
},
{
text: 'Remove',
link: `/charge-information-workflow/${workflow.id}/remove`
}
]
}

function _workflowActionReviewer (workflow) {
return [
{
text: 'Review',
link: `/licences/${workflow.licenceId}/charge-information/${workflow.id}/review`
}
]
}

module.exports = {
Expand Down

0 comments on commit 8bc07b6

Please sign in to comment.