Skip to content

Commit

Permalink
feat: add negate component for ability to mint
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Dec 12, 2022
1 parent 181dc3c commit 21ef5b3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Fragment, PropsWithChildren } from 'react';

import { BareComponentProps } from '../../../../common';
import { useTieredSalesContext } from '../providers/TieredSalesProvider';

type Props = PropsWithChildren<
BareComponentProps & {
loadingMask?: React.ReactNode;
tierId?: number;
}
>;

export const TieredSalesIfWalletCannotMint = ({
as,
loadingMask = '...',
tierId,
children,
...attributes
}: Props) => {
const {
data: { canMint },
} = useTieredSalesContext();

const Component =
as || (attributes.className || attributes.style ? 'span' : Fragment);

return (
<Component {...attributes}>
{loadingMask && canMint === undefined ? (
<>{loadingMask}</>
) : !canMint ? (
<>{children}</>
) : null}
</Component>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './TieredSalesEligibleAmount';
export * from './TieredSalesIfNotSoldOut';
export * from './TieredSalesIfSoldOut';
export * from './TieredSalesIfWalletCanMint';
export * from './TieredSalesIfWalletCannotMint';
export * from './TieredSalesMaxAllocation';
export * from './TieredSalesMaxSupply';
export * from './TieredSalesMintButton';
Expand Down

0 comments on commit 21ef5b3

Please sign in to comment.