|
|
@ -1,5 +1,5 @@ |
|
|
|
import {useState, useEffect} from 'react' |
|
|
|
import {useState, useEffect} from 'react' |
|
|
|
import {cleanToken, grabToken, grabTokens, selectToken, storeToken} from "../functions/token"; |
|
|
|
import {cleanToken, grabToken, grabTokenData, grabTokens, selectToken, storeToken} from "../functions/token"; |
|
|
|
|
|
|
|
|
|
|
|
export class Token { |
|
|
|
export class Token { |
|
|
|
id!: string |
|
|
|
id!: string |
|
|
@ -39,9 +39,18 @@ export function useToken(): UseTokenInterface { |
|
|
|
setToken(grabToken()?.payload) |
|
|
|
setToken(grabToken()?.payload) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const addToken = (token: string) => { |
|
|
|
const addToken = (token: string): boolean => { |
|
|
|
|
|
|
|
if (!grabTokenData(token)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
storeToken(token) |
|
|
|
storeToken(token) |
|
|
|
setToken(grabToken()?.payload) |
|
|
|
setToken(grabToken()?.payload) |
|
|
|
|
|
|
|
setTokens([ |
|
|
|
|
|
|
|
...tokens, |
|
|
|
|
|
|
|
grabToken()?.payload |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return {token, tokens, switchToken, deleteToken, addToken} |
|
|
|
return {token, tokens, switchToken, deleteToken, addToken} |
|
|
|