All files / pages/Student StudentCourseShowPage.jsx

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

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                      3x 3x   3x               3x 3x                                                          
import React from "react";
import { useBackend } from "main/utils/useBackend";
 
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import { useParams } from "react-router";
import { useCurrentUser } from "main/utils/currentUser";
 
import { Tab, Tabs } from "react-bootstrap";
import TeamsTabComponent from "main/components/TabComponent/TeamsTabComponent";
 
export default function StudentCourseShowPage() {
  const currentUser = useCurrentUser();
  const courseId = useParams().id;
 
  const { data: course } = useBackend(
    [`/api/courses/${courseId}`],
    // Stryker disable next-line StringLiteral : GET and empty string are equivalent
    { method: "GET", url: `/api/courses/${courseId}` },
    null,
    true,
  );
 
  const testId = "StudentCourseShowPage";
  return (
    <BasicLayout>
      {!course ? (
        <div data-testid={`${testId}-loading`}>Course: Loading...</div>
      ) : (
        <div className="border rounded-3 p-4 mb-4">
          <div className="d-flex align-items-center gap-2">
            <h1 data-testid={`${testId}-title`} className="h3 mb-0 fw-semibold">
              {course.courseName}
            </h1>
            <span className="badge bg-primary-subtle text-primary-emphasis rounded-pill">
              {course.term}
            </span>
          </div>
        </div>
      )}
      <Tabs defaultActiveKey={"teams"}>
        <Tab eventKey={"teams"} title={"My Teams"} className="pt-2">
          <TeamsTabComponent
            courseId={courseId}
            testIdPrefix={testId}
            currentUser={currentUser}
            instructorView={false}
          />
        </Tab>
      </Tabs>
    </BasicLayout>
  );
}