-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from hackerspace-ntnu/not-found
Add error and not found page
- Loading branch information
Showing
7 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use client'; | ||
|
||
import { Button } from '@/components/ui/Button'; | ||
import { Link } from '@/lib/locale/navigation'; | ||
import { AlertTriangleIcon } from 'lucide-react'; | ||
import { useTranslations } from 'next-intl'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function ErrorPage({ | ||
error, | ||
reset, | ||
}: { | ||
error: Error; | ||
reset: () => void; | ||
}) { | ||
const t = useTranslations('error'); | ||
useEffect(() => { | ||
console.error(error); | ||
}, [error]); | ||
return ( | ||
<div className='flex min-h-screen flex-col items-center justify-center px-4 text-center'> | ||
<AlertTriangleIcon className='mb-6 xs:mb-8 size-16 xs:size-24 text-destructive' /> | ||
<h1 className='mb-3 xs:mb-4 font-bold text-3xl xs:text-4xl'> | ||
{t('error')} | ||
</h1> | ||
<p className='mb-4 text-lg text-muted-foreground xs:text-xl'> | ||
{t('errorDescription')} | ||
</p> | ||
{error.message && ( | ||
<p className='mb-6 rounded-md bg-muted p-2 text-sm xs:text-base'> | ||
Error: {error.message} | ||
</p> | ||
)} | ||
<div className='flex w-full xs:w-auto xs:flex-row flex-col xs:space-x-4 space-y-4 xs:space-y-0'> | ||
<Button onClick={reset} variant='outline' className='w-full xs:w-auto'> | ||
{t('tryAgain')} | ||
</Button> | ||
<Button asChild className='w-full xs:w-auto'> | ||
<Link href='/'>{t('goToHomepage')}</Link> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Button } from '@/components/ui/Button'; | ||
import { Link } from '@/lib/locale/navigation'; | ||
import { HardDriveIcon } from 'lucide-react'; | ||
import { useTranslations } from 'next-intl'; | ||
|
||
export default function NotFoundPage() { | ||
const t = useTranslations('error'); | ||
return ( | ||
<div className='flex min-h-screen flex-col items-center justify-center px-4'> | ||
<HardDriveIcon className='mb-6 xs:mb-8 size-16 xs:size-24 text-primary' /> | ||
<h1 className='mb-3 xs:mb-4 font-bold text-3xl xs:text-4xl'> | ||
{t('notFound')} | ||
</h1> | ||
<p className='mb-6 xs:mb-8 text-lg text-muted-foreground xs:text-xl'> | ||
{t('notFoundDescription')} | ||
</p> | ||
<Button className='w-full xs:w-auto' asChild> | ||
<Link href='/'>{t('goToHomepage')}</Link> | ||
</Button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
'use client'; | ||
|
||
import { routing } from '@/lib/locale'; | ||
import { redirect, usePathname } from 'next/navigation'; | ||
import NextError from 'next/error'; | ||
|
||
export default function NotFound() { | ||
const pathname = usePathname(); | ||
redirect(`/${routing.defaultLocale}/${pathname}`); | ||
export default function NotFoundPage() { | ||
return ( | ||
<html lang='en'> | ||
<body> | ||
<NextError statusCode={404} /> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters