diff --git a/packages/webapp/src/components/collection/deckList.tsx b/packages/webapp/src/components/collection/deckList.tsx index f64e1da0..b8e35c6a 100644 --- a/packages/webapp/src/components/collection/deckList.tsx +++ b/packages/webapp/src/components/collection/deckList.tsx @@ -1,78 +1,78 @@ -import React, { useCallback, useEffect, useState } from "react" - -import { getDeckNames } from "src/actions/getDeck" -import Link from "src/components/link" -import { Button } from "src/components/ui/button" -import * as store from "src/store/hooks" - -interface DeckCollectionDisplayProps { - onDeckSelect: (deckID: number) => void -} - -const DeckCollectionDisplay: React.FC = ({ onDeckSelect }) => { - const playerAddress = store.usePlayerAddress() - const [deckNames, setDeckNames] = useState([]) - const [isLoadingDecks, setIsLoadingDecks] = useState(false) - - const loadDeckNames = useCallback(() => { - if (playerAddress) { - setIsLoadingDecks(true) - getDeckNames({ - playerAddress: playerAddress, - onSuccess: () => {}, - }) - .then((response) => { - if (!response.simulatedResult) return - const receivedDecks = response.simulatedResult as string[] - setDeckNames(receivedDecks) - setIsLoadingDecks(false) - }) - .catch((error) => { - console.error("Error fetching decks:", error) - }) - } - }, [playerAddress]) - - useEffect(() => { - loadDeckNames() - }, [loadDeckNames]) - - return ( -
- {/* New Deck Button */} - - - {/* Loading Button */} - {isLoadingDecks && ( - - )} - - {/* Deck Buttons */} - {deckNames.map((deckname, deckID) => ( - - ))} -
- ) -} - -export default DeckCollectionDisplay +import React, { useCallback, useEffect, useState } from "react" + +import { getDeckNames } from "src/actions/getDeck" +import Link from "src/components/link" +import { Button } from "src/components/ui/button" +import * as store from "src/store/hooks" + +interface DeckCollectionDisplayProps { + onDeckSelect: (deckID: number) => void +} + +const DeckCollectionDisplay: React.FC = ({ onDeckSelect }) => { + const playerAddress = store.usePlayerAddress() + const [deckNames, setDeckNames] = useState([]) + const [isLoadingDecks, setIsLoadingDecks] = useState(false) + + const loadDeckNames = useCallback(() => { + if (playerAddress) { + setIsLoadingDecks(true) + getDeckNames({ + playerAddress: playerAddress, + onSuccess: () => {}, + }) + .then((response) => { + if (!response.simulatedResult) return + const receivedDecks = response.simulatedResult as string[] + setDeckNames(receivedDecks) + setIsLoadingDecks(false) + }) + .catch((error) => { + console.error("Error fetching decks:", error) + }) + } + }, [playerAddress]) + + useEffect(() => { + loadDeckNames() + }, [loadDeckNames]) + + return ( +
+ {/* New Deck Button */} + + + {/* Loading Button */} + {isLoadingDecks && ( + + )} + + {/* Deck Buttons */} + {deckNames.map((deckname, deckID) => ( + + ))} +
+ ) +} + +export default DeckCollectionDisplay diff --git a/packages/webapp/src/pages/collection.tsx b/packages/webapp/src/pages/collection.tsx index fc61a276..eafe54c6 100644 --- a/packages/webapp/src/pages/collection.tsx +++ b/packages/webapp/src/pages/collection.tsx @@ -48,9 +48,9 @@ const Collection: FablePage = ({ isHydrated }) => { const [isEditing, setIsEditing] = useState(false) // Deck Collection Display - const [editingDeckIndex, setEditingDeckIndex] = useState(null) - const [decks, setDecks] = useState([]) - const [isLoadingDeck, setIsLoadingDeck] = useState(false) + const [editingDeckIndex, setEditingDeckIndex] = useState(null) + const [decks] = useState([]) + const [isLoadingDeck, setIsLoadingDeck] = useState(false) const activeEffects = Object.keys(effectMap).filter((key) => effectMap[key]) const activeTypes = Object.keys(typeMap).filter((key) => typeMap[key])