All files / react-app/src/features/faq/content chpRenderSection.tsx

100% Statements 3/3
33.33% Branches 1/3
100% Functions 2/2
100% Lines 3/3

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        576x                 72x           576x                                                      
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}
export interface Template {
  title: string;
  text?: string;
  href: string;
  subtext?: string[];
}
 
export const renderSection = (
  title: string,
  templates: Template[],
  filterCondition: (template: Template) => boolean,
  ulClassName: string = "",
) => (
  <>
    <p>{title}</p>
    <ul className={cn("list-disc pl-6 space-y-2", ulClassName)}>
      {templates.filter(filterCondition).map((template) => (
        <li key={template.title}>
          <a
            href={template.href}
            target="_blank"
            rel="noopener noreferrer"
            className="text-blue-600"
          >
            {template.title}: {template.text}
          </a>
          {template.subtext && template.subtext.length > 0 && (
            <ul className="list-disc pl-6 space-y-1">
              {template.subtext.map((sub, index) => (
                <li key={index} className="text-sm text-gray-600">
                  {sub}
                </li>
              ))}
            </ul>
          )}
        </li>
      ))}
    </ul>
  </>
);