Skip to content

Commit

Permalink
MAN-217: Added initial Risk screen changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcphee77 committed Dec 19, 2024
1 parent 295f852 commit fce55a3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions assets/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ $govuk-page-width: $moj-page-width;
@import './components/card';
@import 'assets/scss/local';
@import './components/sortable-table';
@import '../../node_modules/govuk-frontend/dist/govuk/base';
@import '../../node_modules/@ministryofjustice/frontend/moj/components/sortable-table/_sortable-table';
@import "../../node_modules/govuk-frontend/dist/govuk/base";
@import "../../node_modules/@ministryofjustice/frontend/moj/components/sortable-table/_sortable-table";
@import './components/mappa-widget';
Expand Down
2 changes: 1 addition & 1 deletion server/data/arnsApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import config from '../config'
// eslint-disable-next-line import/no-cycle
import RestClient from './restClient'
import { ErrorSummary, ErrorSummaryItem } from './model/common'
import { RiskScoresDto, RoshRiskWidgetDto, RsrPredictorDto } from './model/risk'
import { RiskScoresDto } from './model/risk'

export default class ArnsApiClient extends RestClient {
constructor(token: string) {
Expand Down
6 changes: 3 additions & 3 deletions server/routes/risks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { v4 } from 'uuid'
import asyncMiddleware from '../middleware/asyncMiddleware'
import type { Services } from '../services'
import MasApiClient from '../data/masApiClient'
import ArnsApiClient, { RiskSummary } from '../data/arnsApiClient'
import ArnsApiClient from '../data/arnsApiClient'
import TierApiClient from '../data/tierApiClient'
import { RiskScoresDto, RsrPredictorDto, TimelineItem } from '../data/model/risk'
import { dateWithYearShortMonthAndTime, getLatest, toDate, toRoshWidget, toTimeline } from '../utils/utils'
import { TimelineItem } from '../data/model/risk'
import { toRoshWidget, toTimeline } from '../utils/utils'

export default function risksRoutes(router: Router, { hmppsAuthClient }: Services) {
const get = (path: string | string[], handler: RequestHandler) => router.get(path, asyncMiddleware(handler))
Expand Down
4 changes: 2 additions & 2 deletions server/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export const decorateFormAttributes = (req: Request, res: Response) => (obj: any
}

export const toTimeline = (riskScores: RiskScoresDto[]): TimelineItem[] => {
const sorted = riskScores.sort((a, b) => +toDate(b.completedDate) - +toDate(a.completedDate))
const sorted = [...riskScores].sort((a, b) => +toDate(b.completedDate) - +toDate(a.completedDate))
return sorted.map(riskScore => {
const scores = {
RSR: {
Expand Down Expand Up @@ -606,7 +606,7 @@ export const toTimeline = (riskScores: RiskScoresDto[]): TimelineItem[] => {

export const getLatest = (predictors: RiskScoresDto[]): RiskScoresDto => {
if (predictors.length > 0) {
return predictors.sort((a, b) => +toDate(b.completedDate) - +toDate(a.completedDate))[0]
return [...predictors].sort((a, b) => +toDate(b.completedDate) - +toDate(a.completedDate))[0]
}
return null
}
Expand Down

0 comments on commit fce55a3

Please sign in to comment.