diff --git a/src/widgets/login-form/model/useLoginForm.ts b/src/widgets/login-form/model/useLoginForm.ts index 6282711..bd4f73a 100644 --- a/src/widgets/login-form/model/useLoginForm.ts +++ b/src/widgets/login-form/model/useLoginForm.ts @@ -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) }, })