All files / react-app/src/components/ActionForm actionForm.components.tsx

100% Statements 12/12
93.33% Branches 14/15
100% Functions 4/4
100% Lines 12/12

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        72x 269x                             72x 268x                               72x 1004x           72x 1004x 387x   387x       374x         617x    
import { FAQ_TAB } from "@/router";
import { Link } from "react-router";
import { z } from "zod";
 
export const AttachmentFileFormatInstructions = () => (
  <p data-testid="accepted-files">
    We accept the following file formats:{" "}
    <span className="font-bold">.doc, .docx, .pdf, .jpg, .xlsx, and more. </span>{" "}
    <Link
      to={"/faq/acceptable-file-formats"}
      target={FAQ_TAB}
      rel="noopener noreferrer"
      className="text-blue-900 underline"
    >
      See the full list
    </Link>
    .
  </p>
);
 
export const AttachmentFAQInstructions = ({ faqLink }: { faqLink?: string }) => (
  <p data-testid="attachments-instructions">
    Maximum file size of 80 MB per attachment.{" "}
    <span className="font-bold">You can add multiple files per attachment type.</span> Read the
    description for each of the attachment types on the{" "}
    <Link
      to={faqLink || "/faq"}
      target={FAQ_TAB}
      rel="noopener noreferrer"
      className="text-blue-900 underline"
    >
      FAQ Page
    </Link>
    .
  </p>
);
 
const isZodArrayDef = (def: unknown): def is z.ZodArrayDef =>
  def !== undefined &&
  def !== null &&
  typeof def === "object" &&
  "typeName" in def &&
  def.typeName === "ZodArray";
 
export const AttachmentInstructions = ({ fileValidation }: { fileValidation: z.ZodArray<any> }) => {
  if (isZodArrayDef(fileValidation)) {
    const { maxLength, minLength } = fileValidation;
 
    if (maxLength?.value === 1 && minLength?.value === 1) {
      return <p>One attachment is required</p>;
    }
 
    Eif (minLength?.value) {
      return <p>At least one attachment is required</p>;
    }
  }
 
  return null;
};