Skip to content

Commit 718d677

Browse files
Make actions work
1 parent d521d63 commit 718d677

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

app/routes/regions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ module.exports = router => {
4949
})
5050
})
5151

52+
// Action to mark organisation as accepted
53+
router.post('/regions/accepted/:id', (req, res) => {
54+
const data = req.session.data
55+
const organisation = data.organisations.find((org) => org.id === req.params.id)
56+
organisation.status = 'Active'
57+
58+
res.redirect('/regions/awaiting-approval')
59+
})
60+
61+
// Action to mark organisation as rejected
62+
router.post('/regions/rejected/:id', (req, res) => {
63+
const data = req.session.data
64+
const organisation = data.organisations.find((org) => org.id === req.params.id)
65+
organisation.status = 'Rejected'
66+
67+
res.redirect('/regions/awaiting-approval')
68+
})
69+
70+
5271
router.get('/regions/reject/:id', (req, res) => {
5372
const data = req.session.data
5473
const organisation = data.organisations.find((org) => org.id === req.params.id)

app/views/regions/accept.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h1 class="nhsuk-heading-l">Approve {{ organisation.name }}</h1>
3333
{% include "regions/_email-preview.html" %}
3434

3535

36-
<form action="/regions/awaiting-approval" method="post" novalidate="true">
36+
<form action="/regions/accepted/{{ organisation.id }}" method="post" novalidate="true">
3737
{{ button({
3838
"text": "Confirm and send",
3939
classes: "nhsuk-button"

app/views/regions/reject.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="nhsuk-heading-l">Reject {{ organisation.name }}</h1>
2828

2929
{% include "regions/_email-reject.html" %}
3030

31-
<form action="/regions/awaiting-approval" method="post" novalidate="true">
31+
<form action="/regions/rejected/{{ organisation.id }}" method="post" novalidate="true">
3232
{{ button({
3333
"text": "Confirm and send",
3434
classes: "nhsuk-button--warning"

0 commit comments

Comments
 (0)