-
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.
- Loading branch information
Showing
30 changed files
with
636 additions
and
364 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,20 @@ | ||
import * as React from "react" | ||
import { SVGProps } from "react" | ||
const SvgComponent = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={20} | ||
height={21} | ||
fill="none" | ||
{...props} | ||
> | ||
<path | ||
stroke="#FDFDFD" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={3} | ||
d="M10 2v16.666m0 0-8-8m8 8 8-8" | ||
/> | ||
</svg> | ||
) | ||
export default SvgComponent |
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 |
---|---|---|
@@ -1,55 +1,41 @@ | ||
import { useEffect } from 'react'; | ||
import { | ||
useConnectModal, | ||
} from '@rainbow-me/rainbowkit'; | ||
import { useConnectModal } from '@rainbow-me/rainbowkit'; | ||
import Button from '../Button'; | ||
import{ DownloadIcon } from '../../assets/icons'; | ||
import { useWegaStore, useBlockchainApiHooks } from '../../hooks'; | ||
import { useSelector } from 'react-redux'; | ||
import { useGetSet } from 'react-use'; | ||
import { selectGameById } from '../../containers/App/api'; | ||
import { HexishString } from '../../models'; | ||
import { useWegaStore } from '../../hooks'; | ||
import { useGlobalModalContext, MODAL_TYPES } from "../../common/modals"; | ||
import { Wega } from '../../models'; | ||
import 'twin.macro' | ||
|
||
interface ButtonForClaimingProps { | ||
gameId: number; | ||
game: Wega; | ||
} | ||
export const ButtonForClaiming = ({ gameId }: ButtonForClaimingProps) => { | ||
const game = useSelector(state => selectGameById(state, gameId)); | ||
|
||
export const ButtonForClaiming = ({ game }: ButtonForClaimingProps) => { | ||
const { wallet } = useWegaStore() | ||
const { openConnectModal } = useConnectModal(); | ||
const [isPlayerWinner, setIsPlayerWinner] = useGetSet<boolean>(false); | ||
const { useGetWinnersQuery, useClaimMutation } = useBlockchainApiHooks; | ||
const { getWinners, data: winners } = useGetWinnersQuery(); | ||
const { claim, isLoading: isClaimingLoading } = useClaimMutation(); | ||
|
||
const handleClaim = async (escrowHash: HexishString) => { | ||
claim(escrowHash); | ||
} | ||
|
||
useEffect(() => { | ||
if(game && game?.wager) { | ||
getWinners(game.wager.wagerHash as HexishString); | ||
} | ||
if(winners && winners.length > 0 && wallet && wallet?.address) { | ||
setIsPlayerWinner(winners.some((winner: any) => winner.toLowerCase() === wallet?.address)) | ||
} | ||
console.log(winners); | ||
}, [winners?.length, game, wallet, wallet?.address, winners]); | ||
const { showModal, hideModal } = useGlobalModalContext(); | ||
|
||
const handleClaim = async (wallet: any) => { | ||
showModal(MODAL_TYPES.CLAIM_MODAL, { | ||
game, | ||
wallet, | ||
hide: hideModal, | ||
}, true); | ||
} | ||
|
||
return wallet && game && winners && isPlayerWinner() ? (!wallet && openConnectModal ? | ||
return (!wallet && openConnectModal ? | ||
<Button | ||
buttonType="secondary" | ||
buttonType="primary" | ||
className="flex items-center" | ||
onClick={openConnectModal} | ||
> | ||
Claim | ||
<DownloadIcon tw="h-[16px] w-[16px] ms-[5px]" /> | ||
</Button> : | ||
<Button buttonType="secondary" className="flex items-center" onClick={() => handleClaim(game.wager.wagerHash as HexishString)} > | ||
{ isClaimingLoading ? "Loading..." : "Claim" } | ||
<DownloadIcon tw="h-[16px] w-[16px] ms-[5px]" /> | ||
<Button buttonType="primary" className="flex items-center" onClick={() => handleClaim(wallet)} > | ||
Claim | ||
<DownloadIcon tw="h-[16px] w-[16px] ms-[5px] dark:stroke-blanc" /> | ||
</Button> | ||
) : <></> | ||
} | ||
// sdfasdf | ||
) | ||
} |
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
Empty file.
Oops, something went wrong.