From 2a8c48a18445588dcfbbdaa02ab2b52cebc2a658 Mon Sep 17 00:00:00 2001 From: Caitlin Roach Date: Tue, 16 Jun 2026 16:14:41 +0100 Subject: [PATCH 1/2] Add empty state for no pharmacies --- app/routes/prototype-admin.js | 14 +++ .../includes/_preset-scenarios-table.html | 8 ++ app/views/pharmacies/index.html | 116 +++++++++--------- 3 files changed, 81 insertions(+), 57 deletions(-) diff --git a/app/routes/prototype-admin.js b/app/routes/prototype-admin.js index b2401748..2bd6777f 100644 --- a/app/routes/prototype-admin.js +++ b/app/routes/prototype-admin.js @@ -564,6 +564,20 @@ module.exports = (router) => { res.redirect('/home') }) + // ---------------------------------------------------------------- + // Preset: Pharmacy HQ, no data (Amanda White, P15951) + // ---------------------------------------------------------------- + + router.get('/prototype-setup/preset/pharmacy-hq-no-data', (req, res) => { + resetSession(req) + const data = req.session.data + data.currentUserId = '6424325235325' + data.currentOrganisationId = 'P15951' + // Remove all pharmacies belonging to P15951 to start with a clean slate + data.organisations = data.organisations.filter(org => org.companyId !== 'P15951' || org.type === 'Pharmacy HQ') + res.redirect('/home') + }) + // ---------------------------------------------------------------- // Preset: Recorder, single organisation (Ocean Merritt, FR4V56) // ---------------------------------------------------------------- diff --git a/app/views/includes/_preset-scenarios-table.html b/app/views/includes/_preset-scenarios-table.html index 3d9bd63b..05a98cf7 100644 --- a/app/views/includes/_preset-scenarios-table.html +++ b/app/views/includes/_preset-scenarios-table.html @@ -71,6 +71,14 @@ role: "Group administrator", scenarioDetails: "Group admin for a large pharmacy chain (same-name pharmacies)." }, + { + presetLabel: "Group admin, pharmacy HQ (no data)", + presetPath: "/prototype-setup/preset/pharmacy-hq-no-data", + userName: "Amanda White", + userEmail: "amanda.white@nhs.net", + role: "Group administrator", + scenarioDetails: "Group admin for a pharmacy HQ with no pre-loaded data, pharmacies or users." + }, { presetLabel: "Regional lead", presetPath: "/prototype-setup/preset/regions", diff --git a/app/views/pharmacies/index.html b/app/views/pharmacies/index.html index b033a9bf..ac9ab6ff 100644 --- a/app/views/pharmacies/index.html +++ b/app/views/pharmacies/index.html @@ -43,65 +43,67 @@

Pharmacies

