import { ErrorHandler } from '../../../../utils/ErrorHandler/ErrorHandler.js';
import { FiltersType } from '../../../../components/_filters/filtersTypeEnum.js';
import PersonalisationUtils from '../../../../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.saveDefaults(FiltersType.INTERACTIVE, res, req, this.services);
            res.redirect(req.baseUrl);
        }
        catch (error) {
            req.body = {
                title: 'Failed to save defaults',
                error: new ErrorHandler(error).formatError(),
                ...(req.body && { ...req.body }),
            };
            next(error);
        }
    };
    removeDefaultFilterValues = async (req, res, next) => {
        try {
            await PersonalisationUtils.removeDefaults(FiltersType.INTERACTIVE, res, req, this.services);
            res.redirect(req.baseUrl);
        }
        catch (error) {
            req.body = {
                title: 'Failed to remove defaults',
                error: new ErrorHandler(error).formatError(),
                ...(req.body && { ...req.body }),
            };
            next(error);
        }
    };
}

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