Skip to content

Commit 6a1c45f

Browse files
committed
added custom 404 page, added redirect to 404 page on unauthorized access to code-page
1 parent 13cf784 commit 6a1c45f

File tree

4 files changed

+56
-14
lines changed

4 files changed

+56
-14
lines changed

app/code-area/page.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { cn } from "@/lib/utils";
1111
import useCodeAreaStore from "@/data-store/code-area-store";
1212
import { useStepperStore } from "@/data-store/stepper-store";
1313
import validateUser from "@/lib/validate-user";
14+
import { notFound } from "next/navigation";
1415

1516
type MosaicKey = "EDITOR" | "PREVIEW";
1617

@@ -30,11 +31,7 @@ const CodeArea = () => {
3031
const { email, check, progress, challenge } = useStepperStore();
3132

3233
if (validateUser("Code", email, check, challenge, progress)) {
33-
return (
34-
<p>
35-
error, no bypassing the required form to enter the coding area!
36-
</p>
37-
);
34+
notFound();
3835
} else {
3936
return (
4037
<div className='h-screen'>

app/not-found.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use client";
2+
import Link from "next/link";
3+
import { Navigation } from "@/components/landing/navigation";
4+
import { Button } from "@/components/ui/button";
5+
import { useRouter } from "next/navigation";
6+
import { useEffect } from "react";
7+
8+
export default function NotFound() {
9+
const router = useRouter();
10+
11+
useEffect(() => {
12+
const delay = 5000;
13+
14+
const redirectTimer = setTimeout(() => {
15+
router.push("/");
16+
}, delay);
17+
return () => clearTimeout(redirectTimer);
18+
}, [router]);
19+
20+
return (
21+
<main className='mx-auto flex h-screen w-full flex-col overflow-clip bg-gradient-to-b from-[#493b6c] via-[#14243a] to-[#000000]'>
22+
<Navigation />
23+
24+
<section className='m-auto flex max-w-screen-lg flex-col items-center px-4'>
25+
<h1 className='mb-8 text-4xl font-bold !leading-[1.208] text-orange-500 sm:text-[42px] lg:text-[40px] xl:text-5xl'>
26+
404 - Page Not Found
27+
</h1>
28+
<p className='text-body-color dark:text-dark-6 mb-4 text-base'>
29+
The page you are looking for either does not exist, or you
30+
are not allowed to access it!
31+
</p>
32+
<p className='text-body-color dark:text-dark-6 mb-14 text-base'>
33+
You should be auto-redirect within the next 5 seconds. If
34+
you are not, click the button below.
35+
</p>
36+
37+
<Link href='/'>
38+
<Button>Return Home</Button>
39+
</Link>
40+
</section>
41+
</main>
42+
);
43+
}

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Home() {
2424
<Hero />
2525
</div>
2626
</section>
27-
<section>
27+
<section id='about'>
2828
<AboutTailspin />
2929
</section>
3030
<section

components/landing/navigation.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ import { TailspinLogo } from "../ui/spinning-logo";
77
export const Navigation = () => {
88
return (
99
<nav className='fixed top-0 z-[1] flex h-16 w-full items-center'>
10-
<Link href='#landing'>
10+
<Link href='/#landing'>
1111
<div className='mx-5'>
1212
<TailspinLogo outershellClassname='animate-spin h-10 w-10' />
1313
</div>
1414
</Link>
15-
<Button
16-
variant='ghost'
17-
className='mx-3 font-semibold text-muted-foreground'
18-
>
19-
About
20-
</Button>
21-
<Link href='#stepper'>
15+
<Link href='/#about'>
16+
<Button
17+
variant='ghost'
18+
className='mx-3 font-semibold text-muted-foreground'
19+
>
20+
About
21+
</Button>
22+
</Link>
23+
<Link href='/#stepper'>
2224
<Button
2325
variant='ghost'
2426
className='mx-3 font-semibold text-muted-foreground'

0 commit comments

Comments
 (0)