Skip to content

Commit

Permalink
feat(dashboard): connect bff to api
Browse files Browse the repository at this point in the history
  • Loading branch information
andypf committed Feb 28, 2025
1 parent ba14199 commit 81c966b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/aurora-portal/src/client/Shell/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ interface AuthApi {
isLoading: boolean
scopedDomain?: { id?: string; name?: string }
scopedProject?: { id?: string; name?: string }
session_expres_at?: TokenData["expires_at"]
session_expires_at?: TokenData["expires_at"]
}

const useAuthApi = (): AuthApi => {
const [authData, setAuthData] = useState<State>({ isLoading: true })
console.log("================", authData?.tokenData)

useEffect(() => {
trpcClient.auth.token
Expand Down Expand Up @@ -71,6 +70,7 @@ const useAuthApi = (): AuthApi => {
login,
logout,
getAuthToken,
session_expires_at: authData.tokenData?.expires_at,
isLoading: authData.isLoading,
error: authData.error,
isAuthenticated: !!authData.tokenData,
Expand Down
6 changes: 3 additions & 3 deletions apps/aurora-portal/src/client/Shell/Navigation/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react"
import { useLocation } from "wouter"
import { Button, Icon, PopupMenu } from "@cloudoperators/juno-ui-components"
import { Button, Icon } from "@cloudoperators/juno-ui-components"
import { useAuth } from "../../Shell/AuthProvider"

function Countdown({ className, passwordExpiresAt }: { className?: string; passwordExpiresAt: string }) {
Expand Down Expand Up @@ -40,7 +40,7 @@ function Countdown({ className, passwordExpiresAt }: { className?: string; passw
}

export function UserMenu() {
const { user, isLoading, logout: authLogout } = useAuth()
const { user, session_expires_at, isLoading, logout: authLogout } = useAuth()
const setLocation = useLocation()[1]
const [isOpen, setIsOpen] = useState(false)

Expand All @@ -65,7 +65,7 @@ export function UserMenu() {
<Button disabled={isLoading} variant="default" size="small" onClick={logout}>
Sign Out
</Button>
<Countdown passwordExpiresAt={user.session_expires_at} />
{session_expires_at && <Countdown passwordExpiresAt={session_expires_at} />}
</div>
) : (
<Button disabled={isLoading} variant="primary" size="small" onClick={login} className="w-full">
Expand Down

0 comments on commit 81c966b

Please sign in to comment.