UNPKG

@ministryofjustice/hmpps-digital-prison-reporting-frontend

Version:

The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.

31 lines (26 loc) 961 B
import { RequestHandler } from 'express' import { Services } from '../../../../../types/Services' import SyncReportUtils from './utils' import ErrorSummaryUtils from '../../../../../components/error-summary/utils' export default class ViewSyncReportController { layoutPath: string services: Services constructor(layoutPath: string, services: Services) { this.layoutPath = layoutPath this.services = services } GET: RequestHandler = async (req, res, next) => { try { const renderData = await SyncReportUtils.getReport({ req, res, services: this.services }) res.render(`dpr/routes/journeys/view-report/report`, { layoutPath: this.layoutPath, ...renderData, }) } catch (error) { req.body.title = `Report Failed` req.body.errorDescription = 'We were unable to show this report for the following reason:' req.body.error = ErrorSummaryUtils.handleError(error) next() } } }