buttons
This commit is contained in:
parent
abd7c2f073
commit
384da1e832
18 changed files with 150 additions and 116 deletions
30
src/app/auth/components/AuthNavButtons.tsx
Normal file
30
src/app/auth/components/AuthNavButtons.tsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { useUser } from '../../user/userStore.ts'
|
||||
import NavButton from '../../../components/buttons/NavButton.tsx'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
export default function AuthNavButtons() {
|
||||
const { user } = useUser()
|
||||
|
||||
const { pathname } = useLocation()
|
||||
|
||||
const redirectQuery = new URLSearchParams()
|
||||
redirectQuery.set('t', pathname)
|
||||
|
||||
const loggedIn = user != null
|
||||
|
||||
if (loggedIn) {
|
||||
return (
|
||||
<>
|
||||
<NavButton to="/logout">logout</NavButton>
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
const search = redirectQuery.toString()
|
||||
return (
|
||||
<>
|
||||
<NavButton to={{ pathname: '/login', search }}>login</NavButton>
|
||||
<NavButton to={{ pathname: '/signup', search }}>register</NavButton>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue