feat(auth): header login/logout and /me badge using ky + react-query

This commit is contained in:
Urban Modig
2025-10-13 09:53:31 +02:00
parent f9bd9292ed
commit 23798e301b
9 changed files with 78 additions and 25 deletions

View File

@ -0,0 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { fetchMe } from './api'
export function MeBadge() {
const { data, isLoading, isError } = useQuery({ queryKey: ['me'], queryFn: fetchMe, retry: 0 })
if (isLoading) return <span className="opacity-60"></span>
if (isError) return <span className="opacity-60">ej inloggad</span>
return <span className="opacity-80 text-sm">{data?.name || data?.preferred_username || 'me'}</span>
}