import { RequestStatus } from '../../../../types/UserReports.js';
import localsHelper from '../../../../utils/localsHelper.js';
import { buildCurrentStatusView } from '../../../../components/_async/async-polling/current-status/utils.js';

const initPollingView = async ({ req, res, services }) => {
    const { dprUser } = localsHelper.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 = buildCurrentStatusView(requestReportData, requestReportData.status || RequestStatus.SUBMITTED, res);
    const config = {
        title,
        data: {
            ...data,
            path: req.baseUrl,
        },
    };
    return config;
};

export { initPollingView };
//# sourceMappingURL=utils.js.map
