diff --git a/apps/dashboard/src/components/custom-contract/contract-header/metadata-header.tsx b/apps/dashboard/src/components/custom-contract/contract-header/metadata-header.tsx index b87a01fdcca..7b94eb1a545 100644 --- a/apps/dashboard/src/components/custom-contract/contract-header/metadata-header.tsx +++ b/apps/dashboard/src/components/custom-contract/contract-header/metadata-header.tsx @@ -83,7 +83,7 @@ export const MetadataHeader: React.FC = ({ {chain && ( {cleanedChainName && ( diff --git a/apps/dashboard/src/contract-ui/tabs/proposals/components/proposal-button.tsx b/apps/dashboard/src/contract-ui/tabs/proposals/components/proposal-button.tsx index 69c32923fee..e2eadfe9a23 100644 --- a/apps/dashboard/src/contract-ui/tabs/proposals/components/proposal-button.tsx +++ b/apps/dashboard/src/contract-ui/tabs/proposals/components/proposal-button.tsx @@ -1,12 +1,23 @@ "use client"; -import { useDisclosure } from "@chakra-ui/react"; +import { + Sheet, + SheetContent, + SheetHeader, + SheetTitle, + SheetTrigger, +} from "@/components/ui/sheet"; +import { FormControl, Textarea } from "@chakra-ui/react"; import { TransactionButton } from "components/buttons/TransactionButton"; +import { useTrack } from "hooks/analytics/useTrack"; import { PlusIcon } from "lucide-react"; +import { useState } from "react"; +import { useForm } from "react-hook-form"; +import { toast } from "sonner"; import type { ThirdwebContract } from "thirdweb"; +import * as VoteExt from "thirdweb/extensions/vote"; import { useSendAndConfirmTransaction } from "thirdweb/react"; -import { Button, Drawer } from "tw-components"; -import { CreateProposalForm } from "./proposal-form"; +import { Button, FormErrorMessage, FormLabel } from "tw-components"; interface VoteButtonProps { contract: ThirdwebContract; @@ -15,55 +26,93 @@ interface VoteButtonProps { const PROPOSAL_FORM_ID = "proposal-form-id"; export const ProposalButton: React.FC = ({ contract }) => { - const { isOpen, onOpen, onClose } = useDisclosure(); - + const [open, setOpen] = useState(false); const sendTx = useSendAndConfirmTransaction(); - + const { + register, + handleSubmit, + formState: { errors }, + } = useForm<{ description: string }>(); + const trackEvent = useTrack(); return ( - <> - Create new proposal }} - footer={{ - children: ( - <> - - - Submit Proposal - - - ), - }} - > - - - - + + + + + + + Create new proposal + +
{ + const tx = VoteExt.propose({ + contract, + calldatas: ["0x"], + values: [0n], + targets: [contract.address], + description: data.description, + }); + toast.promise( + sendTx.mutateAsync(tx, { + onSuccess: () => { + trackEvent({ + category: "vote", + action: "create-proposal", + label: "success", + }); + setOpen(false); + }, + onError: (error) => { + console.error(error); + trackEvent({ + category: "vote", + action: "create-proposal", + label: "error", + error, + }); + }, + }), + { + loading: "Creating proposal...", + success: "Proposal created successfully", + error: "Failed to create proposal", + }, + ); + })} + > + + Description +