All files / react-app/src/features/faq/faqs utils.tsx

81.81% Statements 9/11
28.57% Branches 2/7
60% Functions 3/5
80% Lines 8/10

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                  5x         5x 6x           5x 2x 2x           5x                                                   5x                                                    
import { cn } from "@/utils";
 
export interface Template {
  title: string;
  text?: string;
  href: string;
  subtext?: string[];
}
 
export const helpDeskContact = {
  email: "OneMAC_Helpdesk@cms.hhs.gov",
  phone: "(833) 228-2540",
};
 
export const slugify = (text: string) =>
  text
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, "-")
    .replace(/(^-|-$)/g, "")
    .substring(0, 40);
 
export const handleSupportLinkClick = (type: string) => (e: React.MouseEvent<HTMLElement>) => {
  const text = e.currentTarget.textContent?.trim() || "unknown";
  window.gtag("event", `support_click_${type}_${slugify(text)}`, {
    event_category: "Support",
    event_label: text,
  });
};
 
export const PdfLink = ({
  href,
  title,
  text,
  label,
  className = "underline hover:no-underline",
}: {
  href: string;
  title: string;
  text?: string;
  label: string;
  className?: string;
}) => (
  <a
    className={cn("text-primary", className)}
    href={href}
    download
    rel="noopener noreferrer"
    target="_blank"
    onClick={handleSupportLinkClick(label)}
  >
    {title}
    {text && `: ${text}`}
  </a>
);
 
export const PdfList = ({
  list,
  label,
  ulClassName = "list-disc pl-6 space-y-2",
}: {
  list: Template[];
  label: string;
  ulClassName?: string;
}) => (
  <ul className={ulClassName} role="list">
    {list.map((pdf) => (
      <li key={pdf.title}>
        <PdfLink href={pdf.href} title={pdf.title} text={pdf.text} label={label} className="" />
        {pdf.subtext && (
          <ul className="list-disc pl-7 space-y-1" role="list">
            {pdf.subtext.map((sub, index) => (
              <li key={index} className="text-sm text-gray-600">
                {sub}
              </li>
            ))}
          </ul>
        )}
      </li>
    ))}
  </ul>
);