fix: authorization / registration

This commit is contained in:
2026-05-10 19:24:32 +03:00
parent 574e27a379
commit 8b0e787fc6
11 changed files with 140 additions and 39 deletions

View File

@@ -3,9 +3,11 @@ import styles from './WalletHeader.module.css'
import { Link } from 'react-router-dom'
import { ROUTES } from '@shared/config/routes'
import { useEffect, useRef, useState } from 'react'
import { useMutation } from '@tanstack/react-query'
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useNavigate } from 'react-router-dom'
import { logout } from '@features/auth/api/registrationApi'
import { AUTH_QUERY_KEY } from '@features/auth'
import { tokenStore } from '@shared/api/tokenStore'
import { Notification } from '@shared/ui'
const TICKERS = [
@@ -19,10 +21,15 @@ export function WalletHeader() {
const [error, setError] = useState(false)
const ref = useRef<HTMLDivElement>(null)
const navigate = useNavigate()
const queryClient = useQueryClient()
const { mutate: logoutMutate } = useMutation({
mutationFn: logout,
onSuccess: () => navigate(ROUTES.HOME),
onSuccess: () => {
tokenStore.clear()
queryClient.setQueryData(AUTH_QUERY_KEY, null)
navigate(ROUTES.HOME)
},
onError: () => setError(true),
})