From 933372e8eab1acff30e5a6539b2b4abc9e2d68a2 Mon Sep 17 00:00:00 2001 From: David McFadzean Date: Wed, 25 Oct 2023 13:26:09 -0400 Subject: [PATCH] Addressed eslint warnings --- frontend/src/AgentBadge.js | 4 ++-- frontend/src/AssetView.js | 25 ++++--------------------- frontend/src/AuditLog.js | 1 - frontend/src/InvoiceView.js | 4 ++-- frontend/src/NftView.js | 4 ---- frontend/src/ProfileEditor.js | 2 +- 6 files changed, 9 insertions(+), 31 deletions(-) diff --git a/frontend/src/AgentBadge.js b/frontend/src/AgentBadge.js index 5156166..b8cb924 100644 --- a/frontend/src/AgentBadge.js +++ b/frontend/src/AgentBadge.js @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react'; const AgentBadge = ({ agent, xid }) => { - const [user, setUser, refreshProfile] = useState(null); + const [user, setUser] = useState(null); useEffect(() => { const fetchAgent = async () => { @@ -21,7 +21,7 @@ const AgentBadge = ({ agent, xid }) => { }; fetchAgent(); - }, [agent, xid, refreshProfile]); + }, [agent, xid]); if (!user) { return; diff --git a/frontend/src/AssetView.js b/frontend/src/AssetView.js index f20759a..9955b5c 100644 --- a/frontend/src/AssetView.js +++ b/frontend/src/AssetView.js @@ -19,35 +19,18 @@ const AssetView = ({ navigate }) => { const [isDeleted, setIsDeleted] = useState(false); const [tab, setTab] = useState("meta"); const [refreshKey, setRefreshKey] = useState(0); - const [isAuthenticated, setIsAuthenticated] = useState(null); useEffect(() => { const fetchMetadata = async () => { try { - const auth = await axios.get('/check-auth'); - const isAuthenticated = auth.data.isAuthenticated; - setIsAuthenticated(isAuthenticated); - const asset = await axios.get(`/api/v1/asset/${xid}`); const metadata = asset.data; setMetadata(metadata); - - const isToken = !!metadata.token; - setIsToken(isToken); - - if (metadata.asset.collection === 'deleted') { - setIsDeleted(true); - } else { - setIsDeleted(false); - } - - if (isAuthenticated) { - setIsOwner(metadata.userIsOwner); - } else { - setIsOwner(false); - } + setIsToken(!!metadata.token); + setIsDeleted(metadata.asset.collection === 'deleted'); + setIsOwner(metadata.userIsOwner); } catch (error) { - console.error('Error fetching image metadata:', error); + console.error('Error fetching metadata:', error); } }; diff --git a/frontend/src/AuditLog.js b/frontend/src/AuditLog.js index ca57832..e7081ce 100644 --- a/frontend/src/AuditLog.js +++ b/frontend/src/AuditLog.js @@ -8,7 +8,6 @@ import { TableHead, Paper, } from '@mui/material'; -import AgentBadge from './AgentBadge'; const AuditLog = () => { const [txnlog, setTxnLog] = useState([]); diff --git a/frontend/src/InvoiceView.js b/frontend/src/InvoiceView.js index 85910a6..52af5a3 100644 --- a/frontend/src/InvoiceView.js +++ b/frontend/src/InvoiceView.js @@ -7,9 +7,9 @@ const InvoiceView = ({ invoice }) => { const [expired, setExpired] = useState(false); const [paid, setPaid] = useState(false); - let timerId; - useEffect(() => { + let timerId; + if (paid) { clearInterval(timerId); return; diff --git a/frontend/src/NftView.js b/frontend/src/NftView.js index b86429b..f09ecae 100644 --- a/frontend/src/NftView.js +++ b/frontend/src/NftView.js @@ -14,17 +14,13 @@ const NftView = ({ navigate }) => { const [isOwner, setIsOwner] = useState(false); const [tab, setTab] = useState("edition"); const [refreshKey, setRefreshKey] = useState(0); - const [isAuthenticated, setIsAuthenticated] = useState(null); useEffect(() => { const fetchMetadata = async () => { try { - const auth = await axios.get('/check-auth'); - const isAuthenticated = auth.data.isAuthenticated; const asset = await axios.get(`/api/v1/nft/${xid}`); const nft = asset.data; - setIsAuthenticated(isAuthenticated); setNft(nft); setIsOwner(nft.owned); } catch (error) { diff --git a/frontend/src/ProfileEditor.js b/frontend/src/ProfileEditor.js index e505398..b1cf0df 100644 --- a/frontend/src/ProfileEditor.js +++ b/frontend/src/ProfileEditor.js @@ -42,7 +42,7 @@ const ProfileEditor = ({ navigate, refreshProfile, setRefreshProfile }) => { }; fetchProfile(); - }, [navigate, jump, refreshProfile]); + }, [navigate, tab, jump, refreshProfile]); if (!profile) { return;