Skip to content

Commit

Permalink
feat: add 401 error page (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakrisi authored Jul 7, 2024
1 parent 6bee397 commit bc8ccc8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/data/sidelinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
IconTruck,
IconUserShield,
IconUsers,
IconLock,
} from '@tabler/icons-react'

export interface NavLink {
Expand Down Expand Up @@ -158,6 +159,12 @@ export const sidelinks: SideLink[] = [
href: '/503',
icon: <IconBarrierBlock size={18} />,
},
{
title: 'Unauthorised Error',
label: '',
href: '/401',
icon: <IconLock size={18} />,
},
],
},
{
Expand Down
27 changes: 27 additions & 0 deletions src/pages/errors/unauthorised-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useNavigate } from 'react-router-dom'
import { Button } from '@/components/custom/button'

export default function UnauthorisedError() {
const navigate = useNavigate()
return (
<div className='h-svh'>
<div className='m-auto flex h-full w-full flex-col items-center justify-center gap-2'>
<h1 className='text-[7rem] font-bold leading-tight'>401</h1>
<span className='font-medium'>
Oops! You don't have permission to access this page.
</span>
<p className='text-center text-muted-foreground'>
It looks like you tried to access a resource that requires proper
authentication. <br />
Please log in with the appropriate credentials.
</p>
<div className='mt-6 flex gap-4'>
<Button variant='outline' onClick={() => navigate(-1)}>
Go Back
</Button>
<Button onClick={() => navigate('/')}>Back to Home</Button>
</div>
</div>
</div>
)
}
2 changes: 2 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createBrowserRouter } from 'react-router-dom'
import GeneralError from './pages/errors/general-error'
import NotFoundError from './pages/errors/not-found-error'
import MaintenanceError from './pages/errors/maintenance-error'
import UnauthorisedError from './pages/errors/unauthorised-error.tsx'

const router = createBrowserRouter([
// Auth routes
Expand Down Expand Up @@ -142,6 +143,7 @@ const router = createBrowserRouter([
{ path: '/500', Component: GeneralError },
{ path: '/404', Component: NotFoundError },
{ path: '/503', Component: MaintenanceError },
{ path: '/401', Component: UnauthorisedError },

// Fallback 404 route
{ path: '*', Component: NotFoundError },
Expand Down

0 comments on commit bc8ccc8

Please sign in to comment.