All files / react-app/src/features/selection-flow plan-types.tsx

100% Statements 22/22
100% Branches 4/4
100% Functions 10/10
100% Lines 22/22

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                                                  3x 9x                       3x 20x 20x       10x                                         3x 3x             3x 1x             3x 1x                     3x 1x                   3x 1x           3x 1x           3x 1x           3x 1x            
import { Navigate, useLocation } from "react-router";
import { isStateUser } from "shared-utils";
 
import { useGetUser } from "@/api";
import {
  BreadCrumbs,
  LoadingSpinner,
  MACFieldsetOption,
  OptionCard,
  optionCrumbsFromPath,
  OptionFieldset,
  SimplePageContainer,
} from "@/components";
import {
  AUTHORITY_OPTIONS,
  B_WAIVER_OPTIONS,
  B4_WAIVER_OPTIONS,
  BCAP_WAIVER_OPTIONS,
  SPA_OPTIONS,
  useChipSpaOptions,
  useMedSpaOptions,
  WAIVER_OPTIONS,
} from "@/features";
 
/** Can be removed once page title bar with back nav is integrated */
export const SimplePageTitle = ({ title }: { title: string }) => (
  <div className="flex items-center justify-between my-4">
    <h1 className="text-xl">{title}</h1>
  </div>
);
 
export type OptionData = Omit<MACFieldsetOption, "altBg">;
type OptionsPageProps = {
  options: OptionData[];
  title: string;
  fieldsetLegend: string;
};
/** A page for rendering an array of {@link OptionData} */
const OptionsPage = ({ options, title, fieldsetLegend }: OptionsPageProps) => {
  const location = useLocation();
  const { data: userObj, isLoading: isUserLoading } = useGetUser();
 
  if (isUserLoading) return <LoadingSpinner />;
 
  if (!userObj || isStateUser(userObj.user) === false) {
    return <Navigate to="/" replace />;
  }
 
  return (
    <SimplePageContainer>
      <BreadCrumbs options={optionCrumbsFromPath(location.pathname)} />
      <SimplePageTitle title={title} />
      <OptionFieldset legend={fieldsetLegend}>
        {options.map((opt, idx) => (
          <OptionCard
            key={idx}
            {...opt}
            altBg={idx % 2 === 1} // Even number option cards show altBg
          />
        ))}
      </OptionFieldset>
    </SimplePageContainer>
  );
};
/** Initial set of options for a New Submission */
export const NewSubmissionInitialOptions = () => (
  <OptionsPage
    title="Submission Type"
    fieldsetLegend="Select a Submission Type"
    options={AUTHORITY_OPTIONS}
  />
);
/** Choice between the main SPA types when creating a New Submission */
export const SPASubmissionOptions = () => (
  <OptionsPage
    title="SPA Type"
    fieldsetLegend="Select a SPA type to start your submission"
    options={SPA_OPTIONS}
  />
);
/** Sub-choices for Medicaid SPAs */
export const MedicaidSPASubmissionOptions = () => {
  const MEDICAID_SPA_OPTIONS = useMedSpaOptions();
 
  return (
    <OptionsPage
      title="Medicaid SPA Type"
      fieldsetLegend="Select a Medicaid SPA type to create your submission"
      options={MEDICAID_SPA_OPTIONS}
    />
  );
};
/** Sub-choices for CHIP SPAs */
export const ChipSPASubmissionOptions = () => {
  const CHIP_SPA_OPTIONS = useChipSpaOptions();
 
  return (
    <OptionsPage
      title="CHIP SPA Type"
      fieldsetLegend="Select a CHIP SPA type to create your submission"
      options={CHIP_SPA_OPTIONS}
    />
  );
};
export const WaiverSubmissionOptions = () => (
  <OptionsPage
    title="Waiver Action Type"
    fieldsetLegend="Select a Waiver type to start your submission"
    options={WAIVER_OPTIONS}
  />
);
export const BWaiverSubmissionOptions = () => (
  <OptionsPage
    title="1915(b) Waiver Action Type"
    fieldsetLegend="Select a 1915(b) Waiver type for your submission"
    options={B_WAIVER_OPTIONS}
  />
);
export const B4WaiverSubmissionOptions = () => (
  <OptionsPage
    title="1915(b)(4) FFS Selective Contracting Waiver Authority"
    fieldsetLegend="Select a Waiver type to start your submission"
    options={B4_WAIVER_OPTIONS}
  />
);
export const BCapWaiverSubmissionOptions = () => (
  <OptionsPage
    title="1915(b) Comprehensive (Capitated) Waiver Authority"
    fieldsetLegend="Select a Waiver type to start your submission"
    options={BCAP_WAIVER_OPTIONS}
  />
);