All files / react-app/src/features/welcome wrapper.tsx

100% Statements 7/7
90% Branches 9/10
100% Functions 1/1
100% Lines 7/7

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            2x 3x 3x 3x   3x   2x         1x                
import { isCmsUser, isStateUser } from "shared-utils";
 
import { useGetUser } from "@/api";
import * as F from "@/features";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
 
export const WelcomeWrapper = () => {
  const { data: user } = useGetUser();
  const isCMSEnabled = useFeatureFlag("CMS_HOMEPAGE_FLAG");
  const isStateEnabled = useFeatureFlag("STATE_HOMEPAGE_FLAG");
 
  if (user) {
    // Check if the user exists and has a CMS role, cms feature flag
    if (isCmsUser(user.user) && isCMSEnabled) {
      return <F.CMSWelcome />;
    }
 
    // Check if the user exists and has a State role, state feature flag
    Eif (isStateUser(user.user) && isStateEnabled) {
      return <F.StateWelcome />;
    }
  }
 
  // If user is not logged in, show the default welcome page
  return <F.Welcome />;
};