Implement the new Avatar interface to the teams page (#512)
This commit is contained in:
parent
aec22d9362
commit
ce64080160
2 changed files with 13 additions and 13 deletions
|
@ -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">
|
<section className="space-y-2">
|
||||||
<Text variant="title">{member.user.name}</Text>
|
<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">
|
<article className="flex flex-col space-y-8 lg:space-y-12">
|
||||||
<div className="mb-8 text-center">
|
<div className="mb-8 text-center">
|
||||||
<Avatar
|
<Avatar
|
||||||
user={{
|
displayName={team.name}
|
||||||
email: team.name,
|
imageSrc={team.logo}
|
||||||
}}
|
|
||||||
className="mx-auto w-20 h-20 rounded-full mb-4"
|
className="mx-auto w-20 h-20 rounded-full mb-4"
|
||||||
/>
|
/>
|
||||||
<Text variant="headline">{team.name}</Text>
|
<Text variant="headline">{team.name}</Text>
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
import { Team } from "@prisma/client";
|
import { Team } from "@prisma/client";
|
||||||
import prisma from "@lib/prisma";
|
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> => {
|
export const getTeam = async (idOrSlug: string): Promise<Team | null> => {
|
||||||
const teamIdOrSlug = idOrSlug;
|
const teamIdOrSlug = idOrSlug;
|
||||||
|
|
||||||
let team = null;
|
|
||||||
|
|
||||||
log.debug(`{teamIdOrSlug} ${teamIdOrSlug}`);
|
|
||||||
|
|
||||||
const teamSelectInput = {
|
const teamSelectInput = {
|
||||||
id: true,
|
id: true,
|
||||||
name: 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: {
|
where: {
|
||||||
OR: [
|
OR: [
|
||||||
{
|
{
|
||||||
|
@ -48,7 +42,10 @@ export const getTeam = async (idOrSlug: string): Promise<Team | null> => {
|
||||||
select: teamSelectInput,
|
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;
|
return team;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue