feat: Implement orgs/teams logoUrls (#13699)

* feat: Implement orgs/teams logoUrls

* Use getAvatarUrl in team/[slug]

* Extract uploadLogo to standalone file for reuse

* Allow removing the team/organisation logo

* fix: API build fail due to server-only, removed
This commit is contained in:
Alex van Andel authored and GitHub committed 2024-02-16 10:35:53 -03:00
1 parent 477e102388
commit c08365f09c
14 files changed
+81 -37

No files matched your search

+2 -2
View File
@@ -29,7 +29,7 @@ export function getTeamAvatarUrl(
team: Pick<Team, "slug"> & {
organizationId?: number | null;
logoUrl?: string | null;
requestedSlug: string | null;
requestedSlug?: string | null;
}
) {
if (team.logoUrl) {
@@ -42,7 +42,7 @@ export function getTeamAvatarUrl(
export const getOrgAvatarUrl = (
org: Pick<Team, "slug"> & {
logoUrl?: string | null;
requestedSlug: string | null;
requestedSlug?: string | null;
}
) => {
if (org.logoUrl) {
@@ -87,6 +87,7 @@ export async function getTeamWithMembers(args: {
name: true,
slug: true,
...(!!includeTeamLogo ? { logo: true } : {}),
logoUrl: true,
bio: true,
hideBranding: true,
hideBookATeamMember: true,
@@ -232,6 +233,7 @@ export async function getTeamWithMembers(args: {
return {
...teamWithoutInviteTokens,
...(teamWithoutInviteTokens.logoUrl ? { logo: teamWithoutInviteTokens.logoUrl } : {}),
/** To prevent breaking we only return non-email attached token here, if we have one */
inviteToken: inviteTokens.find(
(token) =>
@@ -99,12 +99,6 @@ export class EventTypeRepository {
const profileId = lookupTarget.type === LookupTarget.User ? null : lookupTarget.id;
const select = {
...eventTypeSelect,
// TODO: As required by getByViewHandler - Make it configurable
team: {
select: {
id: true,
},
},
hashedLink: true,
users: { select: userSelect },
children: {
@@ -103,11 +103,6 @@ export class MembershipRepository {
eventTypes: {
select: {
...eventTypeSelect,
team: {
select: {
id: true,
},
},
hashedLink: true,
users: { select: userSelect },
children: {
+33
View File
@@ -0,0 +1,33 @@
import { v4 as uuidv4 } from "uuid";
import { prisma } from "@calcom/prisma";
export const uploadLogo = async ({
teamId,
logo: data,
}: {
teamId: number;
logo: string;
}): Promise<string> => {
const objectKey = uuidv4();
await prisma.avatar.upsert({
where: {
teamId_userId: {
teamId,
userId: 0,
},
},
create: {
teamId,
data,
objectKey,
},
update: {
data,
objectKey,
},
});
return `/api/avatar/${objectKey}.png`;
};