|
|
@ -1,26 +1,13 @@ |
|
|
|
import Cookies from 'js-cookie'; |
|
|
|
|
|
|
|
import { useEffect, useState } from 'preact/hooks'; |
|
|
|
|
|
|
|
import { TOKEN_COOKIE_NAME } from '../../lib/utils'; |
|
|
|
|
|
|
|
import { useAuth } from '../../hooks/use-auth'; |
|
|
|
import { useAuth } from '../../hooks/use-auth'; |
|
|
|
|
|
|
|
|
|
|
|
export default function AccountNavigation() { |
|
|
|
export default function AccountNavigation() { |
|
|
|
const [isAuthenticated, setIsAuthenticated] = useState(false); |
|
|
|
const { user, isLoading } = useAuth(); |
|
|
|
const { user, status } = useAuth(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
console.log('user', user, isLoading); |
|
|
|
const token = Cookies.get(TOKEN_COOKIE_NAME); |
|
|
|
|
|
|
|
if (token) { |
|
|
|
|
|
|
|
setIsAuthenticated(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setIsAuthenticated(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('user', user, status); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
{isAuthenticated ? ( |
|
|
|
{user ? ( |
|
|
|
<div>Authenticated: {user?.name}</div> |
|
|
|
<div>Authenticated: {user?.name}</div> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<div>Not Authenticated</div> |
|
|
|
<div>Not Authenticated</div> |
|
|
|