All files / app/features/profile/edit EditProfilePage.tsx

95% Statements 19/20
100% Branches 1/1
66.66% Functions 2/3
94.73% Lines 18/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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1011x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x   2x                                                                       1x         4x 4x   4x                                                                                  
import { Button, Card, Grid } from "@material-ui/core";
import { TabContext, TabPanel } from "@material-ui/lab";
import HtmlMeta from "components/HtmlMeta";
import PageTitle from "components/PageTitle";
import TabBar from "components/TabBar";
import Link from "next/link";
import { useRouter } from "next/router";
import React from "react";
import { EditUserTab, routeToEditProfile, settingsRoute } from "routes";
import { t } from "test/utils";
import makeStyles from "utils/makeStyles";
 
import EditHostingPreference from "./EditHostingPreference";
import EditProfile from "./EditProfile";
 
const useStyles = makeStyles((theme) => ({
  detailsCard: {
    [theme.breakpoints.down("sm")]: {
      margin: 0,
      width: "100%",
    },
    flexGrow: 1,
    marginRight: 0,
    padding: theme.spacing(2),
  },
  buttonContainer: {
    display: "flex",
    justifyContent: "center",
    paddingBottom: theme.spacing(1),
    paddingTop: theme.spacing(1),
  },
  linkStyle: {
    "&:hover": {
      textDecoration: "underline",
    },
    color: "inherit",
    fontSize: "1rem",
    textDecoration: "none",
  },
  root: {
    paddingTop: theme.spacing(3),
    [theme.breakpoints.up("md")]: {
      paddingTop: 0,
      display: "flex",
    },
  },
  tabPanel: {
    padding: 0,
  },
}));
 
export default function EditProfilePage({
  tab = "about",
}: {
  tab?: EditUserTab;
}) {
  const classes = useStyles();
  const router = useRouter();
 
  return (
    <>
      <HtmlMeta title={t("profile:heading.edit_profile")} />
      <Grid
        container
        direction="row"
        justifyContent="space-between"
        alignItems="center"
      >
        <PageTitle>{t("profile:heading.edit_profile")}</PageTitle>
        <div className={classes.buttonContainer}>
          <Link href={settingsRoute} passHref>
            <Button component="a" variant="contained" color="primary">
              {t("global:nav.account_settings")}
            </Button>
          </Link>
        </div>
      </Grid>
      <div className={classes.root}>
        <Card className={classes.detailsCard}>
          <TabContext value={tab}>
            <TabBar
              setValue={(newTab) => router.push(routeToEditProfile(newTab))}
              labels={{
                about: t("profile:heading.about_me"),
                home: t("profile:heading.home"),
              }}
              ariaLabel={t("profile:edit_profile_tab_bar_a11y_label")}
            />
            <TabPanel classes={{ root: classes.tabPanel }} value="about">
              <EditProfile />
            </TabPanel>
            <TabPanel value="home">
              <EditHostingPreference />
            </TabPanel>
          </TabContext>
        </Card>
      </div>
    </>
  );
}