-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor placement-request page information #2280
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Factory } from 'fishery' | ||
import { faker } from '@faker-js/faker/locale/en_GB' | ||
|
||
import type { OfflineApplication } from '@approved-premises/api' | ||
|
||
import { fullPersonFactory, restrictedPersonFactory } from './person' | ||
import { DateFormats } from '../../utils/dateUtils' | ||
|
||
class OfflineApplicationFactory extends Factory<OfflineApplication> {} | ||
|
||
export default OfflineApplicationFactory.define(() => ({ | ||
type: 'CAS1', | ||
id: faker.string.uuid(), | ||
person: faker.helpers.arrayElement([fullPersonFactory.build(), restrictedPersonFactory.build()]), | ||
createdAt: DateFormats.dateObjToIsoDateTime(faker.date.past()), | ||
})) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import { placementRequirementsRow } from '../placementRequests/placementRequirem | |
import { allReleaseTypes } from '../applications/releaseTypeUtils' | ||
import { placementDates } from './placementDates' | ||
import { occupancyCriteriaMap } from './occupancy' | ||
import paths from '../../paths/apply' | ||
|
||
export { placementDates } from './placementDates' | ||
export { occupancySummary } from './occupancySummary' | ||
|
@@ -181,14 +182,12 @@ export const occupancyViewSummaryListForMatchingDetails = ( | |
): Array<SummaryListItem> => { | ||
const placementRequestDates = placementDates(placementRequest.expectedArrival, placementRequest.duration) | ||
const essentialCharacteristics = filterOutAPTypes(placementRequest.essentialCriteria) | ||
const application = placementRequest.application as ApprovedPremisesApplication | ||
|
||
return [ | ||
arrivalDateRow(placementRequestDates.startDate), | ||
departureDateRow(placementRequestDates.endDate), | ||
placementLengthRow(placementRequestDates.placementLength), | ||
releaseTypeRow(placementRequest), | ||
licenceExpiryDateRow(application), | ||
licenceExpiryDateRow(placementRequest), | ||
totalCapacityRow(totalCapacity), | ||
apManagerDetailsRow(managerDetails), | ||
spaceRequirementsRow(essentialCharacteristics), | ||
|
@@ -244,6 +243,15 @@ export const arrivalDateRow = (arrivalDate: string) => ({ | |
}, | ||
}) | ||
|
||
export const requestedOrEstimatedArrivalDateRow = (isParole: boolean, arrivalDate: string) => ({ | ||
key: { | ||
text: isParole ? 'Estimated arrival date' : 'Requested arrival date', | ||
}, | ||
value: { | ||
text: DateFormats.isoDateToUIDate(arrivalDate), | ||
}, | ||
}) | ||
|
||
export const departureDateRow = (departureDate: string) => ({ | ||
key: { | ||
text: 'Expected departure date', | ||
|
@@ -280,6 +288,31 @@ export const apTypeRow = (apType: ApType) => ({ | |
}, | ||
}) | ||
|
||
export const apTypeWithViewTimelineActionRow = (placementRequest: PlacementRequestDetail) => { | ||
const apTypeItem = { | ||
key: { | ||
text: 'Type of AP', | ||
}, | ||
value: { | ||
text: apTypeLabels[placementRequest.type], | ||
}, | ||
} | ||
if (placementRequest.application) { | ||
return { | ||
...apTypeItem, | ||
actions: { | ||
items: [ | ||
{ | ||
href: `${paths.applications.show({ id: placementRequest.application.id })}?tab=timeline`, | ||
text: 'View timeline', | ||
}, | ||
], | ||
}, | ||
} | ||
} | ||
return apTypeItem | ||
} | ||
|
||
export const addressRow = (spaceSearchResult: SpaceSearchResult) => ({ | ||
key: { | ||
text: 'Address', | ||
|
@@ -376,14 +409,21 @@ export const releaseTypeRow = (placementRequest: PlacementRequest) => ({ | |
}, | ||
}) | ||
|
||
export const licenceExpiryDateRow = (application: ApprovedPremisesApplication) => ({ | ||
key: { | ||
text: 'Licence expiry date', | ||
}, | ||
value: { | ||
text: application.licenceExpiryDate ? DateFormats.isoDateToUIDate(application.licenceExpiryDate) : '', | ||
}, | ||
}) | ||
export const licenceExpiryDateRow = (placementRequest: PlacementRequestDetail) => { | ||
let licenceExpiryDate: string | undefined | ||
if (placementRequest.application && 'licenceExpiryDate' in placementRequest.application) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the integration tests saved my neck here as the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
const application = placementRequest.application as ApprovedPremisesApplication | ||
licenceExpiryDate = application.licenceExpiryDate | ||
} | ||
return { | ||
key: { | ||
text: 'Licence expiry date', | ||
}, | ||
value: { | ||
text: licenceExpiryDate ? DateFormats.isoDateToUIDate(licenceExpiryDate) : '', | ||
}, | ||
} | ||
} | ||
|
||
export const startDateObjFromParams = (params: { startDate: string } | ObjectWithDateParts<'startDate'>) => { | ||
if (params['startDate-day'] && params['startDate-month'] && params['startDate-year']) { | ||
|
@@ -444,9 +484,9 @@ export const lengthOfStayRow = (lengthInDays: number) => ({ | |
}, | ||
}) | ||
|
||
export const postcodeRow = (postcodeDistrict: PlacementRequestDetail['location']) => ({ | ||
export const preferredPostcodeRow = (postcodeDistrict: PlacementRequestDetail['location']) => ({ | ||
key: { | ||
text: 'Postcode', | ||
text: 'Preferred postcode', | ||
}, | ||
value: { | ||
text: postcodeDistrict, | ||
|
@@ -464,7 +504,7 @@ export const placementRequestSummaryListForMatching = (placementRequest: Placeme | |
DateFormats.dateObjToIsoDate(calculateDepartureDate(placementRequest.expectedArrival, placementRequest.duration)), | ||
), | ||
lengthOfStayRow(placementRequest.duration), | ||
postcodeRow(placementRequest.location), | ||
preferredPostcodeRow(placementRequest.location), | ||
apTypeRow(placementRequest.type), | ||
] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
justification for this test case is in a comment in the
index.ts
file of this PR