All files / src/components/Merchants/MerchantPreview/modals helpers.tsx

81.81% Statements 18/22
50% Branches 9/18
100% Functions 5/5
81.81% Lines 18/22

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133      16x     3x     1x                       2x             1x   1x 1x 1x   1x 1x 1x               1x     16x 32x                 16x 275x   275x                 16x                                                                                                                              
import { TOFACStatusImproved } from "@components/Merchants/MerchantPreview/modals/shared/types";
import { LabelValueArray, THistoryCheck } from "@components/Merchants/MerchantPreview/PEP/types";
 
export const mapPepStatusToOfacStatus = (
  pepStatus?: string,
): TOFACStatusImproved => {
  switch (pepStatus) {
    case "possible_match":
    case "Possible match":
      return "Possible match";
    case "confirmed_match":
    case "Confirmed match":
      return "Confirmed match";
    case "clear":
    case "Clear":
      return "Clear";
    case "clear_manually":
    case "manually_cleared":
    case "Manually cleared":
      return "Manually cleared";
    default:
      return "Clear";
  }
};
 
export function createArrayFromObject(
  obj: Record<string, string[] | null>,
): LabelValueArray[] {
  const result: LabelValueArray[] = [];
 
  for (const key in obj) {
    Eif (Object.prototype.hasOwnProperty.call(obj, key)) {
      const values = obj[key];
 
      if (values !== null) {
        values.forEach((value) => {
          result.push({ label: key, value: value });
        });
      } else E{
        result.push({ label: key, value: "None" });
      }
    }
  }
 
  return result;
}
 
export const parser = (check: any): THistoryCheck => {
  return {
    date: check.createdAt,
    status: check.pepStatus,
    checkID: check.id,
    manualPepStatus: check.manualPEPStatus,
    manualStatusAt: check.manualStatusAt,
  };
};
 
export const getListDummyData = (date?: number): THistoryCheck[] => {
  const isDate = date && !isNaN(date);
 
  return [
    {
      date: isDate ? date : Math.floor(new Date().getTime() / 1000),
      status: "pending",
      checkID: 1,
      manualPepStatus: "" as any,
    },
  ];
};
export const dummyObjects = {
  id: 649,
  principalId: 1192,
  pepStatus: "possible_match",
  displayName: "Possible match",
  manualPEPStatus: "",
  manualDisplayName: "",
  createdAt: 1709133350,
  pepResult: [
    {
      id: "evpo-22c89d85-48ec-4fe3-a66c-84d3c81ed7aa",
      match: false,
      score: 0.53261197,
      schema: "Person",
      target: true,
      datasets: ["everypolitician"],
      features: {
        name_literal_match: 0,
        person_name_jaro_winkler: 0.6657649,
        person_name_phonetic_match: 0.5,
      },
      last_seen: "2019-05-21T00:00:00",
      referents: [],
      first_seen: "2019-05-21T00:00:00",
      properties: {
        name: null,
        alias: null,
        notes: null,
        gender: null,
        status: null,
        topics: null,
        address: null,
        country: null,
        innCode: null,
        website: null,
        keywords: null,
        lastName: null,
        position: null,
        religion: null,
        birthDate: null,
        createdAt: null,
        education: null,
        ethnicity: null,
        firstName: null,
        sourceUrl: null,
        weakAlias: null,
        birthPlace: null,
        fatherName: null,
        modifiedAt: null,
        secondName: null,
        wikidataId: null,
        nationality: null,
        birthCountry: null,
        addressEntity: null,
      },
      last_change: "2019-05-21T00:00:00",
    },
  ],
  pepTotal: {
    value: 149,
    relation: "eq",
  },
};