Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Links on avatar for org events (#12892)

Hariom Balhara9a2c2aaca4ef
diff --git a/apps/web/components/ui/avatar/UserAvatarGroupWithOrg.tsx b/apps/web/components/ui/avatar/UserAvatarGroupWithOrg.tsx
index 6b265395d8a..7fcef0b6a88 100644
--- a/apps/web/components/ui/avatar/UserAvatarGroupWithOrg.tsx
+++ b/apps/web/components/ui/avatar/UserAvatarGroupWithOrg.tsx
@@ -1,21 +1,19 @@
-import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
-import { CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
+import { WEBAPP_URL } from "@calcom/lib/constants";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
+import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
import type { Team, User } from "@calcom/prisma/client";
import { AvatarGroup } from "@calcom/ui";
type UserAvatarProps = Omit<React.ComponentProps<typeof AvatarGroup>, "items"> & {
- users: Pick<User, "organizationId" | "name" | "username">[];
+ users: (Pick<User, "organizationId" | "name" | "username"> & { bookerUrl: string })[];
organization: Pick<Team, "slug" | "name">;
};
export function UserAvatarGroupWithOrg(props: UserAvatarProps) {
const { users, organization, ...rest } = props;
- const orgBranding = useOrgBranding();
- const baseUrl = `${orgBranding?.fullDomain ?? CAL_URL}`;
const items = [
{
- href: baseUrl,
+ href: getBookerBaseUrlSync(organization.slug),
image: `${WEBAPP_URL}/team/${organization.slug}/avatar.png`,
alt: organization.name || undefined,
title: organization.name,
@@ -23,13 +21,12 @@ export function UserAvatarGroupWithOrg(props: UserAvatarProps) {
].concat(
users.map((user) => {
return {
- href: `${baseUrl}/${user.username}/?redirect=false`,
+ href: `${user.bookerUrl}/${user.username}?redirect=false`,
image: getUserAvatarUrl(user),
alt: user.name || undefined,
title: user.name || user.username || "",
};
})
);
- users.unshift();
return <AvatarGroup {...rest} items={items} />;
}
diff --git a/packages/features/eventtypes/lib/getPublicEvent.ts b/packages/features/eventtypes/lib/getPublicEvent.ts
index b54976499f7..1c2d1d34626 100644
--- a/packages/features/eventtypes/lib/getPublicEvent.ts
+++ b/packages/features/eventtypes/lib/getPublicEvent.ts
@@ -8,6 +8,7 @@ import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/
import { getSlugOrRequestedSlug } from "@calcom/features/ee/organizations/lib/orgDomains";
import { isRecurringEvent, parseRecurringEvent } from "@calcom/lib";
import { getDefaultEvent, getUsernameList } from "@calcom/lib/defaultEvents";
+import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
import type { PrismaClient } from "@calcom/prisma";
import type { BookerLayoutSettings } from "@calcom/prisma/zod-utils";
@@ -82,6 +83,11 @@ const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
darkBrandColor: true,
theme: true,
organizationId: true,
+ organization: {
+ select: {
+ slug: true,
+ },
+ },
metadata: true,
},
},
@@ -172,7 +178,11 @@ export const getPublicEvent = async (
...defaultEvent,
bookingFields: getBookingFieldsWithSystemFields({ ...defaultEvent, disableBookingTitle }),
// Clears meta data since we don't want to send this in the public api.
- users: users.map((user) => ({ ...user, metadata: undefined })),
+ users: users.map((user) => ({
+ ...user,
+ metadata: undefined,
+ bookerUrl: getBookerBaseUrlSync(user.organization?.slug ?? null),
+ })),
locations: privacyFilteredLocations(locations),
profile: {
username: users[0].username,
@@ -299,23 +309,50 @@ function getUsersFromEvent(event: Event) {
return null;
}
const { username, name, weekStart, organizationId } = owner;
- return [{ username, name, weekStart, organizationId }];
+ return [
+ {
+ username,
+ name,
+ weekStart,
+ organizationId,
+ bookerUrl: getBookerBaseUrlSync(owner.organization?.slug ?? null),
+ },
+ ];
}
async function getOwnerFromUsersArray(prisma: PrismaClient, eventTypeId: number) {
const { users } = await prisma.eventType.findUniqueOrThrow({
where: { id: eventTypeId },
- select: { users: { select: { username: true, name: true, weekStart: true, organizationId: true } } },
+ select: {
+ users: {
+ select: {
+ username: true,
+ name: true,
+ weekStart: true,
+ organizationId: true,
+ organization: {
+ select: {
+ slug: true,
+ },
+ },
+ },
+ },
+ },
});
if (!users.length) return null;
- return [users[0]];
+ return [{ ...users[0], bookerUrl: getBookerBaseUrlSync(users[0].organization?.slug ?? null) }];
}
-function mapHostsToUsers(host: { user: Pick<User, "username" | "name" | "weekStart" | "organizationId"> }) {
+function mapHostsToUsers(host: {
+ user: Pick<User, "username" | "name" | "weekStart" | "organizationId"> & {
+ organization: { slug: string | null } | null;
+ };
+}) {
return {
username: host.user.username,
name: host.user.name,
weekStart: host.user.weekStart,
organizationId: host.user.organizationId,
+ bookerUrl: getBookerBaseUrlSync(host.user.organization?.slug ?? null),
};
}
diff --git a/packages/lib/domainManager/deploymentServices/vercel.ts b/packages/lib/domainManager/deploymentServices/vercel.ts
index 7195e4a58b0..65c1292ee09 100644
--- a/packages/lib/domainManager/deploymentServices/vercel.ts
+++ b/packages/lib/domainManager/deploymentServices/vercel.ts
@@ -93,7 +93,7 @@ function handleDomainCreationError(error: { code?: string | null; domain?: strin
return true;
}
- const errorMessage = `Failed to take action for domain: ${error.domain}`;
+ const errorMessage = `Failed to create domain on Vercel: ${error.domain}`;
logger.error(safeStringify({ errorMessage, vercelError: error }));
throw new HttpError({
message: errorMessage,