@@ -8,19 +8,23 @@ import {
88 SheetTitle ,
99 SheetTrigger ,
1010} from "@/components/ui/sheet" ;
11+ import { TabButtons } from "@/components/ui/tabs" ;
1112import { ListerOnly } from "@3rdweb-sdk/react/components/roles/lister-only" ;
1213import { PlusIcon } from "lucide-react" ;
1314import { useState } from "react" ;
1415import type { ThirdwebContract } from "thirdweb" ;
1516import { useActiveAccount } from "thirdweb/react" ;
1617import { CreateListingsForm } from "./list-form" ;
18+ import { ListFormManual } from "./list-form-manual.client" ;
1719
1820interface CreateListingButtonProps {
1921 contract : ThirdwebContract ;
2022 createText ?: string ;
2123 type ?: "direct-listings" | "english-auctions" ;
2224}
2325
26+ const LISTING_MODES = [ "Selection" , "Manual" ] as const ;
27+
2428export const CreateListingButton : React . FC < CreateListingButtonProps > = ( {
2529 createText = "Create" ,
2630 type,
@@ -29,6 +33,8 @@ export const CreateListingButton: React.FC<CreateListingButtonProps> = ({
2933} ) => {
3034 const address = useActiveAccount ( ) ?. address ;
3135 const [ open , setOpen ] = useState ( false ) ;
36+ const [ listingMode , setListingMode ] =
37+ useState < ( typeof LISTING_MODES ) [ number ] > ( "Selection" ) ;
3238
3339 return (
3440 < ListerOnly contract = { contract } >
@@ -40,14 +46,35 @@ export const CreateListingButton: React.FC<CreateListingButtonProps> = ({
4046 </ SheetTrigger >
4147 < SheetContent className = "w-full overflow-y-auto sm:min-w-[540px] lg:min-w-[700px]" >
4248 < SheetHeader >
43- < SheetTitle className = "mb-5 text-left" > { createText } </ SheetTitle >
49+ < SheetTitle className = "text-left" > { createText } </ SheetTitle >
4450 </ SheetHeader >
45- < CreateListingsForm
46- contract = { contract }
47- type = { type }
48- actionText = { createText }
49- setOpen = { setOpen }
51+ < TabButtons
52+ tabs = { LISTING_MODES . map ( ( mode ) => ( {
53+ name : mode ,
54+ isActive : mode === listingMode ,
55+ onClick : ( ) => setListingMode ( mode ) ,
56+ isEnabled : true ,
57+ } ) ) }
58+ tabClassName = "text-sm gap-2 !text-sm"
59+ tabContainerClassName = "px-3 pt-1.5 gap-0.5"
5060 />
61+ < div className = "mt-5 px-3" >
62+ { listingMode === "Selection" ? (
63+ < CreateListingsForm
64+ contract = { contract }
65+ type = { type }
66+ actionText = { createText }
67+ setOpen = { setOpen }
68+ />
69+ ) : (
70+ < ListFormManual
71+ contract = { contract }
72+ type = { type }
73+ actionText = { createText }
74+ setOpen = { setOpen }
75+ />
76+ ) }
77+ </ div >
5178 </ SheetContent >
5279 </ Sheet >
5380 </ ListerOnly >
0 commit comments