2023-10-24 10:42:36 +00:00
|
|
|
import { subdomainSuffix, getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
|
2023-07-13 13:52:21 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const metadata = teamMetadataSchema.parse(org?.metadata);
|
|
|
|
const slug = (org?.slug || metadata?.requestedSlug) as string;
|
2023-10-24 10:42:36 +00:00
|
|
|
const fullDomain = getOrgFullOrigin(slug);
|
2023-07-13 13:52:21 +00:00
|
|
|
const domainSuffix = subdomainSuffix();
|
|
|
|
|
|
|
|
return {
|
|
|
|
...org,
|
|
|
|
metadata,
|
|
|
|
slug,
|
|
|
|
fullDomain,
|
|
|
|
domainSuffix,
|
|
|
|
};
|
|
|
|
};
|