const {
  IN_PROGRESS,
  NOT_RESOLVED,
  READY_FOR_VERIFICATION,
} = require('../constant/inspect/inspect-finding-status.constant');

module.exports.hasUnresolvedIncident = (document) =>
  document.findings &&
  document.findings.some((finding) =>
    finding.incidents.some((incident) => [NOT_RESOLVED, IN_PROGRESS, READY_FOR_VERIFICATION].includes(incident.status)),
  );

module.exports.hasUnresolvedIncidentForRP = (document) =>
  document.findings &&
  document.findings.some((finding) =>
    finding.incidents.some((incident) => [NOT_RESOLVED, IN_PROGRESS].includes(incident.status)),
  );
