All files / app/features/profile/view UserCard.tsx

100% Statements 20/20
100% Branches 2/2
100% Functions 2/2
100% Lines 19/19

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 672x 2x 2x 2x 2x 2x 2x 2x 2x 2x     2x   2x   2x   9x                           2x                 15x 15x 15x 15x                                            
import { Card } from "@material-ui/core";
import { TabPanel } from "@material-ui/lab";
import TabBar from "components/TabBar";
import { sectionLabels } from "features/profile/constants";
import { useProfileUser } from "features/profile/hooks/useProfileUser";
import About from "features/profile/view/About";
import Home from "features/profile/view/Home";
import References from "features/profile/view/References";
import { useTranslation } from "i18n";
import { PROFILE } from "i18n/namespaces";
import { ReactNode } from "react";
import { UserTab } from "routes";
import makeStyles from "utils/makeStyles";
 
import UserTabContext from "./UserTabContext";
 
const REQUEST_ID = "request";
 
const useStyles = makeStyles((theme) => ({
  detailsCard: {
    [theme.breakpoints.down("sm")]: {
      margin: 0,
      width: "100%",
    },
    flexGrow: 1,
    padding: theme.spacing(2),
  },
  tabPanel: {
    padding: 0,
  },
}));
 
export default function UserCard({
  top,
  onTabChange,
  tab,
}: {
  top?: ReactNode;
  onTabChange: (tab: UserTab) => void;
  tab: UserTab;
}) {
  const { t } = useTranslation([PROFILE]);
  const classes = useStyles();
  const user = useProfileUser();
  return (
    <Card className={classes.detailsCard} id={REQUEST_ID}>
      <UserTabContext tab={tab}>
        <TabBar
          setValue={onTabChange}
          labels={sectionLabels(t)}
          ariaLabel={t("profile:section_tabs_a11y_label")}
        />
        {top || null}
        <TabPanel classes={{ root: classes.tabPanel }} value="about">
          <About user={user} />
        </TabPanel>
        <TabPanel value="home">
          <Home user={user}></Home>
        </TabPanel>
        <TabPanel value="references">
          <References />
        </TabPanel>
      </UserTabContext>
    </Card>
  );
}