All files / react-app/src/features/faq Faq.tsx

96.96% Statements 32/33
50% Branches 9/18
88.88% Functions 8/9
96.77% Lines 30/31

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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362                                4x 8x   8x   8x   8x 1x 1x 2x   1x     8x 4x 3x 3x 3x 3x                 8x 8x 8x   8x                                                                                                                                                                                                                                                                                                                                                                                                   8x                   8x 10x 1x       19x     1x 5x     1x           1x   9x     8x                                                                                                                                                                        
import { useCallback, useEffect, useState } from "react";
import { Navigate, useParams } from "react-router";
 
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
  Button,
  CardWithTopBorder,
  SubNavHeader,
} from "@/components";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
 
import { helpDeskContact, oneMACFAQContent } from "./content/oneMACFAQContent";
 
export const Faq = () => {
  const isFAQHidden = useFeatureFlag("TOGGLE_FAQ");
 
  const { id } = useParams<{ id: string }>();
 
  const [openItems, setOpenItems] = useState<string[]>([]);
 
  const expandAll = useCallback(() => {
    const allIds = [];
    oneMACFAQContent.forEach(({ qanda }) => {
      qanda.forEach(({ anchorText }) => allIds.push(anchorText));
    });
    setOpenItems(allIds);
  }, [setOpenItems]);
 
  useEffect(() => {
    if (id) {
      const element = document.getElementById(id);
      Eif (element) {
        setOpenItems([id]);
        window.scrollTo({
          top: element.offsetTop,
          behavior: "smooth",
        });
      }
    }
  }, [id]);
 
  // Get the flag value for hiding the MMDL banner.
  const isBannerHidden = useFeatureFlag("UAT_HIDE_MMDL_BANNER");
  const isUpdateNewLabel = useFeatureFlag("UPGRADE_NEW_LABEL");
  const isChipSpaDetailsEnabled = useFeatureFlag("CHIP_SPA_DETAILS");
 
  const chipSpaFAQ = isChipSpaDetailsEnabled
    ? {
        anchorText: "chip-spa-attachments",
        question: "What are the attachments for a CHIP SPA?",
        label: null,
        labelColor: null,
        answerJSX: (
          <>
            <p className="font-bold">CHIP SPA Attachment Types:</p>
            <p className="ml-12">Note: “*” indicates a required attachment.</p>
            <table className="faq-table ml-12 border-collapse border border-gray-300 w-full ">
              <tbody>
                <tr>
                  <th className="border border-gray-300 px-4 py-2">Attachment Name</th>
                  <th className="border border-gray-300 px-4 py-2">Description</th>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Current State Plan*</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Current version of the CHIP state plan that details how the State operates its
                    CHIP program
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2 whitespace-nowrap">
                    Amended State Plan Pages*
                  </td>
                  <td className="border border-gray-300 px-4 py-2">
                    Track changes to only the current approved CHIP state plan pages that the State
                    is proposing to amend
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Cover Letter*</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Cover letter to CMS with an authorized signature that outlines the purpose of
                    the CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Budget Documents</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Updated 1-year budget if applicable of the State's planned expenditures if the
                    CHIP SPA submission has a significant impact on the approved budget
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Public Notice</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Process used by the State if applicable to accomplish involvement of the public
                    that occurred specifically for this CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Tribal Consultation</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Consultation process with Indian Tribes if applicable that occurred specifically
                    for this CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Other</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Other supporting document(s) needed to process the CHIP SPA submission
                  </td>
                </tr>
              </tbody>
            </table>
 
            <p className="font-bold mt-12">CHIP Eligibility SPA Attachment Types:</p>
            <p className="ml-12">Note: “*” indicates a required attachment.</p>
            <table className="faq-eligibility-table ml-12 border-collapse border border-gray-300 w-full ">
              <tbody>
                <tr>
                  <th className="border border-gray-300 px-4 py-2">Attachment Name</th>
                  <th className="border border-gray-300 px-4 py-2">Description</th>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2 whitespace-nowrap">
                    CHIP Eligibility SPA Template*
                  </td>
                  <td className="border border-gray-300 px-4 py-2">
                    Amendment to the eligibility section of the CHIP state plan using a PDF template
                    repository, including statutory and regulatory background, required information,
                    and minimum review criteria
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Cover Letter*</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Cover letter to CMS with an authorized signature that outlines the purpose of
                    the CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Budget Documents</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Updated 1-year budget if applicable of the State's planned expenditures if the
                    CHIP SPA submission has a significant impact on the approved budget
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Public Notice</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Process used by the State if applicable to accomplish involvement of the public
                    that occurred specifically for this CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Tribal Consultation</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Consultation process with Indian Tribes if applicable that occurred specifically
                    for this CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Other</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Other supporting document(s) needed to process the CHIP Eligibility SPA
                    submission
                  </td>
                </tr>
              </tbody>
            </table>
          </>
        ),
      }
    : {
        anchorText: "chip-spa-attachments",
        question: "What are the attachments for a CHIP SPA?",
        answerJSX: (
          <>
            <p>Note: “*” indicates a required attachment.</p>
            <table className="faq-table border-collapse border border-gray-300 w-full ">
              <tbody>
                <tr>
                  <th className="border border-gray-300 px-4 py-2">Attachment Name</th>
                  <th className="border border-gray-300 px-4 py-2">Description</th>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Current State Plan*</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Current version of the CHIP state plan that details how the State operates its
                    CHIP program
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Amended State Plan Language*</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Redline version of proposed changes to the existing CHIP state plan pages. State
                    to provide a redline version and a clean version of the CHIP state plan pages
                    being amended.
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Cover Letter*</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Cover letter to CMS with an authorized signature that outlines the purpose of
                    the CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Budget Documents</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Updated 1-year budget if applicable of the State's planned expenditures if the
                    CHIP SPA submission has a significant impact on the approved budget
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Public Notice</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Process used by the State if applicable to accomplish involvement of the public
                    that occurred specifically for this CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Tribal Consultation</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Consultation process with Indian Tribes if applicable that occurred specifically
                    for this CHIP SPA submission
                  </td>
                </tr>
                <tr>
                  <td className="border border-gray-300 px-4 py-2">Other</td>
                  <td className="border border-gray-300 px-4 py-2">
                    Other document(s) needed to process the CHIP SPA submission
                  </td>
                </tr>
              </tbody>
            </table>
          </>
        ),
      };
 
  const anchorsToHide = [
    "spa-admendments",
    "abp-spa-templates",
    "abp-implementation-guides-spa",
    "mpc-spa-templates",
    "mpc-spa-implementation-guides",
    "chip-spa-templates",
    "chip-spa-implentation-guides",
  ];
 
  const filteredFAQContent = oneMACFAQContent.map((section) => {
    if (section.sectionTitle === "State Plan Amendments (SPAs)") {
      const filteredQanda = isBannerHidden
        ? section.qanda.filter((qa) => !anchorsToHide.includes(qa.anchorText))
        : section.qanda;
 
      const existingQanda = filteredQanda.filter((qa) => qa.anchorText !== "chip-spa-attachments");
 
      // Find the correct index for chip-spa-attachments to appear before RAI question
      const raiIndex = existingQanda.findIndex(
        (qa) => qa.anchorText === "chip-spa-rai-attachments",
      );
 
      const updatedQanda = [
        ...existingQanda.slice(0, raiIndex),
        chipSpaFAQ,
        ...existingQanda.slice(raiIndex),
      ];
 
      return { ...section, qanda: updatedQanda };
    }
    return section;
  });
 
  Iif (isFAQHidden) {
    return <Navigate to="/" replace />;
  }
  return (
    <>
      <SubNavHeader>
        <h1 className="text-xl font-medium">Frequently Asked Questions</h1>
      </SubNavHeader>
      <section className="block md:flex md:flex-row max-w-screen-xl m-auto px-4 lg:px-8 pt-8 gap-10">
        <div className="flex-1">
          <article className="mb-8">
            {/* BUTTON */}
            <Button
              onClick={expandAll}
              variant="outline"
              data-testid="expand-all"
              className="w-full xs:w-fit hover:bg-transparent mb-5"
            >
              Expand all to search with CTRL + F
            </Button>
 
            {/* FAQ */}
            <Accordion type="multiple" value={openItems} onValueChange={setOpenItems}>
              {filteredFAQContent.map(({ sectionTitle, qanda }) => (
                <article key={sectionTitle} className="mb-8">
                  <h2 className="text-2xl mb-4 text-primary">{sectionTitle}</h2>
                  {qanda.map(({ anchorText, answerJSX, question, label, labelColor }) => (
                    <AccordionItem
                      value={anchorText}
                      id={anchorText}
                      key={anchorText}
                      data-testid={anchorText}
                    >
                      <AccordionTrigger className="text-left">
                        <div className="flex items-center gap-2">
                          {isUpdateNewLabel && label && (
                            <span
                              className={`text-white text-xs font-semibold px-2 py-0.5 rounded no-underline hover:no-underline ${
                                labelColor === "green"
                                  ? "bg-green-600"
                                  : labelColor === "blue"
                                    ? "bg-blue-600"
                                    : "bg-gray-500"
                              }`}
                            >
                              {label}
                            </span>
                          )}
                          <span className="hover:underline">{question}</span>
                        </div>
                      </AccordionTrigger>
                      <AccordionContent>{answerJSX}</AccordionContent>
                    </AccordionItem>
                  ))}
                </article>
              ))}
            </Accordion>
          </article>
        </div>
        <div>
          <CardWithTopBorder>
            <div className="p-4">
              <h3 className="text-lg text-bold mb-4">OneMAC Help Desk Contact Info</h3>
              <div>
                <b>Phone Number</b>
                <p className="mb-4 text-primary">
                  <a className="underline" href={`tel:${helpDeskContact.phone}`}>
                    {helpDeskContact.phone}
                  </a>
                </p>
                <b>Email</b>
                <p className="text-primary">
                  <a className="underline" href={`mailto:${helpDeskContact.email}`}>
                    {helpDeskContact.email}
                  </a>
                </p>
              </div>
            </div>
          </CardWithTopBorder>
        </div>
      </section>
    </>
  );
};