Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What do you want to do with this return? #1570

Merged
merged 84 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
f9eaa44
How would you like to edit this return
Jozzey Dec 16, 2024
52f0bd4
Merge branch 'main' into how-to-edit-return
Jozzey Dec 16, 2024
9fce8fd
Create route and controller
Jozzey Dec 17, 2024
5235575
Initial page setup
Jozzey Dec 27, 2024
961cb7b
Merge branch 'main' into how-to-edit-return
Jozzey Dec 27, 2024
45f533f
Create service to fetch the data
Jozzey Dec 27, 2024
065cf2c
Update routes to use a querystring
Jozzey Dec 30, 2024
ac75646
Sort out backlink
Jozzey Dec 30, 2024
c1bb9c2
Create presenter
Jozzey Dec 30, 2024
7ba7225
Add POST route
Jozzey Dec 30, 2024
978f89c
Add validation
Jozzey Dec 30, 2024
5710b16
Tidy up validation error
Jozzey Dec 30, 2024
12fff05
Make some tweaks to the controller
Jozzey Dec 31, 2024
dd3c341
Merge remote-tracking branch 'origin/main' into how-to-edit-return
Jozzey Dec 31, 2024
6e508e9
Refactor following PR https://github.com/DEFRA/water-abstraction-syst…
Jozzey Dec 31, 2024
781a196
Make it work following merge
Jozzey Dec 31, 2024
e9bf383
Create submit service
Jozzey Dec 31, 2024
be26c60
Persist selected option
Jozzey Dec 31, 2024
cb5aa94
Make prettier
Jozzey Dec 31, 2024
73ead81
Refactor to minimise merge issues
Jozzey Jan 6, 2025
b151c6d
Merge remote-tracking branch 'origin/main' into how-to-edit-return
Jozzey Jan 6, 2025
4266a14
Add feature flag `ENABLE_SYSTEM_RETURNS_VIEW`
Jozzey Jan 7, 2025
bbbf057
Update view with new layout
Jozzey Jan 7, 2025
d961f31
Rename a load of things following changes to page
Jozzey Jan 7, 2025
5d71802
Update controller test
Jozzey Jan 7, 2025
47d6d19
Add return log status to initiate session data
Jozzey Jan 7, 2025
9a09f87
Add received date to initiate session data
Jozzey Jan 7, 2025
24f44e0
Add feature flag to link
Jozzey Jan 7, 2025
27ce521
Make record receipt option conditional
Jozzey Jan 7, 2025
4d892d0
Update radio button values
Jozzey Jan 8, 2025
370a342
Fix filename
Jozzey Jan 8, 2025
d8a5cdb
Update redirect route for submit
Jozzey Jan 8, 2025
368e376
Update links
Jozzey Jan 8, 2025
f701032
Add due date to session data
Jozzey Jan 8, 2025
db46285
Add return log status tag to view
Jozzey Jan 8, 2025
a23a058
Sort out how the return log status is displayed
Jozzey Jan 8, 2025
2f90bc2
Fix status tag
Jozzey Jan 8, 2025
a8a99a0
Tidy up view
Jozzey Jan 8, 2025
29c3ac0
Merge branch 'main' into how-to-edit-return
Jozzey Jan 8, 2025
0f0f121
Remove view licence link
Jozzey Jan 9, 2025
6af1273
Create controller unit tests
Jozzey Jan 9, 2025
389a927
Create presenter tests
Jozzey Jan 10, 2025
47fd447
Create start service tests
Jozzey Jan 10, 2025
cdd973f
Create submit start tests
Jozzey Jan 10, 2025
3107151
Stub new feature flag in existing test
Jozzey Jan 10, 2025
c542281
Update to minimise merge hell :crossed_fingers:
Jozzey Jan 10, 2025
7dde0a2
Merge remote-tracking branch 'origin/main' into how-to-edit-return
Jozzey Jan 10, 2025
57b5281
Sort out route issue as per review
Jozzey Jan 13, 2025
bb8285b
Add separate test for `overdue` status as per review comment
Jozzey Jan 13, 2025
957c660
Add a comment to test
Jozzey Jan 13, 2025
96d0aaa
Create validator for submit start service as per review comment
Jozzey Jan 13, 2025
f3dcc64
Create validator unit tests
Jozzey Jan 13, 2025
1cc82aa
Merge branch 'main' into how-to-edit-return
Jozzey Jan 13, 2025
46e7def
Tiny tweak
Jozzey Jan 13, 2025
a14d845
Fix unit test
Jozzey Jan 13, 2025
15c7ad9
Fix another test
Jozzey Jan 13, 2025
d3153a2
Fix another test
Jozzey Jan 13, 2025
56154b4
Remove duplicated tests
Jozzey Jan 13, 2025
fda29fe
Update comment
Jozzey Jan 13, 2025
b391184
Update comment
Jozzey Jan 13, 2025
6bbb4d7
Update comment
Jozzey Jan 13, 2025
46f49d6
Update comment
Jozzey Jan 13, 2025
6a71735
Update comment
Jozzey Jan 13, 2025
1195c35
Update comment
Jozzey Jan 13, 2025
78944a2
Update comment
Jozzey Jan 13, 2025
3d37aa1
Update comment
Jozzey Jan 13, 2025
6d8e775
Update comment
Jozzey Jan 13, 2025
4a4fc6e
Update comment
Jozzey Jan 13, 2025
33f0181
Move activeNavBar into service
Jozzey Jan 14, 2025
4e80ee4
Move `activeNavBar` into submit service
Jozzey Jan 14, 2025
f500b53
Rename `whatToDo` to `journey`
Jozzey Jan 14, 2025
e95f791
Make values kebab-case
Jozzey Jan 14, 2025
ee51385
Remove .only
Jozzey Jan 14, 2025
b1ad832
Add missing `afterEach` to unit test
Jozzey Jan 15, 2025
4c85010
Update return log link in 2pt review screens
Jozzey Jan 15, 2025
618faf3
Rename back link "Go back to licence"
Jozzey Jan 15, 2025
5fedd0d
Remove `returnLogId` as not needed
Jozzey Jan 15, 2025
8046c7f
Rename back link "Go back to summary"
Jozzey Jan 15, 2025
30b2357
Merge remote-tracking branch 'origin/main' into how-to-edit-return
Jozzey Jan 15, 2025
08181b9
Tidy up controller to meet new convention
Jozzey Jan 15, 2025
38b9332
Remove unnecessary status
Jozzey Jan 15, 2025
e02b109
Reorder unit tests after the merge messed it up
Jozzey Jan 15, 2025
4a92d47
Update view as per review comment
Jozzey Jan 15, 2025
1c0d5d4
Update presenter comment
Jozzey Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create submit service
Jozzey committed Dec 31, 2024

