All files / pages/Onboarding OnboardingWrapperPage.jsx

100% Statements 27/27
100% Branches 5/5
100% Functions 2/2
100% Lines 27/27

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 331x 1x 1x 1x 1x 1x   1x 5x 5x 5x 5x 3x 3x 5x 1x 1x 1x 1x 1x 1x 5x   5x 5x 5x 5x 5x       5x  
import { hasRole, useCurrentUser } from "main/utils/currentUser";
import OnboardingSelectSchoolComponent from "main/components/Onboarding/OnboardingSelectSchoolComponent";
import OnboardingSelectCoursesComponent from "main/components/Onboarding/OnboardingSelectCoursesComponent";
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import { Container, ProgressBar, Row } from "react-bootstrap";
import OnboardingGithubSignInComponent from "main/components/Onboarding/OnboardingGithubSignInComponent";
 
export default function OnboardingWrapperPage() {
  const userData = useCurrentUser();
  let progress;
  const renderElement = () => {
    if (!userData.loggedIn) {
      progress = 25;
      return <OnboardingSelectSchoolComponent />;
    } else if (!hasRole(userData, "ROLE_GITHUB")) {
      progress = 50;
      return <OnboardingGithubSignInComponent />;
    } else {
      progress = 75;
      return <OnboardingSelectCoursesComponent />;
    }
  };
 
  return (
    <BasicLayout enableBootstrap={true}>
      {renderElement()}
      <Row className="mt-auto pb-3">
        <ProgressBar now={progress} />
      </Row>
    </BasicLayout>
  );
}