href: "/pharmacies/select" }) }} - - -
Pharmacies added ({{ organisations | length }})
- {% if (organisations | length) > 10 %} -
- - -
- {% endif %} - - - - - - - - - - - - {% for organisation in organisations %} - - - - - - + {% if (organisations | length) > 0 %} +
- Name - - Vaccines - - Users - - Status - - Actions -
- {{ organisation.name }} ({{ organisation.id}}) - - {% set vaccinesEnabled = [] %} - {% for vaccine in organisation.vaccines %} - {% if vaccine.status == "enabled" %} - {% set vaccinesEnabled = (vaccinesEnabled.push(vaccine.name), vaccinesEnabled) %} - {% endif %} - {% endfor %} - - {{ (vaccinesEnabled | sort | join(", ")) | capitaliseFirstLetter }} - - {{ organisationUserCounts[organisation.id] }} - - {{ organisation.status }} - - Manage -
+ +
Pharmacies added ({{ organisations | length }})
+ {% if (organisations | length) > 10 %} +
+ + +
+ {% endif %} + + + + + + + + - {% endfor %} + + + {% for organisation in organisations %} + + + + + + + + {% endfor %} - -
+ Name + + Vaccines + + Users + + Status + + Actions +
+ {{ organisation.name }} ({{ organisation.id}}) + + {% set vaccinesEnabled = [] %} + {% for vaccine in organisation.vaccines %} + {% if vaccine.status == "enabled" %} + {% set vaccinesEnabled = (vaccinesEnabled.push(vaccine.name), vaccinesEnabled) %} + {% endif %} + {% endfor %} + + {{ (vaccinesEnabled | sort | join(", ")) | capitaliseFirstLetter }} + + {{ organisationUserCounts[organisation.id] }} + + {{ organisation.status }} + + Manage +
+ + + {% endif %} {% if closedOrganisations.length > 0 %}
From 08be04de4dce1949186af22e479199a513cb6833 Mon Sep 17 00:00:00 2001 From: Caitlin Roach Date: Mon, 13 Jul 2026 13:57:29 +0100 Subject: [PATCH 2/2] Added pagination to pharmacies page when there are more than 50 pharmacies --- app/routes/pharmacies.js | 12 ++++++++++- app/views/pharmacies/index.html | 35 +++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/routes/pharmacies.js b/app/routes/pharmacies.js index 0dbe4bc2..20638aa4 100644 --- a/app/routes/pharmacies.js +++ b/app/routes/pharmacies.js @@ -160,6 +160,8 @@ const renderAddUserPermissionLevelPage = (res, organisation, existingUser, error module.exports = router => { router.get('/pharmacies', (req, res) => { + const perPage = 50 + const requestedPage = parseInt(req.query.page, 10) || 1 const data = req.session.data const added = req.query.added const deleted = req.query.deleted === 'true' @@ -171,8 +173,13 @@ module.exports = router => { const allOrganisations = data.organisations.filter((organisation) => organisation.companyId === companyId).sort(sortByNameThenPostcode()) // Separate active/deactivated pharmacies from closed ones - const organisations = allOrganisations.filter((org) => org.status !== 'Closed') + const activeOrganisations = allOrganisations.filter((org) => org.status !== 'Closed') const closedOrganisations = allOrganisations.filter((org) => org.status === 'Closed') + const totalOrganisations = activeOrganisations.length + const totalPages = Math.max(1, Math.ceil(totalOrganisations / perPage)) + const page = Math.min(Math.max(requestedPage, 1), totalPages) + const indexStartFrom = (page - 1) * perPage + const organisations = activeOrganisations.slice(indexStartFrom, indexStartFrom + perPage) let organisationUserCounts = {} @@ -188,6 +195,9 @@ module.exports = router => { organisations, closedOrganisations, organisationUserCounts, + page, + totalOrganisations, + totalPages, added, deleted, deletedName, diff --git a/app/views/pharmacies/index.html b/app/views/pharmacies/index.html index 338f56d7..596f0bb1 100644 --- a/app/views/pharmacies/index.html +++ b/app/views/pharmacies/index.html @@ -49,9 +49,9 @@

Pharmacies

{% if (organisations | length) > 0 %} - +
Pharmacies added ({{ organisations | length }})Pharmacies added ({{ totalOrganisations }})
- {% if (organisations | length) > 10 %} + {% if totalOrganisations > 10 %}
@@ -107,6 +107,37 @@

Pharmacies

+ + {% if totalPages > 1 %} + {% set items = [] %} + {% set ellipsisAdded = false %} + + {%- for i in range(1, totalPages + 1) -%} + {% if i == 1 or i == (page - 1) or i == page or i == (page + 1) or i == totalPages %} + {% set items = (items.push({ + number: i, + href: "/pharmacies?page=" + i, + current: (i === page) + }), items) %} + {% set ellipsisAdded = false %} + {% elif ellipsisAdded == false %} + {% set items = (items.push({ + ellipsis: true + }), items) %} + {% set ellipsisAdded = true %} + {% endif %} + {%- endfor %} + + {{ pagination({ + previous: { + href: "/pharmacies?page=" + (page - 1) + } if page != 1, + next: { + href: "/pharmacies?page=" + (page + 1) + } if page != totalPages, + items: items + }) }} + {% endif %} {% endif %} {% if closedOrganisations.length > 0 %}