diff --git a/server/views/components/search-by-crn-or-name-form/macro.njk b/server/views/components/search-by-crn-or-name-form/macro.njk new file mode 100644 index 000000000..a652868fe --- /dev/null +++ b/server/views/components/search-by-crn-or-name-form/macro.njk @@ -0,0 +1,38 @@ +{% from "govuk/components/input/macro.njk" import govukInput %} +{% from "govuk/components/button/macro.njk" import govukButton %} + + +{# params - Type of Object - Description #} +{# uiStatus - String - Specific status the record would be in #} +{# type - String - Either "bookings" or "referrals" #} +{# basePath - String - URL used to define where form should be submitted to and the link the "Clear" should take the user too #} +{# crnOrName - String - Either a CRN or Name which the user would like to search for#} + + +{% macro searchByCrnOrNameForm(params) %} + {% set searchLabel = 'Search ' + params.uiStatus + ' ' + params.type + ' by CRN (case reference number)' %} + +
+{% endmacro %} diff --git a/server/views/components/search-by-crn-or-name-results/macro.njk b/server/views/components/search-by-crn-or-name-results/macro.njk new file mode 100644 index 000000000..f877005c3 --- /dev/null +++ b/server/views/components/search-by-crn-or-name-results/macro.njk @@ -0,0 +1,37 @@ +{%- from "moj/components/pagination/macro.njk" import mojPagination -%} + + +{# params - Type of Object - Description #} +{# errors - Object - Errors object from the view, soon to be removed #} +{# resultsHtml - String - HTML string containing the pagination and results. Currently parent view is responsible for this. We will look to moving that logic into this component #} +{# crnOrName - String - Either a CRN or Name which the user would like to search for #} +{# uiStatus - String - Specific status the record would be in #} +{# type - String - Either "bookings" or "referrals". #} + + +{% macro searchByCrnOrNameResults(params) %} + {% if params.errors.crn %} +Enter a CRN. This can be found in nDelius.
+ + {% elif (params.resultsHtml| trim |length > 0) or (not params.crnOrName) %} + {{ params.resultsHtml | safe | trim | indent(8)}} + + {% else %} +Check the other lists.
+ + {% if params.type === 'bookings' %} + {% set type_name = 'booking' %} + {% elif params.type ==='referrals' %} + {% set type_name = 'referral' %} + {% endif %} + ++ If the {{ type_name }} is missing from every list, contact + support for help. +
+ {% endif %} +{% endmacro %} diff --git a/server/views/temporary-accommodation/assessments/index.njk b/server/views/temporary-accommodation/assessments/index.njk index caa9aaca0..44f6d70f9 100644 --- a/server/views/temporary-accommodation/assessments/index.njk +++ b/server/views/temporary-accommodation/assessments/index.njk @@ -1,6 +1,7 @@ {% from "govuk/components/table/macro.njk" import govukTable %} {% from "govuk/components/button/macro.njk" import govukButton %} -{% from "govuk/components/input/macro.njk" import govukInput %} +{% from "../../components/search-by-crn-or-name-form/macro.njk" import searchByCrnOrNameForm%} +{% from "../../components/search-by-crn-or-name-results/macro.njk" import searchByCrnOrNameResults%} {% from "moj/components/sub-navigation/macro.njk" import mojSubNavigation %} {%- from "moj/components/pagination/macro.njk" import mojPagination -%} {% from "../../partials/breadCrumb.njk" import breadCrumb %} @@ -11,6 +12,24 @@ {% set pageTitle = title + " - " + applicationName %} {% set mainClasses = "app-container govuk-body" %} +{# TODO Move this HTML to the searchByCrnOrNameResult once HTML can be standardised between referrals and bookings #} +{% set resultsHtml %} + {% if (not context.errors.prn) and ((tableRows|length > 0) or (not crn)) %} +Enter a CRN. This can be found in nDelius.
- - {% elif (tableRows|length > 0) or (not crn) %} - -Check the other lists.
- -If the referral is missing from every list, contact - support for help.
- {% endif %} + {{ searchByCrnOrNameResults({ + type: 'referrals', + errors: context.errors, + uiStatus: uiStatus, + tableRows: tableRows, + resultsHtml: resultsHtml, + crnOrName: crn + })}} {% block archivedLink %}Enter a CRN. This can be found in nDelius.
- {% elif (response.data|length > 0) or (not crn) %} - {{ govukTable({ - captionClasses: "govuk-table__caption--m", - head: tableHeadings, - rows: response.data - }) }} - - {{ mojPagination(pagination) }} - {% else %} -Check the other lists.
- -If the booking is missing from every list, contact - support for help.
- {% endif %} {% endblock %}