All files / src/app/compliance/_components helpers.tsx

71.42% Statements 15/21
72.22% Branches 26/36
100% Functions 4/4
86.66% Lines 13/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 403x             284x       253x                   169x         85x 85x     85x   85x 85x 70x 15x 15x 15x    
"use client";
 
import type { ComplianceLevel, MatrixRow } from "./types";
 
export function rowKey(
  row: Pick<MatrixRow, "applicationId" | "consumerId">,
): string {
  return row.applicationId ?? row.consumerId;
}
 
export function isUndecided(row: MatrixRow): boolean {
  return (
    row.hasApplication &&
    !row.hasApproval &&
    !["APPROVED", "REJECTED", "REVOKED"].includes(
      (row.applicationStatus ?? "").toUpperCase(),
    )
  );
}
 
export function shortDate(iso: string | null | undefined): string {
  return iso ? iso.slice(0, 10) : "";
}
 
export function complianceLevel(row: MatrixRow): ComplianceLevel {
  // HDAB authorities review others — they don't submit applications
  Iif (row.consumerType === "HDAB" && !row.hasApplication) return "governance";
  Iif (row.approvalStatus === "REVOKED" || row.applicationStatus === "REVOKED") {
    return "revoked";
  }
  Iif (row.approvalStatus === "REJECTED" || row.applicationStatus === "REJECTED")
    return "rejected";
  Iif (row.applicationStatus === "UNDER_REVIEW") return "review";
  if (row.applicationStatus === "PENDING") return "pending";
  if (row.hasApproval && row.datasetId && row.hasContract) return "full";
  Iif (row.hasApproval && row.datasetId) return "approved";
  Iif (row.hasApplication) return "pending";
  return "none";
}