All files / react-app/src/components/Banner macproBanner.tsx

100% Statements 9/9
92.3% Branches 12/13
100% Functions 1/1
100% Lines 8/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          81x 59x 59x 59x     59x     2x           2x                   2x                                                    
import { isCmsUser, isStateUser } from "shared-utils";
 
import { useGetUser } from "@/api";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
 
const TopBanner = () => {
  const { data: user } = useGetUser();
  const isStateHomepage = useFeatureFlag("STATE_HOMEPAGE_FLAG");
  const isCMSHomepage = useFeatureFlag("CMS_HOMEPAGE_FLAG");
 
  // Show nothing if neither flag is on or user is not signed in
  if (!isStateHomepage || !isCMSHomepage || !user.user) return null;
 
  // Button sets
  const stateLinks = [
    { label: "MACPro", href: "https://macpro.cms.gov/suite" },
    { label: "WMS", href: "https://wms-mmdl.cms.gov/WMS/faces/portal.jsp" },
    { label: "MMDL", href: "https://wms-mmdl.cms.gov/MMDL/faces/portal.jsp" },
  ];
 
  const cmsLinks = [
    { label: "MACPro", href: "https://macpro.cms.gov/suite" },
    { label: "SEA TOOL", href: "https://seatool.cms.gov" },
    { label: "WMS", href: "https://wms-mmdl.cms.gov/WMS/faces/portal.jsp" },
    { label: "eRegs", href: "https://www.ecfr.gov/current/title-42" },
    { label: "Laserfiche", href: "https://cmsrio.cms.local/laserfiche" },
    { label: "MMDL", href: "https://wms-mmdl.cms.gov/MMDL/faces/portal.jsp" },
  ];
 
  const linksToRender =
    isCMSHomepage && isCmsUser(user.user)
      ? cmsLinks
      : isStateHomepage && isStateUser(user.user)
        ? stateLinks
        : [];
 
  return (
    <div className="w-full h-[64px] bg-[#205493] flex items-center">
      <div className="w-full max-w-screen-xl mx-auto flex gap-8 text-white text-sm font-semibold px-4 lg:px-8 flex-wrap">
        {linksToRender.map((link) => (
          <a
            key={link.label}
            href={link.href}
            target="_blank"
            rel="noopener noreferrer"
            className="hover:underline"
          >
            {link.label}
          </a>
        ))}
      </div>
    </div>
  );
};
 
export default TopBanner;