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

45.45% Statements 10/22
0% Branches 0/4
0% Functions 0/10
45.45% Lines 10/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                                              72x                         72x                                                 72x               72x               72x               72x             72x             72x             72x             72x              
import { Navigate, useLocation } from "react-router";
import {
  MACFieldsetOption,
  OptionCard,
  OptionFieldset,
  SimplePageContainer,
  BreadCrumbs,
  optionCrumbsFromPath,
} from "@/components";
import {
  AUTHORITY_OPTIONS,
  B4_WAIVER_OPTIONS,
  B_WAIVER_OPTIONS,
  BCAP_WAIVER_OPTIONS,
  CHIP_SPA_OPTIONS,
  MEDICAID_SPA_OPTIONS,
  SPA_OPTIONS,
  WAIVER_OPTIONS,
} from "@/features";
import { useGetUser } from "@/api";
import { isStateUser } from "shared-utils";
 
/** 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 } = useGetUser();
 
  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 = () => (
  <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 = () => (
  <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}
  />
);