All files / react-app/src/features/forms/new-submission Medicaid.tsx

87.5% Statements 7/8
100% Branches 4/4
75% Functions 3/4
87.5% Lines 7/8

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                                          4x 2x 2x 2x 2x                                                                 32x                                       1x                                                                                  
import { Link } from "react-router";
import { isStateUser } from "shared-utils";
 
import { useGetUser } from "@/api";
import {
  ActionForm,
  DatePicker,
  FormControl,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
  Input,
  RequiredIndicator,
  SpaIdFormattingDesc,
} from "@/components";
import { AttachmentFileFormatInstructions } from "@/components/ActionForm/actionForm.components";
import { FAQ_TAB } from "@/consts";
import { formSchemas } from "@/formSchemas";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
 
export const MedicaidForm = () => {
  const { data: user } = useGetUser();
  const isStateUserFlag = useFeatureFlag("MED_SPA_FOOTER");
  const isState = isStateUser(user?.user);
  const showMedspaFooter = isState && isStateUserFlag;
 
  return (
    <ActionForm
      schema={formSchemas["new-medicaid-submission"]}
      title="Medicaid SPA Details"
      breadcrumbText="Submit new Medicaid SPA"
      fields={({ control }) => (
        <>
          <FormField
            control={control}
            name="id"
            render={({ field }) => (
              <FormItem>
                <div className="flex gap-4">
                  <FormLabel className="font-semibold" data-testid="spaid-label">
                    SPA ID <RequiredIndicator />
                  </FormLabel>
                  <Link
                    to="/faq/spa-id-format"
                    target={FAQ_TAB}
                    rel="noopener noreferrer"
                    className="text-blue-900 underline"
                  >
                    What is my SPA ID?
                  </Link>
                </div>
                <SpaIdFormattingDesc />
                <FormControl>
                  <Input
                    className="max-w-sm"
                    ref={field.ref}
                    value={field.value}
                    onChange={(e) => field.onChange(e.currentTarget.value.toUpperCase())}
                  />
                </FormControl>
                <FormMessage />
              </FormItem>
            )}
          />
          <FormField
            control={control}
            name="proposedEffectiveDate"
            render={({ field }) => (
              <FormItem className="max-w-md">
                <FormLabel
                  className="text-lg font-semibold block"
                  data-testid="proposedEffectiveDate-label"
                >
                  Proposed Effective Date of Medicaid SPA <RequiredIndicator />
                </FormLabel>
                <FormControl>
                  <DatePicker
                    onChange={(date) => field.onChange(date.getTime())}
                    date={field.value ? new Date(field.value) : undefined}
                    dataTestId="proposedEffectiveDate"
                  />
                </FormControl>
                <FormMessage />
              </FormItem>
            )}
          />
        </>
      )}
      defaultValues={{ id: "" }}
      attachments={{
        instructions: [
          <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 except for the CMS-179 Form.
            </span>{" "}
            Read the description for each of the attachment types on the{" "}
            <Link
              to="/faq/medicaid-spa-attachments"
              target={FAQ_TAB}
              rel="noopener noreferrer"
              className="text-blue-900 underline"
            >
              FAQ Page
            </Link>
            .
          </p>,
          <AttachmentFileFormatInstructions />,
        ],
      }}
      documentPollerArgs={{
        property: "id",
        documentChecker: (check) => check.recordExists,
      }}
      showCustomFooter={showMedspaFooter}
    />
  );
};