'use strict';

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

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

class RecentlyViewedReportsController {
    services;
    constructor(services) {
        this.services = services;
    }
    POST = async (req, res) => {
        const { dprUser } = localsHelper.default.getValues(res);
        const { id, reportId, tableId, executionId } = req.params;
        const { returnTo } = req.body;
        const returnToWithTab = `${returnTo}#recently-viewed-tab`;
        // Remove the report from recenly viewed list
        await this.services.recentlyViewedService.removeReport(dprUser.id, reportId, id, tableId);
        // And clean up the request data, if there is any
        if (executionId) {
            await this.services.requestedReportService.removeReport(executionId, dprUser.id);
        }
        return safeRedirect.safeRedirect(req, res, returnToWithTab);
    };
}

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