feat: похуй 2.0

This commit is contained in:
2026-05-14 00:31:06 +03:00
parent 61878c20ba
commit 0f88a68c59
4 changed files with 7 additions and 10 deletions

View File

@@ -1,11 +1,13 @@
import { Navigate, Outlet } from 'react-router-dom' import { Navigate, Outlet, useLocation } from 'react-router-dom'
import { useIsAuthenticated } from '@features/auth' import { useIsAuthenticated } from '@features/auth'
import { ROUTES } from '@shared/config/routes' import { ROUTES } from '@shared/config/routes'
export function GuestRoute() { export function GuestRoute() {
const { isAuthenticated, isLoading } = useIsAuthenticated() const { isAuthenticated, isLoading } = useIsAuthenticated()
const location = useLocation()
const from = (location.state as { from?: { pathname: string } })?.from?.pathname ?? ROUTES.WALLET
if (isLoading) return null if (isLoading) return null
if (isAuthenticated) return <Navigate to={ROUTES.WALLET} replace /> if (isAuthenticated) return <Navigate to={from} replace />
return <Outlet /> return <Outlet />
} }

View File

@@ -1,7 +1,9 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import type { ReactNode } from 'react' import type { ReactNode } from 'react'
const queryClient = new QueryClient() const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
})
export function QueryProvider({ children }: { children: ReactNode }) { export function QueryProvider({ children }: { children: ReactNode }) {
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider> return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>

View File

@@ -68,7 +68,6 @@ export function Converter() {
<button <button
type="button" type="button"
className={styles.swapBtn} className={styles.swapBtn}
onClick={c.toggleMode}
aria-label="Поменять направление" aria-label="Поменять направление"
> >
<svg width={16} height={16} viewBox="0 0 16 16" fill="none"> <svg width={16} height={16} viewBox="0 0 16 16" fill="none">

View File

@@ -1,10 +1,8 @@
import { useState } from 'react' import { useState } from 'react'
import { useMutation, useQueryClient } from '@tanstack/react-query' import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useNavigate, useLocation } from 'react-router-dom'
import { loginStart, loginComplete, AUTH_QUERY_KEY } from '@features/auth' import { loginStart, loginComplete, AUTH_QUERY_KEY } from '@features/auth'
import { tokenStore } from '@shared/api/tokenStore' import { tokenStore } from '@shared/api/tokenStore'
import { clearCsrfCache } from '@shared/api/csrf' import { clearCsrfCache } from '@shared/api/csrf'
import { ROUTES } from '@shared/config/routes'
import type { ApiErrorResponse } from '@shared/api/types' import type { ApiErrorResponse } from '@shared/api/types'
function extractErrorMessage(error: unknown): string { function extractErrorMessage(error: unknown): string {
@@ -17,10 +15,7 @@ export function useLoginForm() {
const [password, setPassword] = useState('') const [password, setPassword] = useState('')
const [verificationCode, setVerificationCode] = useState('') const [verificationCode, setVerificationCode] = useState('')
const [codeSent, setCodeSent] = useState(false) const [codeSent, setCodeSent] = useState(false)
const navigate = useNavigate()
const location = useLocation()
const queryClient = useQueryClient() const queryClient = useQueryClient()
const from = (location.state as { from?: { pathname: string } })?.from?.pathname ?? ROUTES.WALLET
const startMutation = useMutation({ const startMutation = useMutation({
mutationFn: loginStart, mutationFn: loginStart,
@@ -33,7 +28,6 @@ export function useLoginForm() {
clearCsrfCache() clearCsrfCache()
tokenStore.set(access_token) tokenStore.set(access_token)
queryClient.setQueryData(AUTH_QUERY_KEY, access_token) queryClient.setQueryData(AUTH_QUERY_KEY, access_token)
navigate(from, { replace: true })
}, },
}) })