Verified

This commit was signed with the committer’s verified signature.
commit e9bf38333e663207c6938193b0ae7f4cf3bdb93e
9 changes: 4 additions & 5 deletions app/controllers/return-logs-edit.controller.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@

const EditReturnLogService = require('../services/return-logs-edit/edit-return-log.service.js')
const InitiateSessionService = require('../services/return-logs-edit/initiate-session.service.js')
const SubmitEditReturnLogService = require('../services/return-logs-edit/submit-edit-return-log.service.js')

const basePath = '/system/return-log-edit'

@@ -26,19 +27,17 @@ async function setup(request, h) {

async function submitEdit(request, h) {
const { sessionId } = request.params
const { howToEdit } = request.payload

const pageData = await EditReturnLogService.go(sessionId)
const pageData = await SubmitEditReturnLogService.go(sessionId, request.payload)

if (!howToEdit) {
if (pageData.error) {
return h.view('return-logs-edit/how-to-edit.njk', {
activeNavBar: 'search',
error: { text: 'Select how would you like to edit this return' },
...pageData
})
}

return h.redirect(`${basePath}/${sessionId}/${howToEdit}`)
return h.redirect(`${basePath}/${sessionId}/${pageData.howToEdit}`)
}

module.exports = {
57 changes: 57 additions & 0 deletions app/services/return-logs-edit/submit-edit-return-log.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict'

/**
* Handles the user submission for the `/return-log-edit/{sessionId}/how-to-edit` page
* @module SubmitEditReturnLogService
*/

const SessionModel = require('../../models/session.model.js')
const EditReturnLogPresenter = require('../../presenters/return-logs-edit/edit-return-log.presenter.js')

/**
* Handles the user submission for the `/return-log-edit/{sessionId}/how-to-edit` page
*
* @param {string} sessionId - The UUID for setup bill run session record
* @param {object} payload - The submitted form data
*
* @returns {Promise<object>} An object with a `howToEdit:` property if there are no errors else the page data for
* the abstraction return page including the validation error details
*/
async function go(sessionId, payload) {
const session = await SessionModel.query().findById(sessionId)
const { howToEdit } = payload
const validationResult = _validate(howToEdit)

if (!validationResult) {
await _save(session, howToEdit)

return { howToEdit }
}

const formattedData = EditReturnLogPresenter.go(session)

return {
error: validationResult,
...formattedData
}
}

async function _save(session, howToEdit) {
const currentData = session

currentData.howToEdit = howToEdit

return session.$query().patch({ data: currentData })
}

function _validate(howToEdit) {
if (!howToEdit) {
return { text: 'Select how would you like to edit this return' }
}

Check failure on line 50 in app/services/return-logs-edit/submit-edit-return-log.service.js

GitHub Actions / build

Delete `··`

return null
}

module.exports = {
go
}