cal/packages/lib/server/getBrand.ts
Hariom Balhara 9d06f6dd0e
fix: Fix 'Book a new time' link in request-reschedule for Team Event (#12261)
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2023-11-14 13:23:44 -07:00

36 lines
821 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: {
logo: 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,
};
};