♻️(frontend) refactor hardcoded '/authenticate' API calls
Use the function introduce by @manuhabitela, authUrl. It reduces code duplication.
This commit is contained in:
committed by
aleb_the_flash
parent
c390499394
commit
3718851435
@@ -2,7 +2,7 @@ import { css } from '@/styled-system/css'
|
|||||||
import { flex } from '@/styled-system/patterns'
|
import { flex } from '@/styled-system/patterns'
|
||||||
import { apiUrl } from '@/api/apiUrl'
|
import { apiUrl } from '@/api/apiUrl'
|
||||||
import { A, Badge, Text } from '@/primitives'
|
import { A, Badge, Text } from '@/primitives'
|
||||||
import { useUser } from '@/features/auth/api/useUser'
|
import { authUrl, useUser } from '@/features/auth'
|
||||||
|
|
||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
const { user, isLoggedIn } = useUser()
|
const { user, isLoggedIn } = useUser()
|
||||||
@@ -31,7 +31,7 @@ export const Header = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{isLoggedIn === false && <A href={apiUrl('/authenticate')}>Login</A>}
|
{isLoggedIn === false && <A href={authUrl()}>Login</A>}
|
||||||
{!!user && (
|
{!!user && (
|
||||||
<p className={flex({ gap: 1, align: 'center' })}>
|
<p className={flex({ gap: 1, align: 'center' })}>
|
||||||
<Badge>{user.email}</Badge>
|
<Badge>{user.email}</Badge>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { A, Button, Italic, P, Div, H, Box } from '@/primitives'
|
import { A, Button, Italic, P, Div, H, Box } from '@/primitives'
|
||||||
import { useUser } from '@/features/auth'
|
import { authUrl, useUser } from '@/features/auth'
|
||||||
import { apiUrl } from '@/api/apiUrl'
|
|
||||||
import { navigateToNewRoom } from '@/features/rooms'
|
import { navigateToNewRoom } from '@/features/rooms'
|
||||||
import { Screen } from '@/layout/Screen'
|
import { Screen } from '@/layout/Screen'
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ export const Home = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<p>
|
<p>
|
||||||
<A href={apiUrl('/authenticate')}>
|
<A href={authUrl()}>
|
||||||
Login to create a conference call
|
Login to create a conference call
|
||||||
</A>
|
</A>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user