import { captureException } from '@sentry/node';
import { ErrorHandler } from '../../../../utils/ErrorHandler/ErrorHandler.js';
import UserReportsListUtils from '../../../../components/user-reports/utils.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;
    }
    POST = async (req, res, _next) => {
        try {
            const response = await UserReportsListUtils.updateExpiredStatus({
                req,
                res,
                services: this.services,
            });
            res.send({ isExpired: response });
        }
        catch (error) {
            captureException(error);
            res.send({ status: 'FAILED' });
        }
    };
    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
