'use strict';

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

var ErrorHandler = require('../../../../utils/ErrorHandler/ErrorHandler.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;
    }
    saveDefaultFilterValues = async (req, res, next) => {
        try {
            await personalisationUtils.default.saveDefaults(filtersTypeEnum.FiltersType.INTERACTIVE, res, req, this.services);
            res.redirect(req.baseUrl);
        }
        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 {
            await 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
