mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 22:29:11 +03:00
* Support updating email address for email identity * Support unlinking identity * Deprecate AccountInformation component * Invalidate identities after unlinking * Address feedback * Smol * Fix type issues * Update toast message * Set up email change pending badge * Fix * Address feedback * Resolve ts-expect-errors * Fix TS issues + Fix GH icon on light mode + Address feedback
33 lines
953 B
TypeScript
33 lines
953 B
TypeScript
import type { UserIdentity } from '@supabase/supabase-js'
|
|
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { auth } from 'lib/gotrue'
|
|
import { profileKeys } from './keys'
|
|
|
|
export async function getProfileIdentities() {
|
|
const { error, data } = await auth.getUser()
|
|
|
|
if (error) throw error
|
|
|
|
const { identities = [], new_email, email_change_sent_at } = data.user
|
|
return { identities, new_email, email_change_sent_at }
|
|
}
|
|
|
|
type ProfileIdentitiesData = {
|
|
identities: UserIdentity[]
|
|
new_email?: string
|
|
email_change_sent_at?: string
|
|
}
|
|
type ProfileIdentitiesError = any
|
|
|
|
export const useProfileIdentitiesQuery = <TData = ProfileIdentitiesData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<ProfileIdentitiesData, ProfileIdentitiesError, TData> = {}) => {
|
|
return useQuery<ProfileIdentitiesData, ProfileIdentitiesError, TData>(
|
|
profileKeys.identities(),
|
|
() => getProfileIdentities(),
|
|
{ ...options }
|
|
)
|
|
}
|