fix: Routing Form and other org related fixes (#10320)
Co-authored-by: Leo Giovanetti <hello@leog.me>
This commit is contained in:
parent
30095d0428
commit
35be4182e9
|
@ -16,6 +16,7 @@ import { TeamsFilter } from "@calcom/features/filters/components/TeamsFilter";
|
|||
import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { APP_NAME, CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
||||
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
||||
|
@ -710,7 +711,7 @@ const EventTypeListHeading = ({
|
|||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const bookerUrl = useBookerUrl();
|
||||
return (
|
||||
<div className="mb-4 flex items-center space-x-2">
|
||||
<Avatar
|
||||
|
@ -741,9 +742,7 @@ const EventTypeListHeading = ({
|
|||
)}
|
||||
{profile?.slug && (
|
||||
<Link href={`${CAL_URL}/${profile.slug}`} className="text-subtle block text-xs">
|
||||
{orgBranding
|
||||
? `${orgBranding.fullDomain.replace("https://", "").replace("http://", "")}${profile.slug}`
|
||||
: `${CAL_URL?.replace("https://", "").replace("http://", "")}/${profile.slug}`}
|
||||
{`${bookerUrl.replace("https://", "").replace("http://", "")}/${profile.slug}`}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import Head from "next/head";
|
||||
import z from "zod";
|
||||
|
||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import type { AppGetServerSidePropsContext, AppPrisma } from "@calcom/types/AppGetServerSideProps";
|
||||
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
|
||||
|
||||
|
@ -47,11 +48,21 @@ export const getServerSideProps = async function getServerSideProps(
|
|||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { form: formId, slug: _slug, pages: _pages, ...fieldsResponses } = queryParsed.data;
|
||||
const form = await prisma.app_RoutingForms_Form.findUnique({
|
||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||
|
||||
const form = await prisma.app_RoutingForms_Form.findFirst({
|
||||
where: {
|
||||
id: formId,
|
||||
user: {
|
||||
organization: isValidOrgDomain
|
||||
? {
|
||||
slug: currentOrgDomain,
|
||||
}
|
||||
: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!form) {
|
||||
return {
|
||||
notFound: true,
|
||||
|
|
|
@ -6,6 +6,7 @@ import { Toaster } from "react-hot-toast";
|
|||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import useGetBrandingColours from "@calcom/lib/getBrandColours";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
@ -246,11 +247,20 @@ export const getServerSideProps = async function getServerSideProps(
|
|||
notFound: true,
|
||||
};
|
||||
}
|
||||
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req.headers.host ?? "");
|
||||
|
||||
const isEmbed = params.appPages[1] === "embed";
|
||||
|
||||
const form = await prisma.app_RoutingForms_Form.findUnique({
|
||||
const form = await prisma.app_RoutingForms_Form.findFirst({
|
||||
where: {
|
||||
id: formId,
|
||||
user: {
|
||||
organization: isValidOrgDomain
|
||||
? {
|
||||
slug: currentOrgDomain,
|
||||
}
|
||||
: null,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
user: {
|
||||
|
|
|
@ -37,6 +37,5 @@ export function subdomainSuffix() {
|
|||
}
|
||||
|
||||
export function getOrgFullDomain(slug: string, options: { protocol: boolean } = { protocol: true }) {
|
||||
// TODO: It is a replacement for WEBAPP_URL and that doesn't have / in the end. Remove / after ensuring that it works reliably everywhere
|
||||
return `${options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""}${slug}.${subdomainSuffix()}/`;
|
||||
return `${options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""}${slug}.${subdomainSuffix()}`;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import classNames from "classnames";
|
|||
import { signIn } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
@ -108,8 +108,9 @@ export default function MemberListItem(props: Props) {
|
|||
props.member.accepted &&
|
||||
process.env.NEXT_PUBLIC_TEAM_IMPERSONATION === "true";
|
||||
|
||||
const urlWithoutProtocol = WEBAPP_URL.replace(/^https?:\/\//, "");
|
||||
const bookingLink = !!props.member.username && `${urlWithoutProtocol}/${props.member.username}`;
|
||||
const bookerUrl = useBookerUrl();
|
||||
const bookerUrlWithoutProtocol = bookerUrl.replace(/^https?:\/\//, "");
|
||||
const bookingLink = !!props.member.username && `${bookerUrlWithoutProtocol}/${props.member.username}`;
|
||||
|
||||
return (
|
||||
<li className="divide-subtle divide-y px-5">
|
||||
|
@ -118,7 +119,7 @@ export default function MemberListItem(props: Props) {
|
|||
<div className="flex">
|
||||
<Avatar
|
||||
size="sm"
|
||||
imageSrc={(orgBranding?.fullDomain ?? WEBAPP_URL) + "/" + props.member.username + "/avatar.png"}
|
||||
imageSrc={bookerUrl + "/" + props.member.username + "/avatar.png"}
|
||||
alt={name || ""}
|
||||
className="h-10 w-10 rounded-full"
|
||||
/>
|
||||
|
@ -139,7 +140,7 @@ export default function MemberListItem(props: Props) {
|
|||
<span className="text-default mx-2 block">•</span>
|
||||
<a
|
||||
target="_blank"
|
||||
href={`${orgBranding?.fullDomain ?? WEBAPP_URL}/${props.member.username}`}
|
||||
href={`${bookerUrl}/${props.member.username}`}
|
||||
className="text-default block text-sm">
|
||||
{bookingLink}
|
||||
</a>
|
||||
|
@ -170,7 +171,7 @@ export default function MemberListItem(props: Props) {
|
|||
<Tooltip content={t("view_public_page")}>
|
||||
<Button
|
||||
target="_blank"
|
||||
href={"/" + props.member.username}
|
||||
href={`${bookerUrl}/${props.member.username}`}
|
||||
color="secondary"
|
||||
className={classNames(!editMode ? "rounded-r-md" : "")}
|
||||
variant="icon"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { CAL_URL, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
export const useBookerUrl = () => {
|
||||
const orgBranding = useOrgBranding();
|
||||
return orgBranding?.fullDomain ?? WEBAPP_URL;
|
||||
return orgBranding?.fullDomain ?? CAL_URL ?? WEBAPP_URL;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user