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

75% Statements 9/12
28.57% Branches 2/7
33.33% Functions 1/3
80% Lines 8/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 304x 4x 4x             4x       24x 33x   33x 33x                        
import { styled } from "@mui/styles";
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];
        return <Badge key={badge.id} badge={badge} />;
      })}
    </StyledContainer>
  );
};