* initial /publish * custom contract init (#27) * clean up customContract interface for the moment * upgrade sdk & make multi-uri publish work * upgraded dependencies and customContract workflow * more custom contract stuff * publish ui update * basic publish & deploy flow works * cleanup eslint * update sdk * add contract address to toast and log it out * integrate newer sdk version * upgrade deps * full deploy loop functional with updated sdk * upgrade sdk * upgrade deps * upgrade sdk to fix big contracts * full flow! * update deps * update to latest sdk, support custom contracts in contracts list * one more sdk update * cache keys // analytics mapping * make mr. typescript happy * try catch the resolve type (need to fix it in SDK) * fix type check * upgrade sdk & handle `ipfs=` from cli * fix yarn lock * publishBatch * add very basic code tab * fix build * init cleaning up code tab * fix zindex issue * update code segments * prep some more stuff * remove duplication * this wont build and that is ok * fix build * upgrade react package * add super basic mint button * update sdk * clean up some custom contract interfaces a bit * updated sdks all around * change minting to useNFTMint * append contract.functions to signatures so you can copy paste * add byoc page tracking * new publish page * slightly fix hook * custom deploy form update * completely overhauled deploy flow now * some improvements, empty states etc * only show coming soon on non-mumbai * tw-components * fix contract items table * upgrade deps * fix secondary cta * fix string * fixed things more * fix up code-block * small code tab improvements * Add mint drawer if ERC721 (#95) * Update thumbnail/title/desc * Add custom nft mint * Fix FormHelperText * Delete unused imports * Remove imports * fix build issues etc * Add token drop (#93) * Update thumbnail/title/desc * Merge * wip * Token drop page working * Add claim phases tab, add TokenDrop to conditionals * update font size * NFTs/token conditional * Add QuantityInputWithUnlimited * Update SDK * Fix unlimited * Remove fontSize Co-authored-by: Jonas Daniels <[email protected]> * set tokendrop back to coming soon * remove "@dev" tag for sdk installation * fix mappings file * fix indentation on custom code tab * ship central 🚢 * fix build Co-authored-by: Joaquim Verges <[email protected]> Co-authored-by: Jake Loo <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]>
258 lines
7.2 KiB
TypeScript
258 lines
7.2 KiB
TypeScript
import {
|
|
Box,
|
|
BoxProps,
|
|
Center,
|
|
Code,
|
|
Flex,
|
|
HStack,
|
|
Icon,
|
|
IconButton,
|
|
Image,
|
|
ImageProps,
|
|
Portal,
|
|
Select,
|
|
Table,
|
|
Tbody,
|
|
Td,
|
|
Th,
|
|
Thead,
|
|
Tr,
|
|
} from "@chakra-ui/react";
|
|
import { NFTMetadata } from "@thirdweb-dev/sdk";
|
|
import { useImageFileOrUrl } from "hooks/useImageFileOrUrl";
|
|
import { useMemo } from "react";
|
|
import {
|
|
MdFirstPage,
|
|
MdLastPage,
|
|
MdNavigateBefore,
|
|
MdNavigateNext,
|
|
} from "react-icons/md";
|
|
import { Column, usePagination, useTable } from "react-table";
|
|
import { Text } from "tw-components";
|
|
import { parseDescription } from "utils/parseDescription";
|
|
|
|
const FileImage: React.FC<ImageProps> = ({ src, ...props }) => {
|
|
const img = useImageFileOrUrl(src);
|
|
return <Image {...props} src={img} />;
|
|
};
|
|
|
|
const FileVideo: React.FC<
|
|
BoxProps & Omit<React.ComponentProps<"video">, "ref">
|
|
> = ({ src, ...props }) => {
|
|
const video = useImageFileOrUrl(src);
|
|
return <Box as="video" {...props} src={video} />;
|
|
};
|
|
interface BatchTableProps {
|
|
data: NFTMetadata[];
|
|
portalRef: React.RefObject<HTMLDivElement>;
|
|
nextTokenIdToMint?: number;
|
|
}
|
|
|
|
export const BatchTable: React.FC<BatchTableProps> = ({
|
|
data,
|
|
portalRef,
|
|
nextTokenIdToMint,
|
|
}) => {
|
|
const columns = useMemo(() => {
|
|
return [
|
|
{
|
|
Header: "Token ID",
|
|
accessor: (_row, index) =>
|
|
nextTokenIdToMint ? nextTokenIdToMint + index : index,
|
|
},
|
|
{
|
|
Header: "Image",
|
|
accessor: (row) => row.image,
|
|
Cell: ({ cell: { value } }: { cell: { value?: string } }) =>
|
|
// We do this so users can see a preview of their IPFS hashes when batch uploading
|
|
typeof value === "string" && value.startsWith("ipfs://") ? (
|
|
<FileImage
|
|
flexShrink={0}
|
|
boxSize={24}
|
|
objectFit="contain"
|
|
src={value.replace(
|
|
"ipfs://",
|
|
`${process.env.NEXT_PUBLIC_IPFS_GATEWAY_URL}/` || "",
|
|
)}
|
|
alt=""
|
|
/>
|
|
) : value ? (
|
|
<FileImage
|
|
flexShrink={0}
|
|
boxSize={24}
|
|
objectFit="contain"
|
|
src={value}
|
|
alt=""
|
|
/>
|
|
) : null,
|
|
},
|
|
{
|
|
Header: "Animation Url",
|
|
accessor: (row) => row.animation_url,
|
|
Cell: ({ cell: { value } }: { cell: { value?: string } }) =>
|
|
// We do this so users can see a preview of their IPFS hashes when batch uploading
|
|
typeof value === "string" && value.startsWith("ipfs://") ? (
|
|
<FileVideo
|
|
flexShrink={0}
|
|
boxSize={24}
|
|
objectFit="contain"
|
|
src={value.replace(
|
|
"ipfs://",
|
|
`${process.env.NEXT_PUBLIC_IPFS_GATEWAY_URL}/` || "",
|
|
)}
|
|
autoPlay
|
|
playsInline
|
|
muted
|
|
loop
|
|
/>
|
|
) : value ? (
|
|
<FileVideo
|
|
flexShrink={0}
|
|
boxSize={24}
|
|
objectFit="contain"
|
|
src={value}
|
|
autoPlay
|
|
playsInline
|
|
muted
|
|
loop
|
|
/>
|
|
) : null,
|
|
},
|
|
{ Header: "Name", accessor: (row) => row.name },
|
|
{
|
|
Header: "Description",
|
|
accessor: (row) => parseDescription(row.description),
|
|
},
|
|
{
|
|
Header: "Properties",
|
|
accessor: (row) => row.attributes || row.properties,
|
|
Cell: ({ cell }: { cell: any }) => (
|
|
<Code whiteSpace="pre">{JSON.stringify(cell.value, null, 2)}</Code>
|
|
),
|
|
},
|
|
{ Header: "External URL", accessor: (row) => row.external_url },
|
|
{ Header: "Background Color", accessor: (row) => row.background_color },
|
|
] as Column<NFTMetadata>[];
|
|
}, [nextTokenIdToMint]);
|
|
|
|
const {
|
|
getTableProps,
|
|
getTableBodyProps,
|
|
headerGroups,
|
|
prepareRow,
|
|
// Instead of using 'rows', we'll use page,
|
|
page,
|
|
// which has only the rows for the active page
|
|
|
|
// The rest of these things are super handy, too ;)
|
|
canPreviousPage,
|
|
canNextPage,
|
|
pageOptions,
|
|
pageCount,
|
|
gotoPage,
|
|
nextPage,
|
|
previousPage,
|
|
setPageSize,
|
|
state: { pageIndex, pageSize },
|
|
} = useTable(
|
|
{
|
|
columns,
|
|
data,
|
|
initialState: {
|
|
pageSize: 50,
|
|
pageIndex: 0,
|
|
},
|
|
},
|
|
usePagination,
|
|
);
|
|
|
|
// Render the UI for your table
|
|
return (
|
|
<Flex flexGrow={1} overflow="auto">
|
|
<Box w="100%">
|
|
<Table {...getTableProps()}>
|
|
<Thead>
|
|
{headerGroups.map((headerGroup) => (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Tr {...headerGroup.getHeaderGroupProps()}>
|
|
{headerGroup.headers.map((column) => (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Th {...column.getHeaderProps()}>
|
|
<Text as="label" size="label.md">
|
|
{column.render("Header")}
|
|
</Text>
|
|
</Th>
|
|
))}
|
|
</Tr>
|
|
))}
|
|
</Thead>
|
|
<Tbody {...getTableBodyProps()}>
|
|
{page.map((row) => {
|
|
prepareRow(row);
|
|
return (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Tr {...row.getRowProps()}>
|
|
{row.cells.map((cell) => {
|
|
return (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Td {...cell.getCellProps()}>{cell.render("Cell")}</Td>
|
|
);
|
|
})}
|
|
</Tr>
|
|
);
|
|
})}
|
|
</Tbody>
|
|
</Table>
|
|
</Box>
|
|
|
|
<Portal containerRef={portalRef}>
|
|
<Center w="100%">
|
|
<HStack>
|
|
<IconButton
|
|
isDisabled={!canPreviousPage}
|
|
aria-label="first page"
|
|
icon={<Icon as={MdFirstPage} />}
|
|
onClick={() => gotoPage(0)}
|
|
/>
|
|
<IconButton
|
|
isDisabled={!canPreviousPage}
|
|
aria-label="previous page"
|
|
icon={<Icon as={MdNavigateBefore} />}
|
|
onClick={() => previousPage()}
|
|
/>
|
|
<Text whiteSpace="nowrap">
|
|
Page <strong>{pageIndex + 1}</strong> of{" "}
|
|
<strong>{pageOptions.length}</strong>
|
|
</Text>
|
|
<IconButton
|
|
isDisabled={!canNextPage}
|
|
aria-label="next page"
|
|
icon={<Icon as={MdNavigateNext} />}
|
|
onClick={() => nextPage()}
|
|
/>
|
|
<IconButton
|
|
isDisabled={!canNextPage}
|
|
aria-label="last page"
|
|
icon={<Icon as={MdLastPage} />}
|
|
onClick={() => gotoPage(pageCount - 1)}
|
|
/>
|
|
|
|
<Select
|
|
onChange={(e) => {
|
|
setPageSize(parseInt(e.target.value as string, 10));
|
|
}}
|
|
value={pageSize}
|
|
>
|
|
<option value="25">25</option>
|
|
<option value="50">50</option>
|
|
<option value="100">100</option>
|
|
<option value="250">250</option>
|
|
<option value="500">500</option>
|
|
</Select>
|
|
</HStack>
|
|
</Center>
|
|
</Portal>
|
|
</Flex>
|
|
);
|
|
};
|