♻️(frontend) introduce a logoutUrl function

Wrap the logout URL in a function for consistency with '/authenticate'.
This commit is contained in:
lebaudantoine
2024-07-17 16:47:44 +02:00
committed by aleb_the_flash
parent 1c046abf5f
commit 6e20d5385f
3 changed files with 8 additions and 3 deletions

View File

@@ -1,2 +1,3 @@
export { useUser } from './api/useUser' export { useUser } from './api/useUser'
export { authUrl } from './utils/authUrl' export { authUrl } from './utils/authUrl'
export { logoutUrl } from './utils/logoutUrl'

View File

@@ -0,0 +1,5 @@
import { apiUrl } from '@/api/apiUrl'
export const logoutUrl = () => {
return apiUrl('/logout')
}

View File

@@ -1,8 +1,7 @@
import { css } from '@/styled-system/css' import { css } from '@/styled-system/css'
import { flex } from '@/styled-system/patterns' import { flex } from '@/styled-system/patterns'
import { apiUrl } from '@/api/apiUrl'
import { A, Badge, Text } from '@/primitives' import { A, Badge, Text } from '@/primitives'
import { authUrl, useUser } from '@/features/auth' import { authUrl, logoutUrl, useUser } from '@/features/auth'
export const Header = () => { export const Header = () => {
const { user, isLoggedIn } = useUser() const { user, isLoggedIn } = useUser()
@@ -35,7 +34,7 @@ export const Header = () => {
{!!user && ( {!!user && (
<p className={flex({ gap: 1, align: 'center' })}> <p className={flex({ gap: 1, align: 'center' })}>
<Badge>{user.email}</Badge> <Badge>{user.email}</Badge>
<A href={apiUrl('/logout')} size="small"> <A href={logoutUrl()} size="small">
Logout Logout
</A> </A>
</p> </p>