Skip to content

Commit

Permalink
Merge pull request #363 from anquetil/updateSettleButton
Browse files Browse the repository at this point in the history
Changes "Settle Auction" button to "Claim NFT" or "Start next auction" based on connected wallet
  • Loading branch information
neokry authored Sep 6, 2023
2 parents c3a8e7b + d0fd005 commit 9ad50bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const CurrentAuction = ({
</AuctionDetails>

<ActionsWrapper>
<Settle isEnding={isEnding} />
<Settle isEnding={isEnding} owner={owner} />
</ActionsWrapper>
</Fragment>
)
Expand Down
15 changes: 12 additions & 3 deletions apps/web/src/modules/auction/components/CurrentAuction/Settle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Button, Flex } from '@zoralabs/zord'
import React, { useState } from 'react'
import { useContractRead, useContractWrite, usePrepareContractWrite } from 'wagmi'
import {
useAccount,
useContractRead,
useContractWrite,
usePrepareContractWrite,
} from 'wagmi'
import { waitForTransaction } from 'wagmi/actions'

import { ContractButton } from 'src/components/ContractButton'
Expand All @@ -13,12 +18,16 @@ import { auctionActionButtonVariants } from '../Auction.css'
interface SettleProps {
isEnding: boolean
collectionAddress?: string
owner?: string | undefined
}

export const Settle = ({ isEnding }: SettleProps) => {
export const Settle = ({ isEnding, owner }: SettleProps) => {
const chain = useChainStore((x) => x.chain)
const addresses = useDaoStore((state) => state.addresses)

const { address } = useAccount()
const isWinner = owner != undefined && address == owner

const { data: paused } = useContractRead({
enabled: !!addresses?.auction,
address: addresses?.auction,
Expand Down Expand Up @@ -77,7 +86,7 @@ export const Settle = ({ isEnding }: SettleProps) => {
handleClick={handleSettle}
className={auctionActionButtonVariants['settle']}
>
Settle Auction
{isWinner ? 'Claim NFT' : 'Start next auction'}
</ContractButton>
</Flex>
)
Expand Down

1 comment on commit 9ad50bd

@vercel
Copy link

@vercel vercel bot commented on 9ad50bd Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.