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

70.37% Statements 19/27
73.68% Branches 14/19
71.42% Functions 5/7
68% Lines 17/25

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 106 107 108 109 110 111 112 113 1143x 3x 3x 3x 3x   3x   3x 3x 3x           30x       150x       21x 30x 30x 30x                                                                                                     14x               56x                                                      
import { styled, Typography, useTheme } from "@mui/material";
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 { useRegions } from "../hooks/useRegions";
import ProfilePhotoGallery from "./ProfilePhotoGallery";
import { AgeGenderLanguagesLabels, RemainingAboutLabels } from "./userLabels";
 
interface AboutProps {
  user: User.AsObject;
}
 
const StyledWrapper = styled("div")(({ theme }) => ({
  marginTop: theme.spacing(1),
}));
 
const StyledDivider = styled(Divider)(({ theme }) => ({
  marginTop: theme.spacing(3),
}));
 
export default function About({ user }: AboutProps) {
  const { t } = useTranslation([GLOBAL, PROFILE]);
  const theme = useTheme();
  const { regions } = useRegions();
  return (
    <StyledWrapper>
      <Typography variant="h1">
        {t("profile:heading.overview_section")}
      </Typography>
      <AgeGenderLanguagesLabels user={user} />
      <RemainingAboutLabels user={user} />
 
      {user.profileGalleryId && user.profileGalleryId > 0 && (
        <>
          <ProfilePhotoGallery galleryId={user.profileGalleryId} />
          <StyledDivider />
        </>
      )}
 
      {!user.profileGalleryId && <StyledDivider />}
 
      {user.aboutMe && (
        <>
          <Typography variant="h1">
            {t("profile:heading.who_section")}
          </Typography>
          <Markdown source={user.aboutMe} />
          <StyledDivider />
        </>
      )}
      {user.thingsILike && (
        <>
          <Typography variant="h1">
            {t("profile:heading.hobbies_section")}
          </Typography>
          <Markdown source={user.thingsILike} />
          <StyledDivider />
        </>
      )}
      {user.additionalInformation && (
        <>
          <Typography variant="h1">
            {t("profile:heading.additional_information_section")}
          </Typography>
          <Markdown source={user.additionalInformation} />
          <StyledDivider />
        </>
      )}
      <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>
      <StyledDivider />
      <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>
      <StyledDivider />
      <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>
    </StyledWrapper>
  );
}