Skip to content

Commit

Permalink
fix: render conditionally parts of Header
Browse files Browse the repository at this point in the history
  • Loading branch information
sripwoud committed Sep 9, 2024
1 parent 40418c3 commit 7af364f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
.next
tsconfig.tsbuildinfo
10 changes: 7 additions & 3 deletions client/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import { useAuthorized } from 'h/useAuthorized'
import { config } from 'l/config'
import Image from 'next/image'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
export const Header = () => {
const { auth, loading, logout } = useAuthorized()
const pathname = usePathname()

const render = () => {
if (loading === true) return <Image alt='spinner' height={50} src='/spinner.svg' width={50} />
if (auth === true) {
return (
<>
<li className='self-center'>
<Link href='/x'>Restricted content</Link>
</li>
{!pathname.endsWith('/x') && (
<li className='self-center'>
<Link href='/x'>Restricted content</Link>
</li>
)}
<li>
<button onClick={logout} type='button'>Logout</button>
</li>
Expand Down
1 change: 0 additions & 1 deletion client/tsconfig.tsbuildinfo

This file was deleted.

0 comments on commit 7af364f

Please sign in to comment.