Skip to content

Commit

Permalink
wip: Initial button, route, controller, service
Browse files Browse the repository at this point in the history
  • Loading branch information
StuAA78 committed Jan 30, 2025
1 parent 57bfedb commit eb387cc
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
11 changes: 11 additions & 0 deletions app/controllers/return-logs.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

const Boom = require('@hapi/boom')

const SubmitViewReturnLogService = require('../services/return-logs/submit-view-return-log.service.js')

const ViewReturnLogService = require('../services/return-logs/view-return-log.service.js')

async function view(request, h) {
Expand All @@ -23,6 +25,15 @@ async function view(request, h) {
return h.view('return-logs/view.njk', pageData)
}

async function submitView(request, h) {
const { id } = request.query

await SubmitViewReturnLogService.go(id)

return h.redirect(`/system/return-logs?id=${id}`)
}

module.exports = {
submitView,
view
}
7 changes: 7 additions & 0 deletions app/routes/return-logs.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const routes = [
options: {
handler: ReturnLogsController.view
}
},
{
method: 'POST',
path: '/return-logs',
options: {
handler: ReturnLogsController.submitView
}
}
]

Expand Down
20 changes: 20 additions & 0 deletions app/services/return-logs/submit-view-return-log.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

/**
* Handles updating a return log record when the query button is clicked
* @module SubmitViewReturnLogService
*/

/**
*
* @param returnLogId
* @param _yar
* @param _payload
*/
async function go(returnLogId, _yar, _payload) {
console.log('🚀 ~ go ~ returnLogId:', returnLogId)
}

module.exports = {
go
}
46 changes: 36 additions & 10 deletions app/views/return-logs/view.njk
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,46 @@
</div>
{% endif %}

{# Submit/Edit return button #}
{% if actionButton %}
<div class="govuk-grid-row govuk-!-margin-bottom-3">
<div class="govuk-grid-column-full">
{{
govukButton({
text: actionButton.text,
preventDoubleClick: true,
href: actionButton.href
})
}}
<form method="post">
<input type="hidden" name="wrlsCrumb" value="{{wrlsCrumb}}"/>
{% if actionButton %}
{# The button group div goes inside the if because we only need a group when there's two buttons #}
<div class="govuk-button-group">
{# Submit/Edit return button #}
{{
govukButton({
text: actionButton.text,
preventDoubleClick: true,
href: actionButton.href
})
}}
{% endif %}

{# Mark as under query / Resolve query button #}
{% if query %}
{% set queryButtonText = 'Resolve query' %}
{% set queryButtonValue = 'unmark' %}
{% else %}
{% set queryButtonText = 'Mark as under query' %}
{% set queryButtonValue = 'mark' %}
{% endif %}
{{
govukButton({
text: queryButtonText,
classes: "govuk-button--secondary",
name: "mark-query",
value: queryButtonValue,
preventDoubleClick: true
})
}}
{% if actionButton %}
</div>
</form>
{% endif %}
</div>
</div>
{% endif %}

{# Selected return submission details #}
{% if displayTable %}
Expand Down

0 comments on commit eb387cc

Please sign in to comment.