diff --git a/apps/web/components/eventtype/EventTeamTab.tsx b/apps/web/components/eventtype/EventTeamTab.tsx index f76603cf3a..a5dc455b19 100644 --- a/apps/web/components/eventtype/EventTeamTab.tsx +++ b/apps/web/components/eventtype/EventTeamTab.tsx @@ -33,6 +33,7 @@ export const mapMemberToChildrenOption = ( membership: member.membership, eventTypeSlugs: member.eventTypes ?? [], avatar: member.avatar, + profile: member.profile, }, value: `${member.id ?? ""}`, label: `${member.name || member.email || ""}${!member.username ? ` (${pendingString})` : ""}`, diff --git a/packages/features/test/orgDomains.test.ts b/packages/features/ee/organizations/lib/orgDomains.test.ts similarity index 100% rename from packages/features/test/orgDomains.test.ts rename to packages/features/ee/organizations/lib/orgDomains.test.ts diff --git a/packages/features/ee/teams/pages/team-profile-view.tsx b/packages/features/ee/teams/pages/team-profile-view.tsx index 64a9e684cf..43f51a7c38 100644 --- a/packages/features/ee/teams/pages/team-profile-view.tsx +++ b/packages/features/ee/teams/pages/team-profile-view.tsx @@ -115,7 +115,12 @@ const ProfileView = () => { const isAdmin = team && (team.membership.role === MembershipRole.OWNER || team.membership.role === MembershipRole.ADMIN); - const permalink = `${WEBAPP_URL}/team/${team?.slug}`; + const permalink = team + ? `${getTeamUrlSync({ + orgSlug: team.parent ? team.parent.slug : null, + teamSlug: team.slug, + })}` + : ""; const isBioEmpty = !team || !team.bio || !team.bio.replace("


", "").length; diff --git a/packages/features/eventtypes/components/ChildrenEventTypeSelect.tsx b/packages/features/eventtypes/components/ChildrenEventTypeSelect.tsx index 24488c5b7c..be6fd104b3 100644 --- a/packages/features/eventtypes/components/ChildrenEventTypeSelect.tsx +++ b/packages/features/eventtypes/components/ChildrenEventTypeSelect.tsx @@ -1,11 +1,11 @@ import { useAutoAnimate } from "@formkit/auto-animate/react"; import type { Props } from "react-select"; -import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider"; import { classNames } from "@calcom/lib"; -import { WEBSITE_URL } from "@calcom/lib/constants"; +import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { MembershipRole } from "@calcom/prisma/enums"; +import type { UserProfile } from "@calcom/types/UserProfile"; import { Avatar, Badge, Button, ButtonGroup, Select, Switch, Tooltip } from "@calcom/ui"; export type ChildrenEventType = { @@ -20,6 +20,7 @@ export type ChildrenEventType = { username: string; membership: MembershipRole; eventTypeSlugs: string[]; + profile: UserProfile; }; slug: string; hidden: boolean; @@ -35,10 +36,7 @@ export const ChildrenEventTypeSelect = ({ onChange: (value: readonly ChildrenEventType[]) => void; }) => { const { t } = useLocale(); - const orgBranding = useOrgBranding(); - const [animationRef] = useAutoAnimate(); - const domain = orgBranding?.fullDomain ?? WEBSITE_URL; return ( <> @@ -109,7 +107,9 @@ export const ChildrenEventTypeSelect = ({ color="secondary" target="_blank" variant="icon" - href={`${domain}/${children.owner?.username}/${children.slug}`} + href={`${getBookerBaseUrlSync( + children.owner.profile?.organization?.slug ?? null + )}/${children.owner?.username}/${children.slug}`} StartIcon="external-link" /> diff --git a/packages/lib/getBookerUrl/client.test.ts b/packages/lib/getBookerUrl/client.test.ts new file mode 100644 index 0000000000..4a57c545ce --- /dev/null +++ b/packages/lib/getBookerUrl/client.test.ts @@ -0,0 +1,30 @@ +import { describe, it, vi, expect } from "vitest"; + +import { getTeamUrlSync } from "./client"; +import * as getBookerBaseUrlSyncExport from "./getBookerBaseUrlSync"; + +vi.mock("./getBookerBaseUrlSync", async () => { + return { + getBookerBaseUrlSync: vi.fn(), + }; +}); + +describe("getBookerUrl:client", () => { + describe("getTeamUrlSync", () => { + it("if orgSlug is null, it should return a URL with /team in it", () => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + getBookerBaseUrlSyncExport.getBookerBaseUrlSync.mockReturnValueOnce("https://abc.com"); + const url = getTeamUrlSync({ orgSlug: null, teamSlug: "myTeam" }); + expect(url).toBe("https://abc.com/team/myTeam"); + }); + + it("if orgSlug is set, it should return a URL without /team in it", () => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + getBookerBaseUrlSyncExport.getBookerBaseUrlSync.mockReturnValueOnce("https://acme.com"); + const url = getTeamUrlSync({ orgSlug: "acme", teamSlug: "myTeam" }); + expect(url).toBe("https://acme.com/myTeam"); + }); + }); +}); diff --git a/packages/lib/getBookerUrl/client.ts b/packages/lib/getBookerUrl/client.ts index 6eaa692764..c018d51f13 100644 --- a/packages/lib/getBookerUrl/client.ts +++ b/packages/lib/getBookerUrl/client.ts @@ -1,14 +1,6 @@ -import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains"; - -export const getBookerBaseUrlSync = ( - orgSlug: string | null, - options?: { - protocol: boolean; - } -) => { - return getOrgFullOrigin(orgSlug ?? "", options); -}; +import { getBookerBaseUrlSync } from "./getBookerBaseUrlSync"; +export { getBookerBaseUrlSync } from "./getBookerBaseUrlSync"; export const getTeamUrlSync = ( { orgSlug, diff --git a/packages/lib/getBookerUrl/getBookerBaseUrlSync.ts b/packages/lib/getBookerUrl/getBookerBaseUrlSync.ts new file mode 100644 index 0000000000..2109bec816 --- /dev/null +++ b/packages/lib/getBookerUrl/getBookerBaseUrlSync.ts @@ -0,0 +1,10 @@ +import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains"; + +export const getBookerBaseUrlSync = ( + orgSlug: string | null, + options?: { + protocol: boolean; + } +) => { + return getOrgFullOrigin(orgSlug ?? "", options); +};