Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add referral link #458

Merged
merged 8 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

NEXT_PUBLIC_UPLOAD_API=https://upload-api.zora.co
NEXT_PUBLIC_IPFS_GATEWAY=https://ipfs.decentralized-content.com
NEXT_PUBLIC_NETWORK_TYPE=testnet
NEXT_PUBLIC_NETWORK_TYPE=testnet
55 changes: 39 additions & 16 deletions apps/web/src/modules/auction/components/CurrentAuction/PlaceBid.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Box, Button, Flex } from '@zoralabs/zord'
import React, { Fragment, memo, useEffect, useState } from 'react'
import React, { memo, useEffect, useState } from 'react'
import useSWR, { useSWRConfig } from 'swr'
import { formatEther, parseEther } from 'viem'
import { Address, useAccount, useBalance, useContractReads, useNetwork } from 'wagmi'
import { prepareWriteContract, waitForTransaction, writeContract } from 'wagmi/actions'

import { ContractButton } from 'src/components/ContractButton'
import { Icon } from 'src/components/Icon/Icon'
import AnimatedModal from 'src/components/Modal/AnimatedModal'
import SWR_KEYS from 'src/constants/swrKeys'
import { auctionAbi } from 'src/data/contract/abis'
Expand Down Expand Up @@ -69,7 +70,7 @@ export const PlaceBid = ({
addresses.token
? [SWR_KEYS.AVERAGE_WINNING_BID, chain.id, addresses.token]
: undefined,
() => averageWinningBid(chain.id, addresses.token as Address)
() => averageWinningBid(chain.id, addresses.token as Address),
)

const isMinBid = Number(bidAmount) >= minBidAmount
Expand Down Expand Up @@ -122,11 +123,11 @@ export const PlaceBid = ({
if (tx?.hash) await waitForTransaction({ hash: tx.hash })

await mutate([SWR_KEYS.AUCTION_BIDS, chain.id, addresses.token, tokenId], () =>
getBids(chain.id, addresses.token!, tokenId)
getBids(chain.id, addresses.token!, tokenId),
)

await mutate([SWR_KEYS.AVERAGE_WINNING_BID, chain.id, addresses.token], () =>
averageWinningBid(chain.id, addresses.token as Address)
averageWinningBid(chain.id, addresses.token as Address),
)
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -164,7 +165,7 @@ export const PlaceBid = ({
) : null}

{!creatingBid ? (
<Fragment>
<Flex wrap="wrap">
<form className={bidForm}>
<Box position="relative" mr={{ '@initial': 'x0', '@768': 'x2' }}>
<input
Expand All @@ -182,16 +183,38 @@ export const PlaceBid = ({
</Box>
</Box>
</form>

<ContractButton
className={auctionActionButtonVariants['bid']}
handleClick={handleCreateBid}
disabled={address && isValidChain ? !isValidBid : false}
mt={{ '@initial': 'x2', '@768': 'x0' }}
>
Place bid
</ContractButton>
</Fragment>
<Flex mt="x2">
mulfdev marked this conversation as resolved.
Show resolved Hide resolved
<ContractButton
className={auctionActionButtonVariants['bid']}
handleClick={handleCreateBid}
disabled={address && isValidChain ? !isValidBid : false}
mt={{ '@initial': 'x2', '@768': 'x0' }}
>
Place bid
</ContractButton>
{chain.id !== 1 ? (
<Button
mulfdev marked this conversation as resolved.
Show resolved Hide resolved
ml="x2"
mt={{ '@initial': 'x2', '@768': 'x0' }}
onClick={async () => {
const baseUrl = `https://nouns.build/dao/${chain.name.toLowerCase()}/${addresses.token}`
mulfdev marked this conversation as resolved.
Show resolved Hide resolved
if (address === undefined) {
return
mulfdev marked this conversation as resolved.
Show resolved Hide resolved
}
const params = new URLSearchParams({
referral: address.toString(),
}).toString()
const fullUrl = `${baseUrl}?${params}`

await navigator.clipboard.writeText(fullUrl)
}}
>
Refer
mulfdev marked this conversation as resolved.
Show resolved Hide resolved
<Icon size="md" fill="neutral" id="copy" />
</Button>
) : null}
</Flex>
</Flex>
) : (
<Button className={auctionActionButtonVariants['bidding']} disabled>
placing {bidAmount} ETH bid
Expand All @@ -201,4 +224,4 @@ export const PlaceBid = ({
)
}

export const MemoizedPlaceBid = memo(PlaceBid)
export const MemoizedPlaceBid = memo(PlaceBid)
Loading