All files / app/features/dashboard CommunitiesSection.tsx

0% Statements 0/16
100% Branches 0/0
0% Functions 0/4
0% Lines 0/15

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                                                                                                                                                 
import { Link as MuiLink, makeStyles, Typography } from "@material-ui/core";
import CommunitiesDialog from "features/dashboard/CommunitiesDialog";
import CommunitiesList from "features/dashboard/CommunitiesList";
import { Trans, useTranslation } from "i18n";
import { DASHBOARD, GLOBAL } from "i18n/namespaces";
import { useState } from "react";
 
const COMMUNITY_BUILDER_FORM_LINK =
  "https://couchers.org/community-builder-form";
 
const useStyles = makeStyles((theme) => ({
  createCommunityText: {
    paddingBlockStart: theme.spacing(2),
  },
  browseCommunitiesLink: {
    verticalAlign: "baseline",
  },
}));
 
export default function CommunitiesSection() {
  const { t } = useTranslation([GLOBAL, DASHBOARD]);
  const classes = useStyles();
  const [isCommunitiesDialogOpen, setIsCommunitiesDialogOpen] = useState(false);
 
  return (
    <>
      <Typography variant="h2" gutterBottom>
        {t("dashboard:your_communities_heading")}
      </Typography>
      <Typography variant="body1" paragraph>
        <Trans i18nKey="dashboard:your_communities_helper_text">
          {`You have been added to all communities based on your location. Feel free to `}
          <MuiLink
            component="button"
            className={classes.browseCommunitiesLink}
            onClick={() => {
              setIsCommunitiesDialogOpen(true);
            }}
          >
            {/* @todo: revisit this UI. A button that opens a popup shouldn't look like a link */}
            browse communities
          </MuiLink>
          {` in other locations as well.`}
        </Trans>
      </Typography>
 
      <CommunitiesList />
 
      <CommunitiesDialog
        isOpen={isCommunitiesDialogOpen}
        onClose={() => setIsCommunitiesDialogOpen(false)}
      />
 
      <Typography
        variant="body1"
        paragraph
        className={classes.createCommunityText}
      >
        <Trans i18nKey="dashboard:your_communities_helper_text2">
          {`Don't see your community? `}
          <MuiLink
            href={COMMUNITY_BUILDER_FORM_LINK}
            target="_blank"
            rel="noreferrer noopener"
          >
            Get it started!
          </MuiLink>
        </Trans>
      </Typography>
    </>
  );
}