diff --git a/apps/nextjs-app/e2e/tests/auth.setup.ts b/apps/nextjs-app/e2e/tests/auth.setup.ts index 1117cc38..187d10c9 100644 --- a/apps/nextjs-app/e2e/tests/auth.setup.ts +++ b/apps/nextjs-app/e2e/tests/auth.setup.ts @@ -28,7 +28,7 @@ setup('authenticate', async ({ page }) => { // log out: await page.getByRole('button', { name: 'Open user menu' }).click(); await page.getByRole('menuitem', { name: 'Sign Out' }).click(); - await page.waitForURL('/auth/login?redirectTo=%2Fapp'); + await page.waitForURL('/auth/login?redirectTo=%252Fapp'); // log in: await page.getByLabel('Email Address').click(); diff --git a/apps/nextjs-app/src/app/auth/layout.tsx b/apps/nextjs-app/src/app/auth/layout.tsx index 28a5c00f..6ee7609b 100644 --- a/apps/nextjs-app/src/app/auth/layout.tsx +++ b/apps/nextjs-app/src/app/auth/layout.tsx @@ -1,6 +1,8 @@ -import { ReactNode } from 'react'; +import { ReactNode, Suspense } from 'react'; +import { ErrorBoundary } from 'react-error-boundary'; import { AuthLayout as AuthLayoutComponent } from '@/components/layouts/auth-layout'; +import { Spinner } from '@/components/ui/spinner'; export const metadata = { title: 'Bulletproof React', @@ -8,7 +10,19 @@ export const metadata = { }; const AuthLayout = ({ children }: { children: ReactNode }) => { - return {children}; + return ( + + + + } + > + Something went wrong!}> + {children} + + + ); }; export default AuthLayout; diff --git a/apps/nextjs-app/src/app/auth/login/page.tsx b/apps/nextjs-app/src/app/auth/login/page.tsx index b779aef0..fcdfff01 100644 --- a/apps/nextjs-app/src/app/auth/login/page.tsx +++ b/apps/nextjs-app/src/app/auth/login/page.tsx @@ -2,6 +2,7 @@ import { useRouter, useSearchParams } from 'next/navigation'; +import { paths } from '@/config/paths'; import { LoginForm } from '@/features/auth/components/login-form'; // export const metadata = { @@ -17,7 +18,9 @@ const LoginPage = () => { return ( - router.replace(`${redirectTo ? `${redirectTo}` : '/app'}`) + router.replace( + `${redirectTo ? `${decodeURIComponent(redirectTo)}` : paths.app.dashboard.getHref()}`, + ) } /> ); diff --git a/apps/nextjs-app/src/app/auth/register/page.tsx b/apps/nextjs-app/src/app/auth/register/page.tsx index 87ca70fd..aed4c1cb 100644 --- a/apps/nextjs-app/src/app/auth/register/page.tsx +++ b/apps/nextjs-app/src/app/auth/register/page.tsx @@ -3,6 +3,7 @@ import { useRouter, useSearchParams } from 'next/navigation'; import { useState } from 'react'; +import { paths } from '@/config/paths'; import { RegisterForm } from '@/features/auth/components/register-form'; import { useTeams } from '@/features/teams/api/get-teams'; @@ -28,7 +29,9 @@ const RegisterPage = () => { return ( - router.replace(`${redirectTo ? `${redirectTo}` : '/app'}`) + router.replace( + `${redirectTo ? `${decodeURIComponent(redirectTo)}` : paths.app.dashboard.getHref()}`, + ) } chooseTeam={chooseTeam} setChooseTeam={() => setChooseTeam(!chooseTeam)} diff --git a/apps/nextjs-app/src/app/not-found.tsx b/apps/nextjs-app/src/app/not-found.tsx index 2aa724ad..6f3ae4e6 100644 --- a/apps/nextjs-app/src/app/not-found.tsx +++ b/apps/nextjs-app/src/app/not-found.tsx @@ -1,11 +1,12 @@ import { Link } from '@/components/ui/link'; +import { paths } from '@/config/paths'; const NotFoundPage = () => { return (

404 - Not Found

Sorry, the page you are looking for does not exist.

- + Go to Home
diff --git a/apps/nextjs-app/src/app/page.tsx b/apps/nextjs-app/src/app/page.tsx index 3276a41b..2d7d0051 100644 --- a/apps/nextjs-app/src/app/page.tsx +++ b/apps/nextjs-app/src/app/page.tsx @@ -1,5 +1,6 @@ import { Button } from '@/components/ui/button'; import { Link } from '@/components/ui/link'; +import { paths } from '@/config/paths'; import { checkLoggedIn } from '@/utils/auth'; const HomePage = () => { @@ -15,7 +16,13 @@ const HomePage = () => {

Showcasing Best Practices For Building React Applications

- +