Skip to content

Commit 15a6726

Browse files
Add all clinics and today's clinics
1 parent 6423289 commit 15a6726

File tree

4 files changed

+89
-44
lines changed

4 files changed

+89
-44
lines changed

app/routes/clinics.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ function getClinicData(data, clinicId) {
3535
}
3636

3737
module.exports = router => {
38+
39+
router.get('/clinics/today', (req, res) => {
40+
res.render('clinics/today');
41+
});
42+
3843
// Single clinic view
3944
router.get('/clinics/:id', (req, res) => {
4045
const clinicData = getClinicData(req.session.data, req.params.id);

app/views/clinics.html

Lines changed: 0 additions & 44 deletions
This file was deleted.

app/views/clinics/index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
{% extends 'layout-app.html' %}
3+
4+
{% set pageHeading = "Today’s clinics" %}
5+
6+
7+
{% block pageContent %}
8+
<h1 class="nhsuk-heading-l">All clinics</h1>
9+
10+
{% if data.clinics.length === 0 %}
11+
<p class="nhsuk-body">No clinics found.</p>
12+
{% else %}
13+
<table class="nhsuk-table">
14+
<thead class="nhsuk-table__head">
15+
<tr>
16+
<th class="nhsuk-table__header">Date</th>
17+
<th class="nhsuk-table__header">Location</th>
18+
<th class="nhsuk-table__header">Actions</th>
19+
</tr>
20+
</thead>
21+
<tbody class="nhsuk-table__body">
22+
{% for clinic in data.clinics | sort(false, false, 'date') %}
23+
{% set unit = data.breastScreeningUnits | findById(clinic.breastScreeningUnitId) %}
24+
{% set events = data.events | getClinicEvents(clinic.id) %}
25+
<tr class="nhsuk-table__row">
26+
<td class="nhsuk-table__cell">{{ clinic.date | formatDate }}</td>
27+
<td class="nhsuk-table__cell">{{ unit.name }}</td>
28+
<td class="nhsuk-table__cell">
29+
<a href="/clinics/{{ clinic.id }}" class="nhsuk-link">View clinic</a>
30+
({{ events.length }} participants)
31+
</td>
32+
</tr>
33+
{% endfor %}
34+
</tbody>
35+
</table>
36+
{% endif %}
37+
38+
<p class="nhsuk-body">
39+
<a href="/clinics/today" class="nhsuk-link">View today's clinics</a>
40+
</p>
41+
{% endblock %}

app/views/clinics/today.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
{% extends 'layout-app.html' %}
3+
4+
{% set pageHeading = "Today’s clinics" %}
5+
6+
7+
{% block pageContent %}
8+
{% set todaysClinics = data.clinics | getTodaysClinics %}
9+
10+
<h1 class="nhsuk-heading-l">Today's clinics</h1>
11+
12+
{% if todaysClinics.length === 0 %}
13+
<p class="nhsuk-body">No clinics scheduled for today.</p>
14+
{% else %}
15+
<table class="nhsuk-table">
16+
<thead class="nhsuk-table__head">
17+
<tr>
18+
<th class="nhsuk-table__header">Location</th>
19+
<th class="nhsuk-table__header">Time</th>
20+
<th class="nhsuk-table__header">Actions</th>
21+
</tr>
22+
</thead>
23+
<tbody class="nhsuk-table__body">
24+
{% for clinic in todaysClinics %}
25+
{% set unit = data.breastScreeningUnits | findById(clinic.breastScreeningUnitId) %}
26+
{% set events = data.events | getClinicEvents(clinic.id) %}
27+
<tr class="nhsuk-table__row">
28+
<td class="nhsuk-table__cell">{{ unit.name }}</td>
29+
<td class="nhsuk-table__cell">{{ clinic.date | formatDate }}</td>
30+
<td class="nhsuk-table__cell">
31+
<a href="/clinics/{{ clinic.id }}" class="nhsuk-link">View clinic</a>
32+
({{ events.length }} participants)
33+
</td>
34+
</tr>
35+
{% endfor %}
36+
</tbody>
37+
</table>
38+
{% endif %}
39+
40+
<p class="nhsuk-body">
41+
<a href="/clinics" class="nhsuk-link">View all clinics</a>
42+
</p>
43+
{% endblock %}

0 commit comments

Comments
 (0)