♻️ Switch to app router (#922)

This commit is contained in:
Luke Vella 2023-11-06 09:15:49 +00:00 committed by GitHub
parent 41f85279bb
commit 95feb9f01a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
181 changed files with 2507 additions and 2494 deletions

View file

@ -1,5 +1,5 @@
import Link, { LinkProps } from "next/link";
import { useRouter } from "next/router";
import { usePathname, useRouter } from "next/navigation";
import React from "react";
export const LoginLink = React.forwardRef<
@ -7,6 +7,7 @@ export const LoginLink = React.forwardRef<
React.PropsWithChildren<Omit<LinkProps, "href"> & { className?: string }>
>(function LoginLink({ children, ...props }, ref) {
const router = useRouter();
const pathname = usePathname() ?? "/";
return (
<Link
ref={ref}
@ -15,7 +16,7 @@ export const LoginLink = React.forwardRef<
onClick={async (e) => {
e.preventDefault();
props.onClick?.(e);
router.push("/login?callbackUrl=" + encodeURIComponent(router.asPath));
router.push("/login?callbackUrl=" + encodeURIComponent(pathname));
}}
>
{children}