|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
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 { |
|
|
|
|
id!: string |
|
|
|
@ -39,9 +39,18 @@ export function useToken(): UseTokenInterface { |
|
|
|
|
setToken(grabToken()?.payload) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const addToken = (token: string) => { |
|
|
|
|
const addToken = (token: string): boolean => { |
|
|
|
|
if (!grabTokenData(token)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
storeToken(token) |
|
|
|
|
setToken(grabToken()?.payload) |
|
|
|
|
setTokens([ |
|
|
|
|
...tokens, |
|
|
|
|
grabToken()?.payload |
|
|
|
|
]) |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return {token, tokens, switchToken, deleteToken, addToken} |
|
|
|
|