From 03944631092acdba2f2ffe94744c3060e46f6816 Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Thu, 12 Sep 2024 16:51:22 +0100 Subject: [PATCH] Display organisation name and address in profile (#107) This updates the profile page to show the user the name and address of the organisation they are signed in as. This is mainly for the benefit of any users who may have multiple accounts with different organisations. The address is shown as well as the organisation name, as some organisations have identical names, particularly community pharmacies (where there are hundreds with the name "Boots" or "Superdrug"). ### Screenshot Screenshot 2024-09-12 at 16 49 27 --- app/data/session-data-defaults.js | 33 ++++++++++++++++++++++++++++ app/locals.js | 6 ++++- app/routes/auth.js | 16 +++++++++++++- app/views/select-organisation.html | 31 +++++++++++++------------- app/views/user-profile/v2/index.html | 22 +++++++++++++++++++ 5 files changed, 90 insertions(+), 18 deletions(-) diff --git a/app/data/session-data-defaults.js b/app/data/session-data-defaults.js index eff8cad..126a4c7 100644 --- a/app/data/session-data-defaults.js +++ b/app/data/session-data-defaults.js @@ -1,5 +1,6 @@ module.exports = { currentUserId: "12345", + currentOrganisationId: "R0A", vaccines: [], "users": [ { @@ -175,6 +176,38 @@ module.exports = { data: [ "Patients", "Staff", "Site or delivery team", "Assessment and consent", "Vaccination" ], + organisations: [ + { + id: "FAC81", + name: "Hambro Pharmacy", + type: "Community pharmacy", + address: { + line1: "53A Hullbridge Road", + town: "Rayleigh", + postcode: "SS6 9NL" + } + }, + { + id: "FA464", + name: "Cohens Chemists", + type: "Community pharmacy", + address: { + line1: "151-151A Accrington Road", + town: "Burnley", + postcode: "BB11 5AL" + } + }, + { + id: "R0A", + name: "Manchester University NHS Foundation Trust", + type: "NHS Trust", + address: { + line1: "Cobbett House, Oxford Road", + town: "Manchester", + postcode: "M13 9WL" + } + } + ], "nhsTrusts": { "R0A": "Manchester University NHS Foundation Trust", "R0B": "South Tyneside and Sunderland NHS Foundation Trust", diff --git a/app/locals.js b/app/locals.js index 4684d06..534af9b 100644 --- a/app/locals.js +++ b/app/locals.js @@ -1,8 +1,12 @@ module.exports = (config) => (req, res, next) => { res.locals.serviceName = config.serviceName; - // Set currentUser for convenience + // Set currentUser and currentOrganisation for convenience res.locals.currentUser = req.session.data.users.find((user) => user.id === req.session.data.currentUserId); + // Set currentUser for convenience + res.locals.currentOrganisation = req.session.data.organisations.find((organisation) => organisation.id === req.session.data.currentOrganisationId); + + next(); }; diff --git a/app/routes/auth.js b/app/routes/auth.js index 133330e..94bf958 100644 --- a/app/routes/auth.js +++ b/app/routes/auth.js @@ -1,10 +1,21 @@ module.exports = router => { + router.get('/select-organisation', (req, res) => { + + const organisations = req.session.data.organisations.filter((organisation) => ["FAC81", "FA464"].includes(organisation.id)) + + res.render('select-organisation', { + organisations + }) + + }) + router.post('/select-organisation', (req, res) => { const organisationId = req.session.data.organisationId if (organisationId) { req.session.data.currentUserId = "12345"; + req.session.data.currentOrganisationId = organisationId; // Reset data delete req.session.data.organisationId @@ -18,8 +29,11 @@ module.exports = router => { href: "#organisationId-1" } + const organisations = req.session.data.organisations.filter((organisation) => ["FAC81", "FA464"].includes(organisation.id)) + res.render('select-organisation', { - error + error, + organisations }) } }) diff --git a/app/views/select-organisation.html b/app/views/select-organisation.html index 8159771..63f7489 100644 --- a/app/views/select-organisation.html +++ b/app/views/select-organisation.html @@ -21,6 +21,20 @@
+ {% set items = [] %} + {% for organisation in organisations %} + + {% set items = (items.push({ + value: organisation.id, + text: organisation.name, + hint: { + text: organisation.address.line1 + } + }), items) %} + {% endfor %} + + + {{ radios({ name: "organisationId", fieldset: { @@ -33,22 +47,7 @@ errorMessage: { text: error.text } if error, - items: [ - { - value: "FA424", - text: "Pickfords Pharmacy", - hint: { - text: "8 Spencer Court, Corby, NN17 1NU" - } - }, - { - value: "FAH83", - text: "Claygate Pharmacy", - hint: { - text: "35 The Parade, Claygate, Esher, KT10 0PD" - } - } - ] + items: items }) }} {{ button({ diff --git a/app/views/user-profile/v2/index.html b/app/views/user-profile/v2/index.html index 2f61a75..fd945db 100644 --- a/app/views/user-profile/v2/index.html +++ b/app/views/user-profile/v2/index.html @@ -24,6 +24,14 @@

Your profile

{% endset %} + {% set organisationHtml %} +
{{ currentOrganisation.name }}
+

+ {{ currentOrganisation.address.line1 }}, {{ currentOrganisation.address.postcode }} +

+ + {% endset %} + {{ summaryList({ classes: "nhsuk-u-margin-bottom-4", rows: [ @@ -56,6 +64,20 @@

Your profile

] } }, + { + key: { + text: "Organisation" + }, + value: { + html: organisationHtml + }, + actions: { + items: [ + { + } + ] + } + }, { key: { text: "Permission level"