'use strict';

var UserReports = require('../../../../types/UserReports.js');
var localsHelper = require('../../../../utils/localsHelper.js');
var utils = require('../../../../components/_async/async-polling/current-status/utils.js');

const initPollingView = async ({ req, res, services }) => {
    const { dprUser } = localsHelper.default.getValues(res);
    const { executionId, type } = req.params;
    const requestReportData = await services.requestedReportService.getReportByExecutionId(executionId, dprUser.id);
    if (!requestReportData)
        return {};
    const title = `${type.charAt(0).toUpperCase() + type.substring(1).toLowerCase()} request status`;
    const data = utils.buildCurrentStatusView(requestReportData, requestReportData.status || UserReports.RequestStatus.SUBMITTED, res);
    const config = {
        title,
        data: {
            ...data,
            path: req.baseUrl,
        },
    };
    return config;
};

exports.initPollingView = initPollingView;
//# sourceMappingURL=utils.js.map
