fix: routing form redirects to use app.cal.com instead of cal.com (#21924)
* fix: routing form redirects to use app.cal.com instead of cal.com * Update packages/lib/hooks/useBookerUrl.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * update --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
parent
12cb94950a
commit
3714d5faab
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
import { CAL_URL } from "@calcom/lib/constants";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
import { getAbsoluteEventTypeRedirectUrl } from "../getEventTypeRedirectUrl";
|
||||
|
||||
@@ -20,13 +20,13 @@ describe("getAbsoluteEventTypeRedirectUrl", () => {
|
||||
isEmbed: false,
|
||||
};
|
||||
|
||||
it("should return CAL_URL for non-migrated user", () => {
|
||||
it("should return WEBAPP_URL for non-migrated user", () => {
|
||||
const result = getAbsoluteEventTypeRedirectUrl({
|
||||
...defaultParams,
|
||||
eventTypeRedirectUrl: "user/event",
|
||||
form: { ...defaultForm, nonOrgUsername: "user" },
|
||||
});
|
||||
expect(result).toBe(`${CAL_URL}/user/event?`);
|
||||
expect(result).toBe(`${WEBAPP_URL}/user/event?`);
|
||||
});
|
||||
|
||||
it("should return user origin for migrated user", () => {
|
||||
@@ -34,13 +34,13 @@ describe("getAbsoluteEventTypeRedirectUrl", () => {
|
||||
expect(result).toBe("https://user.cal.com/user/event?");
|
||||
});
|
||||
|
||||
it("should return CAL_URL for non-migrated team", () => {
|
||||
it("should return WEBAPP_URL for non-migrated team", () => {
|
||||
const result = getAbsoluteEventTypeRedirectUrl({
|
||||
...defaultParams,
|
||||
eventTypeRedirectUrl: "team/team1/event",
|
||||
form: { ...defaultForm, nonOrgTeamslug: "team1" },
|
||||
});
|
||||
expect(result).toBe(`${CAL_URL}/team/team1/event?`);
|
||||
expect(result).toBe(`${WEBAPP_URL}/team/team1/event?`);
|
||||
});
|
||||
|
||||
it("should return team origin for migrated team", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getOrgFullOrigin } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import { CAL_URL } from "@calcom/lib/constants";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { teamMetadataSchema, userMetadata } from "@calcom/prisma/zod-utils";
|
||||
|
||||
export const enrichFormWithMigrationData = <
|
||||
@@ -45,12 +45,12 @@ export const enrichFormWithMigrationData = <
|
||||
? getOrgFullOrigin(formOwnerOrgSlug, {
|
||||
protocol: true,
|
||||
})
|
||||
: CAL_URL,
|
||||
: WEBAPP_URL,
|
||||
teamOrigin: form.team?.parent?.slug
|
||||
? getOrgFullOrigin(form.team.parent.slug, {
|
||||
protocol: true,
|
||||
})
|
||||
: CAL_URL,
|
||||
: WEBAPP_URL,
|
||||
nonOrgUsername,
|
||||
nonOrgTeamslug,
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
|
||||
|
||||
import type { BookerLayout } from "@calcom/features/bookings/Booker/types";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||
import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { TextArea } from "@calcom/ui/components/form";
|
||||
|
||||
@@ -188,7 +188,7 @@ ${getEmbedTypeSpecificString({
|
||||
HTMLIFrameElement | HTMLTextAreaElement | null,
|
||||
{ calLink: string; embedType: EmbedType; previewState: PreviewState; namespace: string }
|
||||
>(function Preview({ calLink, embedType }, ref) {
|
||||
const bookerUrl = useBookerUrl();
|
||||
const bookerUrl = useEmbedBookerUrl();
|
||||
const iframeSrc = `${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`;
|
||||
if (ref instanceof Function || !ref) {
|
||||
return null;
|
||||
@@ -329,7 +329,7 @@ const getInstructionString = ({
|
||||
};
|
||||
|
||||
function useGetEmbedSnippetString(namespace: string | null) {
|
||||
const bookerUrl = useBookerUrl();
|
||||
const bookerUrl = useEmbedBookerUrl();
|
||||
// TODO: Import this string from @calcom/embed-snippet
|
||||
// Right now the problem is that embed-snippet export is not minified and has comments which makes it unsuitable for giving it to users.
|
||||
// If we can minify that during build time and then import the built code here, that could work
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||
import { useEmbedBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
export const useEmbedTypes = () => {
|
||||
@@ -319,6 +319,6 @@ export const useEmbedTypes = () => {
|
||||
};
|
||||
|
||||
export const useEmbedCalOrigin = () => {
|
||||
const bookerUrl = useBookerUrl();
|
||||
const bookerUrl = useEmbedBookerUrl();
|
||||
return bookerUrl;
|
||||
};
|
||||
|
||||
@@ -5,3 +5,8 @@ export const useBookerUrl = () => {
|
||||
const orgBranding = useOrgBranding();
|
||||
return orgBranding?.fullDomain ?? WEBSITE_URL ?? WEBAPP_URL;
|
||||
};
|
||||
|
||||
export const useEmbedBookerUrl = () => {
|
||||
const orgBranding = useOrgBranding();
|
||||
return orgBranding?.fullDomain ?? WEBAPP_URL;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user