Skip to content

Commit

Permalink
♻️(frontend) refactor hardcoded '/authenticate' API calls
Browse files Browse the repository at this point in the history
Use the function introduce by @manuhabitela, authUrl.
It reduces code duplication.
  • Loading branch information
lebaudantoine committed Jul 17, 2024
1 parent c390499 commit c6db346
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css } from '@/styled-system/css'
import { flex } from '@/styled-system/patterns'
import { apiUrl } from '@/api/apiUrl'
import { A, Badge, Text } from '@/primitives'
import { useUser } from '@/features/auth/api/useUser'
import { authUrl, useUser } from '@/features/auth'

export const Header = () => {
const { user, isLoggedIn } = useUser()
Expand Down Expand Up @@ -31,7 +31,7 @@ export const Header = () => {
</Text>
</div>
<div>
{isLoggedIn === false && <A href={apiUrl('/authenticate')}>Login</A>}
{isLoggedIn === false && <A href={authUrl()}>Login</A>}
{!!user && (
<p className={flex({ gap: 1, align: 'center' })}>
<Badge>{user.email}</Badge>
Expand Down
5 changes: 2 additions & 3 deletions src/frontend/src/routes/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { A, Button, Italic, P, Div, H, Box } from '@/primitives'
import { useUser } from '@/features/auth'
import { apiUrl } from '@/api/apiUrl'
import { authUrl, useUser } from '@/features/auth'
import { navigateToNewRoom } from '@/features/rooms'
import { Screen } from '@/layout/Screen'

Expand All @@ -19,7 +18,7 @@ export const Home = () => {
</Button>
) : (
<p>
<A href={apiUrl('/authenticate')}>
<A href={authUrl()}>
Login to create a conference call
</A>
</p>
Expand Down

0 comments on commit c6db346

Please sign in to comment.