Skip to content

Commit

Permalink
content changes (#44)
Browse files Browse the repository at this point in the history
* feat: change view application page and status

* feat: bump version

* fix: tests

* fix: content and test
  • Loading branch information
shivanshuit914 authored Nov 11, 2022
1 parent 3bc5fce commit 38d5eb9
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 88 deletions.
3 changes: 3 additions & 0 deletions app/constants/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const status = {
APPLIED: {
styleClass: 'govuk-tag--green'
},
AGREED: {
styleClass: 'govuk-tag--green'
},
WITHDRAWN: {
styleClass: 'govuk-tag--grey'
},
Expand Down
15 changes: 7 additions & 8 deletions app/routes/models/application-claim.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
const { formatedDateToUk } = require('../../lib/display-helper')
const { formatedDateToUk, upperFirstLetter } = require('../../lib/display-helper')

module.exports = (application) => {
const { data } = application
const formatedDate = formatedDateToUk(application.updatedAt)
return {
head: [{ text: 'Date' }, { text: 'Data requested' }, { text: 'Data entered' }],
firstCellIsHeader: true,
rows: [
[{ text: formatedDate }, { text: 'Details correct?' }, { text: data?.confirmCheckDetails }],
[{ text: formatedDate }, { text: 'Date of review' }, { text: formatedDateToUk(data?.visitDate) }],
[{ text: formatedDate }, { text: 'Vet’s name' }, { text: data?.vetName }],
[{ text: formatedDate }, { text: 'Vet’s RCVS number' }, { text: data?.vetRcvs }],
[{ text: formatedDate }, { text: 'Unique reference number (URN)' }, { text: data?.urnResult }]
[{ text: 'Review details confirmed' }, { text: upperFirstLetter(data?.confirmCheckDetails) }],
[{ text: 'Date of review' }, { text: formatedDateToUk(data?.visitDate) }],
[{ text: 'Vet’s name' }, { text: data?.vetName }],
[{ text: 'Vet’s RCVS number' }, { text: data?.vetRcvs }],
[{ text: 'Unique reference number (URN)' }, { text: data?.urnResult }]
]
}
}
9 changes: 5 additions & 4 deletions app/routes/models/application-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class ViewModel {
const getApplicationTableHeader = (sortField) => {
const direction = sortField && sortField.direction === 'DESC' ? 'descending' : 'ascending'
const headerColumns = [{
text: 'Ref'
text: 'Agreement number'
},
{
text: 'Business'
text: 'Organisation'
}]
headerColumns.push({
text: 'SBI',
text: 'SBI number',
attributes: {
'aria-sort': sortField && sortField.field === 'SBI' ? direction : 'none',
'data-url': '/applications/sort/SBI'
Expand Down Expand Up @@ -66,6 +66,7 @@ async function createModel (request, page) {
if (apps.total > 0) {
let statusClass
const applications = apps.applications.map(n => {
n.status.status = n.status.status === 'APPLIED' ? 'AGREED' : n.status.status
statusClass = getStyleClassByStatus(n.status.status)
return [
{ text: n.reference },
Expand All @@ -90,7 +91,7 @@ async function createModel (request, page) {
'data-sort-value': `${n.status.status}`
}
},
{ html: `<a href="${serviceUri}/view-application/${n.reference}?page=${page}">View application</a>` }
{ html: `<a href="${serviceUri}/view-application/${n.reference}?page=${page}">View details</a>` }
]
})
const pagingData = getPagingData(apps.total ?? 0, limit, page, path)
Expand Down
1 change: 1 addition & 0 deletions app/routes/models/application-organisation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = (organisation) => {
return [
{ key: { text: 'Name:' }, value: { text: organisation?.farmerName } },
{ key: { text: 'SBI number:' }, value: { text: organisation?.sbi } },
{ key: { text: 'Address:' }, value: { text: organisation?.address } },
{ key: { text: 'Email address:' }, value: { text: organisation?.email } }
Expand Down
11 changes: 6 additions & 5 deletions app/routes/models/farmer-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ module.exports = (application) => {
const { data, createdAt } = application
const formatedDate = formatedDateToUk(createdAt)
return {
head: [{ text: 'Date' }, { text: 'Data requested' }, { text: 'Data entered' }],
firstCellIsHeader: true,
rows: [
[{ text: formatedDate }, { text: 'Detail correct?' }, { text: upperFirstLetter(data.confirmCheckDetails) }],
[{ text: formatedDate }, { text: 'Review type' }, { text: upperFirstLetter(data.whichReview) }],
[{ text: formatedDate }, { text: 'Livestock number' }, { text: speciesNumbers[data.whichReview] }],
[{ text: formatedDate }, { text: 'T&Cs agreed?' }, { text: data.declaration ? 'Yes' : 'No' }]
[{ text: 'Agreement formed' }, { text: formatedDate }],
[{ text: 'Business details correct' }, { text: upperFirstLetter(data.confirmCheckDetails) }],
[{ text: 'Type of review' }, { text: upperFirstLetter(data.whichReview) }],
[{ text: 'Number of livestock' }, { text: speciesNumbers[data.whichReview] }],
[{ text: 'Agreement accepted' }, { text: data.declaration ? 'Yes' : 'No' }]
]
}
}
4 changes: 3 additions & 1 deletion app/routes/view-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { getApplication } = require('../api/applications')
const { administrator, processor, user } = require('../auth/permissions')
const getStyleClassByStatus = require('../constants/status')
const ViewModel = require('./models/view-application')
const { upperFirstLetter } = require('../lib/display-helper')

module.exports = {
method: 'GET',
Expand All @@ -25,9 +26,10 @@ module.exports = {
}

const statusClass = getStyleClassByStatus(application.status.status)
const status = application.status.status === 'APPLIED' ? 'Agreed' : upperFirstLetter(application.status.status.toLowerCase())
return h.view('view-application', {
applicationId: application.reference,
status: application.status.status,
status,
statusClass,
organisationName: application?.data?.organisation?.name,
vetVisit: application?.vetVisit,
Expand Down
6 changes: 3 additions & 3 deletions app/views/applications.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<form method="POST" action="/applications">
<div class="govuk-grid-row govuk-!-padding-bottom-9">
<h1 class="govuk-heading-l">AHWR Applications</h1>
<h1 class="govuk-heading-l">Annual health and welfare review agreements</h1>
<div class="user-search-box govuk-!-width-two-thirds">
<label class="govuk-label govuk-label--s" for="user-search">
Search for an application by SBI number or reference or status
Expand Down Expand Up @@ -80,9 +80,9 @@
</div>

<div class="moj-filter-layout__content">
<div class="moj-action-bar">
{# <div class="moj-action-bar">
<div class="moj-action-bar__filter hide_pseudo_after"></div>
</div>
</div> #}
<div class="moj-scrollable-pane">

<div class="moj-scrollable-pane__wrapper">
Expand Down
4 changes: 2 additions & 2 deletions app/views/macros/view-application-tabs.njk
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<h2 class="govuk-heading-l">Claimed</h2>
{{ govukTable(model.claimData) }}
{% else %}
<h2 class="govuk-heading-l">Not yet able to claim</h2>
<h2 class="govuk-heading-l">Never claimed</h2>
{% endif %}
{% endset -%}

{{ govukTabs({
items: [
{
label: "Application",
label: "Agreement",
id: "application",
panel: {
html: applicationHtml
Expand Down
2 changes: 1 addition & 1 deletion app/views/view-application.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-caption-l govuk-!-margin-bottom-3">Application {{ applicationId }}</h1>
<h1 class="govuk-caption-l govuk-!-margin-bottom-3">Agreement number: {{ applicationId }}</h1>

<h2 class="govuk-fieldset__legend--m">{{ organisationName }}
<span class="govuk-tag {{ statusClass }}">{{ status }}</span></h2>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-ahwr-backoffice",
"version": "1.13.1",
"version": "1.14.0",
"description": "Back office of the health and welfare of your livestock",
"homepage": "https://github.com/DEFRA/ffc-ahwr-backoffice",
"main": "app/index.js",
Expand Down
4 changes: 4 additions & 0 deletions test/data/view-applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"name": "My Farm",
"email": "[email protected]",
"isTest": true,
"farmerName": "Farmer name",
"address": "Long dusty road, Middle-of-knowhere, In the countryside, CC33 3CC"
},
"eligibleSpecies": "yes",
Expand All @@ -34,6 +35,7 @@
"sbi": "333333333",
"name": "My Farm",
"email": "[email protected]",
"farmerName": "Farmer name",
"isTest": true,
"address": "Long dusty road, Middle-of-knowhere, In the countryside, CC33 3CC"
},
Expand All @@ -57,6 +59,7 @@
"sbi": "333333333",
"name": "My Farm",
"email": "[email protected]",
"farmerName": "Farmer name",
"isTest": true,
"address": "Long dusty road, Middle-of-knowhere, In the countryside, CC33 3CC"
},
Expand Down Expand Up @@ -85,6 +88,7 @@
"sbi": "333333333",
"name": "My Farm",
"email": "[email protected]",
"farmerName": "Farmer name",
"isTest": true,
"address": "Long dusty road, Middle-of-knowhere, In the countryside, CC33 3CC"
},
Expand Down
4 changes: 2 additions & 2 deletions test/integration/narrow/routes/applications.filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Applications Filter test', () => {
const res = await global.__SERVER__.inject(options)
expect(res.statusCode).toBe(200)
const $ = cheerio.load(res.payload)
expect($('h1.govuk-heading-l').text()).toEqual('AHWR Applications')
expect($('h1.govuk-heading-l').text()).toEqual('Annual health and welfare review agreements')
expect($('title').text()).toContain('AHWR Applications')
expect(sessionMock.getAppSearch).toHaveBeenCalledTimes(6)
expect(sessionMock.setAppSearch).toHaveBeenCalledTimes(1)
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('Applications Filter test', () => {
const res = await global.__SERVER__.inject(options)
expect(res.statusCode).toBe(200)
const $ = cheerio.load(res.payload)
expect($('h1.govuk-heading-l').text()).toEqual('AHWR Applications')
expect($('h1.govuk-heading-l').text()).toEqual('Annual health and welfare review agreements')
expect($('title').text()).toContain('AHWR Applications')
expect(sessionMock.getAppSearch).toHaveBeenCalledTimes(5)
expect(sessionMock.setAppSearch).toHaveBeenCalledTimes(1)
Expand Down
10 changes: 5 additions & 5 deletions test/integration/narrow/routes/applications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Applications test', () => {
const res = await global.__SERVER__.inject(options)
expect(res.statusCode).toBe(200)
const $ = cheerio.load(res.payload)
expect($('h1.govuk-heading-l').text()).toEqual('AHWR Applications')
expect($('h1.govuk-heading-l').text()).toEqual('Annual health and welfare review agreements')
expect($('title').text()).toContain('AHWR Applications')
expect(sessionMock.getAppSearch).toHaveBeenCalledTimes(5)
expectPhaseBanner.ok($)
Expand All @@ -57,9 +57,9 @@ describe('Applications test', () => {
const res = await global.__SERVER__.inject(options)
expect(res.statusCode).toBe(200)
const $ = cheerio.load(res.payload)
expect($('h1.govuk-heading-l').text()).toEqual('AHWR Applications')
expect($('h1.govuk-heading-l').text()).toEqual('Annual health and welfare review agreements')
expect($('title').text()).toContain('AHWR Applications')
expect($('span.govuk-tag--green').text()).toContain('APPLIED')
expect($('span.govuk-tag--green').text()).toContain('AGREED')
expect($('span.govuk-tag--yellow').text()).toContain('DATA INPUTTED')
expect($('span.govuk-tag--orange').text()).toContain('CHECK')
expect($('span.govuk-tag--blue').text()).toContain('PAID')
Expand Down Expand Up @@ -111,9 +111,9 @@ describe('Applications test', () => {
const res = await global.__SERVER__.inject(options)
expect(res.statusCode).toBe(200)
const $ = cheerio.load(res.payload)
expect($('h1.govuk-heading-l').text()).toEqual('AHWR Applications')
expect($('h1.govuk-heading-l').text()).toEqual('Annual health and welfare review agreements')
expect($('title').text()).toContain('AHWR Applications')
expect($('span.govuk-tag--green').text()).toContain('APPLIED')
expect($('span.govuk-tag--green').text()).toContain('AGREED')
expect($('span.govuk-tag--yellow').text()).toContain('DATA INPUTTED')
expect($('span.govuk-tag--orange').text()).toContain('CHECK')
expect($('span.govuk-tag--blue').text()).toContain('PAID')
Expand Down
Loading

0 comments on commit 38d5eb9

Please sign in to comment.