fix: Plain Chat loading in embed (#19348)
* PlainChat has to be on dashboard and not on booking pages * improve useIsBookingPage --------- Co-authored-by: hbjORbj <sldisek783@gmail.com>
This commit is contained in:
co-authored by
hbjORbj
parent
9a271f397b
commit
25f3368fa1
@@ -4,13 +4,16 @@ import { TrpcProvider } from "app/_trpc/trpc-provider";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import CacheProvider from "react-inlinesvg/provider";
|
||||
|
||||
import useIsBookingPage from "@lib/hooks/useIsBookingPage";
|
||||
import PlainChat from "@lib/plain/dynamicProvider";
|
||||
|
||||
export function Providers({ children }: { children: React.ReactNode }) {
|
||||
const isBookingPage = useIsBookingPage();
|
||||
|
||||
return (
|
||||
<SessionProvider>
|
||||
<TrpcProvider>
|
||||
<PlainChat />
|
||||
{!isBookingPage ? <PlainChat /> : null}
|
||||
{/* @ts-expect-error FIXME remove this comment when upgrading typescript to v5 */}
|
||||
<CacheProvider>{children}</CacheProvider>
|
||||
</TrpcProvider>
|
||||
|
||||
@@ -8,14 +8,16 @@ export default function useIsBookingPage(): boolean {
|
||||
"/booking",
|
||||
"/cancel",
|
||||
"/reschedule",
|
||||
"/instant-meeting", // Instant booking page
|
||||
"/team", // Team booking pages
|
||||
"/d", // Private Link of booking page
|
||||
"/apps/routing-forms/routing-link", // Routing Form page
|
||||
"/forms/", // Rewrites to /apps/routing-forms/routing-link
|
||||
].some((route) => pathname?.startsWith(route));
|
||||
|
||||
const searchParams = useCompatSearchParams();
|
||||
const userParam = Boolean(searchParams?.get("user"));
|
||||
const teamParam = Boolean(searchParams?.get("team"));
|
||||
const isUserBookingPage = Boolean(searchParams?.get("user"));
|
||||
const isUserBookingTypePage = Boolean(searchParams?.get("user") && searchParams?.get("type"));
|
||||
|
||||
return isBookingPage || userParam || teamParam;
|
||||
return isBookingPage || isUserBookingPage || isUserBookingTypePage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user