Something went wrong. Try again.
cee sky
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132import {useMutation} from '@tanstack/react-query'
import {checkAndFormatResetCode} from '#/lib/strings/password'import {usePdsClient, useSession, useSessionApi} from '#/state/session'import {com} from '#/lexicons'
export function useConfirmEmail({ onSuccess, onError,}: {onSuccess?: () => void; onError?: () => void} = {}) { const pdsClient = usePdsClient() const {currentAccount} = useSession() const {refreshSession} = useSessionApi()
return useMutation({ mutationFn: async ({token}: {token: string}) => { if (!currentAccount?.email) { throw new Error('No email found for the current account') }
await pdsClient.call(com.atproto.server.confirmEmail, { email: currentAccount.email.trim(), token: checkAndFormatResetCode(token) || token.trim(), }) // will update session state at root of app await refreshSession() }, onSuccess, onError, })}