Skip to content

Commit

Permalink
Update routes to use a querystring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozzey committed Dec 30, 2024
1 parent 45f533f commit 065cf2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/return-logs.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const EditReturnLogService = require('../services/return-logs/edit-return-log.se
*/

async function edit(request, h) {
const { returnLogId } = request.params
const { returnLogId } = request.query
const pageData = await EditReturnLogService.go(returnLogId)

return h.view('return-logs/edit.njk', { activeNavBar: 'search', ...pageData })
Expand Down
2 changes: 1 addition & 1 deletion app/routes/return-logs.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ReturnLogsController = require('../controllers/return-logs.controller.js')
const routes = [
{
method: 'GET',
path: '/return-logs/{returnLogId}/edit',
path: '/return-logs/edit',
options: {
handler: ReturnLogsController.edit,
app: {
Expand Down
5 changes: 5 additions & 0 deletions app/services/return-logs/edit-return-log.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @module EditReturnLogService
*/

const FetchEditReturnLogService = require('./fetch-edit-return-log.service.js')

/**
* Orchestrates fetching and presenting the data needed for the how to edit an abstraction return page
*
Expand All @@ -13,6 +15,9 @@
* @returns {Promise<object>} page data needed by the view template
*/
async function go(returnLogId) {
const editReturnLog = await FetchEditReturnLogService.go(returnLogId)
console.log('🚀 ~ go ~ editReturnLog:', editReturnLog)

return {
returnLogId,
pageTitle: 'Abstraction return',
Expand Down
8 changes: 4 additions & 4 deletions app/views/return-logs/edit.njk
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@
},
items: [
{
value: '/return-logs/'+ returnLogId +'/edit/single-volume',
value: '/return-logs/edit/single-volume?returnLogId=' + returnLogId,
text: "Enter individual volumes"
},
{
value: '/return-logs/'+ returnLogId +'/edit/new-volumes',
value: '/return-logs/edit/new-volumes?returnLogId=' + returnLogId,
text: "Enter new volumes or readings"
},
{
value: '/return-logs/'+ returnLogId +'/edit/nil-return',
value: '/return-logs/edit/nil-return?returnLogId=' + returnLogId,
text: "Enter a nil return"
},
{
value: '/return-logs/'+ returnLogId +'/edit/query',
value: '/return-logs/edit/query?returnLogId=' + returnLogId,
text: queryText
}
]
Expand Down

0 comments on commit 065cf2c

Please sign in to comment.