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

MDWFP-129 fixing bug with success message. #5

Merged
merged 2 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion server/model/adjustmentsListModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ export type Message = {
export default class AdjustmentsListViewModel {
public adjustmentTypes = adjustmentTypes

public messageType: AdjustmentType

constructor(
public prisonerDetail: PrisonApiPrisoner,
public adjustments: Adjustment[],
public relevantRemand: Remand[],
public message: Message,
) {}
) {
this.messageType = message && this.adjustmentTypes.find(it => it.value === message.type)
}

public deductions(): AdjustmentType[] {
return this.adjustmentTypes.filter(it =>
Expand Down
6 changes: 6 additions & 0 deletions server/routes/adjustmentRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export default class AdjustmentRoutes {
})
}

public success: RequestHandler = async (req, res): Promise<void> => {
const { nomsId } = req.params
req.flash('message', req.query.message as string)
return res.redirect(`/${nomsId}`)
}

public list: RequestHandler = async (req, res): Promise<void> => {
const { caseloads, token } = res.locals.user
const { nomsId } = req.params
Expand Down
1 change: 1 addition & 0 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function routes(service: Services): Router {
get('/:nomsId/start', adjustmentRoutes.start)
get('/:nomsId', adjustmentRoutes.list)
get('/:nomsId/remand', adjustmentRoutes.remand)
get('/:nomsId/success', adjustmentRoutes.success)

get('/test/:nomsId', adjustmentTestRoutes.list)
get('/test/:nomsId/create', adjustmentTestRoutes.create)
Expand Down
2 changes: 1 addition & 1 deletion server/views/pages/adjustments/list.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
<div class="govuk-notification-banner__content">
<h3 class="govuk-notification-banner__heading">
{{model.message.days}} days of {{model.message.type.shortText}} have been applied
{{model.message.days}} days of {{model.messageType.shortText}} have been applied
</h3>
<p class="govuk-body">The adjustments have been saved in NOMIS. You can continue to add adjustments for {{model.prisonerDetail.firstName | title}}
{{model.prisonerDetail.lastName | title}}.</p>
Expand Down