import localsHelper from '../../../../utils/localsHelper.js';
import { safeRedirect } from '../../../../utils/http/safeRedirect.js';

class RecentlyViewedReportsController {
    services;
    constructor(services) {
        this.services = services;
    }
    POST = async (req, res) => {
        const { dprUser } = localsHelper.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(req, res, returnToWithTab);
    };
}

export { RecentlyViewedReportsController, RecentlyViewedReportsController as default };
//# sourceMappingURL=controller.js.map
