Skip to content

Commit

Permalink
Fixed github CI checks for linting (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
norswap authored Feb 26, 2024
2 parents a980cd7 + ff0d1b5 commit 7820324
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check project

on:
push:
branches: [master]
pull_request:
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Fake contract deployment
run: mkdir -p packages/contracts/out && echo "{}" > packages/contracts/out/deployment.json
- run: make setup
- run: make check

6 changes: 3 additions & 3 deletions packages/webapp/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NextPage } from "next"
import type { AppType } from "next/app"
import Head from "next/head"
import { useAccount, WagmiConfig } from "wagmi"
import { useState } from "react"
import { Dispatch, SetStateAction, useState } from "react"
import { ensureLocalAccountIndex, wagmiConfig } from "src/chain"
import jotaiDebug from "src/components/lib/jotaiDebug"
import { GlobalErrorModal } from "src/components/modals/globalErrorModal"
Expand All @@ -27,7 +27,7 @@ import { Deck } from "src/store/types"
* Make pages in the app conform to this type.
* See [@link useIsHydrated] for more info on the meaning of the `isHydrated` prop.
*/
export type FablePage = NextPage<{ isHydrated: boolean }>
export type FablePage = NextPage<{ decks: Deck[], isHydrated: boolean, setDecks: Dispatch<SetStateAction<Deck[]>> }>

// =================================================================================================

Expand Down Expand Up @@ -76,7 +76,7 @@ const ComponentWrapper = ({
const errorConfig = useErrorConfig()

// todo @eviterin: i've understood it so that decks are stored on chain. thus, below part is not going to be needed.
const testCards = [];
const _testCards = [];
const [decks, setDecks] = useState<Deck[]>([]);
//

Expand Down
4 changes: 3 additions & 1 deletion packages/webapp/src/pages/collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Card } from "src/store/types"
import { Address } from "src/chain"
import { FablePage } from "src/pages/_app"
import Link from "next/link"
import { router } from 'next/router'
import { useRouter } from 'next/router'

// NOTE(norswap & geniusgarlic): Just an example, when the game actually has effects & types,
// fetch those from the chain instead of hardcoding them here.
Expand All @@ -36,6 +36,8 @@ const Collection: FablePage = ({ decks, isHydrated }) => {
const [ effectMap, setEffectMap ] = useState(initialEffectMap)
const [ typeMap, setTypeMap ] = useState(initialTypeMap)

const router = useRouter()

const cardName = selectedCard?.lore.name || "Select a card"
const cardFlavor = selectedCard?.lore.flavor || "Select a card to see its details"

Expand Down
28 changes: 16 additions & 12 deletions packages/webapp/src/pages/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useInventoryCardsCollectionGetCollection } from "src/generated"
import { Card } from "src/store/types"
import { Address } from "src/chain"
import { FablePage } from "src/pages/_app"
import { router } from 'next/router'
import { useRouter } from 'next/router'
import { useEffect} from 'react'

// NOTE(norswap & geniusgarlic): Just an example, when the game actually has effects & types,
Expand All @@ -36,7 +36,9 @@ const Editor: FablePage = ({ decks, setDecks, isHydrated }) => {
const [ typeMap, setTypeMap ] = useState(initialTypeMap)
const [ deckName, setDeckName ] = useState('')
const [ deck, setDeck ] = useState<Card[]>([])
const [ originalDeckIndex, setOriginalDeckIndex ] = useState(null)
const [ originalDeckIndex, setOriginalDeckIndex ] = useState<number | null>(null)

const router = useRouter()

const cardName = selectedCard?.lore.name || "Hover a card"
const cardFlavor = selectedCard?.lore.flavor || "Hover a card to see its details"
Expand Down Expand Up @@ -81,16 +83,18 @@ const Editor: FablePage = ({ decks, setDecks, isHydrated }) => {

// Check url for an index, which is passed if the user wants to modify an existing deck
useEffect(() => {
const deckIndex = parseInt(router.query.deckID)
if (!isNaN(deckIndex) && decks[deckIndex] != null) {
setOriginalDeckIndex(deckIndex) // Store the original index
const selectedDeck = decks[deckIndex]
setDeckName(selectedDeck.name)
setDeck(selectedDeck.cards)
} else {
setOriginalDeckIndex(null) // Reset if not editing an existing deck
if (typeof router.query.deckID === "string") {
const deckIndex = parseInt(router.query.deckID)
if (!isNaN(deckIndex) && decks[deckIndex] != null) {
setOriginalDeckIndex(deckIndex) // Store the original index
const selectedDeck = decks[deckIndex]
setDeckName(selectedDeck.name)
setDeck(selectedDeck.cards)
} else {
setOriginalDeckIndex(null) // Reset if not editing an existing deck
}
}
}, [router.query.index, decks])
}, [router.query.deckID, decks])

const isCardInDeck = (cardToCheck: Card) => {
return deck.some(cardInDeck => cardInDeck.id === cardToCheck.id)
Expand Down Expand Up @@ -121,7 +125,7 @@ const Editor: FablePage = ({ decks, setDecks, isHydrated }) => {

setIsDeckValid(true)

let updatedDecks = [...decks]
const updatedDecks = [...decks]

// Check if editing an existing deck and the name has changed
if (originalDeckIndex !== null && decks[originalDeckIndex].name !== deckName) {
Expand Down

0 comments on commit 7820324

Please sign in to comment.