14.05.2026 rip
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { loginStart, loginComplete, AUTH_QUERY_KEY } from '@features/auth'
|
||||
import { tokenStore } from '@shared/api/tokenStore'
|
||||
import { clearCsrfCache } from '@shared/api/csrf'
|
||||
import { ROUTES } from '@shared/config/routes'
|
||||
import type { ApiErrorResponse } from '@shared/api/types'
|
||||
|
||||
function extractErrorMessage(error: unknown): string {
|
||||
@@ -16,6 +18,7 @@ export function useLoginForm() {
|
||||
const [verificationCode, setVerificationCode] = useState('')
|
||||
const [codeSent, setCodeSent] = useState(false)
|
||||
const queryClient = useQueryClient()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const startMutation = useMutation({
|
||||
mutationFn: loginStart,
|
||||
@@ -28,6 +31,7 @@ export function useLoginForm() {
|
||||
clearCsrfCache()
|
||||
tokenStore.set(access_token)
|
||||
queryClient.setQueryData(AUTH_QUERY_KEY, access_token)
|
||||
navigate(ROUTES.PROFILE)
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user