diff --git a/apps/web/components/eventtype/EventTypeSingleLayout.tsx b/apps/web/components/eventtype/EventTypeSingleLayout.tsx index c989ea01d0..a6408e44e5 100644 --- a/apps/web/components/eventtype/EventTypeSingleLayout.tsx +++ b/apps/web/components/eventtype/EventTypeSingleLayout.tsx @@ -7,6 +7,7 @@ import { useMemo, useState, Suspense } from "react"; import type { UseFormReturn } from "react-hook-form"; import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager"; +import { useOrgBrandingValues } from "@calcom/features/ee/organizations/hooks"; import Shell from "@calcom/features/shell/Shell"; import { classNames } from "@calcom/lib"; import { CAL_URL } from "@calcom/lib/constants"; @@ -233,9 +234,11 @@ function EventTypeSingleLayout({ formMethods, ]); - const permalink = `${CAL_URL}/${team ? `team/${team.slug}` : eventType.users[0].username}/${ - eventType.slug - }`; + const orgBranding = useOrgBrandingValues(); + const isOrgEvent = orgBranding?.fullDomain; + const permalink = `${orgBranding?.fullDomain ?? CAL_URL}/${ + team ? `${!isOrgEvent ? "team/" : ""}${team.slug}` : eventType.users[0].username + }/${eventType.slug}`; const embedLink = `${team ? `team/${team.slug}` : eventType.users[0].username}/${eventType.slug}`; const isManagedEvent = eventType.schedulingType === SchedulingType.MANAGED ? "_managed" : ""; diff --git a/packages/app-store/routing-forms/components/FormActions.tsx b/packages/app-store/routing-forms/components/FormActions.tsx index 6abba3f51b..bdad562f7b 100644 --- a/packages/app-store/routing-forms/components/FormActions.tsx +++ b/packages/app-store/routing-forms/components/FormActions.tsx @@ -7,8 +7,9 @@ import { Controller } from "react-hook-form"; import { v4 as uuidv4 } from "uuid"; import { z } from "zod"; +import { useOrgBrandingValues } from "@calcom/features/ee/organizations/hooks"; import { classNames } from "@calcom/lib"; -import getOrgAwareUrlOnClient from "@calcom/lib/getOrgAwareUrl"; +import { CAL_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import type { ButtonProps } from "@calcom/ui"; @@ -401,11 +402,13 @@ export const FormAction = forwardRef(function FormAction { - relativeRedirectUrl += `&${getFieldIdentifier(field)}={Recalled_Response_For_This_Field}`; + redirectUrl += `&${getFieldIdentifier(field)}={Recalled_Response_For_This_Field}`; }); const { t } = useLocale(); @@ -415,12 +418,12 @@ export const FormAction = forwardRef(function FormAction["render"] } > = { preview: { - href: formRelativeLink, + href: formLink, }, copyLink: { onClick: () => { showToast(t("link_copied"), "success"); - navigator.clipboard.writeText(getOrgAwareUrlOnClient(formRelativeLink)); + navigator.clipboard.writeText(formLink); }, }, duplicate: { @@ -447,7 +450,7 @@ export const FormAction = forwardRef(function FormAction { - navigator.clipboard.writeText(getOrgAwareUrlOnClient(relativeRedirectUrl)); + navigator.clipboard.writeText(redirectUrl); showToast(t("typeform_redirect_url_copied"), "success"); }, }, diff --git a/packages/features/ee/teams/components/MemberListItem.tsx b/packages/features/ee/teams/components/MemberListItem.tsx index 4e43f249fe..90394181de 100644 --- a/packages/features/ee/teams/components/MemberListItem.tsx +++ b/packages/features/ee/teams/components/MemberListItem.tsx @@ -2,6 +2,7 @@ import classNames from "classnames"; import { signIn } from "next-auth/react"; import { useState } from "react"; +import { useOrgBrandingValues } from "@calcom/features/ee/organizations/hooks"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { MembershipRole } from "@calcom/prisma/enums"; @@ -53,6 +54,7 @@ const checkIsOrg = (team: Props["team"]) => { export default function MemberListItem(props: Props) { const { t } = useLocale(); + const orgBranding = useOrgBrandingValues(); const utils = trpc.useContext(); const [showChangeMemberRoleModal, setShowChangeMemberRoleModal] = useState(false); @@ -116,7 +118,7 @@ export default function MemberListItem(props: Props) {
@@ -137,7 +139,7 @@ export default function MemberListItem(props: Props) { • {bookingLink} diff --git a/packages/lib/getOrgAwareUrl.ts b/packages/lib/getOrgAwareUrl.ts deleted file mode 100644 index 7cd0b794a7..0000000000 --- a/packages/lib/getOrgAwareUrl.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { CAL_URL, WEBAPP_URL } from "./constants"; - -/** - * It is a simpler(no HTTP request) alternative to get full URL of a path - * Should be used on app.cal.com Pages and not Booking Pages(which can be accessed through website URL also) - */ -export function getOrgAwareUrlOnClient(path: string) { - if (!path.startsWith("/")) { - throw new Error("path must start with /"); - } - const documentURLObj = new URL(document.URL); - const webAppUrlObj = new URL(WEBAPP_URL); - const isNonOrgDomain = documentURLObj.host === webAppUrlObj.host; - if (isNonOrgDomain) { - return `${CAL_URL}${path}`; - } - return `${documentURLObj.href.replace(/\/$/, "")}${path}`; -} - -export default getOrgAwareUrlOnClient;