Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import type {
DirectListing,
EnglishAuction,
} from "thirdweb/extensions/marketplace";
import { useActiveAccount } from "thirdweb/react";
import { BuyDirectListingButton, useActiveAccount } from "thirdweb/react";

import { CodeClient } from "@/components/ui/code/code.client";
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
import { toast } from "sonner";
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
import { CancelTab } from "./cancel-tab";
import { LISTING_STATUS } from "./types";
Expand Down Expand Up @@ -141,11 +142,6 @@ export const ListingDrawer: React.FC<NFTDrawerProps> = ({
</GridItem>
</>
)}

{/*
Todo: Add a Buy button somewhere in this section once the Dashboard is fully migrated to v5 (?)
Kien already shipped a prebuilt component for the Marketplace Buy Button in SDK v5
*/}
</SimpleGrid>
</Card>
{data?.asset.metadata.properties ? (
Expand All @@ -168,6 +164,27 @@ export const ListingDrawer: React.FC<NFTDrawerProps> = ({
twAccount={twAccount}
/>
)}

{!isOwner && renderData.status === "ACTIVE" && (
<BuyDirectListingButton
listingId={renderData.id}
contractAddress={renderData.assetContractAddress}
chain={contract.chain}
client={contract.client}
className="w-full"
quantity={1n}
onError={(error) => {
toast.error("Failed to buy listing", {
description: error.message,
});
}}
onTransactionConfirmed={() => {
toast.success("Listing bought successfully");
}}
>
Buy Listing
</BuyDirectListingButton>
)}
</SheetContent>
</Sheet>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export type BuyDirectListingButtonProps = Omit<
* Since it uses the TransactionButton, it can take in any props that can be passed
* to the [`TransactionButton`](https://portal.thirdweb.com/references/typescript/v5/TransactionButton)
*
*
* @param props
* @returns <TransactionButton />
*
* @param props props of type [BuyDirectListingButtonProps](https://portal.thirdweb.com/references/typescript/v5/BuyDirectListingButtonProps)
* @example
* ```tsx
* import { BuyDirectListingButton } from "thirdweb/react";
Expand Down
Loading