All files / src/utils statusUtils.ts

100% Statements 26/26
100% Branches 22/22
100% Functions 3/3
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                  46x 46x 44x 41x 39x 36x 34x                   73x 71x 69x 7x 3x                   10x 7x 3x    
import { StatusType } from "../types/common/StatusTypes";
 
/**
 * Converts a risk level string to a status badge variant
 *
 * @param level - The risk level string (e.g., "Low Risk", "High Risk")
 * @returns The corresponding StatusType for the badge
 */
export function getStatusVariant(level: string): StatusType {
  const normalizedLevel = level.toLowerCase();
  if (normalizedLevel === "none") return "error";
  if (normalizedLevel === "low") return "warning";
  if (normalizedLevel === "moderate") return "info";
  if (normalizedLevel === "high") return "success";
  if (normalizedLevel === "very high") return "purple";
  return "neutral";
}
 
/**
 * Gets the appropriate Tailwind CSS color class for a risk level
 *
 * @param risk - The risk level string
 * @returns Tailwind CSS class string for text color
 */
export function getRiskColorClass(risk: string): string {
  if (risk.includes("Low")) return "text-green-600 dark:text-green-400";
  if (risk.includes("Medium")) return "text-yellow-600 dark:text-yellow-400";
  if (risk.includes("High")) return "text-orange-600 dark:text-orange-400";
  if (risk.includes("Critical")) return "text-red-600 dark:text-red-400";
  return "text-gray-600 dark:text-gray-400";
}
 
/**
 * Gets compliance status text based on compliance score
 *
 * @param complianceScore - The compliance score (0-100)
 * @returns Human-readable compliance status text
 */
export function getComplianceStatusText(complianceScore: number): string {
  if (complianceScore >= 80) return "Strong compliance position";
  if (complianceScore >= 50) return "Moderate compliance position";
  return "Compliance gaps detected";
}