-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: complete loading of winning section
- Loading branch information
Showing
19 changed files
with
244 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'twin.macro'; | ||
import { NormalText } from '../CreateGameCard/types'; | ||
import Section from '../../common/Section'; | ||
import optimismLogo from '../../assets/images/optimisim-logo.png' | ||
import arbitrumLogo from '../../assets/images/arbitrum-logo.png' | ||
|
||
function ClaimOnOtherNetworkSection(props: React.AllHTMLAttributes<HTMLDivElement>) { | ||
// filter out the games of which the user is not the winner | ||
return ( <Section hdr="Claim on other networks" direction="col" {...props}> | ||
|
||
<div tw="flex self-start gap-x-[24px] "> | ||
<div tw="flex px-[10px] py-[5px] rounded-[5px] bg-[#2E2E2E] justify-center items-center gap-x-[10px]"> | ||
<img src={optimismLogo} alt="optimism-logo" tw="w-[24px] h-[24px]"/> | ||
<NormalText>Arbitrum - Coming soon</NormalText> | ||
</div> | ||
|
||
<div tw="flex px-[10px] py-[5px] rounded-[5px] bg-[#2E2E2E] justify-center items-center gap-x-[10px]"> | ||
<img src={arbitrumLogo} alt="arbitrum-logo" tw="w-[24px] h-[24px]" /> | ||
<NormalText>Optimisim - Coming soon</NormalText> | ||
</div> | ||
</div> | ||
</Section> | ||
) | ||
} | ||
export default ClaimOnOtherNetworkSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import Section from '../../common/Section'; | ||
import ClaimBar from '../../common/ClaimBar'; | ||
import 'twin.macro'; | ||
interface ClaimTokenWinsSectionProps extends React.Attributes { | ||
gameIds: number[] | ||
import { ClaimableGames } from '../WegaGames'; | ||
import { HexishString } from '../../models'; | ||
|
||
interface ClaimTokenWinsSectionProps extends React.AllHTMLAttributes<HTMLDivElement> { | ||
userWalletAddress: HexishString; | ||
gamesCount: number; | ||
networkId: number; | ||
} | ||
|
||
function ClaimTokenWinsSection({ gameIds , ...rest }: ClaimTokenWinsSectionProps) { | ||
function ClaimTokenWinsSection({ networkId, userWalletAddress, gamesCount, ...rest }: ClaimTokenWinsSectionProps) { | ||
// filter out the games of which the user is not the winner | ||
return ( | ||
<Section hdr="Tokens won" direction="col" tw="gap-2" { ...rest } > | ||
{ | ||
gameIds.map( | ||
(dg, i) => ( <ClaimBar count={i + 1} gameId={dg} key={`claim-wins-bar-${i}`} className="dark:bg-[#1C1C1C] py-2 px-3 rounded-[5px]"/> )) | ||
} | ||
</Section> | ||
) | ||
return ( <ClaimableGames userWalletAddress={userWalletAddress} gamesCount={gamesCount} {...rest} networkId={networkId} /> ) | ||
} | ||
export default ClaimTokenWinsSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Section from '../../common/Section'; | ||
import Button from '../../common/Button'; | ||
import { | ||
LargeText, | ||
NormalText | ||
} from "../CreateGameCard/types"; | ||
import { | ||
useConnectModal, | ||
} from '@rainbow-me/rainbowkit'; | ||
import 'twin.macro'; | ||
|
||
interface ClaimWinsDisconnectedUserSectionProps extends React.AllHTMLAttributes<HTMLDivElement> { | ||
gameIds: number[] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function ClaimWinsDisconnectedUserSection({ gameIds , ...rest }: ClaimWinsDisconnectedUserSectionProps) { | ||
// filter out the games of which the user is not the winner | ||
const { openConnectModal } = useConnectModal(); | ||
return openConnectModal ? ( | ||
<Section hdr="Tokens won" direction="col" tw="gap-y-[32px] w-full" { ...rest } > | ||
<LargeText tw="text-shinishi text-center">Connect your wallet to see your wins.</LargeText> | ||
<Button buttonType="secondary" tw="flex max-w-[fit-content] self-center border-[2px]" onClick={ | ||
(e: any) => { | ||
e.preventDefault(); | ||
openConnectModal(); | ||
}}> | ||
<NormalText tw="tracking-[0.32px] leading-[12px] font-bold">Connect</NormalText> | ||
</Button> | ||
</Section> | ||
) : <></> | ||
} | ||
export default ClaimWinsDisconnectedUserSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
import { User } from '../../models'; | ||
import { appApiSlice } from '../../app/apiSlice'; | ||
|
||
export const connectButtonApiSlice = appApiSlice.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
createPlayer: builder.mutation<any, Partial<User> & Pick<User, 'uuid'>>({ | ||
query: (walletAddress) => ({ | ||
url: '/users', | ||
method: 'POST', | ||
body: { walletAddress } | ||
}), | ||
transformResponse: (response: any) => { | ||
return response.uuid | ||
}, | ||
}), | ||
}) | ||
}) | ||
|
||
export const { useCreatePlayerMutation } = connectButtonApiSlice; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable no-unused-vars */ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { Network, User, Wallet } from '../../models'; | ||
import { RootState } from "../../app/store"; | ||
import { connectButtonApiSlice } from './apiSlice'; | ||
|
||
interface AppState { | ||
loading: boolean; | ||
network: Network | undefined; | ||
user: User; | ||
} | ||
|
||
export const initialState: AppState = { | ||
loading: false, | ||
network: undefined, | ||
user: { | ||
uuid: undefined, | ||
wallet: undefined, | ||
loading: false, | ||
}, | ||
}; | ||
|
||
export const connectionSlice = createSlice({ | ||
name: 'connection', | ||
initialState, | ||
reducers: { | ||
setWallet(state, action: PayloadAction<Wallet>){ | ||
state.user.wallet = action.payload | ||
}, | ||
resetWallet(state) { | ||
state.user.wallet = undefined; | ||
}, | ||
resetNetwork(state) { | ||
state.network = undefined; | ||
}, | ||
setNetworkUnsupported(state, action: PayloadAction<boolean>) { | ||
state = Object.assign(state, { ...state, network: { unsupported: action.payload } }); | ||
}, | ||
setNetwork(state, action: PayloadAction<Network>){ | ||
state.network = action.payload; | ||
}, | ||
}, | ||
extraReducers: (builder) => { | ||
builder.addMatcher(connectButtonApiSlice.endpoints.createPlayer.matchFulfilled, (state, action) => { state.user.uuid = action.payload }); | ||
builder.addMatcher(connectButtonApiSlice.endpoints.createPlayer.matchRejected, (state) => { state.user.loading = false }); | ||
builder.addMatcher(connectButtonApiSlice.endpoints.createPlayer.matchPending, (state) => { state.user.loading = true }); | ||
} | ||
}); | ||
|
||
export const { setWallet, setNetwork, resetWallet, resetNetwork, setNetworkUnsupported } = connectionSlice.actions; | ||
export const selectNetwork = (state: RootState) => state.connection.network; | ||
export const selectUser = (state: RootState) => state.connection.user; | ||
export const selectWallet = (state: RootState) => state.connection.user.wallet; | ||
export const selectAppLoading = (state: RootState) => state.connection.loading; | ||
export default connectionSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.