-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathactionForm.components.tsx
55 lines (48 loc) · 1.59 KB
/
actionForm.components.tsx
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
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 && 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>;
}
if (minLength?.value) {
return <p>At least one attachment is required</p>;
}
}
return null;
};