diff --git a/integration_tests/pages/match/searchPage.ts b/integration_tests/pages/match/searchPage.ts index cdbd16092..b7e9abe77 100644 --- a/integration_tests/pages/match/searchPage.ts +++ b/integration_tests/pages/match/searchPage.ts @@ -45,15 +45,11 @@ export default class SearchPage extends Page { } changeSearchParameters(newSearchParameters: SpaceSearchParametersUi): void { - this.clearDateInputs('startDate') - this.completeDateInputs('startDate', newSearchParameters.startDate) - this.getTextInputByIdAndClear('targetPostcodeDistrict') this.getTextInputByIdAndEnterDetails('targetPostcodeDistrict', newSearchParameters.targetPostcodeDistrict) cy.get('[type="checkbox"]').uncheck() this.checkRadioByNameAndValue('requirements[apType]', newSearchParameters.requirements.apType) - this.checkRadioByNameAndValue('requirements[gender]', newSearchParameters.requirements.gender) newSearchParameters.requirements.spaceCharacteristics.forEach(requirement => { cy.get(`input[name="requirements[spaceCharacteristics][]"][value="${requirement}"]`).check() @@ -61,11 +57,9 @@ export default class SearchPage extends Page { } shouldShowSearchParametersInInputs(newSearchParameters: SpaceSearchParametersUi): void { - this.dateInputsShouldContainDate('startDate', newSearchParameters.startDate) this.verifyTextInputContentsById('targetPostcodeDistrict', newSearchParameters.targetPostcodeDistrict) cy.get(`input[name="requirements[apType]"][value="${newSearchParameters.requirements.apType}"]`) - cy.get(`input[name="requirements[gender]"][value="${newSearchParameters.requirements.gender}"]`) newSearchParameters.requirements.spaceCharacteristics.forEach(requirement => { cy.get(`input[name="requirements[spaceCharacteristics][]"][value="${requirement}"]`).should('be.checked') diff --git a/integration_tests/tests/match/match.cy.ts b/integration_tests/tests/match/match.cy.ts index a43ae7183..9d5adfc53 100644 --- a/integration_tests/tests/match/match.cy.ts +++ b/integration_tests/tests/match/match.cy.ts @@ -99,7 +99,6 @@ context('Placement Requests', () => { targetPostcodeDistrict: placementRequest.location, requirements: { apTypes: [placementRequest.type], - genders: [placementRequest.gender], spaceCharacteristics: filteredPlacementCriteria, }, }) @@ -108,7 +107,7 @@ context('Placement Requests', () => { expect(secondSearchRequestBody).to.contain({ applicationId: placementRequest.applicationId, durationInDays: placementRequest.duration, - startDate: newSearchParameters.startDate, + startDate: placementRequest.expectedArrival, targetPostcodeDistrict: newSearchParameters.targetPostcodeDistrict, }) @@ -116,7 +115,6 @@ context('Placement Requests', () => { expect(secondSearchRequestBody.requirements.spaceCharacteristics).to.contain.members( newSearchParameters.requirements.spaceCharacteristics, ) - expect(secondSearchRequestBody.requirements.genders).to.contain.members([newSearchParameters.requirements.gender]) }) }) diff --git a/server/@types/ui/index.d.ts b/server/@types/ui/index.d.ts index 1ce5bb506..0838d8a2f 100644 --- a/server/@types/ui/index.d.ts +++ b/server/@types/ui/index.d.ts @@ -13,7 +13,6 @@ import { Cas1PremisesBasicSummary, Document, FlagsEnvelope, - Gender, Mappa, OASysSection, PersonAcctAlert, @@ -110,7 +109,7 @@ export type TableCell = export type TableRow = Array -export interface RadioItem { +export type RadioItem = { text: string value: string checked?: boolean @@ -130,9 +129,9 @@ export type CheckBoxItem = } behaviour?: 'exclusive' } - | CheckBoxDivider + | Divider -export type CheckBoxDivider = { divider: string } +export type Divider = { divider: string } export interface SelectOption { text: string @@ -384,8 +383,7 @@ export interface SpaceSearchParametersUi { durationInDays: string requirements: { apType: ApType - gender: Gender - spaceCharacteristics: Array + spaceCharacteristics: Array } } diff --git a/server/controllers/match/search/spaceSearchController.ts b/server/controllers/match/search/spaceSearchController.ts index a22e7806c..24478669c 100644 --- a/server/controllers/match/search/spaceSearchController.ts +++ b/server/controllers/match/search/spaceSearchController.ts @@ -6,7 +6,6 @@ import matchPaths from '../../../paths/match' import { PlacementRequestService } from '../../../services' import SpaceService from '../../../services/spaceService' -import { startDateObjFromParams } from '../../../utils/match' import { objectIfNotEmpty } from '../../../utils/utils' export default class SpaceSearchController { @@ -28,8 +27,6 @@ export default class SpaceSearchController { ...body, } - params.startDate = startDateObjFromParams(params).startDate - const tier = placementRequest?.risks?.tier?.value?.level || 'N/A' const spaceSearchResults = await this.spaceService.search(req.user.token, params) @@ -40,7 +37,6 @@ export default class SpaceSearchController { tier, formPath: matchPaths.v2Match.placementRequests.search.spaces({ id: placementRequest.id }), ...params, - ...startDateObjFromParams(params), }) } } diff --git a/server/form-pages/assess/matchingInformation/matchingInformationTask/matchingInformation.ts b/server/form-pages/assess/matchingInformation/matchingInformationTask/matchingInformation.ts index a86f4a731..1d88ed742 100644 --- a/server/form-pages/assess/matchingInformation/matchingInformationTask/matchingInformation.ts +++ b/server/form-pages/assess/matchingInformation/matchingInformationTask/matchingInformation.ts @@ -160,9 +160,9 @@ export default class MatchingInformation implements TasklistPage { this.placementRequirementCriteria.forEach(placementRequirementCriterion => { if (!this.body[placementRequirementCriterion]) { - errors[placementRequirementCriterion] = `You must specify a preference for ${lowerCase( - placementCriteriaLabels[placementRequirementCriterion], - )}` + errors[placementRequirementCriterion] = `You must specify a preference for ${placementCriteriaLabels[ + placementRequirementCriterion + ].toLowerCase()}` } }) diff --git a/server/testutils/factories/spaceSearchParameters.ts b/server/testutils/factories/spaceSearchParameters.ts index 9f12ee4ec..28fd91a59 100644 --- a/server/testutils/factories/spaceSearchParameters.ts +++ b/server/testutils/factories/spaceSearchParameters.ts @@ -36,8 +36,6 @@ export const spaceSearchParametersUiFactory = Factory.define { apType: 'isESAP', isWheelchairDesignated: 'essential', isStepFreeDesignated: 'essential', - isCatered: 'essential', acceptsSexOffenders: 'relevant', acceptsChildSexOffenders: 'relevant', acceptsNonSexualChildOffenders: 'relevant', - isArsonSuitable: 'relevant', - acceptsHateCrimeOffenders: 'relevant', isSuitableForVulnerable: 'relevant', }) @@ -153,12 +150,9 @@ describe('acceptanceData', () => { 'isESAP', 'isWheelchairDesignated', 'isStepFreeDesignated', - 'isCatered', 'acceptsSexOffenders', 'acceptsChildSexOffenders', 'acceptsNonSexualChildOffenders', - 'isArsonSuitable', - 'acceptsHateCrimeOffenders', 'isSuitableForVulnerable', 'isSuitedForSexOffenders', ].sort(), @@ -170,14 +164,11 @@ describe('acceptanceData', () => { apType: 'normal', isWheelchairDesignated: 'desirable', isStepFreeDesignated: 'desirable', - isCatered: 'desirable', }) const result = criteriaFromMatchingInformation(matchingInformation) - expect(result.desirableCriteria.sort()).toEqual( - ['isStepFreeDesignated', 'isWheelchairDesignated', 'isCatered'].sort(), - ) + expect(result.desirableCriteria.sort()).toEqual(['isStepFreeDesignated', 'isWheelchairDesignated'].sort()) expect(result.essentialCriteria).toEqual([]) }) @@ -190,8 +181,6 @@ describe('acceptanceData', () => { acceptsSexOffenders: 'notRelevant', acceptsChildSexOffenders: 'notRelevant', acceptsNonSexualChildOffenders: 'notRelevant', - isArsonSuitable: 'notRelevant', - acceptsHateCrimeOffenders: 'notRelevant', isSuitableForVulnerable: 'notRelevant', }) diff --git a/server/utils/match/index.test.ts b/server/utils/match/index.test.ts index f1d11b29c..394490645 100644 --- a/server/utils/match/index.test.ts +++ b/server/utils/match/index.test.ts @@ -91,7 +91,6 @@ describe('matchUtils', () => { durationInDays: Number(uiParams.durationInDays), requirements: { apTypes: [uiParams.requirements.apType], - genders: [uiParams.requirements.gender], spaceCharacteristics: uiParams.requirements.spaceCharacteristics, }, applicationId: uiParams.applicationId, @@ -287,11 +286,11 @@ describe('matchUtils', () => { describe('groupedCheckboxes', () => { it('returns checkboxes grouped by category', () => { expect(groupedCheckboxes()).toEqual({ - 'Risks and offences': { + 'AP requirements': { inputName: 'spaceCharacteristics', items: groupedCriteria.offenceAndRisk.items, }, - 'Access needs and additional features': { + 'Room requirements': { inputName: 'spaceCharacteristics', items: groupedCriteria.accessNeeds.items, }, @@ -661,6 +660,7 @@ describe('matchUtils', () => { text: 'Standard AP', value: 'normal', }, + { divider: 'or' }, { checked: false, conditional: undefined, diff --git a/server/utils/match/index.ts b/server/utils/match/index.ts index c0925f241..ebd58655e 100644 --- a/server/utils/match/index.ts +++ b/server/utils/match/index.ts @@ -12,9 +12,10 @@ import type { Cas1SpaceSearchParameters as SpaceSearchParameters, Cas1SpaceSearchResult as SpaceSearchResult, } from '@approved-premises/api' -import type { +import { KeyDetailsArgs, ObjectWithDateParts, + RadioItem, SpaceSearchParametersUi, SummaryListItem, } from '@approved-premises/ui' @@ -23,9 +24,9 @@ import { DateFormats, daysToWeeksAndDays } from '../dateUtils' import { createQueryString, sentenceCase } from '../utils' import matchPaths from '../../paths/match' import { - offenceAndRiskCriteriaLabels, placementCriteriaLabels, - placementRequirementCriteriaLabels, + spaceSearchCriteriaApLevelLabels, + spaceSearchCriteriaRoomLevelLabels, } from '../placementCriteriaUtils' import { apTypeLabels } from '../apTypeLabels' import { convertKeyValuePairToRadioItems, summaryListItem } from '../formUtils' @@ -57,7 +58,6 @@ export const mapUiParamsForApi = (query: SpaceSearchParametersUi): SpaceSearchPa targetPostcodeDistrict: query.targetPostcodeDistrict, requirements: { apTypes: [query.requirements.apType], - genders: [query.requirements.gender], spaceCharacteristics: query.requirements.spaceCharacteristics, }, durationInDays: Number(query.durationInDays), @@ -434,13 +434,13 @@ export const startDateObjFromParams = (params: { startDate: string } | ObjectWit export const groupedCriteria = { offenceAndRisk: { - title: 'Risks and offences', - items: offenceAndRiskCriteriaLabels, + title: 'AP requirements', + items: spaceSearchCriteriaApLevelLabels, inputName: 'spaceCharacteristics', }, accessNeeds: { - title: 'Access needs and additional features', - items: placementRequirementCriteriaLabels, + title: 'Room requirements', + items: spaceSearchCriteriaRoomLevelLabels, inputName: 'spaceCharacteristics', }, } @@ -469,7 +469,11 @@ export const checkBoxesForCriteria = (criteria: Record, selected } export const apTypeLabelsForRadioInput = (selectedValue: ApType) => { - return convertKeyValuePairToRadioItems(apTypeLabels, selectedValue) + const apTypeRadios = convertKeyValuePairToRadioItems(apTypeLabels, selectedValue) as Array< + RadioItem | { divider: 'or' } + > + apTypeRadios.splice(1, 0, { divider: 'or' }) + return apTypeRadios } export const lengthOfStayRow = (lengthInDays: number) => ({ diff --git a/server/utils/placementCriteriaUtils.ts b/server/utils/placementCriteriaUtils.ts index 5ec28f113..fced65c09 100644 --- a/server/utils/placementCriteriaUtils.ts +++ b/server/utils/placementCriteriaUtils.ts @@ -77,11 +77,20 @@ export const apTypeCriteriaLabels: Record = { normal: 'Standard AP', ...specialistApTypeCriteriaLabels, } -export const offenceAndRiskCriteriaLabels = filterByType( - offenceAndRiskCriteria, - placementCriteriaLabels, -) -export const placementRequirementCriteriaLabels = filterByType( - placementRequirementCriteria, - placementCriteriaLabels, -) + +export const spaceSearchCriteriaApLevelLabels = { + acceptsSexOffenders: 'Sexual offences against adults', + acceptsChildSexOffenders: 'Sexual offences against children', + acceptsNonSexualChildOffenders: 'Non sexual offences against children', + isSuitableForVulnerable: 'Vulnerable to exploitation (removes ESAP APs)', + isCatered: 'Catered', +} + +export const spaceSearchCriteriaRoomLevelLabels = { + isWheelchairDesignated: 'Wheelchair', + isStepFreeDesignated: 'Step-free', + hasEnSuite: 'En-suite', + isSingle: 'Single room', + isArsonSuitable: 'Arson room', + isSuitedForSexOffenders: 'Suitable for sexual offences', +} diff --git a/server/utils/placementRequests/utils.test.ts b/server/utils/placementRequests/utils.test.ts index 8b0b55aa7..a976a24f3 100644 --- a/server/utils/placementRequests/utils.test.ts +++ b/server/utils/placementRequests/utils.test.ts @@ -34,7 +34,6 @@ describe('utils', () => { ...placementRequest.essentialCriteria, ]), apType: placementRequest.type, - gender: placementRequest.gender, }, }) }) diff --git a/server/utils/placementRequests/utils.ts b/server/utils/placementRequests/utils.ts index 9a6f91628..408f13d31 100644 --- a/server/utils/placementRequests/utils.ts +++ b/server/utils/placementRequests/utils.ts @@ -18,7 +18,6 @@ export const mapPlacementRequestToSpaceSearchParams = ({ essentialCriteria, desirableCriteria, type, - gender, }: PlacementRequest): SpaceSearchParametersUi => { return { applicationId, @@ -28,7 +27,6 @@ export const mapPlacementRequestToSpaceSearchParams = ({ requirements: { spaceCharacteristics: filterOutAPTypes([...desirableCriteria, ...essentialCriteria]), apType: type, - gender, }, } } diff --git a/server/views/match/search.njk b/server/views/match/search.njk index 0725eb748..4dc60749b 100644 --- a/server/views/match/search.njk +++ b/server/views/match/search.njk @@ -21,6 +21,11 @@ }) }} {% endblock %} +{% set locationTitle %} + Preferred location +
For example, M5
+{% endset %} + {% block content %}
@@ -54,31 +59,29 @@
- {{ govukDateInput({ - id: "startDate", - namePrefix: "startDate", - fieldset: { - legend: { - text: "Available from", - classes: "govuk-fieldset__legend--s" - } + {% call govukFieldset({ + legend: { + html: locationTitle }, - items: dateFieldValues('startDate', errors), - errorMessage: errors.startDate - }) }} + hint: { + text: "For example, M5" + } + }) %} {{ govukInput({ id: "targetPostcodeDistrict", name: "targetPostcodeDistrict", value: targetPostcodeDistrict, label: { - text: "Preferred location", - classes: "govuk-fieldset__legend--s" - + text: "Postcode" }, classes: "govuk-input--width-3" }) }} + {% endcall %} + +
+ {{ govukRadios({ name: "requirements[apType]", classes: "govuk-radios--small", @@ -106,21 +109,7 @@ items: MatchUtils.checkBoxesForCriteria(details.items, context['requirements'][details.inputName]) }) }} {% endfor %} - - {{ govukRadios({ - name: "requirements[gender]", - classes: "govuk-radios--small", - value: requirements.gender, - fieldset: { - legend: { - text: 'Gender', - classes: 'govuk-fieldset__legend--s', - isPageHeading: false - } - }, - items: [{value: 'male', text: 'Male' }, {value: 'female', text: 'Female' }] - }) }} - +
{{ govukButton({ text: "Update",