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

64.28% Statements 9/14
33.33% Branches 2/6
33.33% Functions 1/3
66.66% Lines 8/12

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 334x 4x 4x             4x       27x 36x   36x 36x                              
import { styled } from "@mui/material";
import Badge from "features/badges/Badge";
import { useBadges } from "features/badges/hooks";
import { User } from "proto/api_pb";
 
interface Props {
  user: User.AsObject;
}
 
const StyledContainer = styled("div")(({ theme }) => ({
  marginTop: theme.spacing(1),
}));
 
export const Badges = ({ user }: Props) => {
  const { badges } = useBadges();
 
  if (badges === undefined || user.badgesList === undefined) {
    return <></>;
  }
 
  return (
    <StyledContainer>
      {(user.badgesList || []).map((badgeId) => {
        const badge = badges[badgeId];
        Iif (!badge) {
          return null;
        }
        return <Badge key={badge.id} badge={badge} />;
      })}
    </StyledContainer>
  );
};