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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | 72x 1x 1x 1x 1x 9x 9x 9x 1x 42x 42x 42x 72x 2x 2x 72x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { useGetItem } from "@/api"; import { ActionForm, LoadingSpinner, PackageSection, SchemaWithEnforcableProps, } from "@/components"; import { AttachmentFAQInstructions, AttachmentFileFormatInstructions, } from "@/components/ActionForm/actionForm.components"; import { formSchemas } from "@/formSchemas"; import { Navigate, useParams } from "react-router"; import { z } from "zod"; import { getFAQLinkForAttachments } from "../../faqLinks"; const pickAttachmentsAndAdditionalInfo = ( schema: SchemaWithEnforcableProps, submissionId: string, ) => { Iif (schema instanceof z.ZodEffects) { return pickAttachmentsAndAdditionalInfo(schema.innerType(), submissionId); } Eif (schema instanceof z.ZodObject) { const shape = schema._def.shape(); const optionalAttachmentsShape = Object.fromEntries( Object.entries(shape.attachments.shape).map(([key, value]) => { const files = value._def.shape().files; const filesArray = files instanceof z.ZodArray ? files : files.unwrap(); return [ key, z.object({ files: z.array(filesArray.element).optional(), label: value._def.shape().label, }), ]; }), ); return z .object({ id: z.string().default(submissionId), event: z.literal("upload-subsequent-documents").default("upload-subsequent-documents"), attachments: z.object(optionalAttachmentsShape), additionalInformation: z .string() .min(1, { message: "Additional Information is required." }) .max(4000) .refine((value) => value.trim().length > 0, { message: "Additional Information can not be only whitespace.", }), authority: z.string(), }) .refine( (data) => data.attachments && Object.values(data.attachments).some( (attachment) => attachment && attachment.files && attachment.files.length > 0, ), { message: "At least one attachment must have files.", path: ["attachments"], }, ); } throw new Error("No attachments property found in schema"); }; const getTitle = (originalSubmissionEvent: string) => { switch (true) { case originalSubmissionEvent === "new-medicaid-submission": return "Medicaid SPA"; case originalSubmissionEvent === "new-chip-submission": return "CHIP SPA"; case originalSubmissionEvent === "app-k": return "1915(c) Appendix K Waiver Amendment"; case originalSubmissionEvent.includes("amendment"): return "1915(b) Waiver Amendment"; case originalSubmissionEvent.includes("initial"): return "1915(b) Initial Waiver"; case originalSubmissionEvent.includes("renewal"): return "1915(b) Waiver Renewal"; default: return ""; } }; export const UploadSubsequentDocuments = () => { const { id, authority } = useParams<{ id: string; authority: string }>(); const { data: submission, isLoading: isSubmissionLoading } = useGetItem(id); if (isSubmissionLoading === true) { return <LoadingSpinner />; } Iif (!submission?._source) { return <Navigate to="/dashboard" />; } let originalSubmissionEvent = (submission._source.changelog ?? []).reduce<string | null>( (acc, { _source }) => (_source?.event ? _source?.event : acc), null, ); Iif (originalSubmissionEvent === "NOSO") { originalSubmissionEvent = submission._source.mockEvent; } Iif (originalSubmissionEvent === "split-spa") { originalSubmissionEvent = submission._source.mockEvent; } const schema: SchemaWithEnforcableProps | undefined = formSchemas[originalSubmissionEvent]; Iif (schema === undefined) { return <Navigate to="/dashboard" />; } const pickedSchema = pickAttachmentsAndAdditionalInfo(schema, submission._id); const faqLink = getFAQLinkForAttachments(originalSubmissionEvent); return ( <ActionForm title={`${getTitle(originalSubmissionEvent)} Subsequent Documents Details`} schema={pickedSchema} breadcrumbText="New Subsequent Documentation" formDescription={` Provide revised or additional documentation for your submission. Once you submit this form, a confirmation email is sent to you and to CMS. CMS will use this content to review your package, and you will not be able to edit this form. If CMS needs any additional information, they will follow up by email. `} fields={PackageSection} promptPreSubmission={{ header: "Submit additional documents?", body: "These documents will be added to the package and reviewed by CMS.", acceptButtonText: "Yes, Submit", }} bannerPostSubmission={{ header: "Documents submitted", body: "CMS reviewers will follow up by email if additional information is needed.", variant: "success", }} attachments={{ title: `Subsequent ${getTitle(originalSubmissionEvent)} Documents`, requiredIndicatorForTitle: true, instructions: [ <AttachmentFAQInstructions faqLink={faqLink} />, <AttachmentFileFormatInstructions />, <p>At least one attachment is required to submit.</p>, ], }} documentPollerArgs={{ property: "id", documentChecker: (check) => check.recordExists, }} defaultValues={{ authority }} additionalInformation={{ required: true, title: "Reason for subsequent documents", label: "Explain why additional documents are being submitted.", }} /> ); }; |