2
0
Files
cal/calcom/packages/lib/server/getBrand.ts
2024-08-09 00:39:27 +02:00

36 lines
824 B
TypeScript

import { subdomainSuffix, getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
import { prisma } from "@calcom/prisma";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
export const getBrand = async (orgId: number | null) => {
if (!orgId) {
return null;
}
const org = await prisma.team.findFirst({
where: {
id: orgId,
},
select: {
logoUrl: true,
name: true,
slug: true,
metadata: true,
},
});
if (!org) {
return null;
}
const metadata = teamMetadataSchema.parse(org.metadata);
const slug = (org.slug || metadata?.requestedSlug) as string;
const fullDomain = getOrgFullOrigin(slug);
const domainSuffix = subdomainSuffix();
return {
...org,
metadata,
slug,
fullDomain,
domainSuffix,
};
};