All files / app/features/communities/events EventUsers.tsx

100% Statements 11/11
100% Branches 2/2
100% Functions 2/2
100% Lines 10/10

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 584x 4x 4x   4x 4x 4x   22x                                   75x               75x 75x                                            
import { Card, Typography } from "@mui/material";
import Button from "components/Button";
import UsersList from "components/UsersList";
import { RpcError } from "grpc-web";
import { useTranslation } from "i18n";
import { COMMUNITIES } from "i18n/namespaces";
import makeStyles from "utils/makeStyles";
 
const useStyles = makeStyles((theme) => ({
  cardSection: {
    padding: theme.spacing(2),
  },
  seeAllButton: {
    justifySelf: "center",
  },
}));
 
export interface EventUsersProps {
  emptyState: string;
  error: RpcError | null;
  hasNextPage?: boolean;
  onSeeAllClick?(): void;
  userIds: number[] | undefined;
  title: string;
}
 
export default function EventUsers({
  emptyState,
  error,
  hasNextPage,
  onSeeAllClick,
  userIds,
  title,
}: EventUsersProps) {
  const { t } = useTranslation([COMMUNITIES]);
  const classes = useStyles();
 
  return (
    <Card className={classes.cardSection}>
      <Typography variant="h2">{title}</Typography>
      <UsersList
        error={error}
        userIds={userIds}
        endChildren={
          hasNextPage && (
            <Button className={classes.seeAllButton} onClick={onSeeAllClick}>
              {t("communities:see_all")}
            </Button>
          )
        }
        emptyListChildren={
          !error && <Typography variant="body1">{emptyState}</Typography>
        }
      />
    </Card>
  );
}