'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var ErrorHandler = require('../../../../../utils/ErrorHandler/ErrorHandler.js');
var utils = require('./utils.js');
var utils$1 = require('../../utils.js');

class ViewSyncDashboardController {
    layoutPath;
    services;
    constructor(layoutPath, services) {
        this.layoutPath = layoutPath;
        this.services = services;
    }
    GET = async (req, res, next) => {
        try {
            const renderData = await utils.default.renderSyncDashboard({ req, res, services: this.services });
            res.render(`dpr/routes/journeys/view-report/dashboard`, {
                layoutPath: this.layoutPath,
                ...renderData,
            });
        }
        catch (error) {
            req.body ??= {};
            req.body.title = `Dashboard Failed`;
            req.body.errorDescription = 'We were unable to show this dashboard for the following reason:';
            req.body.error = new ErrorHandler.ErrorHandler(error).formatError();
            next(error);
        }
    };
    applyFilters = async (req, res, _next) => {
        await utils$1.default.applyDashboardInteractiveQuery(req, res, this.services, 'filters');
    };
}

exports.ViewSyncDashboardController = ViewSyncDashboardController;
exports.default = ViewSyncDashboardController;
//# sourceMappingURL=controller.js.map
