All files / app/components TOS.tsx

0% Statements 0/20
0% Branches 0/5
0% Functions 0/3
0% Lines 0/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                                                                                                 
import { CircularProgress } from "@material-ui/core";
import HtmlMeta from "components/HtmlMeta";
import Markdown from "components/Markdown";
import PageTitle from "components/PageTitle";
import { tosQueryKey } from "features/queryKeys";
import { RpcError } from "grpc-web";
import { useTranslation } from "i18n";
import { GLOBAL } from "i18n/namespaces";
import { GetTermsOfServiceRes } from "proto/resources_pb";
import { useQuery } from "react-query";
import { service } from "service";
import makeStyles from "utils/makeStyles";
 
const useStyles = makeStyles((theme) => ({
  root: {
    maxWidth: theme.breakpoints.values.lg,
    margin: "0 auto",
    padding: theme.spacing(2),
  },
}));
 
export default function TOS() {
  const { t } = useTranslation(GLOBAL);
  const classes = useStyles();
  const { data, error, isLoading } = useQuery<
    GetTermsOfServiceRes.AsObject,
    RpcError
  >({
    queryKey: tosQueryKey,
    queryFn: () => service.resources.getTermsOfService(),
  });
 
  Iif (error) {
    // Re-throw error to trigger error boundary to encourage user to report it
    // if they can't see the terms
    throw error;
  }
 
  return isLoading ? (
    <CircularProgress />
  ) : data ? (
    <div className={classes.root}>
      <HtmlMeta title={t("terms_of_service")} />
      <PageTitle>{t("terms_of_service")}</PageTitle>
      <Markdown source={data?.termsOfService} />
    </div>
  ) : null;
}