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.

57 lines (52 loc) 2.26 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var utils = require('./utils.js'); var ErrorHandler = require('../../../../utils/ErrorHandler/ErrorHandler.js'); var createReportPollingHandler = require('../../../../controllers/reportPolling/createReportPollingHandler.js'); var utils$1 = require('../../../../components/_async/async-polling/current-status/utils.js'); var captureError = require('../../../../utils/captureError.js'); class RequestStatusController { layoutPath; services; getCurrentStatus; constructor(layoutPath, services) { this.layoutPath = layoutPath; this.services = services; // Polling current status - render partial this.getCurrentStatus = createReportPollingHandler.createReportPollingHandler(this.services, (updated, resolution, req, res) => { const viewModel = utils$1.buildCurrentStatusView(updated, resolution.newStatus, res, req); return { template: 'dpr/components/_async/async-polling/current-status/view.njk', data: { data: viewModel }, }; }); } // Render status page GET = async (req, res, next) => { try { const pollingRenderData = await utils.initPollingView({ req, res, services: this.services, next, }); res.render(`dpr/routes/journeys/request-report/status/view`, { layoutPath: this.layoutPath, ...pollingRenderData, }); } catch (error) { const message = 'Failed to retrieve report status'; const { reportId, executionId, id, type } = req.params; captureError.captureDprError(error, message, { reportId, executionId, id, type }); req.body ??= {}; req.body.title = message; req.body.errorDescription = 'We were unable to retrieve the report status:'; req.body.error = new ErrorHandler.ErrorHandler(error).formatError(); next(error); } }; } exports.RequestStatusController = RequestStatusController; exports.default = RequestStatusController; //# sourceMappingURL=controller.js.map