* Make nft drop contracts use custom contract page * Fix claim conditions detection of token drop * Hide tab until we fix erc20 cc * Fix hooks * Fix lgtm * Add MinterOnly checks * Only show burn/transfer/airdrop if balance > 0 * Fix token balance * Fix lgtm * Redirect old urls * Delete console.logs * Fix import * Add claim conditions banner * Use old code tab for prebuilts * Disable add button when conditions are saving * Only show banner to admins * Remove eslint disable * Use activeChainId * Don't render Drawer if not minter * Clean stuff * Stop breaking react * Improvypvyvpy * Show button but disable it * Save omg Co-authored-by: Jonas Daniels <[email protected]>
41 lines
932 B
TypeScript
41 lines
932 B
TypeScript
import { useIsAdmin, useIsAdminOrSelf } from "@3rdweb-sdk/react";
|
|
import { ValidContractInstance } from "@thirdweb-dev/sdk";
|
|
import { ComponentWithChildren } from "types/component-with-children";
|
|
|
|
interface AdminOnlyProps {
|
|
contract?: ValidContractInstance;
|
|
fallback?: JSX.Element;
|
|
}
|
|
|
|
export const AdminOnly: ComponentWithChildren<AdminOnlyProps> = ({
|
|
children,
|
|
contract,
|
|
fallback,
|
|
}) => {
|
|
const isAdmin = useIsAdmin(contract);
|
|
if (!isAdmin) {
|
|
return fallback ?? null;
|
|
}
|
|
return <>{children}</>;
|
|
};
|
|
|
|
interface AdminOrSelfOnlyProps extends AdminOnlyProps {
|
|
/**
|
|
* The address of the account to check against
|
|
*/
|
|
self: string;
|
|
}
|
|
|
|
export const AdminOrSelfOnly: ComponentWithChildren<AdminOrSelfOnlyProps> = ({
|
|
children,
|
|
self,
|
|
fallback,
|
|
contract,
|
|
}) => {
|
|
const isAdminOrSelf = useIsAdminOrSelf(contract, self);
|
|
if (!isAdminOrSelf) {
|
|
return fallback ?? null;
|
|
}
|
|
return <>{children}</>;
|
|
};
|