diff --git a/apps/web/pages/404.tsx b/apps/web/pages/404.tsx index c6e448cc..6e3e318a 100644 --- a/apps/web/pages/404.tsx +++ b/apps/web/pages/404.tsx @@ -3,7 +3,7 @@ import { ChevronRightIcon } from "@heroicons/react/solid"; import { GetStaticPropsContext } from "next"; import Link from "next/link"; import { useRouter } from "next/router"; -import React from "react"; +import React, { useEffect, useState } from "react"; import { useLocale } from "@lib/hooks/useLocale"; @@ -13,8 +13,10 @@ import { ssgInit } from "@server/lib/ssg"; export default function Custom404() { const { t } = useLocale(); + const router = useRouter(); const username = router.asPath.replace("%20", "-"); + const links = [ { title: t("documentation"), @@ -30,10 +32,14 @@ export default function Custom404() { }, ]; + const [url, setUrl] = useState("https://cal.com/signup?username="); + useEffect(() => { + setUrl(`https://cal.com/signup?username=${username.replace("/", "")}`); + }, [router.query]); + const isSubpage = router.asPath.includes("/", 2); const isSignup = router.asPath.includes("/signup"); const isCalcom = process.env.NEXT_PUBLIC_BASE_URL === "https://app.cal.com"; - const signupLink = "https://cal.com/signup?username=" + username.replace("/", ""); return ( <> @@ -178,21 +184,18 @@ export default function Custom404() { {t("check_spelling_mistakes_or_go_back")} ) : isCalcom ? ( - + {t("the_username")} cal.com{username}{" "} {t("is_still_available")} {t("register_now")}. ) : ( - <> + {t("the_username")}{" "} - - {new URL(process.env.NEXT_PUBLIC_BASE_URL || "").hostname} - {username} - {" "} + {username}{" "} {t("is_still_available")} - > + )}