mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at thread-bug 23 lines 636 B view raw
1import {useMutation} from '@tanstack/react-query' 2 3import {useAgent, useSession} from '#/state/session' 4 5export function useConfirmEmail() { 6 const agent = useAgent() 7 const {currentAccount} = useSession() 8 9 return useMutation({ 10 mutationFn: async ({token}: {token: string}) => { 11 if (!currentAccount?.email) { 12 throw new Error('No email found for the current account') 13 } 14 15 await agent.com.atproto.server.confirmEmail({ 16 email: currentAccount.email, 17 token: token.trim(), 18 }) 19 // will update session state at root of app 20 await agent.resumeSession(agent.session!) 21 }, 22 }) 23}