diff --git a/pages/admin/card-editor.js b/pages/admin/card-editor.js
index d358ce8..fc93164 100644
--- a/pages/admin/card-editor.js
+++ b/pages/admin/card-editor.js
@@ -8,22 +8,6 @@ import AdminProtected from '../../components/AdminProtected';
const CardEditor = () => {
const router = useRouter();
const { id } = router.query;
-
- const [mounted, setMounted] = useState(false);
-
- useEffect(() => {
- setMounted(true);
- }, []);
-
- if (!mounted) {
- return (
-
-
-
- );
- }
const [card, setCard] = useState(null);
const [loading, setLoading] = useState(true);
diff --git a/pages/admin/card-import.js b/pages/admin/card-import.js
index a2a4f20..843dfe1 100644
--- a/pages/admin/card-import.js
+++ b/pages/admin/card-import.js
@@ -5,21 +5,6 @@ import Layout from '../../components/Layout';
import AdminProtected from '../../components/AdminProtected';
const CardImport = () => {
- const [mounted, setMounted] = useState(false);
-
- useEffect(() => {
- setMounted(true);
- }, []);
-
- if (!mounted) {
- return (
-
-
-
- );
- }
const router = useRouter();
const [importType, setImportType] = useState('mtg');
const [setCode, setSetCode] = useState('');
diff --git a/pages/scanner.js b/pages/scanner.js
index 345a816..f5a1039 100644
--- a/pages/scanner.js
+++ b/pages/scanner.js
@@ -8,7 +8,7 @@ import ManaSymbolSettings from '../components/ManaSymbolSettings';
import { useAuth } from '../lib/use-auth';
export default function Scanner() {
- const { user } = useAuth();
+ const { user, loading: authLoading } = useAuth();
const router = useRouter();
const [scannedCards, setScannedCards] = useState([]);
const [collections, setCollections] = useState([]);
@@ -26,13 +26,12 @@ export default function Scanner() {
// Mana symbol settings
const [manaSymbolSettings, setManaSymbolSettings] = useState({ useSVG: false });
- // Redirect to login if not authenticated
+ // Redirect to login if not authenticated (wait for verify to finish)
useEffect(() => {
- if (!user) {
+ if (!authLoading && !user) {
router.push('/login');
- return;
}
- }, [user, router]);
+ }, [authLoading, user, router]);
// Load collections and decks
useEffect(() => {
@@ -325,6 +324,16 @@ export default function Scanner() {
setSelectedCards(new Set());
};
+ if (authLoading) {
+ return (
+
+
+
+ );
+ }
+
if (!user) {
return
Redirecting to login...
;
}