Implement the new Avatar interface to the teams page (#512)

This commit is contained in:
Alex van Andel 2021-08-23 10:40:57 +01:00 committed by GitHub
parent aec22d9362
commit ce64080160
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View file

@ -37,7 +37,11 @@ const Team = ({ team }) => {
)}
/>
<Avatar user={member.user} className="w-12 h-12 rounded-full" />
<Avatar
displayName={member.user.name}
imageSrc={member.user.avatar}
className="w-12 h-12 rounded-full"
/>
<section className="space-y-2">
<Text variant="title">{member.user.name}</Text>
@ -68,9 +72,8 @@ const Team = ({ team }) => {
<article className="flex flex-col space-y-8 lg:space-y-12">
<div className="mb-8 text-center">
<Avatar
user={{
email: team.name,
}}
displayName={team.name}
imageSrc={team.logo}
className="mx-auto w-20 h-20 rounded-full mb-4"
/>
<Text variant="headline">{team.name}</Text>

View file

@ -1,15 +1,9 @@
import { Team } from "@prisma/client";
import prisma from "@lib/prisma";
import logger from "@lib/logger";
import { defaultAvatarSrc } from "@lib/profile";
const log = logger.getChildLogger({ prefix: ["[lib] getTeam"] });
export const getTeam = async (idOrSlug: string): Promise<Team | null> => {
const teamIdOrSlug = idOrSlug;
let team = null;
log.debug(`{teamIdOrSlug} ${teamIdOrSlug}`);
const teamSelectInput = {
id: true,
name: true,
@ -34,7 +28,7 @@ export const getTeam = async (idOrSlug: string): Promise<Team | null> => {
},
};
team = await prisma.team.findFirst({
const team = await prisma.team.findFirst({
where: {
OR: [
{
@ -48,7 +42,10 @@ export const getTeam = async (idOrSlug: string): Promise<Team | null> => {
select: teamSelectInput,
});
log.debug(`{team}`, { team });
team.members = team.members.map((member) => {
member.user.avatar = member.user.avatar || defaultAvatarSrc({ email: member.user.email });
return member;
});
return team;
};