import {
  mapApiOpenIssuesToRows,
  mapApiAssignmentToDetail,
  mapApiRgcDecisionsToRows,
} from "@/features/ministry/progress-report/progress-report-detail-data";
import type { DateLanguage } from "@/lib/date-utils";

import {
  getCdcMinistryStatusLabel,
  type ApiCdcProgressReportMinistryDetail,
} from "../../../service/progress-report-service";

export function mapCdcMinistryProgressReportDetail(
  assignment: ApiCdcProgressReportMinistryDetail,
  language: DateLanguage = "en",
) {
  return {
    ...mapApiAssignmentToDetail(assignment, language),
    status: getCdcMinistryStatusLabel(assignment.status),
  };
}

export function mapCdcMinistryIssues(assignment: ApiCdcProgressReportMinistryDetail) {
  return mapApiOpenIssuesToRows(assignment.openIssues);
}

export function mapCdcMinistryRgcDecisions(
  assignment: ApiCdcProgressReportMinistryDetail,
) {
  return mapApiRgcDecisionsToRows(
    assignment.rgcDecisions,
    assignment.ministry,
  );
}
