'use strict';

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

var node = require('@sentry/node');
var ErrorHandler = require('../../../../utils/ErrorHandler/ErrorHandler.js');
var utils = require('../../../../components/user-reports/utils.js');
var filtersTypeEnum = require('../../../../components/_filters/filtersTypeEnum.js');
var personalisationUtils = require('../../../../utils/Personalisation/personalisationUtils.js');

class AsyncController {
    layoutPath;
    services;
    constructor(layoutPath, services) {
        this.layoutPath = layoutPath;
        this.services = services;
    }
    POST = async (req, res, _next) => {
        try {
            const response = await utils.default.updateExpiredStatus({
                req,
                res,
                services: this.services,
            });
            res.send({ isExpired: response });
        }
        catch (error) {
            node.captureException(error);
            res.send({ status: 'FAILED' });
        }
    };
    saveDefaultFilterValues = async (req, res, next) => {
        try {
            personalisationUtils.default.saveDefaults(filtersTypeEnum.FiltersType.INTERACTIVE, res, req, this.services);
            res.redirect(`${req.baseUrl}?defaultsSaved=true`);
        }
        catch (error) {
            req.body = {
                title: 'Failed to save defaults',
                error: new ErrorHandler.ErrorHandler(error).formatError(),
                ...(req.body && { ...req.body }),
            };
            next(error);
        }
    };
    removeDefaultFilterValues = async (req, res, next) => {
        try {
            personalisationUtils.default.removeDefaults(filtersTypeEnum.FiltersType.INTERACTIVE, res, req, this.services);
            res.redirect(req.baseUrl);
        }
        catch (error) {
            req.body = {
                title: 'Failed to remove defaults',
                error: new ErrorHandler.ErrorHandler(error).formatError(),
                ...(req.body && { ...req.body }),
            };
            next(error);
        }
    };
}

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