mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Sorted all imports in all packages, `cms`, `design-system` and `ui-library` apps by running `pnpm format` on them. All changes in this PR are done by the script.
23 lines
547 B
TypeScript
23 lines
547 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
import { createClient } from '@/registry/default/clients/nextjs/lib/supabase/client'
|
|
|
|
export const useCurrentUserName = () => {
|
|
const [name, setName] = useState<string | null>(null)
|
|
|
|
useEffect(() => {
|
|
const fetchProfileName = async () => {
|
|
const { data, error } = await createClient().auth.getSession()
|
|
if (error) {
|
|
console.error(error)
|
|
}
|
|
|
|
setName(data.session?.user.user_metadata.full_name ?? '?')
|
|
}
|
|
|
|
fetchProfileName()
|
|
}, [])
|
|
|
|
return name || '?'
|
|
}
|