'use strict';

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

var sessionHelper = require('../../../../../../utils/sessionHelper.js');
var localsHelper = require('../../../../../../utils/localsHelper.js');

class RequestDownloadSubmittedController {
    layoutPath;
    services;
    constructor(layoutPath, services) {
        this.layoutPath = layoutPath;
        this.services = services;
    }
    GET = async (req, res, _next) => {
        const { dprUser } = localsHelper.default.getValues(res);
        const { reportId, variantId, tableId } = req.params;
        const { reportName, variantName } = req.query;
        const currentReportUrl = sessionHelper.getActiveJourneyValue(req, { id: variantId, reportId, tableId }, 'currentReportUrl');
        let reportHref = currentReportUrl;
        if (reportHref) {
            reportHref = reportHref.replaceAll('/download-disabled', '');
        }
        await this.services.downloadPermissionService.saveDownloadPermissionData(dprUser.id, reportId, variantId);
        res.render(`dpr/routes/journeys/download-report/request-download/form/submitted/view`, {
            title: 'success',
            layoutPath: this.layoutPath,
            report: {
                reportName,
                variantName,
                reportHref,
            },
        });
    };
}

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