-
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.
* feat(client): protect `/x` route * chore: add comment * feat(client): do not show login button link on login page
- Loading branch information
Showing
5 changed files
with
54 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
export default function X() { | ||
return ( | ||
<div className='flex flex-col items-center justify-center'> | ||
<h1 className='text-3xl font-bold text-center text-violet'>Gallery</h1> | ||
<div className='w-full max-w-5xl'> | ||
<div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 justify-items-center'> | ||
{[0, 1, 2].map((index) => ( | ||
<div key={index} className='bg-wisteria p-4 rounded-lg shadow-lg w-full max-w-xs'> | ||
<img | ||
src={`/dog${index}.avif`} | ||
alt={`Dog eating corndog AI generated drawing ${index + 1}`} | ||
className='w-full h-auto rounded object-cover' | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
'use client' | ||
import { withAuth } from 'c/withAuth' | ||
|
||
const X = () => ( | ||
<div className='flex flex-col items-center justify-center'> | ||
<h1 className='text-3xl font-bold text-center text-violet'>Gallery</h1> | ||
<div className='w-full max-w-5xl'> | ||
<div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 justify-items-center'> | ||
{[0, 1, 2].map((index) => ( | ||
<div key={index} className='bg-wisteria p-4 rounded-lg shadow-lg w-full max-w-xs'> | ||
<img | ||
src={`/dog${index}.avif`} | ||
alt={`Dog eating corndog AI generated drawing ${index + 1}`} | ||
className='w-full h-auto rounded object-cover' | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
</div> | ||
) | ||
|
||
export default withAuth(X) |
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,21 @@ | ||
import { useAuthorized } from 'h/useAuthorized' | ||
import { useRouter } from 'next/navigation' | ||
import { useEffect } from 'react' | ||
import type { ComponentType } from 'react' | ||
|
||
export const withAuth = <P extends object>(Component: ComponentType<P>) => { | ||
return function WithAuth(props: P) { | ||
const { auth, loading } = useAuthorized() | ||
const router = useRouter() | ||
useEffect(() => { | ||
if (auth === false) { | ||
alert('Nice try! But we need to verify your age first.') | ||
router.push('/login') | ||
} | ||
}, [loading]) | ||
if (auth === false || loading === true) | ||
return null | ||
|
||
return <Component {...props} /> | ||
} | ||
} |
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