Skip to content

Commit 55ccbb0

Browse files
committed
Update erc1155 airdrop form
1 parent 45fcfb1 commit 55ccbb0

File tree

5 files changed

+250
-536
lines changed

5 files changed

+250
-536
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/components/airdrop-tab.tsx

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
"use client";
22

3-
import { Flex, useDisclosure } from "@chakra-ui/react";
3+
import {
4+
Sheet,
5+
SheetContent,
6+
SheetHeader,
7+
SheetTitle,
8+
SheetTrigger,
9+
} from "@/components/ui/sheet";
10+
import { Flex } from "@chakra-ui/react";
411
import { TransactionButton } from "components/buttons/TransactionButton";
512
import { useTrack } from "hooks/analytics/useTrack";
613
import { useTxNotifications } from "hooks/useTxNotifications";
714
import { UploadIcon } from "lucide-react";
15+
import { useState } from "react";
816
import { useForm } from "react-hook-form";
917
import type { ThirdwebContract } from "thirdweb";
1018
import { multicall } from "thirdweb/extensions/common";
1119
import { balanceOf, encodeSafeTransferFrom } from "thirdweb/extensions/erc1155";
1220
import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
1321
import { Button, Text } from "tw-components";
14-
import { type AirdropAddressInput, AirdropUpload } from "./airdrop-upload";
22+
import {
23+
type AirdropAddressInput,
24+
AirdropUpload,
25+
} from "../../../tokens/components/airdrop-upload";
1526

1627
interface AirdropTabProps {
1728
contract: ThirdwebContract;
@@ -31,18 +42,15 @@ const AirdropTab: React.FC<AirdropTabProps> = ({ contract, tokenId }) => {
3142
defaultValues: { addresses: [] },
3243
});
3344
const trackEvent = useTrack();
34-
35-
const { isOpen, onOpen, onClose } = useDisclosure();
36-
3745
const { mutate, isPending } = useSendAndConfirmTransaction();
38-
3946
const { onSuccess, onError } = useTxNotifications(
4047
"Airdrop successful",
4148
"Error transferring",
4249
contract,
4350
);
4451

4552
const addresses = watch("addresses");
53+
const [open, setOpen] = useState(false);
4654

4755
return (
4856
<div className="flex w-full flex-col gap-2">
@@ -109,22 +117,29 @@ const AirdropTab: React.FC<AirdropTabProps> = ({ contract, tokenId }) => {
109117
>
110118
<div className="flex flex-col gap-2">
111119
<div className="mb-3 flex w-full flex-col gap-6 md:flex-row">
112-
<AirdropUpload
113-
isOpen={isOpen}
114-
onClose={onClose}
115-
setAirdrop={(value) =>
116-
setValue("addresses", value, { shouldDirty: true })
117-
}
118-
/>
119120
<Flex direction={{ base: "column", md: "row" }} gap={4}>
120-
<Button
121-
colorScheme="primary"
122-
borderRadius="md"
123-
onClick={onOpen}
124-
rightIcon={<UploadIcon className="size-5" />}
125-
>
126-
Upload addresses
127-
</Button>
121+
<Sheet open={open} onOpenChange={setOpen}>
122+
<SheetTrigger asChild>
123+
<Button
124+
colorScheme="primary"
125+
borderRadius="md"
126+
rightIcon={<UploadIcon className="size-5" />}
127+
>
128+
Upload addresses
129+
</Button>
130+
</SheetTrigger>
131+
<SheetContent className="z-[10000] overflow-y-auto sm:w-[540px] sm:max-w-[90%] lg:w-[700px]">
132+
<SheetHeader>
133+
<SheetTitle>Aidrop NFTs</SheetTitle>
134+
</SheetHeader>
135+
<AirdropUpload
136+
onClose={() => setOpen(false)}
137+
setAirdrop={(value) =>
138+
setValue("addresses", value, { shouldDirty: true })
139+
}
140+
/>
141+
</SheetContent>
142+
</Sheet>
128143

129144
<Flex
130145
gap={2}

0 commit comments

Comments
 (0)