cal.pub0.org/apps/web/lib/hooks/useIsBookingPage.ts

13 lines
471 B
TypeScript
Raw Normal View History

import { usePathname, useSearchParams } from "next/navigation";
export default function useIsBookingPage(): boolean {
const pathname = usePathname();
const isBookingPage = ["/booking/", "/cancel", "/reschedule"].some((route) => pathname?.startsWith(route));
const searchParams = useSearchParams();
const userParam = Boolean(searchParams?.get("user"));
const teamParam = Boolean(searchParams?.get("team"));
return isBookingPage || userParam || teamParam;
}