Skip to content

Commit

Permalink
Make check fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eviterin committed Mar 16, 2024
1 parent 59e800c commit 3e6f052
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 81 deletions.
156 changes: 78 additions & 78 deletions packages/webapp/src/components/collection/deckList.tsx
Original file line number Diff line number Diff line change
@@ -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<DeckCollectionDisplayProps> = ({ onDeckSelect }) => {
const playerAddress = store.usePlayerAddress()
const [deckNames, setDeckNames] = useState<string[]>([])
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 (
<div className="flex w-full flex-col items-center p-3">
{/* New Deck Button */}
<Button
width="full"
className="my-2 border-2 border-yellow-500 font-fable text-xl hover:scale-105 hover:border-yellow-400"
>
<Link href={"/collection?newDeck=true"}>New Deck →</Link>
</Button>

{/* Loading Button */}
{isLoadingDecks && (
<Button
variant={"secondary"}
width="full"
className="my-2 border-2 border-yellow-500 font-fable text-xl normal-case hover:scale-105 hover:border-yellow-400"
disabled={true}
>
Loading...
</Button>
)}

{/* Deck Buttons */}
{deckNames.map((deckname, deckID) => (
<Button
variant={"secondary"}
width="full"
className="my-1 border-2 border-yellow-500 font-fable text-xl normal-case hover:scale-105 hover:border-yellow-400"
key={deckID}
onClick={() => onDeckSelect(deckID)}
>
{deckname}
</Button>
))}
</div>
)
}

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<DeckCollectionDisplayProps> = ({ onDeckSelect }) => {
const playerAddress = store.usePlayerAddress()
const [deckNames, setDeckNames] = useState<string[]>([])
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 (
<div className="flex w-full flex-col items-center p-3">
{/* New Deck Button */}
<Button
width="full"
className="my-2 border-2 border-yellow-500 font-fable text-xl hover:scale-105 hover:border-yellow-400"
>
<Link href={"/collection?newDeck=true"}>New Deck →</Link>
</Button>

{/* Loading Button */}
{isLoadingDecks && (
<Button
variant={"secondary"}
width="full"
className="my-2 border-2 border-yellow-500 font-fable text-xl normal-case hover:scale-105 hover:border-yellow-400"
disabled={true}
>
Loading...
</Button>
)}

{/* Deck Buttons */}
{deckNames.map((deckname, deckID) => (
<Button
variant={"secondary"}
width="full"
className="my-1 border-2 border-yellow-500 font-fable text-xl normal-case hover:scale-105 hover:border-yellow-400"
key={deckID}
onClick={() => onDeckSelect(deckID)}
>
{deckname}
</Button>
))}
</div>
)
}

export default DeckCollectionDisplay
6 changes: 3 additions & 3 deletions packages/webapp/src/pages/collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ const Collection: FablePage = ({ isHydrated }) => {
const [isEditing, setIsEditing] = useState(false)

// Deck Collection Display
const [editingDeckIndex, setEditingDeckIndex] = useState<number|null>(null)
const [decks, setDecks] = useState<Deck[]>([])
const [isLoadingDeck, setIsLoadingDeck] = useState(false)
const [editingDeckIndex, setEditingDeckIndex] = useState<number | null>(null)
const [decks] = useState<Deck[]>([])
const [isLoadingDeck, setIsLoadingDeck] = useState(false)

const activeEffects = Object.keys(effectMap).filter((key) => effectMap[key])
const activeTypes = Object.keys(typeMap).filter((key) => typeMap[key])
Expand Down

0 comments on commit 3e6f052

Please sign in to comment.