diff --git a/apps/web/src/app/[locale]/(auth)/components/link-with-redirect-to.tsx b/apps/web/src/app/[locale]/(auth)/components/link-with-redirect-to.tsx new file mode 100644 index 000000000..d31264423 --- /dev/null +++ b/apps/web/src/app/[locale]/(auth)/components/link-with-redirect-to.tsx @@ -0,0 +1,30 @@ +"use client"; + +import Link from "next/link"; +import { useSearchParams } from "next/navigation"; + +export function LinkWithRedirectTo({ + href, + className, + children, +}: { + href: string; + className?: string; + children?: React.ReactNode; +}) { + const searchParams = useSearchParams(); + const redirectTo = searchParams.get("redirectTo"); + + return ( + + {children} + + ); +} diff --git a/apps/web/src/app/[locale]/(auth)/login/page.tsx b/apps/web/src/app/[locale]/(auth)/login/page.tsx index 3176a58ec..9be81d6a5 100644 --- a/apps/web/src/app/[locale]/(auth)/login/page.tsx +++ b/apps/web/src/app/[locale]/(auth)/login/page.tsx @@ -1,4 +1,3 @@ -import Link from "next/link"; import { Trans } from "react-i18next/TransWithoutContext"; import { GoogleProvider } from "@/auth/providers/google"; @@ -15,6 +14,7 @@ import { AuthPageHeader, AuthPageTitle, } from "../components/auth-page"; +import { LinkWithRedirectTo } from "../components/link-with-redirect-to"; import { AuthErrors } from "./components/auth-errors"; import { LoginWithEmailForm } from "./components/login-email-form"; import { LoginWithOIDC } from "./components/login-with-oidc"; @@ -96,7 +96,7 @@ export default async function LoginPage(props: { i18nKey="loginFooter" defaults="Don't have an account? Sign up" components={{ - a: , + a: , }} /> diff --git a/apps/web/src/app/[locale]/(auth)/register/page.tsx b/apps/web/src/app/[locale]/(auth)/register/page.tsx index 3e16ccd04..3f2621473 100644 --- a/apps/web/src/app/[locale]/(auth)/register/page.tsx +++ b/apps/web/src/app/[locale]/(auth)/register/page.tsx @@ -1,4 +1,3 @@ -import Link from "next/link"; import { Trans } from "react-i18next/TransWithoutContext"; import { getTranslation } from "@/i18n/server"; @@ -13,6 +12,7 @@ import { AuthPageHeader, AuthPageTitle, } from "../components/auth-page"; +import { LinkWithRedirectTo } from "../components/link-with-redirect-to"; import { RegisterNameForm } from "./components/register-name-form"; export default async function Register(props: { @@ -56,7 +56,7 @@ export default async function Register(props: { i18nKey="alreadyHaveAccount" defaults="Already have an account? Log in" components={{ - a: , + a: , }} />