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

70.37% Statements 19/27
72.22% Branches 13/18
66.66% Functions 4/6
69.23% Lines 18/26

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 101 102 103 104 105 1063x 3x 3x 3x 3x   3x 3x   3x 3x         15x                 3x 36x 36x 36x 36x 36x                                                                                 20x               80x                                                      
import { Typography, useTheme } from "@material-ui/core";
import Divider from "components/Divider";
import Markdown from "components/Markdown";
import { useTranslation } from "i18n";
import { GLOBAL, PROFILE } from "i18n/namespaces";
import { User } from "proto/api_pb";
import { ComposableMap, Geographies, Geography } from "react-simple-maps";
import makeStyles from "utils/makeStyles";
 
import { useRegions } from "../hooks/useRegions";
import { AgeGenderLanguagesLabels, RemainingAboutLabels } from "./userLabels";
 
interface AboutProps {
  user: User.AsObject;
}
const useStyles = makeStyles((theme) => ({
  root: {
    marginTop: theme.spacing(1),
  },
  marginTop3: {
    marginTop: theme.spacing(3),
  },
}));
 
export default function About({ user }: AboutProps) {
  const { t } = useTranslation([GLOBAL, PROFILE]);
  const classes = useStyles();
  const theme = useTheme();
  const { regions } = useRegions();
  return (
    <div className={classes.root}>
      <Typography variant="h1">
        {t("profile:heading.overview_section")}
      </Typography>
      <AgeGenderLanguagesLabels user={user} />
      <RemainingAboutLabels user={user} />
      <Divider className={classes.marginTop3} />
      {user.aboutMe && (
        <>
          <Typography variant="h1">
            {t("profile:heading.who_section")}
          </Typography>
          <Markdown source={user.aboutMe} />
          <Divider className={classes.marginTop3} />
        </>
      )}
      {user.thingsILike && (
        <>
          <Typography variant="h1">
            {t("profile:heading.hobbies_section")}
          </Typography>
          <Markdown source={user.thingsILike} />
          <Divider className={classes.marginTop3} />
        </>
      )}
      {user.additionalInformation && (
        <>
          <Typography variant="h1">
            {t("profile:heading.additional_information_section")}
          </Typography>
          <Markdown source={user.additionalInformation} />
          <Divider className={classes.marginTop3} />
        </>
      )}
      <Typography variant="h1">
        {t("profile:heading.travel_section")}
      </Typography>
      <Typography variant="body1">
        {regions && user.regionsVisitedList.length > 0
          ? user.regionsVisitedList
              .map((country) => regions[country])
              .join(`, `)
          : t("profile:regions_empty_state")}
      </Typography>
      <Divider className={classes.marginTop3} />
      <Typography variant="h1">{t("profile:heading.lived_section")}</Typography>
      <Typography variant="body1">
        {regions && user.regionsLivedList.length > 0
          ? user.regionsLivedList.map((country) => regions[country]).join(`, `)
          : t("profile:regions_empty_state")}
      </Typography>
      <Divider className={classes.marginTop3} />
      <Typography variant="h1">{t("profile:heading.map_section")}</Typography>
      <ComposableMap projection="geoEqualEarth">
        <Geographies geography={"/regions.json"}>
          {({ geographies }) =>
            geographies.map((geo) => {
              let color = theme.palette.grey[200];
              Iif (regions) {
                if (user.regionsLivedList.includes(geo.id)) {
                  color = theme.palette.primary.main;
                } else Iif (user.regionsVisitedList.includes(geo.id)) {
                  color = theme.palette.secondary.main;
                }
              }
              return (
                <Geography key={geo.rsmKey} geography={geo} fill={color} />
              );
            })
          }
        </Geographies>
      </ComposableMap>
    </div>
  );
}