"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { getOrgDomainConfigFromHostname, subdomainSuffix, } from "@calcom/features/ee/organizations/lib/orgDomains"; import { DOCS_URL, IS_CALCOM, WEBSITE_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Icon } from "@calcom/ui/components/icon"; enum PageType { ORG = "ORG", TEAM = "TEAM", USER = "USER", OTHER = "OTHER", } function getPageInfo(pathname: string, host: string) { const { isValidOrgDomain, currentOrgDomain } = getOrgDomainConfigFromHostname({ hostname: host }); const [routerUsername] = pathname?.replace("%20", "-").split(/[?#]/) ?? []; if (routerUsername && (!isValidOrgDomain || !currentOrgDomain)) { const splitPath = routerUsername.split("/"); if (splitPath[1] === "team" && splitPath.length === 3) { return { username: splitPath[2], pageType: PageType.TEAM, url: `${WEBSITE_URL}/signup?callbackUrl=settings/teams/new%3Fslug%3D${splitPath[2].replace("/", "")}`, }; } else { return { username: routerUsername, pageType: PageType.USER, url: `${WEBSITE_URL}/signup?username=${routerUsername.replace("/", "")}`, }; } } else { return { username: currentOrgDomain ?? "", pageType: PageType.ORG, url: `${WEBSITE_URL}/signup?callbackUrl=settings/organizations/new%3Fslug%3D${ currentOrgDomain?.replace("/", "") ?? "" }`, }; } } export function NotFound({ host }: { host: string }) { const { t } = useLocale(); const pathname = usePathname() ?? ""; const { username, pageType, url } = getPageInfo(pathname, host); const isBookingSuccessPage = pathname?.startsWith("/booking"); const isSubpage = pathname?.includes("/", 2) || isBookingSuccessPage; const isInsights = pathname?.startsWith("/insights"); const links = [ { title: t("enterprise"), description: "Learn more about organizations and subdomains in our enterprise plan.", icon: "shield" as const, href: `${WEBSITE_URL}/enterprise`, }, { title: t("documentation"), description: t("documentation_description"), icon: "file-text" as const, href: DOCS_URL, }, { title: t("blog"), description: t("blog_description"), icon: "book-open" as const, href: `${WEBSITE_URL}/blog`, }, ]; /** * If we're on 404 and the route is insights it means it is disabled * TODO: Abstract this for all disabled features **/ if (isInsights) { return (

{t("error_404")}

{t("feature_currently_disabled") ?? "Feature is currently disabled"}

{t("or_go_back_home")}
); } return (

{t("error_404")}

{isBookingSuccessPage ? "Booking not found" : t("page_doesnt_exist")}

{isSubpage && pageType !== PageType.TEAM ? ( {t("check_spelling_mistakes_or_go_back")} ) : IS_CALCOM ? ( {t(`404_the_${pageType.toLowerCase()}`)}{" "} {username ? ( <> {username} {` ${t("is_still_available")} `} {t("register_now")}. ) : null} ) : ( {t(`404_the_${pageType.toLowerCase()}`)}{" "} {username ? ( <> {username}{" "} {t("is_still_available")} ) : null} )}
{((!isSubpage && IS_CALCOM) || pageType === PageType.ORG || pageType === PageType.TEAM) && ( )}

{t("popular_pages")}

{t("or_go_back_home")}
); }