All files / src/components/Merchants/MerchantPreview/utils index.ts

71.42% Statements 20/28
54.54% Branches 12/22
60% Functions 3/5
72% Lines 18/25

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          94x 2x 2x   2x   2x     94x       94x           36x 34x   31x     94x               94x         72x       72x       72x       72x 72x       94x              
import { CAMPAIGN_PANEL_WIDTH } from "@common/CampaignCard/CampaignDetailsModal/useCampaignModal";
import { OFACCheckStatusType } from "../OFAC/hooks/useOFAC";
import moment from "moment";
import { PLATFORM_TIMEZONE } from "@utils/timezones";
 
export const clamper = (fileName?: string) => {
  Iif (!fileName) return "";
  const [name, extension] = fileName.split(".");
  const clampedName =
    name.length > 8 ? `${name.substring(0, 7)}...${extension}` : fileName;
 
  return clampedName;
};
 
export const isOFACClear = (status?: OFACCheckStatusType) => {
  return status && ["clear", "manually_cleared"].includes(status);
};
 
export const getOwnerIdImage = (
  isLocalFile: boolean,
  localFile: string,
  fileURL: string,
  idImageUrl?: string,
) => {
  if (isLocalFile) return localFile;
  if (idImageUrl) return idImageUrl;
 
  return fileURL;
};
 
export const OFAC_MATCH_PANEL_WIDTH = CAMPAIGN_PANEL_WIDTH - 30 + "px";
 
type MatchInfoParams = {
  isOFACPossibleMatch: boolean;
  isPEPMatch: boolean;
  isOFACMatch: boolean;
};
 
export const getMatchInfoMessage = ({
  isOFACPossibleMatch,
  isPEPMatch,
  isOFACMatch,
}: MatchInfoParams) => {
  Iif (isOFACPossibleMatch && isPEPMatch) {
    return "This edit is blocked by a confirmed match on OFAC and PEP";
  }
 
  Iif (isOFACMatch) {
    return "This edit is blocked by a confirmed match on OFAC";
  }
 
  Iif (isOFACPossibleMatch) {
    return "This edit is blocked by a possible match on OFAC";
  }
 
  Eif (isPEPMatch) {
    return "This edit is blocked by a confirmed match on PEP";
  }
};
 
export const formatOwnersDateUTC = (date: Date, isMobile: boolean) => {
  if (isMobile) {
    return moment(date).tz(PLATFORM_TIMEZONE).format("MMM D, YYYY");
  } else {
    return moment(date).tz(PLATFORM_TIMEZONE).format("MMM D, YYYY, h:mm:ss A z");
  }
};