fix: authorization / registration
This commit is contained in:
@@ -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),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user